fix(call): overwrite gas when exceed the RPC_DEFAULT_GAS_CAP #17847
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently, we switched node from geth to reth, reth got a discrepancy result from geth
Request:
Geth result:
{"jsonrpc":"2.0","id":1,"error":{"code":-32003,"message":"insufficient funds for gas * price + value: have 40433651070486113 want 469929704750000000"}} --> this is expected
reth result
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"intrinsic gas too high"}}
This discrepancy is because the implementation logic a little different:
Geth checks the input gasLimit, and sets the gasLimit with RPCGasCap (50000000) if the input gasLimit exceeds RPCGasCap
https://github.com/ethereum/go-ethereum/blob/60cbf64f9c77761cf809120d5ff6c5716df0be5b/internal/ethapi/transaction_args.go#L207-L210
But reth just checks the input gasLimit, returns intrinsic gas too high if exceeds it.
reth/crates/rpc/rpc-eth-api/src/helpers/call.rs
Lines 731 to 735 in fa31b9e
There are two issues:
Some apps like rundler (for EIP4337) just set a very large gasLimit as the default value for eth_call, geth returns the right result for some requests since geth overwrites the gasLimit for the requests, but reth doesn't. the runder sets the default gasLimit : 550000000 https://github.com/alchemyplatform/rundler/blob/main/bin/rundler/src/cli/mod.rs#L415
The return error
intrinsic gas too high
is definitely misleading