Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/context/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ dev = [
"optional_block_gas_limit",
"optional_eip3541",
"optional_eip3607",
"optional_eip7623",
"optional_no_base_fee",
"optional_priority_fee_check",
"optional_fee_charge",
Expand All @@ -74,6 +75,7 @@ optional_balance_check = []
optional_block_gas_limit = []
optional_eip3541 = []
optional_eip3607 = []
optional_eip7623 = []
optional_no_base_fee = []
optional_priority_fee_check = []
optional_fee_charge = []
3 changes: 3 additions & 0 deletions crates/context/interface/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ pub trait Cfg {
/// Returns whether the EIP-3541 (disallowing new contracts with 0xEF prefix) is disabled.
fn is_eip3541_disabled(&self) -> bool;

/// Returns whether the EIP-7623 (increased calldata cost) is disabled.
fn is_eip7623_disabled(&self) -> bool;

/// Returns whether the balance check is disabled.
fn is_balance_check_disabled(&self) -> bool;

Expand Down
29 changes: 29 additions & 0 deletions crates/context/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ pub struct CfgEnv<SPEC = SpecId> {
/// By default, it is set to `false`.
#[cfg(feature = "optional_eip3607")]
pub disable_eip3607: bool,
/// EIP-7623 increases calldata cost.
///
/// This EIP can be considered irrelevant in the context of an EVM-compatible L2 rollup,
/// if it does not make use of blobs.
///
/// By default, it is set to `false`.
#[cfg(feature = "optional_eip7623")]
pub disable_eip7623: bool,
/// Disables base fee checks for EIP-1559 transactions
///
/// This is useful for testing method calls with zero gas price.
Expand Down Expand Up @@ -161,6 +169,8 @@ impl<SPEC> CfgEnv<SPEC> {
disable_eip3541: false,
#[cfg(feature = "optional_eip3607")]
disable_eip3607: false,
#[cfg(feature = "optional_eip7623")]
disable_eip7623: false,
#[cfg(feature = "optional_no_base_fee")]
disable_base_fee: false,
#[cfg(feature = "optional_priority_fee_check")]
Expand Down Expand Up @@ -210,6 +220,8 @@ impl<SPEC> CfgEnv<SPEC> {
disable_eip3541: self.disable_eip3541,
#[cfg(feature = "optional_eip3607")]
disable_eip3607: self.disable_eip3607,
#[cfg(feature = "optional_eip7623")]
disable_eip7623: self.disable_eip7623,
#[cfg(feature = "optional_no_base_fee")]
disable_base_fee: self.disable_base_fee,
#[cfg(feature = "optional_priority_fee_check")]
Expand Down Expand Up @@ -248,6 +260,13 @@ impl<SPEC> CfgEnv<SPEC> {
self.disable_fee_charge = disable;
self
}

/// Sets the disable eip7623 flag.
#[cfg(feature = "optional_eip7623")]
pub fn with_disable_eip7623(mut self, disable: bool) -> Self {
self.disable_eip7623 = disable;
self
}
}

impl<SPEC: Into<SpecId> + Copy> Cfg for CfgEnv<SPEC> {
Expand Down Expand Up @@ -317,6 +336,16 @@ impl<SPEC: Into<SpecId> + Copy> Cfg for CfgEnv<SPEC> {
}
}

fn is_eip7623_disabled(&self) -> bool {
cfg_if::cfg_if! {
if #[cfg(feature = "optional_eip7623")] {
self.disable_eip7623
} else {
false
}
}
}

fn is_balance_check_disabled(&self) -> bool {
cfg_if::cfg_if! {
if #[cfg(feature = "optional_balance_check")] {
Expand Down
8 changes: 7 additions & 1 deletion crates/handler/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ pub trait Handler {
// Calculate final refund and add EIP-7702 refund to gas.
self.refund(evm, exec_result, eip7702_gas_refund);
// Ensure gas floor is met and minimum floor gas is spent.
// if `cfg.is_eip7623_disabled` is true, floor gas will be set to zero
self.eip7623_check_gas_floor(evm, exec_result, init_and_floor_gas);
// Return unused gas to caller
self.reimburse_caller(evm, exec_result)?;
Expand Down Expand Up @@ -251,7 +252,12 @@ pub trait Handler {
#[inline]
fn validate_initial_tx_gas(&self, evm: &Self::Evm) -> Result<InitialAndFloorGas, Self::Error> {
let ctx = evm.ctx_ref();
validation::validate_initial_tx_gas(ctx.tx(), ctx.cfg().spec().into()).map_err(From::from)
validation::validate_initial_tx_gas(
ctx.tx(),
ctx.cfg().spec().into(),
ctx.cfg().is_eip7623_disabled(),
)
.map_err(From::from)
}

/* PRE EXECUTION */
Expand Down
7 changes: 6 additions & 1 deletion crates/handler/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,13 @@ pub fn validate_tx_env<CTX: ContextTr>(
pub fn validate_initial_tx_gas(
tx: impl Transaction,
spec: SpecId,
is_eip7623_disabled: bool,
) -> Result<InitialAndFloorGas, InvalidTransaction> {
let gas = gas::calculate_initial_tx_gas_for_tx(&tx, spec);
let mut gas = gas::calculate_initial_tx_gas_for_tx(&tx, spec);

if is_eip7623_disabled {
gas.floor_gas = 0
}

// Additional check to see if limit is big enough to cover initial gas.
if gas.initial_gas > tx.gas_limit() {
Expand Down
2 changes: 2 additions & 0 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ dev = [
"optional_block_gas_limit",
"optional_eip3541",
"optional_eip3607",
"optional_eip7623",
"optional_no_base_fee",
]
memory_limit = ["context/memory_limit", "interpreter/memory_limit"]
optional_balance_check = ["context/optional_balance_check"]
optional_block_gas_limit = ["context/optional_block_gas_limit"]
optional_eip3541 = ["context/optional_eip3541"]
optional_eip3607 = ["context/optional_eip3607"]
optional_eip7623 = ["context/optional_eip7623"]
optional_no_base_fee = ["context/optional_no_base_fee"]

# Precompiles features: Please look at the comments in `precompile` crate for more information.
Expand Down
Loading