foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Failed to estimate gas for CREATE2 deployment on Arbitrum

Open Nemusonaneko opened this issue 2 years ago • 4 comments

Component

Forge

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

  • [X] Foundry
  • [X] Foundryup

What version of Foundry are you on?

forge 0.2.0 (5910e7b 2022-08-25T00:04:03.61597382Z)

What command(s) is the bug in?

forge script

Operating System

Linux

Describe the bug

Running this script using this command: forge script script/LlamaPayBotDeploy.sol --private-key "${PRIVATE_KEY}" --rpc-url "${ARBITRUM_RPC}" --verify --broadcast --etherscan-api-key "${ARBISCAN_API_KEY}" results in forge not being able to estimate gas for tx.

I have also tried trying multiple Arbitrum RPCs and it yields the same result.

image

Nemusonaneko avatar Aug 25 '22 15:08 Nemusonaneko

Seems like the CREATE2 deployer we use 0x4e59b44847b379578588920ca78fbf26c0b4956c is not deployed on arbitrum.

joshieDo avatar Aug 25 '22 17:08 joshieDo

It is deployed on mainnet and rinkeby arbitrum but it may not be deployed on the new nitro goerli deploy if that's what you're testing

$ cast code 0x4e59b44847b379578588920ca78fbf26c0b4956c --rpc-url $ARBITRUM_RPC_URL
0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3

mds1 avatar Aug 25 '22 17:08 mds1

It is deployed on mainnet and rinkeby arbitrum but it may not be deployed on the new nitro goerli deploy if that's what you're testing

Am trying to deploy on mainnet

Nemusonaneko avatar Aug 25 '22 19:08 Nemusonaneko

I'm experiencing the same issue but not related to CREATE2. When I try to deploy something to arbitrum I get the failed to extimate gas for tx error, but when I try to deploy the same contract to mainnet it works with no issues. I tried with alchemy private endpoints and also anker public endpoints and I'm getting the same behavior with both

UPDATE: I can confirm this happens only when using scripts, deploying through forge create works just fine

0xchoripan avatar Sep 07 '22 17:09 0xchoripan

