From 27e5a3020a98c04978e8053b5678ed8dd6a86f5f Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 8 Apr 2026 06:51:59 +0200 Subject: [PATCH] net_processing: don't modify addrman for private broadcast connections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is best if the internal addrman database is not modified with information coming from private broadcast connections because that information can potentially later be sent via other connections. Co-authored-by: Greg Sanders Co-authored-by: Lőrinc Github-Pull: #35032 Rebased-From: 1ed1a124028aa6783ecdd8c82083a3d7a6a16e53 --- src/net_processing.cpp | 2 +- src/test/net_tests.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 4450ff23f55..e2f7126e3ce 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3603,7 +3603,7 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string } vRecv.ignore(8); // Ignore the addrMe service bits sent by the peer vRecv >> CNetAddr::V1(addrMe); - if (!pfrom.IsInboundConn()) + if (!pfrom.IsInboundConn() && !pfrom.IsPrivateBroadcastConn()) { // Overwrites potentially existing services. In contrast to this, // unvalidated services received via gossip relay in ADDR/ADDRV2 diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index 1fc8d526944..32801d97b8b 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include #include #include #include @@ -1559,4 +1560,34 @@ BOOST_AUTO_TEST_CASE(v2transport_test) } } +BOOST_AUTO_TEST_CASE(private_broadcast_version_does_not_update_addrman_services) +{ + LOCK(NetEventsInterface::g_msgproc_mutex); + + const CNetAddr source{LookupHost("2.3.4.5", /*fAllowLookup=*/false).value()}; + const CAddress addr{Lookup("1.2.3.4", 8333, /*fAllowLookup=*/false).value(), NODE_NONE}; + BOOST_REQUIRE(m_node.addrman->Add({addr}, source)); + CNode node{/*id=*/0, + /*sock=*/nullptr, + /*addrIn=*/addr, + /*nKeyedNetGroupIn=*/0, + /*nLocalHostNonceIn=*/0, + /*addrBindIn=*/CService{}, + /*addrNameIn=*/"", + /*conn_type_in=*/ConnectionType::PRIVATE_BROADCAST, + /*inbound_onion=*/false, + /*network_key=*/0}; + + auto& connman = static_cast(*m_node.connman); + connman.Handshake(node, + /*successfully_connected=*/false, + /*remote_services=*/NODE_NETWORK, + /*local_services=*/NODE_NONE, + /*version=*/PROTOCOL_VERSION, + /*relay_txs=*/true); + + BOOST_CHECK_EQUAL(m_node.addrman->Select().first.nServices, NODE_NONE); + m_node.peerman->FinalizeNode(node); +} + BOOST_AUTO_TEST_SUITE_END()