RandomX PoW verification is ~84% of block-connect wall time during network IBD, and CheckBlock was recomputing it TWICE per block: once in CheckBlockHeader and again in hush_checkPOW (which has no CBlockIndex, so it cannot use the fRandomXVerified dedup the parallel pre-verify pool relies on). Skip the redundant recompute inside hush_checkPOW: CheckBlockHeader runs first in CheckBlock and rejects an invalid solution before hush_checkPOW is reached, so the block is already verified once. Equihash, PoW-target and notary checks in hush_checkPOW still run. A scoped guard (ScopedRandomXSkip) SAVES and RESTORES the thread-local fSkipRandomXValidation, so it neither clobbers the miner's own skip (TestBlockValidity -> ConnectBlock re-entry, which would otherwise force the ~256MB inline RandomX alloc the miner deliberately avoids) nor leaks the flag on an exception. Measured on an isolated RandomX test chain: RandomX verifies per block 2.0 -> 1.03 (~40% faster network sync). The 2x behavior pre-exists in v1.0.2. Consensus-neutral: RandomXPreVerify.ConsensusEquivalence gtest passes; each block is still verified exactly once by CheckBlockHeader. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5.8 KiB
5.8 KiB