Open dmitry-markin opened 1 month ago
First time attempting to contribute to polkadot SDK, I'd like to give this a shot
Hello @dmitry-markin, I'd like to know what defines an agnostic type.
Hello @dmitry-markin, I'd like to know what defines an agnostic type.
This is coming from the sc_network
documentation:
Substrate’s networking protocol is based upon libp2p. It is at the moment not possible and not planned to permit using something else than the libp2p network stack and the rust-libp2p library. However the libp2p framework is very flexible and the rust-libp2p library could be extended to support a wider range of protocols than what is offered by libp2p.
The dependency to 1 type of network library makes it non-network backend agnostic, so by removing the libp2p dependency from sc_network_sync
(which is the subject here), you make it able to use more than one type of network library (or stack...the manual says stack) --> network backend agnostic.
Feel free to correct me if I didn't get it right
@cenwadike , I would suggest to ~replace~
~~ by~~
use libp2p::request_response::OutboundFailure;
~in~
use sc_network::OutboundFailure;
or use sc_network::request_responses::OutboundFailure
[substrate/client/network/sync/src/engine.rs](https://github.com/paritytech/polkadot-sdk/blob/
b301218db8785c6d425ca9a9ef90daa80780f2ce/substrate/client/network/sync/src/engine.rs#L1276)
~This way, when it will be ok to use other protocols than libp2p in substrate, sc_network_sync will be ready...thinking out loud, so feel free to correct me~
Ok after the details given in the PR by @bkchr , I think the best way to do this is to replace OutBoundFailure
by a generic term→Need to work in substrate/client/network/src/request_responses.rs as well.
A bit more involved than what I first said.
@dmitry-markin , I have PR ready to be reviewed here:
https://github.com/paritytech/polkadot-sdk/pull/4974
The main libp2p dependency in engine.rs
being the request_responses::Network
field, I decided to add a request_responses::Network2
field. Then, by using a CustomOutboundFailure
enum which does not depend on libp2p, I make sure that engine is completely free from any libp2p dependency.
Now, looking at issue #4859 I am wondering if there is more...
libp2p
is currently pulled in as a dependency ofsc-network-sync
due to the use oflibp2p::request_response::OutboundFailure
insubstrate/client/network/sync/src/engine.rs
. This should be refactored/replaced by a network backend agnostic type.