Repository navigation
fix(store): re-verify stored sections once on first start after the receive-path binding - #24
Open
cafebedouin wants to merge 1 commit into
Open
cafebedouin wants to merge 1 commit into
cafebedouin wants to merge 1 commit into
Conversation
…eceive-path binding v0.8.2 binds sections at the network write. A body stored under a derived id by an earlier version — including one a peer wrote while v0.8.1 accepted unbound deliveries — is read back by v0.8.2, passes the sweep's has_modifier gate, and is applied; section_id_from_body has one production call site, the pipeline write, so nothing re-checks stored bytes. Witnessed across two versions sharing one store file. RedbModifierStore::rebind_sections(type_ids, bound): one read pass over PRIMARY for 102/104/108, one write pass deleting rows that fail the predicate and the HEIGHT_INDEX rows that pointed at them; returns (kept, dropped). main.rs runs it once after the scores migration with section_id_from_body(t, bytes).id == id and records chain_meta "sections_rebound_v1", mirroring scores_migrated_v1. Test: rebind_sections_drops_unbound_rows_and_their_index_entries. Contract: facts/store.md § One-shot rebind of stored sections.
This was referenced Sep 16, 2026
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.
Branch:
ergo-logic/rebind-stored-sections. Files:store/src/redb.rs,src/main.rs,facts/store.md.Why
v0.8.2's binding applies to writes. A body stored under a derived id by v0.8.1 — including one a peer
wrote while v0.8.1 accepted unbound deliveries — is read back by v0.8.2, passes the sweep's
has_modifiergate, and is applied; nothing recomputes its id (section_id_from_bodyhas oneproduction call site, the pipeline write). Executed across two clones sharing one store file:
poison: read_back=true contains=true would_bind=Some(false); honest control binds.What
RedbModifierStore::rebind_sections(type_ids, bound): one read pass over PRIMARY for 102/104/108,one write pass deleting rows that fail the predicate and the HEIGHT_INDEX rows pointing at them;
returns
(kept, dropped).main.rsruns it once after the scores migration, predicatesection_id_from_body(t, bytes).id == id, and recordschain_meta["sections_rebound_v1"], mirroringscores_migrated_v1.Tests
New:
rebind_sections_drops_unbound_rows_and_their_index_entries(kept/dropped counts, index rows,idempotence).
cargo test -p enr-store: 54 passed;cargo check -p ergo-node-rust: clean.Contract
facts/store.md§ "One-shot rebind of stored sections".Cost, and what a dropped row means
The pass hashes every stored body of types 102/104/108 in one read pass and removes the unbound rows
in one write transaction, before the chain restores. The scores migration just above it chunks its
writes at 50,000 entries to bound unclean-restart work (
src/main.rs:2217-2255); this pass is notchunked. On a pruned node the walk is
blocks_to_keepbodies and short. On an archival node it hashesevery body on the chain once; if you would rather have it chunked with a progress line, say so and
the patch gets that shape. A dropped row was never a body the node had validated against its header:
its bytes did not hash to its key. Below the applied tip nothing re-requests it (the sweep resumes at
applied_tip + 1,sync/src/state.rs), so an archival node that was poisoned on v0.8.1 servesnothing for that height's section after the pass, where before it served the poison; a resync
restores it. Above the applied tip the sweep's existence gate sees the gap and downloads the body.
Changelog entry
Not in the patch (your repo instructions reserve
CHANGELOG.mdfor the main session, and four PRsinserting an Unreleased block at the same spot conflict with each other). Text, if useful:
🤖 Generated with Claude Code