Skip to content

fix(spice): read execution heads only on spice-enabled code paths#15977

Open
shreyan-gupta wants to merge 1 commit into
masterfrom
shreyan-gupta/spice/always-seed-execution-head
Open

fix(spice): read execution heads only on spice-enabled code paths#15977
shreyan-gupta wants to merge 1 commit into
masterfrom
shreyan-gupta/spice/always-seed-execution-head

Conversation

@shreyan-gupta

@shreyan-gupta shreyan-gupta commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Background

The SPICE execution heads (spice_execution_head / spice_final_execution_head) track the execution frontier and are meaningful only when SPICE is enabled, so every reader should sit behind a ProtocolFeature::Spice.enabled check. One didn't: the node Status handler called find_first_executed_ancestor unconditionally — on non-spice nodes too. That ungated read is the only reason the read sites carried defensive .ok() / DBNotFound fallbacks.

Change

  • Gate the Status-handler read on ProtocolFeature::Spice.enabled (from the head's epoch), falling back to the head block header otherwise — mirroring the already-correct view_client_actor path. Non-spice nodes no longer read the spice head.
  • With every reader now confined to spice-enabled paths, drop the defensive fallbacks at the five read sites: find_first_executed_ancestor, prune_below_final_head, is_descendant_of_final_execution_head, process_all_ready_blocks, start_waiting_on_missing_data.
  • Initialization is unchanged: genesis seeds the heads only when SPICE is enabled at genesis.

The chunk-executor / data-distributor read sites are gated at compile time (cfg(protocol_feature_spice)) rather than at runtime, so their now-unconditional reads rely on the head being seeded at genesis — which holds because SPICE is enabled from genesis wherever these actors run. is_descendant_of_final_execution_head documents this invariant and fails loud if it is ever violated.

Context

Supersedes the earlier "always seed the execution heads" approach: seeding a head for non-spice nodes that then never updates is a wart; gating the one ungated reader is the cleaner fix.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 makes spice_execution_head / spice_final_execution_head a guaranteed invariant on all nodes by (1) seeding them unconditionally at genesis and (2) backfilling older DBs at startup, allowing call sites to drop DBNotFound-style defensive fallbacks.

Changes:

  • Seed SPICE execution heads at genesis unconditionally (no protocol-version gate).
  • Backfill missing SPICE execution heads for existing databases on startup.
  • Simplify multiple read sites to assume SPICE execution heads exist (remove DBNotFound fallbacks).

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
chain/client/src/spice/data_distributor_actor.rs Removes fallback logic and requires spice_final_execution_head to exist when starting missing-data search.
chain/client/src/spice/chunk_executor_actor/receipt_tracker.rs Removes “absent on non-spice” early return; now relies on the seeded/backfilled final execution head.
chain/client/src/spice/chunk_executor_actor/per_shard.rs Switches to an invariant-based read of spice_final_execution_head for descendant checks.
chain/client/src/spice/chunk_executor_actor/coordinator.rs Removes fallback-to-genesis scanning; starts from spice_final_execution_head directly.
chain/chain/src/spice/chain.rs Makes find_first_executed_ancestor require the final execution head instead of treating it as optional.
chain/chain/src/genesis.rs Seeds SPICE execution heads at genesis for all nodes.
chain/chain/src/chain.rs Backfills missing SPICE execution heads on startup for DBs created before the invariant existed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +756 to +757
let final_execution_head =
chain_store.spice_final_execution_head().expect("failed to find final execution head");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't think this is an issue.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.85714% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.59%. Comparing base (715e0f9) to head (d4d8662).

Files with missing lines Patch % Lines
chain/chain/src/chain.rs 25.00% 6 Missing ⚠️
chain/chain/src/spice/chain.rs 33.33% 1 Missing and 1 partial ⚠️
chain/chain/src/genesis.rs 80.00% 0 Missing and 1 partial ⚠️
...ient/src/spice/chunk_executor_actor/coordinator.rs 0.00% 0 Missing and 1 partial ⚠️
.../src/spice/chunk_executor_actor/receipt_tracker.rs 0.00% 0 Missing and 1 partial ⚠️
chain/client/src/spice/data_distributor_actor.rs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #15977      +/-   ##
==========================================
- Coverage   72.60%   72.59%   -0.01%     
==========================================
  Files         952      952              
  Lines      205109   205094      -15     
  Branches   205109   205094      -15     
==========================================
- Hits       148914   148898      -16     
- Misses      51218    51219       +1     
  Partials     4977     4977              
Flag Coverage Δ
pytests-nightly 1.10% <0.00%> (+<0.01%) ⬆️
unittests 69.56% <38.09%> (+<0.01%) ⬆️
unittests-nightly 69.54% <38.09%> (+<0.01%) ⬆️
unittests-spice 66.96% <42.85%> (-0.03%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@shreyan-gupta shreyan-gupta force-pushed the shreyan-gupta/spice/always-seed-execution-head branch from 32aee7a to d4d8662 Compare June 25, 2026 18:05
@shreyan-gupta shreyan-gupta force-pushed the shreyan-gupta/spice/always-seed-execution-head branch from d4d8662 to 8b970eb Compare June 25, 2026 20:31
@shreyan-gupta shreyan-gupta changed the title chore(spice): always seed execution heads at initialization fix(spice): read execution heads only on spice-enabled code paths Jun 25, 2026
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.

2 participants