Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Overestimated gas prices for cheap chains #7089

@klkvr

Description

@klkvr

Component

Forge

Describe the bug

Mentioned in #6503 (comment) and #4903 (comment).

Currently, due to ethers internals being oriented on Mainnet, gas prices for scripts are often over-estimated to be around 3 gwei when the actually needed gas price might be less than 1 gwei.

It can be reproduced by dry-running any script on any L2 via forge script <SCRIPT_CONTRACT> --rpc-url <RPC_OF_L2>

For Arbitrum the output will include

Estimated gas price: 3.2 gwei

And the estimation of required funds for execution will be calculated considering gas price being 3.2 as well, which is much higher than is actually needed and can result in script failing due to sender not having enough funds.

This is reproducible on Optimism, Base, Arbitrum and any other cheap chain I believe. Currently common workaround is to add --legacy flag to the command which helps avoiding priority fee calculation.

I am not sure what's the best way to fix this as it is possible that we might break some scenarios as for some L2s this overestimation helped avoiding situations when script sender does not have enough funds to cover additional L2 fees. For example, the actuall gas price on Base is around 0.000000315, but usually most of tx cost is coming from L1 fees which are not included in the estimation currently

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Completed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions