Introducing a new way to review your PRs.

Read the announcement

near / nearcore

Reference client for NEAR Protocol

View on GitHub

20 documents · Updated Nov 23, 2026

docs / storage-and-state

Storage and state

Storage and state form the durable base of a nearcore node. They preserve chain history and shard state across restarts, provide suitable views for execution and queries, and support state transfer and archival retention as the chain advances. The persistent storage and flat state page covers local persistence and fast key reads. The state synchronization and state parts page covers state transfer and reconstruction. The cloud archival storage page covers external archival data and recovery. Chain data processing and runtime execution describe the consumers that move and use this state.

State model

Chain state is kept per shard in a persistent Merkle-Patricia trie. A state root names one complete version of that trie, so block processing can use a precise state while the node keeps older versions needed by forks, queries, proofs, and recovery.

Durable state representation

Trie nodes and their values are stored by content hash. Shared records can support more than one state root until reference tracking and cleanup show that no live version needs them. The store also keeps chain records, state changes, flat-state data, and synchronization work in separate data groups so each group can follow its own access and retention needs. A state update carries both the new root and the changes needed to keep shared records live. This lets the same logical update serve the persistent trie, an in-memory trie, and recorded partial state without changing the state meaning.

References: core/…/mod.rs• L282-425 core/…/memtrie_update.rs• L70-134 core/…/memtrie_update.rs• L433-462 core/…/lib.rs• L1-27 core/…/columns.rs• L468-480 core/…/refcount.rs• L97-145

State roots and versions

A state root connects chain processing to state storage. Block work first creates a possible new version. The node then commits it for accepted work or discards it. This separation keeps fork work available without making every candidate state durable.

References: core/…/shard_tries.rs• L325-414 core/…/update.rs• L275-323 core/…/mod.rs• L441-476 chain/…/types.rs• L108-149

Persistence foundation

The persistence foundation gives chain processing, runtime execution, queries, synchronization, and maintenance a shared durable store. It keeps chain records, epoch context, shard state, and progress markers connected while allowing active data and retained history to use different storage tiers.

Database organization

The local database is organized as named data columns. Each column gives one kind of chain or operational data a stable key shape and access pattern. This separation lets the node scan related records, apply different cleanup rules, and move selected data to cold storage. Column policy also states whether data is permanent, reference-counted, deleted by garbage collection, or managed by a dedicated path.

The main groups are:

  • Chain records hold blocks, headers, chunks, receipts, outcomes, and height indexes.
  • State records hold trie content, state changes, flat state, and shard mappings.
  • Progress records track state parts, synchronization work, execution progress, and epoch proofs.
  • Local support records hold caches, witnesses, metrics data, and other node-only information.

The store exposes one common way to read keys or ranges, apply updates, flush durable data, create checkpoints, and collect storage statistics. A database instance can open only the columns needed by a storage tier, while the in-memory test database follows the same read, range, write, and reference-count behavior for storage-independent tests.

References: core/…/lib.rs• L1-27 core/…/columns.rs• L468-480 core/…/columns.rs• L697-797 core/…/rocksdb.rs• L101-137 core/…/rocksdb.rs• L545-585 core/…/testdb.rs• L8-20 core/…/testdb.rs• L45-126

Storage configuration

Storage configuration controls the boundary between safe persistence and performance support. It selects the database path and access mode. It also sets cache limits, prefetch use, in-memory trie loading, migration checkpoints, and hot or cold database behavior.

These settings change how quickly the node reaches state. They do not change the state root or the result of a valid lookup. Database metadata also records a strictly increasing format version and the database kind, such as RPC, archive, hot, or cold. Read-only mode remains separate from modes that can create or change a database, which protects inspection and recovery work from accidental writes.

References: core/…/config.rs• L9-18 core/…/config.rs• L48-87 core/…/config.rs• L107-133 core/…/config.rs• L277-386 core/…/metadata.rs• L1-59 core/…/rocksdb.rs• L73-123 core/…/rocksdb.rs• L879-895

Chain and epoch context

