-
Notifications
You must be signed in to change notification settings - Fork 820
Closed
Description
While reviewing EIP-7918 and after discussing it with @rakita, it makes sense to remove this file:
revm/crates/primitives/src/eip7918.rs
Lines 1 to 6 in 784d30d
//! EIP-7918: Blob Base Fee Bounded by Execution Cost | |
//! | |
//! Constants for blob base fee calculation with execution cost bounds. | |
/// Minimum base fee for blobs, if price of the blob is less than this value, this value will be used. | |
pub const BLOB_BASE_COST: u64 = 2_u64.pow(14); |
Also, to perform some cleanup within this file (some functions are deprecated, not relevant anymore):
revm/crates/context/interface/src/block/blob.rs
Lines 43 to 130 in 784d30d
/// Calculate this block excess gas and price from the parent excess gas and gas used | |
/// and the target blob gas per block. | |
/// | |
/// These fields will be used to calculate `excess_blob_gas` with [`calc_excess_blob_gas`] func. | |
#[deprecated( | |
note = "Use `calc_excess_blob_gas` and `BlobExcessGasAndPrice::new` instead. Only works for forks before Osaka." | |
)] | |
pub fn from_parent_and_target( | |
parent_excess_blob_gas: u64, | |
parent_blob_gas_used: u64, | |
parent_target_blob_gas_per_block: u64, | |
blob_base_fee_update_fraction: u64, | |
) -> Self { | |
Self::new( | |
calc_excess_blob_gas( | |
parent_excess_blob_gas, | |
parent_blob_gas_used, | |
parent_target_blob_gas_per_block, | |
), | |
blob_base_fee_update_fraction, | |
) | |
} | |
} | |
/// Calculates the `excess_blob_gas` from the parent header's `blob_gas_used` and `excess_blob_gas`. | |
/// Uses [`calc_excess_blob_gas_osaka`] internally. | |
#[inline] | |
pub fn calc_excess_blob_gas( | |
parent_excess_blob_gas: u64, | |
parent_blob_gas_used: u64, | |
parent_target_blob_gas_per_block: u64, | |
) -> u64 { | |
calc_excess_blob_gas_osaka( | |
parent_excess_blob_gas, | |
parent_blob_gas_used, | |
parent_target_blob_gas_per_block, | |
false, | |
0, | |
0, | |
0, | |
0, | |
0, | |
) | |
} | |
/// Calculates the `excess_blob_gas` from the parent header's `blob_gas_used` and `excess_blob_gas`. | |
/// | |
/// See also [the EIP-4844 helpers]<https://eips.ethereum.org/EIPS/eip-4844#helpers> | |
/// (`calc_excess_blob_gas`). | |
/// | |
/// [EIP-7918: Blob base fee bounded by execution cost](https://eips.ethereum.org/EIPS/eip-7918) | |
/// | |
/// `blob_base_cost` is introduced in EIP-7918 in Osaka fork. All fields after is_osaka input are not needed before Osaka. | |
#[allow(clippy::too_many_arguments)] | |
#[inline] | |
pub fn calc_excess_blob_gas_osaka( | |
parent_excess_blob_gas: u64, | |
parent_blob_gas_used: u64, | |
parent_target_blob_gas_per_block: u64, | |
is_osaka: bool, | |
parent_base_fee_per_gas: u64, | |
parent_blob_base_fee_per_gas: u64, | |
parent_blob_base_fee_update_fraction: u64, | |
max_blob_count: u64, | |
target_blob_count: u64, | |
) -> u64 { | |
let excess_and_used = parent_excess_blob_gas.saturating_add(parent_blob_gas_used); | |
if is_osaka { | |
if excess_and_used < parent_target_blob_gas_per_block { | |
return 0; | |
} | |
if (eip7918::BLOB_BASE_COST.saturating_mul(parent_base_fee_per_gas) as u128) | |
> (GAS_PER_BLOB as u128).saturating_mul(get_base_fee_per_blob_gas( | |
parent_blob_base_fee_per_gas, | |
parent_blob_base_fee_update_fraction, | |
)) | |
{ | |
return excess_and_used.saturating_add( | |
parent_blob_gas_used.saturating_mul(max_blob_count - target_blob_count) | |
/ max_blob_count, | |
); | |
} | |
} | |
excess_and_used.saturating_sub(parent_target_blob_gas_per_block) | |
} |
These are performed in alloy-rs
, outisde of the revm.
Alloy PR: alloy-rs#2821
Metadata
Metadata
Assignees
Labels
No labels