IBD stall fix: restore IsInitialBlockDownload() time check, add block 570 checkpoint, fix version handler IBD bypass

This commit is contained in:
Krystie
2026-05-24 15:40:29 -07:00
parent 03aa38f1b4
commit 09ccd4339c
3 changed files with 22 additions and 10 deletions
+1
View File
@@ -21,6 +21,7 @@ namespace Checkpoints
//
static MapCheckpoints mapCheckpoints = {
{ 0, hashGenesisBlockOfficial },
{ 570, uint256("0x00000000005ce8c8eac03a0ca05f2ca0300268af40d52331e78392a5200d7e5f")},
{ 2000, uint256("0x0000000000b5f20078bf46ebdf1500813bb6b2cb482065aa93b89e073b2c6467")},
{ 2101, uint256("0xd4ea1ac45b63c8162a7fc8033cec441db8d532ba988202849d7831e32fe2d059")},
{ 2847, uint256("0xb5015e2835f13fd3bb6135cff9b31ac33310c9b77d694bdb592b8680d98d018e")},
+3 -3
View File
@@ -6,9 +6,9 @@
//
// These need to be macros, as version.cpp's and triangles-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 6
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_MAJOR 5
#define CLIENT_VERSION_MINOR 9
#define CLIENT_VERSION_REVISION 8
#define CLIENT_VERSION_BUILD 0
// Converts the parameter X to a string after macro replacement on X has been performed.
+18 -7
View File
@@ -1324,10 +1324,12 @@ bool IsInitialBlockDownload()
pindexLastBest = pindexBest;
nLastUpdate = GetTime();
}
// IBD is complete once we've passed the checkpoint height estimate.
// The previous >24h block-time check incorrectly kept IBD true when the
// chain was synced but simply stalled (no new blocks arriving), which
// prevented the stake miner from ever proceeding.
// IBD is complete once we've passed the checkpoint AND the chain tip is
// recent (within 24h). This prevents a stall AFTER checkpoint from
// permanently disabling header fetching. The forcestaking path above
// handles the specific staking-broker scenario.
if (GetTime() - nLastUpdate > 24 * 60 * 60)
return true;
return false;
}
@@ -4043,14 +4045,23 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
// parallelism. Multiple peers sending overlapping inv ranges is harmless
// (AlreadyHave filters duplicates) but ensures we discover and download
// blocks from the fastest available source.
// NOTE: nStartingHeight from version messages is unverified. Peers can
// claim any height. During IBD we always ask all eligible peers rather
// than filtering on a claim that may be wrong (a stunted node could be
// reporting the full chain height while only serving the tail of its
// own fork). Use nBestKnownHeight (updated from actual block responses)
// for peer capability assessment instead.
static int nAskedForBlocks = 0;
bool fIBD = IsInitialBlockDownload();
bool fBehindPeer = (pfrom->nStartingHeight > nBestHeight);
// During IBD: ask every non-client peer unconditionally to maximise
// download sources. Post-IBD: use traditional height-check logic.
bool fShouldAsk = !pfrom->fClient && !pfrom->fOneShot &&
(pfrom->nStartingHeight > (nBestHeight - 144)) &&
(fIBD ||
pfrom->nStartingHeight > (nBestHeight - 144) ||
pfrom->nStartingHeight > nBestHeight) &&
(pfrom->nVersion < NOBLKS_VERSION_START ||
pfrom->nVersion >= NOBLKS_VERSION_END) &&
(fIBD || nAskedForBlocks < 1 || vNodes.size() <= 1 || fBehindPeer);
(fIBD || nAskedForBlocks < 1 || vNodes.size() <= 1 || pfrom->nStartingHeight > nBestHeight);
printf("IBD-DIAG: version handler: peer=%s height=%d ourHeight=%d fClient=%d fOneShot=%d shouldAsk=%d nAskedForBlocks=%d IBD=%d\n",
pfrom->addr.ToString().c_str(), pfrom->nStartingHeight, nBestHeight,
pfrom->fClient, pfrom->fOneShot, fShouldAsk, nAskedForBlocks, fIBD);