foundry: bug: invalid gas estimation on Metis

Component

Cast

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.3.0 (5a8bd89 2024-12-20T08:46:21.555250780Z)

What version of Foundryup are you on?

foundryup: 0.3.3

What command(s) is the bug in?

cast send

Operating System

Linux

Describe the bug

Sending transactions on Metis fails due to bad gas estimation. E.g. my wallet holds 0.5 metis and running

 cast send $WALLET_ARGS --value 0.0000001ether $(cast wallet address $WALLET_ARGS)

(which is just sending some metis to self) yields:

Error: server returned an error response: error code -32000: insufficient balance to pay for gas

Checked with https://andromeda.metis.io/, https://metis-rpc.publicnode.com and https://metis.drpc.org, so it’s consistent.

Using --gas-limit to override estimation solves the issue, transactions work fine. Using forge script also solves the problem, probably because simulation is done locally. It seems that metis RPCs may be returning something exotic when estimating gas.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

  • Berlin came out before London, PUSH0 is from Shanghai, lacking PUSH0 was causing compatibility issues for devs migrating from Ethereum (so latest metis evm version is Berlin + EIP-3855)
  • Metis doesn’t support EIP-1559, but recently added effectiveGasPrice to the tx receipt to be compatible with Foundry
  • Faucet is here: https://faucet.metis.io

If you face any problems with the faucet, I can send testnet or mainnet tokens for testing

I can confirm, it works with https://andromeda.metis.io/ and still fails with https://metis-rpc.publicnode.com/ and https://metis.drpc.org/. When I was opening this issue it was failing on all 3, so t0mcr8se is right, it was fixed on Metis side and will probably soon be resolved for all RPCs. Thank you all for looking into this!

Of course. I’m using

cast Version: 1.0.0-nightly
Commit SHA: db3d9fc95398450dbed83d4841042c62c155bcfc
Build Timestamp: 2025-02-11T00:20:51.893339867Z (1739233251)
Build Profile: maxperf

I’m not sure which exact part is contains the bad bit, so here are the full logs:

Warning: This is a nightly build of Foundry. It is recommended to use the latest stable version. Visit https://book.getfoundry.sh/announcements for more information. 
To mute this warning set `FOUNDRY_DISABLE_NIGHTLY_WARNING` in your environment. 

2025-02-11T17:12:47.758132Z TRACE mio::poll: registering event source with poller: token=Token(1), interests=READABLE    
2025-02-11T17:12:47.772496Z TRACE foundry_config: load config with provider: Metadata { name: "Default", source: None, provide_location: None, interpolater:  }
2025-02-11T17:12:47.773021Z TRACE alloy_rpc_client::call: polling RpcCall self.state=Prepared
2025-02-11T17:12:47.773045Z DEBUG alloy_rpc_client::call: sending request method=eth_chainId id=0
2025-02-11T17:12:47.773069Z TRACE alloy_rpc_client::call: full request params_ty=[(); 0] request=Request { meta: RequestMeta { method: "eth_chainId", id: Number(0), is_subscription: false }, params: [] }
2025-02-11T17:12:47.773104Z TRACE alloy_rpc_client::call: serialized request request={"method":"eth_chainId","id":0,"jsonrpc":"2.0"}
2025-02-11T17:12:47.774136Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: checkout waiting for idle connection: ("https", andromeda.metis.io)
2025-02-11T17:12:47.774151Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: reqwest::connect: starting new connection: https://andromeda.metis.io/    
2025-02-11T17:12:47.774172Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::connect::http: Http::connect; scheme=Some("https"), host=Some("andromeda.metis.io"), port=None
2025-02-11T17:12:47.775443Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2025-02-11T17:12:47.775459Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::connect::http: connecting to 99.83.225.141:443
2025-02-11T17:12:47.775529Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: mio::poll: registering event source with poller: token=Token(140562200260736), interests=READABLE | WRITABLE    
2025-02-11T17:12:47.788457Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2025-02-11T17:12:47.788508Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::connect::http: connected to 99.83.225.141:443
2025-02-11T17:12:47.824693Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2025-02-11T17:12:47.854022Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2025-02-11T17:12:47.854093Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::client: http1 handshake complete, spawning background dispatcher task
2025-02-11T17:12:47.854285Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2025-02-11T17:12:47.854294Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: checkout dropped for ("https", andromeda.metis.io)
2025-02-11T17:12:47.884049Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2025-02-11T17:12:47.884089Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: put; add idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.884104Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: pooling idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.884127Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: received response from server status=200 OK
2025-02-11T17:12:47.884154Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: retrieved response body. Use `trace` for full body bytes=42
2025-02-11T17:12:47.884164Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: response body body={"jsonrpc":"2.0","id":0,"result":"0x440"}

