paritytech / litep2p

Peer-to-peer networking library
MIT License
67 stars 8 forks source link

identify: Report observer addresses of peers that succeeded dial attempts #203

Open lexnv opened 1 month ago

lexnv commented 1 month ago

Correlate DialFailure and ListDialFailures attempts with the Identify response provided to peers.

The addresses the node could not dial should be removed from the list of addresses we provide back to the peer.

This ensures the remote peer has a healthy view of its addresses and leads to better connectivity over time. Libp2p uses a similar approach, caching individual peer addresses and removing the addresses the node failed to dial.

dmitry-markin commented 1 month ago

I'm not sure I understand this issue correctly, but here is my understanding of the Identify operation. As per libp2p spec, observed_addr is the connection source address of a peer initiating the connection. It is reported in any case and is part of Identify protocol.

In libp2p, Identify protocol implementation keeps a cache of remote peer addresses to provide them when dialing peers, and this is why this list is cleaned up of unreachable addresses. But the observed address is always reported back.

In litep2p peer addresses are discovered entirely through Kademlia DHT routing table, without caching the remote peer listen addresses in the Identify protocol implementation.

So, IMO we shouldn't modify the Identify protocol implementation in litep2p. If we need to check the reachability of external addresses after applying the "many peers have seen the same address" heuristic, it should be done using a different protocol, similar to AutoNAT.

dmitry-markin commented 1 month ago

Also, the heuristic of not reporting back the failed addresses won't work in case of restricted cone NATs, as in this case the dial attempts of the peer previously dialed by another peer behind NAT will succeed, while no other peers will be able to reach the peer behind NAT using discovered address and port. AutoNAT tries to solve this issue by using different IP to probe the addresses.