Skip to content

p2p: reduce false-positives in addr rate-limiting - #33699

Closed
0xB10C wants to merge 1 commit into
bitcoin:masterfrom
0xB10C:2025-10-addr-token-bucket-start-5
Closed

0xB10C wants to merge 1 commit into
bitcoin:masterfrom
0xB10C:2025-10-addr-token-bucket-start-5

Conversation

@0xB10C

@0xB10C 0xB10C commented Oct 24, 2025 •

Copy link
Copy Markdown
Contributor

Start the rate-limiter with 5 tokens instead of 1 token.


On some occasions, a peer will send us addresses a few seconds after the connection is established. As peers start with token=1 and only get an additional token only every 10 seconds, some of these addresses might be rate-limited. The following log snippet contains an example:

04:12:02 [net] Added connection to [redacted] peer=1234
...
04:12:03 [net] Received addr: 1 addresses (1 processed, 0 rate-limited) from peer=1234
04:12:34 [net] Received addr: 4 addresses (3 processed, 1 rate-limited) from peer=1234
04:13:09 [net] Received addr: 2 addresses (2 processed, 0 rate-limited) from peer=1234

The peer starts with token=1 and uses one for its self-announcement at 04:12:03. Until the next addr message arrives at 04:12:34, it re-gains 3 tokens and uses them, however, the fourth address in this addr message is rate-limited. At 04:13:09, the peer has token=3 and uses 2.

This change gives peers token=5 to start with. To choose this value, I looked at the address relay of freshly connected peers. The data was sampled from the debug.logs from different nodes. It appears, that only very few peers require more than 5 initial tokens.

image

By increasing the initial tokens to 5, someone could connect, send 5 addresses, disconnect, and repeat to spam the node with addresses. Previously, the same was possible but only one address was processed. I don't think this is a problem anymore since #30568.

On some occasions, a peer will send us addresses a few seconds after
the connection is established. As peers start with token=1 and only
get an additional token only every 10 seconds, some of these
addresses might be rate-limited. The following log snippet contains
an example:

```
04:12:02 [net] Added connection to [redacted] peer=1234
...
04:12:03 [net] Received addr: 1 addresses (1 processed, 0 rate-limited) from peer=1234
04:12:34 [net] Received addr: 4 addresses (3 processed, 1 rate-limited) from peer=1234
04:13:09 [net] Received addr: 2 addresses (2 processed, 0 rate-limited) from peer=1234
```

The peer starts with token=1 and uses one for its self-announcement at
04:12:03. Until the next addr message arrives at 04:12:34, it re-gains
3 tokens and uses them, however, the fourth address in this addr
message is rate-limited. At 04:13:09, the peer has token=3 and uses 2.

This change gives peers token=5 to start with. To choose this value, I
looked at the address relay of freshly connected peers. The data was
sampled from the debug.logs from different nodes. It appears, that only
very few peers require more than 5 initial tokens.

(see image in PR)

By increasing the initial tokens to 5, someone could connect, send 5
addresses, disconnect, and repeat to spam the node with addresses.
Previously, the same was possible but only one address was processed.
I don't think this is a problem since we have bitcoin#30568.
@DrahtBot DrahtBot added the P2P label Oct 24, 2025
@DrahtBot

DrahtBot commented Oct 24, 2025 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33699.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK mzumsande, Crypt-iQ

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

@mzumsande mzumsande left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK fdf4863

