Skip to content
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

Remove libp2p dependency from sc-network-sync #4974

Merged
merged 61 commits into from
Sep 18, 2024
Merged

Conversation

ndkazu
Copy link
Contributor

@ndkazu ndkazu commented Jul 8, 2024

Issue

#4858

Description

This PR removes libp2p::request_response::OutboundFailure from substrate/client/network/sync/src/engine.rs. This way, the dependency with the library libp2p is removed from sc-network-sync.

@bkchr
Copy link
Member

bkchr commented Jul 8, 2024

@ndkazu totally the crate libp2p should be removed as a dependency. Also the type OutboundFailure is still a libp2p type, even if you import it from sc-network. Not sure this is what @dmitry-markin wanted to achieve here.

@ndkazu ndkazu changed the title Removed libp2p dependancy from sc_network_sync Removed libp2p dependancy from sc-network-sync Jul 8, 2024
@ndkazu
Copy link
Contributor Author

ndkazu commented Jul 8, 2024

@ndkazu totally the crate libp2p should be removed as a dependency. Also the type OutboundFailure is still a libp2p type, even if you import it from sc-network. Not sure this is what @dmitry-markin wanted to achieve here.

Thanks for the clarification, will keep looking into it then.

@ndkazu ndkazu marked this pull request as draft July 8, 2024 23:50
@ndkazu
Copy link
Contributor Author

ndkazu commented Jul 10, 2024

The main libp2p dependency in engine.rs being the request_responses::Network, I decided to add a Network2 field in the request_responses struct, and by using a CustomOutboundFailure enum which does not depend on libp2p, I make sure that engine is completely free from any libp2p dependency.
@dmitry-markin & @bkchr , could you review the PR please?

@ndkazu ndkazu marked this pull request as ready for review July 10, 2024 23:44
@ndkazu
Copy link
Contributor Author

ndkazu commented Jul 13, 2024

@dmitry-markin & @bkchr , only OutboundFailure in engine.rs is mentioned in the issue, but by looking at the definition of sc_network_types::PeerId I see that it is also coming from libp2p_identity: is it ok to keep this one?

@dmitry-markin
Copy link
Contributor

dmitry-markin commented Jul 15, 2024

@dmitry-markin & @bkchr , only OutboundFailure in engine.rs is mentioned in the issue, but by looking at the definition of sc_network_types::PeerId I see that it is also coming from libp2p_identity: is it ok to keep this one?

sc_network_types::PeerId is fine as it's a Substrate-specific wrapper that does not expose the underlying type, and can be updated later to wrap another networking library type. Of course, if there are other types that make impossible removing the libp2p dependency from Cargo.toml, they have to be replaced by Substrate types as well.

@dmitry-markin
Copy link
Contributor

@ndkazu totally the crate libp2p should be removed as a dependency. Also the type OutboundFailure is still a libp2p type, even if you import it from sc-network. Not sure this is what @dmitry-markin wanted to achieve here.

I would say the first step would be to remove libp2p from Cargo.toml, but we also want to make sure the common sc-network code shared by both libp2p & litep2p network backends does not depend on the specific network libraries, so we can completely remove one of the libraries in the future. I would say removing libp2p dependency is higher in priority than removing litep2p dependency (and there shouldn't be any already).

@ndkazu
Copy link
Contributor Author

ndkazu commented Jul 15, 2024

@dmitry-markin & @bkchr , only OutboundFailure in engine.rs is mentioned in the issue, but by looking at the definition of sc_network_types::PeerId I see that it is also coming from libp2p_identity: is it ok to keep this one?

sc_network_types::PeerId is fine as it's a Substrate-specific wrapper that does not expose the underlying type, and can be updated later to wrap another networking library type. Of course, if there are other types that make impossible removing the libp2p dependency from Cargo.toml, they have to be replaced by Substrate types as well.

In this case, I think this PR is ready for Review.

@ndkazu
Copy link
Contributor Author

ndkazu commented Jul 18, 2024

@dmitry-markin & @bkchr , correct me if I'm wrong, but after spending time reading the code, I believe the only way to complete this PR as requested is to remove ALL libp2p dependency found in request_responses.rs. This however, is not as trivial as the issue made it seem... I am still digging...

@ndkazu ndkazu marked this pull request as draft July 20, 2024 03:11
@ndkazu
Copy link
Contributor Author

ndkazu commented Jul 20, 2024

Do not hesitate to let me know If you think I should pull the brake/re-think my approach...

@lexnv
Copy link
Contributor

lexnv commented Sep 17, 2024

bot fmt

@command-bot
Copy link

command-bot bot commented Sep 17, 2024

@lexnv https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7366911 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 5-4e41e1d2-2cdb-4737-9f61-a17c6d154398 to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Sep 17, 2024

@lexnv Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7366911 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7366911/artifacts/download.

@ndkazu
Copy link
Contributor Author

ndkazu commented Sep 17, 2024

Sorry, another bot fmt needed.

@ndkazu
Copy link
Contributor Author

ndkazu commented Sep 18, 2024

There is a failing CI test that seems unrelated to this PR: not sure what to do.

@dmitry-markin
Copy link
Contributor

bot fmt

@command-bot
Copy link

command-bot bot commented Sep 18, 2024

@dmitry-markin https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7369110 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 1-76b1d14d-f53e-4b5b-9c2f-50ade48a208f to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Sep 18, 2024

@dmitry-markin Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7369110 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7369110/artifacts/download.

@dmitry-markin
Copy link
Contributor

bot fmt was a no-op, the format was fine. I only had to manually correct the EOF in prdoc in vim as it had some spaces after a newline.

The unrelated tests failing is not an issue, you can ignore them.

Copy link
Contributor

@dmitry-markin dmitry-markin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job here! Thanks for contributing!

Once @lexnv approves the PR, we will merge it.

@dmitry-markin
Copy link
Contributor

Can you also update the PR description to reflect the latest state of PR? Can be something similar to your prdoc.

@dmitry-markin dmitry-markin linked an issue Sep 18, 2024 that may be closed by this pull request
Copy link
Contributor

@lexnv lexnv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing!

@ndkazu
Copy link
Contributor Author

ndkazu commented Sep 18, 2024

Shall we address issue #4859 next? 😄

@bkchr
Copy link
Member

bkchr commented Sep 18, 2024

Shall we address issue #4859 next? 😄

Fell free :)

@bkchr bkchr added this pull request to the merge queue Sep 18, 2024
Merged via the queue into paritytech:master with commit 7063395 Sep 18, 2024
204 of 209 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T0-node This PR/Issue is related to the topic “node”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get rid of libp2p dependency in sc-network-sync
5 participants