gakonst / ethers-rs

Complete Ethereum & Celo library and wallet implementation in Rust. https://docs.rs/ethers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proper gas estimation for L2's

Sabnock01 opened this issue · comments

Is your feature request related to a problem? Please describe.
A core issue not only for Foundry but also wallets as of late has been accurate estimation of gas fees for L2's such as Optimism and Arbitrum.

Describe the solution you'd like
The current paradigm for using a gas estimation service is the ethers-middleware crate which contains gas oracle implementations. Notably, Polygon is present yet the way it as well as the other gas oracle implementations operate is to in essence query an API endpoint, get a JSON response and parse it into the response for estimate_eip1559_fees used in both ethers-middleware and Foundry.

It would be preferable if we could construct gas oracles for Optimism and Arbitrum in a similar vein yet I do not believe similar fee estimation endpoints exist for either of these. (I know one doesn't for Optimism, still investigating Arbitrum)

Describe alternatives you've considered
Optimism has a fee estimation package which calculates fees by calling the GasPriceOracle predeploy's functions. This functionality is being superceded by op-viem though the functionality is not yet merged. I've considered a possible solution where we could do something similar in the gas oracle implementation in ethers-rs where we simply use the GasPriceOracle predeploy as the source of truth but we would need access to a provider and I'm not sure how viable this solution is.

Additional context
The solution space for this task may very well change before it is addressed (Foundry may transition completely to alloy) so more than happy to discuss approaches in the comments of this issue.

Fixed via #7638