Skip to content

csnode: checkpoints save and check the digest of the state they hold - #87

Merged
EnzinoBB merged 2 commits into
masterfrom
feat/checkpoint-digest
Oct 24, 2026
Merged

EnzinoBB merged 2 commits into
masterfrom
feat/checkpoint-digest

Conversation

@EnzinoBB

Copy link
Copy Markdown
Collaborator

First step of snapshots served by community nodes (docs/specs/2026-10-24-snapshot-serving-design.md on docs/snapshot-serving, plan step 1).

What changes

  • Every checkpoint (periodic, slow-start, shutdown qs/0) writes qs/<seq>/state_digest.bin. The file holds the wallets digest, the wallet count and a hash of the consensus settings the caches carry: block reward, mining coefficient, staking/mining flags, stage-1 time, pending settings, DPOS start, recorded special orders. The checkpoint logs STATE DIGEST #<seq> <hex> wallets <n> checkpoint.
  • A quick start recomputes those values from the loaded caches and logs ... checkpoint loaded. A checkpoint whose caches do not match is quarantined (qs/<seq>.bad), and the next one is tried. A checkpoint without the file, from earlier builds, loads as before.
  • Loading or clearing the wallets invalidates the incrementally kept digest. Before this change a reload after a rejected checkpoint would reuse the stale one.
  • Node and BlockChain share one formatter for the digest line. Existing lines are unchanged, so the entrypoint, snapshot-make.sh, digest_offline.sh and run.sh still parse them; the new suffixes follow wallets <n>.

Not consensus-relevant: logging and local checkpoint files only.

Tests: unit tests for the file format (round trip, missing, truncated or longer, unknown version), the comparison and the log line format. Robustness scenarios to run on this branch: snapshot-join, snapshot-corrupt, all-storage, all-storage-crash, lmdb-pruned-crash, lmdb-pruned-term-kill, checkpoint-ahead, storage-switch.

🤖 Generated with Claude Code

Every checkpoint (periodic, slow-start and shutdown) writes
qs/<seq>/state_digest.bin: the wallets digest, the wallet count and a
hash of the consensus settings the caches carry, and logs
'STATE DIGEST #<seq> ... checkpoint'. A quick start recomputes them from
the loaded caches, logs '... checkpoint loaded', and quarantines a
checkpoint whose caches do not match, so the next one is tried. A
checkpoint without the file (earlier builds) loads as before.

Loading or clearing the wallets now invalidates the incrementally kept
digest, which a reload after a rejected checkpoint would otherwise reuse.

First step of snapshots served by community nodes: a snapshot made from
a checkpoint can declare the state of that checkpoint's block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The quick-start rejection line no longer contains 'STATE DIGEST #', so
scripts reading the digest of a block cannot pick the rejected one.
Tests: the consensus settings digest survives a checkpoint save and load
(every field it covers is restored before the comparison) and changes
with each of those fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EnzinoBB
EnzinoBB merged commit b11bf99 into master Oct 24, 2026
2 checks passed
EnzinoBB added a commit that referenced this pull request Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant