feat: implement forkchoice is_head_weak() and is_parent_strong() - #9654
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the fork choice implementation to support the Gloas fork's modified is_head_weak specification. It splits the tracking of node weights into two separate components: attestationScore (representing attester votes only) and weight (which includes proposer boost). The isHeadWeak logic is extracted into a private helper method in ForkChoice that handles both pre-Gloas and post-Gloas specifications, including adding back the weight of equivocating validators for post-Gloas blocks. Additionally, deltas has been renamed to attestationDeltas across the codebase for clarity, and comprehensive unit tests have been added to verify the new behavior. I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Performance Report🚀🚀 Significant benchmark improvement detected
Full benchmark results
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #9654 +/- ##
============================================
- Coverage 52.49% 52.48% -0.02%
============================================
Files 848 848
Lines 60485 60458 -27
Branches 4466 4459 -7
============================================
- Hits 31754 31732 -22
+ Misses 28670 28665 -5
Partials 61 61 🚀 New features to boost your workflow:
|
…ProposerBoost is_head_weak() landed via #9654 with the exact gloas semantics (boost-excluded attestation score + committee-scoped equivocator balance add-back), so the weak-parent check can call it directly instead of approximating with raw node.weight against the reorg threshold. Also adapt findEquivocatingBlocks to the current VariantIndices layout via getDefaultNodeIndex, and add the new ProtoBlock fields to test fixtures that were added on unstable since the last merge. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
🎉 This PR is included in v1.46.0 🎉 |
## Summary Implements the `should_apply_proposer_boost` logic ethereum/consensus-specs/pull/4807 ([gloas/fork-choice.md#new-should_apply_proposer_boost](https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.12/specs/gloas/fork-choice.md#new-should_apply_proposer_boost)). Was blocked on `is_head_weak()`; now rebased on top of #9654 (merged) and reuses its `isHeadWeak()` — boost-excluded attestation score + equivocator balance add-back — for the weak-parent check, exactly matching the spec's `is_head_weak(store, parent_root)` call. ### Changes - Add `ptcTimeliness` and `proposerIndex` fields to `ProtoBlock` - Add `isBlockPtcTimely` to track PTC deadline timeliness - Add `shouldApplyProposerBoost` which withholds boost when the parent is a weak, equivocating block from the previous slot - Reuse `isHeadWeak()` from #9654 for the weak-parent check - Add `findEquivocatingBlocks` in `ProtoArray` to detect proposer equivocations - Gate proposer boost in `getWeight` on `shouldApplyProposerBoost()` - Pre-gloas blocks retain unconditional boost (backward compatible) ### Note on test coverage The existing gloas fork_choice vectors pass with or without this gate (the withhold branch executes but never decides the asserted head), so CI alone doesn't discriminate it. Discriminating vectors are proposed upstream in consensus-specs (`test_should_apply_proposer_boost.py`, MC/DC over the three apply conditions); the withheld case fails on `unstable` and passes on this branch.
Motivation
getProposerHead()Description
getProposerHead()AI Assistance Disclosure