Skip to content

feat(forge): create add scale-gas-limit #1928

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

Closed

Conversation

shawnharmsen
Copy link
Contributor

@shawnharmsen shawnharmsen commented Jun 13, 2022

closes: #1803

Opened as draft to get some guidance, if you wouldn't mind pointing me in the right direction.

  1. Trying to figure out how to multiply the gas_limit to get a scaled 10% or 20%, etc
#[clap(
    long = "scale-gas-limit",
    help_heading = "TRANSACTION OPTIONS",
    help = "Scale the gas limit by the given percentage.",
    value_name = "NUM"
)]
scale_gas_limit: Option<U256>,

if let Some(gas_limit) = self.gas_limit {
    if let Some(scale_gas_limit) = self.scale_gas_limit {
        // let new_gas_limit = gas_limit * (1f64 + (scale_gas_limit / 100f64));
        // deployer.tx.set_gas(new_gas_limit);
        deployer.tx.set_gas(gas_limit * scale_gas_limit);
    } else {
        deployer.tx.set_gas(gas_limit);
    }
}

Currently it works as full number multiplier -ex: --gas-limit 2000000 --scale-gas-limit 2

➜  playground git:(main) ~/CLionProjects/foundry/target/debug/forge create --rpc-url $MUMBAI_RPC_URL --constructor-args "Zech" "ZCH" --private-key $PRIVATE_KEY src/NFT.sol:Zech --gas-limit 2000000 --scale-gas-limit 2
[⠑] Compiling...
No files changed, compilation skipped
Deployer: 0x28a435d0fe95e127e6b95babf232d5739217b3f0
Deployed to: 0x29ba3e20fa76aff8bb5a2a19ac4e4b5a2febbd95
Transaction hash: 0x118474b9e53720e351c546d6aadee29c882d0c541eab21c298862dd39399c7cf

Gives a 4 million gas limit

Motivation

Solution

@onbjerg onbjerg added the T-feature Type: feature label Jun 13, 2022
@Genysys
Copy link
Contributor

Genysys commented Jun 15, 2022

I think the issue is because what you are trying to do is 1.2 which is not an integer i.e. U256 ; maybe a helper function that converts the scaling factor to fraction and then multiplies it might help. i.e. 1.2 becomes. 6/5 .

so

    deployer.tx.set_gas(gas_limit * scale_gas_limit);
    ```
    
    becomes 
    
  deployer.tx.set_gas((gas_limit * scale_gas_limit_numerator)/scale_gas_limit_denominator);
```
might work

@shawnharmsen
Copy link
Contributor Author

apologies but I've been a bit swamped.

I'd like to revisit this again when things die down.

I will close this issue if it is considered stale.

@rkrasiuk rkrasiuk added C-forge Command: forge Cmd-forge-create Command: forge create labels Aug 23, 2022
@onbjerg
Copy link
Collaborator

onbjerg commented Aug 23, 2022

Closing as stale 👍 Feel free to reopen if you get the time :)

@onbjerg onbjerg closed this Aug 23, 2022
@shawnharmsen shawnharmsen deleted the forge-create-scale-gas branch September 15, 2022 05:02
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-create Command: forge create T-feature Type: feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(forge create / cast send): add --gas-estimate-multiplier flag
4 participants