@@ -25,7 +25,7 @@ use alloy::{
2525 network:: { EthereumWallet , TransactionBuilder } ,
2626 primitives:: { utils:: parse_ether, Address , U256 } ,
2727 providers:: { PendingTransactionError , Provider , ProviderBuilder } ,
28- rpc:: types:: TransactionReceipt ,
28+ rpc:: types:: { TransactionReceipt , TransactionRequest } ,
2929 signers:: local:: LocalSigner ,
3030} ;
3131use config:: Config ;
@@ -391,7 +391,8 @@ impl ProofAggregator {
391391 ) -> Result < TransactionReceipt , AggregatedProofSubmissionError > {
392392 let retry_interval = Duration :: from_secs ( self . config . bump_retry_interval_seconds ) ;
393393 let base_bump_percentage = self . config . base_bump_percentage ;
394- let retry_attempt_percentage = self . config . retry_attempt_percentage ;
394+ let max_fee_bump_percentage = self . config . max_fee_bump_percentage ;
395+ let priority_fee_gwei = self . config . priority_fee_gwei ;
395396
396397 // Build the transaction request
397398 let mut tx_req = match aggregated_proof {
@@ -426,8 +427,8 @@ impl ProofAggregator {
426427 tx_req = self
427428 . apply_gas_fee_bump (
428429 base_bump_percentage,
429- retry_attempt_percentage ,
430- attempt ,
430+ max_fee_bump_percentage ,
431+ priority_fee_gwei ,
431432 tx_req,
432433 )
433434 . await ?;
@@ -500,70 +501,38 @@ impl ProofAggregator {
500501 }
501502 }
502503
503- // Updates the gas fees of a `TransactionRequest` for retry attempts by applying a linear fee
504- // bump based on the retry number. This method is intended to be used when a previous transaction
505- // attempt was not confirmed (e.g. receipt timeout or transient failure).
504+ // Updates the gas fees of a `TransactionRequest` using a fixed bump strategy.
505+ // Intended for retrying an on-chain submission after a timeout.
506506 //
507- // Fee strategy (similar to Go implementation):
508- // The bump is calculated as: base_bump_percentage + (retry_count * retry_attempt_percentage)
509- // For example, with `base_bump_percentage = 10` and `retry_attempt_percentage = 5`:
510- // - `attempt = 1` → 10% + (1 * 5%) = 15% bump
511- // - `attempt = 2` → 10% + (2 * 5%) = 20% bump
512- // - `attempt = 3` → 10% + (3 * 5%) = 25% bump
507+ // Strategy:
508+ // - Fetch the current network gas price.
509+ // - Apply `base_bump_percentage` to compute a bumped base fee.
510+ // - Apply `max_fee_bump_percentage` on top of the bumped base fee to set `max_fee_per_gas`.
511+ // - Set `max_priority_fee_per_gas` to a fixed value derived from `priority_fee_gwei`.
513512 //
514- // The bumped price is: current_gas_price * (1 + total_bump_percentage / 100)
513+ // Fees are recomputed on each retry using the latest gas price (no incremental per-attempt bump).
514+
515515 async fn apply_gas_fee_bump (
516516 & self ,
517517 base_bump_percentage : u64 ,
518- retry_attempt_percentage : u64 ,
519- attempt : u64 ,
520- tx_req : alloy :: rpc :: types :: TransactionRequest ,
521- ) -> Result < alloy :: rpc :: types :: TransactionRequest , AggregatedProofSubmissionError > {
518+ max_fee_bump_percentage : u64 ,
519+ priority_fee_gwei : u128 ,
520+ tx_req : TransactionRequest ,
521+ ) -> Result < TransactionRequest , AggregatedProofSubmissionError > {
522522 let provider = self . proof_aggregation_service . provider ( ) ;
523523
524- // Calculate total bump percentage: base + (retry_count * retry_attempt)
525- let incremental_retry_percentage = retry_attempt_percentage * attempt;
526- let total_bump_percentage = base_bump_percentage + incremental_retry_percentage;
527-
528- info ! (
529- "Applying {}% gas fee bump for attempt {}" ,
530- total_bump_percentage,
531- attempt + 1
532- ) ;
533-
534- let mut current_tx_req = tx_req. clone ( ) ;
535-
536- if current_tx_req. max_fee_per_gas . is_none ( ) {
537- let current_gas_price = provider
538- . get_gas_price ( )
539- . await
540- . map_err ( |e| AggregatedProofSubmissionError :: GasPriceError ( e. to_string ( ) ) ) ?;
541-
542- let new_max_fee =
543- Self :: calculate_bumped_price ( current_gas_price, total_bump_percentage) ;
544- let new_priority_fee = new_max_fee / 10 ;
545-
546- current_tx_req = current_tx_req
547- . with_max_fee_per_gas ( new_max_fee)
548- . with_max_priority_fee_per_gas ( new_priority_fee) ;
549- } else {
550- if let Some ( max_fee) = current_tx_req. max_fee_per_gas {
551- let new_max_fee = Self :: calculate_bumped_price ( max_fee, total_bump_percentage) ;
552- current_tx_req = current_tx_req. with_max_fee_per_gas ( new_max_fee) ;
553- }
554- if let Some ( priority_fee) = current_tx_req. max_priority_fee_per_gas {
555- let new_priority_fee =
556- Self :: calculate_bumped_price ( priority_fee, total_bump_percentage) ;
557- current_tx_req = current_tx_req. with_max_priority_fee_per_gas ( new_priority_fee) ;
558- }
559- }
524+ let current_gas_price = provider
525+ . get_gas_price ( )
526+ . await
527+ . map_err ( |e| AggregatedProofSubmissionError :: GasPriceError ( e. to_string ( ) ) ) ?;
560528
561- Ok ( current_tx_req)
562- }
529+ let new_base_fee = current_gas_price * ( 1 + base_bump_percentage as u128 / 100 ) ;
530+ let new_max_fee = new_base_fee * ( 1 + max_fee_bump_percentage as u128 / 100 ) ;
531+ let new_priority_fee = priority_fee_gwei * 1000000000 ; // Convert to wei
563532
564- fn calculate_bumped_price ( current_price : u128 , total_bump_percentage : u64 ) -> u128 {
565- let bump_amount = ( current_price * total_bump_percentage as u128 ) / 100 ;
566- current_price + bump_amount
533+ Ok ( tx_req
534+ . with_max_fee_per_gas ( new_max_fee )
535+ . with_max_priority_fee_per_gas ( new_priority_fee ) )
567536 }
568537
569538 async fn wait_until_can_submit_aggregated_proof (
0 commit comments