@@ -379,7 +379,13 @@ impl ProofAggregator {
379379 // Wrap the entire transaction submission in a result to catch all errors, passing
380380 // the same nonce to all attempts
381381 let attempt_result = self
382- . try_submit_transaction ( & blob, blob_versioned_hash, aggregated_proof, nonce)
382+ . try_submit_transaction (
383+ & blob,
384+ blob_versioned_hash,
385+ aggregated_proof,
386+ nonce,
387+ attempt,
388+ )
383389 . await ;
384390
385391 match attempt_result {
@@ -466,6 +472,7 @@ impl ProofAggregator {
466472 blob_versioned_hash : [ u8 ; 32 ] ,
467473 aggregated_proof : & AlignedProof ,
468474 nonce : u64 ,
475+ attempt : u16 ,
469476 ) -> Result < SubmitOutcome , AggregatedProofSubmissionError > {
470477 let retry_interval = Duration :: from_secs ( self . config . bump_retry_interval_seconds ) ;
471478
@@ -501,7 +508,7 @@ impl ProofAggregator {
501508 tx_req = tx_req. with_nonce ( nonce) ;
502509
503510 // Apply gas fee bump for retries
504- tx_req = self . apply_gas_fee_bump ( tx_req) . await ?;
511+ tx_req = self . apply_gas_fee_bump ( tx_req, attempt ) . await ?;
505512
506513 let provider = self . proof_aggregation_service . provider ( ) ;
507514
@@ -569,19 +576,21 @@ impl ProofAggregator {
569576 //
570577 // Strategy:
571578 // - Fetch the current base fee from the latest block.
572- // - Set `max_priority_fee_per_gas` to a fixed value from `priority_fee_wei`.
579+ // - Fetch the suggested priority fee from the network (eth_maxPriorityFeePerGas).
580+ // - Compute priority fee as: suggested * (1 + (attempt + 1) * 0.1), capped at `max_priority_fee_upper_limit`.
573581 // - Compute `max_fee_per_gas` as: (1 + max_fee_bump_percentage/100) * base_fee + priority_fee.
574582 //
575- // Fees are recomputed on each retry using the latest base fee (no incremental per-attempt bump) .
583+ // Fees are recomputed on each retry using the latest base fee.
576584
577585 async fn apply_gas_fee_bump (
578586 & self ,
579587 tx_req : TransactionRequest ,
588+ attempt : u16 ,
580589 ) -> Result < TransactionRequest , AggregatedProofSubmissionError > {
581590 let provider = self . proof_aggregation_service . provider ( ) ;
582591
583592 let max_fee_bump_percentage = self . config . max_fee_bump_percentage ;
584- let priority_fee_wei = self . config . priority_fee_wei ;
593+ let max_priority_fee_upper_limit = self . config . max_priority_fee_upper_limit ;
585594
586595 let latest_block = provider
587596 . get_block_by_number ( BlockNumberOrTag :: Latest )
@@ -592,14 +601,34 @@ impl ProofAggregator {
592601 let current_base_fee = latest_block
593602 . header
594603 . base_fee_per_gas
595- . ok_or ( AggregatedProofSubmissionError :: BaseFeePerGasMissing ) ?;
604+ . ok_or ( AggregatedProofSubmissionError :: BaseFeePerGasMissing ) ?
605+ as f64 ;
606+
607+ // Fetch suggested priority fee from the network
608+ let suggested_priority_fee = provider
609+ . get_max_priority_fee_per_gas ( )
610+ . await
611+ . map_err ( |e| AggregatedProofSubmissionError :: GasPriceError ( e. to_string ( ) ) ) ?
612+ as f64 ;
613+
614+ // Calculate priority fee: suggested * (1 + (attempt + 1) * 0.1), capped at max
615+ let priority_fee_multiplier = 1.0 + ( attempt + 1 ) as f64 * 0.1 ;
616+ let max_priority_fee_per_gas = ( suggested_priority_fee * priority_fee_multiplier)
617+ . min ( max_priority_fee_upper_limit as f64 ) ;
596618
597619 let max_fee_multiplier = 1.0 + max_fee_bump_percentage as f64 / 100.0 ;
598- let new_max_fee = max_fee_multiplier * current_base_fee as f64 + priority_fee_wei as f64 ;
620+ let max_fee_per_gas = max_fee_multiplier * current_base_fee + max_priority_fee_per_gas;
621+
622+ info ! (
623+ "Base fee: {:.4} Gwei. Applying max_fee_per_gas: {:.4} Gwei and max_priority_fee_per_gas: {:.4} Gwei to tx" ,
624+ current_base_fee / 1e9 ,
625+ max_fee_per_gas / 1e9 ,
626+ max_priority_fee_per_gas / 1e9
627+ ) ;
599628
600629 Ok ( tx_req
601- . with_max_fee_per_gas ( new_max_fee as u128 )
602- . with_max_priority_fee_per_gas ( priority_fee_wei ) )
630+ . with_max_fee_per_gas ( max_fee_per_gas as u128 )
631+ . with_max_priority_fee_per_gas ( max_priority_fee_per_gas as u128 ) )
603632 }
604633
605634 async fn wait_until_can_submit_aggregated_proof (
0 commit comments