From 35e9f25acfdb768c0ff786d65832ad6ef852b805 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 21 Jun 2024 15:50:43 +0200 Subject: [PATCH] chore: rename net-common to banlist --- Cargo.lock | 9 ++++----- Cargo.toml | 4 ++-- bin/reth/Cargo.toml | 2 +- crates/net/{common => banlist}/Cargo.toml | 4 ++-- crates/net/banlist/src/ban_list.rs | 0 .../{common/src/ban_list.rs => banlist/src/lib.rs} | 8 ++++++++ crates/net/common/src/lib.rs | 11 ----------- crates/net/discv4/Cargo.toml | 2 +- crates/net/discv4/src/config.rs | 2 +- crates/net/eth-wire/Cargo.toml | 1 - crates/net/network/Cargo.toml | 2 +- crates/net/network/src/peers/manager.rs | 4 ++-- crates/net/network/tests/it/connect.rs | 2 +- docs/repo/layout.md | 2 +- 14 files changed, 24 insertions(+), 29 deletions(-) rename crates/net/{common => banlist}/Cargo.toml (77%) create mode 100644 crates/net/banlist/src/ban_list.rs rename crates/net/{common/src/ban_list.rs => banlist/src/lib.rs} (94%) delete mode 100644 crates/net/common/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index bb62e8c4729d..3f85f1b76a62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6234,7 +6234,7 @@ dependencies = [ "reth-execution-types", "reth-exex", "reth-fs-util", - "reth-net-common", + "reth-net-banlist", "reth-network", "reth-network-api", "reth-network-p2p", @@ -6686,7 +6686,7 @@ dependencies = [ "rand 0.8.5", "reth-chainspec", "reth-ethereum-forks", - "reth-net-common", + "reth-net-banlist", "reth-net-nat", "reth-network-peers", "reth-tracing", @@ -6890,7 +6890,6 @@ dependencies = [ "reth-ecies", "reth-eth-wire-types", "reth-metrics", - "reth-net-common", "reth-network-peers", "reth-primitives", "reth-tracing", @@ -7221,7 +7220,7 @@ dependencies = [ ] [[package]] -name = "reth-net-common" +name = "reth-net-banlist" version = "1.0.0-rc.2" dependencies = [ "alloy-primitives", @@ -7269,7 +7268,7 @@ dependencies = [ "reth-ecies", "reth-eth-wire", "reth-metrics", - "reth-net-common", + "reth-net-banlist", "reth-network", "reth-network-api", "reth-network-p2p", diff --git a/Cargo.toml b/Cargo.toml index 069452a7f33e..7c996352238b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ members = [ "crates/exex/types/", "crates/metrics/", "crates/metrics/metrics-derive/", - "crates/net/common/", + "crates/net/banlist/", "crates/net/discv4/", "crates/net/discv5/", "crates/net/dns/", @@ -288,7 +288,7 @@ reth-libmdbx = { path = "crates/storage/libmdbx-rs" } reth-mdbx-sys = { path = "crates/storage/libmdbx-rs/mdbx-sys" } reth-metrics = { path = "crates/metrics" } reth-metrics-derive = { path = "crates/metrics/metrics-derive" } -reth-net-common = { path = "crates/net/common" } +reth-net-banlist = { path = "crates/net/banlist" } reth-net-nat = { path = "crates/net/nat" } reth-network = { path = "crates/net/network" } reth-network-api = { path = "crates/net/network-api" } diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 46636913fdb1..1440922ee225 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -39,7 +39,7 @@ reth-rpc-types-compat.workspace = true reth-rpc-api = { workspace = true, features = ["client"] } reth-network = { workspace = true, features = ["serde"] } reth-network-p2p.workspace = true -reth-net-common.workspace = true +reth-net-banlist.workspace = true reth-network-api.workspace = true reth-downloaders.workspace = true reth-tracing.workspace = true diff --git a/crates/net/common/Cargo.toml b/crates/net/banlist/Cargo.toml similarity index 77% rename from crates/net/common/Cargo.toml rename to crates/net/banlist/Cargo.toml index 360c27c0aeb4..a9fb9fcda609 100644 --- a/crates/net/common/Cargo.toml +++ b/crates/net/banlist/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "reth-net-common" +name = "reth-net-banlist" version.workspace = true edition.workspace = true rust-version.workspace = true license.workspace = true homepage.workspace = true repository.workspace = true -description = "Types shared across network code" +description = "Banlist for peers and IPs" [lints] workspace = true diff --git a/crates/net/banlist/src/ban_list.rs b/crates/net/banlist/src/ban_list.rs new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/crates/net/common/src/ban_list.rs b/crates/net/banlist/src/lib.rs similarity index 94% rename from crates/net/common/src/ban_list.rs rename to crates/net/banlist/src/lib.rs index 6586becae0ae..29cf8eb76a4a 100644 --- a/crates/net/common/src/ban_list.rs +++ b/crates/net/banlist/src/lib.rs @@ -1,5 +1,13 @@ //! Support for banning peers. +#![doc( + html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png", + html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256", + issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/" +)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + type PeerId = alloy_primitives::B512; use std::{collections::HashMap, net::IpAddr, time::Instant}; diff --git a/crates/net/common/src/lib.rs b/crates/net/common/src/lib.rs deleted file mode 100644 index b4fcc48d675f..000000000000 --- a/crates/net/common/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! Shared types across `reth-net`. - -#![doc( - html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png", - html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256", - issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/" -)] -#![cfg_attr(not(test), warn(unused_crate_dependencies))] -#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] - -pub mod ban_list; diff --git a/crates/net/discv4/Cargo.toml b/crates/net/discv4/Cargo.toml index 2418f4d63ccc..2121b904c7fb 100644 --- a/crates/net/discv4/Cargo.toml +++ b/crates/net/discv4/Cargo.toml @@ -13,7 +13,7 @@ workspace = true [dependencies] # reth -reth-net-common.workspace = true +reth-net-banlist.workspace = true reth-ethereum-forks.workspace = true reth-net-nat.workspace = true reth-network-peers = { workspace = true, features = ["secp256k1"] } diff --git a/crates/net/discv4/src/config.rs b/crates/net/discv4/src/config.rs index 174514d98c67..4fae31f585ae 100644 --- a/crates/net/discv4/src/config.rs +++ b/crates/net/discv4/src/config.rs @@ -5,7 +5,7 @@ use alloy_primitives::bytes::Bytes; use alloy_rlp::Encodable; -use reth_net_common::ban_list::BanList; +use reth_net_banlist::BanList; use reth_net_nat::{NatResolver, ResolveNatInterval}; use reth_network_peers::NodeRecord; #[cfg(feature = "serde")] diff --git a/crates/net/eth-wire/Cargo.toml b/crates/net/eth-wire/Cargo.toml index 91bf9290f4c3..120512af1014 100644 --- a/crates/net/eth-wire/Cargo.toml +++ b/crates/net/eth-wire/Cargo.toml @@ -41,7 +41,6 @@ snap = "1.0.5" arbitrary = { workspace = true, features = ["derive"], optional = true } [dev-dependencies] -reth-net-common.workspace = true reth-primitives = { workspace = true, features = ["arbitrary"] } reth-tracing.workspace = true diff --git a/crates/net/network/Cargo.toml b/crates/net/network/Cargo.toml index 7d56243f66ff..f72ed6f6da29 100644 --- a/crates/net/network/Cargo.toml +++ b/crates/net/network/Cargo.toml @@ -15,7 +15,7 @@ workspace = true # reth reth-chainspec.workspace = true reth-primitives.workspace = true -reth-net-common.workspace = true +reth-net-banlist.workspace = true reth-network-api.workspace = true reth-network-p2p.workspace = true reth-discv4.workspace = true diff --git a/crates/net/network/src/peers/manager.rs b/crates/net/network/src/peers/manager.rs index 7468ba1a06ad..bde0bd066f07 100644 --- a/crates/net/network/src/peers/manager.rs +++ b/crates/net/network/src/peers/manager.rs @@ -12,7 +12,7 @@ use crate::{ }; use futures::StreamExt; use reth_eth_wire::{errors::EthStreamError, DisconnectReason}; -use reth_net_common::ban_list::BanList; +use reth_net_banlist::BanList; use reth_network_api::{PeerKind, ReputationChangeKind}; use reth_network_peers::{NodeRecord, PeerId}; use reth_primitives::ForkId; @@ -1555,7 +1555,7 @@ mod tests { errors::{EthHandshakeError, EthStreamError, P2PHandshakeError, P2PStreamError}, DisconnectReason, }; - use reth_net_common::ban_list::BanList; + use reth_net_banlist::BanList; use reth_network_api::{Direction, ReputationChangeKind}; use reth_network_peers::PeerId; use reth_primitives::B512; diff --git a/crates/net/network/tests/it/connect.rs b/crates/net/network/tests/it/connect.rs index bc61cd81befe..a191443ed8cb 100644 --- a/crates/net/network/tests/it/connect.rs +++ b/crates/net/network/tests/it/connect.rs @@ -6,7 +6,7 @@ use futures::StreamExt; use reth_chainspec::net::mainnet_nodes; use reth_discv4::Discv4Config; use reth_eth_wire::DisconnectReason; -use reth_net_common::ban_list::BanList; +use reth_net_banlist::BanList; use reth_network::{ test_utils::{enr_to_peer_id, NetworkEventStream, PeerConfig, Testnet, GETH_TIMEOUT}, NetworkConfigBuilder, NetworkEvent, NetworkEvents, NetworkManager, PeersConfig, diff --git a/docs/repo/layout.md b/docs/repo/layout.md index 552da3196b19..f7f0e93eab2e 100644 --- a/docs/repo/layout.md +++ b/docs/repo/layout.md @@ -56,7 +56,7 @@ The networking component mainly lives in [`net/network`](../../crates/net/networ #### Common -- [`net/common`](../../crates/net/common): Shared types used across multiple networking crates. +- [`net/banlist`](../../crates/net/banlist): A simple peer banlist that can be used to ban peers or IP addresses. - Contains: Peer banlist. - [`net/network-api`](../../crates/net/network-api): Contains traits that define the networking component as a whole. Other components that interface with the network stack only need to depend on this crate for the relevant types. - [`net/nat`](../../crates/net/nat): A small helper crate that resolves the external IP of the running node using various methods (such as a manually provided IP, using UPnP etc.)