Skip to content

Commit 7bcacfc

Browse files
committed
fix(tap-agent): check horizon is active before checking for escrow
1 parent 4e62220 commit 7bcacfc

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

crates/attestation/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fn wallet_for_allocation(
191191

192192
let wallet_address = wallet.address();
193193

194-
if i < 5 || (i % 20 == 0) {
194+
if i < 5 || i.is_multiple_of(20) {
195195
// Log first 5 attempts and every 20th attempt
196196
tracing::debug!(
197197
"Derivation attempt: epoch={}, index={}, derived_address={}, target_allocation={}",

crates/tap-agent/src/agent.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ use indexer_config::{
4040
SubgraphConfig, SubgraphsConfig, TapConfig,
4141
};
4242
use indexer_monitor::{
43-
escrow_accounts_v1, escrow_accounts_v2, indexer_allocations, DeploymentDetails, SubgraphClient,
43+
empty_escrow_accounts_watcher, escrow_accounts_v1, escrow_accounts_v2, indexer_allocations,
44+
DeploymentDetails, SubgraphClient,
4445
};
4546
use ractor::{concurrency::JoinHandle, Actor, ActorRef};
4647
use sender_account::SenderAccountConfig;
@@ -165,16 +166,6 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
165166
.await
166167
.expect("Error creating escrow_accounts channel");
167168

168-
// V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
169-
let escrow_accounts_v2 = escrow_accounts_v2(
170-
network_subgraph,
171-
*indexer_address,
172-
*network_sync_interval,
173-
false,
174-
)
175-
.await
176-
.expect("Error creating escrow_accounts_v2 channel");
177-
178169
// Determine if we should check for Horizon contracts and potentially enable hybrid mode:
179170
// - If horizon.enabled = false: Pure legacy mode, no Horizon detection
180171
// - If horizon.enabled = true: Check if Horizon contracts are active in the network
@@ -205,13 +196,29 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
205196
false
206197
};
207198

199+
// Create V2 escrow accounts watcher only if Horizon is active
200+
// V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
201+
let escrow_accounts_v2 = if is_horizon_enabled {
202+
escrow_accounts_v2(
203+
network_subgraph,
204+
*indexer_address,
205+
*network_sync_interval,
206+
false,
207+
)
208+
.await
209+
.expect("Error creating escrow_accounts_v2 channel")
210+
} else {
211+
// Create a dummy watcher that never updates for consistency
212+
empty_escrow_accounts_watcher()
213+
};
214+
208215
// In both modes we need both watchers for the hybrid processing
209216
let (escrow_accounts_v1_final, escrow_accounts_v2_final) = if is_horizon_enabled {
210217
tracing::info!("TAP Agent: Horizon migration mode - processing existing V1 receipts and new V2 receipts");
211218
(escrow_accounts_v1, escrow_accounts_v2)
212219
} else {
213220
tracing::info!("TAP Agent: Legacy mode - V1 receipts only");
214-
(escrow_accounts_v1, escrow_accounts_v2) // Still keep V2 watcher for consistency
221+
(escrow_accounts_v1, escrow_accounts_v2)
215222
};
216223

217224
let config = Box::leak(Box::new({

0 commit comments

Comments
 (0)