File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
substrate/client/network/src/litep2p Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ title: 'litep2p/discovery: Ensure non-global addresses are not reported as external'
2+ doc:
3+ - audience: Node Dev
4+ description: "This PR ensures that external addresses discovered by the identify\
5+ \ protocol are not propagated to the litep2p backend if they are not global. This\
6+ \ leads to a healthier DHT over time, since nodes will not advertise loopback\
7+ \ / non-global addresses.\n\nWe have seen various cases were loopback addresses\
8+ \ were reported as external:\n\n```\n2025-07-16 16:18:39.765 TRACE tokio-runtime-worker\
9+ \ sub-libp2p::discovery: verify new external address: /ip4/127.0.0.1/tcp/30310/p2p/12D3KooWNw19ScMjzNGLnYYLQxWcM9EK9VYPbCq241araUGgbdLM\n\
10+ \n2025-07-16 16:18:39.765 INFO tokio-runtime-worker sub-libp2p: \U0001F50D Discovered\
11+ \ new external address for our node: /ip4/127.0.0.1/tcp/30310/p2p/12D3KooWNw19ScMjzNGLnYYLQxWcM9EK9VYPbCq241araUGgbdLM\n\
12+ ```\n\nThis PR takes into account the network config for `allow_non_global_addresses`.\n\
13+ \nCloses: https://github.com/paritytech/polkadot-sdk/issues/9261\n\ncc @paritytech/networking"
14+ crates:
15+ - name: sc-network
16+ bump: patch
Original file line number Diff line number Diff line change @@ -493,6 +493,15 @@ impl Discovery {
493493 ) -> ( bool , Option < Multiaddr > ) {
494494 log:: trace!( target: LOG_TARGET , "verify new external address: {address}" ) ;
495495
496+ if !self . allow_non_global_addresses && !Discovery :: can_add_to_dht ( & address) {
497+ log:: trace!(
498+ target: LOG_TARGET ,
499+ "ignoring externally reported non-global address {address} from {peer}."
500+ ) ;
501+
502+ return ( false , None ) ;
503+ }
504+
496505 // is the address one of our known addresses
497506 if self
498507 . listen_addresses
You can’t perform that action at this time.
0 commit comments