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.
instagibbs suggested this change, thank you!
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.
instagibbs suggested this change, thank you!
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
See the guideline for information on the review process.
| Type | Reviewers |
|---|---|
| ACK | l0rinc, instagibbs, andrewtoth, danielabrozzoni, achow101 |
| Stale ACK | optout21 |
If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
ACK 687bbde1f87ddf10521eea096bf539ddcce9b84d
Sorry meant to ACK earlier.
crACK 687bbde1f87ddf10521eea096bf539ddcce9b84d
Change assessment: This is a small change related to private broadcast connections: in PeerManagerImpl::ProcessMessage(), for a VERSION message received from a peer, whom we connected to as private broadcast connection, addrman is not updated with the services of the peer. The reason is information hygiene: not to store this information about private connections, as this information may get sent to other peers later.
The change is limited to this one condition, and it looks correct.
Some observations:
Is it possible to easily test the effect of this change, in a unit test? A test would be desirable, to safeguard against later degradation.
Could there be other places where the same logic could be applied? I have identified one location, but I’m not sure whether the state saved there is relevant, and whether it’s striclty needed for correct functioning.
https://github.com/bitcoin/bitcoin/blob/master/src/net_processing.cpp#L3786
0 if (!pfrom.IsInboundConn()) {
1 // For non-inbound connections, we update the addrman to record
2 // ...
3 m_addrman.Good(pfrom.addr);
4 }
Note: The changed location is the only place where SetServices() gets called.
I have identified one location …
This will not be reached for private broadcast connections because we have stopped the processing for those connections earlier:
https://github.com/bitcoin/bitcoin/blob/master/src/net_processing.cpp#L3708
Is it possible to easily test the effect of this change, in a unit test? A test would be desirable, to safeguard against later degradation.
I had the same concern, we have identified a missing coverage, maybe we could add a dedicated test - or extend an existing one with a new assert.
0diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
1--- a/src/test/net_tests.cpp (revision d2844c6a4ffa39ec365009777cd87caf1fbab867)
2+++ b/src/test/net_tests.cpp (date 1775729451959)
3@@ -2,6 +2,7 @@
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6
7+#include <addrman.h>
8 #include <chainparams.h>
9 #include <clientversion.h>
10 #include <common/args.h>
11@@ -1006,6 +1007,21 @@
12 RemoveLocal(addr_cjdns);
13 }
14
15+BOOST_AUTO_TEST_CASE(private_broadcast_version_does_not_update_addrman_services)
16+{
17+ LOCK(NetEventsInterface::g_msgproc_mutex);
18+
19+ CAddress addr{Lookup("1.2.3.4", 8333, false).value(), NODE_NONE, Now<NodeSeconds>()};
20+ BOOST_REQUIRE(m_node.addrman->Add({addr}, Lookup("2.3.4.5", 8333, false).value()));
21+ CNode peer{0, nullptr, addr, 0, 0, {}, "", ConnectionType::PRIVATE_BROADCAST, false, 0};
22+
23+ auto& connman = static_cast<ConnmanTestMsg&>(*m_node.connman);
24+ connman.Handshake(peer, false, ServiceFlags(NODE_NETWORK | NODE_WITNESS), ServiceFlags(NODE_NETWORK | NODE_WITNESS), PROTOCOL_VERSION, true);
25+
26+ BOOST_CHECK_EQUAL(m_node.addrman->Select().first.nServices, NODE_NONE);
27+ m_node.peerman->FinalizeNode(peer);
28+}
29+
30 namespace {
31
32 CKey GenerateRandomTestKey(FastRandomContext& rng) noexcept
This will not be reached for private broadcast connections
Correct. Thanks for looking into it.
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 <gsanders87@gmail.com>
Co-authored-by: Lőrinc <pap.lorinc@gmail.com>
687bbde1f87ddf10521eea096bf539ddcce9b84d...1ed1a124028aa6783ecdd8c82083a3d7a6a16e53: added the test from above, thanks!
ACK 1ed1a124028aa6783ecdd8c82083a3d7a6a16e53
test fails as expected without fix
tACK 1ed1a124028aa6783ecdd8c82083a3d7a6a16e53
I checked if we modified addrman in any other way during private broadcast. I think it only happens in one other place: in CConnman::ConnectNode we might call Attempt, but this is not problematic as we never gossip any of m_last_try, m_last_count_attempt, nAttempts.
vasild
DrahtBot
instagibbs
andrewtoth
achow101
optout21
l0rinc
danielabrozzoni
fanquake
Milestone
31.1