net: prevent duplication manual connections (take 2)

bitcoin/bitcoin: PR #35600

3 suggestions

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

Optional improvements

Link

[suggestion] · Equivalent hostname spellings get separate reservations

The documented raw-hostname scope leaves a pre-existing duplicate-dial case for names with omitted versus explicit default ports or different case, although normalizing those forms requires no DNS lookup.

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

Details and suggested fix

ManualConnectionKey() returns ordinary DNS names unchanged, so peer.example and peer.example:<default port> reserve different keys, as do Peer.Example and peer.example. Overlapping attempts can both pass the exact-string connected-name check. Local resolution only checks published peers; name-proxy connections have no resolved endpoint to check. Normalize unresolved DNS reservation keys to a lowercased host and effective port using SplitHostPort() with GetDefaultPort(dest), while retaining the original destination for dialing. This closes the spelling-only overlap without resolving aliases or adding DNS lookups. Extend check_pending_attempt() with example.invalid versus example.invalid:18444; its current hostname case uses identical strings.


Link

[suggestion] · In-progress rejection discards queued manual fallbacks

Overlapping manual dials can discard a queued v1 fallback or return early from onetry; production impact is unconfirmed, and no in-tree caller relying on onetry completion was found.

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

Details and suggested fix

DisconnectNodes() removes the old manual peer before queueing its v1 fallback. Another manual dial can reserve the destination before PerformReconnections() drains that item. This branch then returns false without dialing, and the fallback is discarded. If the holder fails before creating a node, it cannot generate a replacement fallback. Persistent -connect/-addnode entries can recover through later attempts, but standalone onetry has no such scheduler entry.

Return a distinct in-progress status so PerformReconnections() can retain the item for a later pass without requeueing into the current drain loop. Also document the overlap result in the API and RPC contracts: onetry currently ignores the result and returns null while the holder remains pending, as the new test asserts. Base already allowed already-connected no-ops, so null was never a connection-success guarantee.


Link

[suggestion] · Proxy and Future waits ignore the timeout factor

The new functional test uses unscaled ten-second socket and Future waits, making slow CI runs more timing-sensitive; no flaky run has been demonstrated.

Location: test/functional/p2p_duplicate_manual_connections.py:104 (head).

Details and suggested fix

proxy.settimeout(10) and both result(timeout=10) calls bypass --timeout-factor, which CI defaults to 40 for slow environments such as sanitizer builds. Multiply all three limits by self.options.timeout_factor so accepting the local proxy connection and waiting for RPC completion receive the requested allowance. The framework already converts a factor of zero to 999. This reduces test-side timing sensitivity but does not remove the node's independent twenty-second SOCKS receive timeout, which still bounds the held handshake.


Coverage details

Earlier concerns

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