-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Gas estimation message for EIP1559 txs is extremely misleading #5709
Comments
cc @Sabnock01 |
Taking a look |
Are there any updates on this? It is inconvenient to deploy on L2s without being able to specify the priority fee especially if there is network congestion and the base fee is fluctuating. |
@simplyoptimistic ack—we thought this had been fixed with new refactors. Looking |
So, this flag is working as intended, but the estimation output is wrong. This happens because the priority gas price is applied just before sending the transaction ()https://github.com/foundry-rs/foundry/blob/master/crates/forge/bin/cmd/script/broadcast.rs#L106), instead of being applied when the script sequence is being created (https://github.com/foundry-rs/foundry/blob/master/crates/forge/bin/cmd/script/broadcast.rs#L541-L544). This means that when calculating the EIP1559 price, the default estimator is used which has the hardcoded tip, but the transaction is sent with the correct priority gas price and the most up-to-date base fee possible. This does mean though that this leads to massive overpaying on L2s as the default estimator uses the hardcoded tip which is excessive. The correct fix for this is to make a custom estimator which can take a non-hardcoded tip, but this will require changes upstream on alloy / ethers. |
The problem is deeper, even when you specify the tip by hand you overpay, and this affect both L1 & L2 Exhibit A:
Exhibit B:
Been overspending on deployments/scripts for a while now, I'm pretty sure I raised a separate issue a while ago for this. |
Looks like this has been fixed, at least with simulations. Thanks for the hard work! Will report if I have any issues with this. |
@simplyoptimistic whats the solution ?? |
|
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (1143e57 2023-08-24T00:28:32.561836000Z)
What command(s) is the bug in?
forge script
Operating System
None
Describe the bug
--priority-gas-price was implemented in #5281
My version of foundry is up to date.
Expected behavior: when I use --priority-gas-price, it lowers my gas fee on deployment and doesn't use foundry's default 3 gwei tip.
To reproduce, create a fresh repository and deploy. I ran the following command:
forge script script/Counter.s.sol:CounterScript --priority-gas-price 100 --broadcast --slow --rpc-url optimism -vvvv
This is the output:
Following the suggestion in #5281, I use
--legacy --with-gas-price
:forge script script/Counter.s.sol:CounterScript --legacy --with-gas-price 100 --broadcast --slow --rpc-url optimism -vvvv
This is the output:
I have also tried by using the environment variable alias, it also doesn't work.
The text was updated successfully, but these errors were encountered: