better diff adjustment at block 350.000

This commit is contained in:
NotRin7
2025-11-22 16:38:29 +01:00
parent 6620061934
commit 89940a5e2f
3 changed files with 33 additions and 8 deletions

View File

@@ -9,6 +9,7 @@
#include <consensus/validation.h>
#include <coins.h>
#include <validation.h>
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)) {

View File

@@ -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;

View File

@@ -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