refactor: defer fc store mutations after protoarray block import#9581
Conversation
…Block Per review on #9565. `onBlock` mutated `proposerBoostRoot` and the justified/ finalized checkpoints before `protoArray.onBlock()` inserted the block. If the insertion threw, the store was left pointing at / justified on a block that was never added. Compute the proposer-boost decision into a temp, pass the candidate root to `protoArray.onBlock()` for its best-child weighting, and commit the store mutations (proposerBoostRoot + updateCheckpoints + updateUnrealizedCheckpoints) only after the insertion succeeds — mirroring the spec's `on_block` ordering. Behavior-preserving on the happy path: ProtoArray holds its own justified/ finalized epochs and never reads fcStore, so checkpoint-update ordering does not affect insertion. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request refactors the fork-choice block processing logic to defer state mutations until after the block is successfully added to the proto-array. Specifically, the assignment of 'this.proposerBoostRoot' and the updates to checkpoints (via 'updateCheckpoints' and 'updateUnrealizedCheckpoints') are moved to execute only after 'this.protoArray.onBlock()' succeeds, using a temporary local variable for the initial call. There are no review comments, and I have no additional 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✔️ no performance regression detected Full benchmark results
|
ProtoArray.onBlockcan potentially reject the block to be imported. So we should update our fork choice store only after the import is complete.See #9565 (review) for more context