Skip to content

Commit

Permalink
fix: Do not relay/store/count votes from pose-banned MNs
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Sep 26, 2023
1 parent 7bff85e commit 07c6593
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/governance/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ std::unique_ptr<CGovernanceManager> 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;

Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions src/governance/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions src/governance/vote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 07c6593

Please sign in to comment.