Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AC_PREREQ([2.69])
define(_CLIENT_VERSION_MAJOR, 5)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_BUILD, 70 )
define(_CLIENT_VERSION_MAJOR, 5)
define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_BUILD, 42)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true )
define(_COPYRIGHT_YEAR, 2025)
Expand Down
24 changes: 24 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ class CMainParams : public CChainParams {
consensus.nDeadpoolAnnounceValidity = 672;
consensus.nDeadpoolAnnounceMinBurn = 1000000; // 0.01 COIN

// Hard diff removal hardfork
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].bit = 26;
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].nStartTime = 1743465600LL; // 2025-04-01
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].nTimeout = 1775001600LL; // 2026-04-01
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].min_activation_height = 160000; // no delay

/**
* The message start string is designed to be unlikely to occur in normal data.
* The characters are rarely used upper ASCII, not valid as UTF-8, and produce
Expand Down Expand Up @@ -232,6 +238,12 @@ class CTestNetParams : public CChainParams {
consensus.nDeadpoolAnnounceValidity = 100;
consensus.nDeadpoolAnnounceMinBurn = 1000000; // 0.01 COIN

// Hard diff removal hardfork
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].bit = 26;
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].min_activation_height = (4 * consensus.nMinerConfirmationWindow);

//Number of rounds for gHash to generate random Ws around which to search for semiprimes.
consensus.hashRounds = 1;

Expand Down Expand Up @@ -389,6 +401,12 @@ class SigNetParams : public CChainParams {
consensus.nDeadpoolAnnounceValidity = 100;
consensus.nDeadpoolAnnounceMinBurn = 1000000; // 0.01 COIN

// Hard diff removal hardfork
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].bit = 26;
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].nStartTime = 1743465600LL; // 2025-04-01
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].nTimeout = 1775001600LL; // 2026-04-01
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].min_activation_height = 160000; // no delay

vFixedSeeds.clear();
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
Expand Down Expand Up @@ -467,6 +485,12 @@ class CRegTestParams : public CChainParams {
consensus.nDeadpoolAnnounceValidity = 100;
consensus.nDeadpoolAnnounceMinBurn = 1000000; // 0.01 COIN

// Hard diff removal hardfork
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].bit = 26;
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].nStartTime = 1743465600LL; // 2025-04-01
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].nTimeout = 1775001600LL; // 2026-04-01
consensus.vDeployments[Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL].min_activation_height = 160000; // no delay

UpdateActivationParametersFromArgs(args);

vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
Expand Down
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ constexpr bool ValidDeployment(BuriedDeployment dep) { return dep <= DEPLOYMENT_
enum DeploymentPos : uint16_t {
DEPLOYMENT_TESTDUMMY,
DEPLOYMENT_DEADPOOL,
DEPLOYMENT_HARD_DIFF_REMOVAL,
// NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp
MAX_VERSION_BITS_DEPLOYMENTS
};
Expand Down
4 changes: 4 additions & 0 deletions src/deploymentinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B
/*.name =*/ "deadpool",
/*.gbt_force =*/ true,
},
{
/*.name =*/ "hard_diff_removal",
/*.gbt_force =*/ true,
},
};

std::string DeploymentName(Consensus::BuriedDeployment dep)
Expand Down
86 changes: 72 additions & 14 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
//Fancy popcount implementation
#include <libpopcnt.h>

// DeploymentActiveAfter
#include <deploymentstatus.h>

uint16_t GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader* pblock, const Consensus::Params& params)
{
assert(pindexLast != nullptr);
Expand Down Expand Up @@ -62,6 +65,73 @@ uint16_t GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader*
return CalculateNextWorkRequired(pindexLast, pindexFirst->GetBlockTime(), params);
}

