-
Notifications
You must be signed in to change notification settings - Fork 963
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
Add an AddressBook
to Swarm
#2133
Conversation
For now, the `Swarm` doesn't do anything with this, we are just putting infrastructure in place.
d3b6d3c
to
ee9c923
Compare
I'd like to point to https://github.com/ipfs-rust/ipfs-embed/blob/master/src/net/peers.rs as a reference of previous work.
|
Thanks! I will definitely take a look to see how this PR can be improved. Please have a look at this discussion as well for some more context on what I am trying to achieve here.
That makes sense although not all addresses of incoming connections will be dialable (TCP's outgoing ports are an issue here f.e.) but it may be worth to try anyway.
I agree that such events would generally be useful. At the moment, I am trying to land an MVP version of address book that allows
As stated in the PR description, I primarily added this for testing purposes. If we find a good way of testing this reliably, I am happy to remove it.
mdns is already reporting its discovered peers via
See (3) in the PR description.
That makes sense, I'll add it to the PR description as a task. Will only proceed if we can get an ACK on the design though! :) |
ee9c923
to
d683921
Compare
Ah without port reuse enabled there will certainly be a lot of garbage. But not handling this correctly was actually a bug in actyx at some point. After sim-open lands I think making port-reuse the default may be sensible. Not enabling it just causes a larger test matrix of behaviours, most of which will be untested. |
I am having 2nd thoughts on the design of this. Instead of introducing
If we are consistent in the use of
The reason I am proposing this behaviour is because having all On the upside, if we manage to design an |
My conclusion from the above post is that we should actually fix Not only is this less invasive but I think it will also already improve how our |
Couple of things to discuss:
AddressBook
within theSwarm
to minimize changes of the public API.SwarmEvent::AddressBookUpdated
. This could in theory be removed again if we want to keep changes to the public API as small as possible.Identify
protocol to use this. I don't know enough aboutKademlia
to make changes there and I think for the time being (i.e. as long asNetworkBehaviour::addresses_of_peer
exists), lettingKademlia
manage its own internal address book is actually better.Open questions
Swarm::add_address
? Doing so would allow us to simplify the public API of at leastlibp2p-request-response
but it is also a commitment toSwarm
knowing about the address book. With the current API changes (NetworkBehaviourAction::ReportPeerAddr
andSwarmEvent::AddressBookUpdated
) we could still move into a different direction and f.e. not embed anAddressBook
insideSwarm
.libp2p-kad
emitNetworkBehaviourAction::ReportPeerAddr
? This could lead to a very large address book if we are connected to something like the IPFS DHT.Open tasks (once we have consensus on the design)
Mdns
to not useaddresses_of_peer
but report the discovered addresses viaNetworkBehaviourAction::ReportPeerAddr
/p2p
(Is this actually necessary? I think with [libp2p-dns] Implement/dnsaddr
resolution. #1931, we already always append/p2p
to a multiaddr before dialling it.)