fix: The idea behind fDIP0001LockedInAtTip was to indicate that it WAS locked in, not that it IS locked in (#1666)

This commit is contained in:
UdjinM6 2017-10-04 22:35:09 +03:00 committed by GitHub
parent c3bc06bbf8
commit d286198728
5 changed files with 6 additions and 6 deletions

View File

@ -38,8 +38,8 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
bool fDIP0001ActiveAtTipTmp = fDIP0001ActiveAtTip; bool fDIP0001ActiveAtTipTmp = fDIP0001ActiveAtTip;
// Update global flags // 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); 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 // Update min fees only if activation changed and we are using default fees
if (fDIP0001ActiveAtTipTmp != fDIP0001ActiveAtTip) { if (fDIP0001ActiveAtTipTmp != fDIP0001ActiveAtTip) {

View File

@ -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); strError = strprintf("Masternode is not in the top %d (%d)", MNPAYMENTS_SIGNATURES_TOTAL*2, nRank);
LogPrintf("CMasternodePaymentVote::IsValid -- Error: %s\n", strError); LogPrintf("CMasternodePaymentVote::IsValid -- Error: %s\n", strError);
// do not ban nodes before DIP0001 is locked in to avoid banning majority of (old) masternodes // do not ban nodes before DIP0001 is locked in to avoid banning majority of (old) masternodes
if (fDIP0001LockedInAtTip) { if (fDIP0001WasLockedIn) {
Misbehaving(pnode->GetId(), 20); Misbehaving(pnode->GetId(), 20);
} }
} }
@ -783,7 +783,7 @@ void CMasternodePaymentVote::Relay(CConnman& connman)
if (!masternodeSync.IsWinnersListSynced()) return; if (!masternodeSync.IsWinnersListSynced()) return;
CInv inv(MSG_MASTERNODE_PAYMENT_VOTE, GetHash()); 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 // 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) bool CMasternodePaymentVote::CheckSignature(const CPubKey& pubKeyMasternode, int nValidationHeight, int &nDos)

View File

@ -90,7 +90,7 @@ bool CMasternode::UpdateFromNewBroadcast(CMasternodeBroadcast& mnb, CConnman& co
// //
arith_uint256 CMasternode::CalculateScore(const uint256& blockHash) arith_uint256 CMasternode::CalculateScore(const uint256& blockHash)
{ {
if (fDIP0001LockedInAtTip) { if (fDIP0001WasLockedIn) {
// Deterministically calculate a "score" for a Masternode based on any given (block)hash // Deterministically calculate a "score" for a Masternode based on any given (block)hash
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
ss << vin.prevout << nCollateralMinConfBlockHash << blockHash; ss << vin.prevout << nCollateralMinConfBlockHash << blockHash;

View File

@ -85,7 +85,7 @@ uint64_t nPruneTarget = 0;
bool fAlerts = DEFAULT_ALERTS; bool fAlerts = DEFAULT_ALERTS;
bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT; bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT;
std::atomic<bool> fDIP0001LockedInAtTip{false}; std::atomic<bool> fDIP0001WasLockedIn{false};
std::atomic<bool> fDIP0001ActiveAtTip{false}; std::atomic<bool> fDIP0001ActiveAtTip{false};
uint256 hashAssumeValid; uint256 hashAssumeValid;

View File

@ -165,7 +165,7 @@ extern bool fEnableReplacement;
extern std::map<uint256, int64_t> mapRejectedBlocks; extern std::map<uint256, int64_t> mapRejectedBlocks;
static const int DIP0001_PROTOCOL_VERSION = 70208; static const int DIP0001_PROTOCOL_VERSION = 70208;
extern std::atomic<bool> fDIP0001LockedInAtTip; extern std::atomic<bool> fDIP0001WasLockedIn;
extern std::atomic<bool> fDIP0001ActiveAtTip; extern std::atomic<bool> fDIP0001ActiveAtTip;
/** Block hash whose ancestors we will assume to have valid scripts without checking them. */ /** Block hash whose ancestors we will assume to have valid scripts without checking them. */