From 89940a5e2f1148898abde310081e1ea10c5aeabc Mon Sep 17 00:00:00 2001 From: NotRin7 Date: Sat, 22 Nov 2025 16:38:29 +0100 Subject: [PATCH] better diff adjustment at block 350.000 --- src/policy/policy.cpp | 9 +++++++-- src/pow.cpp | 30 +++++++++++++++++++++++++----- src/script/standard.h | 2 +- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index 7d75248..077cdc2 100644 --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -9,6 +9,7 @@ #include #include +#include CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn) @@ -117,9 +118,13 @@ bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeR return false; } - if (whichType == TX_NULL_DATA) + if (whichType == TX_NULL_DATA) { + if (ChainActive().Height() < 350000 && txout.scriptPubKey.size() > 83) { + reason = "scriptpubkey"; + return false; + } nDataOut++; - else if ((whichType == TX_MULTISIG) && (!permit_bare_multisig)) { + } else if ((whichType == TX_MULTISIG) && (!permit_bare_multisig)) { reason = "bare-multisig"; return false; } else if (IsDust(txout, dust_relay_fee)) { diff --git a/src/pow.cpp b/src/pow.cpp index cd01e1e..23c19cc 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -28,6 +28,20 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead if (params.fPowAllowMinDifficultyBlocks && pindexLast->nHeight >= 0) return LwmaCalculateNextWorkRequired(pindexLast, params); + // Palladium: Hard Fork at 350,000 for fast difficulty adjustment + if (pindexLast->nHeight + 1 >= 350000) { + int64_t nIntervalNew = 60; + if ((pindexLast->nHeight + 1) % nIntervalNew != 0) + return pindexLast->nBits; + + int nHeightFirst = pindexLast->nHeight - (nIntervalNew - 1); + assert(nHeightFirst >= 0); + const CBlockIndex* pindexFirst = pindexLast->GetAncestor(nHeightFirst); + assert(pindexFirst); + + return CalculateNextWorkRequired(pindexLast, pindexFirst->GetBlockTime(), params); + } + if (pindexLast->nHeight >= 29000) return LwmaCalculateNextWorkRequired(pindexLast, params); @@ -110,19 +124,25 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF if (params.fPowNoRetargeting) return pindexLast->nBits; + // Palladium: Hard Fork at 350,000 for fast difficulty adjustment + int64_t nTargetTimespan = params.nPowTargetTimespan; + if (pindexLast->nHeight + 1 >= 350000) { + nTargetTimespan = 7200; // 60 blocks * 120 seconds + } + // Limit adjustment step int64_t nActualTimespan = pindexLast->GetBlockTime() - nFirstBlockTime; - if (nActualTimespan < params.nPowTargetTimespan/4) - nActualTimespan = params.nPowTargetTimespan/4; - if (nActualTimespan > params.nPowTargetTimespan*4) - nActualTimespan = params.nPowTargetTimespan*4; + if (nActualTimespan < nTargetTimespan/4) + nActualTimespan = nTargetTimespan/4; + if (nActualTimespan > nTargetTimespan*4) + nActualTimespan = nTargetTimespan*4; // Retarget const arith_uint256 bnPowLimit = UintToArith256(params.powLimit); arith_uint256 bnNew; bnNew.SetCompact(pindexLast->nBits); bnNew *= nActualTimespan; - bnNew /= params.nPowTargetTimespan; + bnNew /= nTargetTimespan; if (bnNew > bnPowLimit) bnNew = bnPowLimit; diff --git a/src/script/standard.h b/src/script/standard.h index a710990..2d4b61f 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -30,7 +30,7 @@ public: * Default setting for nMaxDatacarrierBytes. 80 bytes of data, +1 for OP_RETURN, * +2 for the pushdata opcodes. */ -static const unsigned int MAX_OP_RETURN_RELAY = 83; +static const unsigned int MAX_OP_RETURN_RELAY = 520; /** * A data carrying output is an unspendable output containing data. The script