Skip to content

Commit

Permalink
feat(eth-sender): separate gas calculations for blobs transactions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomg10 authored Jun 24, 2024
1 parent b4327b6 commit 627aab9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/node/eth_sender/src/eth_fees_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ impl GasAdjusterFeesOracle {
&self,
previous_sent_tx: &Option<TxHistory>,
) -> Result<EthFees, EthSenderError> {
let base_fee_per_gas = self.gas_adjuster.get_base_fee(0);
let priority_fee_per_gas = self.gas_adjuster.get_priority_fee();
let blob_base_fee_per_gas = Some(self.gas_adjuster.get_blob_base_fee());
let base_fee_per_gas = self.gas_adjuster.get_blob_tx_base_fee();
let priority_fee_per_gas = self.gas_adjuster.get_blob_tx_priority_fee();
let blob_base_fee_per_gas = Some(self.gas_adjuster.get_blob_tx_blob_base_fee());

if let Some(previous_sent_tx) = previous_sent_tx {
// for blob transactions on re-sending need to double all gas prices
Expand Down
16 changes: 16 additions & 0 deletions core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,22 @@ impl L1TxParamsProvider for GasAdjuster {
fn get_priority_fee(&self) -> u64 {
self.config.default_priority_fee_per_gas
}

// The idea is that when we finally decide to send blob tx, we want to offer gas fees high
// enough to "almost be certain" that the transaction gets included. To never have to double
// the gas prices as then we have very little control how much we pay in the end. This strategy
// works as no matter if we double or triple such price, we pay the same block base fees.
fn get_blob_tx_base_fee(&self) -> u64 {
self.base_fee_statistics.last_added_value() * 2
}

fn get_blob_tx_blob_base_fee(&self) -> u64 {
self.blob_base_fee_statistics.last_added_value().as_u64() * 2
}

fn get_blob_tx_priority_fee(&self) -> u64 {
self.get_priority_fee() * 2
}
}

/// Helper structure responsible for collecting the data about recent transactions,
Expand Down
9 changes: 9 additions & 0 deletions core/node/fee_model/src/l1_gas_price/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ pub trait L1TxParamsProvider: fmt::Debug + 'static + Send + Sync {

/// Returns a lower bound for the `base_fee` value for the next L1 block.
fn get_next_block_minimal_base_fee(&self) -> u64;

/// Returns the recommended `max_fee_per_gas` value (EIP1559) for blob transaction.
fn get_blob_tx_base_fee(&self) -> u64;

/// Returns the recommended `max_blob_fee_per_gas` value (EIP4844) for blob transaction.
fn get_blob_tx_blob_base_fee(&self) -> u64;

/// Returns the recommended `max_priority_fee_per_gas` value (EIP1559) for blob transaction.
fn get_blob_tx_priority_fee(&self) -> u64;
}

0 comments on commit 627aab9

Please sign in to comment.