From 07c659384425ce5f7534ca003fdf4f2e2f7a74ee Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 26 Sep 2023 17:35:41 +0300 Subject: [PATCH] fix: Do not relay/store/count votes from pose-banned MNs --- src/governance/governance.cpp | 4 +++- src/governance/object.cpp | 7 +++++++ src/governance/vote.cpp | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/governance/governance.cpp b/src/governance/governance.cpp index ddf5515ed7c45..0dc6252c720b2 100644 --- a/src/governance/governance.cpp +++ b/src/governance/governance.cpp @@ -27,7 +27,7 @@ std::unique_ptr governance; int nSubmittedFinalBudget; -const std::string GovernanceStore::SERIALIZATION_VERSION_STRING = "CGovernanceManager-Version-16"; +const std::string GovernanceStore::SERIALIZATION_VERSION_STRING = "CGovernanceManager-Version-17"; const int CGovernanceManager::MAX_TIME_FUTURE_DEVIATION = 60 * 60; const int CGovernanceManager::RELIABLE_PROPAGATION_TIME = 60; @@ -1501,6 +1501,8 @@ void CGovernanceManager::RemoveInvalidVotes() changedKeyMNs.emplace_back(oldDmn->collateralOutpoint); } else if ((p.second.fields & CDeterministicMNStateDiff::Field_pubKeyOperator) && p.second.state.pubKeyOperator != oldDmn->pdmnState->pubKeyOperator) { changedKeyMNs.emplace_back(oldDmn->collateralOutpoint); + } else if ((p.second.fields & CDeterministicMNStateDiff::Field_nPoSeBanHeight) && p.second.state.IsBanned()) { + changedKeyMNs.emplace_back(oldDmn->collateralOutpoint); } } for (const auto& id : diff.removedMns) { diff --git a/src/governance/object.cpp b/src/governance/object.cpp index 01dfb8b00cbcf..ac82a97506990 100644 --- a/src/governance/object.cpp +++ b/src/governance/object.cpp @@ -123,6 +123,13 @@ bool CGovernanceObject::ProcessVote(const CGovernanceVote& vote, CGovernanceExce return false; } + if (dmn->pdmnState->IsBanned()) { + std::ostringstream ostr; + ostr << "CGovernanceObject::ProcessVote -- Masternode " << vote.GetMasternodeOutpoint().ToStringShort() << " is banned"; + exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_WARNING); + return false; + } + auto it = mapCurrentMNVotes.emplace(vote_m_t::value_type(vote.GetMasternodeOutpoint(), vote_rec_t())).first; vote_rec_t& voteRecordRef = it->second; vote_signal_enum_t eSignal = vote.GetSignal(); diff --git a/src/governance/vote.cpp b/src/governance/vote.cpp index c5b3a3e1c0244..39ca68a7df584 100644 --- a/src/governance/vote.cpp +++ b/src/governance/vote.cpp @@ -274,6 +274,11 @@ bool CGovernanceVote::IsValid(bool useVotingKey) const return false; } + if (dmn->pdmnState->IsBanned()) { + LogPrint(BCLog::GOBJECT, "CGovernanceVote::IsValid -- Invalid Masternode - %s\n", masternodeOutpoint.ToStringShort()); + return false; + } + if (useVotingKey) { return CheckSignature(dmn->pdmnState->keyIDVoting); } else {