Chain data processing
Nearcore turns blocks and shard chunks into one trusted chain state. It checks links and commitments, applies each shard transition, stores the result, and advances the chain only when the required data is ready. Epoch data gives each block a stable shard layout and validator context. The runtime also tracks accepted external calls and exposes canonical execution outcomes. SPICE adds a separate certification path for chunk execution. Read Block and chunk processing for the block life cycle and Epoch and validator management for validator and epoch changes.
Processing model
Blockchain data model
The chain is a linked sequence of blocks. Each block names one chunk result for each shard. A new chunk carries new transactions and receipts. An old chunk carries the prior chunk header and keeps shard progress aligned when that shard has no new work.
The main data relationships are:
| Data | Role |
|---|---|
| Block header | Links to the parent and commits to block, chunk, epoch, approval, finality, and execution data. |
| Chunk header | Identifies the shard result and commits to its state, receipts, outcomes, and resource use. |
| Chunk body | Carries transactions and outgoing receipts for a new chunk. |
| Chunk extra | Records the result after the runtime applies a chunk. |
| State root | Names the shard state after a transition. |
| Receipt | Carries asynchronous work from one shard to another. |
| Shard identity | Pairs a shard number with a layout version so state stays distinct across resharding. |
| Execution result | In SPICE, carries a certified chunk result for shards that this node may not track. |
The chain passes the layout-qualified shard identity into state application. This prevents a shard number in an old layout from being confused with the same number in a new layout.
References: chain/…/types.rs• L109-185 chain/…/types.rs• L415-430 chain/…/chain.rs• L795-857
Genesis data
Genesis creates the first block and the starting state for every shard. It fixes the initial state roots, shard layout, gas rules, validator data, and other values that later transitions use as their base. It also records the initial congestion state needed by later chunk processing.
Saving genesis creates the first chain heads, chunk extras, and flat-storage roots. When SPICE is active, it also creates the initial execution heads. These records let the node restart with the same chain and state view that it had at startup.
References: chain/…/genesis.rs• L26-75 chain/…/genesis.rs• L114-172
Chain processing stages
The chain processes a block in three broad stages. It first checks the block and prepares shard work. It then applies shard work in parallel. It finally persists the results and advances the chain view.
The high-level flow is:
flowchart LR
A[Block or header received] --> B[Check links and commitments]
B --> C[Find chunk data and prepare shard work]
C --> D[Apply shard transitions]
D --> E[Collect state and receipt results]
E --> F[Commit block and shard data]
F --> G[Advance heads and retry dependents]
Headers can arrive before bodies. A block can also wait for its parent, a missing chunk, or a result from optimistic execution. These paths keep useful data and retry the work when its dependency arrives. The node can therefore know a longer header chain without claiming that it has processed the same block bodies.
Optimistic processing can start chunk work before the complete block arrives when the protocol allows it. The normal block path reuses those results. SPICE does not use this path because its chunk results must follow its certification rules.
SPICE keeps another progress point for chunk certification. A block can become the body head while its chunks still wait for validator evidence. Block postprocessing commits SPICE execution heads first. It then advances flat storage and removes old in-memory trie roots only for shards that have applied the relevant final block. A lagging shard keeps its own local progress until it catches up.
References: chain/…/chain.rs• L277-323 chain/…/chain.rs• L1263-1313 chain/…/chain_update.rs• L212-351 chain/…/block_application.rs• L12-73
Dependency recovery
An orphan is a block whose parent is not accepted yet. The chain keeps bounded pools for orphans, missing chunks, and blocks waiting for optimistic execution. When the needed data arrives, it sends the block back through the normal processing path.
This recovery keeps dependency handling separate from validation. A missing input causes a wait. Invalid input causes rejection. The distinction lets the node request data without treating an incomplete block as bad chain data.
References: chain/…/chain.rs• L1770-1855 chain/…/chain.rs• L1714-1722 chain/…/orphan.rs• L19-43 chain/…/orphan.rs• L194-255
Validation model
Block and chunk validation
Validation protects the chain from data that does not match its producer, its parent, or its committed contents. The epoch manager supplies the shard layout, protocol version, validator keys, and approval context for these checks.
The checks establish these contracts:
- The block body hash and header signature match the received data.
- The parent determines the expected epoch, next epoch, time order, producer data, and shard layout.
- The block has the expected chunk count and valid new or old chunk forms.
- A new chunk names the right parent and has a valid producer signature.
- An old chunk matches the prior chunk header for that shard.
- Block and chunk commitments match their contents.
- Approvals meet the required signature and stake rules.
- A transaction envelope is valid for the active protocol version before costly execution begins.
SPICE also checks the core statements that carry endorsements and execution results. It rejects statements for unknown or already certified chunks, duplicate evidence, mismatched results, and execution results without enough matching endorsements.
References: chain/…/chain.rs• L775-857 chain/…/chain.rs• L903-1075 chain/…/chain.rs• L2582-2666 chain/…/core.rs• L641-835 chain/…/chunk_validation.rs• L309-365
Merkle commitments
Merkle roots bind a block to its chunk headers and bind receipts, encoded bodies, state, outcomes, and execution results to their source data. Nearcore verifies these paths before it accepts a block, applies a witness, or uses a state-sync response.
A mismatch stops the related path before it can install state or use an untrusted result. Later processing can then rely on the state root or result named by the accepted commitment.
References: chain/…/chain.rs• L775-857 chain/…/chunk_validation.rs• L775-803 chain/…/adapter.rs• L655-719 chain/…/types.rs• L153-185
State witnesses and receipts
A state witness lets a node validate a chunk without reading the full shard state from its own database. Pre-validation checks the witness's shard, protocol, transaction root, receipt proofs, and applied-receipt hash. Runtime replay then checks the resulting state root and outgoing receipt root.
Witness validation walks back to the last new chunk. It replays old chunks and resharding transitions between that chunk and the witnessed block. This preserves the same state path that full-state execution would use.
SPICE uses the same idea for regular chunk witnesses. At the activation boundary it uses a boundary witness that starts from the last pre-SPICE new chunk, proves all consumed receipts, replays later old chunks, and proves receipts that were still undelivered.
References: chain/…/chunk_validation.rs• L141-252 chain/…/chunk_validation.rs• L309-457 chain/…/chunk_validation.rs• L579-803 chain/…/boundary_synthesis.rs• L388-520
SPICE certification
SPICE separates chunk execution from chunk certification. A chunk result is certified only after matching validator evidence is available. The block head and the certification frontier can therefore move at different rates.
The certification path is:
flowchart LR
A[Chunk execution result] --> B[Matching validator evidence]
B --> C[Stake threshold]
C --> D[Certified chunk]
D --> E[Certified block frontier]
E --> F[Trusted state and execution results]
The chain stores the chunks that still need certification. It carries valid endorsements forward across blocks, accepts an all-stake fallback after the required delay, and records the certifying progress. It limits the number of distinct chunks and statements in one block so certification work remains bounded.
Execution results can be read from local chunk state or from the chain-wide certified result store. If the result store is behind, the reader can recover results from certified block bodies. This keeps certification progress usable during normal write lag.
At SPICE activation, the last pre-SPICE block gets one waiting record per shard. The first SPICE block seeds its execution heads from that prior block and carries the waiting records into its own certification state. Each fork keeps its own boundary record.
Block-level SPICE postprocessing commits execution heads before it advances flat storage or removes old in-memory trie roots. The durable head update is forward-only. Repeating postprocessing reaches the same end state, while shards that did not apply the final block advance separately when they later apply it.
References: chain/…/core.rs• L41-70 chain/…/core.rs• L641-835 chain/…/core.rs• L982-1130 chain/…/block_application.rs• L12-114 chain/…/boundary.rs• L18-147 chain/…/boundary_synthesis.rs• L388-520
State transition model
Transaction admission
Transaction preparation selects work for a future new chunk against the state that chunk will use. It keeps temporary account and key updates during one selection pass, so later transactions see the balance and nonce changes made by earlier selected transactions.
Admission applies chain, lifetime, signer, congestion, nonce, gas, size, storage-read, and protocol rules. Transactions that do not fit remain available for a later pass when the rule allows it.
External contract calls are a separate transaction form with no signer nonce. Outside SPICE, the target contract decides whether a call is accepted during a bounded dry run. Accepted calls contribute state reads and resource use to the chunk. Refused or late calls are not included. A node also checks its recent accepted-call history so a repeated call is not run again after a final canonical inclusion within the repeat window. SPICE currently does not admit these calls during transaction preparation.
References: chain/…/mod.rs• L223-430 chain/…/mod.rs• L1158-1550 chain/…/mod.rs• L1624-1670 chain/…/types.rs• L432-500
Shard execution
The runtime applies a chunk to the shard state named by the prior state root. It uses block context and epoch context to process transactions, incoming receipts, validator-account changes, congestion, bandwidth, and protocol rules. The result is a deterministic next state plus the receipts and outcomes needed by other shards and later blocks.
Cross-shard work moves through receipts. An old chunk performs the system transition needed to keep shard scheduling state aligned without applying new user transactions. In SPICE, congestion and bandwidth inputs come from the latest trusted execution results, including results for shards this node does not track.
The runtime can use full local state, recorded trie data, or a partial state from a witness. The transition has the same meaning in each case. This gives full-state execution, replay, and stateless validation one state-transition contract.
References: chain/…/mod.rs• L669-829 chain/…/mod.rs• L907-943 chain/…/types.rs• L415-430 chain/…/chunk_application.rs• L237-361 chain/…/update_shard.rs• L90-234
State results
Chunk execution returns the new state root with outcomes, outgoing receipts, validator proposals, processed-receipt data, and shard flow data. It can also return congestion, bandwidth, contract-access, external-call, and resharding information. The chain uses this result set to build chunk metadata and to persist one logical state transition.
The result has two important downstream roles. The state root becomes the input to the next chunk. The outgoing receipts and outcomes become commitments that later blocks and receiving shards validate. External-call inclusions also support repeat suppression and transaction lookup after the chunk is stored.
The chain keeps the persistence choices for these results in one chunk persistence policy. The normal chain path and the SPICE executor use the same policy, so optional trie changes, outcomes, receipt origins, and state changes do not drift between processing modes.
References: chain/…/types.rs• L117-185 chain/…/mod.rs• L915-943 chain/…/chunk_application.rs• L47-155 chain/…/mod.rs• L294-331
Shard layout changes
An epoch can change the shard layout through resharding. A new shard can read state and receipts from a parent shard in the old layout. The layout-qualified shard identity keeps the two lineages separate while the transition connects them.
Receipt collection resolves the source layout first and then maps receipts into the target layout. Witness validation and runtime replay apply the same mapping.
Resharding moves state in two durable stages. Flat storage first copies parent data into child shards and catches the children up to the final chain. Trie state resharding then fills child trie state in batches, records its resume point, removes temporary shard mappings, and cleans the parent flat storage only after the child state is complete. Both stages can resume after interruption.
References: chain/…/mod.rs• L649-667 chain/…/chunk_validation.rs• L255-307 chain/…/chunk_validation.rs• L647-774 chain/…/flat_storage_resharder.rs• L35-57 chain/…/flat_storage_resharder.rs• L422-495 chain/…/trie_state_resharder.rs• L248-318 chain/…/trie_state_resharder.rs• L451-486 chain/…/types.rs• L415-430
Persistence and chain advancement
Chain progress
The chain store keeps blocks, headers, chunks, results, receipts, state changes, proofs, and processing records. Separate indexes describe different forms of progress because header sync, body processing, finality, SPICE certification, and retention do not advance at the same time.
| Progress point | Meaning |
|---|---|
| Header head | Highest known header chain. |
| Body head | Highest block whose body and required shard work are processed. |
| Final head | Monotonic finality boundary. |
| Certification frontier | Highest block for which SPICE chunk results are fully certified. |
| Tail ranges | Oldest retained blocks, chunks, and fork data. |
The store also keeps state-sync and catch-up records. These records tell processing whether a shard has enough state to execute or serve later data.
Fork choice changes the canonical chain represented by height-based reads. A longer or preferred fork can replace earlier height mappings while accepted fork data remains stored. Finality prevents processing from moving behind a finalized boundary.
References: chain/…/chain.rs• L277-323 chain/…/chain_update.rs• L368-474 chain/…/mod.rs• L73-156 chain/…/simple_chain.rs• L128-157 chain/…/simple_chain.rs• L160-255
Atomic updates
After shard work succeeds, chain postprocessing combines block metadata, chunk results, state changes, receipts, indexes, and head changes before commit. This gives a restart one clear boundary between an unapplied result and a completed result.
Per-shard chunk persistence puts the completion marker beside the refcounted state and receipt writes. Optional state, outcome, and receipt-origin columns follow the same persistence policy. A failed commit leaves the apply incomplete, so replay can repeat it without counting shared data twice. The normal block path then combines the per-shard results with block-level progress.
SPICE uses per-shard atomic persistence for chunk results and a separate block-level commit for execution heads. Flat-storage movement and in-memory cleanup happen after the durable head update. Repeating the later work is safe because the heads move forward only after their durable record exists. Each applied chunk also records accepted external-call hashes and updates the shared in-memory call cache.
References: chain/…/chunk_application.rs• L47-155 chain/…/block_application.rs• L12-57 chain/…/chain.rs• L1479-1522 chain/…/chain_update.rs• L81-175 chain/…/mod.rs• L322-331 chain/…/external_call_cache.rs• L47-145
Execution outcome lookup
Execution outcome lookup resolves an identifier against the current canonical chain rather than trusting the first stored copy. If an outcome changed state, the chain returns the canonical inclusion. If every canonical inclusion was a rejection, it returns the earliest rejection.
This rule keeps transaction and receipt views stable across forks. A successful or state-changing outcome on an abandoned fork does not hide the canonical result, and a later invalid attempt does not hide an earlier rejection when no attempt changed state.
References: chain/…/chain.rs• L4312-4366 chain/…/mod.rs• L542-598 chain/…/execution_outcome.rs• L48-108
State synchronization
State sync lets a node install a shard state at a trusted final chain point instead of replaying all earlier blocks. A response links the target block to a state root and supplies the parts that make up that root. SPICE can use a certified execution result as the trusted chunk result.
The receiver checks the state-root node, each state part, chunk or execution links, and receipt proofs before applying the data. It applies accepted parts to trie and flat state, then moves the chain heads. A sync point is usable only after finality and after the epoch's shard conditions are met.
The flow is:
sequenceDiagram
participant N as Syncing node
participant P as Peer
participant S as State store
N->>P: Request trusted sync header
P->>S: Read state root and chain proofs
S-->>P: Return header and proofs
P-->>N: Send header
N->>N: Verify links and state-root data
N->>P: Request state parts
P-->>N: Send state parts
N->>N: Verify each part
N->>S: Apply parts and finalize state
After a non-SPICE sync, the node rebuilds the shard's chunk history from the restored chunk through the sync block. A SPICE sync installs the certified execution result directly at the sync block because SPICE stores the shard's state delta under the block that produced it.
References: chain/…/chain.rs• L1641-1735 chain/…/chain_update.rs• L476-607 chain/…/mod.rs• L1000-1040 chain/…/adapter.rs• L287-445 chain/…/adapter.rs• L456-719
State snapshots
State snapshots provide a trusted, reusable state point for state sync and archival work. Snapshot creation follows epoch cadence and also runs for resharding epochs when the normal cadence would miss the required boundary.
Snapshot creation waits when flat-storage resharding has not caught up enough to avoid duplicating catch-up work. The snapshot key differs by processing mode: non-SPICE snapshots represent the state before the sync block, while SPICE snapshots represent the sync block's own executed state. SPICE announces the snapshot only after chunk certification.
References: chain/…/state_snapshot_actor.rs• L21-199 chain/…/state_snapshot_actor.rs• L235-315 chain/…/chain.rs• L3927-3949 chain/…/flat_storage_resharder.rs• L645-751
Data retention
Retention removes old blocks, chunks, receipts, state changes, and witness data only after no active chain path needs them. Fork ancestry, state sync, resharding, certification, and archival progress can all extend the safe boundary.
Fork cleanup removes abandoned branches by reference count. Canonical cleanup advances the block tail only after it has removed data that no longer supports the retained chain. Chunk-tail cleanup also removes invalid SPICE chunk evidence and producer records that are not reachable from retained headers.
The runtime also limits cleanup by the oldest epoch that archival storage can serve. This prevents hot storage from deleting data before recovery or archival reads can use it.
References: chain/…/mod.rs• L946-989 chain/…/garbage_collection.rs• L67-162 chain/…/garbage_collection.rs• L164-304 chain/…/garbage_collection.rs• L560-660 chain/…/garbage_collection.rs• L687-888 chain/…/garbage_collection.rs• L139-300
Store consistency
The store validator checks that persisted chain data agrees with its indexes, links, state roots, reference counts, and retention markers. It treats the database as a set of related views rather than as independent rows.
Validation covers head and tail ordering, block and chunk identity, required bodies and chunk extras, receipt and transaction references, trie-change roots, canonical links, state-sync parts, and execution outcomes. It allows the limited gaps created by state sync and epoch-sync boundaries while rejecting unexplained missing or conflicting data.
References: chain/…/validate.rs• L97-148 chain/…/validate.rs• L235-425 chain/…/validate.rs• L563-643 chain/…/validate.rs• L824-963
Epoch coordination
Epoch context
An epoch is the period in which the protocol uses one validator context, shard layout, randomness context, and protocol version. Chain validation and runtime execution resolve this context from the block's ancestry.
The context gives each block and chunk a stable meaning. It tells the node which shards exist, which identity names each state, which validators can produce or approve data, and which runtime rules apply.
References: chain/…/chain.rs• L903-982 chain/…/mod.rs• L703-771 chain/…/types.rs• L501-546
Validator transitions
Shard execution produces validator proposals as part of its chunk result. At an epoch boundary, the runtime applies account-side stake and reward changes. The epoch manager then uses the proposals and chain history to build later validator roles, chunk assignments, and shard assignments.
At the start of a new epoch, the runtime filters stake data, rewards, and prior proposals to the shard that owns each validator account. This lets the account update and the shard transition use the same layout. SPICE carries proposals from uncertified chunks into the boundary context. This prevents delayed certification from hiding a validator change that belongs to the next epoch.
See Epoch and validator management for the validator life cycle and assignment rules.
References: chain/…/mod.rs• L699-754 chain/…/core.rs• L213-260 chain/…/tests.rs• L259-315 chain/…/tests.rs• L360-437
Epoch boundary effects
The first block of an epoch links the old context to the new one. Processing it can update validator accounts, change the shard layout, reset sync tracking, and start resharding work.
Finality remains separate from acceptance. A block can be accepted on a fork before it becomes final. State sync and retention use the final boundary when they decide which history is safe to install or remove.
References: chain/…/mod.rs• L703-754 chain/…/chain_update.rs• L247-349 chain/…/chain.rs• L1636-1725 chain/…/chunk_validation.rs• L255-307
Related processing paths
Block and chunk processing
Block processing is the path from network input to an accepted chain view. It coordinates header checks, chunk availability, shard execution, persistence, fork choice, and retries for dependent blocks.
Read Block and chunk processing for the detailed roles of the client, chain, shard manager, and runtime.
References: chain/…/chain.rs• L1263-1313 chain/…/chain.rs• L1746-1884
Epoch and validator management
Epoch management supplies the context that makes block and chunk data meaningful. It turns execution proposals and chain history into validator roles, shard assignments, epoch records, and sync data.
Read Epoch and validator management for the validator life cycle and epoch transition rules.
References: chain/…/mod.rs• L703-771 chain/…/core.rs• L213-260
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to block or chunk commitments must stay aligned across full-state validation, witness replay, SPICE execution results, and persistence.
- Changes to
ApplyChunkShardContextor shard identity must preserve the layout version used by runtime state lookup, receipt mapping, witness replay, and state sync. - Changes to chunk persistence must keep the completion marker, refcounted state and receipt writes, flat-state delta, external-call records, and replay guard in the intended store update.
- Changes to external-call admission or repeat rules must stay aligned across dry-run preparation, protocol feature gates, chunk execution, persisted call hashes, the canonical-chain check, and transaction views.
- Changes to SPICE activation must keep the last pre-SPICE block rule, boundary records, execution heads, inherited entries, and fork-local state aligned.
- Changes to SPICE postprocessing must preserve the order between durable execution heads and per-shard flat-storage or memtrie cleanup. Do not advance a shard that has not applied the final block.
- Changes to boundary witnesses must keep the anchor chunk, source receipt proofs, old-chunk transitions, undelivered receipt proofs, and post-state roots consistent.
- Changes to SPICE certification must keep result hashes, validator evidence, fallback rules, pending chunks, certifying progress, and block limits consistent.
- Changes to transaction envelopes or external-call rules must stay aligned across protocol checks, preparation, runtime execution, witness validation, and challenge evidence.
- Changes to runtime error conversion must preserve the block height and hash on query errors so callers can identify the state that failed.
- Changes to state sync or snapshot keys must preserve the links among the sync block, certified result or chunk proof, snapshot state, state-root node, state parts, and final head update.
- Changes to snapshot timing must preserve the resharding catch-up wait and the different pre-sync versus sync-block state meanings.
- Changes to shard layout must update layout-qualified state lookup, receipt mapping, witness traversal, flat-storage readiness, child-state catch-up, and trie-state cleanup together.
- Changes to resharding order must keep flat child creation and catch-up ahead of trie state completion, and parent flat-storage cleanup last.
- Changes to epoch processing must keep validator proposals, protocol version, shard layout, assignments, and account updates on the same ancestry.
- Changes to execution outcome selection must preserve canonical-chain filtering and the preference for state-changing inclusions over earlier rejections.
- Changes to store indexes or retention markers must keep block, chunk, header, reference-count, tail, state-sync, and producer-record views consistent.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A block signature, parent link, chunk header, or commitment is invalid. | The block is rejected as bad chain data. | Check signatures, ancestry, layout, and commitments before shard application. |
| A parent, chunk body, or optimistic result is missing. | Processing waits and the body head does not advance. | Keep the block in the matching bounded dependency pool and retry it. |
| A shard number uses the wrong layout version. | State or receipts can use the wrong shard lineage. | Carry the layout-qualified shard identity through chain, runtime, and witness paths. |
| An old chunk differs from the prior chunk header. | Shard continuity fails and the block is rejected. | Compare old headers with the parent-derived headers. |
| A completion marker is committed without its state or receipt writes. | Replay can double-count shared data or expose incomplete state. | Commit the marker and related writes in one per-shard update. |
| An accepted external call is treated as a repeat without checking finality and canonicality. | A new call can be dropped because of an orphaned or non-final inclusion. | Use the call cache only with the final canonical chain and bounded repeat window. |
| A witness has incomplete receipt proofs or a mismatched applied-receipt hash. | Stateless validation cannot establish the input to execution. | Require exact source proofs and compare the resulting receipt hash. |
| A boundary witness names the wrong block or state root. | The pre-SPICE state path cannot be reconstructed safely. | Replay each named old chunk and compare every claimed root. |
| A SPICE result lacks enough matching validator evidence. | A chunk cannot move to the certified frontier. | Match the result hash to the evidence and apply the designated or fallback stake rule. |
| A SPICE block carries duplicate, irrelevant, or mismatched core statements. | The block is rejected before certification progress is recorded. | Validate statement relevance, signatures, uniqueness, limits, and result hashes. |
| SPICE cleanup runs before its durable execution head is committed. | Flat state or memtrie data can move ahead of the trusted execution view. | Commit heads first and clean only shards that applied the relevant final block. |
| State-sync parts or their root do not match the trusted response. | The node rejects the state before changing local state. | Validate the root node and every part before applying them. |
| A snapshot starts while resharding catch-up is too far behind. | Snapshot work duplicates catch-up or names a state that is not ready. | Delay creation until the tracked shards reach the required catch-up point. |
| A child state is marked ready before flat and trie catch-up reaches the final chain. | Reads can use incomplete state after resharding. | Keep child readiness and parent cleanup after both resharding stages complete. |
| Runtime preparation admits an external call that the active protocol forbids. | A producer and validator can derive different chunk results. | Apply protocol and chunk-wide envelope checks before preparation and witness replay. |
| An outcome from an abandoned fork is selected over a canonical outcome. | Transaction views report a result that did not affect the current chain. | Filter stored outcomes by canonical ancestry and prefer state-changing outcomes. |
| Store indexes, reference counts, or tail markers disagree. | Restart, lookup, or garbage collection can remove live data or expose missing data. | Run store consistency checks across linked rows and enforce head-tail ordering. |
| Validator proposals are read without their epoch context. | The next epoch can use the wrong validator or shard assignment. | Resolve proposals through the same block ancestry and epoch boundary. |
Key files
| File | Why to read it |
|---|---|
| chain/…/chain.rs | Main chain path for block validation, dependency handling, shard scheduling, state sync, outcome lookup, and head changes. |
| chain/…/chain_update.rs | Durable block and shard update boundary, epoch recording, state-sync finalization, and head advancement. |
| chain/…/types.rs | Shared contract between the chain and runtime for state sources, block context, shard identity, and apply results. |
| chain/…/mod.rs | Runtime boundary for transaction admission, external-call checks, shard transitions, validator account updates, state parts, and resharding checks. |
| chain/…/external_call_cache.rs | Recent external-call inclusions and the final canonical-chain rule for repeat suppression and call lookup. |
| chain/…/update_shard.rs | Common path that turns new and old chunk work into runtime state transitions. |
| chain/…/chunk_application.rs | Shared per-shard persistence contract, optional store columns, external-call recording, and SPICE execution context. |
| chain/…/block_application.rs | SPICE execution-head commit and ordered per-shard flat-storage and trie cleanup. |
| chain/…/core.rs | SPICE certification state, core statements, execution-result recovery, limits, and validator proposals. |
| chain/…/boundary.rs | Activation-boundary records and execution-head seeding between pre-SPICE and SPICE. |
| chain/…/boundary_synthesis.rs | Construction of boundary execution results, receipt proofs, and boundary witnesses from prior state transitions. |
| chain/…/chunk_validation.rs | Stateless witness traversal across old chunks, resharding, receipts, and state roots. |
| chain/…/state_snapshot_actor.rs | Snapshot cadence, resharding wait rules, snapshot state location, and state-sync advertisement. |
| chain/…/adapter.rs | State-sync proof, state-part, certified-result, and response handling. |
| chain/…/genesis.rs | Genesis block, initial chunk state, congestion data, chain heads, and flat-storage initialization. |
| chain/…/flat_storage_resharder.rs | Parent-to-child flat-state copy, catch-up, readiness, cancellation, and recovery. |
| chain/…/trie_state_resharder.rs | Batched child trie-state creation, resume state, mapping cleanup, and parent flat-storage removal. |
| chain/…/mod.rs | Chain-store contracts, persistence policy, receipt mapping, indexed data, and atomic update state. |
| chain/…/garbage_collection.rs | Retention rules for canonical, fork, witness, sync, invalid-chunk, and archival data. |
| chain/…/validate.rs | Cross-checks for persisted blocks, chunks, roots, indexes, references, and state-sync data. |
| chain/…/tests.rs | Behavioral coverage for state transitions, validator account changes, state-part behavior, and runtime state access. |
| chain/…/block_application.rs | Behavioral coverage for per-shard SPICE execution-head and post-commit advancement. |
| chain/…/garbage_collection.rs | Behavioral coverage for fork retention, canonical cleanup, tail movement, and trie preservation. |