diff --git a/src/hush_bitcoind.h b/src/hush_bitcoind.h index e29b4f5bd..3d09cdac5 100644 --- a/src/hush_bitcoind.h +++ b/src/hush_bitcoind.h @@ -1713,6 +1713,22 @@ int32_t hush_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) height = pprev->GetHeight() + 1; if ( height == 0 ) return(0); + // The CheckRandomXSolution() above ran with height==0, where RandomXValidationRequired(0) + // is false, so RandomX was NOT verified. Re-verify now that the real height is recovered + // from hashPrevBlock. Without this, a peer block entering via ProcessNewBlock(0,0,...) (the + // net BLOCK handler, main.cpp) becomes a setBlockIndexCandidate with its PoW never checked + // at its real height: both CheckBlock() calls on that accept path pass fCheckPOW=0, so + // CheckBlockHeader's RandomX check never runs there -- this hush_checkPOW(0,...) is the ONLY + // real-height PoW gate before candidacy. A forged-RandomX fork could then trip the reorg + // guard before the connect-time check rejects it. This is a no-op wherever the first call + // was already a no-op: RandomXValidationRequired() gates on algo, the activation height + // (regtest heights are far below it), HUSH_LOADINGBLOCKS (IBD/reindex), and the last + // in-index checkpoint, and the thread-local fSkipRandomXValidation still skips the miner self-check. + if ( !CheckRandomXSolution(pblock, height) ) + { + fprintf(stderr,"hush_checkPOW slowflag.%d ht.%d CheckRandomXSolution failed (post height-recovery)\n",slowflag,height); + return(-1); + } } if ( (SMART_CHAIN_SYMBOL[0] != 0) && bhash > bnTarget ) {