refactor(node/storage): tighten docs and fix two pruning defects#1107
Merged
tcoratger merged 1 commit intoJun 16, 2026
Merged
Conversation
Documentation: - Trim the verbose docstrings and consensus-tutorial comments across the module to the project rules, keeping only the load-bearing rationale (head is a raw root, genesis time is little-endian, the empty keep-set branch, blocks and states share columns). - Fix three doc inaccuracies in the SQLite backend: it referenced a commit() method that does not exist (durability is only via the batch-write block), claimed thread safety the shared-connection design does not provide, and listed attestation storage that does not exist. Pruning correctness: - Prune the state-root index too. It was never cleaned, leaking rows and leaving lookups that resolve to a block that no longer exists. - Make the slot-index delete honor the keep set, like blocks and states, so a preserved root below the prune slot keeps its slot mapping. - Cover both with tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Clarity/documentation pass over
src/lean_spec/node/storage/, plus two real pruning correctness fixes surfaced during review. The storage module is otherwise well-built — the get/put boilerplate, checkpoint accessors, and connection model are left as-is (refactoring them would trade readability for indirection and the rollback tests pin the current transaction model).Documentation
commit()method that does not exist — durability is exclusively via the batch-write block, and a lone write outside it is rolled back on close. The docstring invited silent data loss.Pruning correctness
prune_before_slotnever cleanedstate_root_index, leaking rows indefinitely and leavingget_block_root_by_state_rootable to resolve to a block that was already pruned. Now drops index entries whose block is no longer present.Testing
just checkpasses (ruff, format, ty, codespell, mdformat).uv run pytest tests/node/storage tests/node/sync tests/node/test_node.py— all pass.🤖 Generated with Claude Code