running into this as well atm -- anyone look into it yet or have a work around (short of deploying w create which doesn't have deterministic deploys)?

wminshew avatar Oct 05 '22 21:10 wminshew

fwiw

forge 0.2.0 (83a9dc7 2022-10-05T00:15:21.378381Z)

wminshew avatar Oct 05 '22 21:10 wminshew

@joshieDo have you noticed any issues testing w arb mainnet on https://github.com/foundry-rs/foundry/pull/2541 ?

wminshew avatar Oct 07 '22 21:10 wminshew

hey guys, any update by chance? having the same issue for arbitrum mainnet, can't call a write function on a deployed contract with forge scripts, the exact same set up works with arbitrum goerli. command looked like this:

forge script script/MyContract.s.sol:MyScript --rpc-url https://rpc.ankr.com/arbitrum --broadcast ususally get a message like this: Script ran successfully. Error: Failed to estimate gas for tx: 0x513b…88e4

Occasionally ill get this message:

` The application panicked (crashed). Message: Could not instantiate forked environment: Could not instantiate forked environment with fork url: https://arb1.arbitrum.io/rpc

Context:

  • Failed to get block for block number: 29225231 latest block number: 29225231 Location: C:\Users\13018.cargo\git\checkouts\foundry-f7cca724e93059b0\3a462eb\evm\src\executor\opts.rs:56

This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry `

I've tried several different rpc urls found on https://chainlist.org/ please let me know if i did something wrong! Thanks!

nolanjannotta avatar Oct 09 '22 15:10 nolanjannotta

just ran into this on arbitrum-goerli as well (can recreate via https://github.com/0xSplits/splits-liquid script simulation)

wminshew avatar Oct 25 '22 04:10 wminshew

hmm @wminshew what's the forge script command that results in an error here? will debug.

mattsse avatar Oct 25 '22 08:10 mattsse

hmm @wminshew what's the forge script command that results in an error here? will debug.

in https://github.com/0xSplits/splits-liquid you can run

forge script script/LiquidSplitFactory.s.sol:LiquidSplitFactoryScript --rpc-url $ARB_RPC_URL -vvvv forge script script/LiquidSplitFactory.s.sol:LiquidSplitFactoryScript --rpc-url $ARB_GOERLI_RPC_URL -vvvv

in https://github.com/0xSplits/splits-waterfall you can run

forge script script/WaterfallModuleFactory.s.sol:WaterfallModuleFactoryScript --rpc-url $ARB_RPC_URL -vvvv

(interestingly enough 20 days ago arb-goerli worked in the waterfall repo although on the latest foundryup I don't think it's working anymore)

wminshew avatar Oct 25 '22 15:10 wminshew

@wminshew found a but with gas estimation for chains that have different calc, with #3549 I was able to deploy succesfully.

mattsse avatar Oct 26 '22 09:10 mattsse

@wminshew found a but with gas estimation for chains that have different calc, with #3549 I was able to deploy succesfully.

thanks for the quick turn around. Confirmed to work on arb mainnet w waterfall repo & on arb mainnet & goerli w liquid repo

looks like the ordering of contracts in verification has changed (for the worse), but will open a separate issue for that

thank you!

wminshew avatar Oct 26 '22 13:10 wminshew

I'm still encountering this error as well, on all Arbitrum networks - One, Nova, and Goerli.

emo-eth avatar Nov 19 '22 00:11 emo-eth

Hello, same here, I'm still getting the error while deploying on an Arbitrum fork in script with forge version 0.2.0 (15c0226 2022-11-18T00:11:16.546830339Z).

xenoliss avatar Nov 21 '22 11:11 xenoliss

Are people still seeing this error now that arbitrum has upgraded to nitro on mainnet/testnets?

mds1 avatar Apr 11 '23 23:04 mds1

Yup, I see this regularly while trying to deploy to Arbitrum Goerli (at times there is also the RPC error of max fee per gas less than block base fee)

wagmiwiz avatar Apr 13 '23 12:04 wagmiwiz

Saw this error while trying to deploy on Arbitrum today, and it seems to be due to a gas estimation error (tried multiple RPCs to be sure) image.

Actual deployment cost was 0.0039331355 ETH. I had to top up my deployer with excess ETH for this deployment to succeed.

suhailgme avatar Jul 05 '23 10:07 suhailgme

Saw this error while trying to deploy on Arbitrum today, and it seems to be due to a gas estimation error (tried multiple RPCs to be sure) image.

Actual deployment cost was 0.0039331355 ETH. I had to top up my deployer with excess ETH for this deployment to succeed.

Bumping for visibility, we cannot deploy to arbitrum mainnet with most recent foundry

`Failed to estimate gas for tx: 0xc0dfd71034b0e538500086df53633683f769e6365db61fc579f6473933053560´

Also, estimated total cost for all transactions is a whopping 6.22 ETH. Something wrong is going on

foundryup: installed - forge 0.2.0 (0e33b3e 2023-07-28T00:23:39.362605000Z) foundryup: installed - cast 0.2.0 (0e33b3e 2023-07-28T00:23:39.362605000Z) foundryup: installed - anvil 0.1.0 (0e33b3e 2023-07-28T00:23:55.455062000Z) foundryup: installed - chisel 0.1.0 (0e33b3e 2023-07-28T00:23:55.584471000Z)

tagging @gakonst @Evalir

0xTimepunk avatar Jul 28 '23 17:07 0xTimepunk

I am also experiencing a similar problem when attempting to deploy to arbitrum.

adamxyzxyz avatar Aug 22 '23 14:08 adamxyzxyz

We recently introduce a flag to script --priority-gas-price(#5585, see docs)—This should help alleviate the high cost issue by letting y'all set the price manually. Please try it and let us know 🙏

Evalir avatar Aug 22 '23 14:08 Evalir

Will give that a try, FWIW I was receiving this error while using forge create. Adding the --legacy flag seemed to alleviate the issue.

adamxyzxyz avatar Aug 22 '23 14:08 adamxyzxyz

Makes sense! we should prob replicate this for create if it's not there already

Evalir avatar Aug 22 '23 14:08 Evalir

Any updates here? I have the same error when deploying to an Arbitrum One fork.

--priority-gas-price flag does not alleviate the issue.

NouDaimon avatar Sep 20 '23 15:09 NouDaimon

Any updates here? I have the same error when deploying to an Arbitrum One fork.

--priority-gas-price flag does not alleviate the issue.

Seems like this is because of the push0 opcode not supported on Arbitrum.

Dropping to 0.8.19 pragma allowed deployment.

NouDaimon avatar Sep 21 '23 11:09 NouDaimon

0.8.19 did not help, issue still valid,

used --legacy option for workaround on Arbitrum Sepolia

Also had to use --with-gas-price 100000000 once.

radeksvarz avatar Dec 20 '23 16:12 radeksvarz

Cannot deploy towards Tenderly devnet (Arbitrum):

Chain 421611

Estimated gas price: 0.1 gwei

Estimated total gas used for script: 50945202

Estimated amount required: 0.0050945202 ETH

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

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

Error: 
Failed to estimate gas for tx: 0xfec8e1a395163625e93b680a4ed4f3bf2a...

Context:
- (code: 3, message: insufficient funds for gas * price + value, data: None)

radeksvarz avatar Dec 21 '23 23:12 radeksvarz

Still valid issue with latest foundryup.

Failed to estimate gas for tx: 0x2abb866e7fbd57919ac30c1a9867f6bf16446c911f5e229406ac5fb7e374e2ba

Tested towards latest fork of Arbitrum Sepolia (by Tenderly testnets) with:

💤 forge script script/DeployArbitrum.s.sol -vvvv --rpc-url $RPC --trezor --hd-paths "m/44'/60'/0'/0/xx" --sender 0x... --legacy --with-gas-price 100000000 --slow --broadcast

where I checked up front the sender has enough funds.

Interestingly it was deployed without error towards latest Arbitrum production fork.

radeksvarz avatar Jan 07 '24 21:01 radeksvarz

I had to use the --legacy flag to deploy to Arbitrum One, no other options of setting a fixed gas price worked until I used a legacy flag.

stevyhacker avatar Jan 18 '24 13:01 stevyhacker