From be12177a2fe8a5ebbd1186432749df9d90b750bf Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 13 Jun 2024 22:46:30 +0200 Subject: [PATCH] chore: rm HasRemoteAddr trait (#8809) --- Cargo.lock | 1 - crates/net/common/Cargo.toml | 2 +- crates/net/common/src/lib.rs | 3 --- crates/net/common/src/stream.rs | 13 ------------- crates/net/ecies/Cargo.toml | 1 - crates/net/ecies/src/stream.rs | 6 ++---- crates/net/network/src/session/mod.rs | 3 +-- 7 files changed, 4 insertions(+), 25 deletions(-) delete mode 100644 crates/net/common/src/stream.rs diff --git a/Cargo.lock b/Cargo.lock index 6624aeac3b..c5280bf952 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6844,7 +6844,6 @@ dependencies = [ "hmac 0.12.1", "pin-project", "rand 0.8.5", - "reth-net-common", "reth-network-peers", "reth-primitives", "secp256k1 0.28.2", diff --git a/crates/net/common/Cargo.toml b/crates/net/common/Cargo.toml index c477725b55..975c2bdecc 100644 --- a/crates/net/common/Cargo.toml +++ b/crates/net/common/Cargo.toml @@ -16,4 +16,4 @@ workspace = true alloy-primitives.workspace = true # async -tokio = { workspace = true, features = ["full"] } +tokio = { workspace = true, features = ["time"] } diff --git a/crates/net/common/src/lib.rs b/crates/net/common/src/lib.rs index 9706d36620..3020abf26d 100644 --- a/crates/net/common/src/lib.rs +++ b/crates/net/common/src/lib.rs @@ -10,7 +10,4 @@ pub mod ban_list; -/// Traits related to tokio streams -pub mod stream; - pub mod ratelimit; diff --git a/crates/net/common/src/stream.rs b/crates/net/common/src/stream.rs deleted file mode 100644 index 4cf6f12bb1..0000000000 --- a/crates/net/common/src/stream.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::net::SocketAddr; -use tokio::net::TcpStream; -/// This trait is for instrumenting a `TCPStream` with a socket addr -pub trait HasRemoteAddr { - /// Maybe returns a [`SocketAddr`] - fn remote_addr(&self) -> Option; -} - -impl HasRemoteAddr for TcpStream { - fn remote_addr(&self) -> Option { - self.peer_addr().ok() - } -} diff --git a/crates/net/ecies/Cargo.toml b/crates/net/ecies/Cargo.toml index d7800c74db..2123bf48ff 100644 --- a/crates/net/ecies/Cargo.toml +++ b/crates/net/ecies/Cargo.toml @@ -12,7 +12,6 @@ workspace = true [dependencies] reth-primitives.workspace = true -reth-net-common.workspace = true reth-network-peers = { workspace = true, features = ["secp256k1"] } alloy-rlp = { workspace = true, features = ["derive"] } diff --git a/crates/net/ecies/src/stream.rs b/crates/net/ecies/src/stream.rs index 02c834fe0d..ca43fd4540 100644 --- a/crates/net/ecies/src/stream.rs +++ b/crates/net/ecies/src/stream.rs @@ -4,7 +4,6 @@ use crate::{ codec::ECIESCodec, error::ECIESErrorImpl, ECIESError, EgressECIESValue, IngressECIESValue, }; use futures::{ready, Sink, SinkExt}; -use reth_net_common::stream::HasRemoteAddr; use reth_primitives::{ bytes::{Bytes, BytesMut}, B512 as PeerId, @@ -38,10 +37,10 @@ pub struct ECIESStream { impl ECIESStream where - Io: AsyncRead + AsyncWrite + Unpin + HasRemoteAddr, + Io: AsyncRead + AsyncWrite + Unpin, { /// Connect to an `ECIES` server - #[instrument(skip(transport, secret_key), fields(peer=&*format!("{:?}", transport.remote_addr())))] + #[instrument(skip(transport, secret_key))] pub async fn connect( transport: Io, secret_key: SecretKey, @@ -98,7 +97,6 @@ where } /// Listen on a just connected ECIES client - #[instrument(skip_all, fields(peer=&*format!("{:?}", transport.remote_addr())))] pub async fn incoming(transport: Io, secret_key: SecretKey) -> Result { let ecies = ECIESCodec::new_server(secret_key)?; diff --git a/crates/net/network/src/session/mod.rs b/crates/net/network/src/session/mod.rs index ab5a9634cf..4f6be86317 100644 --- a/crates/net/network/src/session/mod.rs +++ b/crates/net/network/src/session/mod.rs @@ -15,7 +15,6 @@ use reth_eth_wire::{ UnauthedP2PStream, }; use reth_metrics::common::mpsc::MeteredPollSender; -use reth_net_common::stream::HasRemoteAddr; use reth_network_peers::PeerId; use reth_primitives::{ForkFilter, ForkId, ForkTransition, Head}; use reth_tasks::TaskSpawner; @@ -927,7 +926,7 @@ async fn authenticate( /// Returns an [`ECIESStream`] if it can be built. If not, send a /// [`PendingSessionEvent::EciesAuthError`] and returns `None` -async fn get_eciess_stream( +async fn get_eciess_stream( stream: Io, secret_key: SecretKey, direction: Direction,