Skip to content

net: --connect peers are manual, as in Core - #876

Merged
reardencode merged 2 commits into
reardencode:masterfrom
bkeroack:net/connect-peers-manual
Oct 4, 2026
Merged

reardencode merged 2 commits into
reardencode:masterfrom
bkeroack:net/connect-peers-manual

Conversation

@bkeroack

@bkeroack bkeroack commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #819.

Problem

getpeerinfo reports a peer dialled for --connect as outbound-full-relay. Bitcoin Core opens every -connect address as ConnectionType::MANUAL and reports it as manual.

Fix

Both dial paths for --connect targets now use PeerConnType::Manual:

  • the tip-follow dial of the pinned targets in run.rs, through a new P2PNode::follow_from_net_as(peer, typ) (follow_from_net keeps OutboundFullRelay for its other callers);
  • the redial of remembered --connect hostnames in PeerHub::redial_remembered_with. addnode add and --connect hosts now redial the same way, so remembered_redials drops the per-host type.

The connection type feeds more than the label. For a --connect peer:

Reader Before After Core
is_preferred_download (whether a stalled headers-sync peer can be replaced) counted, as outbound-full-relay counted: Manual added fPreferredDownload counts manual peers
--seednode addr-fetch: the startup dial (empty addrman) and the 10 s fallback (fires below 2 live outbound-full-relay peers) the fallback was held off by 2+ live --connect peers; the startup dial ran whenever addrman was empty neither runs under --connect never dials seednodes under -connect
expect_services_from_conn (NODE_NETWORK required) required not required ExpectServicesFromConn is false for MANUAL

The stale-tip rotation already skips --connect, so the outbound_full_relay_* helpers it uses are unaffected.

Adding Manual to is_preferred_download also covers the second case in #819: a node whose outbound peers all come from addnode could never replace a stalling headers-sync peer.

Tests

  • node_run_p2p_short (product run_p2p --connect) asserted connection_type == "outbound-full-relay". It now asserts "manual".
  • redial_same_endpoint_in_addnode_and_connect_dials_once: a --connect-only host must redial as Manual.
  • session_heartbeat_replaces_stalled_headers_sync_peer_only_with_another_preferred (renamed from ..._keeps_sole_preferred_...): the sole preferred sync peer is still kept; once a Manual peer is live, the stalled sync peer is replaced.
  • follow_dial_targets_connect_bypasses_diversity asserts follow_dial_type. New seednodes_are_off_under_connect covers seednodes_allowed, the guard both seednode paths share.

Each new assertion fails when its guard is reverted.

Ran locally: cargo fmt --check, ./scripts/ast-grep.sh, cargo clippy --workspace --all-targets -- -D warnings, the rbitcoin-net peers:: tests, the rbitcoin-node run:: tests, and node_run_p2p_short.

Not changed

is_preferred_download still leaves out Core's other preferred cases (feelers, inbound peers with noban), and it does not check that the peer can serve blocks.

Literal --connect addresses (IP, onion, I2P, CJDNS) are dialled once at startup and not redialled after the session drops. Only --connect hostnames go into the 2 s redial loop (set_connect_hosts(config.listen.connect_dns…) in run.rs). That is separate from #819 and unchanged here.

🤖 Generated with Claude Code

bkeroack and others added 2 commits October 2, 2026 18:14
getpeerinfo reported a --connect peer as outbound-full-relay. Core opens
every -connect address as ConnectionType::MANUAL. Both dial paths now
use Manual: the tip-follow dial of the pinned targets and the redial of
remembered --connect hostnames.

The type is read by more than the RPC label, so the readers follow Core:

- is_preferred_download counts Manual, as Core's fPreferredDownload
  does. Otherwise a node dialled only through --connect (or addnode, as
  today) never replaces a stalling headers-sync peer.
- The 10 s --seednode fallback no longer runs under --connect. It fired
  when fewer than 2 outbound-full-relay peers were live, which manual
  --connect peers would never satisfy. Core never dials seednodes under
  -connect.
- Manual peers are not held to the NODE_NETWORK service check, as in
  Core's ExpectServicesFromConn.

Fixes reardencode#819.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The previous commit kept the 10 s seednode fallback off under --connect,
but the startup dial (empty addrman) still ran. That happens when every
--connect target is a hostname that does not resolve and peers.dat is
empty. Both paths now share seednodes_allowed, which is false under
--connect, as Core never dials seednodes under -connect.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@reardencode
reardencode merged commit 3219620 into reardencode:master Oct 4, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getpeerinfo reports --connect peers as outbound-full-relay; Bitcoin Core reports them as manual

2 participants