From fa8151ec39c171c7a684a90db09a6d725c41a164 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 9 Dec 2022 09:31:46 +1100 Subject: [PATCH 1/9] Fix `cargo-semver-checks` hickup --- protocols/dcutr/src/handler/relayed.rs | 12 +++++++--- protocols/dcutr/src/lib.rs | 27 ++++++++++++++++++----- protocols/dcutr/src/protocol/inbound.rs | 28 ++++++++++++++---------- protocols/dcutr/src/protocol/outbound.rs | 19 +++++++++------- 4 files changed, 57 insertions(+), 29 deletions(-) diff --git a/protocols/dcutr/src/handler/relayed.rs b/protocols/dcutr/src/handler/relayed.rs index 301f2ee3d82..673bbb7c45c 100644 --- a/protocols/dcutr/src/handler/relayed.rs +++ b/protocols/dcutr/src/handler/relayed.rs @@ -134,7 +134,10 @@ pub struct Handler { /// A pending fatal error that results in the connection being closed. pending_error: Option< ConnectionHandlerUpgrErr< - EitherError, + EitherError< + protocol::inbound::InboundUpgradeError, + protocol::outbound::OutboundUpgradeError, + >, >, >, /// Queue of events to return when polled. @@ -148,7 +151,7 @@ pub struct Handler { >, /// Inbound connect, accepted by the behaviour, pending completion. inbound_connect: - Option, protocol::inbound::UpgradeError>>>, + Option, protocol::inbound::InboundUpgradeError>>>, keep_alive: KeepAlive, } @@ -302,7 +305,10 @@ impl ConnectionHandler for Handler { type InEvent = Command; type OutEvent = Event; type Error = ConnectionHandlerUpgrErr< - EitherError, + EitherError< + protocol::inbound::InboundUpgradeError, + protocol::outbound::OutboundUpgradeError, + >, >; type InboundProtocol = upgrade::EitherUpgrade; type OutboundProtocol = protocol::outbound::Upgrade; diff --git a/protocols/dcutr/src/lib.rs b/protocols/dcutr/src/lib.rs index 738af5300b1..4ce15ffed74 100644 --- a/protocols/dcutr/src/lib.rs +++ b/protocols/dcutr/src/lib.rs @@ -26,13 +26,28 @@ pub mod behaviour; mod handler; mod protocol; - -pub use protocol::{ - inbound::UpgradeError as InboundUpgradeError, outbound::UpgradeError as OutboundUpgradeError, - PROTOCOL_NAME, -}; - #[allow(clippy::derive_partial_eq_without_eq)] mod message_proto { include!(concat!(env!("OUT_DIR"), "/holepunch.pb.rs")); } + +pub use protocol::PROTOCOL_NAME; +pub mod inbound { + pub use crate::protocol::inbound::InboundUpgradeError as UpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 +} + +pub mod outbound { + pub use crate::protocol::outbound::OutboundUpgradeError as UpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 +} + +#[deprecated( + since = "0.8.1", + note = "Use `libp2p_dcutr::inbound::UpgradeError` instead.`" +)] +pub type InboundUpgradeError = inbound::UpgradeError; + +#[deprecated( + since = "0.8.1", + note = "Use `libp2p_dcutr::outbound::UpgradeError` instead.`" +)] +pub type OutboundUpgradeError = outbound::UpgradeError; diff --git a/protocols/dcutr/src/protocol/inbound.rs b/protocols/dcutr/src/protocol/inbound.rs index 3b964881f51..78a8cc0e0fe 100644 --- a/protocols/dcutr/src/protocol/inbound.rs +++ b/protocols/dcutr/src/protocol/inbound.rs @@ -40,7 +40,7 @@ impl upgrade::UpgradeInfo for Upgrade { impl upgrade::InboundUpgrade for Upgrade { type Output = PendingConnect; - type Error = UpgradeError; + type Error = InboundUpgradeError; type Future = BoxFuture<'static, Result>; fn upgrade_inbound(self, substream: NegotiatedSubstream, _: Self::Info) -> Self::Future { @@ -50,11 +50,13 @@ impl upgrade::InboundUpgrade for Upgrade { ); async move { - let HolePunch { r#type, obs_addrs } = - substream.next().await.ok_or(UpgradeError::StreamClosed)??; + let HolePunch { r#type, obs_addrs } = substream + .next() + .await + .ok_or(InboundUpgradeError::StreamClosed)??; let obs_addrs = if obs_addrs.is_empty() { - return Err(UpgradeError::NoAddresses); + return Err(InboundUpgradeError::NoAddresses); } else { obs_addrs .into_iter() @@ -65,14 +67,15 @@ impl upgrade::InboundUpgrade for Upgrade { Err(_) => true, }) .collect::, _>>() - .map_err(|_| UpgradeError::InvalidAddrs)? + .map_err(|_| InboundUpgradeError::InvalidAddrs)? }; - let r#type = hole_punch::Type::from_i32(r#type).ok_or(UpgradeError::ParseTypeField)?; + let r#type = + hole_punch::Type::from_i32(r#type).ok_or(InboundUpgradeError::ParseTypeField)?; match r#type { hole_punch::Type::Connect => {} - hole_punch::Type::Sync => return Err(UpgradeError::UnexpectedTypeSync), + hole_punch::Type::Sync => return Err(InboundUpgradeError::UnexpectedTypeSync), } Ok(PendingConnect { @@ -93,7 +96,7 @@ impl PendingConnect { pub async fn accept( mut self, local_obs_addrs: Vec, - ) -> Result, UpgradeError> { + ) -> Result, InboundUpgradeError> { let msg = HolePunch { r#type: hole_punch::Type::Connect.into(), obs_addrs: local_obs_addrs.into_iter().map(|a| a.to_vec()).collect(), @@ -104,11 +107,12 @@ impl PendingConnect { .substream .next() .await - .ok_or(UpgradeError::StreamClosed)??; + .ok_or(InboundUpgradeError::StreamClosed)??; - let r#type = hole_punch::Type::from_i32(r#type).ok_or(UpgradeError::ParseTypeField)?; + let r#type = + hole_punch::Type::from_i32(r#type).ok_or(InboundUpgradeError::ParseTypeField)?; match r#type { - hole_punch::Type::Connect => return Err(UpgradeError::UnexpectedTypeConnect), + hole_punch::Type::Connect => return Err(InboundUpgradeError::UnexpectedTypeConnect), hole_punch::Type::Sync => {} } @@ -117,7 +121,7 @@ impl PendingConnect { } #[derive(Debug, Error)] -pub enum UpgradeError { +pub enum InboundUpgradeError { #[error(transparent)] Codec(#[from] prost_codec::Error), #[error("Stream closed")] diff --git a/protocols/dcutr/src/protocol/outbound.rs b/protocols/dcutr/src/protocol/outbound.rs index ca2a340aecb..58dba144e0e 100644 --- a/protocols/dcutr/src/protocol/outbound.rs +++ b/protocols/dcutr/src/protocol/outbound.rs @@ -50,7 +50,7 @@ impl Upgrade { impl upgrade::OutboundUpgrade for Upgrade { type Output = Connect; - type Error = UpgradeError; + type Error = OutboundUpgradeError; type Future = BoxFuture<'static, Result>; fn upgrade_outbound(self, substream: NegotiatedSubstream, _: Self::Info) -> Self::Future { @@ -69,19 +69,22 @@ impl upgrade::OutboundUpgrade for Upgrade { let sent_time = Instant::now(); - let HolePunch { r#type, obs_addrs } = - substream.next().await.ok_or(UpgradeError::StreamClosed)??; + let HolePunch { r#type, obs_addrs } = substream + .next() + .await + .ok_or(OutboundUpgradeError::StreamClosed)??; let rtt = sent_time.elapsed(); - let r#type = hole_punch::Type::from_i32(r#type).ok_or(UpgradeError::ParseTypeField)?; + let r#type = + hole_punch::Type::from_i32(r#type).ok_or(OutboundUpgradeError::ParseTypeField)?; match r#type { hole_punch::Type::Connect => {} - hole_punch::Type::Sync => return Err(UpgradeError::UnexpectedTypeSync), + hole_punch::Type::Sync => return Err(OutboundUpgradeError::UnexpectedTypeSync), } let obs_addrs = if obs_addrs.is_empty() { - return Err(UpgradeError::NoAddresses); + return Err(OutboundUpgradeError::NoAddresses); } else { obs_addrs .into_iter() @@ -92,7 +95,7 @@ impl upgrade::OutboundUpgrade for Upgrade { Err(_) => true, }) .collect::, _>>() - .map_err(|_| UpgradeError::InvalidAddrs)? + .map_err(|_| OutboundUpgradeError::InvalidAddrs)? }; let msg = HolePunch { @@ -115,7 +118,7 @@ pub struct Connect { } #[derive(Debug, Error)] -pub enum UpgradeError { +pub enum OutboundUpgradeError { #[error(transparent)] Codec(#[from] prost_codec::Error), #[error("Stream closed")] From b8059394cf3024e69b4206efc1651d0808ce7c71 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 9 Dec 2022 09:35:32 +1100 Subject: [PATCH 2/9] Bump version in manifest and update changelog --- CHANGELOG.md | 5 +++++ Cargo.toml | 4 ++-- misc/metrics/CHANGELOG.md | 4 ++++ misc/metrics/Cargo.toml | 4 ++-- protocols/dcutr/CHANGELOG.md | 7 +++++++ protocols/dcutr/Cargo.toml | 2 +- 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 966b2da7d0d..fac2c219330 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,11 @@ # `libp2p` facade crate +# 0.50.1 + +- Update individual crates. + - Update to [`libp2p-dcutr` `v0.8.1`](protocols/dcutr/CHANGELOG.md#081). + # 0.50.0 This is a large release. After > 4 years, rust-libp2p ships with an [(alpha) QUIC diff --git a/Cargo.toml b/Cargo.toml index 726a717a810..affd1f4d13f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p" edition = "2021" rust-version = "1.62.0" description = "Peer-to-peer networking library" -version = "0.50.0" +version = "0.50.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -94,7 +94,7 @@ instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature libp2p-autonat = { version = "0.9.0", path = "protocols/autonat", optional = true } libp2p-core = { version = "0.38.0", path = "core" } -libp2p-dcutr = { version = "0.8.0", path = "protocols/dcutr", optional = true } +libp2p-dcutr = { version = "0.8.1", path = "protocols/dcutr", optional = true } libp2p-floodsub = { version = "0.41.0", path = "protocols/floodsub", optional = true } libp2p-identify = { version = "0.41.0", path = "protocols/identify", optional = true } libp2p-kad = { version = "0.42.0", path = "protocols/kad", optional = true } diff --git a/misc/metrics/CHANGELOG.md b/misc/metrics/CHANGELOG.md index 50ada3fe51a..fae85ff0594 100644 --- a/misc/metrics/CHANGELOG.md +++ b/misc/metrics/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.11.1 [unreleased] + +- Update to `libp2p-dcutr` `v0.8.1`. + # 0.11.0 - Update to `libp2p-dcutr` `v0.8.0`. diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index 0505a856cc4..3a7ce8a38ea 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-metrics" edition = "2021" rust-version = "1.62.0" description = "Metrics for libp2p" -version = "0.11.0" +version = "0.11.1" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -20,7 +20,7 @@ dcutr = ["libp2p-dcutr"] [dependencies] libp2p-core = { version = "0.38.0", path = "../../core" } -libp2p-dcutr = { version = "0.8.0", path = "../../protocols/dcutr", optional = true } +libp2p-dcutr = { version = "0.8.1", path = "../../protocols/dcutr", optional = true } libp2p-identify = { version = "0.41.0", path = "../../protocols/identify", optional = true } libp2p-kad = { version = "0.42.0", path = "../../protocols/kad", optional = true } libp2p-ping = { version = "0.41.0", path = "../../protocols/ping", optional = true } diff --git a/protocols/dcutr/CHANGELOG.md b/protocols/dcutr/CHANGELOG.md index ab4e266c305..468f94ed013 100644 --- a/protocols/dcutr/CHANGELOG.md +++ b/protocols/dcutr/CHANGELOG.md @@ -1,3 +1,10 @@ +# 0.8.1 [unreleased] + +- Deprecate `InboundUpgradeError` and `OutboundUpgradeError` to follow the conventions discussed in [issue 2217]. See [PR XXXX]. + +[issue 2217]: https://github.com/libp2p/rust-libp2p/issues/2217 +[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX + # 0.8.0 - Update to `prost-codec` `v0.3.0`. diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 3046e66fbc1..3b6f35c7b7e 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-dcutr" edition = "2021" rust-version = "1.62.0" description = "Direct connection upgrade through relay" -version = "0.8.0" +version = "0.8.1" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" From 9f7078927ecd3bd5f675655625b2111c6eb34d51 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 9 Dec 2022 09:57:10 +1100 Subject: [PATCH 3/9] Actually make it backwards-compatible --- protocols/dcutr/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/protocols/dcutr/src/lib.rs b/protocols/dcutr/src/lib.rs index 4ce15ffed74..2dc9613168d 100644 --- a/protocols/dcutr/src/lib.rs +++ b/protocols/dcutr/src/lib.rs @@ -33,11 +33,13 @@ mod message_proto { pub use protocol::PROTOCOL_NAME; pub mod inbound { - pub use crate::protocol::inbound::InboundUpgradeError as UpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 + pub use crate::protocol::inbound::InboundUpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 + pub type UpgradeError = InboundUpgradeError; } pub mod outbound { - pub use crate::protocol::outbound::OutboundUpgradeError as UpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 + pub use crate::protocol::outbound::OutboundUpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 + pub type UpgradeError = OutboundUpgradeError; } #[deprecated( From 4335ce1ee992d72e220701e322f5574a96dcdd76 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 9 Dec 2022 11:42:04 +1100 Subject: [PATCH 4/9] Don't export more symbols than necessary --- protocols/dcutr/src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/protocols/dcutr/src/lib.rs b/protocols/dcutr/src/lib.rs index 2dc9613168d..a4d96772ba8 100644 --- a/protocols/dcutr/src/lib.rs +++ b/protocols/dcutr/src/lib.rs @@ -33,23 +33,21 @@ mod message_proto { pub use protocol::PROTOCOL_NAME; pub mod inbound { - pub use crate::protocol::inbound::InboundUpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 - pub type UpgradeError = InboundUpgradeError; + pub type UpgradeError = crate::protocol::inbound::InboundUpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 } pub mod outbound { - pub use crate::protocol::outbound::OutboundUpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 - pub type UpgradeError = OutboundUpgradeError; + pub type UpgradeError = crate::protocol::outbound::OutboundUpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 } #[deprecated( since = "0.8.1", note = "Use `libp2p_dcutr::inbound::UpgradeError` instead.`" )] -pub type InboundUpgradeError = inbound::UpgradeError; +pub type InboundUpgradeError = protocol::inbound::InboundUpgradeError; #[deprecated( since = "0.8.1", note = "Use `libp2p_dcutr::outbound::UpgradeError` instead.`" )] -pub type OutboundUpgradeError = outbound::UpgradeError; +pub type OutboundUpgradeError = protocol::outbound::OutboundUpgradeError; From 9383624da311be5a572854c0f4af8852088970ae Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sun, 11 Dec 2022 20:07:21 +1100 Subject: [PATCH 5/9] Rename type back --- protocols/dcutr/src/handler/relayed.rs | 12 +++------- protocols/dcutr/src/lib.rs | 8 +++---- protocols/dcutr/src/protocol/inbound.rs | 28 ++++++++++-------------- protocols/dcutr/src/protocol/outbound.rs | 19 +++++++--------- 4 files changed, 27 insertions(+), 40 deletions(-) diff --git a/protocols/dcutr/src/handler/relayed.rs b/protocols/dcutr/src/handler/relayed.rs index 673bbb7c45c..301f2ee3d82 100644 --- a/protocols/dcutr/src/handler/relayed.rs +++ b/protocols/dcutr/src/handler/relayed.rs @@ -134,10 +134,7 @@ pub struct Handler { /// A pending fatal error that results in the connection being closed. pending_error: Option< ConnectionHandlerUpgrErr< - EitherError< - protocol::inbound::InboundUpgradeError, - protocol::outbound::OutboundUpgradeError, - >, + EitherError, >, >, /// Queue of events to return when polled. @@ -151,7 +148,7 @@ pub struct Handler { >, /// Inbound connect, accepted by the behaviour, pending completion. inbound_connect: - Option, protocol::inbound::InboundUpgradeError>>>, + Option, protocol::inbound::UpgradeError>>>, keep_alive: KeepAlive, } @@ -305,10 +302,7 @@ impl ConnectionHandler for Handler { type InEvent = Command; type OutEvent = Event; type Error = ConnectionHandlerUpgrErr< - EitherError< - protocol::inbound::InboundUpgradeError, - protocol::outbound::OutboundUpgradeError, - >, + EitherError, >; type InboundProtocol = upgrade::EitherUpgrade; type OutboundProtocol = protocol::outbound::Upgrade; diff --git a/protocols/dcutr/src/lib.rs b/protocols/dcutr/src/lib.rs index a4d96772ba8..55de87faf48 100644 --- a/protocols/dcutr/src/lib.rs +++ b/protocols/dcutr/src/lib.rs @@ -33,21 +33,21 @@ mod message_proto { pub use protocol::PROTOCOL_NAME; pub mod inbound { - pub type UpgradeError = crate::protocol::inbound::InboundUpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 + pub use crate::protocol::inbound::UpgradeError; } pub mod outbound { - pub type UpgradeError = crate::protocol::outbound::OutboundUpgradeError; // TODO: Rename the inner error once `cargo-semver-checks` supports it: https://github.com/obi1kenobi/cargo-semver-checks/issues/152 + pub use crate::protocol::outbound::UpgradeError; } #[deprecated( since = "0.8.1", note = "Use `libp2p_dcutr::inbound::UpgradeError` instead.`" )] -pub type InboundUpgradeError = protocol::inbound::InboundUpgradeError; +pub type InboundUpgradeError = inbound::UpgradeError; #[deprecated( since = "0.8.1", note = "Use `libp2p_dcutr::outbound::UpgradeError` instead.`" )] -pub type OutboundUpgradeError = protocol::outbound::OutboundUpgradeError; +pub type OutboundUpgradeError = outbound::UpgradeError; diff --git a/protocols/dcutr/src/protocol/inbound.rs b/protocols/dcutr/src/protocol/inbound.rs index 78a8cc0e0fe..3b964881f51 100644 --- a/protocols/dcutr/src/protocol/inbound.rs +++ b/protocols/dcutr/src/protocol/inbound.rs @@ -40,7 +40,7 @@ impl upgrade::UpgradeInfo for Upgrade { impl upgrade::InboundUpgrade for Upgrade { type Output = PendingConnect; - type Error = InboundUpgradeError; + type Error = UpgradeError; type Future = BoxFuture<'static, Result>; fn upgrade_inbound(self, substream: NegotiatedSubstream, _: Self::Info) -> Self::Future { @@ -50,13 +50,11 @@ impl upgrade::InboundUpgrade for Upgrade { ); async move { - let HolePunch { r#type, obs_addrs } = substream - .next() - .await - .ok_or(InboundUpgradeError::StreamClosed)??; + let HolePunch { r#type, obs_addrs } = + substream.next().await.ok_or(UpgradeError::StreamClosed)??; let obs_addrs = if obs_addrs.is_empty() { - return Err(InboundUpgradeError::NoAddresses); + return Err(UpgradeError::NoAddresses); } else { obs_addrs .into_iter() @@ -67,15 +65,14 @@ impl upgrade::InboundUpgrade for Upgrade { Err(_) => true, }) .collect::, _>>() - .map_err(|_| InboundUpgradeError::InvalidAddrs)? + .map_err(|_| UpgradeError::InvalidAddrs)? }; - let r#type = - hole_punch::Type::from_i32(r#type).ok_or(InboundUpgradeError::ParseTypeField)?; + let r#type = hole_punch::Type::from_i32(r#type).ok_or(UpgradeError::ParseTypeField)?; match r#type { hole_punch::Type::Connect => {} - hole_punch::Type::Sync => return Err(InboundUpgradeError::UnexpectedTypeSync), + hole_punch::Type::Sync => return Err(UpgradeError::UnexpectedTypeSync), } Ok(PendingConnect { @@ -96,7 +93,7 @@ impl PendingConnect { pub async fn accept( mut self, local_obs_addrs: Vec, - ) -> Result, InboundUpgradeError> { + ) -> Result, UpgradeError> { let msg = HolePunch { r#type: hole_punch::Type::Connect.into(), obs_addrs: local_obs_addrs.into_iter().map(|a| a.to_vec()).collect(), @@ -107,12 +104,11 @@ impl PendingConnect { .substream .next() .await - .ok_or(InboundUpgradeError::StreamClosed)??; + .ok_or(UpgradeError::StreamClosed)??; - let r#type = - hole_punch::Type::from_i32(r#type).ok_or(InboundUpgradeError::ParseTypeField)?; + let r#type = hole_punch::Type::from_i32(r#type).ok_or(UpgradeError::ParseTypeField)?; match r#type { - hole_punch::Type::Connect => return Err(InboundUpgradeError::UnexpectedTypeConnect), + hole_punch::Type::Connect => return Err(UpgradeError::UnexpectedTypeConnect), hole_punch::Type::Sync => {} } @@ -121,7 +117,7 @@ impl PendingConnect { } #[derive(Debug, Error)] -pub enum InboundUpgradeError { +pub enum UpgradeError { #[error(transparent)] Codec(#[from] prost_codec::Error), #[error("Stream closed")] diff --git a/protocols/dcutr/src/protocol/outbound.rs b/protocols/dcutr/src/protocol/outbound.rs index 58dba144e0e..ca2a340aecb 100644 --- a/protocols/dcutr/src/protocol/outbound.rs +++ b/protocols/dcutr/src/protocol/outbound.rs @@ -50,7 +50,7 @@ impl Upgrade { impl upgrade::OutboundUpgrade for Upgrade { type Output = Connect; - type Error = OutboundUpgradeError; + type Error = UpgradeError; type Future = BoxFuture<'static, Result>; fn upgrade_outbound(self, substream: NegotiatedSubstream, _: Self::Info) -> Self::Future { @@ -69,22 +69,19 @@ impl upgrade::OutboundUpgrade for Upgrade { let sent_time = Instant::now(); - let HolePunch { r#type, obs_addrs } = substream - .next() - .await - .ok_or(OutboundUpgradeError::StreamClosed)??; + let HolePunch { r#type, obs_addrs } = + substream.next().await.ok_or(UpgradeError::StreamClosed)??; let rtt = sent_time.elapsed(); - let r#type = - hole_punch::Type::from_i32(r#type).ok_or(OutboundUpgradeError::ParseTypeField)?; + let r#type = hole_punch::Type::from_i32(r#type).ok_or(UpgradeError::ParseTypeField)?; match r#type { hole_punch::Type::Connect => {} - hole_punch::Type::Sync => return Err(OutboundUpgradeError::UnexpectedTypeSync), + hole_punch::Type::Sync => return Err(UpgradeError::UnexpectedTypeSync), } let obs_addrs = if obs_addrs.is_empty() { - return Err(OutboundUpgradeError::NoAddresses); + return Err(UpgradeError::NoAddresses); } else { obs_addrs .into_iter() @@ -95,7 +92,7 @@ impl upgrade::OutboundUpgrade for Upgrade { Err(_) => true, }) .collect::, _>>() - .map_err(|_| OutboundUpgradeError::InvalidAddrs)? + .map_err(|_| UpgradeError::InvalidAddrs)? }; let msg = HolePunch { @@ -118,7 +115,7 @@ pub struct Connect { } #[derive(Debug, Error)] -pub enum OutboundUpgradeError { +pub enum UpgradeError { #[error(transparent)] Codec(#[from] prost_codec::Error), #[error("Stream closed")] From 406f62d2ad149f3aa7432e545d3b649a01b457c6 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sun, 11 Dec 2022 20:10:32 +1100 Subject: [PATCH 6/9] Update protocols/dcutr/CHANGELOG.md --- protocols/dcutr/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/dcutr/CHANGELOG.md b/protocols/dcutr/CHANGELOG.md index 468f94ed013..cfe8f5e6922 100644 --- a/protocols/dcutr/CHANGELOG.md +++ b/protocols/dcutr/CHANGELOG.md @@ -1,9 +1,9 @@ # 0.8.1 [unreleased] -- Deprecate `InboundUpgradeError` and `OutboundUpgradeError` to follow the conventions discussed in [issue 2217]. See [PR XXXX]. +- Deprecate `InboundUpgradeError` and `OutboundUpgradeError` to follow the conventions discussed in [issue 2217]. See [PR 3213]. [issue 2217]: https://github.com/libp2p/rust-libp2p/issues/2217 -[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX +[PR 3213]: https://github.com/libp2p/rust-libp2p/pull/3213 # 0.8.0 From 012ad58bfc2e31aad3966cbeb58704b85b966ea8 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sun, 11 Dec 2022 20:15:46 +1100 Subject: [PATCH 7/9] Undo bump in `misc/metrics` --- misc/metrics/CHANGELOG.md | 4 ---- misc/metrics/Cargo.toml | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/misc/metrics/CHANGELOG.md b/misc/metrics/CHANGELOG.md index fae85ff0594..50ada3fe51a 100644 --- a/misc/metrics/CHANGELOG.md +++ b/misc/metrics/CHANGELOG.md @@ -1,7 +1,3 @@ -# 0.11.1 [unreleased] - -- Update to `libp2p-dcutr` `v0.8.1`. - # 0.11.0 - Update to `libp2p-dcutr` `v0.8.0`. diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index 354e4166d37..5ad5cdc7071 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-metrics" edition = "2021" rust-version = "1.62.0" description = "Metrics for libp2p" -version = "0.11.1" +version = "0.11.0" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -20,7 +20,7 @@ dcutr = ["libp2p-dcutr"] [dependencies] libp2p-core = { version = "0.38.0", path = "../../core" } -libp2p-dcutr = { version = "0.8.1", path = "../../protocols/dcutr", optional = true } +libp2p-dcutr = { version = "0.8.0", path = "../../protocols/dcutr", optional = true } libp2p-identify = { version = "0.41.0", path = "../../protocols/identify", optional = true } libp2p-kad = { version = "0.42.0", path = "../../protocols/kad", optional = true } libp2p-ping = { version = "0.41.0", path = "../../protocols/ping", optional = true } From 21fb9b4a110175b8d6ba03142911f4be18858285 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sun, 11 Dec 2022 20:16:10 +1100 Subject: [PATCH 8/9] Undo bump and changelog entry in root lib --- CHANGELOG.md | 1 - Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a48eec636f1..6ed79777319 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,7 +51,6 @@ - Update individual crates. - Update to [`libp2p-swarm` `v0.42.0`](swarm/CHANGELOG.md#0420). - - Update to [`libp2p-dcutr` `v0.8.1`](protocols/dcutr/CHANGELOG.md#081). [PR 3191]: https://github.com/libp2p/rust-libp2p/pull/3191 diff --git a/Cargo.toml b/Cargo.toml index a3f1891d579..6ebcf2d45c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,7 +94,7 @@ instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature libp2p-autonat = { version = "0.9.0", path = "protocols/autonat", optional = true } libp2p-core = { version = "0.38.0", path = "core" } -libp2p-dcutr = { version = "0.8.1", path = "protocols/dcutr", optional = true } +libp2p-dcutr = { version = "0.8.0", path = "protocols/dcutr", optional = true } libp2p-floodsub = { version = "0.41.0", path = "protocols/floodsub", optional = true } libp2p-identify = { version = "0.41.0", path = "protocols/identify", optional = true } libp2p-kad = { version = "0.42.0", path = "protocols/kad", optional = true } From 5c1ec739afa90c3f720fa743e78d72a1ab08183b Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sun, 11 Dec 2022 20:17:51 +1100 Subject: [PATCH 9/9] Make change more minimal --- protocols/dcutr/CHANGELOG.md | 6 +++--- protocols/dcutr/src/lib.rs | 21 ++------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/protocols/dcutr/CHANGELOG.md b/protocols/dcutr/CHANGELOG.md index 468f94ed013..ee07fae51a0 100644 --- a/protocols/dcutr/CHANGELOG.md +++ b/protocols/dcutr/CHANGELOG.md @@ -1,9 +1,9 @@ # 0.8.1 [unreleased] -- Deprecate `InboundUpgradeError` and `OutboundUpgradeError` to follow the conventions discussed in [issue 2217]. See [PR XXXX]. +- Declare `InboundUpgradeError` and `OutboundUpgradeError` as type aliases instead of renames. + This is a workaround for a missing feature in `cargo semver-checks`. See [PR 3213]. -[issue 2217]: https://github.com/libp2p/rust-libp2p/issues/2217 -[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX +[PR 3213]: https://github.com/libp2p/rust-libp2p/pull/3213 # 0.8.0 diff --git a/protocols/dcutr/src/lib.rs b/protocols/dcutr/src/lib.rs index 55de87faf48..525b2a08d20 100644 --- a/protocols/dcutr/src/lib.rs +++ b/protocols/dcutr/src/lib.rs @@ -32,22 +32,5 @@ mod message_proto { } pub use protocol::PROTOCOL_NAME; -pub mod inbound { - pub use crate::protocol::inbound::UpgradeError; -} - -pub mod outbound { - pub use crate::protocol::outbound::UpgradeError; -} - -#[deprecated( - since = "0.8.1", - note = "Use `libp2p_dcutr::inbound::UpgradeError` instead.`" -)] -pub type InboundUpgradeError = inbound::UpgradeError; - -#[deprecated( - since = "0.8.1", - note = "Use `libp2p_dcutr::outbound::UpgradeError` instead.`" -)] -pub type OutboundUpgradeError = outbound::UpgradeError; +pub type InboundUpgradeError = protocol::inbound::UpgradeError; +pub type OutboundUpgradeError = protocol::outbound::UpgradeError;