Skip to content

feat: remove async_std support in TCP crate #5955

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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

gitToki
Copy link
Contributor

@gitToki gitToki commented Mar 25, 2025

ref #5935

crate to update:
swarm, mDNS, and the transports TCP, QUIC and DNS.

@dariusc93 dariusc93 changed the title chore!: deprecate async_std support in TCP crate chore: deprecate async_std support in TCP crate Mar 25, 2025
Copy link
Member

@dariusc93 dariusc93 left a comment

Choose a reason for hiding this comment

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

Thanks. Left a couple of comments

async-io = ["dep:async-io", "if-watch/smol"]
default = ["tokio"]
Copy link
Member

Choose a reason for hiding this comment

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

We probably should not have it default to tokio right now since it would require disabling default features to enable the needed feature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will correct next commit

Comment on lines 29 to 31
//! This crate provides a [`async_io::Transport`] (deprecated) and [`tokio::Transport`],
//! which implement the [`libp2p_core::Transport`] trait for use as a
//! transport with `libp2p-core` or `libp2p-swarm`.
Copy link
Member

Choose a reason for hiding this comment

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

Though the comment is modified, it is also duplicated from above.

Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Can we not soft deprecate and just hard deprecate? CC @elenaf9 @dariusc93

@elenaf9
Copy link
Member

elenaf9 commented Mar 26, 2025

Can we not soft deprecate and just hard deprecate? CC @elenaf9 @dariusc93

@gitToki initially did that, but I asked for a soft deprecation. I think a soft deprecation makes sense here because we might still have users that use async_std. It would a) give them time to object before we do a hard removal and b) offer a transition period for them.

Any specific reason why you'd prefer a direct removal @jxs?

@dariusc93
Copy link
Member

Can we not soft deprecate and just hard deprecate? CC @elenaf9 @dariusc93

Would there be any reason to suddenly do a hard deprecation vs soft? Imo, I think we should do a soft (though I am not against a hard one) to give users a time to switch or figure out plans on migration (or supporting the executor themselves for the respected protocols and utils).

@jxs
Copy link
Member

jxs commented Apr 3, 2025

Hi!

Any specific reason why you'd prefer a direct removal @jxs?

the reason is more work, double the PR's for something that has been declared as unmaintained, I feel redundant to have a version for users to remove their usage when they probably are already removing, added to the fact that I have seen soft deprecations lost in time.
But if you two agree that we should do soft I cede :)

@gitToki
Copy link
Contributor Author

gitToki commented Apr 13, 2025

updated, should be good. @dariusc93 please let me know if everything look good to you

@@ -47,8 +47,6 @@ use libp2p_core::{
multiaddr::{Multiaddr, Protocol},
transport::{DialOpts, ListenerId, PortUse, TransportError, TransportEvent},
};
#[cfg(feature = "async-io")]
pub use provider::async_io;
#[cfg(feature = "tokio")]
pub use provider::tokio;
use provider::{Incoming, Provider};
Copy link
Member

Choose a reason for hiding this comment

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

@jxs @dariusc93 based on the discussion in #5935 (comment), should we make the Incoming and Provider traits public to allow a downstream implementation?

In the other affected crates (libp2p-quic, libp2p-dns, etc.) the Provider traits are already public.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, we aren't really consistent on this. In libp2p-mdns for example the Provider trait is also private.

Still, I think we should make them public in all crates.

Copy link
Member

Choose a reason for hiding this comment

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

yeah makes sense to me, and possibly isolate them so they aren't duplicated right?

Copy link
Member

Choose a reason for hiding this comment

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

yeah makes sense to me, and possibly isolate them so they aren't duplicated right?

Yes good idea. But let's do that in a follow-up PR.

@jxs jxs changed the title chore: deprecate async_std support in TCP crate feat: deprecate async_std support in TCP crate Jun 4, 2025
Copy link
Contributor

mergify bot commented Jun 4, 2025

This pull request has merge conflicts. Could you please resolve them @gitToki? 🙏

@elenaf9 elenaf9 changed the title feat: deprecate async_std support in TCP crate feat: remove async_std support in TCP crate Jun 4, 2025
@gitToki
Copy link
Contributor Author

gitToki commented Jun 5, 2025

Is it good to you now @elenaf9 ? 🫡

Copy link
Member

@elenaf9 elenaf9 left a comment

Choose a reason for hiding this comment

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

Thank you for the follow-up @gitToki

Comment on lines 205 to 211

use crate::{cbor::codec::Codec, Codec as _};

#[async_std::test]
#[tokio::test]
async fn test_codec() {
let expected_request = TestRequest {
payload: "test_payload".to_string(),
Copy link
Member

Choose a reason for hiding this comment

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

Changing the request-response tests to use tokio is out of scope for this PR but blocked by it. There is a pending PR #5857 for this, that is blocked by failing tests. Would be interested in helping on that PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes sure I will try to take a look

Comment on lines 316 to 330
#[tokio::test]
async fn dialer_connects_to_listener_ipv4() {
let a = "/ip4/127.0.0.1/tcp/0/ws".parse().unwrap();
futures::executor::block_on(connect(a))
connect(a).await
}

#[test]
fn dialer_connects_to_listener_ipv6() {
#[tokio::test]
async fn dialer_connects_to_listener_ipv6() {
let a = "/ip6/::1/tcp/0/ws".parse().unwrap();
futures::executor::block_on(connect(a))
connect(a).await
}

fn new_ws_config() -> Config<tcp::async_io::Transport> {
Config::new(tcp::async_io::Transport::new(tcp::Config::default()))
fn new_ws_config() -> Config<tcp::tokio::Transport> {
Config::new(tcp::tokio::Transport::new(tcp::Config::default()))
}
Copy link
Member

Choose a reason for hiding this comment

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

Same here. This should be a separate PR, and the current PR should only be merged afterwards.

Copy link
Contributor Author

@gitToki gitToki Jun 7, 2025

Choose a reason for hiding this comment

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

Are you OK if I open a new PR for websocket ? I already made the change in a new branch (it was fast), available here: master...gitToki:rust-libp2p:websocket

Copy link
Member

Choose a reason for hiding this comment

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

Sure, thanks!

Copy link
Contributor

mergify bot commented Jun 9, 2025

This pull request has merge conflicts. Could you please resolve them @gitToki? 🙏

mergify bot pushed a commit that referenced this pull request Jun 10, 2025
migrate from async-std to tokio, asked before [here](#5955 (comment))

Pull-Request: #6054.
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.

4 participants