This PR builds on the test refactors extracted into #22306 (first 5 commits).
This PR aims to reduce addr blackholes. When we receive an addr
message that contains 10 or less addresses, we forward them to 1-2 peers. This is the main technique we use for self advertisements, so sending to peers that wouldn’t relay would effectively “blackhole” the trickle. Although we cannot prevent this in a malicious case, we can improve it for the normal, honest cases, and reduce the overall likelihood of occurrence. Two known cases where peers would not participate in addr relay are if they have connected to you as a block-relay-only connection, or if they are a light client.
This implementation defers initialization of m_addr_known
until it is needed, then uses its presence to decide if the peer is participating in addr relay. For outbound (not block-relay-only) peers, we initialize the filter before sending the initial self announcement when processing their version
message. For inbound peers, we initialize the filter if/when we get an addr related message (ADDR
, ADDRV2
, GETADDR
). We do NOT initialize the filter based on a SENDADDRV2
message.
To communicate about these changes beyond bitcoin core & to (try to) ensure that no other software would be disrupted, I have:
- Posted to the mailing list
- Researched other open source clients to confirm compatibility, opened issues in all the projects & documented in #21528 (comment). Many have confirmed that this change would not be problematic.
- Raised as topic during bitcoin-core-dev meeting
- Raised as topic during bitcoin p2p meeting