I think that while the existing rate limit is sufficient, the observed events where the rate limit kicks in are just due to statistical fluctuation (which wouldn't lead to rate limiting later on because the node will usually have saved up some cushion) - having fewer of those could prevent a peer's self-announcement from being ignored, and could make monitoring a bit easier.

@Crypt-iQ

Copy link
Copy Markdown
Contributor

crACK fdf4863

The graph is helpful, I wonder what's going on with those peers above and to the left of the staircase?

@fanquake

Copy link
Copy Markdown
Member

cc @ajtowns

@0xB10C

0xB10C commented Oct 27, 2025 •

Copy link
Copy Markdown
Contributor Author

I wonder what's going on with those peers above and to the left of the staircase?

It can happen that a (Bitcoin Core) peer sends us an addr message with more than X entries by random chance. Observed from the logs I looked at:

chance >= 1 entries 	 100.00%
chance >= 2 entries 	 37.62%
chance >= 3 entries 	 19.14%
chance >= 4 entries 	 10.16%
chance >= 5 entries 	 5.66%
chance >= 6 entries 	 3.28%
chance >= 7 entries 	 1.98%
chance >= 8 entries 	 1.25%
chance >= 9 entries 	 0.81%
chance >= 10 entries 	 0.55%
chance >= 11 entries 	 0.39%
chance >= 12 entries 	 0.28%
chance >= 13 entries 	 0.21%
chance >= 14 entries 	 0.16%
chance >= 15 entries 	 0.13%

So there's a 3.28% chance that a peer sends us a addr message with more than 5 addr. If this message arrives <10s after connection open, the peer does not have enough token yet. However, it's also unlikely that we choose to relay >5 addresses to this peer in <10s.

This is a hand-picked example from a peer (that claims to be v29.0) that sent some larger addr messages early on:

01:08:43 [net] Added connection to X peer=9668
01:09:05 [msghand] Received addr: 8 addresses (3 processed, 5 rate-limited) from peer=9668
01:10:25 [msghand] Received addr: 11 addresses (8 processed, 3 rate-limited) from peer=9668
01:10:48 [msghand] Received addr: 3 addresses (2 processed, 1 rate-limited) from peer=9668
01:11:38 [msghand] Received addr: 9 addresses (5 processed, 4 rate-limited) from peer=9668
01:12:13 [msghand] Received addr: 3 addresses (3 processed, 0 rate-limited) from peer=9668
01:13:09 [msghand] Received addr: 8 addresses (6 processed, 2 rate-limited) from peer=9668
01:13:55 [msghand] Received addr: 2 addresses (2 processed, 0 rate-limited) from peer=9668

Here's an overview of the number addr message entries peers send to me and were processed or rate-limited. Nearly all of the rate-limited entries were send in the first 60 seconds.

image

@ajtowns

ajtowns commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

On some occasions, a peer will send us addresses a few seconds after the connection is established.

What's the drawback of ignoring these addresses? If we'd connected a few seconds/a minute later, we'd have missed them anyway.

An advantage of starting with an (almost) empty bucket is that someone attempting an address spamming attack has to pay for that attack by maintaining a connection to us. Increasing the initial bucket for outbound/manual connections but not inbound connections might be better?

@mzumsande

Copy link
Copy Markdown
Contributor

What's the drawback of ignoring these addresses? If we'd connected a few seconds/a minute later, we'd have missed them anyway.

Ignoring the initial self-announcement of the peer if it get mixed up with other addrs would feel strange.

@Crypt-iQ

Crypt-iQ commented Oct 28, 2025 •

Copy link
Copy Markdown
Contributor

Ignoring self-announcements seems to occur only in the time between our inbound peer (outbound from their perspective) 1) calling SetupAddressRelay when receiving version, and 2) receiving verack where it will set fSuccessfullyConnected = true and call SendMessages followed by MaybeSendAddr. The address entries are sent in order of insert, but then shuffled before processing since #22387 (see rationale). If they weren't shuffled on receipt, I think the self-announcement would always be processed.

If we are being connected to, I think our self-announcement won't be rate-limited because we'll wait until receiving getaddr, call SetupAddressRelay, and then in SendMessages, our self-announcement will replace one of the existing entries in the getaddr response. There's no time-gap in this case afaict.

@glozow

glozow commented Oct 28, 2025 •

Copy link
Copy Markdown
Contributor

If these are Bitcoin Core nodes (so our sender-side logic is seemingly incompatible with our receiver-side logic), is an alternative approach to increase the delay after which we'd send addrs?

@ajtowns

ajtowns commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

What's the drawback of ignoring these addresses? If we'd connected a few seconds/a minute later, we'd have missed them anyway.

Ignoring the initial self-announcement of the peer if it get mixed up with other addrs would feel strange.

Yeah, you're right. Though as glozow points out, it's also strange to have our sender/receiver side logic randomly mismatch depending on network behaviour (with this PR making the random mismatch much less frequent). Would it make sense to change the logic to be:

