From 34e2ef896eefd3bffa113ccf80f5c575b9cbdb86 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Thu, 1 Aug 2024 14:54:53 +0200 Subject: [PATCH] Move reputation module to reth-network-p2p --- Cargo.lock | 3 ++- crates/net/network-types/Cargo.toml | 3 ++- crates/net/network-types/src/lib.rs | 7 +++---- crates/net/network-types/src/peers/mod.rs | 6 +++--- crates/net/p2p/Cargo.toml | 5 ++++- crates/net/p2p/src/error.rs | 8 +++++--- crates/net/p2p/src/lib.rs | 4 ++++ .../{network-types/src/peers => p2p/src}/reputation.rs | 0 8 files changed, 23 insertions(+), 13 deletions(-) rename crates/net/{network-types/src/peers => p2p/src}/reputation.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index a5d8201179a6..05810f268ee9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7581,9 +7581,9 @@ dependencies = [ "reth-consensus", "reth-eth-wire-types", "reth-network-peers", - "reth-network-types", "reth-primitives", "reth-storage-errors", + "serde", "thiserror", "tokio", "tracing", @@ -7611,6 +7611,7 @@ version = "1.0.3" dependencies = [ "humantime-serde", "reth-net-banlist", + "reth-network-p2p", "reth-network-peers", "serde", "serde_json", diff --git a/crates/net/network-types/Cargo.toml b/crates/net/network-types/Cargo.toml index 2478aa6b494b..3cef30cf7d3c 100644 --- a/crates/net/network-types/Cargo.toml +++ b/crates/net/network-types/Cargo.toml @@ -15,6 +15,7 @@ workspace = true # reth reth-network-peers.workspace = true reth-net-banlist.workspace = true +reth-network-p2p.workspace = true # io serde = { workspace = true, optional = true } @@ -25,5 +26,5 @@ serde_json = { workspace = true } tracing.workspace = true [features] -serde = ["dep:serde", "dep:humantime-serde"] +serde = ["dep:serde", "dep:humantime-serde", "reth-network-p2p/serde"] test-utils = [] diff --git a/crates/net/network-types/src/lib.rs b/crates/net/network-types/src/lib.rs index 37ac395d5046..a4b5f5b10af6 100644 --- a/crates/net/network-types/src/lib.rs +++ b/crates/net/network-types/src/lib.rs @@ -14,10 +14,7 @@ /// Types related to peering. pub mod peers; -pub use peers::{ - reputation::{Reputation, ReputationChangeKind, ReputationChangeWeights}, - ConnectionsConfig, PeersConfig, -}; +pub use peers::{ConnectionsConfig, PeersConfig}; pub mod session; pub use session::{SessionLimits, SessionsConfig}; @@ -25,3 +22,5 @@ pub use session::{SessionLimits, SessionsConfig}; /// [`BackoffKind`] definition. mod backoff; pub use backoff::BackoffKind; + +pub use reth_network_p2p::reputation::{Reputation, ReputationChangeKind, ReputationChangeWeights}; diff --git a/crates/net/network-types/src/peers/mod.rs b/crates/net/network-types/src/peers/mod.rs index 4b195750b516..b28f998ef094 100644 --- a/crates/net/network-types/src/peers/mod.rs +++ b/crates/net/network-types/src/peers/mod.rs @@ -1,5 +1,5 @@ -pub mod reputation; -pub use reputation::ReputationChangeWeights; - pub mod config; + +pub use reth_network_p2p::reputation; + pub use config::{ConnectionsConfig, PeersConfig}; diff --git a/crates/net/p2p/Cargo.toml b/crates/net/p2p/Cargo.toml index 420212c6545e..617557f9fa33 100644 --- a/crates/net/p2p/Cargo.toml +++ b/crates/net/p2p/Cargo.toml @@ -17,7 +17,9 @@ reth-eth-wire-types.workspace = true reth-consensus.workspace = true reth-network-peers.workspace = true reth-storage-errors.workspace = true -reth-network-types.workspace = true + +# io +serde = { workspace = true, optional = true } # async futures.workspace = true @@ -38,3 +40,4 @@ tokio = { workspace = true, features = ["full"] } [features] test-utils = ["reth-consensus/test-utils", "parking_lot"] +serde = ["dep:serde"] diff --git a/crates/net/p2p/src/error.rs b/crates/net/p2p/src/error.rs index 0c0ec4bbde5d..91c3fa78fb6e 100644 --- a/crates/net/p2p/src/error.rs +++ b/crates/net/p2p/src/error.rs @@ -1,15 +1,17 @@ -use super::headers::client::HeadersRequest; +use std::ops::RangeInclusive; + use reth_consensus::ConsensusError; use reth_network_peers::WithPeerId; -use reth_network_types::ReputationChangeKind; use reth_primitives::{ BlockHashOrNumber, BlockNumber, GotExpected, GotExpectedBoxed, Header, B256, }; use reth_storage_errors::{db::DatabaseError, provider::ProviderError}; -use std::ops::RangeInclusive; use thiserror::Error; use tokio::sync::{mpsc, oneshot}; +use super::headers::client::HeadersRequest; +use crate::ReputationChangeKind; + /// Result alias for result of a request. pub type RequestResult = Result; diff --git a/crates/net/p2p/src/lib.rs b/crates/net/p2p/src/lib.rs index 074ec6e08c86..944c2f813307 100644 --- a/crates/net/p2p/src/lib.rs +++ b/crates/net/p2p/src/lib.rs @@ -44,3 +44,7 @@ pub mod sync; /// Common test helpers for mocking out Consensus, Downloaders and Header Clients. #[cfg(any(test, feature = "test-utils"))] pub mod test_utils; + +pub mod reputation; + +pub use reputation::{Reputation, ReputationChange, ReputationChangeKind, ReputationChangeWeights}; diff --git a/crates/net/network-types/src/peers/reputation.rs b/crates/net/p2p/src/reputation.rs similarity index 100% rename from crates/net/network-types/src/peers/reputation.rs rename to crates/net/p2p/src/reputation.rs