-
Notifications
You must be signed in to change notification settings - Fork 26
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
Refactor libp2p code #154
Refactor libp2p code #154
Conversation
ef6f37d
to
2180615
Compare
This PR is ready for review. Mock interface and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me over all. Added a bunch of suggestions. It was not completely clear to me which bits just moved around and which have also changed, so some of the comments may not be specifically connected to the changes in this PR.
76c5540
to
132a84a
Compare
bb12802
to
81f5773
Compare
Rename common.rs to types.rs to follow naming convention with the mock interface.
This commit does not implement the now-required message validation API for the mock interface.
Peer object was used to implement multiplexing between SwarmManager and SyncManager, to handle handshaking and ping/pong connectivity checks. Now that responsibility of providing that functionality is given to the network service provider, the peer object doesn't have a use in its current form.
From now on it's required that multiplexing is provided by the network service provider and that the users of the protocol can issue generic request-response type messages.
Now that handshaking is part of the connection establishment and that the front-end gets only handshaked connections, peer don't need to be registered to the backend anymore.
This service is used instead the old SocketService + Peer combo by allowing the network service provider to do the socket multiplexing as it sees fit. It simplifies the design on the upper-level and allows Mintlayer to better utilize the tools libp2p provides.
- configure Ping and Identify protocols - move protocol handlers to separate files - creat/interpret protocol string correctly Unit tests for the protocol handlers are missing
Inbound connections also carry the address of the remote peer which was previously discarded in the backend. While there, rename the events more logically.
- rename Strategy to DiscoveryStrategy - do not use hard-coded ports in tests - rename addr to bind_addr - rename config to chain_config - format source code - gate `create_custom()` behind "testing" attribute
Highlights:
libp2p::floodsub
withlibp2p::gossipsub
libp2p::streaming
(our fork) and the peer objectlibp2p::ping
for keep-alivelibp2p::identify
for exchanging peer informationSocketService
and introduce a new request/response-basedSyncingService
I'm leaning towards the viewpoint that
SwarmManager
should ultimately be the one that decided whether inbound/outbound peer is kept in our swarm and not thelibp2p::identify
handler. The reason for that is because the manager must anyway check the incoming peer information against the info it has (unless we start adding panics to the code) so it would be cleaner if that check was done in one place. I'll experiment with tests to see which is nicer (duplicate check or onlySwarmManager
checking) and decide based on that. Let me know what you think about it.For now this is a draft as I still need to write more tests for the libp2p implementation and sync the mock interface with these new changes. I don't expect the tests to reveal a lot of need for changes so you're free to start reviewing if you feel like it.