feat(validation): allow min difficulty blocks after testnet inactivity

Add logic to skip proof-of-work check for testnet when there's been 20 minutes of inactivity, allowing min difficulty blocks to be mined. This helps maintain chain progress during periods of low testnet activity.
This commit is contained in:
2025-11-14 15:06:09 +01:00
parent 7f96a7d84c
commit 0e08faad30

View File

@@ -3437,7 +3437,16 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
// Check proof of work
const Consensus::Params& consensusParams = params.GetConsensus();
if (block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams))
// For testnet, allow min difficulty blocks after 20 minutes of inactivity
bool skipPowCheck = false;
if (params.NetworkIDString() == "test" && consensusParams.fPowAllowMinDifficultyBlocks) {
if (pindexPrev && block.GetBlockTime() > pindexPrev->GetBlockTime() + consensusParams.nPowTargetSpacing * 2) {
skipPowCheck = true; // Allow min difficulty after 20 min inactivity
}
}
if (!skipPowCheck && block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams))
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "bad-diffbits", "incorrect proof of work");
// Check against checkpoints