void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::microseconds current_time)
{
    ...
    if (... && peer.m_next_local_addr_send < current_time) {
        ...   
        if (peer.m_next_local_addr_send != 0us) {
            peer.m_addr_known->reset();
        }
        if (std::optional<CService> local_service = GetLocalAddrForPeer(node)) {
            CAddress local_addr{*local_service, peer.m_our_services, Now<NodeSeconds>()};
            if (peer.m_next_local_addr_send == 0us) {
                // first local addr announcement, send as a single message
                if (peer.m_wants_addrv2) {
                    MakeAndPushMessage(node, NetMsgType::ADDRV2, CAddress::V2_NETWORK(local_addr));
                } else {
                    MakeAndPushMessage(node, NetMsgType::ADDR, CAddress::V1_NETWORK(local_addr));
                }
            } else {
                // normally, include local addr with any others queued up
                PushAddress(peer, local_addr);
            }
        }
        peer.m_next_local_addr_send = current_time + m_rng.rand_exp_duration(AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL);
    }
    ...

so that we push our local address as a single message first, using up the bucket preallocation, then allow other addresses to be sent and rate-limited as normal? That seems like it would automatically help existing nodes not rate-limit self announcements from future releases.

@ajtowns

ajtowns commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

If they weren't shuffled on receipt, I think the self-announcement would always be processed.

I think shuffling helps avoid an attacker being able to (a) prevent honest nodes' addresses from being relayed (by filling up the buffer, so that later honest announcements get dropped) and (b) (easily?) detect how many addresses are being rate limited. So I don't think removing the shuffle would be a good idea.

@mzumsande

Copy link
Copy Markdown
Contributor

If we are being connected to, I think our self-announcement won't be rate-limited because we'll wait until receiving getaddr, call SetupAddressRelay, and then in SendMessages, our self-announcement will replace one of the existing entries in the getaddr response. There's no time-gap in this case afaict.

True, I have observed this effect too recently, it isn't really clean though - I don't think anyone intended it to work such that a GETADDR answers would contain 999 addresses from addrman and a self announcement replacing a random one - so aj's suggestion makes change to me.

If these are Bitcoin Core nodes (so our sender-side logic is seemingly incompatible with our receiver-side logic), is an alternative approach to increase the delay after which we'd send addrs?

That should work too, but it would also slow things down if the receiver waits for addrs (ADDRFETCH connections).

@0xB10C

0xB10C commented Dec 3, 2025 •

Copy link
Copy Markdown
Contributor Author

Ignoring self-announcements seems to occur only in the time between our inbound peer (outbound from their perspective) 1) calling SetupAddressRelay when receiving version, and 2) receiving verack where it will set fSuccessfullyConnected = true and call SendMessages followed by MaybeSendAddr. The address entries are sent in order of insert, but then shuffled before processing since #22387 (see rationale). If they weren't shuffled on receipt, I think the self-announcement would always be processed.

If we are being connected to, I think our self-announcement won't be rate-limited because we'll wait until receiving getaddr, call SetupAddressRelay, and then in SendMessages, our self-announcement will replace one of the existing entries in the getaddr response. There's no time-gap in this case afaict.

Thanks for that digging, I found that helpful.

What's the drawback of ignoring these addresses? If we'd connected a few seconds/a minute later, we'd have missed them anyway.

Ignoring the initial self-announcement of the peer if it get mixed up with other addrs would feel strange.

Yeah, you're right.

I'm actually not sure yet if any addresses my nodes rate-limited are actually self-announcements. Looking at the logs, there are certainly initial addr(v2) messages I received shortly after connection open (from inbound peers) with at least one address being rate-limited by me. However, I think if the peer doesn't self-announce (e.g. -listen=0), these could be just early normal address relay messages. I've set up a few nodes with this patch to log some of the rate-limitings 0xB10C@159b6fd and hope to compare the rate-limited address to the address of the peer. Let's see...

Would it make sense to change the logic to be:

I picked that up in https://github.com/0xB10C/bitcoin/tree/2025-11-self-advertise-in-separate-message - but will hold off PRing it until I'm sure we actually rate-limit self-announcements. Most of the work was the function test for the self-announcements, which is good to have regardless1.