Chain storage preserves the records that let the node identify its current chain and interpret its history. It exposes the canonical head, final head, header head, height-to-hash links, block and receipt data, execution results, state-sync headers, and certification markers. It also keeps separate progress for SPICE execution, because execution and chain acceptance can complete at different times.

Epoch storage preserves the context needed to process blocks and continue synchronization. It records epoch starts, block and validator information, shard assignments, and epoch synchronization proofs. These records let a restarted node resume chain work without rebuilding all context from the beginning.

Chunk storage complements this chain view with the data produced while a shard chunk is applied. It keeps chunk results, application statistics, state witnesses, and contract access records available to later validation and maintenance work.

References: chain/…/chain.rs• L273-335 chain/…/core_writer_actor.rs• L130-179 chain/…/core_writer_actor.rs• L520-610 core/…/chain_store.rs• L57-145 core/…/chunk_store.rs• L42-124

Certified execution state

SPICE adds a durable layer for chunk execution results and validator endorsements. The node stores endorsements as they arrive, keeps uncertified results when needed, and promotes a result when the required stake supports it. This lets readers recover a certified state root even when the asynchronous writer is behind the block that already carries the certification.

The writer also buffers valid messages that arrive before their block. When the block becomes known, it checks the messages again against that block before adding them to durable state. This keeps asynchronous arrival from weakening block, shard, validator, or key-rotation checks.

The store keeps separate execution heads for ordinary and final SPICE progress. These heads move forward only, and the store records which block certified a chunk result once that block is final. This gives restart and read paths a stable view of certification progress.

References: chain/…/core_writer_actor.rs• L130-225 chain/…/core_writer_actor.rs• L405-500 chain/…/core_writer_actor.rs• L520-610 core/…/chain_store.rs• L122-145 core/…/chain_store.rs• L671-753 core/…/spice_proof_verifier.rs• L38-139 chain/…/core.rs• L175-244

Genesis state initialization

Genesis initialization establishes the first state roots for every shard. It can use roots already stored in the database, roots from a state dump, or roots computed from genesis records. Before it commits new roots, it checks that their count matches the shard layout so the node cannot start with a state and layout that describe different chains.

When records must be applied, the process also builds the initial trie and flat-state views. It preserves account storage use, receipt and promise queues, validator balances, and genesis congestion data as one starting position. A stored genesis height and root set then let later startup paths reuse the same state.

References: core/…/initialization.rs• L31-113 core/…/initialization.rs• L115-152 core/…/initialization.rs• L168-255 core/…/state_applier.rs• L26-99 core/…/state_applier.rs• L101-169 core/…/state_applier.rs• L174-377

Durable updates

Related records must reach durable storage as one logical update. A store update keeps state changes, indexes, roots, and progress markers consistent after a crash. The same boundary applies when a chunk produces trie changes, flat-state changes, contract updates, or execution progress.

The durability boundary is shown below.

flowchart LR
    A[Accepted chain work] --> B[Prepare state and metadata changes]
    B --> C[Commit one store update]
    C --> D[Durable trie and indexes]
    C --> E[Durable progress and certification markers]
    D --> F[Restart and query paths]
    E --> F

The production database turns one store update into one RocksDB write batch. The in-memory test database applies the same operation types without disk effects, which keeps tests focused on the storage contract rather than a particular engine.

References: chain/…/types.rs• L116-149 core/…/update.rs• L292-323 core/…/rocksdb.rs• L389-434 core/…/rocksdb.rs• L475-494 core/…/testdb.rs• L88-126 chain/…/core_writer_actor.rs• L228-284 chain/…/core_writer_actor.rs• L520-610

Storage lifecycle

The node uses hot storage for active chain work and can retain older data in cold storage. A split store presents the needed hot and cold records as one read view to callers that query history. External cloud archival extends this model for long-term retention and bootstrap; see cloud archival storage.

The hot and cold databases do not have identical duties. Cold migration copies the records for a finalized chain position and updates shard mappings when that position crosses a resharding boundary. Cloud archival reads retained chain data in block and shard batches rather than one block at a time. Its configuration carries the archive location, credentials, and chain identity; the current opener supports filesystem and GCS locations while rejecting unsupported backends. Garbage collection must stop at the oldest position still protected by local cold storage or cloud archival. This prevents active storage cleanup from passing the point at which a retained tier can recover the chain.

