[Bug] Ledger checkpoint can contain a block tree that is ahead of its RocksDB data
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Read node/rest/src/routes.rs's db_backup handler and node/src/node.rs's automatic checkpoint task, then trace how the ledger backup and block tree cache are written. The issue describes a race between those two steps; inspect the block store locking and checkpoint APIs to determine how to make both snapshots consistent. Done means a checkpoint's tree and RocksDB data describe the same height and the reported restart failure is covered.
Written by the indexing model from the issue text.
Description
🐛 Bug Report
A ledger checkpoint can contain a block_tree file that is ahead of its RocksDB data. A node that restarts from this checkpoint fails to load the ledger.
The checkpoint is written in two steps:
ledger.backup_database(path)takes a RocksDB checkpoint.ledger.cache_block_tree()writes the in-memory block tree. The file is then copied into the checkpoint.
Nothing stops a block from being committed between step 1 and step 2. If a block is committed there, the RocksDB checkpoint ends at height H and the cached tree contains height H + 1.
Affected call sites:
node/rest/src/routes.rs,db_backuphandler (POST /{network}/db_backup).node/src/node.rs, automatic checkpoint task. Open PR #4583 moves this task to a blocking thread but keeps the two separate steps.
Steps to Reproduce
The devnet CI job (.ci/test_db_backup.sh) hits this as a flake. Example: https://github.com/aleo-labs-protocol/snarkOS/actions/runs/41003086250/job/123892952148 (PR #4606 changes only Cargo.lock).
Timeline for validator-3:
| time (s) | event |
|---|---|
| 14.569655 | db_backup request received. RocksDB checkpoint taken at height 4. |
| 14.569704 | atomic speculate (height 5, round 10) starts. |
| 14.587979 | Cached the current block tree (tree includes block 5). |
| 14.588518 | Advanced to block 5 at round 10. |
Validators 0–2 served the request 30–80 ms before block 5 and did not hit the race.
After the rollback, validator-3 restarts from checkpoint_3_0 and exits:
Failed to start node — Failed to initialize the ledger — Failed to load ledger (run 'snarkos clean' and try again)
Block 5 exists in tree but not in storage;perhaps you used a wrong block tree cache file at '.../checkpoint_3_0/block_tree'?
Expected Behavior
The RocksDB checkpoint and its block_tree file describe the same height. A node can always restart from a checkpoint it wrote.
Possible fixes
- Take the RocksDB checkpoint and the tree snapshot as one consistent step.
BlockStore::insertholds the block-tree write lock while it writes storage. If the backup holds the tree lock across both steps, no block can be committed between them. This likely needs a snarkVM API, for example aBlockStoremethod that does both under one lock. - Or take the tree snapshot first, then the RocksDB checkpoint. On load, trim the cached tree down to the stored height instead of failing. This needs a snarkVM change to the load path.
Related: #4227 (same mismatch type, seen after a restart).
Your Environment
- snarkOS
stagingat22c4a97a3(base of PR #4606). - snarkVM rev
9796eb19(pinned inCargo.toml). - CI: GitHub Actions
devnetjob.
- Dominant language
- Rust
- Stars
- 4.5k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ProvableHQ/snarkOS
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ProvableHQ/snarkOS#4817 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 53/100
ProvableHQ/snarkOS#4814 ·
-
Proposal::signers derives every signer address on each callPossibly taken @cbeck88 claimed this 5 days ago. Openbft perf
Difficulty 3/5 1-2 days Newbie friendliness 72/100
ProvableHQ/snarkOS#4804 ·
-
bft question
Difficulty 5/5 Over a week Newbie friendliness 8/100
ProvableHQ/snarkOS#4789 ·
-
Bootstrap client parses gateway events as router messages when their IDs overlap, and drops the validatorPossibly taken @cbeck88 claimed this 10 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 65/100
ProvableHQ/snarkOS#4743 ·
All issues in ProvableHQ/snarkOS
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Copperpour/Copperpour#1105 ·
Maintainers usually reply within 1 day
-
bug release-blocker
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
refactor: Use new Bloom filter API introduced in arrow-rsPossibly taken @etseidl claimed this today. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/datafusion#27923 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
erkamyaman/rust-anything#1153 ·
Maintainers usually reply within 1 day
-
area: infra tier: p3 type: chore
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day