Compute correctly the finalized field value in a bunch of beacon API endpoints. - #17401
Merged
Conversation
- `/eth/v1/beacon/states/{state_id}/root`,
- `/fork`,
- `/randao`,
- `/committees`,
- `/sync_committees`,
- `/finality_checkpoints`,
- `/validators`,
- `/validator_balances`,
- `/validator_identities`,
- `/pending_consolidations`,
- `/pending_deposits`,
- `/pending_partial_withdrawals`,
- `/proposer_lookahead`,
- `/eth/v2/debug/beacon/states/{state_id}`, and
- `/prysm/v1/beacon/states/{state_id}/validator_count`.
finalized field value in a bunch of beacon API endpoints.
nalepae
marked this pull request as ready for review
August 24, 2026 10:54
Inspector-Butters
previously approved these changes
Aug 24, 2026
james-prysm
previously approved these changes
Aug 24, 2026
nalepae
enabled auto-merge
August 24, 2026 14:18
nalepae
dismissed stale reviews from Inspector-Butters and james-prysm
via
August 25, 2026 10:24
8bbd1a9
Inspector-Butters
approved these changes
Aug 25, 2026
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.
What type of PR is this?
Bug fix
What does this PR do? Why is it needed?
On a bunch of beacon API endpoints, the
finalizedfield is always set tofalse, even if it should actually returntrue.These endpoints are:
/eth/v1/beacon/states/{state_id}/root,/fork,/randao,/committees,/sync_committees,/finality_checkpoints,/validators,/validator_balances,/validator_identities,/pending_consolidations,/pending_deposits,/pending_partial_withdrawals,/proposer_lookahead,/eth/v2/debug/beacon/states/{state_id}, and/prysm/v1/beacon/states/{state_id}/validator_count.First, explaining the egg and chicken issue.
When producing a new block, the block itself must contain (post) state root.
This state root represents a state, which itself contains the latest beacon block header:
The beacon spec explicitly asks to set the
state.latest_block_header.state_rootto 0.Why?
Simply because the proposer needs
block.state_root = htr(post_state). Butpost_statecontainslatest_block_header, which is this block's header, which containsstate_root.So if the state carried the real value, the proposer would need
xsuch that:which is unsolvable.
With the zero placeholder it collapses to a single evaluation.
x = htr(state_containing_0)and the verifier redoes that one evaluation to check it.Why this is related to the
"finalized:" falseissue?Because, when the beacon node needs to compute the block root from a state, it uses:
This latest block header actually contains the zeroed
state_rootfield.Then, it looks if the computed
blockRootis finalized. Because theblockRootis not found, it always returnfalse.The fix introduces a new
BlockRootFromStatefunction, that actually replaces the zeroedstate_rootfield by the correct one.How to test it?
Without the fix, call the
/eth/v1/beacon/states/<slot>/rootendpoint with any finalized slot.It will always return
"finalized": false.Example:
With the fix, the same call should return
"finalized": true.Other notes for review
Please review commit by commit, with commit messages.
Acknowledgements