Skip to content

bug(anvil): eth_estimateGas max_fee_per_gas overrides the block.basefee when simulating a transaction #8516

Closed
@jakim929

Description

@jakim929

Component

Anvil

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (e903484 2024-07-19T00:18:41.070490000Z)

What command(s) is the bug in?

anvil

Operating System

macOS (Apple Silicon)

Describe the bug

Opened an issue since I'm not sure if this is intended behavior.

when calling eth_estimateGas, the max_fee_per_gas parameter included in the tx ends up overwriting the block.basefee. Is there a reason for this? This makes it harder to estimate gas for contracts that rely on the value of block.basefee (although I see it's not a common issue).

the FeeDetails is created based on the transaction params, then

let fees = FeeDetails::new(
request.gas_price,
request.max_fee_per_gas,
request.max_priority_fee_per_gas,
request.max_fee_per_blob_gas,
)?
.or_zero_fees();

used in this line to override the block's basefee.

if let Some(base) = max_fee_per_gas {
env.block.basefee = U256::from(base);
}

Given the spec here, I would expect that all that eth_estimateGas does is set the block gas limit if unspecified, not change anything about the block otherwise. Curious if this is intended behavior? Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions