@@ -25,12 +25,14 @@ use tap_aggregator::grpc::{
2525 v1:: tap_aggregator_client:: TapAggregatorClient as AggregatorV1 ,
2626 v2:: tap_aggregator_client:: TapAggregatorClient as AggregatorV2 ,
2727} ;
28- use thegraph_core:: alloy:: {
29- hex:: ToHexExt ,
30- primitives:: { Address , U256 } ,
31- sol_types:: Eip712Domain ,
28+ use thegraph_core:: {
29+ alloy:: {
30+ hex:: ToHexExt ,
31+ primitives:: { Address , U256 } ,
32+ sol_types:: Eip712Domain ,
33+ } ,
34+ AllocationId as AllocationIdCore , CollectionId ,
3235} ;
33- use thegraph_core:: { AllocationId as AllocationIdCore , CollectionId } ;
3436use tokio:: { sync:: watch:: Receiver , task:: JoinHandle } ;
3537use tonic:: transport:: { Channel , Endpoint } ;
3638use tracing:: Level ;
@@ -145,7 +147,8 @@ impl From<tap_graph::SignedRav> for RavInformation {
145147impl From < & tap_graph:: v2:: SignedRav > for RavInformation {
146148 fn from ( value : & tap_graph:: v2:: SignedRav ) -> Self {
147149 RavInformation {
148- allocation_id : AllocationIdCore :: from ( CollectionId :: from ( value. message . collectionId ) ) . into_inner ( ) ,
150+ allocation_id : AllocationIdCore :: from ( CollectionId :: from ( value. message . collectionId ) )
151+ . into_inner ( ) ,
149152 value_aggregate : value. message . valueAggregate ,
150153 }
151154 }
@@ -214,9 +217,9 @@ pub enum SenderAccountMessage {
214217 /// as well as requesting the underlaying allocation rav request
215218 ///
216219 /// Custom behavior is defined in [ReceiptFees]
217- UpdateReceiptFees ( Address , ReceiptFees ) ,
220+ UpdateReceiptFees ( AllocationId , ReceiptFees ) ,
218221 /// Updates the counter for invalid receipts and verify to deny sender
219- UpdateInvalidReceiptFees ( Address , UnaggregatedReceipts ) ,
222+ UpdateInvalidReceiptFees ( AllocationId , UnaggregatedReceipts ) ,
220223 /// Update rav tracker
221224 UpdateRav ( RavInformation ) ,
222225 #[ cfg( test) ]
@@ -475,7 +478,7 @@ impl State {
475478 . build ( ) ;
476479
477480 SenderAllocation :: < Horizon > :: spawn_linked (
478- Some ( self . format_sender_allocation ( & id) ) ,
481+ Some ( self . format_sender_allocation ( & id. as_address ( ) ) ) ,
479482 SenderAllocation :: default ( ) ,
480483 args,
481484 sender_account_ref. get_cell ( ) ,
@@ -1061,7 +1064,7 @@ impl Actor for SenderAccount {
10611064
10621065 state
10631066 . invalid_receipts_tracker
1064- . update ( allocation_id, unaggregated_fees. value ) ;
1067+ . update ( allocation_id. address ( ) , unaggregated_fees. value ) ;
10651068
10661069 // invalid receipts can't go down
10671070 let should_deny = !state. denied && state. deny_condition_reached ( ) ;
@@ -1098,7 +1101,7 @@ impl Actor for SenderAccount {
10981101 // add new value
10991102 state
11001103 . sender_fee_tracker
1101- . add ( allocation_id, value, timestamp_ns) ;
1104+ . add ( allocation_id. address ( ) , value, timestamp_ns) ;
11021105
11031106 SENDER_FEE_TRACKER
11041107 . with_label_values ( & [ & state. sender . to_string ( ) ] )
@@ -1111,16 +1114,16 @@ impl Actor for SenderAccount {
11111114 . set (
11121115 state
11131116 . sender_fee_tracker
1114- . get_total_fee_for_allocation ( & allocation_id)
1117+ . get_total_fee_for_allocation ( & allocation_id. address ( ) )
11151118 . map ( |fee| fee. value )
11161119 . unwrap_or_default ( ) as f64 ,
11171120 ) ;
11181121 }
11191122 ReceiptFees :: RavRequestResponse ( fees, rav_result) => {
1120- state. finalize_rav_request ( allocation_id, ( fees, rav_result) ) ;
1123+ state. finalize_rav_request ( allocation_id. address ( ) , ( fees, rav_result) ) ;
11211124 }
11221125 ReceiptFees :: UpdateValue ( unaggregated_fees) => {
1123- state. update_sender_fee ( allocation_id, unaggregated_fees) ;
1126+ state. update_sender_fee ( allocation_id. address ( ) , unaggregated_fees) ;
11241127 }
11251128 ReceiptFees :: Retry => { }
11261129 }
@@ -1138,8 +1141,10 @@ impl Actor for SenderAccount {
11381141 let total_fee_outside_buffer = state. sender_fee_tracker . get_ravable_total_fee ( ) ;
11391142 let total_counter_for_allocation = state
11401143 . sender_fee_tracker
1141- . get_count_outside_buffer_for_allocation ( & allocation_id) ;
1142- let can_trigger_rav = state. sender_fee_tracker . can_trigger_rav ( allocation_id) ;
1144+ . get_count_outside_buffer_for_allocation ( & allocation_id. address ( ) ) ;
1145+ let can_trigger_rav = state
1146+ . sender_fee_tracker
1147+ . can_trigger_rav ( allocation_id. address ( ) ) ;
11431148 let counter_greater_receipt_limit = total_counter_for_allocation
11441149 >= state. config . rav_request_receipt_limit
11451150 && can_trigger_rav;
@@ -1159,7 +1164,9 @@ impl Actor for SenderAccount {
11591164 %allocation_id,
11601165 "Total counter greater than the receipt limit per rav. Triggering RAV request"
11611166 ) ;
1162- state. rav_request_for_allocation ( allocation_id) . await
1167+ state
1168+ . rav_request_for_allocation ( allocation_id. address ( ) )
1169+ . await
11631170 } else {
11641171 Ok ( ( ) )
11651172 } ;
@@ -1368,7 +1375,7 @@ impl Actor for SenderAccount {
13681375
13691376 // check for deny conditions
13701377 let _ = myself. cast ( SenderAccountMessage :: UpdateReceiptFees (
1371- allocation_id,
1378+ AllocationId :: Legacy ( AllocationIdCore :: from ( allocation_id) ) ,
13721379 ReceiptFees :: Retry ,
13731380 ) ) ;
13741381
@@ -1472,7 +1479,10 @@ pub mod tests {
14721479 flush_messages, pgpool, ALLOCATION_ID_0 , ALLOCATION_ID_1 , TAP_SENDER as SENDER ,
14731480 TAP_SIGNER as SIGNER ,
14741481 } ;
1475- use thegraph_core:: alloy:: { hex:: ToHexExt , primitives:: U256 } ;
1482+ use thegraph_core:: {
1483+ alloy:: { hex:: ToHexExt , primitives:: U256 } ,
1484+ AllocationId as AllocationIdCore ,
1485+ } ;
14761486 use tokio:: sync:: mpsc;
14771487 use wiremock:: {
14781488 matchers:: { body_string_contains, method} ,
@@ -1566,7 +1576,9 @@ pub mod tests {
15661576 . call ( )
15671577 . await ;
15681578
1569- let allocation_ids = HashSet :: from_iter ( [ AllocationId :: Legacy ( ALLOCATION_ID_0 ) ] ) ;
1579+ let allocation_ids = HashSet :: from_iter ( [ AllocationId :: Legacy ( AllocationIdCore :: from (
1580+ ALLOCATION_ID_0 ,
1581+ ) ) ] ) ;
15701582 // we expect it to create a sender allocation
15711583 sender_account
15721584 . cast ( SenderAccountMessage :: UpdateAllocationIds (
@@ -1660,7 +1672,7 @@ pub mod tests {
16601672 // we expect it to create a sender allocation
16611673 sender_account
16621674 . cast ( SenderAccountMessage :: NewAllocationId ( AllocationId :: Legacy (
1663- ALLOCATION_ID_0 ,
1675+ AllocationIdCore :: from ( ALLOCATION_ID_0 ) ,
16641676 ) ) )
16651677 . unwrap ( ) ;
16661678
@@ -1674,9 +1686,11 @@ pub mod tests {
16741686 // nothing should change because we already created
16751687 sender_account
16761688 . cast ( SenderAccountMessage :: UpdateAllocationIds (
1677- vec ! [ AllocationId :: Legacy ( ALLOCATION_ID_0 ) ]
1678- . into_iter ( )
1679- . collect ( ) ,
1689+ vec ! [ AllocationId :: Legacy ( AllocationIdCore :: from(
1690+ ALLOCATION_ID_0 ,
1691+ ) ) ]
1692+ . into_iter ( )
1693+ . collect ( ) ,
16801694 ) )
16811695 . unwrap ( ) ;
16821696
@@ -1754,7 +1768,7 @@ pub mod tests {
17541768 basic_sender_account
17551769 . sender_account
17561770 . cast ( SenderAccountMessage :: UpdateReceiptFees (
1757- ALLOCATION_ID_0 ,
1771+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
17581772 ReceiptFees :: NewReceipt ( TRIGGER_VALUE - 1 , get_current_timestamp_u64_ns ( ) ) ,
17591773 ) )
17601774 . unwrap ( ) ;
@@ -1784,7 +1798,7 @@ pub mod tests {
17841798 basic_sender_account
17851799 . sender_account
17861800 . cast ( SenderAccountMessage :: UpdateReceiptFees (
1787- ALLOCATION_ID_0 ,
1801+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
17881802 ReceiptFees :: NewReceipt ( TRIGGER_VALUE , get_current_timestamp_u64_ns ( ) ) ,
17891803 ) )
17901804 . unwrap ( ) ;
@@ -1798,7 +1812,7 @@ pub mod tests {
17981812 basic_sender_account
17991813 . sender_account
18001814 . cast ( SenderAccountMessage :: UpdateReceiptFees (
1801- ALLOCATION_ID_0 ,
1815+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
18021816 ReceiptFees :: Retry ,
18031817 ) )
18041818 . unwrap ( ) ;
@@ -1827,7 +1841,7 @@ pub mod tests {
18271841
18281842 sender_account
18291843 . cast ( SenderAccountMessage :: UpdateReceiptFees (
1830- ALLOCATION_ID_0 ,
1844+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
18311845 ReceiptFees :: NewReceipt ( 1 , get_current_timestamp_u64_ns ( ) ) ,
18321846 ) )
18331847 . unwrap ( ) ;
@@ -1837,7 +1851,7 @@ pub mod tests {
18371851
18381852 sender_account
18391853 . cast ( SenderAccountMessage :: UpdateReceiptFees (
1840- ALLOCATION_ID_0 ,
1854+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
18411855 ReceiptFees :: NewReceipt ( 1 , get_current_timestamp_u64_ns ( ) ) ,
18421856 ) )
18431857 . unwrap ( ) ;
@@ -1848,7 +1862,7 @@ pub mod tests {
18481862
18491863 sender_account
18501864 . cast ( SenderAccountMessage :: UpdateReceiptFees (
1851- ALLOCATION_ID_0 ,
1865+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
18521866 ReceiptFees :: Retry ,
18531867 ) )
18541868 . unwrap ( ) ;
@@ -1867,9 +1881,11 @@ pub mod tests {
18671881 let ( sender_account, _, prefix, _) = create_sender_account ( )
18681882 . pgpool ( pgpool)
18691883 . initial_allocation (
1870- vec ! [ AllocationId :: Legacy ( ALLOCATION_ID_0 ) ]
1871- . into_iter ( )
1872- . collect ( ) ,
1884+ vec ! [ AllocationId :: Legacy ( AllocationIdCore :: from(
1885+ ALLOCATION_ID_0 ,
1886+ ) ) ]
1887+ . into_iter ( )
1888+ . collect ( ) ,
18731889 )
18741890 . escrow_subgraph_endpoint ( & mock_escrow_subgraph. uri ( ) )
18751891 . call ( )
@@ -1954,7 +1970,7 @@ pub mod tests {
19541970
19551971 sender_account
19561972 . cast ( SenderAccountMessage :: UpdateReceiptFees (
1957- ALLOCATION_ID_0 ,
1973+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
19581974 ReceiptFees :: NewReceipt ( TRIGGER_VALUE , get_current_timestamp_u64_ns ( ) ) ,
19591975 ) )
19601976 . unwrap ( ) ;
@@ -1990,7 +2006,7 @@ pub mod tests {
19902006 ( $value: expr) => {
19912007 sender_account
19922008 . cast( SenderAccountMessage :: UpdateReceiptFees (
1993- ALLOCATION_ID_0 ,
2009+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
19942010 ReceiptFees :: UpdateValue ( UnaggregatedReceipts {
19952011 value: $value,
19962012 last_id: 11 ,
@@ -2007,7 +2023,7 @@ pub mod tests {
20072023 ( $value: expr) => {
20082024 sender_account
20092025 . cast( SenderAccountMessage :: UpdateInvalidReceiptFees (
2010- ALLOCATION_ID_0 ,
2026+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
20112027 UnaggregatedReceipts {
20122028 value: $value,
20132029 last_id: 11 ,
@@ -2143,7 +2159,7 @@ pub mod tests {
21432159 ( $value: expr) => {
21442160 sender_account
21452161 . cast( SenderAccountMessage :: UpdateReceiptFees (
2146- ALLOCATION_ID_0 ,
2162+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
21472163 ReceiptFees :: UpdateValue ( UnaggregatedReceipts {
21482164 value: $value,
21492165 last_id: 11 ,
@@ -2433,17 +2449,17 @@ pub mod tests {
24332449 // set retry
24342450 sender_account
24352451 . cast ( SenderAccountMessage :: UpdateReceiptFees (
2436- ALLOCATION_ID_0 ,
2452+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
24372453 ReceiptFees :: NewReceipt ( TRIGGER_VALUE , get_current_timestamp_u64_ns ( ) ) ,
24382454 ) )
24392455 . unwrap ( ) ;
24402456 let msg = msg_receiver. recv ( ) . await . expect ( "Channel failed" ) ;
24412457 assert ! ( matches!(
24422458 msg,
24432459 SenderAccountMessage :: UpdateReceiptFees (
2444- ALLOCATION_ID_0 ,
2460+ AllocationId :: Legacy ( allocation_id ) ,
24452461 ReceiptFees :: NewReceipt ( TRIGGER_VALUE , _)
2446- )
2462+ ) if allocation_id == AllocationIdCore :: from ( ALLOCATION_ID_0 )
24472463 ) ) ;
24482464
24492465 let deny = call ! ( sender_account, SenderAccountMessage :: GetDeny ) . unwrap ( ) ;
0 commit comments