foundry-rs / foundry-rs/foundry

feat(`forge script`): add `--gas-price-multiplier`

Open
#9,067 2 comments 0 reactions 0 assignees View on GitHub
C-forge Cmd-forge-script T-feature T-post-V1
Dominant language
Rust
Stars
10.6k
Forks
2.6k
Avg merge
16h 38m
Merged PRs (30d)
511

Description

### 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](https://book.getfoundry.sh/reference/forge/forge-script), 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.