mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
net: add bip152hb permission to select BIP152 high-bandwidth peers #35940
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!35940
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/addnode-bip152-hb"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
bip152hbnet permission:For a peer with this permission, the node requests high-bandwidth mode in the existing
SENDCMPCTmessage sent atVERACK, so it applies to every connection to that peer and requires no new P2P messages. It works with the existing-whitelist/-whitebindsemantics:outapplies to manual connections (-addnode,-connect,addnodeRPC),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:
bip152hbis not included inall: unlike the other flags it grants the peer nothing and only costs bandwidth, so existingall@configurations are unaffected.-blocksonly, where high-bandwidth mode is never requested.Earlier versions of this PR used an
-addnode=<host>=bip152-hbsuffix; it was reworked into a permission following review (https://github.com/bitcoin/bitcoin/pull/35940#issuecomment-6811490029).The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
clang-tidyoptin.performance.Paddingby 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.
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
-addnodealso made more sense to me than creating a dedicated option.shouldn't this be renamed to
release-notes-35940.mdbefore merge?Done. Thanks.
Earlier concerns remain unresolved; see the Run archive linked from the Review report.
🟠 Minor · PR description advertises an unimplemented addnode suffix
The description advertises an addnode-only suffix, but the implementation exposes an address/listener permission that can also select explicitly permissioned inbound, RPC-created, and
-connectpeers.Location:
src/net_permissions.cpp:59(head).Review coverage was incomplete.
Reviewed:
c29c91f5f254· Review report · Previous reportspermalink
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.
Following the same pattern as in the
test_empty_addnodein 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`).We could add the test case where a configured peer disconnects and reconnects again on its own is granted the high-bandwidth mode again.
Thanks! Added in
0b54bdbfeb,Thanks, good idea! Added in
0b54bdbfeb, with a small change: rather than restarting node 2, the test disconnects it and reconnects withaddnode ... onetry. Otherwise the addnode thread can take up to 60s to retry.Concept ACK, but I think it might make more sense to do this as a whitelist permission.
Done. Thanks.
🚧 At least one of the CI tasks failed.
Task
macOS native, fuzz: https://github.com/bitcoin/bitcoin/actions/runs/43301840898/job/131474760807LLM reason (✨ experimental): The CI failed because the
cmpctblockfuzz target hit an assertion (num_hb <= 3) while processing corpus input46958d….Hints
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.
Thanks @davidgumberg for the suggestion! I've reworked the PR to add a
bip152hbpermission instead of the-addnodesuffix:The diff is a lot smaller now: there's no extra
-addnodeparsing and no code to match connections against added nodes.As a bonus, it now also works with the
addnodeRPC and-connect, can cover several nodes with one subnet entry (e.g.bip152hb,[email protected]/24), and can apply to inbound connections from those addresses.Two trade-offs:
bip152hbisn't included inall: 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.
PR description updated.