@@ -25,7 +25,7 @@ use eventuals::{Eventual, EventualExt, PipeHandle};
2525use indexer_common:: { escrow_accounts:: EscrowAccounts , prelude:: SubgraphClient } ;
2626use ractor:: { Actor , ActorProcessingErr , ActorRef , MessagingErr , SupervisionEvent } ;
2727use sqlx:: PgPool ;
28- use tap_core:: rav:: SignedRAV ;
28+ use tap_core:: rav:: { self , SignedRAV } ;
2929use tracing:: { error, warn, Level } ;
3030
3131use super :: sender_allocation:: { SenderAllocation , SenderAllocationArgs } ;
@@ -87,7 +87,13 @@ type Balance = U256;
8787pub enum ReceiptFees {
8888 NewReceipt ( u128 , u64 ) ,
8989 UpdateValue ( UnaggregatedReceipts ) ,
90- RavRequestResponse ( anyhow:: Result < ( UnaggregatedReceipts , Option < SignedRAV > ) > ) ,
90+ RavRequestResponse (
91+ (
92+ UnaggregatedReceipts ,
93+ Option < SignedRAV > ,
94+ Result < ( ) , anyhow:: Error > ,
95+ ) ,
96+ ) ,
9197 Retry ,
9298}
9399
@@ -285,11 +291,15 @@ impl State {
285291 fn finalize_rav_request (
286292 & mut self ,
287293 allocation_id : Address ,
288- rav_result : anyhow:: Result < ( UnaggregatedReceipts , Option < SignedRAV > ) > ,
294+ rav_result : (
295+ UnaggregatedReceipts ,
296+ Option < SignedRAV > ,
297+ Result < ( ) , anyhow:: Error > ,
298+ ) ,
289299 ) {
290300 self . sender_fee_tracker . finish_rav_request ( allocation_id) ;
291301 match rav_result {
292- Ok ( ( fees, rav) ) => {
302+ ( fees, rav, Ok ( ( ) ) ) => {
293303 self . sender_fee_tracker . ok_rav_request ( allocation_id) ;
294304 self . adaptive_limiter . on_success ( ) ;
295305
@@ -299,14 +309,14 @@ impl State {
299309 // update sender fee tracker
300310 self . update_sender_fee ( allocation_id, fees) ;
301311 }
302- Err ( err) => {
303- // TODO we should update the total value too
312+ ( fees, _, Err ( err) ) => {
304313 self . sender_fee_tracker . failed_rav_backoff ( allocation_id) ;
305314 self . adaptive_limiter . on_failure ( ) ;
306315 error ! (
307316 "Error while requesting RAV for sender {} and allocation {}: {}" ,
308317 self . sender, allocation_id, err
309318 ) ;
319+ self . update_sender_fee ( allocation_id, fees) ;
310320 }
311321 } ;
312322 }
@@ -1079,8 +1089,18 @@ pub mod tests {
10791089 ReceiptFees :: RavRequestResponse ( l) ,
10801090 ReceiptFees :: RavRequestResponse ( r) ,
10811091 ) => match ( l, r) {
1082- ( Ok ( l) , Ok ( r) ) => l == r,
1083- ( Err ( l) , Err ( r) ) => l. to_string ( ) == r. to_string ( ) ,
1092+ ( l, r) if l. 2 . is_ok ( ) && r. 2 . is_ok ( ) => l. 0 == r. 0 && l. 1 == r. 1 ,
1093+ ( l, r) if l. 2 . is_err ( ) && r. 2 . is_err ( ) => {
1094+ let l = match & l. 2 {
1095+ Ok ( ( ) ) => "Success" . to_string ( ) ,
1096+ Err ( e) => e. to_string ( ) ,
1097+ } ;
1098+ let r = match & r. 2 {
1099+ Ok ( ( ) ) => "Success" . to_string ( ) ,
1100+ Err ( e) => e. to_string ( ) ,
1101+ } ;
1102+ l == r
1103+ }
10841104 _ => false ,
10851105 } ,
10861106 ( ReceiptFees :: Retry , ReceiptFees :: Retry ) => true ,
@@ -1483,14 +1503,15 @@ pub mod tests {
14831503 if let Some ( sender_account) = self . sender_actor . as_ref ( ) {
14841504 sender_account. cast ( SenderAccountMessage :: UpdateReceiptFees (
14851505 * ALLOCATION_ID_0 ,
1486- ReceiptFees :: RavRequestResponse ( Ok ( (
1506+ ReceiptFees :: RavRequestResponse ( (
14871507 UnaggregatedReceipts {
14881508 value : * self . next_unaggregated_fees_value . lock ( ) . unwrap ( ) ,
14891509 last_id : 0 ,
14901510 counter : 0 ,
14911511 } ,
14921512 Some ( signed_rav) ,
1493- ) ) ) ,
1513+ Ok ( ( ) ) ,
1514+ ) ) ,
14941515 ) ) ?;
14951516 }
14961517 }
0 commit comments