Skip to content

Commit

Permalink
refactor(net): move node record constants to network-peers crate (#9161)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Jun 28, 2024
1 parent d8e6d01 commit 530e7e8
Show file tree
Hide file tree
Showing 23 changed files with 151 additions and 290 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions crates/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ extern crate alloc;
/// The chain info module.
mod info;

/// Network related constants
pub mod net;

/// The chain spec module.
mod spec;

Expand Down
250 changes: 0 additions & 250 deletions crates/chainspec/src/net.rs

This file was deleted.

12 changes: 4 additions & 8 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ use crate::constants::optimism::{
pub use alloy_eips::eip1559::BaseFeeParams;
#[cfg(feature = "optimism")]
use reth_ethereum_forks::OptimismHardfork;

#[cfg(feature = "optimism")]
use crate::net::{base_nodes, base_testnet_nodes, op_nodes, op_testnet_nodes};
use crate::net::{goerli_nodes, holesky_nodes, mainnet_nodes, sepolia_nodes};
use reth_network_peers::{
base_nodes, base_testnet_nodes, goerli_nodes, holesky_nodes, mainnet_nodes, op_nodes,
op_testnet_nodes, sepolia_nodes,
};

/// The Ethereum mainnet spec
pub static MAINNET: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
Expand Down Expand Up @@ -727,13 +727,9 @@ impl ChainSpec {
C::Goerli => Some(goerli_nodes()),
C::Sepolia => Some(sepolia_nodes()),
C::Holesky => Some(holesky_nodes()),
#[cfg(feature = "optimism")]
C::Base => Some(base_nodes()),
#[cfg(feature = "optimism")]
C::Optimism => Some(op_nodes()),
#[cfg(feature = "optimism")]
C::BaseGoerli | C::BaseSepolia => Some(base_testnet_nodes()),
#[cfg(feature = "optimism")]
C::OptimismSepolia | C::OptimismGoerli | C::OptimismKovan => Some(op_testnet_nodes()),
_ => None,
}
Expand Down
1 change: 1 addition & 0 deletions crates/e2e-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ reth-provider.workspace = true
reth-node-builder.workspace = true
reth-tokio-util.workspace = true
reth-stages-types.workspace = true
reth-network-peers.workspace = true

jsonrpsee.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/e2e-test-utils/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use reth::{
network::{NetworkEvent, NetworkEvents, NetworkHandle, PeersInfo},
rpc::types::PeerId,
};
use reth_chainspec::net::NodeRecord;
use reth_network_peers::NodeRecord;
use reth_tokio_util::EventStream;
use reth_tracing::tracing::info;

Expand Down
5 changes: 2 additions & 3 deletions crates/net/discv4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,8 @@ impl Discv4 {
/// ```
/// # use std::io;
/// use rand::thread_rng;
/// use reth_chainspec::net::NodeRecord;
/// use reth_discv4::{Discv4, Discv4Config};
/// use reth_network_peers::{pk2id, PeerId};
/// use reth_network_peers::{pk2id, NodeRecord, PeerId};
/// use secp256k1::SECP256K1;
/// use std::{net::SocketAddr, str::FromStr};
/// # async fn t() -> io::Result<()> {
Expand Down Expand Up @@ -2288,8 +2287,8 @@ mod tests {
use alloy_primitives::hex;
use alloy_rlp::{Decodable, Encodable};
use rand::{thread_rng, Rng};
use reth_chainspec::net::mainnet_nodes;
use reth_ethereum_forks::{EnrForkIdEntry, ForkHash};
use reth_network_peers::mainnet_nodes;
use std::future::poll_fn;

#[tokio::test]
Expand Down
7 changes: 2 additions & 5 deletions crates/net/network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ use crate::{
transactions::TransactionsManagerConfig,
NetworkHandle, NetworkManager,
};
use reth_chainspec::{
net::{mainnet_nodes, sepolia_nodes, TrustedPeer},
ChainSpec, MAINNET,
};
use reth_chainspec::{ChainSpec, MAINNET};
use reth_discv4::{Discv4Config, Discv4ConfigBuilder, NatResolver, DEFAULT_DISCOVERY_ADDRESS};
use reth_discv5::NetworkStackId;
use reth_dns_discovery::DnsDiscoveryConfig;
use reth_eth_wire::{HelloMessage, HelloMessageWithProtocols, Status};
use reth_network_peers::{pk2id, PeerId};
use reth_network_peers::{mainnet_nodes, pk2id, sepolia_nodes, PeerId, TrustedPeer};
use reth_network_types::{PeersConfig, SessionsConfig};
use reth_primitives::{ForkFilter, Head};
use reth_provider::{BlockReader, HeaderProvider};
Expand Down
4 changes: 2 additions & 2 deletions crates/net/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
//!
//! ```
//! # async fn launch() {
//! use reth_chainspec::net::mainnet_nodes;
//! use reth_network::{config::rng_secret_key, NetworkConfig, NetworkManager};
//! use reth_network_peers::mainnet_nodes;
//! use reth_provider::test_utils::NoopProvider;
//!
//! // This block provider implementation is used for testing purposes.
Expand All @@ -71,8 +71,8 @@
//! ### Configure all components of the Network with the [`NetworkBuilder`]
//!
//! ```
//! use reth_chainspec::net::mainnet_nodes;
//! use reth_network::{config::rng_secret_key, NetworkConfig, NetworkManager};
//! use reth_network_peers::mainnet_nodes;
//! use reth_provider::test_utils::NoopProvider;
//! use reth_transaction_pool::TransactionPool;
//! async fn launch<Pool: TransactionPool>(pool: Pool) {
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ where
/// components of the network
///
/// ```
/// use reth_chainspec::net::mainnet_nodes;
/// use reth_network::{config::rng_secret_key, NetworkConfig, NetworkManager};
/// use reth_network_peers::mainnet_nodes;
/// use reth_provider::test_utils::NoopProvider;
/// use reth_transaction_pool::TransactionPool;
/// async fn launch<Pool: TransactionPool>(pool: Pool) {
Expand Down
Loading

0 comments on commit 530e7e8

Please sign in to comment.