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)"},
},