feat(libp2p): deprecate mplex

`mplex` module (no flow control and no streams limit) is deprecated to encourage `yamux` usage.

Resolves #3677.

Pull-Request: #3689.
This commit is contained in:
Thomas Coratger
2023-04-04 11:49:59 +02:00
committed by GitHub
parent 4bbc108103
commit 44d4b1133d
15 changed files with 33 additions and 16 deletions

3
Cargo.lock generated
View File

@ -2081,6 +2081,7 @@ dependencies = [
"env_logger 0.10.0", "env_logger 0.10.0",
"futures", "futures",
"libp2p", "libp2p",
"libp2p-mplex",
"libp2p-quic", "libp2p-quic",
"libp2p-webrtc", "libp2p-webrtc",
"log", "log",
@ -2228,7 +2229,7 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
[[package]] [[package]]
name = "libp2p" name = "libp2p"
version = "0.51.2" version = "0.51.3"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-trait", "async-trait",

View File

@ -10,5 +10,5 @@ async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1" async-trait = "0.1"
env_logger = "0.10.0" env_logger = "0.10.0"
futures = "0.3.28" futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["async-std", "gossipsub", "mdns", "mplex", "noise", "macros", "tcp", "yamux"] } libp2p = { path = "../../libp2p", features = ["async-std", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux"] }
libp2p-quic = { path = "../../transports/quic", features = ["async-std"] } libp2p-quic = { path = "../../transports/quic", features = ["async-std"] }

View File

@ -10,5 +10,5 @@ clap = { version = "4.2.1", features = ["derive"] }
env_logger = "0.10.0" env_logger = "0.10.0"
futures = "0.3.28" futures = "0.3.28"
futures-timer = "3.0" futures-timer = "3.0"
libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "mplex", "noise", "ping", "relay", "rendezvous", "tcp", "tokio", "yamux"] } libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio", "yamux"] }
log = "0.4" log = "0.4"

View File

@ -10,5 +10,5 @@ async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1" async-trait = "0.1"
env_logger = "0.10" env_logger = "0.10"
futures = "0.3.28" futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["async-std", "dns", "kad", "mdns", "mplex", "noise", "macros", "tcp", "websocket", "yamux"] } libp2p = { path = "../../libp2p", features = ["async-std", "dns", "kad", "mdns", "noise", "macros", "tcp", "websocket", "yamux"] }
multiaddr = { version = "0.17.0" } multiaddr = { version = "0.17.0" }

View File

@ -12,5 +12,5 @@ clap = { version = "4.2.1", features = ["derive"] }
either = "1.8" either = "1.8"
env_logger = "0.10" env_logger = "0.10"
futures = "0.3.28" futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["async-std", "dns", "kad", "mplex", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] } libp2p = { path = "../../libp2p", features = ["async-std", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] }
multiaddr = { version = "0.17.0" } multiaddr = { version = "0.17.0" }

View File

@ -9,4 +9,4 @@ license = "MIT"
async-std = { version = "1.12", features = ["attributes"] } async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1" async-trait = "0.1"
futures = "0.3.28" futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "mplex", "noise", "ping", "relay", "rendezvous", "tcp", "tokio", "yamux"] } libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio", "yamux"] }

View File

@ -10,4 +10,4 @@ async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1" async-trait = "0.1"
env_logger = "0.10" env_logger = "0.10"
futures = "0.3.28" 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", "mplex", "noise", "tcp", "websocket", "yamux"] }

View File

@ -11,5 +11,5 @@ async-trait = "0.1"
either = "1.8" either = "1.8"
env_logger = "0.10" env_logger = "0.10"
futures = "0.3.28" futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["async-std", "gossipsub", "dns", "identify", "kad", "macros", "mplex", "noise", "ping", "pnet", "tcp", "websocket", "yamux"] } libp2p = { path = "../../libp2p", features = ["async-std", "gossipsub", "dns", "identify", "kad", "macros", "noise", "ping", "pnet", "tcp", "websocket", "yamux"] }
multiaddr = { version = "0.17.0" } multiaddr = { version = "0.17.0" }

View File

@ -9,5 +9,5 @@ license = "MIT"
async-std = { version = "1.12", features = ["attributes"] } async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1" async-trait = "0.1"
futures = "0.3.28" futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["async-std", "dns", "macros", "mplex", "noise", "ping", "tcp", "websocket", "yamux"] } libp2p = { path = "../../libp2p", features = ["async-std", "dns", "macros", "noise", "ping", "tcp", "websocket", "yamux"] }
multiaddr = { version = "0.17.0" } multiaddr = { version = "0.17.0" }

View File

