diff --git a/crates/context/Cargo.toml b/crates/context/Cargo.toml index 4a1ae51caf..d116dd039f 100644 --- a/crates/context/Cargo.toml +++ b/crates/context/Cargo.toml @@ -67,6 +67,7 @@ dev = [ "optional_eip3607", "optional_no_base_fee", "optional_priority_fee_check", + "optional_fee_charge", ] memory_limit = [] optional_balance_check = [] @@ -75,3 +76,4 @@ optional_eip3541 = [] optional_eip3607 = [] optional_no_base_fee = [] optional_priority_fee_check = [] +optional_fee_charge = [] diff --git a/crates/context/interface/src/cfg.rs b/crates/context/interface/src/cfg.rs index cd91706edc..6454557e92 100644 --- a/crates/context/interface/src/cfg.rs +++ b/crates/context/interface/src/cfg.rs @@ -58,6 +58,9 @@ pub trait Cfg { /// Returns whether the priority fee check is disabled. fn is_priority_fee_check_disabled(&self) -> bool; + + /// Returns whether the fee charge is disabled. + fn is_fee_charge_disabled(&self) -> bool; } /// What bytecode analysis to perform diff --git a/crates/context/src/cfg.rs b/crates/context/src/cfg.rs index 788b358cfc..db2194506a 100644 --- a/crates/context/src/cfg.rs +++ b/crates/context/src/cfg.rs @@ -104,6 +104,12 @@ pub struct CfgEnv { /// By default, it is set to `false`. #[cfg(feature = "optional_priority_fee_check")] pub disable_priority_fee_check: bool, + /// Disables fee charging for transactions. + /// This is useful when executing `eth_call` for example, on OP-chains where setting the base fee + /// to 0 isn't sufficient. + /// By default, it is set to `false`. + #[cfg(feature = "optional_fee_charge")] + pub disable_fee_charge: bool, } impl CfgEnv { @@ -159,6 +165,8 @@ impl CfgEnv { disable_base_fee: false, #[cfg(feature = "optional_priority_fee_check")] disable_priority_fee_check: false, + #[cfg(feature = "optional_fee_charge")] + disable_fee_charge: false, } } @@ -206,6 +214,8 @@ impl CfgEnv { disable_base_fee: self.disable_base_fee, #[cfg(feature = "optional_priority_fee_check")] disable_priority_fee_check: self.disable_priority_fee_check, + #[cfg(feature = "optional_fee_charge")] + disable_fee_charge: self.disable_fee_charge, } } @@ -231,6 +241,13 @@ impl CfgEnv { self.disable_priority_fee_check = disable; self } + + /// Sets the disable fee charge flag. + #[cfg(feature = "optional_fee_charge")] + pub fn with_disable_fee_charge(mut self, disable: bool) -> Self { + self.disable_fee_charge = disable; + self + } } impl + Copy> Cfg for CfgEnv { @@ -344,6 +361,16 @@ impl + Copy> Cfg for CfgEnv { } } } + + fn is_fee_charge_disabled(&self) -> bool { + cfg_if::cfg_if! { + if #[cfg(feature = "optional_fee_charge")] { + self.disable_fee_charge + } else { + false + } + } + } } impl Default for CfgEnv { diff --git a/crates/op-revm/src/handler.rs b/crates/op-revm/src/handler.rs index 5e25ff738c..64a91db80c 100644 --- a/crates/op-revm/src/handler.rs +++ b/crates/op-revm/src/handler.rs @@ -115,7 +115,7 @@ where let mut additional_cost = U256::ZERO; // The L1-cost fee is only computed for Optimism non-deposit transactions. - if !is_deposit { + if !is_deposit && !ctx.cfg().is_fee_charge_disabled() { // L1 block info is stored in the context for later use. // and it will be reloaded from the database if it is not for the current block. if ctx.chain().l2_block != block_number {