Skip to content

fix(rpc): set prevrandao to zero for eth_simulateV1 simulated blocks#21399

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

fix(rpc): set prevrandao to zero for eth_simulateV1 simulated blocks#21399
klkvr merged 1 commit intomainfrom
fix/eth-simulate-prevrandao

Conversation

@mattsse
Copy link
Collaborator

@mattsse mattsse commented Jan 24, 2026

Summary

In geth, simulated block headers are created with MixDigest (prevrandao) zero-initialized by default. Only when a prevRandao/random override is explicitly provided does it get set to a non-zero value.

Reth was inheriting prevrandao from the parent block's environment, causing mixHash in the response to differ from geth's output.

This fix sets prevrandao to B256::ZERO before applying block overrides, matching geth's behavior. If user provides a random override, it will be applied by apply_block_overrides.

Test Plan

Fixes failing Hive rpc-compat tests for eth_simulateV1, specifically ethSimulate-blockhash-simple which expects mixHash to be 0x0000...0000.

Related

@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 13:51
@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Jan 24, 2026
In geth, simulated block headers are created with MixDigest (prevrandao)
zero-initialized by default. Only when a prevRandao/random override is
explicitly provided does it get set to a non-zero value.

Reth was inheriting prevrandao from the parent block's environment,
causing mixHash in the response to differ from geth's output.

This fix sets prevrandao to B256::ZERO before applying block overrides,
matching geth's behavior. If user provides a random override, it will
be applied by apply_block_overrides.

Fixes failing Hive rpc-compat tests for eth_simulateV1.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019bf01b-ec5c-775e-9997-98c5dd7248ac
@mattsse mattsse force-pushed the fix/eth-simulate-prevrandao branch from e1fd061 to b392fa2 Compare January 24, 2026 13:52
@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 963bfee Jan 26, 2026
45 checks passed
@klkvr klkvr deleted the fix/eth-simulate-prevrandao 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