doc: clarify RPC addnode 'add' vs 'onetry' connection limits #36719

pull Snan0M wants to merge 2 commits into bitcoin:master from Snan0M:netinfo-peer-count-width changing 2 files +5 −4
  1. Snan0M commented at 2:36 PM on October 31, 2026: none

    Clarifies the addnode RPC help on the separate limits for add and onetry: add entries are capped by MAX_ADDNODE_CONNECTIONS, onetry connections are not.

    Also fixes -netinfo: the manual peer count is uint8_t while the other counts are uint16_t, so it wraps at 256. This is reachable via addnode onetry, which is not subject to the MAX_ADDNODE_CONNECTIONS cap.

  2. DrahtBot added the label Scripts and tools on Oct 31, 2026
  3. DrahtBot commented at 2:36 PM on October 31, 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
    ACK jonatack, w0xlt

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. pinheadmz commented at 2:36 PM on October 31, 2026: member

    You just opened 3 PRs really fast. Lets stop there ok? Give us time to digest them

  5. in src/bitcoin-cli.cpp:390 in feeb2fdccf outdated
     385 | @@ -386,8 +386,8 @@ class NetinfoRequestHandler : public BaseRequestHandler
     386 |  {
     387 |  private:
     388 |      std::array<std::array<uint16_t, NETWORKS.size() + 1>, 3> m_counts{{{}}}; //!< Peer counts by (in/out/total, networks/total)
     389 | -    uint8_t m_block_relay_peers_count{0};
     390 | -    uint8_t m_manual_peers_count{0};
     391 | +    uint16_t m_block_relay_peers_count{0};
     392 | +    uint16_t m_manual_peers_count{0};
    


    jonatack commented at 4:23 PM on November 1, 2026:

    For block relay peers, the steady state should be limited to around 2, with only brief extras that are actively evicted.

    For addnode peers, persistent connections are capped at 8.

    RPC addnode onetry can bypass this limit, but exceeding 255 seems unrealistic under ordinary operation, limited by:

    • file descriptors
    • system resources (memory and CPU for the extra CNode objects and peer processing)
    • distinct reachable peers that accept the connection

    Exceeding 255 onetry connections might perhaps be an intentional stress/abuse scenario more than normal node behavior.

    So, tentative ACK on this change for the manual peers counter and NACK on the block relay one.

    The RPC addnode help could perhaps be clarified about the separate limits for add and onetry; for instance:

    --- a/src/rpc/net.cpp
    +++ b/src/rpc/net.cpp
    @@ -347,12 +347,14 @@ static RPCMethod addnode()
             "addnode",
             "Attempts to add or remove a node from the addnode list.\n"
                     "Or try a connection to a node once.\n"
                     "Nodes added using addnode (or -connect) are protected from DoS disconnection and IBD block stalling\n"
                     "disconnection, and are not required to be full nodes or support SegWit as other outbound peers are (though\n"
                     "such peers will not be synced from).\n" +
    -                strprintf("Addnode connections are limited to %u at a time", MAX_ADDNODE_CONNECTIONS) +
    -                " and are counted separately from the -maxconnections limit.\n",
    +                strprintf("Persistent addnode connections (command 'add') are limited to %u at a time", MAX_ADDNODE_CONNECTIONS) +
    +                " and are counted separately from the -maxconnections limit.\n"
    +                "The 'onetry' command attempts a connection once and does not count against this limit.\n",
                     {
                         {"node", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP address/hostname optionally followed by :port of the peer to connect to"},
    -                    {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once"},
    +                    {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'add' to add a node to the persistent list (limited to " + std::to_string(MAX_ADDNODE_CONNECTIONS) + "), 'remove' to remove a node from the list, 'onetry' to try a connection to the node once (does not count against the limit)"},
                         {"v2transport", RPCArg::Type::BOOL, RPCArg::DefaultHint{"set by -v2transport"}, "Attempt to connect using BIP324 v2 transport protocol (ignored for 'remove' command)"},
                     },
    

    Snan0M commented at 8:12 PM on November 1, 2026:

    Thanks @jonatack. Reverted the block-relay counter to uint8_t and kept uint16_t for the manual peer count only. I also took your suggested addnode RPC help clarification (add vs onetry) as a separate commit.

  6. jonatack commented at 4:29 PM on November 1, 2026: member

    (If this moves forward, the PR description should state why the manual peer counter might exceed 255 to justify the change.)

  7. Snan0M force-pushed on Nov 1, 2026
  8. Snan0M renamed this:
    cli: use uint16_t for -netinfo block-relay and manual peer counts
    cli: use uint16_t for -netinfo manual peer count
    on Nov 1, 2026
  9. jonatack commented at 8:54 PM on November 1, 2026: member

    @Snan0M Can you please squash the first and last commits (and verify the commit title and message body)?

  10. cli: use uint16_t for -netinfo manual peer count
    The other -netinfo peer counts are uint16_t, but the manual peer count
    was uint8_t and wraps at 256. Manual peers aren't limited to the 8
    -addnode slots (addnode onetry connections also count as manual and are
    not subject to MAX_ADDNODE_CONNECTIONS), so the count can reach that and
    the "manual" column then disappears or shows a wrapped value.
    e46bcd40bb
  11. rpc: clarify addnode 'add' vs 'onetry' connection limits
    Persistent addnode connections added with the 'add' command are capped at
    MAX_ADDNODE_CONNECTIONS, while 'onetry' connections are not subject to
    that limit. Say so in the addnode RPC help.
    4c4970a696
  12. Snan0M force-pushed on Nov 1, 2026
  13. Snan0M commented at 9:23 PM on November 1, 2026: none

    @Snan0M Can you please squash the first and last commits (and verify the commit title and message body)?

    Done, squashed

  14. jonatack commented at 9:36 PM on November 1, 2026: member

    ACK 4c4970a69646231a1b443caa3c0c57aa012e4d89

    Perhaps update the PR title to doc: clarify RPC addnode 'add' vs 'onetry' connection limits (and mention the -netinfo change in the PR description body instead), as ISTM the doc change is the more interesting one.

  15. Snan0M renamed this:
    cli: use uint16_t for -netinfo manual peer count
    doc: clarify RPC addnode 'add' vs 'onetry' connection limits
    on Nov 1, 2026
  16. Snan0M commented at 9:44 PM on November 1, 2026: none

    Thanks, updated the title and moved the -netinfo change into the description.

  17. w0xlt commented at 12:57 AM on November 6, 2026: contributor

    ACK 4c4970a69646231a1b443caa3c0c57aa012e4d89

  18. sedited requested review from vasild on Nov 6, 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-07 15:51 UTC

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