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

Arbitrum Goerli forge script - intrinsic gas too low #3487

Closed
2 tasks done
jaeaster opened this issue Oct 13, 2022 · 7 comments · Fixed by #3508
Closed
2 tasks done

Arbitrum Goerli forge script - intrinsic gas too low #3487

jaeaster opened this issue Oct 13, 2022 · 7 comments · Fixed by #3508
Labels
C-forge Command: forge Cmd-forge-script Command: forge script good first issue Good for newcomers T-bug Type: bug

Comments

@jaeaster
Copy link
Contributor

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (28312e7 2022-10-13T00:10:09.318425Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

I have a simple script to deploy a contract. This script executes successfully on Goerli and Arbitrum Rinkeby, but it fails on Arbitrum Goerli with (code: -32000, message: intrinsic gas too low, data: None)

I have tried Alchemy RPC + public RPC (https://goerli-rollup.arbitrum.io/rpc/)

Very weird that Arbitrum Rinkeby works, but Arbitrum Goerli does not. They both run Arbitrum Nitro ... perhaps Goerli is running a newer version since Rinkeby is deprecated...?

Also, I tried increasing the gas price and gas limit by many multiples, but that didn't change anything. And I have more than enough ArbGoerli ETH in my EOA.

The transaction requests are identical between rinkeby and goerli, aside from the nonce, but I also tried using a fresh account with nonce = 0 on goerli and that also didn't change anything:

      "transaction": {
        "type": "0x00",
        "from": "0x...",
        "gas": "0x1c60d2",
        "value": "0x0",
        "data": "0x...",
        "nonce": "0x0"
      },

Full output:

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

Estimated total gas used for script: 1859794

Estimated amount required: 0.0001859794 ETH

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

###
Finding wallets for all the necessary addresses...
##
Sending transactions [0 - 0].

Transactions saved to: broadcast/DeployFactory.s.sol/421613/run-latest.json

Error:
(code: -32000, message: intrinsic gas too low, data: None)

Script:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "forge-std/Script.sol";
import "../src/Factory.sol";

contract DeployFactory is Script {
    function run() external {
        uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

        vm.startBroadcast(deployerPrivateKey);
        new Factory();
        vm.stopBroadcast();
    }
}

@jaeaster jaeaster added the T-bug Type: bug label Oct 13, 2022
@gakonst gakonst added this to Foundry Oct 13, 2022
@gakonst gakonst moved this to Todo in Foundry Oct 13, 2022
@jaeaster
Copy link
Contributor Author

Also, just tried a simple forge create and that works successfully
forge create Factory --rpc-url arbitrum-goerli

@jaeaster
Copy link
Contributor Author

Ok I managed to get the script working...

I had to pass --skip-simulation

The estimated gas usage with simulation was 1,859,794

Without simulation, the gas limit was set to ~20M while the gas used was ~14M

So the gas estimation is off. Does forge estimate gas with the local EVM (rEVM?)? Does it call out to the provider?

@gakonst
Copy link
Member

gakonst commented Oct 14, 2022

@joshieDo do you remember if there is an issue with the arbitrum gas calculation logic? this has been increasingly common

@rkrasiuk rkrasiuk added C-forge Command: forge Cmd-forge-script Command: forge script labels Oct 17, 2022
@joshieDo
Copy link
Collaborator

So the gas estimation is off. Does forge estimate gas with the local EVM (rEVM?)? Does it call out to the provider?

It should be calling out to the provider

@joshieDo
Copy link
Collaborator

joshieDo commented Oct 18, 2022

pub fn has_different_gas_calc(chain: u64) -> bool {
if let ConfigChain::Named(chain) = ConfigChain::from(chain) {
return matches!(chain, Chain::Arbitrum | Chain::ArbitrumTestnet)
}

Very weird that Arbitrum Rinkeby works, but Arbitrum Goerli does not. They both run Arbitrum Nitro ... perhaps Goerli is running a newer version since Rinkeby is deprecated...?

Yeah that explains it. We only have one Arbitrum testnet, we need to add Chain::ArbitrumGoerli .

--skip-simulation works because it's during the simulation that we calculate the gas usage. With the flag, we ask the provider for the gas estimation.

@joshieDo joshieDo added the good first issue Good for newcomers label Oct 18, 2022
Repository owner moved this from Todo to Done in Foundry Oct 18, 2022
@philburrrt
Copy link

Ok I managed to get the script working...

I had to pass --skip-simulation

The estimated gas usage with simulation was 1,859,794

Without simulation, the gas limit was set to ~20M while the gas used was ~14M

So the gas estimation is off. Does forge estimate gas with the local EVM (rEVM?)? Does it call out to the provider?

this fixed the same issue i was having with arbitrum mainnet

@ratio91
Copy link

ratio91 commented Jun 24, 2024

--skip-simulation solved this issue for me on Mantle as well.

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 good first issue Good for newcomers T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants