Skip to content

Commit

Permalink
feat(core): remove deprecated identity module
Browse files Browse the repository at this point in the history
Related: #3647.

Pull-Request: #4040.
  • Loading branch information
thomaseizinger committed Jun 6, 2023
1 parent 23d499b commit 6112871
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 87 deletions.
14 changes: 9 additions & 5 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<str>`.
See [PR 3746]
Expand All @@ -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 4040].

[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 4040]: https://github.com/libp2p/rust-libp2p/pull/4040

## 0.39.2

Expand Down
4 changes: 1 addition & 3 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
62 changes: 0 additions & 62 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,55 +45,6 @@ mod proto {
pub use multiaddr;
pub type Negotiated<T> = multistream_select::Negotiated<T>;

#[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;
Expand All @@ -108,15 +55,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;
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions protocols/gossipsub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
6 changes: 4 additions & 2 deletions protocols/relay/src/priv_client/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions swarm-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 2 additions & 1 deletion swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 4 additions & 4 deletions transports/plaintext/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ 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.
/// 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.
Expand Down Expand Up @@ -93,8 +93,8 @@ impl From<DecodeError> for PlainTextError {
}
}

impl From<libp2p_core::identity::error::DecodingError> for PlainTextError {
fn from(err: libp2p_core::identity::error::DecodingError) -> PlainTextError {
impl From<libp2p_identity::DecodingError> for PlainTextError {
fn from(err: libp2p_identity::DecodingError) -> PlainTextError {
PlainTextError::InvalidPublicKey(err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions transports/pnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion transports/webrtc/src/tokio/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
///
Expand Down

0 comments on commit 6112871

Please sign in to comment.