Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(anvil): disable basefee if manually set to 0 #5126

Merged
merged 3 commits into from
Jun 9, 2023
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
16 changes: 15 additions & 1 deletion anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,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();
Expand Down Expand Up @@ -1014,6 +1021,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
}

Expand Down
1 change: 1 addition & 0 deletions evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ revm = { version = "3", default-features = false, features = [
"memory_limit",
"optional_eip3607",
"optional_block_gas_limit",
"optional_no_base_fee"
] }

# Fuzzer
Expand Down
5 changes: 5 additions & 0 deletions evm/src/executor/fork/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down