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:
@@ -5107,7 +5107,14 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
||||
|
||||
assert(pindexPrev);
|
||||
|
||||
int daaForkHeight = GetArg("-daaforkheight", 450000);
|
||||
// For HUSH3, nBits validation starts above the original DAA fork height (450000).
|
||||
// For DragonX, nBits was never validated before the standalone binary, so the
|
||||
// chain contains blocks with incorrect nBits during the vulnerable window
|
||||
// (diff reset at RANDOMX_VALIDATION height through the attack at ~2879907).
|
||||
// Set daaForkHeight past that window so fresh sync accepts historical blocks.
|
||||
bool isdragonx = strncmp(SMART_CHAIN_SYMBOL, "DRAGONX", 7) == 0;
|
||||
int defaultDaaForkHeight = isdragonx ? ASSETCHAINS_RANDOMX_VALIDATION + 62000 : 450000;
|
||||
int daaForkHeight = GetArg("-daaforkheight", defaultDaaForkHeight);
|
||||
int nHeight = pindexPrev->GetHeight()+1;
|
||||
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||
// Check Proof-of-Work difficulty
|
||||
|
||||
Reference in New Issue
Block a user