References: chain/…/mod.rs• L763-812 core/…/config.rs• L277-310 core/…/lib.rs• L10-15 core/…/columns.rs• L567-695 core/…/rocksdb.rs• L101-123 core/…/rocksdb.rs• L140-163 core/…/rocksdb.rs• L780-793 core/…/cold_storage.rs• L41-142 core/…/cold_storage.rs• L196-304 core/…/config.rs• L10-45 core/…/opener.rs• L22-49 core/…/mod.rs• L32-112 core/…/mod.rs• L114-192

Storage observability

Storage metrics expose the health of the main access paths rather than only database activity. Operators can compare database latency with cache use, prefetch staging, flat-state distance, in-memory trie work, state-part work, witness work, and resharding checks. These signals help show whether a slow operation comes from the database, an acceleration layer, or state maintenance.

The database also reports column-level engine statistics and tracks open iterators. A long-lived iterator is a storage risk because it can keep disk state from being compacted, so the store records its duration and warns when it remains open too long.

References: chain/…/metrics.rs• L12-160 chain/…/metrics.rs• L162-284 core/…/trie_storage.rs• L433-480 core/…/rocksdb.rs• L319-343 core/…/rocksdb.rs• L524-535

State access

The node uses several state views because current execution, historical queries, proof work, and stateless validation have different needs. The persistent trie remains the authoritative state identified by a root. Flat state, in-memory tries, caches, prefetching, and recorded partial state reduce the cost of reaching that state without changing its meaning.

Trie access

Trie access follows a key from a state root to its value. A normal lookup can use an in-memory trie, flat state, or the persistent trie. A view lookup avoids current in-memory roots so it can read historical state without competing with block processing. If an acceleration layer cannot serve the request, the lookup returns to another valid state source.

Lookup options also control whether a read records witness access or cache effects. This keeps transparent performance paths separate from reads whose access pattern is part of a protocol proof.

References: core/…/mod.rs• L96-157 core/…/mod.rs• L248-297 core/…/mod.rs• L1231-1325 core/…/shard_tries.rs• L137-220 chain/…/types.rs• L586-615

Trie iteration

Trie iteration provides ordered, prefix, and bounded-range access over either persistent or in-memory state. The same iterator contract lets callers scan state without knowing which state view serves the read. Seeking positions the scan without adding those navigation nodes to a recorded witness, while normal iteration records the nodes it visits when recording is enabled.

State-part generation uses the same ordered traversal to select a disjoint interval of trie data. Transaction-local iteration merges durable trie keys with committed and prospective changes, so callers see the temporary state rather than only the last durable root.

References: core/…/iterator.rs• L12-105 core/…/iter.rs• L61-167 core/…/iter.rs• L397-468 core/…/iterator.rs• L36-140

Typed state access

Typed state access provides one shared boundary for reading and writing accounts, contracts, access keys, receipt queues, and scheduler data. It serializes values under stable trie keys and turns malformed stored bytes into storage errors. It also offers reads with no access-recording side effects when a caller needs to inspect state without adding to a witness.

Paired mappings and account-owned records must be managed as one logical state unit. Account removal therefore covers the account, contract code, access keys, gas-key data, and contract data rather than leaving related trie entries behind.

References: core/…/mod.rs• L25-63 core/…/mod.rs• L109-179 core/…/mod.rs• L200-350 core/…/mod.rs• L426-443 core/…/mod.rs• L496-567

Transactional state updates

Transactional state updates provide a temporary read and write view while a block or chunk is applied. Reads see pending changes before the underlying trie. Commit moves those changes into the accepted update set, while rollback removes uncommitted work. Finalization turns the accepted changes into a new trie version and state-change records.

Contract deployments follow the same boundary. A contract can be visible to later work in the same apply before it is durable, but only committed deployments become part of the final update. Deterministic compilation accounting stays separate from receipt-state rollback.

