Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Count all MNs when calculating voting threshold #5584

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/evo/deterministicmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ class CDeterministicMNList
});
}

[[nodiscard]] size_t GetWeightedMNsCount() const
{
return std::accumulate(mnMap.begin(), mnMap.end(), 0, [this](auto res, const auto& p) {
return res + GetMnType(p.second->nType).voting_weight;
});
}

/**
* Execute a callback on all masternodes in the mnList. This will pass a reference
* of each masternode to the callback function. This should be preferred over ForEachMNShared.
Expand Down
2 changes: 1 addition & 1 deletion src/governance/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ std::optional<CSuperblock> CGovernanceManager::CreateSuperblockCandidate(int nHe
// A proposal is considered passing if (YES votes) >= (Total Weight of Masternodes / 10),
// count total valid (ENABLED) masternodes to determine passing threshold.
UdjinM6 marked this conversation as resolved.
Show resolved Hide resolved
const auto mnList = deterministicMNManager->GetListAtChainTip();
const int nWeightedMnCount = mnList.GetValidWeightedMNsCount();
const int nWeightedMnCount = mnList.GetWeightedMNsCount();
const int nAbsVoteReq = std::max(Params().GetConsensus().nGovernanceMinQuorum, nWeightedMnCount / 10);

// Use std::vector of std::shared_ptr<const CGovernanceObject> because CGovernanceObject doesn't support move operations (needed for sorting the vector later)
Expand Down
2 changes: 1 addition & 1 deletion src/qt/governancelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void GovernanceList::updateProposalList()
// A proposal is considered passing if (YES votes - NO votes) >= (Total Weight of Masternodes / 10),
// count total valid (ENABLED) masternodes to determine passing threshold.
UdjinM6 marked this conversation as resolved.
Show resolved Hide resolved
// Need to query number of masternodes here with access to clientModel.
const int nWeightedMnCount = clientModel->getMasternodeList().GetValidWeightedMNsCount();
const int nWeightedMnCount = clientModel->getMasternodeList().GetWeightedMNsCount();
const int nAbsVoteReq = std::max(Params().GetConsensus().nGovernanceMinQuorum, nWeightedMnCount / 10);
proposalModel->setVotingParams(nAbsVoteReq);

Expand Down
2 changes: 1 addition & 1 deletion src/rpc/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ static UniValue getgovernanceinfo(const JSONRPCRequest& request)
obj.pushKV("superblockmaturitywindow", Params().GetConsensus().nSuperblockMaturityWindow);
obj.pushKV("lastsuperblock", nLastSuperblock);
obj.pushKV("nextsuperblock", nNextSuperblock);
obj.pushKV("fundingthreshold", int(deterministicMNManager->GetListAtChainTip().GetValidWeightedMNsCount() / 10));
obj.pushKV("fundingthreshold", int(deterministicMNManager->GetListAtChainTip().GetWeightedMNsCount() / 10));

return obj;
}
Expand Down