diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index 2bd91ca87b..8f2cb81f23 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -116,8 +116,6 @@ void CDSNotificationInterface::BlockDisconnected(const std::shared_ptr= nAbsVoteReq) fCachedValid = false; } - -void CGovernanceObject::CheckOrphanVotes(CConnman& connman) -{ - int64_t nNow = GetAdjustedTime(); - auto mnList = deterministicMNManager->GetListAtChainTip(); - const vote_cmm_t::list_t& listVotes = cmmapOrphanVotes.GetItemList(); - vote_cmm_t::list_cit it = listVotes.begin(); - while (it != listVotes.end()) { - bool fRemove = false; - const COutPoint& key = it->key; - const vote_time_pair_t& pairVote = it->value; - const CGovernanceVote& vote = pairVote.first; - if (pairVote.second < nNow) { - fRemove = true; - } else if (!mnList.HasValidMNByCollateral(vote.GetMasternodeOutpoint())) { - ++it; - continue; - } - CGovernanceException exception; - if (!ProcessVote(nullptr, vote, exception, connman)) { - LogPrintf("CGovernanceObject::CheckOrphanVotes -- Failed to add orphan vote: %s\n", exception.what()); - } else { - vote.Relay(connman); - fRemove = true; - } - ++it; - if (fRemove) { - cmmapOrphanVotes.Erase(key, pairVote); - } - } -} diff --git a/src/governance/governance-object.h b/src/governance/governance-object.h index 21659c275d..99dbe0c4d6 100644 --- a/src/governance/governance-object.h +++ b/src/governance/governance-object.h @@ -180,9 +180,6 @@ private: vote_m_t mapCurrentMNVotes; - /// Limited map of votes orphaned by MN - vote_cmm_t cmmapOrphanVotes; - CGovernanceObjectVoteFile fileVotes; public: @@ -267,7 +264,7 @@ public: bool IsValidLocally(std::string& strError, bool fCheckCollateral) const; - bool IsValidLocally(std::string& strError, bool& fMissingMasternode, bool& fMissingConfirmations, bool fCheckCollateral) const; + bool IsValidLocally(std::string& strError, bool& fMissingConfirmations, bool fCheckCollateral) const; /// Check the collateral transaction for the budget proposal/finalized budget bool IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const; @@ -350,8 +347,6 @@ private: // also for MNs that were removed from the list completely. // Returns deleted vote hashes. std::set RemoveInvalidVotes(const COutPoint& mnOutpoint); - - void CheckOrphanVotes(CConnman& connman); }; diff --git a/src/governance/governance.cpp b/src/governance/governance.cpp index b5cb586c22..7470f379f9 100644 --- a/src/governance/governance.cpp +++ b/src/governance/governance.cpp @@ -33,7 +33,6 @@ CGovernanceManager::CGovernanceManager() : nCachedBlockHeight(0), mapObjects(), mapErasedGovernanceObjects(), - mapMasternodeOrphanObjects(), cmapVoteToObject(MAX_CACHE_SIZE), cmapInvalidVotes(MAX_CACHE_SIZE), cmmapOrphanVotes(MAX_CACHE_SIZE), @@ -161,8 +160,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm LOCK2(cs_main, cs); - if (mapObjects.count(nHash) || mapPostponedObjects.count(nHash) || - mapErasedGovernanceObjects.count(nHash) || mapMasternodeOrphanObjects.count(nHash)) { + if (mapObjects.count(nHash) || mapPostponedObjects.count(nHash) || mapErasedGovernanceObjects.count(nHash)) { // TODO - print error code? what if it's GOVOBJ_ERROR_IMMATURE? LogPrint(BCLog::GOBJECT, "MNGOVERNANCEOBJECT -- Received already seen object: %s\n", strHash); return; @@ -177,11 +175,10 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm std::string strError = ""; // CHECK OBJECT AGAINST LOCAL BLOCKCHAIN - bool fMasternodeMissing = false; bool fMissingConfirmations = false; - bool fIsValid = govobj.IsValidLocally(strError, fMasternodeMissing, fMissingConfirmations, true); + bool fIsValid = govobj.IsValidLocally(strError, fMissingConfirmations, true); - if (fRateCheckBypassed && (fIsValid || fMasternodeMissing)) { + if (fRateCheckBypassed && fIsValid) { if (!MasternodeRateCheck(govobj, true)) { LogPrintf("MNGOVERNANCEOBJECT -- masternode rate check failed (after signature verification) - %s - (current block height %d)\n", strHash, nCachedBlockHeight); return; @@ -189,21 +186,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm } if (!fIsValid) { - if (fMasternodeMissing) { - int& count = mapMasternodeOrphanCounter[govobj.GetMasternodeOutpoint()]; - if (count >= 10) { - LogPrint(BCLog::GOBJECT, "MNGOVERNANCEOBJECT -- Too many orphan objects, missing masternode=%s\n", govobj.GetMasternodeOutpoint().ToStringShort()); - // ask for this object again in 2 minutes - CInv inv(MSG_GOVERNANCE_OBJECT, govobj.GetHash()); - pfrom->AskFor(inv); - return; - } - - count++; - ExpirationInfo info(pfrom->GetId(), GetAdjustedTime() + GOVERNANCE_ORPHAN_EXPIRATION_TIME); - mapMasternodeOrphanObjects.insert(std::make_pair(nHash, object_info_pair_t(govobj, info))); - LogPrintf("MNGOVERNANCEOBJECT -- Missing masternode for: %s, strError = %s\n", strHash, strError); - } else if (fMissingConfirmations) { + if (fMissingConfirmations) { AddPostponedObject(govobj); LogPrintf("MNGOVERNANCEOBJECT -- Not enough fee confirmations for: %s, strError = %s\n", strHash, strError); } else { @@ -863,52 +846,6 @@ bool CGovernanceManager::ProcessVote(CNode* pfrom, const CGovernanceVote& vote, return fOk; } -void CGovernanceManager::CheckMasternodeOrphanVotes(CConnman& connman) -{ - LOCK2(cs_main, cs); - - ScopedLockBool guard(cs, fRateChecksEnabled, false); - - for (auto& objPair : mapObjects) { - objPair.second.CheckOrphanVotes(connman); - } -} - -void CGovernanceManager::CheckMasternodeOrphanObjects(CConnman& connman) -{ - LOCK2(cs_main, cs); - int64_t nNow = GetAdjustedTime(); - ScopedLockBool guard(cs, fRateChecksEnabled, false); - object_info_m_it it = mapMasternodeOrphanObjects.begin(); - while (it != mapMasternodeOrphanObjects.end()) { - object_info_pair_t& pair = it->second; - CGovernanceObject& govobj = pair.first; - - if (pair.second.nExpirationTime >= nNow) { - std::string strError; - bool fMasternodeMissing = false; - bool fConfirmationsMissing = false; - bool fIsValid = govobj.IsValidLocally(strError, fMasternodeMissing, fConfirmationsMissing, true); - - if (fIsValid) { - AddGovernanceObject(govobj, connman); - } else if (fMasternodeMissing) { - ++it; - continue; - } - } else { - // apply node's ban score - Misbehaving(pair.second.idFrom, 20); - } - - auto it_count = mapMasternodeOrphanCounter.find(govobj.GetMasternodeOutpoint()); - if (--it_count->second == 0) - mapMasternodeOrphanCounter.erase(it_count); - - mapMasternodeOrphanObjects.erase(it++); - } -} - void CGovernanceManager::CheckPostponedObjects(CConnman& connman) { if (!masternodeSync.IsSynced()) return; diff --git a/src/governance/governance.h b/src/governance/governance.h index e30a51b5cb..d9031cca93 100644 --- a/src/governance/governance.h +++ b/src/governance/governance.h @@ -241,9 +241,6 @@ private: // value - expiration time for deleted objects hash_time_m_t mapErasedGovernanceObjects; - object_info_m_t mapMasternodeOrphanObjects; - txout_int_m_t mapMasternodeOrphanCounter; - object_m_t mapPostponedObjects; hash_s_t setAdditionalRelayObjects; @@ -402,10 +399,6 @@ public: return fOK; } - void CheckMasternodeOrphanVotes(CConnman& connman); - - void CheckMasternodeOrphanObjects(CConnman& connman); - void CheckPostponedObjects(CConnman& connman); bool AreRateChecksEnabled() const diff --git a/src/rpc/governance.cpp b/src/rpc/governance.cpp index f9c23b60d9..16ea771ae2 100644 --- a/src/rpc/governance.cpp +++ b/src/rpc/governance.cpp @@ -308,11 +308,10 @@ UniValue gobject_submit(const JSONRPCRequest& request) std::string strHash = govobj.GetHash().ToString(); std::string strError = ""; - bool fMissingMasternode; bool fMissingConfirmations; { LOCK(cs_main); - if (!govobj.IsValidLocally(strError, fMissingMasternode, fMissingConfirmations, true) && !fMissingConfirmations) { + if (!govobj.IsValidLocally(strError, fMissingConfirmations, true) && !fMissingConfirmations) { LogPrintf("gobject(submit) -- Object submission rejected because object is not valid - hash = %s, strError = %s\n", strHash, strError); throw JSONRPCError(RPC_INTERNAL_ERROR, "Governance object is not valid - " + strHash + " - " + strError); }