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

Cargo.toml: Deprecate executor specific features for sub-crates #2962

Merged
merged 8 commits into from Oct 11, 2022

Conversation

thomaseizinger
Copy link
Contributor

Description

Typically, an application will only use one kind of executor like tokio or async-std. Currently, users of libp2p need to activate a separate feature for each sub-crate that is specific to the executor they want to use, i.e. tcp-tokio, dns-tokio, etc.

With this PR, we deprecate these features in favor of a single tokio and async-std feature. Thanks to cargo's support for weak-features, we can forward the respective executor feature to each sub-crate without pulling them in as dependencies unless the user also activated the corresponding protocol (dns, tcp etc).

Deprecation warnings don't work on re-exports so I had to (temporarily) define a new module in lib.rs. This module should be removed again once we actually remove the deprecated features.

Here is a screenshot of the warning being active:

image

This is a backwards-compatible change.

The warning goes away as soon as we stop using the deprecated feature:

image

Links to any relevant issues

Open Questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
We only want to emit the deprecation warning in case a user uses
the old features and _not_ the new ones. This assumes that a user
upgrades properly, i.e. adds the new `tokio` or `async-std` feature
AND removes the old `tcp-tokio` feature from the list.

We need to use this rather complex cfg expression because otherwise,
our CI won't pass. We run clippy with `--all-features`, thus just
detecting for presence of the `tcp-async-io` feature for example
will always flag our examples as using deprecated code.
Otherwise CI will not pass once #2963
actually checks it properly.
@elenaf9
Copy link
Contributor

elenaf9 commented Sep 30, 2022

In favor of this!
But I wonder if it is really necessary to deprecate the old features, rather than just removing them directly. Upgrading to the new feature set is very easy, whereas the deprecation logic added in this PR is quite complex.

@thomaseizinger
Copy link
Contributor Author

In favor of this! But I wonder if it is really necessary to deprecate the old features, rather than just removing them directly. Upgrading to the new feature set is very easy, whereas the deprecation logic added in this PR is quite complex.

The annoying thing with removing features is that cargo completely chokes and gives up compiling altogether if it can't find the feature with a given name. The upgrade might be easy but it looks completely broken which might delay looking at a dependabot PR in detail.

The logic is a bit complex but it is only temporary until the release is out. We can remove it immediately after so I wouldn't be too worried about it :)

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

I am in favor the change in general.

I am in favor of the two step (deprecation + removal) process. While not directly related, I think #2971 is a good data point for the argument that configuring rust-libp2p features is hard. Thus I think making it easier for users at the expense of complexity on our end makes sense.

Before we merge here, can you create a second pull request removing the deprecated modules. Once this is merged and released, we can then merge the second pull request.

@thomaseizinger
Copy link
Contributor Author

Before we merge here, can you create a second pull request removing the deprecated modules. Once this is merged and released, we can then merge the second pull request.

Done here: #3001

@thomaseizinger thomaseizinger merged commit 31a45f2 into master Oct 11, 2022
@thomaseizinger thomaseizinger deleted the 2173-single-executor-feature branch October 11, 2022 12:10
elenaf9 added a commit to kpp/rust-libp2p that referenced this pull request Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants