From ff87cc51c4018f1a985380ba254dedeee1458fbe Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Thu, 13 Nov 2025 13:51:26 +0100 Subject: [PATCH] fix(pow): adjust testnet difficulty calculation rules - Apply LWMA difficulty calculation for testnet from block 0 to match mainnet behavior - Clarify testnet min-difficulty rule by using explicit 20 minute threshold instead of nPowTargetSpacing*2 --- src/pow.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 29dfb97..477bf8e 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -19,6 +19,10 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead if ((pindexLast->nHeight >= 28930) && (pindexLast->nHeight <= 28999)) return nProofOfWorkLimit; + // For testnet, use LWMA from beginning to recalculate every block like mainnet + if (params.fPowAllowMinDifficultyBlocks && pindexLast->nHeight >= 0) + return LwmaCalculateNextWorkRequired(pindexLast, params); + if (pindexLast->nHeight >= 29000) return LwmaCalculateNextWorkRequired(pindexLast, params); @@ -28,9 +32,9 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead if (params.fPowAllowMinDifficultyBlocks) { // Special difficulty rule for testnet: - // If the new block's timestamp is more than 2* 10 minutes + // If the new block's timestamp is more than 20 minutes // then allow mining of a min-difficulty block. - if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2) + if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + 20 * 60) return nProofOfWorkLimit; else {