From d286198728f309cfc61e8d32ec4ce34977857280 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 4 Oct 2017 22:35:09 +0300 Subject: [PATCH] fix: The idea behind fDIP0001LockedInAtTip was to indicate that it WAS locked in, not that it IS locked in (#1666) --- src/dsnotificationinterface.cpp | 2 +- src/masternode-payments.cpp | 4 ++-- src/masternode.cpp | 2 +- src/validation.cpp | 2 +- src/validation.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index ee1bd29df..37378de31 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -38,8 +38,8 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con bool fDIP0001ActiveAtTipTmp = fDIP0001ActiveAtTip; // Update global flags - fDIP0001LockedInAtTip = (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_LOCKED_IN); fDIP0001ActiveAtTip = (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_ACTIVE); + fDIP0001WasLockedIn = fDIP0001ActiveAtTip || (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_LOCKED_IN); // Update min fees only if activation changed and we are using default fees if (fDIP0001ActiveAtTipTmp != fDIP0001ActiveAtTip) { diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index cce6b0877..a9e89158f 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -701,7 +701,7 @@ bool CMasternodePaymentVote::IsValid(CNode* pnode, int nValidationHeight, std::s strError = strprintf("Masternode is not in the top %d (%d)", MNPAYMENTS_SIGNATURES_TOTAL*2, nRank); LogPrintf("CMasternodePaymentVote::IsValid -- Error: %s\n", strError); // do not ban nodes before DIP0001 is locked in to avoid banning majority of (old) masternodes - if (fDIP0001LockedInAtTip) { + if (fDIP0001WasLockedIn) { Misbehaving(pnode->GetId(), 20); } } @@ -783,7 +783,7 @@ void CMasternodePaymentVote::Relay(CConnman& connman) if (!masternodeSync.IsWinnersListSynced()) return; CInv inv(MSG_MASTERNODE_PAYMENT_VOTE, GetHash()); // relay votes only strictly to new nodes until DIP0001 is locked in to avoid being banned by majority of (old) masternodes - connman.RelayInv(inv, fDIP0001LockedInAtTip ? mnpayments.GetMinMasternodePaymentsProto() : MIN_MASTERNODE_PAYMENT_PROTO_VERSION_2); + connman.RelayInv(inv, fDIP0001WasLockedIn ? mnpayments.GetMinMasternodePaymentsProto() : MIN_MASTERNODE_PAYMENT_PROTO_VERSION_2); } bool CMasternodePaymentVote::CheckSignature(const CPubKey& pubKeyMasternode, int nValidationHeight, int &nDos) diff --git a/src/masternode.cpp b/src/masternode.cpp index 00fbda5c4..089ed8fc2 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -90,7 +90,7 @@ bool CMasternode::UpdateFromNewBroadcast(CMasternodeBroadcast& mnb, CConnman& co // arith_uint256 CMasternode::CalculateScore(const uint256& blockHash) { - if (fDIP0001LockedInAtTip) { + if (fDIP0001WasLockedIn) { // Deterministically calculate a "score" for a Masternode based on any given (block)hash CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); ss << vin.prevout << nCollateralMinConfBlockHash << blockHash; diff --git a/src/validation.cpp b/src/validation.cpp index 6995b1a29..c2ec90860 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -85,7 +85,7 @@ uint64_t nPruneTarget = 0; bool fAlerts = DEFAULT_ALERTS; bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT; -std::atomic fDIP0001LockedInAtTip{false}; +std::atomic fDIP0001WasLockedIn{false}; std::atomic fDIP0001ActiveAtTip{false}; uint256 hashAssumeValid; diff --git a/src/validation.h b/src/validation.h index c95e28d3a..42250903a 100644 --- a/src/validation.h +++ b/src/validation.h @@ -165,7 +165,7 @@ extern bool fEnableReplacement; extern std::map mapRejectedBlocks; static const int DIP0001_PROTOCOL_VERSION = 70208; -extern std::atomic fDIP0001LockedInAtTip; +extern std::atomic fDIP0001WasLockedIn; extern std::atomic fDIP0001ActiveAtTip; /** Block hash whose ancestors we will assume to have valid scripts without checking them. */