1 minor finding · 3 suggestions
Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.
Findings
[minor] · Relay preference also evicts useful stale-tip recovery peers
After IBD and outside -blocksonly, a non-relaying stale-tip recovery peer can deliver a new block and then be evicted before non-announcing relaying peers, sacrificing that round's rotation without preventing block delivery.
Location: src/net_processing.cpp:5646 (head).
Details and suggested fix
GetTryNewOutboundPeer() opens an OUTBOUND_FULL_RELAY connection, so stale-tip recovery uses this comparator too. If the recovery peer declines transaction relay and shares its network with another full/manual outbound, no_tx_relay outweighs its recent block announcement. Once it passes MINIMUM_CONNECT_TIME and has no blocks in flight, it is disconnected and SetTryNewOutboundPeer(false) ends the round. At base, announcement recency instead selected an eligible non-announcing peer for eviction. Block-relay-only rotation is unchanged, and the frequency of this scenario is unmeasured.
Consider suppressing the preference while GetTryNewOutboundPeer() is set, leaving transaction-relay replacement to a later round. Otherwise, document explicitly that transaction-relay coverage takes precedence over rotating non-announcers even during stale-tip recovery. Making recency the first key globally would undermine the intended replacement mechanism.
Optional improvements
[suggestion] · Protection exclusion also changes IBD behavior
Outside -blocksonly, non-relaying full outbounds lose m_protect eligibility during IBD too, contrary to the stated scope, although peers that keep up with our chain avoid chain-sync timeouts.
Location: src/net_processing.cpp:3209 (head).
Details and suggested fix
The new grant condition requires m_opts.ignore_incoming_txs || pfrom.m_relays_txs without an IBD exception. A peer that previously qualified for protection can therefore become subject to chain-sync timeout disconnection if synchronization has started and it subsequently remains behind through both timeout stages. It can also become eligible for extra-peer eviction. The practical difference during IBD is limited because useful peers are normally ahead of us. Clarify in the PR description and protection comment that this exclusion applies during IBD as well. Explain that protection persists until peer finalization: adding an IBD exception to the grant alone would leave these peers protected after IBD and prevent their replacement.
[suggestion] · Low connection limits leave no permit for replacement
With -maxconnections at most 10 and all outbound targets filled, the inherited semaphore limit prevents connect-before-evict replacement, even when the replacement request is set.
Location: src/net.cpp:2858 (head).
Details and suggested fix
ThreadOpenConnections() acquires semOutbound before counting peers or selecting the replacement branch. For automatic limits at most ten, the full-relay and block-relay targets together equal the semaphore capacity, and established peers retain their grants. For example, -maxconnections=2 leaves two full-relay peers holding both permits, so a stable pair cannot acquire a third connection for replacement. The new functional test checks request logging and continued connectivity, not an actual replacement. Explicitly document that this feature requires spare outbound capacity. Supporting saturated low-capacity configurations would require a separately considered fallback rather than relying on the request flag to make progress.
[suggestion] · Added tests do not exercise the replacement-request consumer
The unit test inserts the replacement manually, and the functional test disables automatic connections, so deleting the new ThreadOpenConnections() selection branch would leave their assertions intact.
Location: test/functional/p2p_blocksonly.py:95 (head).
Details and suggested fix
p2p_blocksonly.py inherits disable_autoconnect = True, which writes connect=0 and prevents CConnman::Start() from starting ThreadOpenConnections(). The test checks the replacement-request log and pings the existing peers. Meanwhile, no_tx_relay_peer_replacement calls AddRandomOutboundPeer() to supply the replacement directly. Neither exercises the new timer, count condition, or flag read. Add a functional case with automatic connections enabled and spare outbound capacity that observes a replacement handshake before eviction. Keep the existing request-generation and eviction-selection checks.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Eviction comments still describe announcement-only ordering (earlier report)
Background
Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.
Documented decisions
Reassigning or preferentially selecting blocksonly peers for block-relay-only slots was considered, but raised a separate diversity concern.
In #16418, sdaftuar argued that all outbound selections should seek diversity in the hope of retaining at least one honest peer. Preferentially choosing blocksonly nodes for block-only slots could concentrate those connections in a smaller population; downgrading an existing connection also raised complexity and possible selection-bias concerns. This explains why replacing a non-relaying full outbound need not imply converting it into a block-relay-only connection. The narrower #28538 proposal explicitly left those block-only connections unaffected.
Unresolved disagreements
The inspected historical record does not establish an empirically justified tolerance for non-relaying full outbounds.
The 2019 discussion suggested allowing two or three such peers; #28538 instead proposed using full-relay slots for transaction participants and listed a one-or-two-peer allowance as an unimplemented, more complex alternative. The privacy objection favored more transaction links but expressly lacked exact numbers. These are competing policy positions relevant to relay coverage versus selection diversity; the inspected sources provide neither a measured optimum nor a general resolution beyond the concrete protection and singleton compromises.