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

Only require valid collaterals for votes and triggers #2947

Merged
merged 3 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 0 additions & 8 deletions src/governance/governance-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,6 @@ bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingMast
strError = "Failed to find Masternode by UTXO, missing masternode=" + strOutpoint;
return false;
}
if (!mnList.IsMNValid(dmn)) {
if (mnList.IsMNPoSeBanned(dmn)) {
strError = "Masternode is POSE_BANNED, masternode=" + strOutpoint;
} else {
strError = "Masternode is invalid for unknown reason, masternode=" + strOutpoint;
}
return false;
}

// Check that we have a valid MN signature
if (!CheckSignature(dmn->pdmnState->pubKeyOperator)) {
Expand Down
1 change: 1 addition & 0 deletions src/governance/governance-object.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class CGovernanceVote;

static const int MIN_GOVERNANCE_PEER_PROTO_VERSION = 70213;
static const int GOVERNANCE_FILTER_PROTO_VERSION = 70206;
static const int GOVERNANCE_POSE_BANNED_VOTES_VERSION = 70215;

static const double GOVERNANCE_FILTER_FP_RATE = 0.001;

Expand Down
17 changes: 15 additions & 2 deletions src/governance/governance-vote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,21 @@ void CGovernanceVote::Relay(CConnman& connman) const
return;
}

auto mnList = deterministicMNManager->GetListAtChainTip();
auto dmn = mnList.GetMNByCollateral(masternodeOutpoint);
if (!dmn) {
return;
}

// When this vote is from non-valid (PoSe banned) MN, we should only announce it to v0.14.0.1 nodes as older nodes
// will ban us otherwise.
int minVersion = MIN_GOVERNANCE_PEER_PROTO_VERSION;
if (!mnList.IsMNValid(dmn)) {
minVersion = GOVERNANCE_POSE_BANNED_VOTES_VERSION;
}

CInv inv(MSG_GOVERNANCE_OBJECT_VOTE, GetHash());
connman.RelayInv(inv, MIN_GOVERNANCE_PEER_PROTO_VERSION);
connman.RelayInv(inv, minVersion);
}

void CGovernanceVote::UpdateHash() const
Expand Down Expand Up @@ -258,7 +271,7 @@ bool CGovernanceVote::IsValid(bool useVotingKey) const
return false;
}

auto dmn = deterministicMNManager->GetListAtChainTip().GetValidMNByCollateral(masternodeOutpoint);
auto dmn = deterministicMNManager->GetListAtChainTip().GetMNByCollateral(masternodeOutpoint);
if (!dmn) {
LogPrint(BCLog::GOBJECT, "CGovernanceVote::IsValid -- Unknown Masternode - %s\n", masternodeOutpoint.ToStringShort());
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/


static const int PROTOCOL_VERSION = 70214;
static const int PROTOCOL_VERSION = 70215;

//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
Expand Down