Skip to content

Commit 5e1dac5

Browse files
Get the current base fee fro the last block instead of from provider
1 parent ae34d73 commit 5e1dac5

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

  • aggregation_mode/proof_aggregator/src/backend

aggregation_mode/proof_aggregator/src/backend/mod.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ use crate::{
2020

2121
use alloy::{
2222
consensus::{BlobTransactionSidecar, EnvKzgSettings, EthereumTxEnvelope, TxEip4844WithSidecar},
23-
eips::{eip4844::BYTES_PER_BLOB, eip7594::BlobTransactionSidecarEip7594, Encodable2718},
23+
eips::{
24+
eip4844::BYTES_PER_BLOB, eip7594::BlobTransactionSidecarEip7594, BlockNumberOrTag,
25+
Encodable2718,
26+
},
2427
hex,
2528
network::{EthereumWallet, TransactionBuilder},
2629
primitives::{utils::parse_ether, Address, TxHash, U256},
@@ -52,6 +55,8 @@ pub enum AggregatedProofSubmissionError {
5255
MerkleRootMisMatch,
5356
StoringMerklePaths(DbError),
5457
GasPriceError(String),
58+
LatestBlockNotFound,
59+
BaseFeePerGasMissing,
5560
}
5661

5762
enum SubmitOutcome {
@@ -589,18 +594,23 @@ impl ProofAggregator {
589594
) -> Result<TransactionRequest, AggregatedProofSubmissionError> {
590595
let provider = self.proof_aggregation_service.provider();
591596

592-
let current_gas_price = provider
593-
.get_gas_price()
597+
let latest_block = provider
598+
.get_block_by_number(BlockNumberOrTag::Latest)
594599
.await
595-
.map_err(|e| AggregatedProofSubmissionError::GasPriceError(e.to_string()))?;
600+
.map_err(|e| AggregatedProofSubmissionError::GasPriceError(e.to_string()))?
601+
.ok_or(AggregatedProofSubmissionError::LatestBlockNotFound)?;
602+
603+
let current_base_fee = latest_block
604+
.header
605+
.base_fee_per_gas
606+
.ok_or(AggregatedProofSubmissionError::BaseFeePerGasMissing)?;
596607

597-
let new_base_fee = current_gas_price as f64 * (1.0 + base_bump_percentage as f64 / 100.0);
608+
let new_base_fee = current_base_fee as f64 * (1.0 + base_bump_percentage as f64 / 100.0);
598609
let new_max_fee = new_base_fee * (1.0 + max_fee_bump_percentage as f64 / 100.0);
599-
let new_priority_fee = priority_fee_wei;
600610

601611
Ok(tx_req
602612
.with_max_fee_per_gas(new_max_fee as u128)
603-
.with_max_priority_fee_per_gas(new_priority_fee))
613+
.with_max_priority_fee_per_gas(priority_fee_wei))
604614
}
605615

606616
async fn wait_until_can_submit_aggregated_proof(

0 commit comments

Comments
 (0)