init: don't fail on ResetSyncCheckpoint for snapshot-sourced chains

When LoadBlockIndex tries to reset the sync-checkpoint, it looks for
one of the known checkpoint blocks in mapBlockIndex and writes it to
the DB. For a freshly snapshot-loaded chain, mapBlockIndex only has
~1166 headers near the tip — none of the known sync checkpoints
(2205000, 2206004) are in that subset.

The reset returns false (no checkpoint found in main chain), and the
caller currently treats this as fatal: 'failed to reset sync-checkpoint'.
But for snapshot-sourced chains this is expected — the sync checkpoint
will be set when the node syncs past the next known checkpoint height.

Soften the failure: if fLoadedFromSnapshot is true, log a warning and
continue instead of erroring out.
This commit is contained in:
Sami Ahmed
2026-06-19 02:54:58 -07:00
parent 800f508abd
commit dcfb650d9f
+11 -1
View File
@@ -3463,7 +3463,17 @@ bool LoadBlockIndex(bool fAllowNew)
if (!txdb.TxnCommit())
return error("LoadBlockIndex() : failed to commit new checkpoint master key to db");
if ((!fTestNet) && !Checkpoints::ResetSyncCheckpoint())
return error("LoadBlockIndex() : failed to reset sync-checkpoint");
{
// For snapshot-sourced chains, the small initial block index may
// not include any of the known sync checkpoints yet (snapshot only
// includes ~1166 headers near tip). The sync checkpoint will be
// set when the node syncs past a known checkpoint height.
if (fLoadedFromSnapshot) {
printf("LoadBlockIndex(): sync-checkpoint reset deferred (snapshot-sourced, no checkpoints in small index yet)\n");
} else {
return error("LoadBlockIndex() : failed to reset sync-checkpoint");
}
}
}
return true;