Load block hash history when starting from non-genesis block#310
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes replay correctness when starting from a non-genesis block by pre-populating the in-memory 256-block hash ring (blockHashHistory) from hashes stored in the block DB, so EVM BLOCKHASH lookups and parent-hash validation work during replays that begin mid-chain.
Changes:
- Pass the block DB into state preparation so replay startup can seed historic block hashes when
StartBlock > 0. - Add
seedBlockHashHistoryto load the last ~256 prior block hashes from the block DB (via each block’sParentHash). - Add unit tests covering the seeding window logic and error propagation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| go/replay/replay.go | Seeds blockHashHistory from the block DB when starting replay from a non-genesis block. |
| go/replay/replay_test.go | Adds focused tests for seedBlockHashHistory behavior across boundary conditions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
LorenzSchueler
force-pushed
the
lorenz/fix-hash-history
branch
from
July 8, 2026 13:00
0383e02 to
e29d112
Compare
LorenzSchueler
force-pushed
the
lorenz/fix-hash-history
branch
from
July 8, 2026 13:35
e29d112 to
b96d0b1
Compare
LorenzSchueler
force-pushed
the
lorenz/fix-hash-history
branch
from
July 8, 2026 13:36
b96d0b1 to
0865102
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR loads the block hash history when starting from a non-genesis block (block 0). The block hash history is an in-memory buffer containing the last 256 block hashes. While replaying blocks it updates this buffer to stay up to date. When starting from some block >0, this history was previously empty (all zero hashes). This is incorrect can cause the replay to fail.
Now, the hashes are loaded from the parent hashes stored in the block db.