References: core/…/update.rs• L30-45 core/…/update.rs• L275-323 core/…/contract.rs• L28-57 core/…/contract.rs• L203-261

Signer state overlay

Transaction preparation uses an ephemeral signer state overlay. It loads an account and its key data from the trie on first access, then keeps balance, nonce, and gas-key changes in the preparation view. All keys for one account share the same account balance, so checking several keys cannot create a double-spend in the temporary view.

The overlay is not a second durable state. It supplies the state that early preparation needs, and accepted transactions still pass through normal chunk application before storage changes are finalized.

References: chain/…/signer_overlay.rs• L8-37 chain/…/signer_overlay.rs• L71-155 chain/…/mod.rs• L205-245

Contract code access

Contract code is state addressed by its code hash. During chunk processing, contract storage combines persistent reads with deployments that are still being evaluated. Commit moves a deployment into the accepted set, while rollback removes only the uncommitted set. Finalization records calls and accepted local deployments for downstream distribution. Global contract deployments remain available locally but do not become local deployment broadcasts.

References: core/…/contract.rs• L11-31 core/…/contract.rs• L141-227 core/…/contract.rs• L249-261

Flat state access

Flat state is a per-shard key/value view that makes common lookups practical without walking the full trie. It keeps a durable flat head and stores changes after that head, so a read at a supported block can combine base values with the relevant chain of changes. The flat store exposes shard-scoped reads and ranges, while the manager advances each shard independently through its chain of deltas.

Flat state changes and the chain update that produced them must be committed together. A protected reader can hold a flat position while a snapshot or background state load uses it. Multiple holds share the same protection, so one reader cannot release the position while another still needs it. During resharding, a shard can remain in a catch-up state until its flat view reaches the required position.

References: core/…/flat_store.rs• L33-141 core/…/flat_store.rs• L168-224 core/…/manager.rs• L142-224 core/…/manager.rs• L273-346 core/…/storage.rs• L19-52 core/…/storage.rs• L287-425 core/…/storage.rs• L436-527 chain/…/types.rs• L306-360 core/…/mod.rs• L1231-1272

In-memory shard state

An in-memory trie is a live memory view of shard state used to make current block work fast. It can hold roots across heights and forks, share nodes between roots, and release old roots when no work needs them. The node rebuilds it from the flat-state base and later deltas, which preserves roots for recent blocks and forks during startup or catch-up.

An update can produce only an in-memory change or a paired in-memory and persistent change. When it produces both, the new root and shared-node reference changes must agree. A root pin keeps an in-flight apply alive while old roots are collected. Large loads can split the trie into key-prefix ranges and build those ranges in parallel before joining them. During resharding, a frozen parent view can be shared with child views until each child has its own complete state.

References: core/…/memtries.rs• L23-48 core/…/memtries.rs• L170-225 core/…/memtries.rs• L268-331 core/…/loading.rs• L21-60 core/…/loading.rs• L101-203 core/…/memtrie_update.rs• L70-84 core/…/memtrie_update.rs• L186-215 core/…/memtrie_update.rs• L402-462 core/…/shard_tries.rs• L491-569 core/…/shard_tries.rs• L572-735 core/…/shard_tries.rs• L745-800

Caching and prefetching

Shard caches keep recently used trie data close to the caller. Prefetching prepares expected keys in background I/O workers and places results in a bounded staging area. The main read path consumes staged data before it reads the database, while duplicate requests share one in-flight fetch.

Prefetching is a performance aid with explicit bounds. Queue and memory limits prevent read-ahead from taking unbounded resources. A full queue, a memory limit, or a failed read must leave the ordinary lookup path available.

References: core/…/trie_storage.rs• L53-64 core/…/trie_storage.rs• L492-605 core/…/prefetching_trie_storage.rs• L16-25 core/…/prefetching_trie_storage.rs• L382-494

State access recording

Trie recording captures the nodes and values touched by a read. The captured partial state can support a proof or witness and can be replayed against the same state root. Recording also tracks an upper size bound that includes removals, so a node can stop work before a witness exceeds its allowed size.

