Skip to content

fix(call): overwrite gas when exceed the RPC_DEFAULT_GAS_CAP #17847

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

Merged
merged 1 commit into from
Aug 13, 2025

Conversation

georgehao
Copy link
Contributor

@georgehao georgehao commented Aug 13, 2025

Recently, we switched node from geth to reth, reth got a discrepancy result from geth

Request:

curl -X POST  <ethereum geth-url or reth-url>
  -H 'Content-Type: application/json' \
  --data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_call",
    "params": [
      {
        "to": "0xA9A003D8dfcaF3fCbFF6c7886B991b3dC64F87EC",
        "from": "0x74B9a66E9b12145C02426BCe913BFd8E5850302A",
        "data": "0x54efc6e50000000000000000000000000000000000000000000000000000000000000001",
        "value": "0x0",
        "gas": "0x2faf08100",
        "gasPrice": "0x32ed60ed"
      },
      "latest"
    ]
  }'
  

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.

if request.as_ref().gas_limit() > Some(self.call_gas_limit()) {
// configured gas exceeds limit
return Err(
EthApiError::InvalidTransaction(RpcInvalidTransactionError::GasTooHigh).into()
)

There are two issues:

  1. 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

  2. The return error intrinsic gas too high is definitely misleading

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh...

fine with that if it makes behaviour consistent across clients, but this this behaviour does feel a bit wrong

Comment on lines +732 to +736
let global_gas_cap = self.call_gas_limit();
if global_gas_cap != 0 && global_gas_cap < requested_gas {
warn!(target: "rpc::eth::call", ?request, ?global_gas_cap, "Capping gas limit to global gas cap");
request.as_mut().set_gas_limit(global_gas_cap);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like doing this because this assumes the user is fine with us altering their intended settings

but this is fine as long as configured gas cap is higher than the actual available blockspace

Copy link
Contributor Author

@georgehao georgehao Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, agree with you. but it's worth to makes behaviour consistent across clients, because after we switch the node, the dapp throws errors. ~

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Aug 13, 2025
@mattsse mattsse added this pull request to the merge queue Aug 13, 2025
@mattsse mattsse added M-changelog This change should be included in the changelog A-rpc Related to the RPC implementation labels Aug 13, 2025
Merged via the queue into paradigmxyz:main with commit 3fe6c0c Aug 13, 2025
44 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation M-changelog This change should be included in the changelog
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants