From b74cd3e1019877a8436bbf67c20d62727ff341db Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Wed, 29 May 2019 10:56:51 +0200 Subject: [PATCH] Only require valid collaterals for votes and triggers (#2947) * Only require valid collaterals for votes and triggers * Bump proto version * Only announce votes from banned MNs to >= 70215 proto version nodes --- src/governance/governance-object.cpp | 8 -------- src/governance/governance-object.h | 1 + src/governance/governance-vote.cpp | 17 +++++++++++++++-- src/version.h | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/governance/governance-object.cpp b/src/governance/governance-object.cpp index 69b95352e..bd137c6ca 100644 --- a/src/governance/governance-object.cpp +++ b/src/governance/governance-object.cpp @@ -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)) { diff --git a/src/governance/governance-object.h b/src/governance/governance-object.h index 30d7a66ae..21659c275 100644 --- a/src/governance/governance-object.h +++ b/src/governance/governance-object.h @@ -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; diff --git a/src/governance/governance-vote.cpp b/src/governance/governance-vote.cpp index 53816bc8a..5836e78a9 100644 --- a/src/governance/governance-vote.cpp +++ b/src/governance/governance-vote.cpp @@ -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 @@ -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; diff --git a/src/version.h b/src/version.h index 680c2a070..148cfd2e3 100644 --- a/src/version.h +++ b/src/version.h @@ -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;