docs: data storage layout#515
Open
Aliemeka wants to merge 4 commits into
Open
Conversation
Contributor
Greptile SummaryThis PR adds a full reference for the storage layer. The main changes are:
Confidence Score: 4/5The crash-recovery description should be corrected before merging.
docs/data_storage.md
|
| Filename | Overview |
|---|---|
| docs/data_storage.md | Adds the storage reference; the crash-recovery section overstates safety across the checkpoint-before-block commit window. |
| docs/SUMMARY.md | Adds a valid navigation entry for the new data storage page. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
docs/data_storage.md:300-305
**Checkpoint Commit Breaks Crash Recovery**
`update_checkpoints()` commits justified metadata before the block and state batches. If the process crashes between those commits, restart can load a justified root with no block, `LiveChain` entry, or state; fork choice may then select that unavailable root and panic when `update_head()` expects its state to exist. Re-import can repair the store, but the on-disk state is not self-reconciling as this paragraph claims.
Reviews (1): Last reviewed commit: "update: clarify description of prune_liv..." | Re-trigger Greptile
…n data_storage.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fills in
docs/data_storage.md(previously a stub already linked from the mdBook TOC) with a full reference for the storage layer: theStore/StorageBackendsplit and what lives in each table.Based on this issue: #164
Contents
The page covers the whole data lifecycle, with ASCII diagrams in the style of the existing consensus docs:
StorageBackendtrait (read views, atomic write batches) vs theStorethat owns all semantics; the RocksDB and in-memory backends; how clonedStores share one backend and the in-memory pools across actors. Includes a layered-architecture diagram and a persisted-vs-in-memory breakdown.Tablevariant with key encoding, value type, write/read/prune behavior. Documents the details the enum doc comments gloss over: the big-endianslot ‖ rootkey layout for early-stop pruning scans, empty-body elision viaEMPTY_BODY_ROOT, and thatBlockSignaturesactually stores the merged aggregate proof keyed byslot ‖ root(the name is historical).StateDiffstores vs recovers, and the LRU cache → snapshot → reconstruction read path, with a reconstruction-walk diagram.BlockSignaturesbelow the ~1-day window), and what is never pruned.MAX_RESUMABLE_DB_STATE_AGEfallback to checkpoint sync.Why
The DB layout has grown complex (block data split across three tables, diff-layer state storage, two pruning paths), but the only documentation was the terse
Tableenum doc comments — one of which (BlockSignatures) has drifted from the implementation. A page indocs/next to the other architecture docs gives contributors a single accurate reference for what is on disk, what is in memory, and what survives a restart.Verification
Every claim was fact-checked against the source in
crates/storageandcrates/blockchain/src/store.rs: table key encodings (encode_slot_root_key), the constants (SNAPSHOT_ANCHOR_INTERVAL = 1024,STATE_CACHE_CAPACITY = 32,SIGNATURE_PRUNING_RANGE = 21_600,MAX_RESUMABLE_DB_STATE_AGE = 450, buffer caps 64/512/2048), theon_blockcommit sequence, the pruning conditions, and the constructor/restore paths.mdbook buildpasses, including thelinkcheck2backend that validates the internal links.Related issue
Closes #164