Footnotes

  1. Note that the snipped above contains a subtle bug which isn't catched by one of our tests (but would be by the mentioned functional test): MakeAndPushMessage(node, NetMsgType::ADDR, CAddress::V1_NETWORK(local_addr)); where local_addr is a CAddress compiles, but it should be a vector of CAddress with one element. This will send out the serialized address alone, which isn't valid content for an addr message. ↩

@0xB10C

0xB10C commented Dec 4, 2025 •

Copy link
Copy Markdown
Contributor Author

Saw one today with 0xB10C@159b6fd. Will wait for a few more.

Rate-limited addr 98.97.137.54:8333 SELF-ANNOUNCEMENT!? from peer=2324 addr=98.97.137.54:46196 ua=/Satoshi:22.0.0(FutureBit-Apollo-Node)/ processed=1 rate-limited=1 age=478ms type=inbound

edit: saw more, but interestingly only from older releases e.g. /Satoshi:23.0.0/?

Rate-limited addr 159.26.100.23:8333 SELF-ANNOUNCEMENT!? from peer=6959 addr=159.26.100.23:44574 ua=/Satoshi:23.0.0/ processed=1 rate-limited=1 age=1396ms type=inbound
Rate-limited addr 86.48.14.196:8333 SELF-ANNOUNCEMENT!? from peer=3645 addr=86.48.14.196:24948 ua=/Satoshi:22.0.0/ processed=1 rate-limited=1 age=313ms type=inbound
Rate-limited addr 103.251.26.153:8333 SELF-ANNOUNCEMENT!? from peer=19504 addr=103.251.26.153:59551 ua=/Satoshi:22.0.0/ processed=1 rate-limited=1 age=252ms type=inbound
Rate-limited addr 92.167.10.252:8333 SELF-ANNOUNCEMENT!? from peer=20975 addr=92.167.10.252:51644 ua=/Satoshi:22.0.0/ processed=1 rate-limited=1 age=614ms type=inbound
Rate-limited addr 150.228.85.13:8333 SELF-ANNOUNCEMENT!? from peer=12338 addr=150.228.85.13:11419 ua=/Satoshi:22.0.0/ processed=1 rate-limited=1 age=477ms type=inbound

# LinkingLion seems to heavily self announce their node IPs and seems to be getting rate limited:
# see https://bnoc.xyz/t/linkinglion-an-entity-linking-bitcoin-transactions-to-ips/12/7?u=b10c
Rate-limited addr 199.116.84.88:8333 SELF-ANNOUNCEMENT!? from peer=7620 addr=199.116.84.88:17165 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=550 age=798ms type=inbound
Rate-limited addr 199.116.84.173:8333 SELF-ANNOUNCEMENT!? from peer=7624 addr=199.116.84.173:15987 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=689 age=1223ms type=inbound
Rate-limited addr 199.116.84.7:8333 SELF-ANNOUNCEMENT!? from peer=7854 addr=199.116.84.7:27880 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=161 age=712ms type=inbound
Rate-limited addr 199.116.84.147:8333 SELF-ANNOUNCEMENT!? from peer=7873 addr=199.116.84.147:4150 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=176 age=1090ms type=inbound
Rate-limited addr 199.116.84.185:8333 SELF-ANNOUNCEMENT!? from peer=7881 addr=199.116.84.185:20012 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=674 age=1297ms type=inbound
Rate-limited addr 199.116.84.185:8333 SELF-ANNOUNCEMENT!? from peer=7890 addr=199.116.84.185:37238 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=693 age=879ms type=inbound
Rate-limited addr 199.116.84.185:8333 SELF-ANNOUNCEMENT!? from peer=7958 addr=199.116.84.185:3673 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=61 age=707ms type=inbound
Rate-limited addr 199.116.84.185:8333 SELF-ANNOUNCEMENT!? from peer=8159 addr=199.116.84.185:32178 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=348 age=483ms type=inbound
Rate-limited addr 199.116.84.185:8333 SELF-ANNOUNCEMENT!? from peer=8396 addr=199.116.84.185:10842 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=669 age=1342ms type=inbound
Rate-limited addr 199.116.84.185:8333 SELF-ANNOUNCEMENT!? from peer=8491 addr=199.116.84.185:34938 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=331 age=20710ms type=inbound
Rate-limited addr 199.116.84.185:8333 SELF-ANNOUNCEMENT!? from peer=8910 addr=199.116.84.185:54696 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=567 age=1098ms type=inbound
Rate-limited addr 199.116.84.185:8333 SELF-ANNOUNCEMENT!? from peer=8946 addr=199.116.84.185:6062 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=605 age=1203ms type=inbound
Rate-limited addr 199.116.84.203:8333 SELF-ANNOUNCEMENT!? from peer=9049 addr=199.116.84.203:19824 ua=/btcwire:0.5.0/Satoshi:25.0.0/ processed=0 rate-limited=517 age=1240ms type=inbound