int32_t CalculateDifficultyDelta(const int32_t nBits, const double nPeriodTimeProportionConsumed, const bool isHardDiffRemoved) {
if (!isHardDiffRemoved) {
// Original difficulty adjustment algorithm

//Note for mainnet:
//If it takes more than 1 minute over the target blocktime, reduce difficulty.
if (nPeriodTimeProportionConsumed > 1.0333f)
return -1;

//Note for mainnet:
//To increase difficulty the network must be able to move the blocktime
//3 minutes under target blocktime. This is to avoid the difficulty becoming
//too much work for the network to handle. Based on heuristics.
if (nPeriodTimeProportionConsumed < 0.90f)
return 1;
} else {
// Difficulty adjustment algorithm that skips over odd aka. hard diffs (2025)

// If block time is too long, decrease to the previous even diff
if (nPeriodTimeProportionConsumed > 1.0333f) {
int32_t nRetarget = 0;
if (nBits % 2 == 0) {
// Even diff to even diff
nRetarget = -2;
} else {
// Odd diff to even diff
nRetarget = -1;
}

// If block time is way too long (>60 min on mainnet), decrease by 4 or 3 instead of by 2 or 1
if (nPeriodTimeProportionConsumed > 2.0f) {
nRetarget -= 2;
}

return nRetarget;
}

// If block time is too short, increase to the next even diff
if (nPeriodTimeProportionConsumed < 0.90f) {
int32_t nRetarget = 0;
if (nBits % 2 == 0) {
// Even diff to even diff
nRetarget = 2;
} else {
// Odd diff to even diff
nRetarget = 1;
}

// If block time is way too short (<15 min on mainnet), increase by 4 or 3 instead of by 2 or 1
if (nPeriodTimeProportionConsumed < 0.5f) {
nRetarget += 2;
}

return nRetarget;
}

// The block time is just right. See if we should move away from an odd diff
if (nBits % 2 == 0) {
// Already even diff. Don't change difficulty
return 0;
} else {
// Currently odd diff. Decrease diff by 1 to reach an even difficulty
return -1;
}
}
}

uint16_t CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params)
{
if (params.fPowNoRetargeting)
Expand All @@ -70,22 +140,10 @@ uint16_t CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirst
// Compute constants
const int64_t nActualTimespan = pindexLast->GetBlockTime() - nFirstBlockTime;
const double nPeriodTimeProportionConsumed = (double)nActualTimespan / (double)params.nPowTargetTimespan;
const bool isHardDiffRemoved = DeploymentActiveAfter(pindexLast, params, Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL);

//Variable to set difficulty delta
int32_t nRetarget = 0;

//Note for mainnet:
//If it takes more than 1 minute over the target blocktime, reduce difficulty.
if (nPeriodTimeProportionConsumed > 1.0333f)
nRetarget = -1;

//Note for mainnet:
//To increase difficulty the network must be able to move the blocktime
//3 minutes under target blocktime. This is to avoid the difficulty becoming
//too much work for the network to handle. Based on heuristics.
if (nPeriodTimeProportionConsumed < 0.90f)
nRetarget = 1;

int32_t nRetarget = CalculateDifficultyDelta(pindexLast->nBits, nPeriodTimeProportionConsumed, isHardDiffRemoved);

return (int32_t)pindexLast->nBits + nRetarget;
}
Expand Down
1 change: 1 addition & 0 deletions src/pow.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CBlockIndex;
class uint256;

uint16_t GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params&);
int32_t CalculateDifficultyDelta(const int32_t nBits, const double nPeriodTimeProportionConsumed, const bool isHardDiffRemoved);
uint16_t CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params&);

/** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
Expand Down
1 change: 1 addition & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,7 @@ RPCHelpMan getblockchaininfo()
SoftForkDescPushBack(tip, softforks, consensusParams, Consensus::DEPLOYMENT_TESTDUMMY);
SoftForkDescPushBack(tip, softforks, consensusParams, Consensus::DEPLOYMENT_TAPROOT);
SoftForkDescPushBack(tip, softforks, consensusParams, Consensus::DEPLOYMENT_DEADPOOL);
SoftForkDescPushBack(tip, softforks, consensusParams, Consensus::DEPLOYMENT_HARD_DIFF_REMOVAL);
obj.pushKV("softforks", softforks);

obj.pushKV("warnings", GetWarnings(false).original);
Expand Down