@ -10,6 +10,6 @@ async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1" async-trait = "0.1"
env_logger = "0.10.0" env_logger = "0.10.0"
futures = "0.3.28" futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["async-std", "identify", "macros", "mplex", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] } libp2p = { path = "../../libp2p", features = ["async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] }
log = "0.4" log = "0.4"
tokio = { version = "1.25", features = [ "rt-multi-thread", "macros", "time" ] } tokio = { version = "1.25", features = [ "rt-multi-thread", "macros", "time" ] }

View File

@ -10,9 +10,10 @@ anyhow = "1"
either = "1.8.0" either = "1.8.0"
env_logger = "0.10.0" env_logger = "0.10.0"
futures = "0.3.28" futures = "0.3.28"
libp2p = { path = "../libp2p", features = ["websocket", "mplex", "yamux", "tcp", "tokio", "ping", "noise", "tls", "dns", "rsa", "macros"] } libp2p = { path = "../libp2p", features = ["websocket", "yamux", "tcp", "tokio", "ping", "noise", "tls", "dns", "rsa", "macros"] }
libp2p-quic = { path = "../transports/quic", features = ["tokio"] } libp2p-quic = { path = "../transports/quic", features = ["tokio"] }
libp2p-webrtc = { path = "../transports/webrtc", features = ["tokio"] } libp2p-webrtc = { path = "../transports/webrtc", features = ["tokio"] }
libp2p-mplex = { path = "../muxers/mplex" }
log = "0.4" log = "0.4"
rand = "0.8.5" rand = "0.8.5"
redis = { version = "0.22.1", default-features = false, features = ["tokio-comp"] } redis = { version = "0.22.1", default-features = false, features = ["tokio-comp"] }

View File

@ -13,9 +13,10 @@ use libp2p::swarm::{keep_alive, NetworkBehaviour, SwarmEvent};
use libp2p::tls::TlsStream; use libp2p::tls::TlsStream;
use libp2p::websocket::WsConfig; use libp2p::websocket::WsConfig;
use libp2p::{ use libp2p::{
identity, mplex, noise, ping, swarm::SwarmBuilder, tcp, tls, yamux, InboundUpgradeExt, identity, noise, ping, swarm::SwarmBuilder, tcp, tls, yamux, InboundUpgradeExt, Multiaddr,
Multiaddr, OutboundUpgradeExt, PeerId, Transport as _, OutboundUpgradeExt, PeerId, Transport as _,
}; };
use libp2p_mplex as mplex;
use libp2p_quic as quic; use libp2p_quic as quic;
use libp2p_webrtc as webrtc; use libp2p_webrtc as webrtc;
use redis::AsyncCommands; use redis::AsyncCommands;

View File

@ -1,3 +1,11 @@
## 0.51.3 - unreleased
- Deprecate the `mplex` feature.
The recommended baseline stream multiplexer is `yamux`.
See [PR 3689].
[PR 3689]: https://github.com/libp2p/rust-libp2p/pull/3689
## 0.51.2 ## 0.51.2
- Introduce `libp2p::connection_limits` module. - Introduce `libp2p::connection_limits` module.

View File

@ -3,7 +3,7 @@ name = "libp2p"
edition = "2021" edition = "2021"
rust-version = "1.65.0" rust-version = "1.65.0"
description = "Peer-to-peer networking library" description = "Peer-to-peer networking library"
version = "0.51.2" version = "0.51.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT" license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p" repository = "https://github.com/libp2p/rust-libp2p"

View File

@ -83,8 +83,12 @@ pub use libp2p_mdns as mdns;
#[doc(inline)] #[doc(inline)]
pub use libp2p_metrics as metrics; pub use libp2p_metrics as metrics;
#[cfg(feature = "mplex")] #[cfg(feature = "mplex")]
#[doc(inline)] #[deprecated(
pub use libp2p_mplex as mplex; 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")] #[cfg(feature = "noise")]
#[doc(inline)] #[doc(inline)]
pub use libp2p_noise as noise; pub use libp2p_noise as noise;
@ -228,6 +232,7 @@ pub async fn development_transport(
.authenticate(noise::NoiseAuthenticated::xx(&keypair).unwrap()) .authenticate(noise::NoiseAuthenticated::xx(&keypair).unwrap())
.multiplex(core::upgrade::SelectUpgrade::new( .multiplex(core::upgrade::SelectUpgrade::new(
yamux::YamuxConfig::default(), yamux::YamuxConfig::default(),
#[allow(deprecated)]
mplex::MplexConfig::default(), mplex::MplexConfig::default(),
)) ))
.timeout(std::time::Duration::from_secs(20)) .timeout(std::time::Duration::from_secs(20))
@ -284,6 +289,7 @@ pub fn tokio_development_transport(
.authenticate(noise::NoiseAuthenticated::xx(&keypair).unwrap()) .authenticate(noise::NoiseAuthenticated::xx(&keypair).unwrap())
.multiplex(core::upgrade::SelectUpgrade::new( .multiplex(core::upgrade::SelectUpgrade::new(
yamux::YamuxConfig::default(), yamux::YamuxConfig::default(),
#[allow(deprecated)]
mplex::MplexConfig::default(), mplex::MplexConfig::default(),
)) ))
.timeout(std::time::Duration::from_secs(20)) .timeout(std::time::Duration::from_secs(20))