0xB10C added a commit to 0xB10C/bitcoin that referenced this pull request Dec 10, 2025
To avoid that our first (i.e. right after connection open) self-
announcement is rate-limited due to being put in a message with other
addresses, send it in a separate message first.

A new connection starts with one token in the addr rate-limiter. It
can happen that the self-announcement is sent in a addr(v2) message
along with other to-be-relayed addresses. Since order of the
addresses is shuffeld on receiving, the self-announcement in might be
rate-limited.

This is inspired by and based on bitcoin#33699 (comment)

Co-Authored-By: Anthony Towns <[email protected]>
@0xB10C

0xB10C commented Dec 10, 2025

Copy link
Copy Markdown
Contributor Author

I picked that up in https://github.com/0xB10C/bitcoin/tree/2025-11-self-advertise-in-separate-message - but will hold off PRing it until I'm sure we actually rate-limit self-announcements. Most of the work was the function test for the self-announcements, which is good to have regardless1.

Opened a PR for the self-announcement test in #34039

The logic change (c1514bf) might be good to be explicit about our self-announcement in case we somehow start sending them along with other addresses, but doesn't seem to be needed now. I will keep an eye on rate-limited self-announcements for a bit longer to see if anything changes my impression there.

@0xB10C

0xB10C commented Dec 10, 2025

Copy link
Copy Markdown
Contributor Author

