From 7cb2042ff826efd605fc7b55048d74315509c6a2 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 6 Jun 2023 20:03:58 +0200 Subject: [PATCH 1/8] Don't re-export libp2p-identity from `libp2p-core` --- core/Cargo.toml | 6 ++-- core/src/lib.rs | 49 ----------------------------- protocols/gossipsub/src/error.rs | 2 +- protocols/gossipsub/src/protocol.rs | 2 +- swarm-test/src/lib.rs | 5 ++- transports/plaintext/src/error.rs | 6 ++-- transports/pnet/Cargo.toml | 4 +-- 7 files changed, 11 insertions(+), 63 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 626529779df..fb448a663a7 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -16,7 +16,7 @@ fnv = "1.0" futures = { version = "0.3.28", features = ["executor", "thread-pool"] } futures-timer = "3" instant = "0.1.12" -libp2p-identity = { workspace = true, features = ["peerid", "ed25519"] } +libp2p-identity = { workspace = true } log = "0.4" multiaddr = { version = "0.17.1" } multihash = { version = "0.17.0", default-features = false, features = ["std"] } @@ -39,11 +39,9 @@ libp2p-mplex = { workspace = true } libp2p-noise = { workspace = true } multihash = { version = "0.17.0", default-features = false, features = ["arb"] } quickcheck = { workspace = true } +libp2p-identity = { workspace = true, features = ["ed25519"] } [features] -secp256k1 = [ "libp2p-identity/secp256k1" ] -ecdsa = [ "libp2p-identity/ecdsa" ] -rsa = [ "libp2p-identity/rsa" ] serde = ["multihash/serde-codec", "dep:serde", "libp2p-identity/serde"] # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/core/src/lib.rs b/core/src/lib.rs index 6d18485c667..31b417944ba 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -49,55 +49,6 @@ mod proto { pub use multiaddr; pub type Negotiated = multistream_select::Negotiated; -#[deprecated(since = "0.39.0", note = "Depend on `libp2p-identity` instead.")] -pub mod identity { - pub use libp2p_identity::Keypair; - pub use libp2p_identity::PublicKey; - - pub mod ed25519 { - pub use libp2p_identity::ed25519::Keypair; - pub use libp2p_identity::ed25519::PublicKey; - pub use libp2p_identity::ed25519::SecretKey; - } - - #[cfg(feature = "ecdsa")] - #[deprecated( - since = "0.39.0", - note = "The `ecdsa` feature-flag is deprecated and will be removed in favor of `libp2p-identity`." - )] - pub mod ecdsa { - pub use libp2p_identity::ecdsa::Keypair; - pub use libp2p_identity::ecdsa::PublicKey; - pub use libp2p_identity::ecdsa::SecretKey; - } - - #[cfg(feature = "secp256k1")] - #[deprecated( - since = "0.39.0", - note = "The `secp256k1` feature-flag is deprecated and will be removed in favor of `libp2p-identity`." - )] - pub mod secp256k1 { - pub use libp2p_identity::secp256k1::Keypair; - pub use libp2p_identity::secp256k1::PublicKey; - pub use libp2p_identity::secp256k1::SecretKey; - } - - #[cfg(feature = "rsa")] - #[deprecated( - since = "0.39.0", - note = "The `rsa` feature-flag is deprecated and will be removed in favor of `libp2p-identity`." - )] - pub mod rsa { - pub use libp2p_identity::rsa::Keypair; - pub use libp2p_identity::rsa::PublicKey; - } - - pub mod error { - pub use libp2p_identity::DecodingError; - pub use libp2p_identity::SigningError; - } -} - mod translation; pub mod connection; diff --git a/protocols/gossipsub/src/error.rs b/protocols/gossipsub/src/error.rs index 1d8d6c052a8..26f71a346c3 100644 --- a/protocols/gossipsub/src/error.rs +++ b/protocols/gossipsub/src/error.rs @@ -20,7 +20,7 @@ //! Error types that can result from gossipsub. -use libp2p_core::identity::error::SigningError; +use libp2p_identity::SigningError; /// Error associated with publishing a gossipsub message. #[derive(Debug)] diff --git a/protocols/gossipsub/src/protocol.rs b/protocols/gossipsub/src/protocol.rs index 48c1e4b2d15..15d2f59755a 100644 --- a/protocols/gossipsub/src/protocol.rs +++ b/protocols/gossipsub/src/protocol.rs @@ -515,7 +515,7 @@ mod tests { use crate::config::Config; use crate::{Behaviour, ConfigBuilder}; use crate::{IdentTopic as Topic, Version}; - use libp2p_core::identity::Keypair; + use libp2p_identity::Keypair; use quickcheck::*; #[derive(Clone, Debug)] diff --git a/swarm-test/src/lib.rs b/swarm-test/src/lib.rs index e70c64bbfd1..d7d54383579 100644 --- a/swarm-test/src/lib.rs +++ b/swarm-test/src/lib.rs @@ -22,10 +22,9 @@ use async_trait::async_trait; use futures::future::Either; use futures::StreamExt; use libp2p_core::{ - identity::Keypair, multiaddr::Protocol, transport::MemoryTransport, upgrade::Version, - Multiaddr, Transport, + multiaddr::Protocol, transport::MemoryTransport, upgrade::Version, Multiaddr, Transport, }; -use libp2p_identity::PeerId; +use libp2p_identity::{Keypair, PeerId}; use libp2p_plaintext::PlainText2Config; use libp2p_swarm::dial_opts::PeerCondition; use libp2p_swarm::{ diff --git a/transports/plaintext/src/error.rs b/transports/plaintext/src/error.rs index 2daac496f12..51c468adfb1 100644 --- a/transports/plaintext/src/error.rs +++ b/transports/plaintext/src/error.rs @@ -31,7 +31,7 @@ pub enum PlainTextError { InvalidPayload(DecodeError), /// Failed to parse public key from bytes in protobuf message. - InvalidPublicKey(libp2p_core::identity::error::DecodingError), + InvalidPublicKey(libp2p_identity::DecodingError), /// Failed to parse the [`PeerId`](libp2p_core::PeerId) from bytes in the protobuf message. InvalidPeerId(libp2p_core::multihash::Error), @@ -93,8 +93,8 @@ impl From for PlainTextError { } } -impl From for PlainTextError { - fn from(err: libp2p_core::identity::error::DecodingError) -> PlainTextError { +impl From for PlainTextError { + fn from(err: libp2p_identity::DecodingError) -> PlainTextError { PlainTextError::InvalidPublicKey(err) } } diff --git a/transports/pnet/Cargo.toml b/transports/pnet/Cargo.toml index 30b0e81c3db..a2b5acaf887 100644 --- a/transports/pnet/Cargo.toml +++ b/transports/pnet/Cargo.toml @@ -19,8 +19,8 @@ rand = "0.8" pin-project = "1.1.0" [dev-dependencies] -libp2p-core = { workspace = true, features = ["rsa", "ecdsa", "secp256k1"] } -libp2p-identity = { workspace = true, features = ["ed25519"] } +libp2p-core = { workspace = true } +libp2p-identity = { workspace = true, features = ["ed25519", "rsa", "ecdsa", "secp256k1"] } libp2p-noise = { workspace = true } libp2p-swarm = { workspace = true, features = ["tokio"] } libp2p-tcp = { workspace = true, features = ["tokio"] } From cf981d044b944cdbd0cce4f392d4239ca76a077e Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 6 Jun 2023 20:05:36 +0200 Subject: [PATCH 2/8] Add changelog entry --- core/CHANGELOG.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 44be3acd4cb..c1838736b4d 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -9,10 +9,6 @@ - Remove deprecated symbols related to upgrades. See [PR 3867]. -[PR 3567]: https://github.com/libp2p/rust-libp2p/pull/3567 -[PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715 -[PR 3867]: https://github.com/libp2p/rust-libp2p/pull/3867 - - Enforce protocol names to be valid UTF8 strings as required by the [spec]. We delete the `ProtocolName` trait and replace it with a requirement for `AsRef`. See [PR 3746] @@ -27,11 +23,19 @@ These are implementation details that should not be depended on. See [PR 3915]. +- Remove deprecated `identity` module. + Depend on `libp2p-identity` directly instead or import it via the `libp2p::identity` re-export. + See [PR XXXX]. + [spec]: https://github.com/libp2p/specs/blob/master/connections/README.md#multistream-select +[PR 3567]: https://github.com/libp2p/rust-libp2p/pull/3567 +[PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715 [PR 3746]: https://github.com/libp2p/rust-libp2p/pull/3746 -[PR 3883]: https://github.com/libp2p/rust-libp2p/pull/3883 [PR 3814]: https://github.com/libp2p/rust-libp2p/pull/3814 +[PR 3867]: https://github.com/libp2p/rust-libp2p/pull/3867 +[PR 3883]: https://github.com/libp2p/rust-libp2p/pull/3883 [PR 3915]: https://github.com/libp2p/rust-libp2p/pull/3915 +[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX ## 0.39.2 From 4eef57cc34d03a3bafd8cf7a923663031a905836 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 6 Jun 2023 20:06:13 +0200 Subject: [PATCH 3/8] Fill in PR number --- core/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index c1838736b4d..c6edd30f562 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -25,7 +25,7 @@ - Remove deprecated `identity` module. Depend on `libp2p-identity` directly instead or import it via the `libp2p::identity` re-export. - See [PR XXXX]. + See [PR 4040]. [spec]: https://github.com/libp2p/specs/blob/master/connections/README.md#multistream-select [PR 3567]: https://github.com/libp2p/rust-libp2p/pull/3567 @@ -35,7 +35,7 @@ [PR 3867]: https://github.com/libp2p/rust-libp2p/pull/3867 [PR 3883]: https://github.com/libp2p/rust-libp2p/pull/3883 [PR 3915]: https://github.com/libp2p/rust-libp2p/pull/3915 -[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX +[PR 4040]: https://github.com/libp2p/rust-libp2p/pull/4040 ## 0.39.2 From b47e20866d1d06cbfedcf557305377ff145c14c9 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 6 Jun 2023 20:07:59 +0200 Subject: [PATCH 4/8] Remove deprecated re-exports --- core/src/lib.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/core/src/lib.rs b/core/src/lib.rs index 31b417944ba..9e662f59c4f 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -59,15 +59,6 @@ pub mod signed_envelope; pub mod transport; pub mod upgrade; -#[deprecated(since = "0.39.0", note = "Depend on `libp2p-identity` instead.")] -pub type PublicKey = libp2p_identity::PublicKey; - -#[deprecated(since = "0.39.0", note = "Depend on `libp2p-identity` instead.")] -pub type PeerId = libp2p_identity::PeerId; - -#[deprecated(since = "0.39.0", note = "Depend on `libp2p-identity` instead.")] -pub type ParseError = libp2p_identity::ParseError; - pub use connection::{ConnectedPoint, Endpoint}; pub use multiaddr::Multiaddr; pub use multihash; From 4f6953dc17612d3c526986e962094426a7f3f2bc Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 6 Jun 2023 20:21:04 +0200 Subject: [PATCH 5/8] Fix compile errors --- core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index fb448a663a7..902a09fc60c 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -16,7 +16,7 @@ fnv = "1.0" futures = { version = "0.3.28", features = ["executor", "thread-pool"] } futures-timer = "3" instant = "0.1.12" -libp2p-identity = { workspace = true } +libp2p-identity = { workspace = true, features = ["ed25519"] } log = "0.4" multiaddr = { version = "0.17.1" } multihash = { version = "0.17.0", default-features = false, features = ["std"] } From 109b2938e65b9e04e02e1c4b593d0cfcf0f7a893 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 6 Jun 2023 20:36:43 +0200 Subject: [PATCH 6/8] Activate peerid feature --- core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 902a09fc60c..e5c13bceb62 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -16,7 +16,7 @@ fnv = "1.0" futures = { version = "0.3.28", features = ["executor", "thread-pool"] } futures-timer = "3" instant = "0.1.12" -libp2p-identity = { workspace = true, features = ["ed25519"] } +libp2p-identity = { workspace = true, features = ["peerid", "ed25519"] } log = "0.4" multiaddr = { version = "0.17.1" } multihash = { version = "0.17.0", default-features = false, features = ["std"] } From 68010b3e579cb0edb57985d8a90cacce2abe45b7 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 6 Jun 2023 20:40:48 +0200 Subject: [PATCH 7/8] Fix rustdoc errors --- protocols/gossipsub/src/lib.rs | 4 ++-- protocols/relay/src/priv_client/transport.rs | 6 ++++-- swarm/src/lib.rs | 3 ++- transports/plaintext/src/error.rs | 2 +- transports/webrtc/src/tokio/transport.rs | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/protocols/gossipsub/src/lib.rs b/protocols/gossipsub/src/lib.rs index b5ea9999a5a..e065319c4c3 100644 --- a/protocols/gossipsub/src/lib.rs +++ b/protocols/gossipsub/src/lib.rs @@ -48,7 +48,7 @@ //! encoded) by setting the `hash_topics` configuration parameter to true. //! //! - **Sequence Numbers** - A message on the gossipsub network is identified by the source -//! [`libp2p_core::PeerId`] and a nonce (sequence number) of the message. The sequence numbers in +//! [`PeerId`](libp2p_identity::PeerId) and a nonce (sequence number) of the message. The sequence numbers in //! this implementation are sent as raw bytes across the wire. They are 64-bit big-endian unsigned //! integers. When messages are signed, they are monotonically increasing integers starting from a //! random value and wrapping around u64::MAX. When messages are unsigned, they are chosen at random. @@ -83,7 +83,7 @@ //! //! The [`Behaviour`] struct implements the [`libp2p_swarm::NetworkBehaviour`] trait allowing it to //! act as the routing behaviour in a [`libp2p_swarm::Swarm`]. This struct requires an instance of -//! [`libp2p_core::PeerId`] and [`Config`]. +//! [`PeerId`](libp2p_identity::PeerId) and [`Config`]. //! //! [`Behaviour`]: struct.Behaviour.html diff --git a/protocols/relay/src/priv_client/transport.rs b/protocols/relay/src/priv_client/transport.rs index aaaf760966f..e54c7850195 100644 --- a/protocols/relay/src/priv_client/transport.rs +++ b/protocols/relay/src/priv_client/transport.rs @@ -48,10 +48,11 @@ use thiserror::Error; /// 1. Establish relayed connections by dialing `/p2p-circuit` addresses. /// /// ``` -/// # use libp2p_core::{Multiaddr, multiaddr::{Protocol}, Transport, PeerId}; +/// # use libp2p_core::{Multiaddr, multiaddr::{Protocol}, Transport}; /// # use libp2p_core::transport::memory::MemoryTransport; /// # use libp2p_core::transport::choice::OrTransport; /// # use libp2p_relay as relay; +/// # use libp2p_identity::PeerId; /// let actual_transport = MemoryTransport::default(); /// let (relay_transport, behaviour) = relay::client::new( /// PeerId::random(), @@ -70,10 +71,11 @@ use thiserror::Error; /// 3. Listen for incoming relayed connections via specific relay. /// /// ``` -/// # use libp2p_core::{Multiaddr, multiaddr::{Protocol}, transport::ListenerId, Transport, PeerId}; +/// # use libp2p_core::{Multiaddr, multiaddr::{Protocol}, transport::ListenerId, Transport}; /// # use libp2p_core::transport::memory::MemoryTransport; /// # use libp2p_core::transport::choice::OrTransport; /// # use libp2p_relay as relay; +/// # use libp2p_identity::PeerId; /// # let relay_id = PeerId::random(); /// # let local_peer_id = PeerId::random(); /// let actual_transport = MemoryTransport::default(); diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index ff54ae58000..ce80c7f0c5f 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -395,9 +395,10 @@ where /// ``` /// # use libp2p_swarm::SwarmBuilder; /// # use libp2p_swarm::dial_opts::{DialOpts, PeerCondition}; - /// # use libp2p_core::{Multiaddr, PeerId, Transport}; + /// # use libp2p_core::{Multiaddr, Transport}; /// # use libp2p_core::transport::dummy::DummyTransport; /// # use libp2p_swarm::dummy; + /// # use libp2p_identity::PeerId; /// # /// let mut swarm = SwarmBuilder::without_executor( /// DummyTransport::new().boxed(), diff --git a/transports/plaintext/src/error.rs b/transports/plaintext/src/error.rs index 51c468adfb1..8ed4aeabc3e 100644 --- a/transports/plaintext/src/error.rs +++ b/transports/plaintext/src/error.rs @@ -33,7 +33,7 @@ pub enum PlainTextError { /// Failed to parse public key from bytes in protobuf message. InvalidPublicKey(libp2p_identity::DecodingError), - /// Failed to parse the [`PeerId`](libp2p_core::PeerId) from bytes in the protobuf message. + /// Failed to parse the [`PeerId`](libp2p_identity::PeerId) from bytes in the protobuf message. InvalidPeerId(libp2p_core::multihash::Error), /// The peer id of the exchange isn't consistent with the remote public key. diff --git a/transports/webrtc/src/tokio/transport.rs b/transports/webrtc/src/tokio/transport.rs index 21f465ba063..ba1bb95fb54 100644 --- a/transports/webrtc/src/tokio/transport.rs +++ b/transports/webrtc/src/tokio/transport.rs @@ -59,7 +59,7 @@ impl Transport { /// # Example /// /// ``` - /// use libp2p_core::identity; + /// use libp2p_identity as identity; /// use rand::thread_rng; /// use libp2p_webrtc::tokio::{Transport, Certificate}; /// From 0fa6e50e1ad843b9f930e8d88e8a5628eaa5854b Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 6 Jun 2023 20:47:27 +0200 Subject: [PATCH 8/8] `PeerId` is not a concept of `libp2p-core` --- core/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/src/lib.rs b/core/src/lib.rs index 9e662f59c4f..abb83481d6c 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -22,10 +22,6 @@ //! //! The main concepts of libp2p-core are: //! -//! - A [`PeerId`] is a unique global identifier for a node on the network. -//! Each node must have a different [`PeerId`]. Normally, a [`PeerId`] is the -//! hash of the public key used to negotiate encryption on the -//! communication channel, thereby guaranteeing that they cannot be spoofed. //! - The [`Transport`] trait defines how to reach a remote node or listen for //! incoming remote connections. See the [`transport`] module. //! - The [`StreamMuxer`] trait is implemented on structs that hold a connection