chore: bump MIN_PEER_PROTO_VERSION to 70215 (#4764)

* chore: bump MIN_PEER_PROTO_VERSION to 70215

simplifies logic, removes branches

This protocol version is from v14 in May of 2019, should be more than safe to bump this

* drop MIN_COINJOIN_PEER_PROTO_VERSION

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
PastaPastaPasta 2022-04-12 12:03:12 -06:00 committed by GitHub
parent 0ea2d5aaf5
commit 6b9f7c3a6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 12 additions and 165 deletions

View File

@ -43,16 +43,6 @@ void CCoinJoinClientQueueManager::ProcessMessage(CNode* pfrom, const std::string
}
if (strCommand == NetMsgType::DSQUEUE) {
if (pfrom->nVersion < MIN_COINJOIN_PEER_PROTO_VERSION) {
LogPrint(BCLog::COINJOIN, "DSQUEUE -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
REJECT_OBSOLETE, strprintf(
"Version must be %d or greater", MIN_COINJOIN_PEER_PROTO_VERSION)));
}
return;
}
CCoinJoinQueue dsq;
vRecv >> dsq;
@ -148,16 +138,6 @@ void CCoinJoinClientSession::ProcessMessage(CNode* pfrom, const std::string& str
if (!masternodeSync.IsBlockchainSynced()) return;
if (strCommand == NetMsgType::DSSTATUSUPDATE) {
if (pfrom->nVersion < MIN_COINJOIN_PEER_PROTO_VERSION) {
LogPrint(BCLog::COINJOIN, "DSSTATUSUPDATE -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
REJECT_OBSOLETE, strprintf(
"Version must be %d or greater", MIN_COINJOIN_PEER_PROTO_VERSION)));
}
return;
}
if (!mixingMasternode) return;
if (mixingMasternode->pdmnState->addr != pfrom->addr) {
return;
@ -169,16 +149,6 @@ void CCoinJoinClientSession::ProcessMessage(CNode* pfrom, const std::string& str
ProcessPoolStateUpdate(psssup);
} else if (strCommand == NetMsgType::DSFINALTX) {
if (pfrom->nVersion < MIN_COINJOIN_PEER_PROTO_VERSION) {
LogPrint(BCLog::COINJOIN, "DSFINALTX -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
REJECT_OBSOLETE, strprintf(
"Version must be %d or greater", MIN_COINJOIN_PEER_PROTO_VERSION)));
}
return;
}
if (!mixingMasternode) return;
if (mixingMasternode->pdmnState->addr != pfrom->addr) {
return;
@ -199,16 +169,6 @@ void CCoinJoinClientSession::ProcessMessage(CNode* pfrom, const std::string& str
SignFinalTransaction(txNew, pfrom, connman);
} else if (strCommand == NetMsgType::DSCOMPLETE) {
if (pfrom->nVersion < MIN_COINJOIN_PEER_PROTO_VERSION) {
LogPrint(BCLog::COINJOIN, "DSCOMPLETE -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
REJECT_OBSOLETE, strprintf(
"Version must be %d or greater", MIN_COINJOIN_PEER_PROTO_VERSION)));
}
return;
}
if (!mixingMasternode) return;
if (mixingMasternode->pdmnState->addr != pfrom->addr) {
LogPrint(BCLog::COINJOIN, "DSCOMPLETE -- message doesn't match current Masternode: infoMixingMasternode=%s addr=%s\n", mixingMasternode->pdmnState->addr.ToString(), pfrom->addr.ToString());
@ -1086,7 +1046,6 @@ bool CCoinJoinClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymized,
mixingMasternode = dmn;
pendingDsaRequest = CPendingDsaRequest(dmn->pdmnState->addr, CCoinJoinAccept(nSessionDenom, txMyCollateral));
connman.AddPendingMasternode(dmn->proTxHash);
// TODO: add new state POOL_STATE_CONNECTING and bump MIN_COINJOIN_PEER_PROTO_VERSION
SetState(POOL_STATE_QUEUE);
nTimeLastSuccessfulStep = GetTime();
LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::JoinExistingQueue -- pending connection (from queue): nSessionDenom: %d (%s), addr=%s\n",
@ -1166,7 +1125,6 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon
mixingMasternode = dmn;
connman.AddPendingMasternode(dmn->proTxHash);
pendingDsaRequest = CPendingDsaRequest(dmn->pdmnState->addr, CCoinJoinAccept(nSessionDenom, txMyCollateral));
// TODO: add new state POOL_STATE_CONNECTING and bump MIN_COINJOIN_PEER_PROTO_VERSION
SetState(POOL_STATE_QUEUE);
nTimeLastSuccessfulStep = GetTime();
LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::StartNewQueue -- pending connection, nSessionDenom: %d (%s), addr=%s\n",
@ -1185,8 +1143,6 @@ bool CCoinJoinClientSession::ProcessPendingDsaRequest(CConnman& connman)
bool fDone = connman.ForNode(pendingDsaRequest.GetAddr(), [this, &connman](CNode* pnode) {
LogPrint(BCLog::COINJOIN, "-- processing dsa queue for addr=%s\n", pnode->addr.ToString());
nTimeLastSuccessfulStep = GetTime();
// TODO: this vvvv should be here after new state POOL_STATE_CONNECTING is added and MIN_COINJOIN_PEER_PROTO_VERSION is bumped
// SetState(POOL_STATE_QUEUE);
CNetMsgMaker msgMaker(pnode->GetSendVersion());
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::DSACCEPT, pendingDsaRequest.GetDSA()));
return true;

View File

@ -74,7 +74,7 @@ bool CCoinJoinQueue::Relay(CConnman& connman)
{
connman.ForEachNode([&connman, this](CNode* pnode) {
CNetMsgMaker msgMaker(pnode->GetSendVersion());
if (pnode->nVersion >= MIN_COINJOIN_PEER_PROTO_VERSION && pnode->fSendDSQueue) {
if (pnode->fSendDSQueue) {
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::DSQUEUE, (*this)));
}
});

View File

@ -47,17 +47,6 @@ void CCoinJoinServer::ProcessMessage(CNode* pfrom, const std::string& strCommand
void CCoinJoinServer::ProcessDSACCEPT(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman, bool enable_bip61)
{
if (pfrom->nVersion < MIN_COINJOIN_PEER_PROTO_VERSION) {
LogPrint(BCLog::COINJOIN, "DSACCEPT -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
REJECT_OBSOLETE, strprintf(
"Version must be %d or greater", MIN_COINJOIN_PEER_PROTO_VERSION)));
}
PushStatus(pfrom, STATUS_REJECTED, ERR_VERSION, connman);
return;
}
if (IsSessionReady()) {
// too many users in this session already, reject new ones
LogPrint(BCLog::COINJOIN, "DSACCEPT -- queue is already full!\n");
@ -123,16 +112,6 @@ void CCoinJoinServer::ProcessDSACCEPT(CNode* pfrom, const std::string& strComman
void CCoinJoinServer::ProcessDSQUEUE(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman, bool enable_bip61)
{
if (pfrom->nVersion < MIN_COINJOIN_PEER_PROTO_VERSION) {
LogPrint(BCLog::COINJOIN, "DSQUEUE -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
REJECT_OBSOLETE, strprintf(
"Version must be %d or greater", MIN_COINJOIN_PEER_PROTO_VERSION)));
}
return;
}
CCoinJoinQueue dsq;
vRecv >> dsq;
@ -189,17 +168,6 @@ void CCoinJoinServer::ProcessDSQUEUE(CNode* pfrom, const std::string& strCommand
void CCoinJoinServer::ProcessDSVIN(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman, bool enable_bip61)
{
if (pfrom->nVersion < MIN_COINJOIN_PEER_PROTO_VERSION) {
LogPrint(BCLog::COINJOIN, "DSVIN -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
REJECT_OBSOLETE, strprintf(
"Version must be %d or greater", MIN_COINJOIN_PEER_PROTO_VERSION)));
}
PushStatus(pfrom, STATUS_REJECTED, ERR_VERSION, connman);
return;
}
//do we have enough users in the current session?
if (!IsSessionReady()) {
LogPrint(BCLog::COINJOIN, "DSVIN -- session not complete!\n");
@ -226,16 +194,6 @@ void CCoinJoinServer::ProcessDSVIN(CNode* pfrom, const std::string& strCommand,
void CCoinJoinServer::ProcessDSSIGNFINALTX(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman, bool enable_bip61)
{
if (pfrom->nVersion < MIN_COINJOIN_PEER_PROTO_VERSION) {
LogPrint(BCLog::COINJOIN, "DSSIGNFINALTX -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
REJECT_OBSOLETE, strprintf(
"Version must be %d or greater", MIN_COINJOIN_PEER_PROTO_VERSION)));
}
return;
}
std::vector<CTxIn> vecTxIn;
vRecv >> vecTxIn;

View File

@ -102,17 +102,13 @@ public:
std::vector<uint256> deletedMNs;
std::vector<CSimplifiedMNListEntry> mnList;
// starting with proto version LLMQS_PROTO_VERSION, we also transfer changes in active quorums
std::vector<std::pair<uint8_t, uint256>> deletedQuorums; // p<LLMQType, quorumHash>
std::vector<llmq::CFinalCommitment> newQuorums;
SERIALIZE_METHODS(CSimplifiedMNListDiff, obj)
{
READWRITE(obj.baseBlockHash, obj.blockHash, obj.cbTxMerkleTree, obj.cbTx, obj.deletedMNs, obj.mnList);
if (s.GetVersion() >= LLMQS_PROTO_VERSION) {
READWRITE(obj.deletedQuorums, obj.newQuorums);
}
READWRITE(obj.deletedQuorums, obj.newQuorums);
}
CSimplifiedMNListDiff();

View File

@ -93,16 +93,6 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
// ANOTHER USER IS ASKING US TO HELP THEM SYNC GOVERNANCE OBJECT DATA
if (strCommand == NetMsgType::MNGOVERNANCESYNC) {
if (pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
LogPrint(BCLog::GOBJECT, "MNGOVERNANCESYNC -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
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.
// We could start processing this after masternode list is synced
// but this is a heavy one so it's better to finish sync first.
@ -138,16 +128,6 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
EraseObjectRequest(pfrom->GetId(), CInv(MSG_GOVERNANCE_OBJECT, nHash));
}
if (pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
LogPrint(BCLog::GOBJECT, "MNGOVERNANCEOBJECT -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
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.IsBlockchainSynced()) {
LogPrint(BCLog::GOBJECT, "MNGOVERNANCEOBJECT -- masternode list not synced\n");
return;
@ -215,15 +195,6 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
EraseObjectRequest(pfrom->GetId(), CInv(MSG_GOVERNANCE_OBJECT_VOTE, nHash));
}
if (pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
LogPrint(BCLog::GOBJECT, "MNGOVERNANCEOBJECTVOTE -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
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
if (!masternodeSync.IsBlockchainSynced()) {
LogPrint(BCLog::GOBJECT, "MNGOVERNANCEOBJECTVOTE -- masternode list not synced\n");
@ -959,7 +930,6 @@ void CGovernanceManager::RequestGovernanceObject(CNode* pfrom, const uint256& nH
int CGovernanceManager::RequestGovernanceObjectVotes(CNode* pnode, CConnman& connman)
{
if (pnode->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) return -3;
std::vector<CNode*> vNodesCopy;
vNodesCopy.push_back(pnode);
return RequestGovernanceObjectVotes(vNodesCopy, connman);
@ -1038,8 +1008,6 @@ int CGovernanceManager::RequestGovernanceObjectVotes(const std::vector<CNode*>&
// Inbound connection this early is most likely a "masternode" connection
// initiated from another node, so skip it too.
if (!pnode->CanRelay() || (fMasternodeMode && pnode->fInbound)) continue;
// only use up to date peers
if (pnode->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) continue;
// stop early to prevent setAskFor overflow
{
LOCK(cs_main);

View File

@ -677,7 +677,7 @@ void CGovernanceObject::Relay(CConnman& connman) const
return;
}
int minProtoVersion = MIN_GOVERNANCE_PEER_PROTO_VERSION;
int minProtoVersion = MIN_PEER_PROTO_VERSION;
if (nObjectType == GOVERNANCE_OBJECT_PROPOSAL) {
// We know this proposal is valid locally, otherwise we would not get to the point we should relay it.
// But we don't want to relay it to pre-GOVSCRIPT_PROTO_VERSION peers if payment_address is p2sh

View File

@ -129,15 +129,8 @@ void CGovernanceVote::Relay(CConnman& connman) const
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 (!CDeterministicMNList::IsMNValid(*dmn)) {
minVersion = GOVERNANCE_POSE_BANNED_VOTES_VERSION;
}
CInv inv(MSG_GOVERNANCE_OBJECT_VOTE, GetHash());
connman.RelayInv(inv, minVersion);
connman.RelayInv(inv);
}
void CGovernanceVote::UpdateHash() const

View File

@ -150,7 +150,7 @@ void CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq::CCha
// Note: do not hold cs while calling RelayInv
AssertLockNotHeld(cs);
g_connman->RelayInv(clsigInv, LLMQS_PROTO_VERSION);
g_connman->RelayInv(clsigInv);
if (pindex == nullptr) {
// we don't know the block/header for this CLSIG yet, so bail out for now

View File

@ -1082,11 +1082,11 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, const uint256& has
const auto is_det = islock->IsDeterministic();
CInv inv(is_det ? MSG_ISDLOCK : MSG_ISLOCK, hash);
if (tx != nullptr) {
g_connman->RelayInvFiltered(inv, *tx, is_det ? ISDLOCK_PROTO_VERSION : LLMQS_PROTO_VERSION);
g_connman->RelayInvFiltered(inv, *tx, is_det ? ISDLOCK_PROTO_VERSION : MIN_PEER_PROTO_VERSION);
} else {
// we don't have the TX yet, so we only filter based on txid. Later when that TX arrives, we will re-announce
// with the TX taken into account.
g_connman->RelayInvFiltered(inv, islock->txid, is_det ? ISDLOCK_PROTO_VERSION : LLMQS_PROTO_VERSION);
g_connman->RelayInvFiltered(inv, islock->txid, is_det ? ISDLOCK_PROTO_VERSION : MIN_PEER_PROTO_VERSION);
}
ResolveBlockConflicts(hash, *islock);

View File

@ -828,7 +828,7 @@ void CSigningManager::ProcessRecoveredSig(const std::shared_ptr<const CRecovered
if (fMasternodeMode) {
CInv inv(MSG_QUORUM_RECOVERED_SIG, recoveredSig->GetHash());
g_connman->ForEachNode([&](CNode* pnode) {
if (pnode->nVersion >= LLMQS_PROTO_VERSION && pnode->fSendRecSigs) {
if (pnode->fSendRecSigs) {
pnode->PushInventory(inv);
}
});

View File

@ -255,7 +255,6 @@ void CMasternodeSync::ProcessTick(CConnman& connman)
}
netfulfilledman.AddFulfilledRequest(pnode->addr, "governance-sync");
if (pnode->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) continue;
nTriedPeerCount++;
SendGovernanceSyncRequest(pnode, connman);

View File

@ -2683,7 +2683,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
(fLogIPs ? strprintf(", peeraddr=%s", pfrom->addr.ToString()) : ""));
}
if (pfrom->nVersion >= LLMQS_PROTO_VERSION && !pfrom->m_masternode_probe_connection) {
if (!pfrom->m_masternode_probe_connection) {
CMNAuth::PushMNAUTH(pfrom, *connman);
}
@ -2708,14 +2708,8 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
}
if (pfrom->nVersion >= SENDDSQUEUE_PROTO_VERSION) {
// Tell our peer that he should send us CoinJoin queue messages
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDDSQUEUE, true));
} else {
// older nodes do not support SENDDSQUEUE and expect us to always send CoinJoin queue messages
// TODO we can remove this compatibility code in 0.15.0
pfrom->fSendDSQueue = true;
}
// Tell our peer that he should send us CoinJoin queue messages
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDDSQUEUE, true));
if (llmq::CLLMQUtils::IsWatchQuorumsEnabled() && !pfrom->m_masternode_connection) {
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::QWATCH));
@ -4665,7 +4659,6 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
const auto islock = llmq::quorumInstantSendManager->GetInstantSendLockByTxid(hash);
if (islock == nullptr) continue;
if (pto->nVersion < LLMQS_PROTO_VERSION) continue;
if (pto->nVersion < ISDLOCK_PROTO_VERSION && islock->IsDeterministic()) continue;
queueAndMaybePushInv(CInv(islock->IsDeterministic() ? MSG_ISDLOCK : MSG_ISLOCK, ::SerializeHash(*islock)));
}

View File

@ -17,31 +17,15 @@ static const int PROTOCOL_VERSION = 70221;
static const int INIT_PROTO_VERSION = 209;
//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION = 70213;
static const int MIN_PEER_PROTO_VERSION = 70215;
//! minimum proto version of masternode to accept in DKGs
static const int MIN_MASTERNODE_PROTO_VERSION = 70219;
//! minimum proto version for governance sync and messages
static const int MIN_GOVERNANCE_PEER_PROTO_VERSION = 70213;
//! minimum proto version to broadcast governance messages from banned masternodes
static const int GOVERNANCE_POSE_BANNED_VOTES_VERSION = 70215;
//! nTime field added to CAddress, starting with this version;
//! if possible, avoid requesting addresses nodes older than this
static const int CADDR_TIME_VERSION = 31402;
//! introduction of LLMQs
static const int LLMQS_PROTO_VERSION = 70214;
//! introduction of SENDDSQUEUE
//! TODO we can remove this in 0.15.0.0
static const int SENDDSQUEUE_PROTO_VERSION = 70214;
//! minimum peer version accepted by mixing pool
static const int MIN_COINJOIN_PEER_PROTO_VERSION = 70213;
//! protocol version is included in MNAUTH starting with this version
static const int MNAUTH_NODE_VER_VERSION = 70218;