The same access result must remain valid across disk, flat-state, and in-memory reads. This makes a state witness a correctness boundary rather than a cache-specific result. Iteration and trie updates follow the same recording rules, including the extra nodes needed when trie restructuring changes a branch. A recording budget can stop the read at a stable point that a later replay reaches in the same way.

References: core/…/trie_recording.rs• L16-46 core/…/trie_recording.rs• L116-229 core/…/memtrie_update.rs• L246-262 core/…/squash.rs• L14-30 core/…/iterator.rs• L89-105 core/…/mod.rs• L653-787 core/…/trie_tests.rs• L255-378

State witness storage

Stateless validation uses recorded state as a temporary input instead of requiring the full shard state on disk. It first checks the witness against chain history, receipt proofs, transaction roots, and shard layout changes. It then replays the needed transitions from the recorded data and checks the resulting roots before accepting the chunk.

Light-client state proofs use the same partial trie idea for a smaller claim. The verifier rebuilds the requested value or a shard-local absence claim from recorded nodes and checks it against the certified state root. Execution and block proofs bind that state root to a trusted final head before the result is used.

This path also handles implicit transitions such as old chunks and resharding. Invalid witnesses can be saved for diagnosis without becoming accepted chain state.

References: chain/…/chunk_validation.rs• L141-252 chain/…/chunk_validation.rs• L309-457 chain/…/chunk_validation.rs• L579-845 core/…/spice_proof_verifier.rs• L104-139

Early preparation state

Chunk production can prepare transaction calls before the parent chunk has fully written its new trie nodes. The preparation waits for those nodes when needed, then runs calls against a state view that matches the parent post-state. A late or busy call stays out of the chunk and remains available for later preparation.

This path shares the same read recording and state rules as chunk application. Its extra thread and deadline only change when work runs, not which state a completed call observes.

References: chain/…/mod.rs• L205-415 chain/…/mod.rs• L418-490 chain/…/ecc_thread.rs• L28-93 chain/…/metrics.rs• L58-93

State advancement

State advances when accepted chain work produces a new shard root and the node records the related changes. The trie, flat state, in-memory views, and chain markers move at different points, but each must describe the same accepted chain position before later work relies on it.

Fork-aware state access

Recent forks need state versions that are not yet the final chain choice. The node keeps roots and changes long enough to answer supported fork reads, then removes old in-memory roots and durable records only when their references expire. This preserves candidate-block processing without making every fork the permanent current state.

References: core/…/mod.rs• L441-476 core/…/shard_tries.rs• L385-414 chain/…/types.rs• L64-83

Shard layout changes

Resharding changes which shard owns state. The node temporarily shares a frozen parent view with child views and applies compatible changes while independent child views are prepared. It uses account boundaries and the memory held by related account subtrees to choose a practical split. This keeps reads and block work available across the ownership change.

State-part and witness validation follow the same layout change. They derive the parent and child transition from the boundary block, retain the correct account range, and carry the needed congestion state into the child.

References: core/…/split.rs• L292-319 core/…/split.rs• L375-494 core/…/shard_tries.rs• L745-800 core/…/tests.rs• L89-141 chain/…/chunk_validation.rs• L255-307 chain/…/chunk_validation.rs• L722-774

State root protection

An in-flight apply must keep its previous root available until all reads and writes finish. The chain passes an explicit shard identity and an optional root pin into chunk application. This prevents cleanup or a resharding transition from removing state that a running task still needs.

References: chain/…/types.rs• L415-429 core/…/shard_tries.rs• L684-707 chain/…/mod.rs• L536-544

State synchronization

State synchronization lets a node obtain a shard state without replaying all earlier blocks. A sender identifies the state root and divides the trie into parts. A receiver validates those parts against the root, applies the complete reconstruction result, and then resumes normal chain work. See state synchronization and state parts for the transfer contract.

State transfer

State parts are independent ranges of trie data. Their boundaries and proof data let the receiver place each part under the claimed root. Applying a part produces persistent trie changes, flat-state changes, and any contract code found in the part. The receiver can process parts as a bounded stream instead of requiring one complete state object in memory.

