diff --git a/Cargo.lock b/Cargo.lock index cdf3ed1e04a..0d898d0360b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2387,7 +2387,6 @@ dependencies = [ "libp2p-kad", "libp2p-mdns", "libp2p-metrics", - "libp2p-mplex", "libp2p-noise", "libp2p-perf", "libp2p-ping", @@ -2591,10 +2590,10 @@ dependencies = [ "instant", "libp2p-core", "libp2p-identity", - "libp2p-mplex", "libp2p-noise", "libp2p-swarm", "libp2p-swarm-test", + "libp2p-yamux", "log", "prometheus-client", "quick-protobuf", diff --git a/examples/chat-example/src/main.rs b/examples/chat-example/src/main.rs index 2c038724c37..338b2e360ec 100644 --- a/examples/chat-example/src/main.rs +++ b/examples/chat-example/src/main.rs @@ -74,7 +74,7 @@ async fn main() -> Result<(), Box> { let local_peer_id = PeerId::from(id_keys.public()); println!("Local peer id: {local_peer_id}"); - // Set up an encrypted DNS-enabled TCP Transport over the Mplex protocol. + // Set up an encrypted DNS-enabled TCP Transport over the yamux protocol. let tcp_transport = tcp::async_io::Transport::new(tcp::Config::default().nodelay(true)) .upgrade(upgrade::Version::V1Lazy) .authenticate(noise::Config::new(&id_keys).expect("signing libp2p-noise static keypair")) diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index 7e156572781..701e4543408 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -10,4 +10,4 @@ async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" env_logger = "0.10" futures = "0.3.28" -libp2p = { path = "../../libp2p", features = ["async-std", "dns", "kad", "mplex", "noise", "tcp", "websocket", "yamux"] } +libp2p = { path = "../../libp2p", features = ["async-std", "dns", "kad", "noise", "tcp", "websocket", "yamux"] } diff --git a/examples/ipfs-kad/src/main.rs b/examples/ipfs-kad/src/main.rs index 9799ca8df0a..42735de2741 100644 --- a/examples/ipfs-kad/src/main.rs +++ b/examples/ipfs-kad/src/main.rs @@ -48,7 +48,7 @@ async fn main() -> Result<(), Box> { let local_key = identity::Keypair::generate_ed25519(); let local_peer_id = PeerId::from(local_key.public()); - // Set up a an encrypted DNS-enabled TCP Transport over the Mplex protocol + // Set up a an encrypted DNS-enabled TCP Transport over the yamux protocol let transport = development_transport(local_key).await?; // Create a swarm to manage peers and events. diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index 18206718799..e073fccf7dd 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -12,9 +12,15 @@ - Rename `NetworkBehaviour::OutEvent` to `NetworkBehaviour::ToSwarm`, `ConnectionHandler::InEvent` to `ConnectionHandler::FromBehaviour`, `ConnectionHandler::OutEvent` to `ConnectionHandler::ToBehaviour`. See [PR 3848]. -[PR 3746]: https://github.com/libp2p/rust-libp2p/pull/3746 +- Remove deprecated `mplex` module. + You can still depend on `libp2p-mplex` directly but we strongly encourage to migrate to `yamux`. + This also removes `mplex` from the `development_transport` and `tokio_development_transport` functions. + See [PR 3920]. + [PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715 +[PR 3746]: https://github.com/libp2p/rust-libp2p/pull/3746 [PR 3848]: https://github.com/libp2p/rust-libp2p/pull/3848 +[PR 3920]: https://github.com/libp2p/rust-libp2p/pull/3920 ## 0.51.3 diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index b4fa79d6343..95cd9c08681 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -26,7 +26,6 @@ full = [ "macros", "mdns", "metrics", - "mplex", "noise", "perf", "ping", @@ -65,7 +64,6 @@ kad = ["dep:libp2p-kad", "libp2p-metrics?/kad"] macros = ["libp2p-swarm/macros"] mdns = ["dep:libp2p-mdns"] metrics = ["dep:libp2p-metrics"] -mplex = ["dep:libp2p-mplex"] noise = ["dep:libp2p-noise"] perf = ["dep:libp2p-perf"] ping = ["dep:libp2p-ping", "libp2p-metrics?/ping"] @@ -106,7 +104,6 @@ libp2p-identify = { workspace = true, optional = true } libp2p-identity = { workspace = true } libp2p-kad = { workspace = true, optional = true } libp2p-metrics = { workspace = true, optional = true } -libp2p-mplex = { workspace = true, optional = true } libp2p-noise = { workspace = true, optional = true } libp2p-ping = { workspace = true, optional = true } libp2p-plaintext = { workspace = true, optional = true } @@ -144,7 +141,6 @@ env_logger = "0.10.0" clap = { version = "4.1.6", features = ["derive"] } tokio = { version = "1.15", features = ["io-util", "io-std", "macros", "rt", "rt-multi-thread"] } -libp2p-mplex = { workspace = true } libp2p-noise = { workspace = true } libp2p-tcp = { workspace = true, features = ["tokio"] } diff --git a/libp2p/src/lib.rs b/libp2p/src/lib.rs index f086c2872f4..917c1c86edc 100644 --- a/libp2p/src/lib.rs +++ b/libp2p/src/lib.rs @@ -82,13 +82,6 @@ pub use libp2p_mdns as mdns; #[cfg(feature = "metrics")] #[doc(inline)] pub use libp2p_metrics as metrics; -#[cfg(feature = "mplex")] -#[deprecated( - note = "`mplex` is not recommended anymore. Please use `yamux` instead or depend on `libp2p-mplex` directly if you need it for legacy use cases." -)] -pub mod mplex { - pub use libp2p_mplex::*; -} #[cfg(feature = "noise")] #[doc(inline)] pub use libp2p_noise as noise; @@ -184,7 +177,7 @@ pub use libp2p_swarm::{Stream, StreamProtocol}; /// * DNS resolution. /// * Noise protocol encryption. /// * Websockets. -/// * Both Yamux and Mplex for substream multiplexing. +/// * Yamux for substream multiplexing. /// /// All async I/O of the transport is based on `async-std`. /// @@ -198,7 +191,6 @@ pub use libp2p_swarm::{Stream, StreamProtocol}; ), feature = "websocket", feature = "noise", - feature = "mplex", feature = "yamux" ))] #[cfg_attr( @@ -231,11 +223,7 @@ pub async fn development_transport( Ok(transport .upgrade(core::upgrade::Version::V1) .authenticate(noise::Config::new(&keypair).unwrap()) - .multiplex(core::upgrade::SelectUpgrade::new( - yamux::Config::default(), - #[allow(deprecated)] - mplex::MplexConfig::default(), - )) + .multiplex(yamux::Config::default()) .timeout(std::time::Duration::from_secs(20)) .boxed()) } @@ -245,7 +233,7 @@ pub async fn development_transport( /// * DNS resolution. /// * Noise protocol encryption. /// * Websockets. -/// * Both Yamux and Mplex for substream multiplexing. +/// * Yamux for substream multiplexing. /// /// All async I/O of the transport is based on `tokio`. /// @@ -259,7 +247,6 @@ pub async fn development_transport( ), feature = "websocket", feature = "noise", - feature = "mplex", feature = "yamux" ))] #[cfg_attr( @@ -288,11 +275,7 @@ pub fn tokio_development_transport( Ok(transport .upgrade(core::upgrade::Version::V1) .authenticate(noise::Config::new(&keypair).unwrap()) - .multiplex(core::upgrade::SelectUpgrade::new( - yamux::Config::default(), - #[allow(deprecated)] - mplex::MplexConfig::default(), - )) + .multiplex(yamux::Config::default()) .timeout(std::time::Duration::from_secs(20)) .boxed()) } diff --git a/libp2p/src/transport_ext.rs b/libp2p/src/transport_ext.rs index b51b8e8298a..8f7c16574f6 100644 --- a/libp2p/src/transport_ext.rs +++ b/libp2p/src/transport_ext.rs @@ -43,7 +43,7 @@ pub trait TransportExt: Transport { /// # Example /// /// ``` - /// use libp2p_mplex as mplex; + /// use libp2p_yamux as yamux; /// use libp2p_noise as noise; /// use libp2p_tcp as tcp; /// use libp2p::{ @@ -61,7 +61,7 @@ pub trait TransportExt: Transport { /// noise::Config::new(&id_keys) /// .expect("Signing libp2p-noise static DH keypair failed."), /// ) - /// .multiplex(mplex::MplexConfig::new()) + /// .multiplex(yamux::Config::default()) /// .boxed(); /// /// let (transport, sinks) = transport.with_bandwidth_logging(); diff --git a/libp2p/src/tutorials/ping.rs b/libp2p/src/tutorials/ping.rs index 295e37e24b1..b698c6ab3bb 100644 --- a/libp2p/src/tutorials/ping.rs +++ b/libp2p/src/tutorials/ping.rs @@ -55,7 +55,7 @@ //! edition = "2021" //! //! [dependencies] -//! libp2p = { version = "0.50", features = ["tcp", "dns", "async-std", "noise", "mplex", "yamux", "websocket", "ping", "macros"] } +//! libp2p = { version = "0.50", features = ["tcp", "dns", "async-std", "noise", "yamux", "websocket", "ping", "macros"] } //! futures = "0.3.21" //! async-std = { version = "1.12.0", features = ["attributes"] } //! ``` diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 813428bc008..80645f509ba 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -42,7 +42,7 @@ async-std = { version = "1.6.3", features = ["unstable"] } env_logger = "0.10.0" hex = "0.4.2" libp2p-core = { workspace = true } -libp2p-mplex = { workspace = true } +libp2p-yamux = { workspace = true } libp2p-noise = { workspace = true } libp2p-swarm-test = { workspace = true } quickcheck = { workspace = true } diff --git a/protocols/gossipsub/src/lib.rs b/protocols/gossipsub/src/lib.rs index cebd24444ee..b5ea9999a5a 100644 --- a/protocols/gossipsub/src/lib.rs +++ b/protocols/gossipsub/src/lib.rs @@ -99,12 +99,12 @@ //! let local_key = identity::Keypair::generate_ed25519(); //! let local_peer_id = local_key.public().to_peer_id(); //! -//! // Set up an encrypted TCP Transport over the Mplex +//! // Set up an encrypted TCP Transport over yamux //! // This is test transport (memory). //! let transport = MemoryTransport::default() //! .upgrade(libp2p_core::upgrade::Version::V1) //! .authenticate(libp2p_noise::Config::new(&local_key).unwrap()) -//! .multiplex(libp2p_mplex::MplexConfig::new()) +//! .multiplex(libp2p_yamux::Config::default()) //! .boxed(); //! //! // Create a Gossipsub topic