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

feat(libp2p): deprecate mplex #3689

Merged
merged 12 commits into from
Apr 4, 2023
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/chat-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
env_logger = "0.10.0"
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"] }
2 changes: 1 addition & 1 deletion examples/dcutr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ clap = { version = "4.2.1", features = ["derive"] }
env_logger = "0.10.0"
futures = "0.3.28"
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"
2 changes: 1 addition & 1 deletion examples/distributed-key-value-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ 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", "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" }
2 changes: 1 addition & 1 deletion examples/file-sharing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ clap = { version = "4.2.1", features = ["derive"] }
either = "1.8"
env_logger = "0.10"
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" }
2 changes: 1 addition & 1 deletion examples/identify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ license = "MIT"
async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
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"] }
2 changes: 1 addition & 1 deletion examples/ipfs-kad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to undo this line to make the IPFS integration test work again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thomaseizinger Done, maybe for future PR: you said in the comments above that you didn't want to use deprecated modules like this in the examples. In this context, shouldn't mplex be replaced by yamux here?

Copy link
Contributor

@thomaseizinger thomaseizinger Apr 3, 2023

Choose a reason for hiding this comment

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

Yes correct. In this case, we still use development_transport for this example. I'd like to change how this function is being used but we still need to hash out a design. See #3657.

The option here would either be to use inline development_transport into the example or use the deprecated feature here. To keep the scope of the PR small, I'd say using it here is fine enough. We don't explicitly show the use of mplex in here so I don't think it is that bad. With the next breaking change, we will remove mplex from the development_transport and the world will be better :)

libp2p = { path = "../../libp2p", features = ["async-std", "dns", "kad", "mplex", "noise", "tcp", "websocket", "yamux"] }
2 changes: 1 addition & 1 deletion examples/ipfs-private/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ async-trait = "0.1"
either = "1.8"
env_logger = "0.10"
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" }
2 changes: 1 addition & 1 deletion examples/ping-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ license = "MIT"
async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
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" }
2 changes: 1 addition & 1 deletion examples/rendezvous/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
env_logger = "0.10.0"
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"
tokio = { version = "1.25", features = [ "rt-multi-thread", "macros", "time" ] }
3 changes: 2 additions & 1 deletion interop-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ anyhow = "1"
either = "1.8.0"
env_logger = "0.10.0"
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-webrtc = { path = "../transports/webrtc", features = ["tokio"] }
libp2p-mplex = { path = "../muxers/mplex" }
log = "0.4"
rand = "0.8.5"
redis = { version = "0.22.1", default-features = false, features = ["tokio-comp"] }
Expand Down
5 changes: 3 additions & 2 deletions interop-tests/src/bin/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ use libp2p::swarm::{keep_alive, NetworkBehaviour, SwarmEvent};
use libp2p::tls::TlsStream;
use libp2p::websocket::WsConfig;
use libp2p::{
identity, mplex, noise, ping, swarm::SwarmBuilder, tcp, tls, yamux, InboundUpgradeExt,
Multiaddr, OutboundUpgradeExt, PeerId, Transport as _,
identity, noise, ping, swarm::SwarmBuilder, tcp, tls, yamux, InboundUpgradeExt, Multiaddr,
OutboundUpgradeExt, PeerId, Transport as _,
};
use libp2p_mplex as mplex;
use libp2p_quic as quic;
use libp2p_webrtc as webrtc;
use redis::AsyncCommands;
Expand Down
8 changes: 8 additions & 0 deletions libp2p/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

- Introduce `libp2p::connection_limits` module.
Expand Down
2 changes: 1 addition & 1 deletion libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p"
edition = "2021"
rust-version = "1.65.0"
description = "Peer-to-peer networking library"
version = "0.51.2"
version = "0.51.3"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
10 changes: 8 additions & 2 deletions libp2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ pub use libp2p_mdns as mdns;
#[doc(inline)]
pub use libp2p_metrics as metrics;
#[cfg(feature = "mplex")]
#[doc(inline)]
pub use libp2p_mplex as 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;
Expand Down Expand Up @@ -228,6 +232,7 @@ pub async fn development_transport(
.authenticate(noise::NoiseAuthenticated::xx(&keypair).unwrap())
.multiplex(core::upgrade::SelectUpgrade::new(
yamux::YamuxConfig::default(),
#[allow(deprecated)]
mplex::MplexConfig::default(),
))
.timeout(std::time::Duration::from_secs(20))
Expand Down Expand Up @@ -284,6 +289,7 @@ pub fn tokio_development_transport(
.authenticate(noise::NoiseAuthenticated::xx(&keypair).unwrap())
.multiplex(core::upgrade::SelectUpgrade::new(
yamux::YamuxConfig::default(),
#[allow(deprecated)]
mplex::MplexConfig::default(),
))
.timeout(std::time::Duration::from_secs(20))
Expand Down