Part boundaries are selected in trie traversal order and include the paths and left siblings needed to prove their position. Part validation rejects missing, unexpected, or duplicate trie data. The complete set of valid parts can then be merged without changing the claimed root.

References: core/…/state_parts.rs• L1-18 core/…/state_parts.rs• L114-156 core/…/state_parts.rs• L158-300 core/…/state_parts.rs• L302-479 core/…/iter.rs• L378-468 core/…/trie_tests.rs• L18-43 chain/…/mod.rs• L815-884 chain/…/types.rs• L737-767 core/…/mod.rs• L515-523

State snapshots

A state snapshot is a read-only checkpoint of selected state at a defined chain position. It isolates state-part generation and other heavy reads from live block processing while preserving the flat-state position needed to find the requested trie data.

Snapshot lifecycle

The node creates a snapshot with a block hash as its identity and includes only shards whose state view reaches the required position. While the snapshot is prepared, protected flat heads keep live updates from moving the read base. The node records the identity in durable metadata, opens the checkpoint for read-only work, and removes both the checkpoint and marker when the snapshot is deleted.

The snapshot flow is shown below.

sequenceDiagram
    participant N as Node
    participant D as Live store
    participant S as Read-only snapshot
    N->>D: Create checkpoint for a chain position
    D-->>S: Expose selected state and flat-state data
    N->>S: Read state for parts or heavy queries
    S-->>N: Return data bound to the snapshot hash
    N->>D: Clear snapshot marker and remove checkpoint

References: chain/…/mod.rs• L170-184 chain/…/mod.rs• L815-859 core/…/manager.rs• L24-47 core/…/manager.rs• L300-328 core/…/shard_tries.rs• L57-66 core/…/opener.rs• L290-297 core/…/opener.rs• L328-373 core/…/config.rs• L65-87

Snapshot-backed state work

State-part generation reads the snapshot's state view and resolves the referenced trie data from the snapshot store. The requested state root remains the correctness boundary, so the snapshot improves isolation without weakening validation.

References: chain/…/mod.rs• L832-859 core/…/state_parts.rs• L162-300 chain/…/tests.rs• L861-998

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to column names or key shapes must preserve existing database compatibility and the mapping used by hot and cold storage.
  • Changes to column retention or reference-count policy must preserve the intended visibility, cold-store membership, and cleanup path for each data group.
  • Changes to reference-count merge logic must keep the payload stable for a key and must preserve the zero-count behavior seen by reads and compaction.
  • Changes to storage modes, selected column sets, or migration checkpoints must keep read-only inspection separate from creation, migration, and normal writes.
  • Changes to cache, prefetch, or memtrie limits must preserve the ordinary lookup result when an acceleration path is full, delayed, or disabled.
  • Changes to write batching must preserve the atomic relationship between state records, indexes, roots, flat deltas, and progress markers.
  • Changes to the production database and test database must preserve the same prefix, range, insert-only, delete, and reference-count semantics.
  • Changes to genesis initialization must keep the selected state source, shard-layout root count, genesis height, congestion data, and returned roots aligned.
  • Changes to chunk-store records must keep chunk extras, apply stats, witnesses, and contract-access data keyed to the same block and shard.
  • Changes to typed state helpers must preserve trie-key pairing for yield mappings and must remove all account-owned records together.
  • Changes to flat-state delta metadata or shard status must keep the flat head, its predecessor chain, and the supported read block aligned.
  • Changes to memtrie update tracking must keep memory-only updates distinct from persistent updates and must produce the same root as the disk trie.
  • Changes to memtrie loading or root pinning must keep in-flight work alive and must apply all flat-state changes that arrive during loading.
  • Changes to transaction-local commit, rollback, or finalization must keep prospective reads, durable trie changes, state-change records, contract updates, and compilation accounting aligned.
  • Changes to signer preparation must keep one account balance shared across all of its keys and must not turn the overlay into durable state.
  • Changes to state-witness recording or budgets must preserve equivalent access results across disk, flat state, memtries, and partial-storage replay.
  • Changes to state-witness validation or light-client proof checks must preserve proof binding to the requested chunk, certified block, state root, and shard-local absence rules.
  • Changes to trie iteration or range overlay logic must preserve ordered, prefix, and exclusive-bound semantics for both persistent and temporary state.
  • Changes to state-part boundaries or trie restructuring must preserve complete coverage, unique roots, proof nodes, and valid account ownership ranges.
  • Changes to state-part application must preserve root proofs, complete coverage, flat-state deltas, and contract-code extraction.
  • Changes to SPICE endorsement or execution-result storage must keep pending messages, certified results, fork reuse, and asynchronous notifications consistent.
  • Changes to SPICE execution heads or certification records must keep forward-only progress aligned with the block and chunk evidence they describe.
  • Changes to garbage-collection limits must stop cleanup at the oldest position protected by local cold storage or cloud archival.
  • Changes to state snapshot identity or flat-head holds must keep the stored hash aligned with the checkpoint and every reader request.
  • Changes to cold migration key derivation or resharding mapping must copy every required state and boundary record without double-counting references.
  • Changes to cloud archival configuration or opener support must keep the chain prefix, credentials, backend validation, and archive reader aligned.

