Skip to content

feat(spice): handle uncertified validator proposals at epoch boundary#15017

Draft
darioush wants to merge 16 commits intonear:masterfrom
darioush:spice-vdr2
Draft

feat(spice): handle uncertified validator proposals at epoch boundary#15017
darioush wants to merge 16 commits intonear:masterfrom
darioush:spice-vdr2

Conversation

@darioush
Copy link
Contributor

@darioush darioush commented Feb 6, 2026

  • At epoch boundaries in SPICE, staking proposals from uncertified chunks (chunks whose execution results haven't been endorsed yet) were being ignored. This could cause incorrect stake returns - e.g., a validator who re-stakes in an uncertified chunk near the epoch boundary would have their full stake returned as if they hadn't re-staked.
  • Add get_uncertified_validator_proposals to SpiceCoreReader which collects validator proposals from uncertified chunks, sorted by block height.
  • In 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.

@darioush darioush requested a review from Copilot February 6, 2026 14:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_proposals to 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
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 0% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.79%. Comparing base (67ba56f) to head (9ed6215).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
chain/chain/src/spice_core.rs 0.00% 47 Missing ⚠️
...src/stateless_validation/spice_chunk_validation.rs 0.00% 15 Missing ⚠️
chain/client/src/chunk_executor_actor.rs 0.00% 5 Missing ⚠️
chain/client/src/spice_chunk_validator_actor.rs 0.00% 1 Missing ⚠️
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     
Flag Coverage Δ
pytests-nightly 1.29% <0.00%> (-0.01%) ⬇️
unittests 68.41% <0.00%> (?)
unittests-nightly 68.37% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +118 to +120
/// 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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

includes a CV to test witness verification path

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments