refactor(spice): tidy chunk-certification endorsement bookkeeping (1/6)#15936
refactor(spice): tidy chunk-certification endorsement bookkeeping (1/6)#15936darioush wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #15936 +/- ##
==========================================
- Coverage 69.70% 69.68% -0.03%
==========================================
Files 946 947 +1
Lines 204272 204311 +39
Branches 204272 204311 +39
==========================================
- Hits 142395 142381 -14
- Misses 57124 57183 +59
+ Partials 4753 4747 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors SPICE chunk-certification endorsement bookkeeping by extracting duplicated endorsement-threshold logic and encapsulating “previous block endorsement state” into a dedicated helper struct, with a preparatory field added to track fallback endorsements.
Changes:
- Adds
SpiceCoreReader::reaches_endorsement_thresholdandChunkValidatorAssignments::is_endorsedto reuse the endorsement-threshold tally logic. - Introduces
AncestryEndorsementsto centralize “pending/known endorsements from previous uncertified chunks” handling during block core-statement validation. - Extends
SpiceUncertifiedChunkInfowithpresent_fallback_endorsementsand providesall_present_endorsements()for unified iteration.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| core/primitives/src/types.rs | Adds fallback-endorsement storage + iterator helper on SpiceUncertifiedChunkInfo. |
| core/primitives/src/stateless_validation/validator_assignment.rs | Adds is_endorsed stake-verdict helper to avoid materializing full endorsement state. |
| chain/chain/src/spice/tests/core.rs | Updates test helper struct construction for new SpiceUncertifiedChunkInfo field. |
| chain/chain/src/spice/mod.rs | Registers new ancestry_endorsements module. |
| chain/chain/src/spice/core.rs | Uses AncestryEndorsements; extracts signature verification + stored-endorsement push; adds threshold helper. |
| chain/chain/src/spice/core_writer_actor.rs | Replaces duplicated store-endorsement tally logic with reaches_endorsement_threshold. |
| chain/chain/src/spice/ancestry_endorsements.rs | New struct encapsulating previous-block endorsement bookkeeping for validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Two behavior-preserving refactors of the SPICE chunk-certification code.
Tally helper:
reaches_endorsement_thresholdhelper onSpiceCoreReader, replacing the duplicated inline assignment-lookup-and-tally incore_writer_actor.is_endorsedonChunkValidatorAssignmentsso callers read the verdict directly.Block-validation endorsement state:
waiting_on_endorsements/known_endorsementsmaps invalidate_core_statements_in_blockinto anAncestryEndorsementsstruct that owns the "endorsement state as of the previous block" bookkeeping.push_stored_endorsementsandverify_endorsement_signaturefromcore_statements_for_next_block/validate_core_statements_in_block.present_fallback_endorsementsfield toSpiceUncertifiedChunkInfo, read throughall_present_endorsements(), so later work can accumulate endorsements without re-touching the validation loop.Note: Full change (non-stacked PRs) is available here: #15935