diff --git a/src/governance/governance.cpp b/src/governance/governance.cpp index c6a43e1f6aa2..d1f9f6100535 100644 --- a/src/governance/governance.cpp +++ b/src/governance/governance.cpp @@ -63,7 +63,6 @@ GovernanceStore::GovernanceStore() : cs_store(), mapObjects(), mapErasedGovernanceObjects(), - cmapInvalidVotes(MAX_CACHE_SIZE), cmmapOrphanVotes(MAX_CACHE_SIZE), mapLastMasternodeObject(), lastMNListForVotingKeys(std::make_shared()) @@ -816,14 +815,6 @@ bool CGovernanceManager::ProcessVote(const CGovernanceVote& vote, CGovernanceExc return false; } - if (cmapInvalidVotes.HasKey(nHashVote)) { - std::string msg{strprintf("CGovernanceManager::%s -- Old invalid vote, MN outpoint = %s, governance object hash = %s", - __func__, vote.GetMasternodeOutpoint().ToStringShort(), nHashGovobj.ToString())}; - LogPrint(BCLog::GOBJECT, "%s\n", msg); - exception = CGovernanceException(msg, GOVERNANCE_EXCEPTION_PERMANENT_ERROR, 20); - return false; - } - auto it = mapObjects.find(nHashGovobj); if (it == mapObjects.end()) { if (!vote.IsValidForUnknownParent(tip_mn_list)) { @@ -856,8 +847,6 @@ bool CGovernanceManager::ProcessVote(const CGovernanceVote& vote, CGovernanceExc bool fOk = govobj.ProcessVote(m_mn_metaman, fRateChecksEnabled, tip_mn_list, vote, exception); if (fOk) { fOk = cmapVoteToObject.Insert(nHashVote, it->second); - } else if (exception.GetType() == GOVERNANCE_EXCEPTION_PERMANENT_ERROR && exception.GetNodePenalty() == 20) { - cmapInvalidVotes.Insert(nHashVote, vote); } return fOk; } @@ -1022,7 +1011,6 @@ void GovernanceStore::Clear() LOCK(cs_store); mapObjects.clear(); mapErasedGovernanceObjects.clear(); - cmapInvalidVotes.Clear(); cmmapOrphanVotes.Clear(); mapLastMasternodeObject.clear(); lastMNListForVotingKeys = std::make_shared(); @@ -1169,7 +1157,6 @@ void CGovernanceManager::RemoveInvalidVotes() } for (const auto& voteHash : removed) { cmapVoteToObject.Erase(voteHash); - cmapInvalidVotes.Erase(voteHash); cmmapOrphanVotes.Erase(voteHash); } } diff --git a/src/governance/governance.h b/src/governance/governance.h index 3c1d3e384d87..6b2eebc62ffb 100644 --- a/src/governance/governance.h +++ b/src/governance/governance.h @@ -190,7 +190,6 @@ class GovernanceStore // key - governance object's hash // value - expiration time for deleted objects std::map mapErasedGovernanceObjects GUARDED_BY(cs_store); - CacheMap cmapInvalidVotes GUARDED_BY(cs_store); vote_cmm_t cmmapOrphanVotes GUARDED_BY(cs_store); txout_m_t mapLastMasternodeObject GUARDED_BY(cs_store); // used to check for changed voting keys @@ -204,9 +203,11 @@ class GovernanceStore void Serialize(Stream &s) const EXCLUSIVE_LOCKS_REQUIRED(!cs_store) { LOCK(cs_store); + // TODO: Remove the historical invalid-vote-cache field on the next disk-format version bump. + const CacheMap empty_invalid_votes{MAX_CACHE_SIZE}; s << SERIALIZATION_VERSION_STRING << mapErasedGovernanceObjects - << cmapInvalidVotes + << empty_invalid_votes << cmmapOrphanVotes << mapObjects << mapLastMasternodeObject @@ -225,8 +226,10 @@ class GovernanceStore return; } + // TODO: Stop consuming the historical invalid-vote-cache field on the next disk-format version bump. + CacheMap discarded_invalid_votes; s >> mapErasedGovernanceObjects - >> cmapInvalidVotes + >> discarded_invalid_votes >> cmmapOrphanVotes >> mapObjects >> mapLastMasternodeObject diff --git a/src/test/governance_vote_processing_tests.cpp b/src/test/governance_vote_processing_tests.cpp index 77e2705e8ae7..a5aa2124e3a3 100644 --- a/src/test/governance_vote_processing_tests.cpp +++ b/src/test/governance_vote_processing_tests.cpp @@ -18,6 +18,7 @@ #include #include #include