Skip to content

fix: use body hash in blockToHeader + resolve stale TODOs#296

Closed
lodekeeper-z wants to merge 1 commit intoChainSafe:mainfrom
lodekeeper-z:chore/cleanup-attester-status-todo
Closed

fix: use body hash in blockToHeader + resolve stale TODOs#296
lodekeeper-z wants to merge 1 commit intoChainSafe:mainfrom
lodekeeper-z:chore/cleanup-attester-status-todo

Conversation

@lodekeeper-z
Copy link
Copy Markdown
Contributor

Summary

Bug fix: blockToHeader was computing body_root as hash_tree_root(block) instead of hash_tree_root(block.body). This would produce incorrect BeaconBlockHeader values. The function is currently unused but will be needed for fork choice and beacon-node integration.

TODO cleanup: Resolves 3 stale TODOs with actionable notes:

  • attester_status.zig: Missing functions (parseAttesterFlags, etc.) are for validator monitor, not STF — noted for beacon-node layer
  • block_root.zig: getTemporaryBlockHeader already implemented as blockToHeader in process_block_header.zig; signedBlockToSignedHeader deferred to beacon-node layer

🤖 Generated with AI assistance

blockToHeader was computing body_root as hash_tree_root(block) instead
of hash_tree_root(block.body). This would produce incorrect block
headers when used (currently unused but will be needed for fork choice
and beacon-node integration).

Also resolves stale TODOs in attester_status.zig and block_root.zig
with context about when each function is actually needed.

🤖 Generated with AI assistance
@lodekeeper-z lodekeeper-z requested a review from a team as a code owner March 29, 2026 01:23
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a functional bug in the block header generation logic and performs a cleanup of technical debt. By ensuring the correct root calculation, the integrity of the BeaconBlockHeader is maintained for future integration. Additionally, the removal of stale TODOs improves code clarity by documenting the intended architectural separation between the state transition function and the beacon-node layer.

Highlights

  • Bug Fix in blockToHeader: Corrected the calculation of body_root in blockToHeader to use the hash tree root of the block body instead of the entire block.
  • Codebase Cleanup: Resolved stale TODOs in attester_status.zig and block_root.zig by adding context-aware notes regarding their implementation status and architectural placement.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the block header processing to extract the beacon block body before hashing and replaces several TODO comments with detailed notes regarding future implementations. A review comment suggests chaining method calls in the block header processing to minimize the number of variables in scope, adhering to the repository's style guide.

Comment on lines +78 to +79
const body = block.beaconBlockBody();
try body.hashTreeRoot(allocator, &out.body_root);
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.

medium

While the current implementation is correct, it can be made more concise by chaining the method calls. This also reduces the number of local variables, adhering to the style guide's principle of minimizing variables in scope.

From the style guide (line 104): "minimize the number of variables in scope, to reduce the probability that variables are misused."

    try block.beaconBlockBody().hashTreeRoot(allocator, &out.body_root);
References
  1. The style guide suggests minimizing the number of variables in scope. The body variable can be elided by chaining method calls. (link)

}

// TODO: getTemporaryBlockHeader
// Note: getTemporaryBlockHeader is implemented via blockToHeader in process_block_header.zig
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.

If it is already implemented, don't need a comment here anymore

// Note: getTemporaryBlockHeader is implemented via blockToHeader in process_block_header.zig

// TODO: signedBlockToSignedHeader
// Note: signedBlockToSignedHeader — implement when needed for beacon-node layer
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.

If it isn't implemented, just remain origin TODO comment

}

// TODOs: implement missing functions
// Note: TS lodestar also has parseAttesterFlags, toAttesterFlags, parseParticipationFlags
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.

don't need this change IMO

@wemeetagain wemeetagain closed this May 6, 2026
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.

3 participants