fix(api): return block root in getBlockHeader response#3134
Open
NikhilSharmaWe wants to merge 1 commit into
Open
fix(api): return block root in getBlockHeader response#3134NikhilSharmaWe wants to merge 1 commit into
NikhilSharmaWe wants to merge 1 commit into
Conversation
Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the Beacon API getBlockHeader response to return the block root in the top-level root field (as specified by the standard Beacon APIs), instead of incorrectly returning body_root. This aligns lookups that use the returned root with backend indexing that keys by block root.
Changes:
- Update
makeBlockHeaderResponseto setBlockHeaderResponse.Roottoheader.HashTreeRoot()(after patching the header’sstate_rootfrom the queried state). - Update
header_test.goassertions to expect the computed header/block root (post-SetStateRoot) rather thanBodyRoot. - Update test fixtures/mocks to use block roots for parent/root-based lookups (e.g.,
GetSlotByBlockRootexpectations and block ID input).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| node-api/handlers/beacon/header.go | Fixes API response root to return the block root (HashTreeRoot) instead of body_root. |
| node-api/handlers/beacon/header_test.go | Updates tests/fixtures/mocks to validate and use the correct block-root semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Closes #3132
Summary
makeBlockHeaderResponsewas returningbody_rootin the top-levelrootfield. The beacon API expects the block root (header.HashTreeRoot()afterSetStateRoot). This broke lookups that use the returnedrootwithGetSlotByBlockRoot, which indexes on block root.This updates
makeBlockHeaderResponseto setRoot: header.HashTreeRoot()after patching the header's state root from the queried state.Test plan
header_test.goto assert block root instead of body rootHashTreeRoot) rather than parentbody_rootGetSlotByBlockRoot