Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gossipsub): remove deprecated items #3862

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

- Raise MSRV to 1.65.
See [PR 3715].
- Remove deprecated items. See [PR 3862].

[PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715
[PR 3862]: https://github.com/libp2p/rust-libp2p/pull/3862

## 0.44.4

Expand Down
1 change: 0 additions & 1 deletion protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ quick-protobuf-codec = { workspace = true }
hex_fmt = "0.3.0"
regex = "1.8.1"
serde = { version = "1", optional = true, features = ["derive"] }
thiserror = "1.0"
wasm-timer = "0.2.5"
instant = "0.1.11"
void = "1.0.2"
Expand Down
10 changes: 5 additions & 5 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ use crate::config::{Config, ValidationMode};
use crate::gossip_promises::GossipPromises;
use crate::handler::{Handler, HandlerEvent, HandlerIn};
use crate::mcache::MessageCache;
use crate::metrics_priv::{Churn, Config as MetricsConfig, Inclusion, Metrics, Penalty};
use crate::metrics::{Churn, Config as MetricsConfig, Inclusion, Metrics, Penalty};
use crate::peer_score::{PeerScore, PeerScoreParams, PeerScoreThresholds, RejectReason};
use crate::protocol_priv::{ProtocolConfig, SIGNING_PREFIX};
use crate::subscription_filter_priv::{AllowAllSubscriptionFilter, TopicSubscriptionFilter};
use crate::time_cache_priv::{DuplicateCache, TimeCache};
use crate::protocol::{ProtocolConfig, SIGNING_PREFIX};
use crate::subscription_filter::{AllowAllSubscriptionFilter, TopicSubscriptionFilter};
use crate::time_cache::{DuplicateCache, TimeCache};
use crate::topic::{Hasher, Topic, TopicHash};
use crate::transform::{DataTransform, IdentityTransform};
use crate::types::{
Expand Down Expand Up @@ -3824,7 +3824,7 @@ mod local_test {
let mut length_codec = unsigned_varint::codec::UviBytes::default();
length_codec.set_max_len(max_transmit_size);
let mut codec =
crate::protocol_priv::GossipsubCodec::new(length_codec, ValidationMode::Permissive);
crate::protocol::GossipsubCodec::new(length_codec, ValidationMode::Permissive);

let rpc_proto = rpc.into_protobuf();
let fragmented_messages = gs
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/behaviour/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// Collection of tests for the gossipsub network behaviour

use super::*;
use crate::subscription_filter_priv::WhitelistSubscriptionFilter;
use crate::subscription_filter::WhitelistSubscriptionFilter;
use crate::transform::{DataTransform, IdentityTransform};
use crate::types::FastMessageId;
use crate::ValidationError;
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ impl std::fmt::Debug for Config {
#[cfg(test)]
mod test {
use super::*;
use crate::protocol_priv::ProtocolConfig;
use crate::protocol::ProtocolConfig;
use crate::topic::IdentityHash;
use crate::types::PeerKind;
use crate::Topic;
Expand Down
127 changes: 103 additions & 24 deletions protocols/gossipsub/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Protocol Labs.
// Copyright 2020 Sigma Prime Pty Ltd.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
Expand All @@ -18,26 +18,105 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#[deprecated(
since = "0.44.0",
note = "Use `libp2p::gossipsub::PublishError` instead, as the `error` module will become crate-private in the future."
)]
pub type PublishError = crate::error_priv::PublishError;

#[deprecated(
since = "0.44.0",
note = "Use `libp2p::gossipsub::SubscriptionError` instead, as the `error` module will become crate-private in the future."
)]
pub type SubscriptionError = crate::error_priv::SubscriptionError;

#[deprecated(note = "This error will no longer be emitted")]
pub type GossipsubHandlerError = crate::error_priv::HandlerError;

#[deprecated(note = "This error will no longer be emitted")]
pub type HandlerError = crate::error_priv::HandlerError;

#[deprecated(
since = "0.44.0",
note = "Use `libp2p::gossipsub::ValidationError` instead, as the `error` module will become crate-private in the future."
)]
pub type ValidationError = crate::error_priv::ValidationError;
//! Error types that can result from gossipsub.

use libp2p_core::identity::error::SigningError;

/// Error associated with publishing a gossipsub message.
#[derive(Debug)]
pub enum PublishError {
/// This message has already been published.
Duplicate,
/// An error occurred whilst signing the message.
SigningError(SigningError),
/// There were no peers to send this message to.
InsufficientPeers,
/// The overall message was too large. This could be due to excessive topics or an excessive
/// message size.
MessageTooLarge,
/// The compression algorithm failed.
TransformFailed(std::io::Error),
}

impl std::fmt::Display for PublishError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{self:?}")
}
}

impl std::error::Error for PublishError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::SigningError(err) => Some(err),
Self::TransformFailed(err) => Some(err),
_ => None,
}
}
}

/// Error associated with subscribing to a topic.
#[derive(Debug)]
pub enum SubscriptionError {
/// Couldn't publish our subscription
PublishError(PublishError),
/// We are not allowed to subscribe to this topic by the subscription filter
NotAllowed,
}

impl std::fmt::Display for SubscriptionError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{self:?}")
}
}

impl std::error::Error for SubscriptionError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::PublishError(err) => Some(err),
_ => None,
}
}
}

impl From<SigningError> for PublishError {
fn from(error: SigningError) -> Self {
PublishError::SigningError(error)
}
}

#[derive(Debug, Clone, Copy)]
pub enum ValidationError {
/// The message has an invalid signature,
InvalidSignature,
/// The sequence number was empty, expected a value.
EmptySequenceNumber,
/// The sequence number was the incorrect size
InvalidSequenceNumber,
/// The PeerId was invalid
InvalidPeerId,
/// Signature existed when validation has been sent to
/// [`crate::behaviour::MessageAuthenticity::Anonymous`].
SignaturePresent,
/// Sequence number existed when validation has been sent to
/// [`crate::behaviour::MessageAuthenticity::Anonymous`].
SequenceNumberPresent,
/// Message source existed when validation has been sent to
/// [`crate::behaviour::MessageAuthenticity::Anonymous`].
MessageSourcePresent,
/// The data transformation failed.
TransformFailed,
}

impl std::fmt::Display for ValidationError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{self:?}")
}
}

impl std::error::Error for ValidationError {}

impl From<std::io::Error> for PublishError {
fn from(error: std::io::Error) -> PublishError {
PublishError::TransformFailed(error)
}
}
141 changes: 0 additions & 141 deletions protocols/gossipsub/src/error_priv.rs

This file was deleted.

2 changes: 1 addition & 1 deletion protocols/gossipsub/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

use crate::protocol_priv::{GossipsubCodec, ProtocolConfig};
use crate::protocol::{GossipsubCodec, ProtocolConfig};
use crate::rpc_proto::proto;
use crate::types::{PeerKind, RawMessage, Rpc};
use crate::ValidationError;
Expand Down
Loading