2025-02-11T17:12:47.884174Z TRACE hyper_util::client::legacy::pool: idle interval checking for expired
2025-02-11T17:12:47.884206Z TRACE alloy_json_rpc::result: deserializing response ty=ruint::Uint<64, 1> json="0x440"
2025-02-11T17:12:47.884217Z TRACE alloy_json_rpc::result: deserialized response response=1088
2025-02-11T17:12:47.884272Z TRACE foundry_wallets::wallet: start finding signer
2025-02-11T17:12:47.884404Z TRACE alloy_rpc_client::call: polling RpcCall self.state=Prepared
2025-02-11T17:12:47.884410Z DEBUG alloy_rpc_client::call: sending request method=eth_getTransactionCount id=1
2025-02-11T17:12:47.884420Z TRACE alloy_rpc_client::call: full request params_ty=alloy_provider::provider::with_block::ParamsWithBlock<alloy_primitives::bits::address::Address> request=Request { meta: RequestMeta { method: "eth_getTransactionCount", id: Number(1), is_subscription: false }, params: ParamsWithBlock { params: 0xef4b994f97092fd22b8a880c47f053910788471b, block_id: latest } }
2025-02-11T17:12:47.884474Z TRACE alloy_rpc_client::call: serialized request request={"method":"eth_getTransactionCount","params":["0xef4b994f97092fd22b8a880c47f053910788471b","latest"],"id":1,"jsonrpc":"2.0"}
2025-02-11T17:12:47.884501Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: take? ("https", andromeda.metis.io): expiration = Some(90s)
2025-02-11T17:12:47.884518Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: reuse idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.917810Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2025-02-11T17:12:47.917839Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: put; add idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.917851Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: pooling idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.917864Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: received response from server status=200 OK
2025-02-11T17:12:47.917883Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: retrieved response body. Use `trace` for full body bytes=41
2025-02-11T17:12:47.917892Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: response body body={"jsonrpc":"2.0","id":1,"result":"0x38"}

2025-02-11T17:12:47.917911Z TRACE alloy_json_rpc::result: deserializing response ty=ruint::Uint<64, 1> json="0x38"
2025-02-11T17:12:47.917918Z TRACE alloy_json_rpc::result: deserialized response response=56
2025-02-11T17:12:47.917929Z TRACE alloy_rpc_client::call: polling RpcCall self.state=Prepared
2025-02-11T17:12:47.917936Z DEBUG alloy_rpc_client::call: sending request method=eth_gasPrice id=2
2025-02-11T17:12:47.917945Z TRACE alloy_rpc_client::call: full request params_ty=[(); 0] request=Request { meta: RequestMeta { method: "eth_gasPrice", id: Number(2), is_subscription: false }, params: [] }
2025-02-11T17:12:47.917958Z TRACE alloy_rpc_client::call: serialized request request={"method":"eth_gasPrice","id":2,"jsonrpc":"2.0"}
2025-02-11T17:12:47.917981Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: take? ("https", andromeda.metis.io): expiration = Some(90s)
2025-02-11T17:12:47.917990Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: reuse idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.945868Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2025-02-11T17:12:47.945896Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: put; add idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.945906Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: pooling idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.945916Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: received response from server status=200 OK
2025-02-11T17:12:47.945932Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: retrieved response body. Use `trace` for full body bytes=47
2025-02-11T17:12:47.945939Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: response body body={"jsonrpc":"2.0","id":2,"result":"0x82f34849"}

2025-02-11T17:12:47.945956Z TRACE alloy_json_rpc::result: deserializing response ty=ruint::Uint<128, 2> json="0x82f34849"
2025-02-11T17:12:47.945963Z TRACE alloy_json_rpc::result: deserialized response response=2196981833
2025-02-11T17:12:47.945974Z TRACE alloy_rpc_client::call: polling RpcCall self.state=Prepared
2025-02-11T17:12:47.945979Z DEBUG alloy_rpc_client::call: sending request method=eth_estimateGas id=3
2025-02-11T17:12:47.945985Z TRACE alloy_rpc_client::call: full request params_ty=alloy_provider::provider::eth_call::params::EthCallParams<alloy_network::any::AnyNetwork> request=Request { meta: RequestMeta { method: "eth_estimateGas", id: Number(3), is_subscription: false }, params: EthCallParams { data: WithOtherFields { inner: TransactionRequest { from: Some(0xef4b994f97092fd22b8a880c47f053910788471b), to: Some(Call(0xef4b994f97092fd22b8a880c47f053910788471b)), gas_price: Some(2196981833), max_fee_per_gas: None, max_priority_fee_per_gas: None, max_fee_per_blob_gas: None, gas: None, value: Some(100000000000), input: TransactionInput { input: Some(0x), data: Some(0x) }, nonce: Some(56), chain_id: Some(1088), access_list: None, transaction_type: None, blob_versioned_hashes: None, sidecar: None, authorization_list: None }, other: OtherFields {} }, block: Some(pending), overrides: None } }
2025-02-11T17:12:47.946094Z TRACE alloy_rpc_client::call: serialized request request={"method":"eth_estimateGas","params":[{"from":"0xef4b994f97092fd22b8a880c47f053910788471b","to":"0xef4b994f97092fd22b8a880c47f053910788471b","gasPrice":"0x82f34849","value":"0x174876e800","input":"0x","data":"0x","nonce":"0x38","chainId":"0x440"},"pending"],"id":3,"jsonrpc":"2.0"}
2025-02-11T17:12:47.946117Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: take? ("https", andromeda.metis.io): expiration = Some(90s)
2025-02-11T17:12:47.946124Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: reuse idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.976137Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2025-02-11T17:12:47.976171Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: put; add idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.976185Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: hyper_util::client::legacy::pool: pooling idle connection for ("https", andromeda.metis.io)
2025-02-11T17:12:47.976211Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: received response from server status=200 OK
2025-02-11T17:12:47.976233Z DEBUG ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: retrieved response body. Use `trace` for full body bytes=97
2025-02-11T17:12:47.976245Z TRACE ReqwestTransport{url=https://andromeda.metis.io/?owner=1088}: alloy_transport_http::reqwest_transport: response body body={"jsonrpc":"2.0","id":3,"error":{"code":-32000,"message":"insufficient balance to pay for gas"}}

2025-02-11T17:12:47.976410Z TRACE mio::poll: deregistering event source from poller    
Error: Failed to estimate gas: server returned an error response: error code -32000: insufficient balance to pay for gas