feat(libp2p): remove deprecated mplex module

Pull-Request: #3920.
This commit is contained in:
Thomas Eizinger
2023-05-15 16:11:13 +02:00
committed by GitHub
parent 08f0b5e9c9
commit 0b209f71cc
11 changed files with 21 additions and 37 deletions

3
Cargo.lock generated
View File

@ -2387,7 +2387,6 @@ dependencies = [
"libp2p-kad", "libp2p-kad",
"libp2p-mdns", "libp2p-mdns",
"libp2p-metrics", "libp2p-metrics",
"libp2p-mplex",
"libp2p-noise", "libp2p-noise",
"libp2p-perf", "libp2p-perf",
"libp2p-ping", "libp2p-ping",
@ -2591,10 +2590,10 @@ dependencies = [
"instant", "instant",
"libp2p-core", "libp2p-core",
"libp2p-identity", "libp2p-identity",
"libp2p-mplex",
"libp2p-noise", "libp2p-noise",
"libp2p-swarm", "libp2p-swarm",
"libp2p-swarm-test", "libp2p-swarm-test",
"libp2p-yamux",
"log", "log",
"prometheus-client", "prometheus-client",
"quick-protobuf", "quick-protobuf",

View File

@ -74,7 +74,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
let local_peer_id = PeerId::from(id_keys.public()); let local_peer_id = PeerId::from(id_keys.public());
println!("Local peer id: {local_peer_id}"); 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)) let tcp_transport = tcp::async_io::Transport::new(tcp::Config::default().nodelay(true))
.upgrade(upgrade::Version::V1Lazy) .upgrade(upgrade::Version::V1Lazy)
.authenticate(noise::Config::new(&id_keys).expect("signing libp2p-noise static keypair")) .authenticate(noise::Config::new(&id_keys).expect("signing libp2p-noise static keypair"))

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", "noise", "tcp", "websocket", "yamux"] }

View File

@ -48,7 +48,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
let local_key = identity::Keypair::generate_ed25519(); let local_key = identity::Keypair::generate_ed25519();
let local_peer_id = PeerId::from(local_key.public()); 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?; let transport = development_transport(local_key).await?;
// Create a swarm to manage peers and events. // Create a swarm to manage peers and events.

View File

@ -12,9 +12,15 @@
- Rename `NetworkBehaviour::OutEvent` to `NetworkBehaviour::ToSwarm`, `ConnectionHandler::InEvent` to `ConnectionHandler::FromBehaviour`, `ConnectionHandler::OutEvent` to `ConnectionHandler::ToBehaviour`. See [PR 3848]. - 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 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 3848]: https://github.com/libp2p/rust-libp2p/pull/3848
[PR 3920]: https://github.com/libp2p/rust-libp2p/pull/3920
## 0.51.3 ## 0.51.3

View File

@ -26,7 +26,6 @@ full = [
"macros", "macros",
"mdns", "mdns",
"metrics", "metrics",
"mplex",
"noise", "noise",
"perf", "perf",
"ping", "ping",
@ -65,7 +64,6 @@ kad = ["dep:libp2p-kad", "libp2p-metrics?/kad"]
macros = ["libp2p-swarm/macros"] macros = ["libp2p-swarm/macros"]
mdns = ["dep:libp2p-mdns"] mdns = ["dep:libp2p-mdns"]
metrics = ["dep:libp2p-metrics"] metrics = ["dep:libp2p-metrics"]
mplex = ["dep:libp2p-mplex"]
noise = ["dep:libp2p-noise"] noise = ["dep:libp2p-noise"]
perf = ["dep:libp2p-perf"] perf = ["dep:libp2p-perf"]
ping = ["dep:libp2p-ping", "libp2p-metrics?/ping"] ping = ["dep:libp2p-ping", "libp2p-metrics?/ping"]
@ -106,7 +104,6 @@ libp2p-identify = { workspace = true, optional = true }
libp2p-identity = { workspace = true } libp2p-identity = { workspace = true }
libp2p-kad = { workspace = true, optional = true } libp2p-kad = { workspace = true, optional = true }
libp2p-metrics = { workspace = true, optional = true } libp2p-metrics = { workspace = true, optional = true }
libp2p-mplex = { workspace = true, optional = true }
libp2p-noise = { workspace = true, optional = true } libp2p-noise = { workspace = true, optional = true }
libp2p-ping = { workspace = true, optional = true } libp2p-ping = { workspace = true, optional = true }
libp2p-plaintext = { 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"] } clap = { version = "4.1.6", features = ["derive"] }
tokio = { version = "1.15", features = ["io-util", "io-std", "macros", "rt", "rt-multi-thread"] } tokio = { version = "1.15", features = ["io-util", "io-std", "macros", "rt", "rt-multi-thread"] }
libp2p-mplex = { workspace = true }
libp2p-noise = { workspace = true } libp2p-noise = { workspace = true }
libp2p-tcp = { workspace = true, features = ["tokio"] } libp2p-tcp = { workspace = true, features = ["tokio"] }

View File

@ -82,13 +82,6 @@ pub use libp2p_mdns as mdns;
#[cfg(feature = "metrics")] #[cfg(feature = "metrics")]
#[doc(inline)] #[doc(inline)]
pub use libp2p_metrics as metrics; 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")] #[cfg(feature = "noise")]
#[doc(inline)] #[doc(inline)]
pub use libp2p_noise as noise; pub use libp2p_noise as noise;
@ -184,7 +177,7 @@ pub use libp2p_swarm::{Stream, StreamProtocol};
/// * DNS resolution. /// * DNS resolution.
/// * Noise protocol encryption. /// * Noise protocol encryption.
/// * Websockets. /// * Websockets.
/// * Both Yamux and Mplex for substream multiplexing. /// * Yamux for substream multiplexing.
/// ///
/// All async I/O of the transport is based on `async-std`. /// 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 = "websocket",
feature = "noise", feature = "noise",
feature = "mplex",
feature = "yamux" feature = "yamux"
))] ))]
#[cfg_attr( #[cfg_attr(
@ -231,11 +223,7 @@ pub async fn development_transport(
Ok(transport Ok(transport
.upgrade(core::upgrade::Version::V1) .upgrade(core::upgrade::Version::V1)
.authenticate(noise::Config::new(&keypair).unwrap()) .authenticate(noise::Config::new(&keypair).unwrap())
.multiplex(core::upgrade::SelectUpgrade::new( .multiplex(yamux::Config::default())
yamux::Config::default(),
#[allow(deprecated)]
mplex::MplexConfig::default(),
))
.timeout(std::time::Duration::from_secs(20)) .timeout(std::time::Duration::from_secs(20))
.boxed()) .boxed())
} }
@ -245,7 +233,7 @@ pub async fn development_transport(
/// * DNS resolution. /// * DNS resolution.
/// * Noise protocol encryption. /// * Noise protocol encryption.
/// * Websockets. /// * Websockets.
/// * Both Yamux and Mplex for substream multiplexing. /// * Yamux for substream multiplexing.
/// ///
/// All async I/O of the transport is based on `tokio`. /// All async I/O of the transport is based on `tokio`.
/// ///
@ -259,7 +247,6 @@ pub async fn development_transport(
), ),
feature = "websocket", feature = "websocket",
feature = "noise", feature = "noise",
feature = "mplex",
feature = "yamux" feature = "yamux"
))] ))]
#[cfg_attr( #[cfg_attr(
@ -288,11 +275,7 @@ pub fn tokio_development_transport(
Ok(transport Ok(transport
.upgrade(core::upgrade::Version::V1) .upgrade(core::upgrade::Version::V1)
.authenticate(noise::Config::new(&keypair).unwrap()) .authenticate(noise::Config::new(&keypair).unwrap())
.multiplex(core::upgrade::SelectUpgrade::new( .multiplex(yamux::Config::default())
yamux::Config::default(),
#[allow(deprecated)]
mplex::MplexConfig::default(),
))
.timeout(std::time::Duration::from_secs(20)) .timeout(std::time::Duration::from_secs(20))
.boxed()) .boxed())
} }

