-
Notifications
You must be signed in to change notification settings - Fork 957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mismatch with the usage of fully and non-fully qualified multiaddr (/p2p suffix) #4573
Comments
Thank you for reporting this! I do agree that we should do better on this front. Using a non-qualified address is totally legitimate so I am afraid we cannot always enforce them being fully-qualified. I think we should be appending Something we could do is change the Other than that, I think we'll have to change all caches / maps of addresses to always check for both. A long-shot could be to refactor |
Thanks for your reply. We totally agree that using non-qualified address is totally legitimate and that we should be able to handle both cases. In that regard, we think that the pragmatic approach is to always make sure that the libp2p API appends We are not particularly convinced with the change to Finally, a refactor of We think that the first solution is the simplest approach and the least likely to have any side effects so we are going to keep working on our POC (always appending |
Yes! Feel free to open a draft PR at any time and we can collaborate from there! :) |
Summary
There seems to be no uniformization with the use of fully-qualified
multiaddr
(ie. withp2p
suffix). This leads to unfortunate side-effects.For example, like it was mentionned in #2280,
multiaddr
are stored fully-qualified inkad
behaviour, but they are stored not fully-qualified inidentify
behaviour.The
identify
caseIn
identify
, the cache is constructed with addresses received from thelisten_addrs
fields which do not contains the/p2p/
part (due to back and forth conversions betweenMultiAddr
andSocketAddr
).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
caseWith the current implementation of the kademlia behaviour, events like
ConnectionEstablished
andDialError
always contain fully-qualified multiaddr.But the application can also manually add multiaddresses into the k-bucket (with the
add_address
method) : if we calladd_address
with a fully-qualified multiaddr it will successfully be removed when aDialError
occurrs, but if we calladd_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 aConnectionEstablished
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
caseWe have two possible solutions to this problem :
The
kad
caseEnsure that we always insert fully-qualified multiaddr when calling
add_address
.Version
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.
The text was updated successfully, but these errors were encountered: