From 5273f4be9eb4eaa3e886342357898b4b866dff68 Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 6 May 2024 08:42:26 -0700 Subject: [PATCH] Give Hush mainnet a dedicated minimum protocol version #345 Hush and DragonX do not have the same requirements for which nodes they should talk to because they don't necessarily have consensus changes at the same time. For instance, 3.10.0 was a consensus change for Hush but not DragonX. This commit changes things so that Hush nodes will no longer talk to old nodes that are not consensus compatible but leaves things the same for DragonX mainnet, which has never had a consensus change. --- src/main.cpp | 6 +++--- src/version.h | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bfcd3c538..475c1546b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -106,7 +106,7 @@ size_t nCoinCacheUsage = 5000 * 300; uint64_t nPruneTarget = 0; // If the tip is older than this (in seconds), the node is considered to be in initial block download. int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; -bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; +const bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; int32_t nFirstHalvingHeight = 340000; unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; @@ -6886,7 +6886,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); return true; } - auto p2pdebug = GetArg("-p2pdebug",0); + const bool p2pdebug = GetArg("-p2pdebug",0); if(p2pdebug) fprintf(stderr,"%s: netmsg: %s from %s\n", __func__, strCommand.c_str(), pfrom->addr.ToString().c_str() ); @@ -6913,7 +6913,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrFrom; uint64_t nNonce = 1; int nVersion; // use temporary for version, don't set version number until validated as connected - int minVersion = MIN_PEER_PROTO_VERSION; + const int minVersion = ishush3 ? MIN_HUSH_PEER_PROTO_VERSION : MIN_PEER_PROTO_VERSION; vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe; if (nVersion == 10300) nVersion = 300; diff --git a/src/version.h b/src/version.h index 74a686bd1..d4641ec5a 100644 --- a/src/version.h +++ b/src/version.h @@ -26,8 +26,13 @@ static const int PROTOCOL_VERSION = 1987426; static const int INIT_PROTO_VERSION = 209; //! In this version, 'getheaders' was introduced. static const int GETHEADERS_VERSION = 31800; -//! disconnect from peers older than this proto version + +//! disconnect from peers older than this proto version (HUSH mainnet) +static const int MIN_HUSH_PEER_PROTO_VERSION = 1987426; + +//! disconnect from peers older than this proto version (HACs) static const int MIN_PEER_PROTO_VERSION = 1987420; + //! 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;