Skip to content

chain: keep the timeout-vote journal across a snapshot import too - #266

Merged
On1x merged 2 commits into
masterfrom
fix/timeout-vote-journal-snapshot-restore
Nov 8, 2026
Merged

On1x merged 2 commits into
masterfrom
fix/timeout-vote-journal-snapshot-restore

Conversation

@On1x

@On1x On1x commented Nov 8, 2026

Copy link
Copy Markdown
Member

Supersedes #265 (auto-closed when its base branch was removed by the #264 merge; same commit).

The production image ships plugin = snapshot, snapshot-every-n-blocks = 2400, snapshot-max-age-days = 2 and sync-snapshot-from-trusted-peer with four trusted peers, and auto-recovery takes the newest snapshot before trying a block-log replay. So on a production node a 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 (#264) alone would not have helped the nodes it was written for.

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.

  • open_from_snapshot() marks the cache pending instead of truncating it.
  • 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 helper reindex() uses too, so one place decides what a kept cache means.

Verification: wiring suite reads plugins/chain/plugin.cpp and pins the snapshot branch and the resume call; 18 mutations, every one red. test_timeout_vote_journal.py PASS. single-TU -fsyntax-only rc=0 for database.cpp and plugin.cpp.

🤖 Generated with Claude Code

On1x added 2 commits November 8, 2026 18:45
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.
@On1x On1x added the testnet21-stand Build the 21-validator testnet image for the QC bench label Nov 8, 2026
@On1x
On1x merged commit dbd4e5e into master Nov 8, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testnet21-stand Build the 21-validator testnet image for the QC bench

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant