diff --git a/anvil/src/eth/backend/mem/mod.rs b/anvil/src/eth/backend/mem/mod.rs index 6c9bf6916742..69f7e0193f19 100644 --- a/anvil/src/eth/backend/mem/mod.rs +++ b/anvil/src/eth/backend/mem/mod.rs @@ -780,7 +780,14 @@ impl Backend { let (outcome, header, block_hash) = { let current_base_fee = self.base_fee(); - let mut env = self.env.read().clone(); + let mut env = self.env().read().clone(); + + if env.block.basefee == revm::primitives::U256::ZERO { + // this is an edge case because the evm fails if `tx.effective_gas_price < base_fee` + // 0 is only possible if it's manually set + env.cfg.disable_base_fee = true; + } + // increase block number for this block env.block.number = env.block.number.saturating_add(rU256::from(1)); env.block.basefee = current_base_fee.into(); @@ -1013,6 +1020,13 @@ impl Backend { nonce: nonce.map(|n| n.as_u64()), access_list: to_revm_access_list(access_list.unwrap_or_default()), }; + + if env.block.basefee == revm::primitives::U256::ZERO { + // this is an edge case because the evm fails if `tx.effective_gas_price < base_fee` + // 0 is only possible if it's manually set + env.cfg.disable_base_fee = true; + } + env } diff --git a/evm/Cargo.toml b/evm/Cargo.toml index 76af3745c8d2..0adb88c36cfc 100644 --- a/evm/Cargo.toml +++ b/evm/Cargo.toml @@ -43,6 +43,7 @@ revm = { version = "3", default-features = false, features = [ "memory_limit", "optional_eip3607", "optional_block_gas_limit", + "optional_no_base_fee" ] } # Fuzzer diff --git a/evm/src/executor/fork/cache.rs b/evm/src/executor/fork/cache.rs index 8e94796b0871..7e8a0caa8747 100644 --- a/evm/src/executor/fork/cache.rs +++ b/evm/src/executor/fork/cache.rs @@ -177,6 +177,11 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta { // keep default value obj.insert(key.to_string(), false.into()); } + let key = "disable_base_fee"; + if !obj.contains_key(key) { + // keep default value + obj.insert(key.to_string(), false.into()); + } } let cfg_env: revm::primitives::CfgEnv =