From 66c2319230f77a8f3d5b1efa7ccfadfcc5d5df0c Mon Sep 17 00:00:00 2001 From: Max Inden Date: Tue, 19 Jul 2022 08:57:50 +0200 Subject: [PATCH 01/13] transports/tcp: Bump to v0.35.0 (#2760) Follow up on https://github.com/libp2p/rust-libp2p/pull/2724/. Given that libp2p-core is bumped to v0.35.0, libp2p-tcp needs to be bumped as well. --- Cargo.toml | 2 +- transports/tcp/CHANGELOG.md | 4 ++++ transports/tcp/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9e6d6ea4786..f716d822552 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,7 +107,7 @@ smallvec = "1.6.1" libp2p-deflate = { version = "0.35.0", path = "transports/deflate", optional = true } libp2p-dns = { version = "0.35.0", path = "transports/dns", optional = true, default-features = false } libp2p-mdns = { version = "0.39.0", path = "protocols/mdns", optional = true } -libp2p-tcp = { version = "0.34.0", path = "transports/tcp", default-features = false, optional = true } +libp2p-tcp = { version = "0.35.0", path = "transports/tcp", default-features = false, optional = true } libp2p-websocket = { version = "0.37.0", path = "transports/websocket", optional = true } [target.'cfg(not(target_os = "unknown"))'.dependencies] diff --git a/transports/tcp/CHANGELOG.md b/transports/tcp/CHANGELOG.md index 4a9d0245b2b..5d860270be9 100644 --- a/transports/tcp/CHANGELOG.md +++ b/transports/tcp/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.35.0 [unreleased] + +- Update to `libp2p-core` `v0.35.0`. + # 0.34.0 - Update to `libp2p-core` `v0.34.0`. diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 0b86689fa32..22969c060ff 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-tcp" edition = "2021" rust-version = "1.56.1" description = "TCP/IP transport protocol for libp2p" -version = "0.34.0" +version = "0.35.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" From c8066df232e16f1d0908c6dfda91a366d7d21028 Mon Sep 17 00:00:00 2001 From: tgmichel Date: Tue, 19 Jul 2022 09:14:00 +0200 Subject: [PATCH 02/13] *: Update to `if-watch` `1.1.1` (#2754) --- protocols/mdns/CHANGELOG.md | 1 + protocols/mdns/Cargo.toml | 2 +- transports/tcp/CHANGELOG.md | 2 ++ transports/tcp/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/protocols/mdns/CHANGELOG.md b/protocols/mdns/CHANGELOG.md index 1bf4be8f6ae..e3b37be4c60 100644 --- a/protocols/mdns/CHANGELOG.md +++ b/protocols/mdns/CHANGELOG.md @@ -1,6 +1,7 @@ # 0.39.0 [unreleased] - Update to `libp2p-swarm` `v0.38.0`. +- Update to `if-watch` `v1.1.1`. - Update to `libp2p-core` `v0.35.0`. diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index eb32b7e9426..bb060c9ed1f 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -15,7 +15,7 @@ async-io = "1.3.1" data-encoding = "2.3.2" dns-parser = "0.8.0" futures = "0.3.13" -if-watch = "1.0.0" +if-watch = "1.1.1" lazy_static = "1.4.0" libp2p-core = { version = "0.35.0", path = "../../core", default-features = false } libp2p-swarm = { version = "0.38.0", path = "../../swarm" } diff --git a/transports/tcp/CHANGELOG.md b/transports/tcp/CHANGELOG.md index 5d860270be9..bf7a5e0daba 100644 --- a/transports/tcp/CHANGELOG.md +++ b/transports/tcp/CHANGELOG.md @@ -2,6 +2,8 @@ - Update to `libp2p-core` `v0.35.0`. +- Update to `if-watch` `v1.1.1`. + # 0.34.0 - Update to `libp2p-core` `v0.34.0`. diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 22969c060ff..7273db58c51 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] async-io-crate = { package = "async-io", version = "1.2.0", optional = true } futures = "0.3.8" futures-timer = "3.0" -if-watch = { version = "1.0.0", optional = true } +if-watch = { version = "1.1.1", optional = true } if-addrs = { version = "0.7.0", optional = true } ipnet = "2.0.0" libc = "0.2.80" From 163c5c17520926f829cf3dfdb17d5c2d79b0f7df Mon Sep 17 00:00:00 2001 From: Hubert Date: Thu, 21 Jul 2022 22:58:41 +0200 Subject: [PATCH 03/13] README.md: Add crates.io and docs.rs badges (#2766) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fb45ac38c10..6e668184a8b 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![dependency status](https://deps.rs/repo/github/libp2p/rust-libp2p/status.svg?style=flat-square)](https://deps.rs/repo/github/libp2p/rust-libp2p) +[![Crates.io](https://img.shields.io/crates/v/libp2p.svg)](https://crates.io/crates/libp2p) +[![docs.rs](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/libp2p) This repository is the central place for Rust development of the [libp2p](https://libp2p.io) spec. From 51a847128cb641202241b641066a1ea1fdfcd078 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Jul 2022 11:20:39 +0200 Subject: [PATCH 04/13] build(deps): Update prometheus-client requirement from 0.16.0 to 0.17.0 (#2761) * build(deps): Update prometheus-client requirement from 0.16.0 to 0.17.0 Updates the requirements on [prometheus-client](https://github.com/prometheus/client_rust) to permit the latest version. - [Release notes](https://github.com/prometheus/client_rust/releases) - [Changelog](https://github.com/prometheus/client_rust/blob/master/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_rust/compare/v0.16.0...v0.17.0) --- updated-dependencies: - dependency-name: prometheus-client dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- misc/metrics/CHANGELOG.md | 4 ++++ misc/metrics/Cargo.toml | 2 +- protocols/gossipsub/CHANGELOG.md | 4 ++++ protocols/gossipsub/Cargo.toml | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/misc/metrics/CHANGELOG.md b/misc/metrics/CHANGELOG.md index c9cc21a06f1..06e2163597e 100644 --- a/misc/metrics/CHANGELOG.md +++ b/misc/metrics/CHANGELOG.md @@ -16,6 +16,10 @@ - Update to `libp2p-core` `v0.35.0`. +- Update to `prometheus-client` `v0.17.0`. See [PR 2761]. + +[PR 2761]: https://github.com/libp2p/rust-libp2p/pull/2761/ + [PR 2734]: https://github.com/libp2p/rust-libp2p/pull/2734/ # 0.7.0 diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index 7fdfec733e0..7ccd259e535 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -26,7 +26,7 @@ libp2p-kad = { version = "0.39.0", path = "../../protocols/kad", optional = true libp2p-ping = { version = "0.38.0", path = "../../protocols/ping", optional = true } libp2p-relay = { version = "0.11.0", path = "../../protocols/relay", optional = true } libp2p-swarm = { version = "0.38.0", path = "../../swarm" } -prometheus-client = "0.16.0" +prometheus-client = "0.17.0" [target.'cfg(not(target_os = "unknown"))'.dependencies] libp2p-gossipsub = { version = "0.40.0", path = "../../protocols/gossipsub", optional = true } diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index f6b0902d306..233d3873e98 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -4,6 +4,10 @@ - Update to `libp2p-core` `v0.35.0`. +- Update to `prometheus-client` `v0.17.0`. See [PR 2761]. + +[PR 2761]: https://github.com/libp2p/rust-libp2p/pull/2761/ + # 0.39.0 - Update to `libp2p-core` `v0.34.0`. diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index e992fb3b9ef..da97500808d 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -31,7 +31,7 @@ serde = { version = "1", optional = true, features = ["derive"] } wasm-timer = "0.2.5" instant = "0.1.11" # Metrics dependencies -prometheus-client = "0.16.0" +prometheus-client = "0.17.0" [dev-dependencies] async-std = "1.6.3" From f15a3dc4e018c706b9b900dc01bdeafe82c62402 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 22 Jul 2022 10:40:27 +0100 Subject: [PATCH 05/13] core/muxing: Drop `Unpin` requirement from `SubstreamBox` (#2762) We are already boxing the given object so we might as well pin to to avoid the `Unpin` trait bound. --- core/CHANGELOG.md | 2 ++ core/src/muxing/boxed.rs | 34 +++++++++++++++++----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 0102096d780..2ee23a194be 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -2,8 +2,10 @@ - Remove `StreamMuxer::poll_event` in favor of individual functions: `poll_inbound`, `poll_outbound` and `poll_address_change`. Consequently, `StreamMuxerEvent` is also removed. See [PR 2724]. +- Drop `Unpin` requirement from `SubstreamBox`. See [PR XXXX. [PR 2724]: https://github.com/libp2p/rust-libp2p/pull/2724 +[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX # 0.34.0 diff --git a/core/src/muxing/boxed.rs b/core/src/muxing/boxed.rs index 80753813dcb..259dfd01219 100644 --- a/core/src/muxing/boxed.rs +++ b/core/src/muxing/boxed.rs @@ -17,7 +17,7 @@ pub struct StreamMuxerBox { /// /// A [`SubstreamBox`] erases the concrete type it is given and only retains its `AsyncRead` /// and `AsyncWrite` capabilities. -pub struct SubstreamBox(Box); +pub struct SubstreamBox(Pin>); struct Wrap where @@ -106,8 +106,8 @@ impl StreamMuxer for StreamMuxerBox { impl SubstreamBox { /// Construct a new [`SubstreamBox`] from something that implements [`AsyncRead`] and [`AsyncWrite`]. - pub fn new(stream: S) -> Self { - Self(Box::new(stream)) + pub fn new(stream: S) -> Self { + Self(Box::pin(stream)) } } @@ -118,7 +118,7 @@ impl fmt::Debug for SubstreamBox { } /// Workaround because Rust does not allow `Box`. -trait AsyncReadWrite: AsyncRead + AsyncWrite + Unpin { +trait AsyncReadWrite: AsyncRead + AsyncWrite { /// Helper function to capture the erased inner type. /// /// Used to make the [`Debug`] implementation of [`SubstreamBox`] more useful. @@ -127,7 +127,7 @@ trait AsyncReadWrite: AsyncRead + AsyncWrite + Unpin { impl AsyncReadWrite for S where - S: AsyncRead + AsyncWrite + Unpin, + S: AsyncRead + AsyncWrite, { fn type_name(&self) -> &'static str { std::any::type_name::() @@ -136,44 +136,44 @@ where impl AsyncRead for SubstreamBox { fn poll_read( - self: Pin<&mut Self>, + mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll> { - Pin::new(&mut self.get_mut().0).poll_read(cx, buf) + self.0.as_mut().poll_read(cx, buf) } fn poll_read_vectored( - self: Pin<&mut Self>, + mut self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>], ) -> Poll> { - Pin::new(&mut self.get_mut().0).poll_read_vectored(cx, bufs) + self.0.as_mut().poll_read_vectored(cx, bufs) } } impl AsyncWrite for SubstreamBox { fn poll_write( - self: Pin<&mut Self>, + mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll> { - Pin::new(&mut self.get_mut().0).poll_write(cx, buf) + self.0.as_mut().poll_write(cx, buf) } fn poll_write_vectored( - self: Pin<&mut Self>, + mut self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll> { - Pin::new(&mut self.get_mut().0).poll_write_vectored(cx, bufs) + self.0.as_mut().poll_write_vectored(cx, bufs) } - fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - Pin::new(&mut self.get_mut().0).poll_flush(cx) + fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + self.0.as_mut().poll_flush(cx) } - fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - Pin::new(&mut self.get_mut().0).poll_close(cx) + fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + self.0.as_mut().poll_close(cx) } } From 2e2c117dab52ec46c94310bbc71a4d8398988554 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 22 Jul 2022 10:59:55 +0100 Subject: [PATCH 06/13] core/tests: Remove unnecessary `Arc` (#2763) --- muxers/mplex/tests/async_write.rs | 3 +-- muxers/mplex/tests/two_peers.rs | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/muxers/mplex/tests/async_write.rs b/muxers/mplex/tests/async_write.rs index 94d69cd7ff1..2c4a2d10f0d 100644 --- a/muxers/mplex/tests/async_write.rs +++ b/muxers/mplex/tests/async_write.rs @@ -22,7 +22,6 @@ use futures::future::poll_fn; use futures::{channel::oneshot, prelude::*}; use libp2p_core::{upgrade, StreamMuxer, Transport}; use libp2p_tcp::TcpTransport; -use std::sync::Arc; #[test] fn async_write() { @@ -72,7 +71,7 @@ fn async_write() { let mut transport = TcpTransport::default() .and_then(move |c, e| upgrade::apply(c, mplex, e, upgrade::Version::V1)); - let client = Arc::new(transport.dial(rx.await.unwrap()).unwrap().await.unwrap()); + let client = transport.dial(rx.await.unwrap()).unwrap().await.unwrap(); let mut inbound = poll_fn(|cx| client.poll_inbound(cx)).await.unwrap(); inbound.write_all(b"hello world").await.unwrap(); diff --git a/muxers/mplex/tests/two_peers.rs b/muxers/mplex/tests/two_peers.rs index 20812fde55c..2b976c12fea 100644 --- a/muxers/mplex/tests/two_peers.rs +++ b/muxers/mplex/tests/two_peers.rs @@ -22,7 +22,6 @@ use futures::future::poll_fn; use futures::{channel::oneshot, prelude::*}; use libp2p_core::{upgrade, StreamMuxer, Transport}; use libp2p_tcp::TcpTransport; -use std::sync::Arc; #[test] fn client_to_server_outbound() { @@ -73,7 +72,7 @@ fn client_to_server_outbound() { .and_then(move |c, e| upgrade::apply(c, mplex, e, upgrade::Version::V1)) .boxed(); - let client = Arc::new(transport.dial(rx.await.unwrap()).unwrap().await.unwrap()); + let client = transport.dial(rx.await.unwrap()).unwrap().await.unwrap(); let mut inbound = poll_fn(|cx| client.poll_inbound(cx)).await.unwrap(); inbound.write_all(b"hello world").await.unwrap(); inbound.close().await.unwrap(); @@ -108,17 +107,15 @@ fn client_to_server_inbound() { tx.send(addr).unwrap(); - let client = Arc::new( - transport - .next() - .await - .expect("some event") - .into_incoming() - .unwrap() - .0 - .await - .unwrap(), - ); + let client = transport + .next() + .await + .expect("some event") + .into_incoming() + .unwrap() + .0 + .await + .unwrap(); let mut inbound = poll_fn(|cx| client.poll_inbound(cx)).await.unwrap(); From 95713ab91c4dcd8494daa190a45d4a9444ff91b0 Mon Sep 17 00:00:00 2001 From: Elena Frank Date: Sat, 23 Jul 2022 20:48:52 +0200 Subject: [PATCH 07/13] core: fix PR number in changelog entry (#2769) --- core/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 2ee23a194be..5098d45dd11 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -2,10 +2,10 @@ - Remove `StreamMuxer::poll_event` in favor of individual functions: `poll_inbound`, `poll_outbound` and `poll_address_change`. Consequently, `StreamMuxerEvent` is also removed. See [PR 2724]. -- Drop `Unpin` requirement from `SubstreamBox`. See [PR XXXX. +- Drop `Unpin` requirement from `SubstreamBox`. See [PR 2762]. [PR 2724]: https://github.com/libp2p/rust-libp2p/pull/2724 -[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX +[PR 2762]: https://github.com/libp2p/rust-libp2p/pull/2762 # 0.34.0 From f85a9909aca659f10f6b024fa0ed581199dddf90 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 25 Jul 2022 08:34:05 +0100 Subject: [PATCH 08/13] core/tests: Remove unnecessary util module (#2764) --- core/tests/transport_upgrade.rs | 12 --------- core/tests/util.rs | 47 --------------------------------- 2 files changed, 59 deletions(-) delete mode 100644 core/tests/util.rs diff --git a/core/tests/transport_upgrade.rs b/core/tests/transport_upgrade.rs index ecba64dfb2f..723a04b0780 100644 --- a/core/tests/transport_upgrade.rs +++ b/core/tests/transport_upgrade.rs @@ -18,8 +18,6 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -mod util; - use futures::prelude::*; use libp2p_core::identity; use libp2p_core::transport::{MemoryTransport, Transport}; @@ -91,11 +89,6 @@ fn upgrade_pipeline() { .apply(HelloUpgrade {}) .apply(HelloUpgrade {}) .multiplex(MplexConfig::default()) - .and_then(|(peer, mplex), _| { - // Gracefully close the connection to allow protocol - // negotiation to complete. - util::CloseMuxer::new(mplex).map_ok(move |mplex| (peer, mplex)) - }) .boxed(); let dialer_keys = identity::Keypair::generate_ed25519(); @@ -110,11 +103,6 @@ fn upgrade_pipeline() { .apply(HelloUpgrade {}) .apply(HelloUpgrade {}) .multiplex(MplexConfig::default()) - .and_then(|(peer, mplex), _| { - // Gracefully close the connection to allow protocol - // negotiation to complete. - util::CloseMuxer::new(mplex).map_ok(move |mplex| (peer, mplex)) - }) .boxed(); let listen_addr1 = Multiaddr::from(Protocol::Memory(random::())); diff --git a/core/tests/util.rs b/core/tests/util.rs deleted file mode 100644 index 7ca52188a52..00000000000 --- a/core/tests/util.rs +++ /dev/null @@ -1,47 +0,0 @@ -#![allow(dead_code)] - -use futures::prelude::*; -use libp2p_core::muxing::StreamMuxer; -use std::{pin::Pin, task::Context, task::Poll}; - -pub struct CloseMuxer { - state: CloseMuxerState, -} - -impl CloseMuxer { - pub fn new(m: M) -> CloseMuxer { - CloseMuxer { - state: CloseMuxerState::Close(m), - } - } -} - -pub enum CloseMuxerState { - Close(M), - Done, -} - -impl Future for CloseMuxer -where - M: StreamMuxer, - M::Error: From, -{ - type Output = Result; - - fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - loop { - match std::mem::replace(&mut self.state, CloseMuxerState::Done) { - CloseMuxerState::Close(muxer) => { - if !muxer.poll_close(cx)?.is_ready() { - self.state = CloseMuxerState::Close(muxer); - return Poll::Pending; - } - return Poll::Ready(Ok(muxer)); - } - CloseMuxerState::Done => panic!(), - } - } - } -} - -impl Unpin for CloseMuxer {} From c19a211dfd489b1b1412050c5adccf896d78ac50 Mon Sep 17 00:00:00 2001 From: Elena Frank Date: Mon, 25 Jul 2022 10:45:43 +0200 Subject: [PATCH 09/13] misc/metrics: fix clippy::assign-op-pattern (#2773) --- misc/metrics/src/identify.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/metrics/src/identify.rs b/misc/metrics/src/identify.rs index b3ae5a75910..730528167a8 100644 --- a/misc/metrics/src/identify.rs +++ b/misc/metrics/src/identify.rs @@ -223,7 +223,7 @@ impl EncodeMetric for Protocols { |mut acc, (_, protocols)| { for protocol in protocols { let count = acc.entry(protocol.to_string()).or_default(); - *count = *count + 1; + *count += 1; } acc }, From 0ec3bbccb2eb8dc4c1db62db184e1358777942ae Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 25 Jul 2022 15:49:22 +0100 Subject: [PATCH 10/13] core/muxing: Remove `Unpin` requirement from `StreamMuxer::Substream` (#2776) --- core/CHANGELOG.md | 3 ++- core/src/muxing/boxed.rs | 4 ++-- core/src/transport/upgrade.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 5098d45dd11..0fb742af96a 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -2,10 +2,11 @@ - Remove `StreamMuxer::poll_event` in favor of individual functions: `poll_inbound`, `poll_outbound` and `poll_address_change`. Consequently, `StreamMuxerEvent` is also removed. See [PR 2724]. -- Drop `Unpin` requirement from `SubstreamBox`. See [PR 2762]. +- Drop `Unpin` requirement from `SubstreamBox`. See [PR 2762] and [PR 2776]. [PR 2724]: https://github.com/libp2p/rust-libp2p/pull/2724 [PR 2762]: https://github.com/libp2p/rust-libp2p/pull/2762 +[PR 2776]: https://github.com/libp2p/rust-libp2p/pull/2776 # 0.34.0 diff --git a/core/src/muxing/boxed.rs b/core/src/muxing/boxed.rs index 259dfd01219..5dc98835866 100644 --- a/core/src/muxing/boxed.rs +++ b/core/src/muxing/boxed.rs @@ -29,7 +29,7 @@ where impl StreamMuxer for Wrap where T: StreamMuxer, - T::Substream: Send + Unpin + 'static, + T::Substream: Send + 'static, T::Error: Send + Sync + 'static, { type Substream = SubstreamBox; @@ -71,7 +71,7 @@ impl StreamMuxerBox { pub fn new(muxer: T) -> StreamMuxerBox where T: StreamMuxer + Send + Sync + 'static, - T::Substream: Send + Unpin + 'static, + T::Substream: Send + 'static, T::Error: Send + Sync + 'static, { let wrap = Wrap { inner: muxer }; diff --git a/core/src/transport/upgrade.rs b/core/src/transport/upgrade.rs index da87fb9dd6a..eb7b310c0a9 100644 --- a/core/src/transport/upgrade.rs +++ b/core/src/transport/upgrade.rs @@ -300,7 +300,7 @@ impl Multiplexed { T::ListenerUpgrade: Send + 'static, T::Error: Send + Sync, M: StreamMuxer + Send + Sync + 'static, - M::Substream: Send + Unpin + 'static, + M::Substream: Send + 'static, M::Error: Send + Sync + 'static, { boxed(self.map(|(i, m), _| (i, StreamMuxerBox::new(m)))) From 74f01e47c9104678a211fec36918f1bd854c1c79 Mon Sep 17 00:00:00 2001 From: Elena Frank Date: Mon, 25 Jul 2022 17:33:31 +0200 Subject: [PATCH 11/13] transports/tcp: fix clippy::from-over-into (#2774) --- transports/tcp/src/provider/tokio.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/transports/tcp/src/provider/tokio.rs b/transports/tcp/src/provider/tokio.rs index fa9ebe3b3ff..564eebfa48b 100644 --- a/transports/tcp/src/provider/tokio.rs +++ b/transports/tcp/src/provider/tokio.rs @@ -155,9 +155,9 @@ impl Provider for Tcp { #[derive(Debug)] pub struct TcpStream(pub tokio_crate::net::TcpStream); -impl Into for TcpStream { - fn into(self: TcpStream) -> tokio_crate::net::TcpStream { - self.0 +impl From for tokio_crate::net::TcpStream { + fn from(t: TcpStream) -> tokio_crate::net::TcpStream { + t.0 } } From ce963dfcaa0a99e4b9bef27cdfe29e48946d823a Mon Sep 17 00:00:00 2001 From: Elena Frank Date: Mon, 25 Jul 2022 17:57:50 +0200 Subject: [PATCH 12/13] core: fix clippy::op-ref, clippy::needless-borrow (#2770) --- core/src/identity/ecdsa.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/identity/ecdsa.rs b/core/src/identity/ecdsa.rs index b883243b13b..81dfec4b4e0 100644 --- a/core/src/identity/ecdsa.rs +++ b/core/src/identity/ecdsa.rs @@ -157,7 +157,7 @@ impl PublicKey { let buf = Self::del_asn1_header(k).ok_or_else(|| { DecodingError::new("failed to parse asn.1 encoded ecdsa p256 public key") })?; - Self::from_bytes(&buf) + Self::from_bytes(buf) } // ecPublicKey (ANSI X9.62 public key type) OID: 1.2.840.10045.2.1 @@ -198,8 +198,8 @@ impl PublicKey { if asn1_head[0] != 0x30 || asn1_head[2] != 0x30 || asn1_head[3] as usize != oids_len - || &oids_buf[..Self::EC_PUBLIC_KEY_OID.len()] != &Self::EC_PUBLIC_KEY_OID - || &oids_buf[Self::EC_PUBLIC_KEY_OID.len()..] != &Self::SECP_256_R1_OID + || oids_buf[..Self::EC_PUBLIC_KEY_OID.len()] != Self::EC_PUBLIC_KEY_OID + || oids_buf[Self::EC_PUBLIC_KEY_OID.len()..] != Self::SECP_256_R1_OID || bitstr_head[0] != 0x03 || bitstr_head[2] != 0x00 { From 56c492cf41191ed7e299b8de29a2dc064b410e57 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 27 Jul 2022 08:23:07 +0200 Subject: [PATCH 13/13] core/muxing: Drop `Sync` requirement for `StreamMuxer` on `StreamMuxerBox` (#2775) `StreamMuxerBox` is never shared across threads but owned by a single connection. Restricting it to be `Sync` unnecessarily limits the design space around the `StreamMuxer` trait and its implementations. --- core/CHANGELOG.md | 2 ++ core/src/muxing/boxed.rs | 4 ++-- core/src/transport/upgrade.rs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 0fb742af96a..047a7ac40e2 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -3,9 +3,11 @@ - Remove `StreamMuxer::poll_event` in favor of individual functions: `poll_inbound`, `poll_outbound` and `poll_address_change`. Consequently, `StreamMuxerEvent` is also removed. See [PR 2724]. - Drop `Unpin` requirement from `SubstreamBox`. See [PR 2762] and [PR 2776]. +- Drop `Sync` requirement on `StreamMuxer` for constructing `StreamMuxerBox`. See [PR 2775]. [PR 2724]: https://github.com/libp2p/rust-libp2p/pull/2724 [PR 2762]: https://github.com/libp2p/rust-libp2p/pull/2762 +[PR 2775]: https://github.com/libp2p/rust-libp2p/pull/2775 [PR 2776]: https://github.com/libp2p/rust-libp2p/pull/2776 # 0.34.0 diff --git a/core/src/muxing/boxed.rs b/core/src/muxing/boxed.rs index 5dc98835866..8c6467dd7ad 100644 --- a/core/src/muxing/boxed.rs +++ b/core/src/muxing/boxed.rs @@ -10,7 +10,7 @@ use std::task::{Context, Poll}; /// Abstract `StreamMuxer`. pub struct StreamMuxerBox { - inner: Box + Send + Sync>, + inner: Box + Send>, } /// Abstract type for asynchronous reading and writing. @@ -70,7 +70,7 @@ impl StreamMuxerBox { /// Turns a stream muxer into a `StreamMuxerBox`. pub fn new(muxer: T) -> StreamMuxerBox where - T: StreamMuxer + Send + Sync + 'static, + T: StreamMuxer + Send + 'static, T::Substream: Send + 'static, T::Error: Send + Sync + 'static, { diff --git a/core/src/transport/upgrade.rs b/core/src/transport/upgrade.rs index eb7b310c0a9..8fc0454794f 100644 --- a/core/src/transport/upgrade.rs +++ b/core/src/transport/upgrade.rs @@ -299,7 +299,7 @@ impl Multiplexed { T::Dial: Send + 'static, T::ListenerUpgrade: Send + 'static, T::Error: Send + Sync, - M: StreamMuxer + Send + Sync + 'static, + M: StreamMuxer + Send + 'static, M::Substream: Send + 'static, M::Error: Send + Sync + 'static, {