Fix checkpoint validation using wrong range limit

This commit is contained in:
Matt Hess
2026-01-18 14:41:37 +00:00
parent a668fa33c2
commit 63467b2c52
+6 -4
View File
@@ -3710,11 +3710,13 @@ bool SideChain::validate_loaded_checkpoints()
for (const Checkpoint& cp : m_checkpoints) {
LOGINFO(3, "Validating checkpoint at height " << cp.height);
// First check if checkpoint is reachable (within PPLNS window of current tip)
// First check if checkpoint is reachable (within checkpoint history range of current tip)
// Use CHECKPOINT_HISTORY * CHECKPOINT_INTERVAL, not m_chainWindowSize
const PoolBlock* tip = m_chainTip;
if (tip && (cp.height + m_chainWindowSize < tip->m_sidechainHeight)) {
// Checkpoint is too old - outside sync window, discard it
LOGWARN(0, "Checkpoint at height " << cp.height << " is unreachable (tip=" << tip->m_sidechainHeight << ", window=" << m_chainWindowSize << ") - discarding stale checkpoint");
const uint64_t checkpoint_range = CHECKPOINT_HISTORY * CHECKPOINT_INTERVAL;
if (tip && (cp.height + checkpoint_range < tip->m_sidechainHeight)) {
// Checkpoint is too old - outside checkpoint history range, discard it
LOGINFO(2, "Checkpoint at height " << cp.height << " is outside history range (tip=" << tip->m_sidechainHeight << ", range=" << checkpoint_range << ") - discarding");
had_stale = true;
continue; // Don't add to valid_checkpoints
}