Skip to content

Commit 7d9f380

Browse files
committed
fix fee calculation
1 parent e9454dd commit 7d9f380

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

aggregation_mode/proof_aggregator/src/backend/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub struct Config {
2323
pub db_connection_urls: Vec<String>,
2424
pub max_bump_retries: u16,
2525
pub bump_retry_interval_seconds: u64,
26-
pub base_bump_percentage: u64,
2726
pub max_fee_bump_percentage: u64,
2827
pub priority_fee_wei: u128,
2928
}

aggregation_mode/proof_aggregator/src/backend/mod.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -564,24 +564,22 @@ impl ProofAggregator {
564564
}
565565
}
566566

567-
// Updates the gas fees of a `TransactionRequest` using a fixed bump strategy.
567+
// Updates the gas fees of a `TransactionRequest` using EIP-1559 fee parameters.
568568
// Intended for retrying an on-chain submission after a timeout.
569569
//
570570
// Strategy:
571-
// - Fetch the current network gas price.
572-
// - Apply `base_bump_percentage` to compute a bumped base fee.
573-
// - Apply `max_fee_bump_percentage` on top of the bumped base fee to set `max_fee_per_gas`.
574-
// - Set `max_priority_fee_per_gas` to a fixed value derived from `priority_fee_wei`.
571+
// - Fetch the current base fee from the latest block.
572+
// - Set `max_priority_fee_per_gas` to a fixed value from `priority_fee_wei`.
573+
// - Compute `max_fee_per_gas` as: (1 + max_fee_bump_percentage/100) * base_fee + priority_fee.
575574
//
576-
// Fees are recomputed on each retry using the latest gas price (no incremental per-attempt bump).
575+
// Fees are recomputed on each retry using the latest base fee (no incremental per-attempt bump).
577576

578577
async fn apply_gas_fee_bump(
579578
&self,
580579
tx_req: TransactionRequest,
581580
) -> Result<TransactionRequest, AggregatedProofSubmissionError> {
582581
let provider = self.proof_aggregation_service.provider();
583582

584-
let base_bump_percentage = self.config.base_bump_percentage;
585583
let max_fee_bump_percentage = self.config.max_fee_bump_percentage;
586584
let priority_fee_wei = self.config.priority_fee_wei;
587585

@@ -596,8 +594,8 @@ impl ProofAggregator {
596594
.base_fee_per_gas
597595
.ok_or(AggregatedProofSubmissionError::BaseFeePerGasMissing)?;
598596

599-
let new_base_fee = current_base_fee as f64 * (1.0 + base_bump_percentage as f64 / 100.0);
600-
let new_max_fee = new_base_fee * (1.0 + max_fee_bump_percentage as f64 / 100.0);
597+
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;
601599

602600
Ok(tx_req
603601
.with_max_fee_per_gas(new_max_fee as u128)

config-files/config-proof-aggregator-ethereum-package.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ risc0_chunk_aggregator_image_id: "8908f01022827e80a5de71908c16ee44f4a467236df20f
3030
# These values modify the bumping behavior after the aggregated proof on-chain submission times out.
3131
max_bump_retries: 5
3232
bump_retry_interval_seconds: 120
33-
base_bump_percentage: 10
3433
max_fee_bump_percentage: 100
3534
priority_fee_wei: 3000000000 # 3 Gwei
3635

config-files/config-proof-aggregator.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ risc0_chunk_aggregator_image_id: "8908f01022827e80a5de71908c16ee44f4a467236df20f
3030
# These values modify the bumping behavior after the aggregated proof on-chain submission times out.
3131
max_bump_retries: 5
3232
bump_retry_interval_seconds: 120
33-
base_bump_percentage: 10
3433
max_fee_bump_percentage: 100
3534
priority_fee_wei: 3000000000 # 3 Gwei
3635

0 commit comments

Comments
 (0)