Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions crates/tap-agent/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ use indexer_config::{
SubgraphConfig, SubgraphsConfig, TapConfig,
};
use indexer_monitor::{
escrow_accounts_v1, escrow_accounts_v2, indexer_allocations, DeploymentDetails, SubgraphClient,
empty_escrow_accounts_watcher, escrow_accounts_v1, escrow_accounts_v2, indexer_allocations,
DeploymentDetails, SubgraphClient,
};
use ractor::{concurrency::JoinHandle, Actor, ActorRef};
use sender_account::SenderAccountConfig;
Expand Down Expand Up @@ -165,16 +166,6 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
.await
.expect("Error creating escrow_accounts channel");

// V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
let escrow_accounts_v2 = escrow_accounts_v2(
network_subgraph,
*indexer_address,
*network_sync_interval,
false,
)
.await
.expect("Error creating escrow_accounts_v2 channel");

// Determine if we should check for Horizon contracts and potentially enable hybrid mode:
// - If horizon.enabled = false: Pure legacy mode, no Horizon detection
// - If horizon.enabled = true: Check if Horizon contracts are active in the network
Expand Down Expand Up @@ -205,13 +196,29 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
false
};

// Create V2 escrow accounts watcher only if Horizon is active
// V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
let escrow_accounts_v2 = if is_horizon_enabled {
escrow_accounts_v2(
network_subgraph,
*indexer_address,
*network_sync_interval,
false,
)
.await
.expect("Error creating escrow_accounts_v2 channel")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reasonable crash as it's a feature mismatch?

} else {
// Create a dummy watcher that never updates for consistency
empty_escrow_accounts_watcher()
};

// In both modes we need both watchers for the hybrid processing
let (escrow_accounts_v1_final, escrow_accounts_v2_final) = if is_horizon_enabled {
tracing::info!("TAP Agent: Horizon migration mode - processing existing V1 receipts and new V2 receipts");
(escrow_accounts_v1, escrow_accounts_v2)
} else {
tracing::info!("TAP Agent: Legacy mode - V1 receipts only");
(escrow_accounts_v1, escrow_accounts_v2) // Still keep V2 watcher for consistency
(escrow_accounts_v1, escrow_accounts_v2)
};

let config = Box::leak(Box::new({
Expand Down
Loading