pruner: fall back to disk snapshot root when journal is missing#304
Merged
curryxbo merged 1 commit intofix/snapshot-zk-mpt-compatfrom Mar 20, 2026
Merged
Conversation
When data is copied from a running node or after an unclean shutdown, the snapshot journal is not written and in-memory diff layers are lost. snapshot.New(headBlock.Root()) fails because the on-disk snapshot root lags behind the chain head by up to 128 blocks. Retry with the persisted disk snapshot root so prune-state can proceed without requiring the operator to run the node first. The pruning target will be at most 128 blocks behind the chain head; the node will re-execute those blocks on the next restart. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
curryxbo
pushed a commit
that referenced
this pull request
Mar 24, 2026
After #304 merged, NewPruner can succeed via the disk-root fallback and create a bloom filter. If prune-state is then interrupted, RecoverPruning is triggered on the next run. Three issues needed fixing: 1. snapshot.New fallback: same as NewPruner — when the journal is missing, retry with ReadSnapshotRoot() so recovery can initialise the snapshot tree. 2. Snapshots() translation: headBlock.Root() may be a zkStateRoot; translate to mptStateRoot before the lookup so diff layers (keyed by mptRoot) can be found. 3. DiskRoot check: when the original prune used DiskRoot() as target (our fallback path), stateBloomRoot equals the disk layer root. Snapshots() with nodisk=true excludes the disk layer, so check snaptree.DiskRoot() explicitly to avoid a spurious "non-existent target state" error. Co-Authored-By: Claude Opus 4.6 <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.
Background
When node data is copied from a running node or after an unclean shutdown,
the snapshot journal is not written and in-memory diff layers are lost.
`snapshot.New(headBlock.Root())` fails because the on-disk snapshot root
lags behind the chain head by up to 128 blocks, causing `prune-state` to
error out and requiring the operator to run the node first before pruning.
Fix
When `snapshot.New(headBlock.Root())` fails in `NewPruner`, fall back to
`rawdb.ReadSnapshotRoot()` and retry. The pruning target becomes the disk
snapshot root (at most 128 blocks behind the chain head). The node will
re-execute those blocks automatically on the next restart.
Trade-off
Relation to #303
This PR is an optional enhancement on top of #303 (`fix/snapshot-zk-mpt-compat`),
kept as a separate PR for independent review and merge consideration.
🤖 Generated with Claude Code