Repository navigation
Description
The configuration of a CometBFT node includes the following parameter, part of the p2p section:
# Maximum number of outbound peers to connect to, excluding persistent peers
max_num_outbound_peers = 10
This parameter is employed by the PEX reactor, responsible for peer discovery, which feeds the node's address book with the address of potential peers, and for dialing such potentially peers. In practical terms, the MaxNumOutboundPeers defines the target number of peers with which a node should establish outbound connections. So, while the number of peers to which the node is currently dialing plus the number of established outbound connections is inferior to MaxNumOutboundPeers, the PEX reactor will instruct the p2p layer to dial peers in order to reach this target (additional details here).
Note that in nodes where the PEX reactor is disabled, this parameter has no effect, as it is intended to control the automatic discovery and dialing of potential peers. Moreover, as documented in the above extract of the configuration file, the parameter does not apply for peer addresses manually configured, mainly through the persistent_peers parameter.
The p2p section of hte configuration of a CometBFT node also includes the following parameter:
# Comma separated list of nodes to keep persistent connections to
persistent_peers =
The peers with addresses configured with this parameter are peers with which the node must be connected. Although there is some debate about the semantics of this parameter, the current design of the p2p layer considers a persistent peer as a peer to which the node is either: (i) connected, or (ii) attempting to establish a connection. The second state (attempting to reconnect) includes some sleeping time (linear then exponential back-off) between connection attempts (additional details here).
The above described behavior applies to every peer configured as persistent peer. As a result, the node is expected to establish connections to all peers configured as so, thus disregarding the value configured for the MaxNumOutboundPeers parameter.
This issue was pointed out in the comments for #486.
The main argument is that the MaxNumOutboundPeers should define the de facto maximum number of peers with which a node maintains outbound connections (namely, to which it dials). This would mean that this parameter should not be a PEX parameter, applying only when dialing to discovered peers, but a general parameter of the p2p layer, applying both for discovered peers and manually configured peers - as it already happens with the companion MaxNumInboundPeers parameter.
A derived discussion is the expected semantics for a peer configured as persistent. In order to render MaxNumOutboundPeers a hard limit, a node should not dial (to connect or reconnect to) a configured persistent peer address in the case in which the successful establishment of such outbound connection would violate the configured MaxNumOutboundPeers limit. This requires rephrasing the semantic for persistent peers, as they would become peers to which the node should maintain a persistent connection given that there are available slots for outbound connections (i.e., less than MaxNumOutboundPeers are taken).
The goal of this issue is therefore discuss the reported scenario and to consider ways of aligning the behavior of the p2p layer with the users' expectations.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
cason commentedon Sep 7, 2023
This topic was discussed on the CometBFT Community call that took place this Thursday, September 7th. The call was recorded and the recording can be made available to who is interested.
In summary, the feedback we collected from the attendees is that maintaining a separation between the manual configuration of peers to which to maintain connections (
persistent_peers) and the bound of connections a node is expected to establish with randomly sampled peers it discovers (max_num_outbound_peers) should be maintained.The follow-up discussion revolved around how we can define a form of "preferred peers", a way for the operator to influence the selection of peers to which the node connects, as this operation respects the configured maximum number of outbound connections to establish. Those peers, however, are not assumed to be persistent, as in the node is not expected to necessarily maintain connections (reconnecting, if needed) with them.
cason commentedon Sep 7, 2023
The addition of a "bootstrap_peers" configuration flag is discussed on issue #1016.
While this is not an exact match to the discussed concept of "preferred peers", it is very similar and should be considered.
cason commentedon Mar 6, 2024
I think we can close this issue.