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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user