feat(spice): handle uncertified validator proposals at epoch boundary#15017
feat(spice): handle uncertified validator proposals at epoch boundary#15017darioush wants to merge 16 commits intonear:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the SPICE execution path to account for staking proposals contained in uncertified chunks when crossing an epoch boundary, and adds tests to prevent stake-return regressions in that scenario.
Changes:
- Add
SpiceCoreReader::get_uncertified_validator_proposalsto extract validator proposals from uncertified chunks (per shard, ordered by height). - Update chunk execution to incorporate uncertified proposals at epoch start.
- Add unit + test-loop coverage for “unstake then re-stake near epoch boundary in uncertified chunk” behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
test-loop-tests/src/tests/stake_nodes.rs |
Adds an integration-style regression test asserting a late uncertified re-stake prevents stake return and is discoverable via the new reader API. |
chain/client/src/chunk_executor_actor.rs |
Adjusts the prev_validator_proposals input to runtime chunk application at epoch start to account for uncertified proposals. |
chain/chain/src/tests/spice_core.rs |
Adds unit tests and helpers validating the new “uncertified validator proposals” reader behavior. |
chain/chain/src/spice_core.rs |
Implements get_uncertified_validator_proposals by traversing uncertified chunk ancestry and extracting proposals from stored ChunkExtra. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #15017 +/- ##
===========================================
+ Coverage 1.30% 68.79% +67.49%
===========================================
Files 726 920 +194
Lines 140845 202180 +61335
Branches 140845 202180 +61335
===========================================
+ Hits 1835 139095 +137260
+ Misses 138957 57109 -81848
- Partials 53 5976 +5923
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| /// Proposals are sorted ascending by block height. If multiple uncertified | ||
| /// chunks contain proposals for the same account, the most recent one (last | ||
| /// in iteration order) should be kept by the caller's fold/insert logic. |
There was a problem hiding this comment.
I think this can be cleaned up a bit better post-spice, where we can move the logic of doing the fold to the callsite instead of having this function.
| let epoch_length: u64 = 10; | ||
| let endorsement_delay: u64 = 4; | ||
| let unstaker_idx = 0; | ||
| let validators_spec = create_validators_spec(4, 1); |
There was a problem hiding this comment.
includes a CV to test witness verification path
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
get_uncertified_validator_proposalstoSpiceCoreReaderwhich collects validator proposals from uncertified chunks, sorted by block height.ChunkExecutorActor, at epoch start, append uncertified proposals to prev_validator_proposalsso the runtime'slast_proposals` fold picks up the most recent proposal per account.Added UTs and test-loop for new behavior.