Skip to content

fix(rpc): cap simulate_v1 default gas limit to RPC gas cap#21402

Merged
klkvr merged 1 commit intomainfrom
fix/eth-simulate-gas-cap
Jan 26, 2026
Merged

fix(rpc): cap simulate_v1 default gas limit to RPC gas cap#21402
klkvr merged 1 commit intomainfrom
fix/eth-simulate-gas-cap

Conversation

@mattsse
Copy link
Collaborator

@mattsse mattsse commented Jan 24, 2026

Summary

Fixes a transaction hash mismatch between reth and geth in eth_simulateV1 for transactions that don't specify a gas limit.

Problem

When eth_simulateV1 transactions don't specify a gas limit, the default is calculated as:

(block_gas_limit - total_specified_gas) / txs_without_gas_limit

This could result in gas limits exceeding the RPC gas cap (50M by default). For example, with a block gas limit of 75.4M and one transaction without gas specified, it would get 75.4M gas.

Geth caps this value to CallDefaults (the RPC gas cap), resulting in different transaction hashes.

Solution

Cap the calculated default gas limit to call_gas_limit(), matching geth's behavior.

This aligns with the eth_simulateV1 spec which allows clients to set their own global gas limits.

Testing

  • Resolves the ethSimulate-blockhash-simple Hive test failure
  • Verified with clippy and formatting

When eth_simulateV1 transactions don't specify a gas limit, the default
is calculated as remaining block gas divided among such transactions.
Previously this could exceed the RPC gas cap (50M by default), causing
transaction hash mismatches with geth.

This fix caps the default gas limit to call_gas_limit(), matching geth's
CallDefaults behavior and the spec allowance for client-specific limits.

Amp-Thread-ID: https://ampcode.com/threads/T-019bf0aa-8b57-7338-a8ec-a932111b46fc
Co-authored-by: Amp <amp@ampcode.com>
@mattsse mattsse added the A-rpc Related to the RPC implementation label Jan 24, 2026
@mattsse mattsse requested a review from Rjected as a code owner January 24, 2026 15:42
@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Jan 24, 2026
@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Jan 26, 2026
@klkvr klkvr added this pull request to the merge queue Jan 26, 2026
Merged via the queue into main with commit adbe6d9 Jan 26, 2026
46 checks passed
@klkvr klkvr deleted the fix/eth-simulate-gas-cap branch January 26, 2026 12:47
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Jan 26, 2026
rakita pushed a commit that referenced this pull request Jan 26, 2026
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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants