foundry icon indicating copy to clipboard operation
foundry copied to clipboard

optimism gas estimation problems

Open sakulstra opened this issue 3 weeks ago • 7 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?

9dc83c98223df59d102dde47405f0650c97b256a

What version of Foundryup are you on?

No response

What command(s) is the bug in?

forge script

Operating System

None

Describe the bug

On latest nightly (i think is not related to nightly but fukasa gas price drops), when i try to submit a txn on optimism, txns error with: Sequence #1 on optimism | retrying transaction Err(server returned an error response: error code -32000: insufficient gas for floor data gas cost: gas 719122, minimum needed 741890) and similar

sakulstra avatar Dec 09 '25 10:12 sakulstra

On gnosis chain, seems like foundry also can no longer submit txns.

## Setting up 1 EVM.

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

Chain 100

Estimated gas price: 0.000000101 gwei

Seems to dramatically underestimate gas cost: https://gnosisscan.io/gastracker

sakulstra avatar Dec 09 '25 10:12 sakulstra

Sorry will just dump here issues i face while i face them as i need to deploy sth on various chains 😅

On Plasma, verification failed initially because I think etherscan is not fast enough.

Response: `NOTOK`
Details: `Error: contract does not exist 9745 0x<sth>

Manual verification works, but probably would be good if foundry retried when contract does not exist (and it knows it exists, given it just deployed).

sakulstra avatar Dec 09 '25 10:12 sakulstra

Sorry will just dump here issues i face while i face them as i need to deploy sth on various chains 😅

On Plasama, verification failed initially because I think etherscan is not fast enough.

Response: `NOTOK`
Details: `Error: contract does not exist 9745 0x<sth>

Manual verification works, but probably would be good if foundry retried when contract does not exist (and it knows it exists, given it just deployed).

@sakulstra for this you could tweak the params

      --retries <RETRIES>
          Number of attempts for retrying verification
          
          [default: 5]

      --delay <DELAY>
          Optional delay to apply in between verification attempts, in seconds
          
          [default: 5]

grandizzy avatar Dec 09 '25 11:12 grandizzy

@grandizzy Will try next time, but honestly feels like this should be the default. At least with this error it's quite obvious that the explorer lags behind.

Also on polygon, without any custom settings it does:

Submitting verification for [src/UpgradePayload.sol:UpgradePayload] 0x<sth>.
Warning: Could not detect deployment: Unable to locate ContractCode at <sth>; waiting 5 seconds before trying again (4 tries remaining)

Submitting verification for [src/UpgradePayload.sol:UpgradePayload] <sth>.
Warning: Could not detect deployment: Unable to locate ContractCode at <sth>; waiting 5 seconds before trying again (3 tries remaining)

Submitting verification for [src/UpgradePayload.sol:UpgradePayload] <sth>.
Warning: Could not detect deployment: Unable to locate ContractCode at <sth>; waiting 5 seconds before trying again (2 tries remaining)

Submitting verification for [src/UpgradePayload.sol:UpgradePayload] <sth>.
Warning: Could not detect deployment: Unable to locate ContractCode at <sth>; waiting 5 seconds before trying again (1 tries remaining)

Submitting verification for [src/UpgradePayload.sol:UpgradePayload] <sth>.
Warning: Could not detect deployment: Unable to locate ContractCode at <sth>; waiting 5 seconds before trying again (0 tries remaining)

So it seems to kinda handle it, but inconsistently.

sakulstra avatar Dec 09 '25 11:12 sakulstra

I see will bump both defaults to 10 then

grandizzy avatar Dec 09 '25 12:12 grandizzy

On latest nightly (i think is not related to nightly but fukasa gas price drops), when i try to submit a txn on optimism, txns error with: Sequence #1 on optimism | retrying transaction Err(server returned an error response: error code -32000: insufficient gas for floor data gas cost: gas 719122, minimum needed 741890) and similar

I think here its not foundry to estimate the gas? Maybe some RPC side issue? cc @grandizzy

aganisgash avatar Dec 10 '25 07:12 aganisgash

I think here its not foundry to estimate the gas? Maybe some RPC side issue?

Was using alchemy and today it seems to work. Perhaps it's them not properly handling the floor price.

sakulstra avatar Dec 10 '25 08:12 sakulstra

@sakulstra if all good now we could keep this to bump the retries as in linked PR, pls comment

grandizzy avatar Dec 10 '25 13:12 grandizzy

@sakulstra can you pls rerun with RUST_LOG=trace and send the response that is logged as Received verification response need that to properly handle the plasma API response. Or if you could provide verifier url details to repro locally, thank you

grandizzy avatar Dec 10 '25 13:12 grandizzy

Will trace on next deployment and post here, did not put any custom config. So it's just forge default(routescan api).

sakulstra avatar Dec 10 '25 13:12 sakulstra

I know there's probably not so much that can be fixed on foundry side, but using alchemy these errors i was reporting are appearing quite frequently now also on other chains. E.g. today on arbitrum was not able to deploy most of the time due to:

Sequence #5 on arbitrum | retrying transaction Err(server returned an error response: error code -32000: max fee per gas less than block base fee: address <redacted>, maxFeePerGas: 71868000 baseFee: 73564000) (attempt 3)

sakulstra avatar Dec 17 '25 16:12 sakulstra