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 @@ -67,6 +67,7 @@ dev = [
"optional_eip3607",
"optional_no_base_fee",
"optional_priority_fee_check",
"optional_fee_charge",
]
memory_limit = []
optional_balance_check = []
Expand All @@ -75,3 +76,4 @@ optional_eip3541 = []
optional_eip3607 = []
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 @@ -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
Expand Down
27 changes: 27 additions & 0 deletions crates/context/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ pub struct CfgEnv<SPEC = SpecId> {
/// 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 {
Expand Down Expand Up @@ -159,6 +165,8 @@ impl<SPEC> CfgEnv<SPEC> {
disable_base_fee: false,
#[cfg(feature = "optional_priority_fee_check")]
disable_priority_fee_check: false,
#[cfg(feature = "optional_fee_charge")]
disable_fee_charge: false,
}
}

Expand Down Expand Up @@ -206,6 +214,8 @@ impl<SPEC> CfgEnv<SPEC> {
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,
}
}

Expand All @@ -231,6 +241,13 @@ impl<SPEC> CfgEnv<SPEC> {
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<SPEC: Into<SpecId> + Copy> Cfg for CfgEnv<SPEC> {
Expand Down Expand Up @@ -344,6 +361,16 @@ impl<SPEC: Into<SpecId> + Copy> Cfg for CfgEnv<SPEC> {
}
}
}

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

impl<SPEC: Default> Default for CfgEnv<SPEC> {
Expand Down
2 changes: 1 addition & 1 deletion crates/op-revm/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checks out

// 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 {
Expand Down
Loading