#35040 Remove CNode dependency for local address functions and introduce LocalAddressManager

ReviewabilityReviewsAgreementSize
#35040 theuni Remove CNode dependency for local address functions and introduce LocalAddressManagerAuthor silent 199d0Mild346 + 75 tests
  • Untangle local address tracking and scoring from peer connection handles
  • Enable testing and fuzzing address advertisement logic without manipulating global state
  • Help clean separation between networking code and peer processing
  • Needs rebase and CI is failing
  • Author has been silent for 154 days after moving to draft to resolve circular dependencies
  • No review verdicts recorded
  • Limited feedback with no formal approvals yet
  • Nonblocking objection: new node library file belongs in src/node/ rather than top level (maflcko)
  • 346 lines added or modified outside tests
  • 75 lines added or modified in tests
  • 406 lines removed in total
  • 23 files, 23 commits
P2P#52 of 71
P3 · cleanup
  • P3 because it is an internal refactoring that does not alter peer-to-peer wire protocol behavior
  • Improves testability of address selection and helps untangle networking from peer processing
  • Ranking pass: Ranked with the other net/net_processing restructuring PRs it shares scope with.
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Decouples local network address management from `CConnman` and `CNode` by introducing a dedicated `LocalAddressManager` class. Moves local address tracking and reachability calculation out of `net` and `netaddress` into `src/local_addresses.{h,cpp}`, and updates callers and tests to interact with `LocalAddressManager` without requiring a full `CNode` instance.

Problem: Local address management logic—used to select and score our own address to advertise to peers—relied heavily on globals (`mapLocalHost`) and took `CNode` references despite having no conceptual tie to connection management. This hindered testing and fuzzing without global state manipulation and blocked clean separation between networking and peer processing.

Evidence of importance:

  • Part of the net/net_processing split project (#33958)
  • Author states: 'Because local address management is unrelated to CConnman, its reliance on them (via CNode) is removed... All functionality is still global in scope, though LocalAddressManager is now instantiated when possible for testing and fuzzing'

Scope: Refactoring across 23 commits creating two new files (`local_addresses.{h,cpp}` and temporary `netglobals.{h,cpp}`). Changes call sites across RPC, init, torcontrol, connman, and unit/fuzz tests.

Reviewability

Stale · Author silent 199d

No author activity for 199 days; a review may wait a long time for a response.

Agreement

Mild

objection that needs an answer has none yet (maflcko)

Thread notes: Initial record. maflcko suggested moving new files to src/node/ in response to the author's inquiry; the author subsequently converted the PR to draft to address a non-trivial circular dependency.

Objections, suggestions, and questions:

ReviewerTypeHarm, request, or questionStatusMust beAuthor repliedQuote
maflcko (member)objection, maintenancenew file for bitcoin_node library is placed in the top-level directory rather than src/node/open · v1, not yet re-checkedansweredno2026-04-09: 'You are adding a new file to `bitcoin_node` lib, so it should be in the node folder'

Participants:

  • fjahr (contributor, neutral, 1 statements 2026-04-09 to 2026-04-09): noted a typo in the PR title
  • maflcko (member, objection, 1 statements 2026-04-09 to 2026-04-09): suggested placing the new file in the node directory

Dependencies

Enables:

  • Removing CNode dependency from GetLocalAddrForPeer and moving addrLocal into Peer/PeerManagerImpl
  • Passing LocalAddressManager options explicitly rather than relying on globals (fListen, fDiscover, fLogIPs)

Files

209 lines under test/bench/ci.

  • src/local_addresses.cpp +191/-0
  • src/test/net_tests.cpp +51/-120
  • src/net.cpp +20/-144
  • src/netaddress.cpp +0/-78
  • src/local_addresses.h +66/-0
  • src/net.h +0/-34
  • src/test/fuzz/net.cpp +14/-12
  • src/netglobals.h +22/-0
  • src/netaddress.h +10/-4
  • src/netglobals.cpp +13/-0
  • src/torcontrol.cpp +4/-3
  • src/node/interfaces.cpp +2/-4
  • src/rpc/net.cpp +4/-2
  • src/test/fuzz/util/net.h +5/-0
  • src/init.cpp +3/-1
  • src/net_processing.cpp +3/-1
  • src/test/util/setup_common.cpp +3/-1
  • src/mapport.cpp +2/-1
  • src/test/fuzz/netaddress.cpp +2/-1
  • src/CMakeLists.txt +2/-0
  • src/qt/clientmodel.cpp +2/-0
  • src/interfaces/node.h +1/-0
  • src/qt/rpcconsole.cpp +1/-0

Card

The short text the ranking pass compares across PRs.

Introduces a `LocalAddressManager` class in `src/local_addresses.{h,cpp}` and removes `CNode` dependencies from local address lookup functions. Previously, local address management relied on globals (`mapLocalHost`) and required `CNode` instances despite being conceptually independent from `CConnman`, making unit and fuzz testing cumbersome. This refactoring is part of the ongoing net/net_processing architectural split (#33958) and unblocks moving peer-specific address advertising logic into `PeerManager`.

Data

dossier JSON · extract JSON · model ledger, generated 2026-09-18T03:28, confidence high, input hash 4b5c9e5342b26424
thread read through 2026-04-10 (5 statements), head dd8968cbd9
Discussion read under schema 1 rules: suggestions and questions may be missing, and an objection may combine several harms (schema history).
labels: Needs rebase, CI failed · draft

Categories

P2P

P3 · cleanup (ranking pass: Ranked with the other net/net_processing restructuring PRs it shares scope with.)

Decouples local address management from CConnman and CNode into a dedicated LocalAddressManager as part of the net/net_processing split (#33958). It reduces global state dependencies and improves unit testability and fuzzing without modifying peer-to-peer wire protocol behavior.

Membership: Extracts local address management logic and reachability scoring from net and netaddress into src/local_addresses.{h,cpp}.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 2