Fix fresh sync failure at diff reset height 2838976

Fresh-syncing nodes rejected the on-chain min-diff block at the
RANDOMX_VALIDATION activation height (2838976) because GetNextWorkRequired
computed the expected nBits from the preceding normal-difficulty blocks,
producing 469847994 instead of the on-chain 0x200f0f0f (HUSH_MINDIFF_NBITS).
This caused all seed nodes to be banned with "Incorrect diffbits" and the
node could never sync past that height.

Two changes:

1. GetNextWorkRequired (pow.cpp): Return nProofOfWorkLimit at the exact
   RANDOMX_VALIDATION activation height, matching the on-chain diff reset.

2. ContextualCheckBlockHeader (main.cpp): Raise DragonX daaForkHeight to
   RANDOMX_VALIDATION + 62000, covering the window where nBits was never
   validated (diff reset at 2838976 through the attack at ~2879907).

Tested by invalidating block 2838975 and reconsidering — node re-validated
through the diff reset and attack window, syncing back to tip with zero
bad-diffbits rejections.

Bump version to 1.0.1.
This commit is contained in:
2026-03-12 01:25:21 -05:00
parent 6d56ad8541
commit f0cb958cac
5 changed files with 21 additions and 4 deletions

View File

@@ -315,6 +315,16 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
if (pindexLast == NULL )
return nProofOfWorkLimit;
// DragonX difficulty reset at the RANDOMX_VALIDATION activation height.
// The chain transitioned to a new binary at this height and difficulty was
// reset to minimum (powLimit). Without this, fresh-syncing nodes compute
// a different nBits from GetNextWorkRequired (based on pre-reset blocks)
// and reject the on-chain min-diff block, banning all seed nodes.
if (ASSETCHAINS_RANDOMX_VALIDATION > 0 && pindexLast->GetHeight() + 1 == ASSETCHAINS_RANDOMX_VALIDATION) {
LogPrintf("%s: difficulty reset to powLimit at height %d\n", __func__, ASSETCHAINS_RANDOMX_VALIDATION);
return nProofOfWorkLimit;
}
//{
// Comparing to pindexLast->nHeight with >= because this function
// returns the work required for the block after pindexLast.