Skip to content

fix(api): return block root in getBlockHeader response#3134

Open
NikhilSharmaWe wants to merge 1 commit into
berachain:mainfrom
NikhilSharmaWe:fix/get-block-header-root
Open

fix(api): return block root in getBlockHeader response#3134
NikhilSharmaWe wants to merge 1 commit into
berachain:mainfrom
NikhilSharmaWe:fix/get-block-header-root

Conversation

@NikhilSharmaWe

Copy link
Copy Markdown

Closes #3132

Summary

makeBlockHeaderResponse was returning body_root in the top-level root field. The beacon API expects the block root (header.HashTreeRoot() after SetStateRoot). This broke lookups that use the returned root with GetSlotByBlockRoot, which indexes on block root.

This updates makeBlockHeaderResponse to set Root: header.HashTreeRoot() after patching the header's state root from the queried state.

Test plan

  • Update header_test.go to assert block root instead of body root
  • Fix test fixtures to use parent block root (HashTreeRoot) rather than parent body_root
  • Fix block-ID lookup mocks to use block roots consistent with GetSlotByBlockRoot

Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
Copilot AI review requested due to automatic review settings June 24, 2026 05:40
@NikhilSharmaWe NikhilSharmaWe requested a review from a team as a code owner June 24, 2026 05:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 makeBlockHeaderResponse to set BlockHeaderResponse.Root to header.HashTreeRoot() (after patching the header’s state_root from the queried state).
  • Update header_test.go assertions to expect the computed header/block root (post-SetStateRoot) rather than BodyRoot.
  • Update test fixtures/mocks to use block roots for parent/root-based lookups (e.g., GetSlotByBlockRoot expectations 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetBlockHeader returns body_root as API root

2 participants