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): use default gas limit if zero #3254

Merged
merged 1 commit into from
Sep 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,16 @@ impl NodeConfig {
panic!("Failed to get block for block number: {}", fork_block_number)
};

// we only use the gas limit value of the block if it is non-zero, since there are networks where this is not used and is always `0x0` which would inevitably result in `OutOfGas` errors as soon as the evm is about to record gas, See also <https://github.com/foundry-rs/foundry/issues/3247>

let gas_limit =
if block.gas_limit.is_zero() { env.block.gas_limit } else { block.gas_limit };

env.block = BlockEnv {
number: fork_block_number.into(),
timestamp: block.timestamp,
difficulty: block.difficulty,
gas_limit: block.gas_limit,
gas_limit,
// Keep previous `coinbase` and `basefee` value
coinbase: env.block.coinbase,
basefee: env.block.basefee,
Expand Down