From 4ffa7bac0284f9ac5b830fd2423837d5dd1cf2b1 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 8 Mar 2018 15:18:24 +0300 Subject: [PATCH] Introduce DIP0001Height (#1973) Block height at which DIP0001 becomes active Also drop fDIP0001WasLockedIn --- src/chainparams.cpp | 4 ++++ src/consensus/params.h | 2 ++ src/dsnotificationinterface.cpp | 2 +- src/validation.cpp | 8 ++++---- src/validation.h | 1 - 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 56dff755c..0f8fce8e4 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -140,6 +140,7 @@ public: consensus.BIP34Hash = uint256S("0x000001f35e70f7c5705f64c6c5cc3dea9449e74d5b5c7cf74dad1bcca14a8012"); consensus.BIP65Height = 619382; // 00000000000076d8fcea02ec0963de4abfd01e771fec0863f960c2c64fe6f357 consensus.BIP66Height = 245817; // 00000000000b1fa2dfa312863570e13fae9ca7b5566cb27e55422620b469aefa + consensus.DIP0001Height = 782208; consensus.powLimit = uint256S("00000fffff000000000000000000000000000000000000000000000000000000"); consensus.nPowTargetTimespan = 24 * 60 * 60; // Dash: 1 day consensus.nPowTargetSpacing = 2.5 * 60; // Dash: 2.5 minutes @@ -291,6 +292,7 @@ public: consensus.BIP34Hash = uint256S("0x000008ebb1db2598e897d17275285767717c6acfeac4c73def49fbea1ddcbcb6"); consensus.BIP65Height = 2431; // 0000039cf01242c7f921dcb4806a5994bc003b48c1973ae0c89b67809c2bb2ab consensus.BIP66Height = 2075; // 0000002acdd29a14583540cb72e1c5cc83783560e38fa7081495d474fe1671f7 + consensus.DIP0001Height = 5500; consensus.powLimit = uint256S("00000fffff000000000000000000000000000000000000000000000000000000"); consensus.nPowTargetTimespan = 24 * 60 * 60; // Dash: 1 day consensus.nPowTargetSpacing = 2.5 * 60; // Dash: 2.5 minutes @@ -419,6 +421,7 @@ public: consensus.BIP34Height = 2; // BIP34 activated immediately on devnet consensus.BIP65Height = 2; // BIP65 activated immediately on devnet consensus.BIP66Height = 2; // BIP66 activated immediately on devnet + consensus.DIP0001Height = 2; // DIP0001 activated immediately on devnet consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.nPowTargetTimespan = 24 * 60 * 60; // Dash: 1 day consensus.nPowTargetSpacing = 2.5 * 60; // Dash: 2.5 minutes @@ -545,6 +548,7 @@ public: consensus.BIP34Hash = uint256(); consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests) consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests) + consensus.DIP0001Height = 2000; consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.nPowTargetTimespan = 24 * 60 * 60; // Dash: 1 day consensus.nPowTargetSpacing = 2.5 * 60; // Dash: 2.5 minutes diff --git a/src/consensus/params.h b/src/consensus/params.h index f34ef34db..0a0658c44 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -65,6 +65,8 @@ struct Params { int BIP65Height; /** Block height at which BIP66 becomes active */ int BIP66Height; + /** Block height at which DIP0001 becomes active */ + int DIP0001Height; /** * Minimum blocks including miner confirmation of the total of nMinerConfirmationWindow blocks in a retargeting period, * (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments. diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index 75123ecef..a1de38b81 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -38,7 +38,7 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con masternodeSync.UpdatedBlockTip(pindexNew, fInitialDownload, connman); // Update global DIP0001 activation status - fDIP0001ActiveAtTip = (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_ACTIVE); + fDIP0001ActiveAtTip = pindexNew->nHeight >= Params().GetConsensus().DIP0001Height; if (fInitialDownload) return; diff --git a/src/validation.cpp b/src/validation.cpp index 6b7a0053e..cc53355a1 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -89,7 +89,6 @@ bool fAlerts = DEFAULT_ALERTS; int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT; -std::atomic fDIP0001WasLockedIn{false}; std::atomic fDIP0001ActiveAtTip{false}; uint256 hashAssumeValid; @@ -561,7 +560,8 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state, CBlockIndex * const pindexPrev) { - bool fDIP0001Active_context = (VersionBitsState(pindexPrev, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_ACTIVE); + int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1; + bool fDIP0001Active_context = nHeight >= Params().GetConsensus().DIP0001Height; // Size limits if (fDIP0001Active_context && ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_STANDARD_TX_SIZE) @@ -2162,7 +2162,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd std::vector > addressUnspentIndex; std::vector > spentIndex; - bool fDIP0001Active_context = (VersionBitsState(pindex->pprev, chainparams.GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_ACTIVE); + bool fDIP0001Active_context = pindex->nHeight >= Params().GetConsensus().DIP0001Height; for (unsigned int i = 0; i < block.vtx.size(); i++) { @@ -3432,7 +3432,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, const Co ? pindexPrev->GetMedianTimePast() : block.GetBlockTime(); - bool fDIP0001Active_context = (VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_ACTIVE); + bool fDIP0001Active_context = nHeight >= Params().GetConsensus().DIP0001Height; // Size limits unsigned int nMaxBlockSize = MaxBlockSize(fDIP0001Active_context); diff --git a/src/validation.h b/src/validation.h index b016c488e..58ced71b8 100644 --- a/src/validation.h +++ b/src/validation.h @@ -189,7 +189,6 @@ extern bool fLargeWorkInvalidChainFound; extern std::map mapRejectedBlocks; -extern std::atomic fDIP0001WasLockedIn; extern std::atomic fDIP0001ActiveAtTip; /** Block hash whose ancestors we will assume to have valid scripts without checking them. */