Review report

core: PR #30951

1 minor finding · 3 suggestions

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Findings

Link

[minor] · Scheduled probes select clearnet addresses that the v2-only guard later skips

With -v2onlyclearnet, scheduled feeler and extra-peer attempts can select v1-only clearnet addresses and then skip them, reducing those probes for opt-in nodes.

Location: src/net.cpp:450 (head).

Details and suggested fix

ThreadOpenConnections advances the feeler or extra-peer timer before selecting an address. Its selection checks do not exclude clearnet addresses lacking NODE_P2P_V2, so one can be selected and then skipped by the guard in OpenNetworkConnection. The scheduled attempt does nothing until the timer fires again.

Because the skip occurs before addrman.Attempt(), it does not update m_last_try or nAttempts, so addrman does not lower the entry's selection weight. A tried-table collision with a v1-only clearnet entry can also be returned repeatedly by SelectTriedCollision() until ResolveCollisions() evicts it after ADDRMAN_TEST_WINDOW.

The PR description reports that about 81% of addrman entries advertise v2, but static review cannot establish the share of actual selections affected. Keep the connection guard as a backstop, and also exclude ineligible candidates during selection. For feelers, fall back to Select(true, ...) when a tried-collision candidate is ineligible; simply continuing could select the same collision again.


Optional improvements

Link

[suggestion] · The new test does not exercise v1 retry suppression or the name-proxy branch

The added tests would still pass if clearnet peers retried with v1 or unresolved hostnames were misclassified for a name proxy.

Location: test/functional/p2p_v2_encrypted.py:144 (head).

Details and suggested fix

The SOCKS proxy in this test has no destinations_factory; it reports success but serves no destination, while keep_alive holds the socket open. The v2 check therefore shows only that ConnectNode created a CNode. No handshake completes, so ShouldReconnectV1() never becomes true and the DisconnectNodes branch that suppresses the v1 retry is not reached. The existing downgrade case runs before the option is set and uses 127.0.0.1, which is exempt.

The test also uses only numeric or .onion destinations, so it does not cover RequiresV2Dest for an unresolved hostname sent through a name proxy. Reuse the harness from p2p_private_broadcast_retry_v1.py to assert a v2 attempt and no v1 retry for a clearnet peer, with an onion control where retry remains allowed. Add an unresolved-hostname addnode case with v2transport=false through -proxy; optionally, use a v2-capable listener to assert the negotiated transport.


Link

[suggestion] · The non-routable v1 exemption is broader than the comment and help text describe

With -v2onlyclearnet, v1 remains allowed for all non-routable IPv4/IPv6 peers, including forwarded inbound peers, not just LAN traffic.

Location: src/net.h:1441 (head).

Details and suggested fix

RequiresV2Peer() uses the peer's network class, and GetNetClass() returns NET_UNROUTABLE for any address that is not routable. This includes loopback, RFC1918 and RFC6598 addresses, among others, so v1 remains allowed in both directions for all of them. Addrman rejects non-routable addresses, limiting this behavior to manual and inbound connections rather than automatic outbound ones.

The release note mentions LAN and loopback, but the -help text says only that inbound v1 connections from clearnet peers are disconnected. The comment here says non-routable traffic never leaves the LAN, which is not true for RFC6598 traffic crossing ISP equipment or for remote peers whose source is rewritten by a local forwarder or reverse proxy. Update the comment to describe the !IsRoutable() set, and clarify the exemption and forwarded-inbound caveat in -help.


Link

[suggestion] · A v1 addnode request for a clearnet peer is accepted but never connects

With -v2onlyclearnet, a manual v1 request for a clearnet peer is skipped, and the operator receives no immediate explanation unless network debug logging is enabled.

Location: src/net.cpp:451 (head).

Details and suggested fix

addnode ... onetry returns success regardless of whether a connection is opened. addnode ... add stores the entry with use_v2transport=false, and ThreadOpenAddedConnections retries it about every 60 seconds. Each attempt hits this guard, returns nullptr, and emits only a BCLog::NET debug message; getaddednodeinfo reports connected=false.

The RPC already rejects a request for v2 transport when -v2transport is disabled. Add a corresponding check for v2transport=false when LookupNumeric resolves the node string to an address for which connman.RequiresV2Peer(addr.GetNetClass()) is true, and return RPC_INVALID_PARAMETER naming -v2onlyclearnet. Hostnames cannot be classified at RPC time and would still reach this skip; whether to error or warn for those is a policy choice.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.