Description
Summary
There seems to be no uniformization with the use of fully-qualified multiaddr
(ie. with p2p
suffix). This leads to unfortunate side-effects.
For example, like it was mentionned in #2280, multiaddr
are stored fully-qualified in kad
behaviour, but they are stored not fully-qualified in identify
behaviour.
The identify
case
In identify
, the cache is constructed with addresses received from the listen_addrs
fields which do not contains the /p2p/
part (due to back and forth conversions between MultiAddr
and SocketAddr
).
However, removal of such addresses occurrs on DialError
rust-libp2p/protocols/identify/src/behaviour.rs
Lines 389 to 397 in ecdd0ff
and on ConnectionEstablished::failed_addresses
rust-libp2p/protocols/identify/src/behaviour.rs
Lines 218 to 222 in ecdd0ff
with fully-qualified multiaddr. This result in addresses never being removed since /ip4/127.0.0.1/tcp/4001/p2p/Qm...
does not match /ip4/127.0.0.1/tcp/4001
.
The kad
case
With the current implementation of the kademlia behaviour, events like ConnectionEstablished
and DialError
always contain fully-qualified multiaddr.
But the application can also manually add multiaddresses into the k-bucket (with the add_address
method) : if we call add_address
with a fully-qualified multiaddr it will successfully be removed when a DialError
occurrs, but if we call add_address
with a non-fully-qualified multiaddr it will never be removed (it might be an expected behaviour for a bootnode for example, we are not sure about it).
Also, non-fully-qualified addresses already present will be duplicated (with /p2p
suffix) on a ConnectionEstablished
event as a dialer.
Expected behaviour
We would expect to have a coherent behaviour when using multiaddr with or without /p2p/
suffix.
It would be nice if the documentation specify whether we should provide fully or non-fully qualified addresses (and the possible side effect if there is any).
Actual behaviour
Mixed of full and non-full qualified leads to addresses never being removed from the identify cache and the DHT.
Possible Solution
The identify
case
We have two possible solutions to this problem :
- ensure that only fully-qualified multiaddr are inserted into the cache
- keep non-fully-qualified multiaddr in the cache but remove them accordingly
The kad
case
Ensure that we always insert fully-qualified multiaddr when calling add_address
.
Version
- libp2p version : 0.52.3
Would you like to work on fixing this bug?
Yes. We already started to work to address this issue. You can find a proof of concept in the following commit : d63cd80
This was made as a starting point for a discussion.