Reject Dash-specific messages from obsolete peers (#1983)

And send REJECT msg back to the peer we received the original message from.
Same logic as for MIN_PEER_PROTO_VERSION but using specific proto versions for each submodule.
This commit is contained in:
UdjinM6 2018-03-15 12:21:43 +03:00 committed by GitHub
parent e9f63073dc
commit 08033ffe4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 12 deletions

View File

@ -2,6 +2,7 @@
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "consensus/validation.h"
#include "governance.h" #include "governance.h"
#include "governance-object.h" #include "governance-object.h"
#include "governance-vote.h" #include "governance-vote.h"
@ -100,12 +101,17 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
if(fLiteMode) return; if(fLiteMode) return;
if(!masternodeSync.IsBlockchainSynced()) return; if(!masternodeSync.IsBlockchainSynced()) return;
if(pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) return;
// ANOTHER USER IS ASKING US TO HELP THEM SYNC GOVERNANCE OBJECT DATA // ANOTHER USER IS ASKING US TO HELP THEM SYNC GOVERNANCE OBJECT DATA
if (strCommand == NetMsgType::MNGOVERNANCESYNC) if (strCommand == NetMsgType::MNGOVERNANCESYNC)
{ {
if(pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
LogPrint("gobject", "MNGOVERNANCESYNC -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_GOVERNANCE_PEER_PROTO_VERSION)));
return;
}
// Ignore such requests until we are fully synced. // Ignore such requests until we are fully synced.
// We could start processing this after masternode list is synced // We could start processing this after masternode list is synced
// but this is a heavy one so it's better to finish sync first. // but this is a heavy one so it's better to finish sync first.
@ -144,6 +150,13 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
pfrom->setAskFor.erase(nHash); pfrom->setAskFor.erase(nHash);
if(pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
LogPrint("gobject", "MNGOVERNANCEOBJECT -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_GOVERNANCE_PEER_PROTO_VERSION)));
return;
}
if(!masternodeSync.IsMasternodeListSynced()) { if(!masternodeSync.IsMasternodeListSynced()) {
LogPrint("gobject", "MNGOVERNANCEOBJECT -- masternode list not synced\n"); LogPrint("gobject", "MNGOVERNANCEOBJECT -- masternode list not synced\n");
return; return;
@ -228,6 +241,12 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
pfrom->setAskFor.erase(nHash); pfrom->setAskFor.erase(nHash);
if(pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
LogPrint("gobject", "MNGOVERNANCEOBJECTVOTE -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_GOVERNANCE_PEER_PROTO_VERSION)));
}
// Ignore such messages until masternode list is synced // Ignore such messages until masternode list is synced
if(!masternodeSync.IsMasternodeListSynced()) { if(!masternodeSync.IsMasternodeListSynced()) {
LogPrint("gobject", "MNGOVERNANCEOBJECTVOTE -- masternode list not synced\n"); LogPrint("gobject", "MNGOVERNANCEOBJECTVOTE -- masternode list not synced\n");

View File

@ -10,6 +10,7 @@
#include "masternodeman.h" #include "masternodeman.h"
#include "messagesigner.h" #include "messagesigner.h"
#include "net.h" #include "net.h"
#include "netmessagemaker.h"
#include "protocol.h" #include "protocol.h"
#include "spork.h" #include "spork.h"
#include "sync.h" #include "sync.h"
@ -56,7 +57,12 @@ void CInstantSend::ProcessMessage(CNode* pfrom, const std::string& strCommand, C
if (strCommand == NetMsgType::TXLOCKVOTE) // InstantSend Transaction Lock Consensus Votes if (strCommand == NetMsgType::TXLOCKVOTE) // InstantSend Transaction Lock Consensus Votes
{ {
if(pfrom->nVersion < MIN_INSTANTSEND_PROTO_VERSION) return; if(pfrom->nVersion < MIN_INSTANTSEND_PROTO_VERSION) {
LogPrint("instantsend", "TXLOCKVOTE -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_INSTANTSEND_PROTO_VERSION)));
return;
}
CTxLockVote vote; CTxLockVote vote;
vRecv >> vote; vRecv >> vote;

View File

@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "activemasternode.h" #include "activemasternode.h"
#include "consensus/validation.h"
#include "governance-classes.h" #include "governance-classes.h"
#include "masternode-payments.h" #include "masternode-payments.h"
#include "masternode-sync.h" #include "masternode-sync.h"
@ -294,6 +295,13 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, const std::string& strCom
if (strCommand == NetMsgType::MASTERNODEPAYMENTSYNC) { //Masternode Payments Request Sync if (strCommand == NetMsgType::MASTERNODEPAYMENTSYNC) { //Masternode Payments Request Sync
if(pfrom->nVersion < GetMinMasternodePaymentsProto()) {
LogPrint("mnpayments", "MASTERNODEPAYMENTSYNC -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", GetMinMasternodePaymentsProto())));
return;
}
// Ignore such requests until we are fully synced. // Ignore such requests until we are fully synced.
// We could start processing this after masternode list is synced // We could start processing this after masternode list is synced
// but this is a heavy one so it's better to finish sync first. // but this is a heavy one so it's better to finish sync first.
@ -321,7 +329,12 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, const std::string& strCom
CMasternodePaymentVote vote; CMasternodePaymentVote vote;
vRecv >> vote; vRecv >> vote;
if(pfrom->nVersion < GetMinMasternodePaymentsProto()) return; if(pfrom->nVersion < GetMinMasternodePaymentsProto()) {
LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", GetMinMasternodePaymentsProto())));
return;
}
uint256 nHash = vote.GetHash(); uint256 nHash = vote.GetHash();

View File

@ -31,7 +31,9 @@ void CPrivateSendClient::ProcessMessage(CNode* pfrom, const std::string& strComm
if(!lockRecv) return; if(!lockRecv) return;
if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) { if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
LogPrint("privatesend", "DSQUEUE -- incompatible version! nVersion: %d\n", pfrom->nVersion); LogPrint("privatesend", "DSQUEUE -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
return; return;
} }
@ -101,7 +103,9 @@ void CPrivateSendClient::ProcessMessage(CNode* pfrom, const std::string& strComm
} else if(strCommand == NetMsgType::DSSTATUSUPDATE) { } else if(strCommand == NetMsgType::DSSTATUSUPDATE) {
if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) { if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
LogPrintf("DSSTATUSUPDATE -- incompatible version! nVersion: %d\n", pfrom->nVersion); LogPrint("privatesend", "DSSTATUSUPDATE -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
return; return;
} }
@ -143,7 +147,9 @@ void CPrivateSendClient::ProcessMessage(CNode* pfrom, const std::string& strComm
} else if(strCommand == NetMsgType::DSFINALTX) { } else if(strCommand == NetMsgType::DSFINALTX) {
if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) { if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
LogPrintf("DSFINALTX -- incompatible version! nVersion: %d\n", pfrom->nVersion); LogPrint("privatesend", "DSFINALTX -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
return; return;
} }
@ -170,7 +176,9 @@ void CPrivateSendClient::ProcessMessage(CNode* pfrom, const std::string& strComm
} else if(strCommand == NetMsgType::DSCOMPLETE) { } else if(strCommand == NetMsgType::DSCOMPLETE) {
if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) { if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
LogPrintf("DSCOMPLETE -- incompatible version! nVersion: %d\n", pfrom->nVersion); LogPrint("privatesend", "DSCOMPLETE -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
return; return;
} }

View File

@ -26,7 +26,9 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
if(strCommand == NetMsgType::DSACCEPT) { if(strCommand == NetMsgType::DSACCEPT) {
if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) { if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
LogPrintf("DSACCEPT -- incompatible version! nVersion: %d\n", pfrom->nVersion); LogPrint("privatesend", "DSACCEPT -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
PushStatus(pfrom, STATUS_REJECTED, ERR_VERSION, connman); PushStatus(pfrom, STATUS_REJECTED, ERR_VERSION, connman);
return; return;
} }
@ -76,7 +78,9 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
if(!lockRecv) return; if(!lockRecv) return;
if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) { if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
LogPrint("privatesend", "DSQUEUE -- incompatible version! nVersion: %d\n", pfrom->nVersion); LogPrint("privatesend", "DSQUEUE -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
return; return;
} }
@ -130,7 +134,9 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
} else if(strCommand == NetMsgType::DSVIN) { } else if(strCommand == NetMsgType::DSVIN) {
if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) { if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
LogPrintf("DSVIN -- incompatible version! nVersion: %d\n", pfrom->nVersion); LogPrint("privatesend", "DSVIN -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
PushStatus(pfrom, STATUS_REJECTED, ERR_VERSION, connman); PushStatus(pfrom, STATUS_REJECTED, ERR_VERSION, connman);
return; return;
} }
@ -228,7 +234,9 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
} else if(strCommand == NetMsgType::DSSIGNFINALTX) { } else if(strCommand == NetMsgType::DSSIGNFINALTX) {
if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) { if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
LogPrintf("DSSIGNFINALTX -- incompatible version! nVersion: %d\n", pfrom->nVersion); LogPrint("privatesend", "DSSIGNFINALTX -- peer=%d using obsolete version %i\n", pfrom->id, pfrom->nVersion);
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
return; return;
} }