Skip to content

Commit

Permalink
Only require valid collaterals for votes and triggers (#2947) (#2957)
Browse files Browse the repository at this point in the history
* Only require valid collaterals for votes and triggers

* Bump proto version

* Only announce votes from banned MNs to >= 70215 proto version nodes
  • Loading branch information
codablock authored and UdjinM6 committed May 30, 2019
1 parent b293e6d commit a2baa93
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
8 changes: 0 additions & 8 deletions src/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-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-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("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

0 comments on commit a2baa93

Please sign in to comment.