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

full analysis

https://github.com/bitcoin/bitcoin/pull/35040 · theuni · +421/-406 in 23 files, 23 commits · labels: Needs rebase, CI failed · draft

Goal

  • Untangle local address discovery and self-advertisement logic from networking globals
  • Improves unit testability and fuzzing while supporting the net and net_processing separation

Extracts node local address discovery and self-advertisement logic out of net.cpp into a new LocalAddressManager class. Removes the CNode dependency from address resolution functions, allowing them to be instantiated and scoped cleanly for unit tests and fuzzing.

Problem: Local address management logic is currently entangled with CNode and CConnman globals in net.cpp, complicating both testing and the ongoing net/net_processing separation project.

Category: P2P (#53 of 65)

P3 · cleanup

  • P3 because it carries no user-visible behavior change or bug fix
  • Improves testability and scoping for P2P networking code
  • Unblocks the broader separation of net and net_processing

Extracts address management out of CConnman/CNode into LocalAddressManager as part of the net/net_processing split. It has no user-visible behavior change or immediate bug fix, but provides clean scoping and improved testability for P2P.

Membership: Refactors P2P self-advertisement and local address resolution functions in src/net.cpp and net_processing.cpp.

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

Reviewability: Stale: Needs rebase, CI failing

  • Needs rebase, CI is failing, and author set to draft to address header circular dependencies
  • Author has been silent for over five months

The branch has merge conflicts, CI is failing, and the author has been silent for over 5 months after converting to draft to resolve circular dependencies.

Author status: silent for 153 days after converting to draft to investigate circular dependencies

Open concerns:

  • Author converted the PR to draft citing a non-trivial circular dependency problem between headers.
  • maflcko suggested moving the newly added files under src/node/.

Resolved concerns:

  • Typo in title was fixed.

Agreement: Crickets

  • No reviews on the overall concept or implementation yet
  • Suggested placing new files under src/node/ (maflcko)
  • Converted to draft to investigate circular dependencies (theuni)

No reviews on the PR as a whole; comments only cover file placement and a title typo

No reviewer has weighed in on the concept or implementation beyond file structure suggestions.

  • maflcko suggested placing local address files in src/node/ rather than top-level src/
  • theuni converted to draft after encountering circular dependency issues

Review verdicts (DrahtBot): 0

Dependencies

Enables:

  • net/net_processing split (#33958)

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

This PR extracts local address bookkeeping and self-advertisement functions from net.cpp into a dedicated LocalAddressManager class, removing unnecessary CNode dependencies as part of the net/net_processing split (#33958). It introduces no behavioral changes, aiming purely to improve modularity and enable isolated unit and fuzz testing. The change is currently in draft due to circular dependency complications, is in a dirty merge state with CI failing, and has been untouched for over 150 days.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:51, confidence high, input hash 0c8269a34d82ecf3