View File

@ -43,7 +43,7 @@ pub trait TransportExt: Transport {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// use libp2p_mplex as mplex; /// use libp2p_yamux as yamux;
/// use libp2p_noise as noise; /// use libp2p_noise as noise;
/// use libp2p_tcp as tcp; /// use libp2p_tcp as tcp;
/// use libp2p::{ /// use libp2p::{
@ -61,7 +61,7 @@ pub trait TransportExt: Transport {
/// noise::Config::new(&id_keys) /// noise::Config::new(&id_keys)
/// .expect("Signing libp2p-noise static DH keypair failed."), /// .expect("Signing libp2p-noise static DH keypair failed."),
/// ) /// )
/// .multiplex(mplex::MplexConfig::new()) /// .multiplex(yamux::Config::default())
/// .boxed(); /// .boxed();
/// ///
/// let (transport, sinks) = transport.with_bandwidth_logging(); /// let (transport, sinks) = transport.with_bandwidth_logging();

View File

@ -55,7 +55,7 @@
//! edition = "2021" //! edition = "2021"
//! //!
//! [dependencies] //! [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" //! futures = "0.3.21"
//! async-std = { version = "1.12.0", features = ["attributes"] } //! async-std = { version = "1.12.0", features = ["attributes"] }
//! ``` //! ```

View File

@ -42,7 +42,7 @@ async-std = { version = "1.6.3", features = ["unstable"] }
env_logger = "0.10.0" env_logger = "0.10.0"
hex = "0.4.2" hex = "0.4.2"
libp2p-core = { workspace = true } libp2p-core = { workspace = true }
libp2p-mplex = { workspace = true } libp2p-yamux = { workspace = true }
libp2p-noise = { workspace = true } libp2p-noise = { workspace = true }
libp2p-swarm-test = { workspace = true } libp2p-swarm-test = { workspace = true }
quickcheck = { workspace = true } quickcheck = { workspace = true }

View File

@ -99,12 +99,12 @@
//! let local_key = identity::Keypair::generate_ed25519(); //! let local_key = identity::Keypair::generate_ed25519();
//! let local_peer_id = local_key.public().to_peer_id(); //! 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). //! // This is test transport (memory).
//! let transport = MemoryTransport::default() //! let transport = MemoryTransport::default()
//! .upgrade(libp2p_core::upgrade::Version::V1) //! .upgrade(libp2p_core::upgrade::Version::V1)
//! .authenticate(libp2p_noise::Config::new(&local_key).unwrap()) //! .authenticate(libp2p_noise::Config::new(&local_key).unwrap())
//! .multiplex(libp2p_mplex::MplexConfig::new()) //! .multiplex(libp2p_yamux::Config::default())
//! .boxed(); //! .boxed();
//! //!
//! // Create a Gossipsub topic //! // Create a Gossipsub topic