@@ -39,6 +39,8 @@ static RECEIPTS_CREATED: LazyLock<CounterVec> = LazyLock::new(|| {
3939 . unwrap ( )
4040} ) ;
4141
42+ const RETRY_INTERVAL : Duration = Duration :: from_secs ( 30 ) ;
43+
4244/// Notification received by pgnotify for V1 (legacy) receipts
4345///
4446/// This contains a list of properties that are sent by postgres when a V1 receipt is inserted
@@ -231,6 +233,9 @@ pub struct SenderAccountsManagerArgs {
231233 /// Domain separator used for tap
232234 pub domain_separator : Eip712Domain ,
233235
236+ /// Domain separator used for tap v2 (Horizon)
237+ pub domain_separator_v2 : Eip712Domain ,
238+
234239 /// Database connection
235240 pub pgpool : PgPool ,
236241 /// Watcher that returns a map of open and recently closed allocation ids
@@ -262,6 +267,7 @@ pub struct State {
262267
263268 config : & ' static SenderAccountConfig ,
264269 domain_separator : Eip712Domain ,
270+ domain_separator_v2 : Eip712Domain ,
265271 pgpool : PgPool ,
266272 indexer_allocations : Receiver < HashSet < AllocationId > > ,
267273 /// Watcher containing the escrow accounts for v1
@@ -289,6 +295,7 @@ impl Actor for SenderAccountsManager {
289295 SenderAccountsManagerArgs {
290296 config,
291297 domain_separator,
298+ domain_separator_v2,
292299 indexer_allocations,
293300 pgpool,
294301 escrow_accounts_v1,
@@ -299,32 +306,15 @@ impl Actor for SenderAccountsManager {
299306 prefix,
300307 } : Self :: Arguments ,
301308 ) -> Result < Self :: State , ActorProcessingErr > {
302- let is_horizon_active = if config. horizon_enabled {
303- match indexer_monitor:: is_horizon_active ( network_subgraph) . await {
304- Ok ( active) => {
305- if active {
306- tracing:: info!(
307- "Horizon contracts detected - allocations will use Horizon type"
308- ) ;
309- } else {
310- tracing:: info!(
311- "Horizon contracts not active - allocations will use Legacy type"
312- ) ;
313- }
314- active
315- }
316- Err ( e) => {
317- tracing:: warn!(
318- "Failed to detect Horizon contracts: {}. Using Legacy type" ,
319- e
320- ) ;
321- false
322- }
323- }
309+ // we can use config.horizon_enabled directly
310+ // because agent_start method does the horizon smart contract/subgraph validation
311+ // and updates the passed in config accordingly
312+ let is_horizon_active = config. horizon_enabled ;
313+ if is_horizon_active {
314+ tracing:: info!( "Horizon enabled in config - allocations will use Horizon type" ) ;
324315 } else {
325316 tracing:: info!( "Horizon disabled in config - allocations will use Legacy type" ) ;
326- false
327- } ;
317+ }
328318
329319 let indexer_allocations = map_watcher ( indexer_allocations, move |allocation_id| {
330320 let allocations: HashSet < _ > = allocation_id
@@ -403,6 +393,7 @@ impl Actor for SenderAccountsManager {
403393 let mut state = State {
404394 config,
405395 domain_separator,
396+ domain_separator_v2,
406397 sender_ids_v1 : HashSet :: new ( ) ,
407398 sender_ids_v2 : HashSet :: new ( ) ,
408399 new_receipts_watcher_handle_v1 : None ,
@@ -998,18 +989,21 @@ impl State {
998989 allocation_ids : HashSet < AllocationId > ,
999990 sender_type : SenderType ,
1000991 ) -> anyhow:: Result < SenderAccountArgs > {
992+ let escrow_accounts = match sender_type {
993+ SenderType :: Legacy => self . escrow_accounts_v1 . clone ( ) ,
994+ SenderType :: Horizon => self . escrow_accounts_v2 . clone ( ) ,
995+ } ;
996+
1001997 Ok ( SenderAccountArgs {
1002998 config : self . config ,
1003999 pgpool : self . pgpool . clone ( ) ,
10041000 sender_id : * sender_id,
1005- escrow_accounts : match sender_type {
1006- SenderType :: Legacy => self . escrow_accounts_v1 . clone ( ) ,
1007- SenderType :: Horizon => self . escrow_accounts_v2 . clone ( ) ,
1008- } ,
1001+ escrow_accounts,
10091002 indexer_allocations : self . indexer_allocations . clone ( ) ,
10101003 escrow_subgraph : self . escrow_subgraph ,
10111004 network_subgraph : self . network_subgraph ,
10121005 domain_separator : self . domain_separator . clone ( ) ,
1006+ domain_separator_v2 : self . domain_separator_v2 . clone ( ) ,
10131007 sender_aggregator_endpoint : self
10141008 . sender_aggregator_endpoints
10151009 . get ( sender_id)
@@ -1020,7 +1014,7 @@ impl State {
10201014 . clone ( ) ,
10211015 allocation_ids,
10221016 prefix : self . prefix . clone ( ) ,
1023- retry_interval : Duration :: from_secs ( 30 ) ,
1017+ retry_interval : RETRY_INTERVAL ,
10241018 sender_type,
10251019 } )
10261020 }
@@ -1356,7 +1350,7 @@ mod tests {
13561350 create_rav, create_received_receipt, create_sender_accounts_manager,
13571351 generate_random_prefix, get_grpc_url, get_sender_account_config, store_rav,
13581352 store_receipt, ALLOCATION_ID_0 , ALLOCATION_ID_1 , INDEXER , SENDER_2 ,
1359- TAP_EIP712_DOMAIN_SEPARATOR ,
1353+ TAP_EIP712_DOMAIN_SEPARATOR , TAP_EIP712_DOMAIN_SEPARATOR_V2 ,
13601354 } ,
13611355 } ;
13621356 const DUMMY_URL : & str = "http://localhost:1234" ;
@@ -1412,6 +1406,7 @@ mod tests {
14121406 State {
14131407 config,
14141408 domain_separator : TAP_EIP712_DOMAIN_SEPARATOR . clone ( ) ,
1409+ domain_separator_v2 : TAP_EIP712_DOMAIN_SEPARATOR_V2 . clone ( ) ,
14151410 sender_ids_v1 : HashSet :: new ( ) ,
14161411 sender_ids_v2 : HashSet :: new ( ) ,
14171412 new_receipts_watcher_handle_v1 : None ,
0 commit comments