Repository navigation
Conversation
The production image ships 'plugin = snapshot', snapshot-every-n-blocks = 2400
and sync-snapshot-from-trusted-peer, and auto-recovery takes the newest
snapshot BEFORE trying a block-log replay. So on a production node the restart
under a stall goes through open_from_snapshot(), not through reindex() -- and
that path truncated the cache on purpose ('chain state was wiped, starting with
an empty cache'). The reindex fix alone therefore would not have helped the
nodes it was written for: the same stall would still empty the journal through
the other door.
Keeping the cache there is safe because nothing from the file is trusted by
itself: the vote digest binds the chain id (block_timeout_digest(get_chain_id(),
...)), and every line is replayed through push_timeout_vote, which re-checks
schedule membership, the signing key, the signature and both edges of the
one-hour window. Votes of another chain are refused, not replayed.
So: open_from_snapshot() marks the cache pending instead of truncating, and
do_snapshot_load() calls database::resume_timeout_vote_journal() once the state
is final (snapshot loaded, dlt_block_log replayed on top). resume_* is the same
helper reindex() now uses, so there is one place that decides what a kept cache
means.
Test: the wiring suite reads plugins/chain/plugin.cpp as well, pins the
snapshot branch (no truncate, pending set) and the resume call, and gains three
mutations -- snapshot-truncates-cache, snapshot-never-restores,
snapshot-load-never-resumes. 18 mutations, every one red. single-TU
-fsyntax-only rc=0 for database.cpp and plugin.cpp.
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.
Stacked on #264 (base is its branch; retarget to master once it lands).
The production image ships
plugin = snapshot,snapshot-every-n-blocks = 2400andsync-snapshot-from-trusted-peer, and auto-recovery takes the newest snapshot before trying a block-log replay. So on a production node a restart under a stall goes throughopen_from_snapshot(), not throughreindex()— and that path truncated the cache on purpose (chain state was wiped, starting with an empty cache). The reindex fix alone would not have helped the nodes it was written for: the same stall would still empty the journal through the other door.Keeping the cache there is safe because nothing from the file is trusted by itself: the vote digest binds the chain id (
block_timeout_digest(get_chain_id(), ...)), and every line is replayed throughpush_timeout_vote, which re-checks schedule membership, the signing key, the signature and both edges of the one-hour window. Votes of another chain are refused, not replayed.Change:
open_from_snapshot()marks the cache pending instead of truncating it.do_snapshot_load()callsdatabase::resume_timeout_vote_journal()once the state is final (snapshot loaded,dlt_block_logreplayed on top).resume_*is the same helperreindex()uses now, so one place decides what a kept cache means.Verification:
plugins/chain/plugin.cpp, pins the snapshot branch (no truncate, pending set) and the resume call; three new mutations (snapshot-truncates-cache,snapshot-never-restores,snapshot-load-never-resumes) — 18 mutations, every one red.tests/chain/test_timeout_vote_journal.py: PASS.-fsyntax-only:database.cpprc=0,plugin.cpprc=0.Live acceptance after #264's image: same stand with a snapshot present, so the restart takes the snapshot door.
🤖 Generated with Claude Code