Skip to content

Commit e15ea7a

Browse files
authored
fix(tap-agent): check horizon is active before checking for escrow (#776)
1 parent 4e62220 commit e15ea7a

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

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)