Important failure modes

TriggerConsequenceGuard
A state root is removed while in-flight work still uses itBlock processing can fail to resolve its prior statePin the root for the lifetime of the work and release it only afterward
Background memtrie loading releases its flat head before catch-upThe in-memory view can miss changes made during loadingHold the flat head through load completion and delta catch-up
A database opens in a mode that can write during inspectionRecovery or viewing work can change the node's durable stateUse read-only mode for inspection and keep creation modes explicit
A storage tier opens without a required column or with an incompatible column setReads or migrations can fail before the node reaches chain workSelect columns according to the tier and validate database metadata before normal access
A write batch omits a related flat delta, index, root, or progress markerRestart can expose state and chain metadata at different positionsCommit related changes through one store update
A reference-counted key receives a different payloadShared state or receipt data can become ambiguousKeep the payload immutable for a key and use the reference-count update path
Prefetch staging reaches its memory or queue limitRead-ahead stops and a request can stall or fail through the prefetch pathBound the staging area and use the ordinary storage path
A transaction is finalized with pending prospective changesUncommitted work can be lost or the update cannot produce a valid rootCommit or roll back the temporary view before finalization
Signer data is cached per key instead of per accountSeveral keys can spend the same balance during preparationShare one account entry across all key entries
A contract deployment is rolled back after its code is used as committedContract updates can describe code that is not in accepted stateSeparate uncommitted and committed deployments
A recorded proof exceeds its size limitWitness generation cannot safely completeTrack nodes and removal cost with an upper-bound check
A state witness or light-client proof is not bound to the requested chunk or certified headA valid proof for another state can be accepted as the requested resultCheck identifiers, Merkle paths, outcome roots, and the claimed state root
A state witness omits a receipt proof or implicit transitionA validator can reject the chunk or replay the wrong stateDerive required transitions from chain history and validate complete coverage
A state part is missing boundary or sibling nodesThe receiver cannot prove the part belongs under the claimed rootInclude and validate the paths and left siblings required by the part boundary
A state part is applied without its flat delta or contract codeFast reads or contract distribution can lag behind the reconstructed trieApply the complete state-part result as one reconstruction unit
A trie deletion leaves an invalid branch or extension shapeDisk and memory roots can diverge or later reads can failRestructure modified nodes after deletion and compare persistent and in-memory roots
A pending SPICE endorsement is not checked again after its block arrivesA message valid for a possible epoch can enter the wrong block's stateRevalidate it against the known block and its epoch keys
A certified SPICE result is stored without enough stake supportReaders can treat an unverified result as certified stateRequire designated or eligible fallback endorsement thresholds
Garbage collection passes the local cold or cloud archival headHistorical reads or recovery can lose their source dataBound cleanup by every configured retention tier
Snapshot metadata names a different checkpoint than the reader requestsState-part generation cannot use a stable snapshotMatch the request hash with durable metadata and the open checkpoint
A cold migration derives a row with the wrong shard layout at a resharding boundaryCold storage can miss state or copy the same trie nodes twiceUse boundary-aware mapping and prefix scans where a row may use another epoch layout
Cloud archival is configured for an unsupported locationThe node cannot open its archival read or write pathValidate the location before creating the external connection

