-
Notifications
You must be signed in to change notification settings - Fork 684
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
Get rid of libp2p
dependency in sc-authority-discovery
#5842
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Bastian Köcher <git@kchr.de>
This reverts commit 73860e6.
@dmitry-markin , @bkchr , @lexnv , I think we're ready for a review. |
It seems that I cannot add new reviewers myself: I don't see the gear usuallly present on the right side of |
@@ -907,7 +907,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkBackend<B, H> for Litep2pNetworkBac | |||
); | |||
|
|||
self.event_streams.send(Event::Dht( | |||
DhtEvent::ValueNotFound(libp2p::kad::RecordKey::new(&key)) | |||
DhtEvent::ValueNotFound(sc_network_types::rec::Key::new::<sc_network_types::rec::Key>(&key.to_vec().into())) |
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.
You are passing the same type as generic argument?
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.
The compiler complains that the type of sc_network_types::rec::Key::new
cannot be infered, and so passing the type as the generic fixed the problem.
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.
This is because of the .into()
call, as the compiler does not know what to convert the key.to_vec()
into. Just keeping it as key.to_vec()
should be enough. Also, the KademliaKey
that is needed here is under your control, so you can implement From::<libp2p::kad::RecordKey>
for it and use key.into()
here instead of sc_network_types::rec::Key::new()
.
Co-authored-by: Bastian Köcher <git@kchr.de>
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.
This is going in the right direction! To completely get rid of libp2p
types we must ensure no nested types in sc-authority-discovery
are libp2p
types. After this is done, no .into()
and explicit template arguments should be needed.
@@ -580,7 +580,7 @@ where | |||
|
|||
debug!(target: LOG_TARGET, "Value for hash '{:?}' found on Dht.", v.record.key); | |||
|
|||
if let Err(e) = self.handle_dht_value_found_event(v) { | |||
if let Err(e) = self.handle_dht_value_found_event(v.into()) { |
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.
What we want is, actually, to get in authority-discovery
types without nested libp2p
types. In this case, DhtEvent
should be updated to carry substrate-specific types and not wrap libp2p
(neither litep2p
) types. So, no .into()
should be needed in this line.
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.
You will also need to update self.network.put_value(key, value)
to use network backend agnostic types all the way down to NetworkWorker
(aka "libp2p network backend") / Litep2pNetworkBackend
, where this type will be converted into a specific network backend type.
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.
@dmitry-markin , sorry! the into()
here was not needed. I made it so that substrate/client/network/src/types.rs
does not use libp2p
at all anymore. DhtEvent
should also be free of any use oflibp2p
.
This Leaves us with Litep2pNetworkBackend
which is still using libp2p
. I am planning to start working on substrate/client/network/src/litep2p/mod.rs
and all related files to remove libp2p
. I just need you to confirm or correct my understanding of the current status before that 😃
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.
Sounds good! There should be no need for libp2p kademlia types in substrate/client/network/src/litep2p/mod.rs
now when you have kad.rs
with network backend agnostic types.
Ideally, we should get rid of all libp2p
types in litep2p network backend, but better to do it as a follow-up PR.
@ndkazu thanks for looking into this issue and sorry for slow reviews on my side. |
@dmitry-markin , what about |
Issue
#4859
Description
This PR removes
libp2p
types in authority-discovery, and replace them with network backend agnostic types fromsc-network-types
.The
sc-network
interface is therefore updated accordingly.