net: add bip152hb permission to select BIP152 high-bandwidth peers #35940

pull w0xlt wants to merge 4 commits into bitcoin:master from w0xlt:feature/addnode-bip152-hb changing 10 files +144 −11
  1. w0xlt commented at 5:57 AM on August 10, 2026: contributor

    Bitcoin Core automatically selects up to three BIP152 high-bandwidth peers after they deliver new blocks. This works well for ordinary connections, but it cannot use topology information known to the operator.

    For example, an operator may run nodes in multiple locations, or maintain a stable, low-latency link to another node, and want that peer to announce compact blocks immediately and consistently, including after reconnects, instead of waiting for automatic selection.

    This PR adds a bip152hb net permission:

    -addnode=203.0.113.5 -whitelist=bip152hb,out@203.0.113.5
    

    For a peer with this permission, the node requests high-bandwidth mode in the existing SENDCMPCT message sent at VERACK, so it applies to every connection to that peer and requires no new P2P messages. It works with the existing -whitelist/-whitebind semantics: out applies to manual connections (-addnode, -connect, addnode RPC), in (the default) to inbound connections, and subnets are supported. Matching is by IP address or subnet, so hostnames are not supported.

    Peers with the permission are additional to the three automatically selected high-bandwidth peers and never take one of their slots. This intentionally allows explicit configuration to exceed BIP152's current three-peer recommendation and may increase redundant bandwidth. If accepted, BIP152 can be updated separately.

    Notes:

    • bip152hb is not included in all: unlike the other flags it grants the peer nothing and only costs bandwidth, so existing all@ configurations are unaffected.
    • The permission is rejected at startup with -blocksonly, where high-bandwidth mode is never requested.

    Earlier versions of this PR used an -addnode=<host>=bip152-hb suffix; it was reworked into a permission following review (https://github.com/bitcoin/bitcoin/pull/35940#issuecomment-6811490029).

  2. DrahtBot added the label P2P on Aug 10, 2026
  3. DrahtBot commented at 5:57 AM on August 10, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    Concept ACK jeanpablojp, Bicaru20, davidgumberg

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36819 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36819.svg"></sub> ([RFC] enable clang-tidy optin.performance.Padding by fanquake)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. jeanpablojp commented at 11:32 PM on August 14, 2026: contributor

    Concept ACK

    The opt-in override of the BIP152 three-peer cap seems fine to me, since it's an explicit operator choice, not a default, and it's disclosed upfront. Reusing -addnode also made more sense to me than creating a dedicated option.

  5. in doc/release-notes-35940.md:1 in 8ebd31e84c outdated
       0 | @@ -0,0 +1,12 @@
       1 | +P2P and network changes
    


    jeanpablojp commented at 11:32 PM on August 14, 2026:

    shouldn't this be renamed to release-notes-35940.md before merge?


    w0xlt commented at 10:34 PM on September 16, 2026:

    Done. Thanks.

  6. w0xlt force-pushed on Sep 16, 2026
  7. in test/functional/feature_config_args.py:302 in 3072e06744 outdated
     297 | +
     298 | +        node.assert_start_raises_init_error(
     299 | +            extra_args=["-blocksonly", "-addnode=127.0.0.1:18444=bip152-hb"],
     300 | +            expected_msg="Error: Invalid -addnode value '127.0.0.1:18444=bip152-hb': the bip152-hb suffix is incompatible with -blocksonly",
     301 | +        )
     302 | +
    


    Bicaru20 commented at 1:40 PM on October 15, 2026:

    Following the same pattern as in the test_empty_addnode in line 268 of the same file, I think we could also check the case where an -addnodeis empty but carries the suffixbip152-hb (-addnode==bip152-hb`).

            with node.assert_debug_log(expected_msgs=["Ignoring empty -addnode value"]):
                self.start_node(0, extra_args=["-blocksonly", "-addnode==bip152-hb"])
            util.assert_equal(node.getaddednodeinfo(), [])
    

    w0xlt commented at 12:43 AM on November 12, 2026:

    Thanks! Added in 0b54bdbfeb,

  8. in test/functional/p2p_compactblocks_hb.py:131 in 3072e06744 outdated
     126 | +            assert_equal(status, [True, nodeid >= 3, nodeid >= 4, nodeid >= 5])
     127 | +
     128 | +        # Receiving another block from the configured peer must not insert it
     129 | +        # into the automatic list or displace one of those three peers.
     130 | +        assert_equal(self.relay_block_through(2), [True, True, True, True])
     131 | +
    


    Bicaru20 commented at 1:42 PM on October 15, 2026:

    We could add the test case where a configured peer disconnects and reconnects again on its own is granted the high-bandwidth mode again.

            self.restart_node(2)
            self.wait_until(configured_peer_connected)
            assert_equal(self.relay_block_through(3), [True, True, True, True])
    

    w0xlt commented at 12:43 AM on November 12, 2026:

    Thanks, good idea! Added in 0b54bdbfeb, with a small change: rather than restarting node 2, the test disconnects it and reconnects with addnode ... onetry. Otherwise the addnode thread can take up to 60s to retry.

  9. Bicaru20 commented at 1:55 PM on October 15, 2026: contributor

    Concept ACK

    I think it’s a good addition to let users add their own high-bandwidth peers, as it gives them more control. I was initially worried about there being no cap on the number of user-selected high-bandwidth peers. However, since this will mostly be used by advanced users, it only affects the operator's own node, and the release notes already warn about the extra bandwidth, I think it's okay to leave it as is.

  10. w0xlt force-pushed on Nov 12, 2026
  11. davidgumberg commented at 1:17 AM on November 12, 2026: contributor

    Concept ACK, but I think it might make more sense to do this as a whitelist permission.

  12. in doc/release-notes-35940.md:7 in 499495aaf1
       0 | @@ -0,0 +1,12 @@
       1 | +P2P and network changes
       2 | +-----------------------
       3 | +
       4 | +- Added persistent BIP152 high-bandwidth compact block announcement requests
       5 | +  for selected outbound added-node connections. Append `=bip152-hb` to an
       6 | +  `-addnode=<host>[:<port>]` value to request high-bandwidth announcements from
       7 | +  connections opened for that added node.
    


    fanquake commented at 11:49 AM on November 12, 2026:
      connections opened for that added node. (#35940)
    

    w0xlt commented at 7:09 PM on November 12, 2026:

    Done. Thanks.

  13. w0xlt force-pushed on Nov 12, 2026
  14. net: add bip152hb permission flag
    Add a "bip152hb" permission that can be granted with -whitelist and
    -whitebind, and that is reported by getpeerinfo. The next commit uses it
    to request BIP152 high-bandwidth compact block announcements from such
    peers, so operators can apply topology knowledge (for example a
    low-latency link to another node they run) that the automatic
    high-bandwidth peer selection cannot have.
    
    Unlike the existing flags, this one grants the peer nothing and only
    makes us request extra announcements. It is therefore not part of
    "all", which would otherwise increase bandwidth usage for existing
    configurations.
    
    The flag has no effect yet.
    d4d294fb0f
  15. w0xlt force-pushed on Nov 12, 2026
  16. DrahtBot added the label CI failed on Nov 12, 2026
  17. DrahtBot commented at 9:17 PM on November 12, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task macOS native, fuzz: https://github.com/bitcoin/bitcoin/actions/runs/43301840898/job/131474760807</sub> <sub>LLM reason (✨ experimental): The CI failed because the cmpctblock fuzz target hit an assertion (num_hb <= 3) while processing corpus input 46958d….</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  18. net_processing: request high-bandwidth mode from bip152hb peers
    Bitcoin Core automatically selects up to three BIP152 high-bandwidth
    peers after they deliver new blocks. That selection cannot use topology
    information known to the operator, e.g. a stable low-latency link to
    another node they run, which should announce compact blocks immediately
    and consistently, including after reconnects.
    
    For peers with the bip152hb permission, request high-bandwidth mode in
    the SENDCMPCT message sent at VERACK, so that this applies to every
    connection to such a peer. Keep these peers out of
    lNodesAnnouncingHeaderAndIDs: they are additional to the three
    automatically selected peers and must not displace them. As for the
    automatic selection, never request high-bandwidth mode in -blocksonly
    mode.
    
    Combined with the existing "out" whitelist direction, this lets an
    operator configure an added node as high-bandwidth, e.g.
    -addnode=203.0.113.5 -whitelist=bip152hb,out@203.0.113.5
    
    The cmpctblock fuzz target asserted that there are at most three
    high-bandwidth peers. Only count automatically selected ones there, and
    check that peers with the permission are high-bandwidth once the
    handshake completes.
    d460936ff2
  19. init: reject bip152hb permission with -blocksonly
    High-bandwidth compact block announcements are never requested in
    -blocksonly mode, because our mempool would not contain the transactions
    needed to reconstruct the blocks. Fail at startup when -whitelist or
    -whitebind grants the bip152hb permission in that mode, rather than
    silently ignoring the operator's configuration.
    a2de0d0909
  20. doc: add release note for bip152hb permission c29c91f5f2
  21. w0xlt force-pushed on Nov 12, 2026
  22. w0xlt commented at 10:56 PM on November 12, 2026: contributor

    Thanks @davidgumberg for the suggestion! I've reworked the PR to add a bip152hb permission instead of the -addnode suffix:

    -addnode=203.0.113.5 -whitelist=bip152hb,out@203.0.113.5
    

    The diff is a lot smaller now: there's no extra -addnode parsing and no code to match connections against added nodes.

    As a bonus, it now also works with the addnode RPC and -connect, can cover several nodes with one subnet entry (e.g. bip152hb,out@10.0.0.0/24), and can apply to inbound connections from those addresses.

    Two trade-offs:

    • Whitelist entries only match IPs and subnets, so an addnode given as a hostname, or a connection made through a name proxy, can no longer get high-bandwidth mode.
    • bip152hb isn't included in all: unlike the other flags it grants the peer nothing and only costs us bandwidth. It's also rejected with -blocksonly, where high-bandwidth mode is never requested.

    I think losing hostnames is acceptable so I pushed a new version.

  23. w0xlt commented at 11:00 PM on November 12, 2026: contributor

    PR description updated.

  24. w0xlt renamed this:
    net: allow selecting BIP152 high-bandwidth peers with `-addnode`
    net: add bip152hb permission to select BIP152 high-bandwidth peers
    on Nov 12, 2026
  25. DrahtBot removed the label CI failed on Nov 12, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-27 03:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me