Key files

FileWhy to read it
core/…/lib.rsDefines the storage surface shared by chain, runtime, tools, and archival services.
core/…/config.rsDefines storage modes, cache and prefetch settings, migration checkpoints, and database tuning groups.
core/…/metadata.rsDefines database version and kind metadata used to validate storage compatibility.
core/…/columns.rsDefines the durable data groups, key shapes, retention tiers, and cleanup policies.
core/…/rocksdb.rsShows how the durable database opens storage tiers, batches updates, creates checkpoints, and reports engine health.
core/…/refcount.rsShows how shared values stay visible while references remain and disappear when their count reaches zero.
core/…/testdb.rsShows the storage contract in a deterministic in-memory database used by tests and IO-independent estimates.
core/…/state_applier.rsShows how trusted genesis records become initial shard state and account storage data.
core/…/initialization.rsShows how stored roots, state dumps, or genesis records become validated initial shard state.
core/…/mod.rsShows the typed state access boundary for accounts, keys, receipts, and account-owned cleanup.
core/…/mod.rsDefines state roots, lookup modes, partial state, reference changes, and the trie access boundary.
core/…/iterator.rsShows the shared ordered and prefix traversal used by disk and memory state views.
core/…/iter.rsShows range traversal used by state-part work and normal state scans.
core/…/iterator.rsShows how temporary committed and prospective changes are merged with trie iteration.
core/…/shard_tries.rsConnects persistent tries with flat state, caches, memtries, prefetching, snapshots, and resharding.
core/…/memtrie_update.rsShows how memory views and persistent trie changes can be produced from the same state update.
core/…/loading.rsShows how in-memory shard state is rebuilt from flat state and later deltas.
core/…/memtries.rsShows root lifetime, sharing, collection, and in-flight root protection for memory state.
core/…/trie_storage.rsShows the bounded shard-cache read path and its fallback to the database.
core/…/prefetching_trie_storage.rsShows how background reads share staged values without changing lookup results.
core/…/manager.rsShows how flat heads, deltas, resharding catch-up, and snapshot holds are coordinated.
core/…/flat_store.rsShows the durable flat-state values, status, ranges, and block delta records.
core/…/update.rsShows temporary state changes, commit and rollback, finalization, and contract update output.
core/…/trie_recording.rsShows how state reads become bounded partial state for proofs and witnesses.
core/…/state_parts.rsShows how state parts are bounded, validated, and converted into trie, flat-state, and contract changes.
core/…/split.rsShows how account boundaries are chosen for balanced shard state ownership.
core/…/contract.rsShows how contract code access and deployment tracking follow state transaction boundaries.
core/…/chain_store.rsShows the chain-facing access to heads, history, synchronization records, and SPICE progress.
core/…/chunk_store.rsShows the chunk-facing access to apply results, witnesses, and contract access records.
core/…/cold_storage.rsShows how finalized hot-store records move to cold storage across normal and resharding boundaries.
core/…/config.rsShows the archive location, credentials, roles, and chain context.
core/…/opener.rsShows backend validation and construction of the cloud archive connection.
core/…/spice_proof_verifier.rsShows how chunk, outcome, and state proofs are checked against a trusted head.
core/…/mod.rsShows the cloud archive read surface and the data rebuilt during cloud bootstrap.
chain/…/types.rsDefines the bridge between chain processing and runtime state access, including storage sources and root protection.
chain/…/mod.rsCoordinates runtime state access, chunk application, transaction preparation, state parts, and retention limits.
chain/…/signer_overlay.rsShows the temporary account and key view used during transaction preparation.
chain/…/chunk_validation.rsShows how recorded state, chain history, receipts, and resharding transitions validate a chunk witness.
chain/…/core_writer_actor.rsShows the durable handling of SPICE endorsements, execution results, pending messages, and certification.
chain/…/chain.rsShows how the chain facade joins block processing, runtime state, snapshots, synchronization, and SPICE reading.