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

feat(forge script): add --gas-price-multiplier #9067

Open
409H opened this issue Oct 8, 2024 · 2 comments
Open

feat(forge script): add --gas-price-multiplier #9067

409H opened this issue Oct 8, 2024 · 2 comments
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-feature Type: feature T-post-V1 Area: to tackle after V1

Comments

@409H
Copy link

409H commented Oct 8, 2024

Component

Forge

Describe the feature you would like

When running forge script script/deploy.s.sol and specifying the gas params, either with -g or --gas-price, the output of the simulation (running without --broadcast) shows the estimated gas price of the current block, not what was specified with the cli params and can be confusing.

As per the docs, supplying -g will multiply the estimated gas by some number.

If gas price is 65 gwei, and we want to deploy with 6 gwei, we could specify -g 10

Current avg gas price: 65 gwei
Call: forge script script/deploy.s.sol:DeployScript -g 10 --rpc-url https://cloudflare-eth.com/

However, in doing so, the output still specifies the 65 gwei. Interpretation of the output could be that we will deploy with 65 gwei gas price.

## Setting up 1 EVM.

==========================

Chain 1

Estimated gas price: 64.375837984 gwei

Estimated total gas used for script: 15627

Estimated amount required: 0.001006001220175968 ETH

We can confirm the estimated amount required is correct and uses what we specify with -g by calling the same exec with -g 1000.

Current avg gas price: 65 gwei
Call: forge script script/deploy.s.sol:DeployScript -g 1000 --rpc-url https://cloudflare-eth.com/

## Setting up 1 EVM.

==========================

Chain 1

Estimated gas price: 64.834925182 gwei

Estimated total gas used for script: 1562760

Estimated amount required: 0.10132142767742232 ETH

It seems to be that Estimated gas price: is not overridden with what we specify in the args but instead of always the gas price of the current block.

Ask:

In the output, either;

  • relabel Estimated gas price: to what we specify (in the case of -g 10, it should read Estimated gas price: 6.4834925182 gwei)
  • relabel Estimated gas price: to something more accurate such as Block gas price and then a new line item with Broadcasting with gas price: if the user specifies a gas price with -g or --gas-price.

Additional context

No response

@409H 409H added T-feature Type: feature T-needs-triage Type: this issue needs to be labelled labels Oct 8, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Oct 8, 2024
@zerosnacks zerosnacks changed the title forge script output to specify set gas price bug(forge script): Estimated gas price: field in script result does not adjust based on --gas-estimate-multiplier value Oct 8, 2024
@zerosnacks zerosnacks added Cmd-forge-script Command: forge script T-to-investigate Type: to investigate T-bug Type: bug and removed T-needs-triage Type: this issue needs to be labelled T-feature Type: feature labels Oct 8, 2024
@zerosnacks zerosnacks changed the title bug(forge script): Estimated gas price: field in script result does not adjust based on --gas-estimate-multiplier value feat(forge script): add --gas-price-multiplier Oct 9, 2024
@zerosnacks
Copy link
Member

zerosnacks commented Oct 9, 2024

Hi @409H

--gas-estimate-multiplier decreases / the gas limit of the transaction by a scalar, you can see an example here: https://holesky.etherscan.io/tx/0x16f18c36af6f987282d846b58e9ab982f9c813f53f9deb8b947c01c3c8b693f4

1,067,150 | 106,733 (10%) when -g is set to 1000 (think of this as specifying a budget of gas the transaction is allowed to use)

I think what you are requesting is a new flag called --gas-price-multiplier which would multiply the gas_price or max_fee_per_gas field by a scalar (as in 6.4 gwei -> 64 gwei)

@zerosnacks zerosnacks added T-feature Type: feature C-forge Command: forge and removed T-bug Type: bug T-to-investigate Type: to investigate labels Oct 9, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Oct 9, 2024
@409H
Copy link
Author

409H commented Oct 15, 2024

@zerosnacks Ah yes, sorry -- good catch. Yes, you're correct in what I mean

@grandizzy grandizzy removed this from the v1.0.0 milestone Nov 5, 2024
@grandizzy grandizzy added the T-post-V1 Area: to tackle after V1 label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-feature Type: feature T-post-V1 Area: to tackle after V1
Projects
Status: Todo
Development

No branches or pull requests

4 participants
@409H @grandizzy @zerosnacks and others