@@ -25,12 +25,14 @@ use tap_aggregator::grpc::{
25
25
v1:: tap_aggregator_client:: TapAggregatorClient as AggregatorV1 ,
26
26
v2:: tap_aggregator_client:: TapAggregatorClient as AggregatorV2 ,
27
27
} ;
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 ,
32
35
} ;
33
- use thegraph_core:: { AllocationId as AllocationIdCore , CollectionId } ;
34
36
use tokio:: { sync:: watch:: Receiver , task:: JoinHandle } ;
35
37
use tonic:: transport:: { Channel , Endpoint } ;
36
38
use tracing:: Level ;
@@ -145,7 +147,8 @@ impl From<tap_graph::SignedRav> for RavInformation {
145
147
impl From < & tap_graph:: v2:: SignedRav > for RavInformation {
146
148
fn from ( value : & tap_graph:: v2:: SignedRav ) -> Self {
147
149
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 ( ) ,
149
152
value_aggregate : value. message . valueAggregate ,
150
153
}
151
154
}
@@ -214,9 +217,9 @@ pub enum SenderAccountMessage {
214
217
/// as well as requesting the underlaying allocation rav request
215
218
///
216
219
/// Custom behavior is defined in [ReceiptFees]
217
- UpdateReceiptFees ( Address , ReceiptFees ) ,
220
+ UpdateReceiptFees ( AllocationId , ReceiptFees ) ,
218
221
/// Updates the counter for invalid receipts and verify to deny sender
219
- UpdateInvalidReceiptFees ( Address , UnaggregatedReceipts ) ,
222
+ UpdateInvalidReceiptFees ( AllocationId , UnaggregatedReceipts ) ,
220
223
/// Update rav tracker
221
224
UpdateRav ( RavInformation ) ,
222
225
#[ cfg( test) ]
@@ -475,7 +478,7 @@ impl State {
475
478
. build ( ) ;
476
479
477
480
SenderAllocation :: < Horizon > :: spawn_linked (
478
- Some ( self . format_sender_allocation ( & id) ) ,
481
+ Some ( self . format_sender_allocation ( & id. as_address ( ) ) ) ,
479
482
SenderAllocation :: default ( ) ,
480
483
args,
481
484
sender_account_ref. get_cell ( ) ,
@@ -1061,7 +1064,7 @@ impl Actor for SenderAccount {
1061
1064
1062
1065
state
1063
1066
. invalid_receipts_tracker
1064
- . update ( allocation_id, unaggregated_fees. value ) ;
1067
+ . update ( allocation_id. address ( ) , unaggregated_fees. value ) ;
1065
1068
1066
1069
// invalid receipts can't go down
1067
1070
let should_deny = !state. denied && state. deny_condition_reached ( ) ;
@@ -1098,7 +1101,7 @@ impl Actor for SenderAccount {
1098
1101
// add new value
1099
1102
state
1100
1103
. sender_fee_tracker
1101
- . add ( allocation_id, value, timestamp_ns) ;
1104
+ . add ( allocation_id. address ( ) , value, timestamp_ns) ;
1102
1105
1103
1106
SENDER_FEE_TRACKER
1104
1107
. with_label_values ( & [ & state. sender . to_string ( ) ] )
@@ -1111,16 +1114,16 @@ impl Actor for SenderAccount {
1111
1114
. set (
1112
1115
state
1113
1116
. sender_fee_tracker
1114
- . get_total_fee_for_allocation ( & allocation_id)
1117
+ . get_total_fee_for_allocation ( & allocation_id. address ( ) )
1115
1118
. map ( |fee| fee. value )
1116
1119
. unwrap_or_default ( ) as f64 ,
1117
1120
) ;
1118
1121
}
1119
1122
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) ) ;
1121
1124
}
1122
1125
ReceiptFees :: UpdateValue ( unaggregated_fees) => {
1123
- state. update_sender_fee ( allocation_id, unaggregated_fees) ;
1126
+ state. update_sender_fee ( allocation_id. address ( ) , unaggregated_fees) ;
1124
1127
}
1125
1128
ReceiptFees :: Retry => { }
1126
1129
}
@@ -1138,8 +1141,10 @@ impl Actor for SenderAccount {
1138
1141
let total_fee_outside_buffer = state. sender_fee_tracker . get_ravable_total_fee ( ) ;
1139
1142
let total_counter_for_allocation = state
1140
1143
. 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 ( ) ) ;
1143
1148
let counter_greater_receipt_limit = total_counter_for_allocation
1144
1149
>= state. config . rav_request_receipt_limit
1145
1150
&& can_trigger_rav;
@@ -1159,7 +1164,9 @@ impl Actor for SenderAccount {
1159
1164
%allocation_id,
1160
1165
"Total counter greater than the receipt limit per rav. Triggering RAV request"
1161
1166
) ;
1162
- state. rav_request_for_allocation ( allocation_id) . await
1167
+ state
1168
+ . rav_request_for_allocation ( allocation_id. address ( ) )
1169
+ . await
1163
1170
} else {
1164
1171
Ok ( ( ) )
1165
1172
} ;
@@ -1368,7 +1375,7 @@ impl Actor for SenderAccount {
1368
1375
1369
1376
// check for deny conditions
1370
1377
let _ = myself. cast ( SenderAccountMessage :: UpdateReceiptFees (
1371
- allocation_id,
1378
+ AllocationId :: Legacy ( AllocationIdCore :: from ( allocation_id) ) ,
1372
1379
ReceiptFees :: Retry ,
1373
1380
) ) ;
1374
1381
@@ -1472,7 +1479,10 @@ pub mod tests {
1472
1479
flush_messages, pgpool, ALLOCATION_ID_0 , ALLOCATION_ID_1 , TAP_SENDER as SENDER ,
1473
1480
TAP_SIGNER as SIGNER ,
1474
1481
} ;
1475
- use thegraph_core:: alloy:: { hex:: ToHexExt , primitives:: U256 } ;
1482
+ use thegraph_core:: {
1483
+ alloy:: { hex:: ToHexExt , primitives:: U256 } ,
1484
+ AllocationId as AllocationIdCore ,
1485
+ } ;
1476
1486
use tokio:: sync:: mpsc;
1477
1487
use wiremock:: {
1478
1488
matchers:: { body_string_contains, method} ,
@@ -1566,7 +1576,9 @@ pub mod tests {
1566
1576
. call ( )
1567
1577
. await ;
1568
1578
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
+ ) ) ] ) ;
1570
1582
// we expect it to create a sender allocation
1571
1583
sender_account
1572
1584
. cast ( SenderAccountMessage :: UpdateAllocationIds (
@@ -1660,7 +1672,7 @@ pub mod tests {
1660
1672
// we expect it to create a sender allocation
1661
1673
sender_account
1662
1674
. cast ( SenderAccountMessage :: NewAllocationId ( AllocationId :: Legacy (
1663
- ALLOCATION_ID_0 ,
1675
+ AllocationIdCore :: from ( ALLOCATION_ID_0 ) ,
1664
1676
) ) )
1665
1677
. unwrap ( ) ;
1666
1678
@@ -1674,9 +1686,11 @@ pub mod tests {
1674
1686
// nothing should change because we already created
1675
1687
sender_account
1676
1688
. 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 ( ) ,
1680
1694
) )
1681
1695
. unwrap ( ) ;
1682
1696
@@ -1754,7 +1768,7 @@ pub mod tests {
1754
1768
basic_sender_account
1755
1769
. sender_account
1756
1770
. cast ( SenderAccountMessage :: UpdateReceiptFees (
1757
- ALLOCATION_ID_0 ,
1771
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
1758
1772
ReceiptFees :: NewReceipt ( TRIGGER_VALUE - 1 , get_current_timestamp_u64_ns ( ) ) ,
1759
1773
) )
1760
1774
. unwrap ( ) ;
@@ -1782,7 +1796,7 @@ pub mod tests {
1782
1796
basic_sender_account
1783
1797
. sender_account
1784
1798
. cast ( SenderAccountMessage :: UpdateReceiptFees (
1785
- ALLOCATION_ID_0 ,
1799
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
1786
1800
ReceiptFees :: NewReceipt ( TRIGGER_VALUE , get_current_timestamp_u64_ns ( ) ) ,
1787
1801
) )
1788
1802
. unwrap ( ) ;
@@ -1796,7 +1810,7 @@ pub mod tests {
1796
1810
basic_sender_account
1797
1811
. sender_account
1798
1812
. cast ( SenderAccountMessage :: UpdateReceiptFees (
1799
- ALLOCATION_ID_0 ,
1813
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
1800
1814
ReceiptFees :: Retry ,
1801
1815
) )
1802
1816
. unwrap ( ) ;
@@ -1825,7 +1839,7 @@ pub mod tests {
1825
1839
1826
1840
sender_account
1827
1841
. cast ( SenderAccountMessage :: UpdateReceiptFees (
1828
- ALLOCATION_ID_0 ,
1842
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
1829
1843
ReceiptFees :: NewReceipt ( 1 , get_current_timestamp_u64_ns ( ) ) ,
1830
1844
) )
1831
1845
. unwrap ( ) ;
@@ -1835,7 +1849,7 @@ pub mod tests {
1835
1849
1836
1850
sender_account
1837
1851
. cast ( SenderAccountMessage :: UpdateReceiptFees (
1838
- ALLOCATION_ID_0 ,
1852
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
1839
1853
ReceiptFees :: NewReceipt ( 1 , get_current_timestamp_u64_ns ( ) ) ,
1840
1854
) )
1841
1855
. unwrap ( ) ;
@@ -1846,7 +1860,7 @@ pub mod tests {
1846
1860
1847
1861
sender_account
1848
1862
. cast ( SenderAccountMessage :: UpdateReceiptFees (
1849
- ALLOCATION_ID_0 ,
1863
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
1850
1864
ReceiptFees :: Retry ,
1851
1865
) )
1852
1866
. unwrap ( ) ;
@@ -1865,9 +1879,11 @@ pub mod tests {
1865
1879
let ( sender_account, _, prefix, _) = create_sender_account ( )
1866
1880
. pgpool ( pgpool)
1867
1881
. initial_allocation (
1868
- vec ! [ AllocationId :: Legacy ( ALLOCATION_ID_0 ) ]
1869
- . into_iter ( )
1870
- . collect ( ) ,
1882
+ vec ! [ AllocationId :: Legacy ( AllocationIdCore :: from(
1883
+ ALLOCATION_ID_0 ,
1884
+ ) ) ]
1885
+ . into_iter ( )
1886
+ . collect ( ) ,
1871
1887
)
1872
1888
. escrow_subgraph_endpoint ( & mock_escrow_subgraph. uri ( ) )
1873
1889
. call ( )
@@ -1952,7 +1968,7 @@ pub mod tests {
1952
1968
1953
1969
sender_account
1954
1970
. cast ( SenderAccountMessage :: UpdateReceiptFees (
1955
- ALLOCATION_ID_0 ,
1971
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
1956
1972
ReceiptFees :: NewReceipt ( TRIGGER_VALUE , get_current_timestamp_u64_ns ( ) ) ,
1957
1973
) )
1958
1974
. unwrap ( ) ;
@@ -1988,7 +2004,7 @@ pub mod tests {
1988
2004
( $value: expr) => {
1989
2005
sender_account
1990
2006
. cast( SenderAccountMessage :: UpdateReceiptFees (
1991
- ALLOCATION_ID_0 ,
2007
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
1992
2008
ReceiptFees :: UpdateValue ( UnaggregatedReceipts {
1993
2009
value: $value,
1994
2010
last_id: 11 ,
@@ -2005,7 +2021,7 @@ pub mod tests {
2005
2021
( $value: expr) => {
2006
2022
sender_account
2007
2023
. cast( SenderAccountMessage :: UpdateInvalidReceiptFees (
2008
- ALLOCATION_ID_0 ,
2024
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
2009
2025
UnaggregatedReceipts {
2010
2026
value: $value,
2011
2027
last_id: 11 ,
@@ -2141,7 +2157,7 @@ pub mod tests {
2141
2157
( $value: expr) => {
2142
2158
sender_account
2143
2159
. cast( SenderAccountMessage :: UpdateReceiptFees (
2144
- ALLOCATION_ID_0 ,
2160
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
2145
2161
ReceiptFees :: UpdateValue ( UnaggregatedReceipts {
2146
2162
value: $value,
2147
2163
last_id: 11 ,
@@ -2431,17 +2447,17 @@ pub mod tests {
2431
2447
// set retry
2432
2448
sender_account
2433
2449
. cast ( SenderAccountMessage :: UpdateReceiptFees (
2434
- ALLOCATION_ID_0 ,
2450
+ AllocationId :: Legacy ( AllocationIdCore :: from ( ALLOCATION_ID_0 ) ) ,
2435
2451
ReceiptFees :: NewReceipt ( TRIGGER_VALUE , get_current_timestamp_u64_ns ( ) ) ,
2436
2452
) )
2437
2453
. unwrap ( ) ;
2438
2454
let msg = msg_receiver. recv ( ) . await . expect ( "Channel failed" ) ;
2439
2455
assert ! ( matches!(
2440
2456
msg,
2441
2457
SenderAccountMessage :: UpdateReceiptFees (
2442
- ALLOCATION_ID_0 ,
2458
+ AllocationId :: Legacy ( allocation_id ) ,
2443
2459
ReceiptFees :: NewReceipt ( TRIGGER_VALUE , _)
2444
- )
2460
+ ) if allocation_id == AllocationIdCore :: from ( ALLOCATION_ID_0 )
2445
2461
) ) ;
2446
2462
2447
2463
let deny = call ! ( sender_account, SenderAccountMessage :: GetDeny ) . unwrap ( ) ;
0 commit comments