I'm becoming less sure that this PR is actually worthwhile doing. I've not seen us rate-limit a self-announcement from a recent node version yet. For all other addresses (that aren't direct self-announcements from our peer) it probably hardly matters if we randomly rate-limit a few gossiped addresses.

An advantage of starting with an (almost) empty bucket is that someone attempting an address spamming attack has to pay for that attack by maintaining a connection to us.

Agree, generally, it might be better to keep the start token at 1 to make it more costly for an attacker to send us addresses that we will process. Especially with e.g. LinkingLion now shifting behavior to mass self-announce IPs of their new, listening nodes.

If these are Bitcoin Core nodes (so our sender-side logic is seemingly incompatible with our receiver-side logic), is an alternative approach to increase the delay after which we'd send addrs?

Yet another approach: On the sender side in RelayAddress(), pick peers where we expect that the tokens the other side has for us (i.e. 1 + connection_age_in_sec/10) is more than the addresses we relayed to it. However, future changes to the start token might break this assumption for old nodes.

Going to close this PR for now. Might reopen if there are new insights from collected data.

@0xB10C 0xB10C closed this Dec 10, 2025

@mzumsande mzumsande left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the suggestion by @ajtowns (#33699 (comment)) to send the first self-advertisement separately would make sense on its own - currently it will usually (I think it depends a bit on timing) get mixed up with the GETADDR answer and replaces one of the 1000 addrs from it, which isn't clean.

@0xB10C

0xB10C commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

I think the suggestion by @ajtowns (#33699 (comment)) to send the first self-advertisement separately would make sense on its own - currently it will usually (I think it depends a bit on timing) get mixed up with the GETADDR answer and replaces one of the 1000 addrs from it, which isn't clean.

done in #34146

0xB10C added a commit to 0xB10C/bitcoin that referenced this pull request Jan 5, 2026
This makes sure the initial address self-announcement a node sends to
a peer happends in a separate P2P message. This has benefits for both
inbound and outbound connections:

For inbound connections from a peer to us, previously, we might send
the self-announcement along with our response to a GETADDR request.
However, the self-announcement might replace an address from the
GETADDR response. This isn't clean.

For outbound connections from us to a peer, previously, it could have
happend that we send the self-announcement along with other addresses.
Since shortly after connection open, the peer might only have one
rate-limiting token for us, and the addresses are shuffeld on arrival,
it's possible that the self-announcement gets rate-limited. However,
note that these rate-limitings seem to be rare in practice.

This is inspired by and based on bitcoin#33699 (comment)

Co-Authored-By: Anthony Towns <[email protected]>
achow101 added a commit that referenced this pull request Jan 14, 2026
…age 🎄

792e2ed p2p: first addr self-announcement in separate msg (0xb10c)

Pull request description:

  This makes sure the initial address self-announcement a node sends to a peer happends in a separate P2P message. This has benefits for both inbound and outbound connections:

  For inbound connections from a peer to us, previously, we might send the self-announcement along with our response to a GETADDR request. However, the self-announcement might replace an address from the GETADDR response. This isn't clean.

  For outbound connections from us to a peer, previously, it could have happend that we send the self-announcement along with other addresses. Since shortly after connection open, the peer might only have one rate-limiting token for us, and the addresses are shuffeld on arrival, it's possible that the self-announcement gets rate-limited. However, note that these rate-limitings seem to be rare in practice.

  This is inspired by and based on #33699 (comment). The discussion there should be helpful for reviewers.

ACKs for top commit:
  bensig:
    ACK 792e2ed
  achow101:
    ACK 792e2ed
  fjahr:
    Code review ACK 792e2ed
  frankomosh:
    Code Review ACK [792e2ed](792e2ed)

Tree-SHA512: e3d39b1e3ae6208b54df4b36c624a32d70a442e01681f49e0c8a65076a818b5bf203c2e51011dc32edbbe3637b3c0b5f18de26e3461c288aa3806646a209a260
Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Jun 28, 2026
This makes sure the initial address self-announcement a node sends to
a peer happends in a separate P2P message. This has benefits for both
inbound and outbound connections:

For inbound connections from a peer to us, previously, we might send
the self-announcement along with our response to a GETADDR request.
However, the self-announcement might replace an address from the
GETADDR response. This isn't clean.

For outbound connections from us to a peer, previously, it could have
happend that we send the self-announcement along with other addresses.
Since shortly after connection open, the peer might only have one
rate-limiting token for us, and the addresses are shuffeld on arrival,
it's possible that the self-announcement gets rate-limited. However,
note that these rate-limitings seem to be rare in practice.

This is inspired by and based on bitcoin/bitcoin#33699 (comment)

Co-Authored-By: Anthony Towns <[email protected]>
Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Jun 28, 2026
…n separate message 🎄

3f3a057 p2p: first addr self-announcement in separate msg (0xb10c)

Pull request description:

  This makes sure the initial address self-announcement a node sends to a peer happends in a separate P2P message. This has benefits for both inbound and outbound connections:

  For inbound connections from a peer to us, previously, we might send the self-announcement along with our response to a GETADDR request. However, the self-announcement might replace an address from the GETADDR response. This isn't clean.

  For outbound connections from us to a peer, previously, it could have happend that we send the self-announcement along with other addresses. Since shortly after connection open, the peer might only have one rate-limiting token for us, and the addresses are shuffeld on arrival, it's possible that the self-announcement gets rate-limited. However, note that these rate-limitings seem to be rare in practice.

  This is inspired by and based on bitcoin/bitcoin#33699 (comment). The discussion there should be helpful for reviewers.

ACKs for top commit:
  bensig:
    ACK 3f3a057
  achow101:
    ACK 3f3a057
  fjahr:
    Code review ACK 3f3a057
  frankomosh:
    Code Review ACK [3f3a057](bitcoin/bitcoin@3f3a057)

Tree-SHA512: e3d39b1e3ae6208b54df4b36c624a32d70a442e01681f49e0c8a65076a818b5bf203c2e51011dc32edbbe3637b3c0b5f18de26e3461c288aa3806646a209a260
BigcoinBGC pushed a commit to BigcoinBGC/bigcoin that referenced this pull request Jun 30, 2026
This makes sure the initial address self-announcement a node sends to
a peer happends in a separate P2P message. This has benefits for both
inbound and outbound connections:

For inbound connections from a peer to us, previously, we might send
the self-announcement along with our response to a GETADDR request.
However, the self-announcement might replace an address from the
GETADDR response. This isn't clean.

For outbound connections from us to a peer, previously, it could have
happend that we send the self-announcement along with other addresses.
Since shortly after connection open, the peer might only have one
rate-limiting token for us, and the addresses are shuffeld on arrival,
it's possible that the self-announcement gets rate-limited. However,
note that these rate-limitings seem to be rare in practice.

This is inspired by and based on bitcoin/bitcoin#33699 (comment)

Co-Authored-By: Anthony Towns <[email protected]>
BigcoinBGC pushed a commit to BigcoinBGC/bigcoin that referenced this pull request Jun 30, 2026
…n separate message 🎄

89dee11 p2p: first addr self-announcement in separate msg (0xb10c)

Pull request description:

  This makes sure the initial address self-announcement a node sends to a peer happends in a separate P2P message. This has benefits for both inbound and outbound connections:

  For inbound connections from a peer to us, previously, we might send the self-announcement along with our response to a GETADDR request. However, the self-announcement might replace an address from the GETADDR response. This isn't clean.

  For outbound connections from us to a peer, previously, it could have happend that we send the self-announcement along with other addresses. Since shortly after connection open, the peer might only have one rate-limiting token for us, and the addresses are shuffeld on arrival, it's possible that the self-announcement gets rate-limited. However, note that these rate-limitings seem to be rare in practice.

  This is inspired by and based on bitcoin/bitcoin#33699 (comment). The discussion there should be helpful for reviewers.

ACKs for top commit:
  bensig:
    ACK 89dee11
  achow101:
    ACK 89dee11
  fjahr:
    Code review ACK 89dee11
  frankomosh:
    Code Review ACK [89dee11](bitcoin/bitcoin@89dee11)

Tree-SHA512: e3d39b1e3ae6208b54df4b36c624a32d70a442e01681f49e0c8a65076a818b5bf203c2e51011dc32edbbe3637b3c0b5f18de26e3461c288aa3806646a209a260
Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Aug 19, 2026
This makes sure the initial address self-announcement a node sends to
a peer happends in a separate P2P message. This has benefits for both
inbound and outbound connections:

For inbound connections from a peer to us, previously, we might send
the self-announcement along with our response to a GETADDR request.
However, the self-announcement might replace an address from the
GETADDR response. This isn't clean.

For outbound connections from us to a peer, previously, it could have
happend that we send the self-announcement along with other addresses.
Since shortly after connection open, the peer might only have one
rate-limiting token for us, and the addresses are shuffeld on arrival,
it's possible that the self-announcement gets rate-limited. However,
note that these rate-limitings seem to be rare in practice.

This is inspired by and based on bitcoin/bitcoin#33699 (comment)

Co-Authored-By: Anthony Towns <[email protected]>
Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Aug 19, 2026
…n separate message 🎄

792e2edf57ab31ae5c6f98acf33af8f67506630f p2p: first addr self-announcement in separate msg (0xb10c)

Pull request description:

  This makes sure the initial address self-announcement a node sends to a peer happends in a separate P2P message. This has benefits for both inbound and outbound connections:

  For inbound connections from a peer to us, previously, we might send the self-announcement along with our response to a GETADDR request. However, the self-announcement might replace an address from the GETADDR response. This isn't clean.

  For outbound connections from us to a peer, previously, it could have happend that we send the self-announcement along with other addresses. Since shortly after connection open, the peer might only have one rate-limiting token for us, and the addresses are shuffeld on arrival, it's possible that the self-announcement gets rate-limited. However, note that these rate-limitings seem to be rare in practice.

  This is inspired by and based on bitcoin/bitcoin#33699 (comment). The discussion there should be helpful for reviewers.

ACKs for top commit:
  bensig:
    ACK 792e2edf57ab31ae5c6f98acf33af8f67506630f
  achow101:
    ACK 792e2edf57ab31ae5c6f98acf33af8f67506630f
  fjahr:
    Code review ACK 792e2edf57ab31ae5c6f98acf33af8f67506630f
  frankomosh:
    Code Review ACK [792e2ed](bitcoin/bitcoin@792e2ed)

Tree-SHA512: e3d39b1e3ae6208b54df4b36c624a32d70a442e01681f49e0c8a65076a818b5bf203c2e51011dc32edbbe3637b3c0b5f18de26e3461c288aa3806646a209a260
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants