refactor: extract peer types to net/types (#7912)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Andrzej Sulkowski
2024-04-27 06:18:59 +02:00
committed by GitHub
parent 6bdba8a2a6
commit cc4a418ddf
75 changed files with 428 additions and 86 deletions

30
Cargo.lock generated
View File

@@ -4741,6 +4741,7 @@ dependencies = [
"reth-ecies",
"reth-eth-wire",
"reth-network",
"reth-network-types",
"reth-primitives",
"secp256k1",
"tokio",
@@ -6323,6 +6324,7 @@ dependencies = [
"reth-engine-primitives",
"reth-evm",
"reth-interfaces",
"reth-network-types",
"reth-primitives",
"reth-provider",
"reth-revm",
@@ -6553,6 +6555,7 @@ dependencies = [
"rand 0.8.5",
"reth-net-common",
"reth-net-nat",
"reth-network-types",
"reth-primitives",
"reth-tracing",
"secp256k1",
@@ -6578,6 +6581,7 @@ dependencies = [
"multiaddr",
"rand 0.8.5",
"reth-metrics",
"reth-network-types",
"reth-primitives",
"reth-tracing",
"secp256k1",
@@ -6597,6 +6601,7 @@ dependencies = [
"parking_lot 0.12.2",
"rand 0.8.5",
"reth-net-common",
"reth-network-types",
"reth-primitives",
"reth-tracing",
"schnellru",
@@ -6628,6 +6633,7 @@ dependencies = [
"reth-db",
"reth-interfaces",
"reth-metrics",
"reth-network-types",
"reth-primitives",
"reth-provider",
"reth-tasks",
@@ -6689,6 +6695,7 @@ dependencies = [
"pin-project",
"rand 0.8.5",
"reth-net-common",
"reth-network-types",
"reth-primitives",
"secp256k1",
"sha2 0.10.8",
@@ -6732,6 +6739,7 @@ dependencies = [
"reth-eth-wire-types",
"reth-metrics",
"reth-net-common",
"reth-network-types",
"reth-primitives",
"reth-tracing",
"secp256k1",
@@ -6888,6 +6896,7 @@ dependencies = [
"reth-consensus",
"reth-eth-wire-types",
"reth-network-api",
"reth-network-types",
"reth-primitives",
"secp256k1",
"thiserror",
@@ -6978,7 +6987,7 @@ name = "reth-net-common"
version = "0.2.0-beta.6"
dependencies = [
"pin-project",
"reth-primitives",
"reth-network-types",
"tokio",
]
@@ -7031,6 +7040,7 @@ dependencies = [
"reth-net-common",
"reth-network",
"reth-network-api",
"reth-network-types",
"reth-primitives",
"reth-provider",
"reth-rpc-types",
@@ -7059,6 +7069,7 @@ dependencies = [
"enr",
"reth-discv4",
"reth-eth-wire",
"reth-network-types",
"reth-primitives",
"reth-rpc-types",
"serde",
@@ -7066,6 +7077,17 @@ dependencies = [
"tokio",
]
[[package]]
name = "reth-network-types"
version = "0.2.0-beta.6"
dependencies = [
"enr",
"reth-primitives",
"reth-rpc-types",
"secp256k1",
"serde_with",
]
[[package]]
name = "reth-nippy-jar"
version = "0.2.0-beta.6"
@@ -7369,7 +7391,6 @@ dependencies = [
"clap",
"criterion",
"derive_more",
"enr",
"hash-db",
"itertools 0.12.1",
"modular-bitfield",
@@ -7390,7 +7411,6 @@ dependencies = [
"secp256k1",
"serde",
"serde_json",
"serde_with",
"sha2 0.10.8",
"strum 0.26.2",
"sucds",
@@ -7500,6 +7520,7 @@ dependencies = [
"reth-interfaces",
"reth-metrics",
"reth-network-api",
"reth-network-types",
"reth-primitives",
"reth-provider",
"reth-revm",
@@ -7531,6 +7552,7 @@ version = "0.2.0-beta.6"
dependencies = [
"jsonrpsee",
"reth-engine-primitives",
"reth-network-types",
"reth-primitives",
"reth-rpc-types",
"serde",
@@ -7679,6 +7701,7 @@ dependencies = [
"reth-evm-ethereum",
"reth-exex",
"reth-interfaces",
"reth-network-types",
"reth-primitives",
"reth-provider",
"reth-revm",
@@ -7794,6 +7817,7 @@ dependencies = [
"rand 0.8.5",
"reth-eth-wire",
"reth-metrics",
"reth-network-types",
"reth-primitives",
"reth-provider",
"reth-revm",

View File

@@ -29,6 +29,7 @@ members = [
"crates/net/nat/",
"crates/net/network/",
"crates/net/network-api/",
"crates/net/types/",
"crates/payload/basic/",
"crates/payload/builder/",
"crates/payload/ethereum/",
@@ -223,7 +224,6 @@ reth-engine-primitives = { path = "crates/engine-primitives" }
reth-ethereum-engine-primitives = { path = "crates/ethereum/engine-primitives" }
reth-node-builder = { path = "crates/node-builder" }
reth-node-ethereum = { path = "crates/node-ethereum" }
reth-node-events = { path = "crates/node/events" }
reth-node-optimism = { path = "crates/optimism/node" }
reth-evm-optimism = { path = "crates/optimism/evm" }
reth-node-core = { path = "crates/node-core" }
@@ -249,6 +249,7 @@ reth-net-common = { path = "crates/net/common" }
reth-net-nat = { path = "crates/net/nat" }
reth-network = { path = "crates/net/network" }
reth-network-api = { path = "crates/net/network-api" }
reth-network-types = { path = "crates/net/types" }
reth-nippy-jar = { path = "crates/storage/nippy-jar" }
reth-payload-builder = { path = "crates/payload/builder" }
reth-payload-validator = { path = "crates/payload/validator" }
@@ -273,6 +274,7 @@ reth-transaction-pool = { path = "crates/transaction-pool" }
reth-trie = { path = "crates/trie" }
reth-trie-parallel = { path = "crates/trie-parallel" }
reth-optimism-consensus = { path = "crates/optimism/consensus" }
reth-node-events = { path = "crates/node/events" }
# revm
revm = { version = "8.0.0", features = ["std", "secp256k1"], default-features = false }

View File

@@ -24,6 +24,7 @@ reth-evm.workspace = true
reth-engine-primitives.workspace = true
reth-consensus.workspace = true
reth-rpc-types.workspace = true
reth-network-types.workspace = true
# async
futures-util.workspace = true

View File

@@ -7,9 +7,8 @@ use reth_interfaces::p2p::{
headers::client::{HeadersClient, HeadersFut, HeadersRequest},
priority::Priority,
};
use reth_primitives::{
BlockBody, BlockHashOrNumber, Header, HeadersDirection, PeerId, WithPeerId, B256,
};
use reth_network_types::{PeerId, WithPeerId};
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, HeadersDirection, B256};
use std::fmt::Debug;
use tracing::{trace, warn};

View File

@@ -15,6 +15,7 @@ reth-primitives.workspace = true
reth-network-api.workspace = true
reth-eth-wire-types.workspace = true
reth-consensus.workspace = true
reth-network-types.workspace = true
# async
futures.workspace = true

View File

@@ -1,4 +1,4 @@
use reth_primitives::PeerId;
use reth_network_types::PeerId;
use std::fmt::Debug;
/// Generic download client for peer penalization

View File

@@ -22,7 +22,7 @@ where
A: DownloadClient,
B: DownloadClient,
{
fn report_bad_message(&self, peer_id: reth_primitives::PeerId) {
fn report_bad_message(&self, peer_id: reth_network_types::PeerId) {
match self {
EitherDownloader::Left(a) => a.report_bad_message(peer_id),
EitherDownloader::Right(b) => b.report_bad_message(peer_id),

View File

@@ -2,8 +2,9 @@ use super::headers::client::HeadersRequest;
use crate::{db::DatabaseError, provider::ProviderError};
use reth_consensus::ConsensusError;
use reth_network_api::ReputationChangeKind;
use reth_network_types::WithPeerId;
use reth_primitives::{
BlockHashOrNumber, BlockNumber, GotExpected, GotExpectedBoxed, Header, WithPeerId, B256,
BlockHashOrNumber, BlockNumber, GotExpected, GotExpectedBoxed, Header, B256,
};
use std::ops::RangeInclusive;
use thiserror::Error;
@@ -12,7 +13,7 @@ use tokio::sync::{mpsc, oneshot};
/// Result alias for result of a request.
pub type RequestResult<T> = Result<T, RequestError>;
/// Result with [PeerId][reth_primitives::PeerId]
/// Result with [PeerId][reth_network_types::PeerId]
pub type PeerRequestResult<T> = RequestResult<WithPeerId<T>>;
/// Helper trait used to validate responses.

View File

@@ -6,8 +6,9 @@ use crate::p2p::{
};
use futures::Stream;
use reth_consensus::{Consensus, ConsensusError};
use reth_network_types::WithPeerId;
use reth_primitives::{
BlockBody, GotExpected, Header, HeadersDirection, SealedBlock, SealedHeader, WithPeerId, B256,
BlockBody, GotExpected, Header, HeadersDirection, SealedBlock, SealedHeader, B256,
};
use std::{
cmp::Reverse,

View File

@@ -22,7 +22,7 @@ impl<F> Debug for TestBodiesClient<F> {
}
impl<F: Sync + Send> DownloadClient for TestBodiesClient<F> {
fn report_bad_message(&self, _peer_id: reth_primitives::PeerId) {
fn report_bad_message(&self, _peer_id: reth_network_types::PeerId) {
// noop
}

View File

@@ -6,9 +6,10 @@ use crate::p2p::{
priority::Priority,
};
use parking_lot::Mutex;
use reth_network_types::{PeerId, WithPeerId};
use reth_primitives::{
BlockBody, BlockHashOrNumber, BlockNumHash, Header, HeadersDirection, PeerId, SealedBlock,
SealedHeader, WithPeerId, B256,
BlockBody, BlockHashOrNumber, BlockNumHash, Header, HeadersDirection, SealedBlock,
SealedHeader, B256,
};
use std::{collections::HashMap, sync::Arc};

View File

@@ -24,7 +24,8 @@ use crate::p2p::{
priority::Priority,
};
use reth_consensus::{test_utils::TestConsensus, Consensus};
use reth_primitives::{Header, HeadersDirection, PeerId, SealedHeader, WithPeerId};
use reth_network_types::{PeerId, WithPeerId};
use reth_primitives::{Header, HeadersDirection, SealedHeader};
/// A test downloader which just returns the values that have been pushed to it.
#[derive(Debug)]

View File

@@ -13,7 +13,7 @@ workspace = true
[dependencies]
# reth
reth-primitives.workspace = true
reth-network-types.workspace = true
# async
pin-project.workspace = true

View File

@@ -1,6 +1,6 @@
//! Support for banning peers.
use reth_primitives::PeerId;
use reth_network_types::PeerId;
use std::{collections::HashMap, net::IpAddr, time::Instant};
/// Determines whether or not the IP is globally routable.

View File

@@ -16,6 +16,7 @@ workspace = true
reth-primitives.workspace = true
reth-net-common.workspace = true
reth-net-nat.workspace = true
reth-network-types.workspace = true
# ethereum
alloy-rlp = { workspace = true, features = ["derive"] }

View File

@@ -39,7 +39,8 @@ use discv5::{
use enr::Enr;
use parking_lot::Mutex;
use proto::{EnrRequest, EnrResponse};
use reth_primitives::{bytes::Bytes, hex, ForkId, PeerId, B256};
use reth_network_types::PeerId;
use reth_primitives::{bytes::Bytes, hex, ForkId, B256};
use secp256k1::SecretKey;
use std::{
cell::RefCell,
@@ -210,7 +211,8 @@ impl Discv4 {
/// # use std::io;
/// use rand::thread_rng;
/// use reth_discv4::{Discv4, Discv4Config};
/// use reth_primitives::{pk2id, NodeRecord, PeerId};
/// use reth_network_types::{pk2id, PeerId};
/// use reth_primitives::NodeRecord;
/// use secp256k1::SECP256K1;
/// use std::{net::SocketAddr, str::FromStr};
/// # async fn t() -> io::Result<()> {

View File

@@ -1,5 +1,6 @@
use generic_array::GenericArray;
use reth_primitives::{keccak256, NodeRecord, PeerId};
use reth_network_types::PeerId;
use reth_primitives::{keccak256, NodeRecord};
/// The key type for the table.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]

View File

@@ -1,11 +1,12 @@
//! Discovery v4 protocol implementation.
use crate::{error::DecodePacketError, PeerId, MAX_PACKET_SIZE, MIN_PACKET_SIZE};
use crate::{error::DecodePacketError, MAX_PACKET_SIZE, MIN_PACKET_SIZE};
use alloy_rlp::{Decodable, Encodable, Error as RlpError, Header, RlpDecodable, RlpEncodable};
use enr::Enr;
use reth_network_types::{pk2id, PeerId};
use reth_primitives::{
bytes::{Buf, BufMut, Bytes, BytesMut},
keccak256, pk2id, EnrForkIdEntry, ForkId, NodeRecord, B256,
keccak256, EnrForkIdEntry, ForkId, NodeRecord, B256,
};
use secp256k1::{
ecdsa::{RecoverableSignature, RecoveryId},

View File

@@ -1,6 +1,6 @@
//! Additional support for tracking nodes.
use reth_primitives::PeerId;
use reth_network_types::PeerId;
use std::{collections::HashMap, net::IpAddr, time::Instant};
/// Keeps track of nodes from which we have received a `Pong` message.

View File

@@ -6,7 +6,8 @@ use crate::{
IngressReceiver, PeerId, SAFE_MAX_DATAGRAM_NEIGHBOUR_RECORDS,
};
use rand::{thread_rng, Rng, RngCore};
use reth_primitives::{hex, pk2id, ForkHash, ForkId, NodeRecord, B256};
use reth_network_types::pk2id;
use reth_primitives::{hex, ForkHash, ForkId, NodeRecord, B256};
use secp256k1::{SecretKey, SECP256K1};
use std::{
collections::{HashMap, HashSet},

View File

@@ -15,6 +15,7 @@ workspace = true
# reth
reth-primitives.workspace = true
reth-metrics.workspace = true
reth-network-types.workspace = true
# ethereum
alloy-rlp.workspace = true

View File

@@ -3,7 +3,7 @@
use discv5::enr::{CombinedPublicKey, EnrPublicKey, NodeId};
use enr::Enr;
use reth_primitives::{id2pk, pk2id, PeerId};
use reth_network_types::{id2pk, pk2id, PeerId};
use secp256k1::{PublicKey, SecretKey};
/// Extracts a [`CombinedPublicKey::Secp256k1`] from a [`discv5::Enr`] and converts it to a

View File

@@ -22,7 +22,8 @@ use enr::{discv4_id_to_discv5_id, EnrCombinedKeyWrapper};
use futures::future::join_all;
use itertools::Itertools;
use rand::{Rng, RngCore};
use reth_primitives::{bytes::Bytes, EnrForkIdEntry, ForkId, NodeRecord, PeerId};
use reth_network_types::PeerId;
use reth_primitives::{bytes::Bytes, EnrForkIdEntry, ForkId, NodeRecord};
use secp256k1::SecretKey;
use tokio::{sync::mpsc, task};
use tracing::{debug, error, trace};

View File

@@ -15,6 +15,7 @@ workspace = true
# reth
reth-primitives.workspace = true
reth-net-common.workspace = true
reth-network-types.workspace = true
# ethereum
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery", "serde"] }

View File

@@ -22,7 +22,8 @@ use crate::{
pub use config::DnsDiscoveryConfig;
use enr::Enr;
use error::ParseDnsEntryError;
use reth_primitives::{pk2id, EnrForkIdEntry, ForkId, NodeRecord};
use reth_network_types::pk2id;
use reth_primitives::{EnrForkIdEntry, ForkId, NodeRecord};
use schnellru::{ByLength, LruMap};
use secp256k1::SecretKey;
use std::{

View File

@@ -19,6 +19,7 @@ reth-tasks.workspace = true
reth-provider.workspace = true
reth-config.workspace = true
reth-consensus.workspace = true
reth-network-types.workspace = true
# async
futures.workspace = true

View File

@@ -6,9 +6,8 @@ use reth_interfaces::p2p::{
error::{DownloadError, DownloadResult},
priority::Priority,
};
use reth_primitives::{
BlockBody, GotExpected, PeerId, SealedBlock, SealedHeader, WithPeerId, B256,
};
use reth_network_types::{PeerId, WithPeerId};
use reth_primitives::{BlockBody, GotExpected, SealedBlock, SealedHeader, B256};
use std::{
collections::VecDeque,
mem,

View File

@@ -7,9 +7,10 @@ use reth_interfaces::p2p::{
headers::client::{HeadersClient, HeadersFut, HeadersRequest},
priority::Priority,
};
use reth_network_types::PeerId;
use reth_primitives::{
BlockBody, BlockHash, BlockHashOrNumber, BlockNumber, BytesMut, Header, HeadersDirection,
PeerId, SealedHeader, B256,
SealedHeader, B256,
};
use std::{collections::HashMap, path::Path};
use thiserror::Error;

View File

@@ -16,9 +16,9 @@ use reth_interfaces::p2p::{
},
priority::Priority,
};
use reth_network_types::PeerId;
use reth_primitives::{
BlockHashOrNumber, BlockNumber, GotExpected, Header, HeadersDirection, PeerId, SealedHeader,
B256,
BlockHashOrNumber, BlockNumber, GotExpected, Header, HeadersDirection, SealedHeader, B256,
};
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use std::{

View File

@@ -3,7 +3,8 @@ use reth_interfaces::p2p::{
download::DownloadClient,
priority::Priority,
};
use reth_primitives::{BlockBody, PeerId, B256};
use reth_network_types::PeerId;
use reth_primitives::{BlockBody, B256};
use std::{
collections::HashMap,
fmt::Debug,

View File

@@ -13,6 +13,7 @@ workspace = true
[dependencies]
reth-primitives.workspace = true
reth-net-common.workspace = true
reth-network-types.workspace = true
alloy-rlp = { workspace = true, features = ["derive"] }
futures.workspace = true

View File

@@ -13,9 +13,10 @@ use ctr::Ctr64BE;
use digest::{crypto_common::KeyIvInit, Digest};
use educe::Educe;
use rand::{thread_rng, Rng};
use reth_network_types::{id2pk, pk2id};
use reth_primitives::{
bytes::{BufMut, Bytes, BytesMut},
id2pk, pk2id, B128, B256, B512 as PeerId,
B128, B256, B512 as PeerId,
};
use secp256k1::{
ecdsa::{RecoverableSignature, RecoveryId},

View File

@@ -175,7 +175,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use reth_primitives::pk2id;
use reth_network_types::pk2id;
use secp256k1::SECP256K1;
use tokio::net::{TcpListener, TcpStream};

View File

@@ -19,6 +19,7 @@ reth-ecies.workspace = true
alloy-rlp = { workspace = true, features = ["derive"] }
reth-discv4.workspace = true
reth-eth-wire-types.workspace = true
reth-network-types.workspace = true
# metrics
reth-metrics.workspace = true

View File

@@ -354,7 +354,8 @@ mod tests {
use futures::{SinkExt, StreamExt};
use reth_discv4::DEFAULT_DISCOVERY_PORT;
use reth_ecies::stream::ECIESStream;
use reth_primitives::{pk2id, ForkFilter, Head, NamedChain, B256, U256};
use reth_network_types::pk2id;
use reth_primitives::{ForkFilter, Head, NamedChain, B256, U256};
use secp256k1::{SecretKey, SECP256K1};
use std::time::Duration;
use tokio::net::{TcpListener, TcpStream};

View File

@@ -2,7 +2,8 @@ use crate::{capability::Capability, EthVersion, ProtocolVersion};
use alloy_rlp::{RlpDecodable, RlpEncodable};
use reth_codecs::derive_arbitrary;
use reth_discv4::DEFAULT_DISCOVERY_PORT;
use reth_primitives::{constants::RETH_CLIENT_VERSION, PeerId};
use reth_network_types::PeerId;
use reth_primitives::constants::RETH_CLIENT_VERSION;
use crate::protocol::Protocol;
#[cfg(feature = "serde")]
@@ -38,7 +39,7 @@ impl HelloMessageWithProtocols {
///
/// ```
/// use reth_eth_wire::HelloMessageWithProtocols;
/// use reth_primitives::pk2id;
/// use reth_network_types::pk2id;
/// use secp256k1::{SecretKey, SECP256K1};
/// let secret_key = SecretKey::new(&mut rand::thread_rng());
/// let id = pk2id(&secret_key.public_key(SECP256K1));
@@ -120,7 +121,7 @@ impl HelloMessage {
///
/// ```
/// use reth_eth_wire::HelloMessage;
/// use reth_primitives::pk2id;
/// use reth_network_types::pk2id;
/// use secp256k1::{SecretKey, SECP256K1};
/// let secret_key = SecretKey::new(&mut rand::thread_rng());
/// let id = pk2id(&secret_key.public_key(SECP256K1));
@@ -209,7 +210,7 @@ impl HelloMessageBuilder {
mod tests {
use alloy_rlp::{Decodable, Encodable, EMPTY_STRING_CODE};
use reth_discv4::DEFAULT_DISCOVERY_PORT;
use reth_primitives::pk2id;
use reth_network_types::pk2id;
use secp256k1::{SecretKey, SECP256K1};
use crate::{

View File

@@ -357,9 +357,10 @@ mod tests {
UnauthedEthStream, UnauthedP2PStream,
};
use futures::{Future, SinkExt, StreamExt};
use reth_network_types::pk2id;
use reth_primitives::{
bytes::{BufMut, Bytes, BytesMut},
pk2id, ForkFilter, Hardfork, MAINNET,
ForkFilter, Hardfork, MAINNET,
};
use secp256k1::{SecretKey, SECP256K1};
use std::{net::SocketAddr, pin::Pin};

View File

@@ -4,7 +4,8 @@ use crate::{
EthVersion, HelloMessageWithProtocols, P2PStream, ProtocolVersion, Status, UnauthedP2PStream,
};
use reth_discv4::DEFAULT_DISCOVERY_PORT;
use reth_primitives::{pk2id, Chain, ForkFilter, Head, B256, U256};
use reth_network_types::pk2id;
use reth_primitives::{Chain, ForkFilter, Head, B256, U256};
use secp256k1::{SecretKey, SECP256K1};
use std::net::SocketAddr;
use tokio::net::TcpStream;

View File

@@ -17,6 +17,7 @@ reth-primitives.workspace = true
reth-eth-wire.workspace = true
reth-rpc-types.workspace = true
reth-discv4.workspace = true
reth-network-types.workspace = true
# eth
enr = { workspace = true, default-features = false, features = ["rust-secp256k1"] }

View File

@@ -14,7 +14,8 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
use reth_eth_wire::{DisconnectReason, EthVersion, Status};
use reth_primitives::{NodeRecord, PeerId};
use reth_network_types::PeerId;
use reth_primitives::NodeRecord;
use std::{future::Future, net::SocketAddr, sync::Arc, time::Instant};
pub use error::NetworkError;

View File

@@ -10,7 +10,8 @@ use crate::{
use enr::{secp256k1::SecretKey, Enr};
use reth_discv4::DEFAULT_DISCOVERY_PORT;
use reth_eth_wire::{DisconnectReason, ProtocolVersion};
use reth_primitives::{Chain, NodeRecord, PeerId};
use reth_network_types::PeerId;
use reth_primitives::{Chain, NodeRecord};
use reth_rpc_types::{admin::EthProtocolInfo, NetworkStatus};
use std::net::{IpAddr, SocketAddr};

View File

@@ -28,6 +28,7 @@ reth-provider.workspace = true
reth-rpc-types.workspace = true
reth-tokio-util.workspace = true
reth-consensus.workspace = true
reth-network-types.workspace = true
# ethereum
enr = { workspace = true, features = ["serde", "rust-secp256k1"] }

View File

@@ -12,9 +12,9 @@ use reth_discv4::{Discv4Config, Discv4ConfigBuilder, DEFAULT_DISCOVERY_ADDRESS};
use reth_discv5::network_key;
use reth_dns_discovery::DnsDiscoveryConfig;
use reth_eth_wire::{HelloMessage, HelloMessageWithProtocols, Status};
use reth_network_types::{pk2id, PeerId};
use reth_primitives::{
mainnet_nodes, pk2id, sepolia_nodes, ChainSpec, ForkFilter, Head, NamedChain, NodeRecord,
PeerId, MAINNET,
mainnet_nodes, sepolia_nodes, ChainSpec, ForkFilter, Head, NamedChain, NodeRecord, MAINNET,
};
use reth_provider::{BlockReader, HeaderProvider};
use reth_tasks::{TaskSpawner, TokioTaskExecutor};

View File

@@ -12,7 +12,8 @@ use reth_discv5::{DiscoveredPeer, Discv5};
use reth_dns_discovery::{
DnsDiscoveryConfig, DnsDiscoveryHandle, DnsDiscoveryService, DnsNodeRecordUpdate, DnsResolver,
};
use reth_primitives::{EnrForkIdEntry, ForkId, NodeRecord, PeerId};
use reth_network_types::PeerId;
use reth_primitives::{EnrForkIdEntry, ForkId, NodeRecord};
use secp256k1::SecretKey;
use std::{
collections::VecDeque,

View File

@@ -11,7 +11,8 @@ use reth_eth_wire::{
Receipts,
};
use reth_interfaces::p2p::error::RequestResult;
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, HeadersDirection, PeerId};
use reth_network_types::PeerId;
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, HeadersDirection};
use reth_provider::{BlockReader, HeaderProvider, ReceiptProvider};
use std::{
future::Future,

View File

@@ -11,7 +11,8 @@ use reth_interfaces::p2p::{
priority::Priority,
};
use reth_network_api::ReputationChangeKind;
use reth_primitives::{Header, PeerId, B256};
use reth_network_types::PeerId;
use reth_primitives::{Header, B256};
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,

View File

@@ -9,7 +9,8 @@ use reth_interfaces::p2p::{
priority::Priority,
};
use reth_network_api::ReputationChangeKind;
use reth_primitives::{BlockBody, Header, PeerId, B256};
use reth_network_types::PeerId;
use reth_primitives::{BlockBody, Header, B256};
use std::{
collections::{HashMap, VecDeque},
sync::{

View File

@@ -1,7 +1,7 @@
//! This module provides an abstraction over block import in the form of the `BlockImport` trait.
use crate::message::NewBlockMessage;
use reth_primitives::PeerId;
use reth_network_types::PeerId;
use std::task::{Context, Poll};
/// Abstraction over block import.

View File

@@ -44,7 +44,8 @@ use reth_eth_wire::{
use reth_metrics::common::mpsc::UnboundedMeteredSender;
use reth_net_common::bandwidth_meter::BandwidthMeter;
use reth_network_api::ReputationChangeKind;
use reth_primitives::{ForkId, NodeRecord, PeerId};
use reth_network_types::PeerId;
use reth_primitives::{ForkId, NodeRecord};
use reth_provider::{BlockNumReader, BlockReader};
use reth_rpc_types::{admin::EthProtocolInfo, NetworkStatus};
use reth_tasks::shutdown::GracefulShutdown;

View File

@@ -11,8 +11,9 @@ use reth_eth_wire::{
SharedTransactions, Transactions,
};
use reth_interfaces::p2p::error::{RequestError, RequestResult};
use reth_network_types::PeerId;
use reth_primitives::{
BlockBody, Bytes, Header, PeerId, PooledTransactionsElement, ReceiptWithBloom, B256,
BlockBody, Bytes, Header, PooledTransactionsElement, ReceiptWithBloom, B256,
};
use std::{
fmt,

View File

@@ -13,7 +13,8 @@ use reth_network_api::{
NetworkError, NetworkInfo, PeerInfo, PeerKind, Peers, PeersInfo, Reputation,
ReputationChangeKind,
};
use reth_primitives::{Head, NodeRecord, PeerId, TransactionSigned, B256};
use reth_network_types::PeerId;
use reth_primitives::{Head, NodeRecord, TransactionSigned, B256};
use reth_rpc_types::NetworkStatus;
use secp256k1::SecretKey;
use std::{

View File

@@ -14,7 +14,8 @@ use futures::StreamExt;
use reth_eth_wire::{errors::EthStreamError, DisconnectReason};
use reth_net_common::ban_list::BanList;
use reth_network_api::{PeerKind, ReputationChangeKind};
use reth_primitives::{ForkId, NodeRecord, PeerId};
use reth_network_types::PeerId;
use reth_primitives::{ForkId, NodeRecord};
use std::{
collections::{hash_map::Entry, HashMap, HashSet, VecDeque},
fmt::Display,
@@ -1558,7 +1559,8 @@ mod tests {
};
use reth_net_common::ban_list::BanList;
use reth_network_api::{Direction, ReputationChangeKind};
use reth_primitives::{PeerId, B512};
use reth_network_types::PeerId;
use reth_primitives::B512;
use std::{
collections::HashSet,
future::{poll_fn, Future},

View File

@@ -20,7 +20,7 @@ use reth_eth_wire::{
};
use reth_interfaces::p2p::error::RequestError;
use reth_metrics::common::mpsc::MeteredPollSender;
use reth_primitives::PeerId;
use reth_network_types::PeerId;
use std::{
collections::VecDeque,
future::Future,
@@ -769,7 +769,8 @@ mod tests {
UnauthedEthStream, UnauthedP2PStream,
};
use reth_net_common::bandwidth_meter::{BandwidthMeter, MeteredStream};
use reth_primitives::{pk2id, ForkFilter, Hardfork, MAINNET};
use reth_network_types::pk2id;
use reth_primitives::{ForkFilter, Hardfork, MAINNET};
use secp256k1::{SecretKey, SECP256K1};
use tokio::{
net::{TcpListener, TcpStream},

View File

@@ -12,7 +12,7 @@ use reth_eth_wire::{
DisconnectReason, EthVersion, Status,
};
use reth_network_api::PeerInfo;
use reth_primitives::PeerId;
use reth_network_types::PeerId;
use std::{io, net::SocketAddr, sync::Arc, time::Instant};
use tokio::sync::{
mpsc::{self, error::SendError},

View File

@@ -19,7 +19,8 @@ use reth_net_common::{
bandwidth_meter::{BandwidthMeter, MeteredStream},
stream::HasRemoteAddr,
};
use reth_primitives::{ForkFilter, ForkId, ForkTransition, Head, PeerId};
use reth_network_types::PeerId;
use reth_primitives::{ForkFilter, ForkId, ForkTransition, Head};
use reth_tasks::TaskSpawner;
use secp256k1::SecretKey;
use std::{

View File

@@ -18,7 +18,8 @@ use reth_eth_wire::{
capability::Capabilities, BlockHashNumber, DisconnectReason, NewBlockHashes, Status,
};
use reth_network_api::PeerKind;
use reth_primitives::{ForkId, PeerId, B256};
use reth_network_types::PeerId;
use reth_primitives::{ForkId, B256};
use reth_provider::BlockNumReader;
use std::{
collections::{HashMap, VecDeque},
@@ -537,7 +538,8 @@ mod tests {
BlockBodies, EthVersion,
};
use reth_interfaces::p2p::{bodies::client::BodiesClient, error::RequestError};
use reth_primitives::{BlockBody, Header, PeerId, B256};
use reth_network_types::PeerId;
use reth_primitives::{BlockBody, Header, B256};
use reth_provider::test_utils::NoopProvider;
use std::{
future::poll_fn,

View File

@@ -12,7 +12,7 @@ use reth_eth_wire::{
errors::EthStreamError,
EthVersion, Status,
};
use reth_primitives::PeerId;
use reth_network_types::PeerId;
use reth_provider::{BlockNumReader, BlockReader};
use std::{
io,

View File

@@ -1,5 +1,5 @@
use enr::{k256::ecdsa::SigningKey, Enr, EnrPublicKey};
use reth_primitives::PeerId;
use reth_network_types::PeerId;
use std::{net::SocketAddr, time::Duration};
/// The timeout for tests that create a GethInstance

View File

@@ -14,7 +14,8 @@ use futures::{FutureExt, StreamExt};
use pin_project::pin_project;
use reth_eth_wire::{protocol::Protocol, DisconnectReason, HelloMessageWithProtocols};
use reth_network_api::{NetworkInfo, Peers};
use reth_primitives::{PeerId, MAINNET};
use reth_network_types::PeerId;
use reth_primitives::MAINNET;
use reth_provider::{
test_utils::NoopProvider, BlockReader, BlockReaderIdExt, HeaderProvider, StateProviderFactory,
};

View File

@@ -41,7 +41,8 @@ use reth_eth_wire::{
PartiallyValidData, RequestTxHashes, ValidAnnouncementData,
};
use reth_interfaces::p2p::error::{RequestError, RequestResult};
use reth_primitives::{PeerId, PooledTransactionsElement, TxHash};
use reth_network_types::PeerId;
use reth_primitives::{PooledTransactionsElement, TxHash};
use schnellru::ByLength;
#[cfg(debug_assertions)]
use smallvec::{smallvec, SmallVec};

View File

@@ -26,9 +26,9 @@ use reth_interfaces::{
};
use reth_metrics::common::mpsc::UnboundedMeteredReceiver;
use reth_network_api::{Peers, ReputationChangeKind};
use reth_network_types::PeerId;
use reth_primitives::{
FromRecoveredPooledTransaction, PeerId, PooledTransactionsElement, TransactionSigned, TxHash,
B256,
FromRecoveredPooledTransaction, PooledTransactionsElement, TransactionSigned, TxHash, B256,
};
use reth_transaction_pool::{
error::{PoolError, PoolResult},

View File

@@ -0,0 +1,27 @@
[package]
name = "reth-network-types"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
description = "Network types and utils"
[lints]
workspace = true
[dependencies]
# reth
reth-rpc-types.workspace = true
reth-primitives.workspace = true
# eth
enr.workspace = true
# crypto
secp256k1 = { workspace = true, features = ["global-context", "recovery", "rand"] }
# misc
serde_with.workspace = true

239
crates/net/types/src/lib.rs Normal file
View File

@@ -0,0 +1,239 @@
//! Network Types and Utilities.
//!
//! This crate manages and converts Ethereum network entities such as node records, peer IDs, and
//! Ethereum Node Records (ENRs)
#![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))]
use secp256k1::{constants::UNCOMPRESSED_PUBLIC_KEY_SIZE, PublicKey, SecretKey};
use std::{net::IpAddr, str::FromStr};
// Re-export PeerId for ease of use.
pub use enr::Enr;
pub use reth_rpc_types::{NodeRecord, PeerId};
/// This tag should be set to indicate to libsecp256k1 that the following bytes denote an
/// uncompressed pubkey.
///
/// `SECP256K1_TAG_PUBKEY_UNCOMPRESSED` = `0x04`
///
/// See: <https://github.com/bitcoin-core/secp256k1/blob/master/include/secp256k1.h#L211>
const SECP256K1_TAG_PUBKEY_UNCOMPRESSED: u8 = 4;
/// Converts a [secp256k1::PublicKey] to a [PeerId] by stripping the
/// `SECP256K1_TAG_PUBKEY_UNCOMPRESSED` tag and storing the rest of the slice in the [PeerId].
#[inline]
pub fn pk2id(pk: &PublicKey) -> PeerId {
PeerId::from_slice(&pk.serialize_uncompressed()[1..])
}
/// Converts a [PeerId] to a [secp256k1::PublicKey] by prepending the [PeerId] bytes with the
/// SECP256K1_TAG_PUBKEY_UNCOMPRESSED tag.
#[inline]
pub fn id2pk(id: PeerId) -> Result<PublicKey, secp256k1::Error> {
// NOTE: B512 is used as a PeerId because 512 bits is enough to represent an uncompressed
// public key.
let mut s = [0u8; UNCOMPRESSED_PUBLIC_KEY_SIZE];
s[0] = SECP256K1_TAG_PUBKEY_UNCOMPRESSED;
s[1..].copy_from_slice(id.as_slice());
PublicKey::from_slice(&s)
}
/// A peer that can come in ENR or [NodeRecord] form.
#[derive(
Debug, Clone, Eq, PartialEq, Hash, serde_with::SerializeDisplay, serde_with::DeserializeFromStr,
)]
pub enum AnyNode {
/// An "enode:" peer with full ip
NodeRecord(NodeRecord),
/// An "enr:"
Enr(Enr<SecretKey>),
/// An incomplete "enode" with only a peer id
PeerId(PeerId),
}
impl AnyNode {
/// Returns the peer id of the node.
pub fn peer_id(&self) -> PeerId {
match self {
AnyNode::NodeRecord(record) => record.id,
AnyNode::Enr(enr) => pk2id(&enr.public_key()),
AnyNode::PeerId(peer_id) => *peer_id,
}
}
/// Returns the full node record if available.
pub fn node_record(&self) -> Option<NodeRecord> {
match self {
AnyNode::NodeRecord(record) => Some(*record),
AnyNode::Enr(enr) => {
let node_record = NodeRecord {
address: enr.ip4().map(IpAddr::from).or_else(|| enr.ip6().map(IpAddr::from))?,
tcp_port: enr.tcp4().or_else(|| enr.tcp6())?,
udp_port: enr.udp4().or_else(|| enr.udp6())?,
id: pk2id(&enr.public_key()),
}
.into_ipv4_mapped();
Some(node_record)
}
_ => None,
}
}
}
impl From<NodeRecord> for AnyNode {
fn from(value: NodeRecord) -> Self {
Self::NodeRecord(value)
}
}
impl From<Enr<SecretKey>> for AnyNode {
fn from(value: Enr<SecretKey>) -> Self {
Self::Enr(value)
}
}
impl FromStr for AnyNode {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
if let Some(rem) = s.strip_prefix("enode://") {
if let Ok(record) = NodeRecord::from_str(s) {
return Ok(AnyNode::NodeRecord(record))
}
// incomplete enode
if let Ok(peer_id) = PeerId::from_str(rem) {
return Ok(AnyNode::PeerId(peer_id))
}
return Err(format!("invalid public key: {rem}"))
}
if s.starts_with("enr:") {
return Enr::from_str(s).map(AnyNode::Enr)
}
Err("missing 'enr:' prefix for base64-encoded record".to_string())
}
}
impl std::fmt::Display for AnyNode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AnyNode::NodeRecord(record) => write!(f, "{record}"),
AnyNode::Enr(enr) => write!(f, "{enr}"),
AnyNode::PeerId(peer_id) => {
write!(f, "enode://{}", reth_primitives::hex::encode(peer_id.as_slice()))
}
}
}
}
/// Generic wrapper with peer id
#[derive(Debug)]
pub struct WithPeerId<T>(PeerId, pub T);
impl<T> From<(PeerId, T)> for WithPeerId<T> {
fn from(value: (PeerId, T)) -> Self {
Self(value.0, value.1)
}
}
impl<T> WithPeerId<T> {
/// Wraps the value with the peerid.
pub fn new(peer: PeerId, value: T) -> Self {
Self(peer, value)
}
/// Get the peer id
pub fn peer_id(&self) -> PeerId {
self.0
}
/// Get the underlying data
pub fn data(&self) -> &T {
&self.1
}
/// Returns ownership of the underlying data.
pub fn into_data(self) -> T {
self.1
}
/// Transform the data
pub fn transform<F: From<T>>(self) -> WithPeerId<F> {
WithPeerId(self.0, self.1.into())
}
/// Split the wrapper into [PeerId] and data tuple
pub fn split(self) -> (PeerId, T) {
(self.0, self.1)
}
/// Maps the inner value to a new value using the given function.
pub fn map<U, F: FnOnce(T) -> U>(self, op: F) -> WithPeerId<U> {
WithPeerId(self.0, op(self.1))
}
}
impl<T> WithPeerId<Option<T>> {
/// returns `None` if the inner value is `None`, otherwise returns `Some(WithPeerId<T>)`.
pub fn transpose(self) -> Option<WithPeerId<T>> {
self.1.map(|v| WithPeerId(self.0, v))
}
}
#[cfg(test)]
mod tests {
use super::*;
use secp256k1::SECP256K1;
#[test]
fn test_node_record_parse() {
let url = "enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@10.3.58.6:30303?discport=30301";
let node: AnyNode = url.parse().unwrap();
assert_eq!(node, AnyNode::NodeRecord(NodeRecord {
address: IpAddr::V4([10,3,58,6].into()),
tcp_port: 30303,
udp_port: 30301,
id: "6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0".parse().unwrap(),
}));
assert_eq!(node.to_string(), url)
}
#[test]
fn test_peer_id_parse() {
let url = "enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0";
let node: AnyNode = url.parse().unwrap();
assert_eq!(node, AnyNode::PeerId("6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0".parse().unwrap()));
assert_eq!(node.to_string(), url);
let url = "enode://";
let err = url.parse::<AnyNode>().unwrap_err();
assert_eq!(err, "invalid public key: ");
}
// <https://eips.ethereum.org/EIPS/eip-778>
#[test]
fn test_enr_parse() {
let url = "enr:-IS4QHCYrYZbAKWCBRlAy5zzaDZXJBGkcnh4MHcBFZntXNFrdvJjX04jRzjzCBOonrkTfj499SZuOh8R33Ls8RRcy5wBgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQPKY0yuDUmstAHYpMa2_oxVtw0RW_QAdpzBQA8yWM0xOIN1ZHCCdl8";
let node: AnyNode = url.parse().unwrap();
assert_eq!(
node.peer_id(),
"0xca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd31387574077f301b421bc84df7266c44e9e6d569fc56be00812904767bf5ccd1fc7f"
.parse::<PeerId>()
.unwrap()
);
assert_eq!(node.to_string(), url);
}
#[test]
fn pk2id2pk() {
let prikey = SecretKey::new(&mut secp256k1::rand::thread_rng());
let pubkey = PublicKey::from_secret_key(SECP256K1, &prikey);
assert_eq!(pubkey, id2pk(pk2id(&pubkey)).unwrap());
}
}

View File

@@ -27,7 +27,6 @@ alloy-trie = { workspace = true, features = ["serde"] }
nybbles = { workspace = true, features = ["serde", "rlp"] }
alloy-genesis.workspace = true
alloy-eips.workspace = true
enr.workspace = true
# crypto
secp256k1 = { workspace = true, features = ["global-context", "recovery", "rand"] }
@@ -43,7 +42,6 @@ itertools.workspace = true
modular-bitfield.workspace = true
once_cell.workspace = true
rayon.workspace = true
serde_with.workspace = true
serde.workspace = true
serde_json.workspace = true
sha2 = { version = "0.10.7", optional = true }

View File

@@ -33,7 +33,6 @@ mod header;
mod integer_list;
mod log;
mod net;
mod peer;
pub mod proofs;
mod prune;
mod receipt;
@@ -77,7 +76,6 @@ pub use net::{
NodeRecordParseError, GOERLI_BOOTNODES, HOLESKY_BOOTNODES, MAINNET_BOOTNODES,
SEPOLIA_BOOTNODES,
};
pub use peer::{id2pk, pk2id, AnyNode, PeerId, WithPeerId};
pub use prune::{
PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneModes, PruneProgress,
PrunePurpose, PruneSegment, PruneSegmentError, ReceiptsLogPruneConfig,

View File

@@ -16,6 +16,7 @@ workspace = true
reth-primitives.workspace = true
reth-rpc-types.workspace = true
reth-engine-primitives.workspace = true
reth-network-types.workspace = true
# misc
jsonrpsee = { workspace = true, features = ["server", "macros"] }

View File

@@ -1,5 +1,6 @@
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use reth_primitives::{AnyNode, NodeRecord};
use reth_network_types::AnyNode;
use reth_primitives::NodeRecord;
use reth_rpc_types::{admin::NodeInfo, PeerInfo};
/// Admin namespace rpc interface that gives access to several non-standard RPC methods.

View File

@@ -27,6 +27,7 @@ reth-consensus-common.workspace = true
reth-rpc-types-compat.workspace = true
revm-inspectors.workspace = true
reth-evm.workspace = true
reth-network-types.workspace = true
# eth
alloy-rlp.workspace = true

View File

@@ -3,7 +3,8 @@ use alloy_primitives::B256;
use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
use reth_network_api::{NetworkInfo, PeerKind, Peers};
use reth_primitives::{AnyNode, ChainSpec, NodeRecord};
use reth_network_types::AnyNode;
use reth_primitives::{ChainSpec, NodeRecord};
use reth_rpc_api::AdminApiServer;
use reth_rpc_types::{
admin::{EthProtocolInfo, NodeInfo, Ports, ProtocolInfo},

View File

@@ -51,6 +51,7 @@ reth-revm.workspace = true
reth-static-file.workspace = true
reth-trie = { workspace = true, features = ["test-utils"] }
reth-provider = { workspace = true, features = ["test-utils"] }
reth-network-types.workspace = true
alloy-rlp.workspace = true
itertools.workspace = true

View File

@@ -17,7 +17,8 @@
//! # use reth_downloaders::headers::reverse_headers::ReverseHeadersDownloaderBuilder;
//! # use reth_interfaces::test_utils::{TestBodiesClient, TestHeadersClient};
//! # use reth_revm::EvmProcessorFactory;
//! # use reth_primitives::{PeerId, MAINNET, B256, PruneModes};
//! # use reth_primitives::{MAINNET, B256, PruneModes};
//! # use reth_network_types::PeerId;
//! # use reth_stages::Pipeline;
//! # use reth_stages::sets::DefaultStages;
//! # use tokio::sync::watch;

View File

@@ -20,6 +20,7 @@ reth-tasks.workspace = true
revm.workspace = true
alloy-rlp.workspace = true
reth-revm = { workspace = true, optional = true }
reth-network-types.workspace = true
# async/futures
futures-util.workspace = true

View File

@@ -9,13 +9,13 @@ use crate::{
};
use futures_util::{ready, Stream};
use reth_eth_wire::HandleMempoolData;
use reth_network_types::PeerId;
use reth_primitives::{
kzg::KzgSettings, transaction::TryFromRecoveredTransactionError, AccessList, Address,
BlobTransactionSidecar, BlobTransactionValidationError, FromRecoveredPooledTransaction,
IntoRecoveredTransaction, PeerId, PooledTransactionsElement,
PooledTransactionsElementEcRecovered, SealedBlock, Transaction, TransactionSignedEcRecovered,
TryFromRecoveredTransaction, TxEip4844, TxHash, TxKind, B256, EIP1559_TX_TYPE_ID,
EIP4844_TX_TYPE_ID, U256,
IntoRecoveredTransaction, PooledTransactionsElement, PooledTransactionsElementEcRecovered,
SealedBlock, Transaction, TransactionSignedEcRecovered, TryFromRecoveredTransaction, TxEip4844,
TxHash, TxKind, B256, EIP1559_TX_TYPE_ID, EIP4844_TX_TYPE_ID, U256,
};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

View File

@@ -6,14 +6,17 @@ edition.workspace = true
license.workspace = true
[dependencies]
once_cell.workspace = true
eyre.workspace = true
reth-primitives.workspace = true
reth-network.workspace = true
reth-discv4.workspace = true
reth-eth-wire.workspace = true
reth-ecies.workspace = true
futures.workspace = true
reth-network-types.workspace = true
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] }
futures.workspace = true
tokio.workspace = true
eyre.workspace = true
once_cell.workspace = true

View File

@@ -16,8 +16,9 @@ use reth_eth_wire::{
EthMessage, EthStream, HelloMessage, P2PStream, Status, UnauthedEthStream, UnauthedP2PStream,
};
use reth_network::config::rng_secret_key;
use reth_network_types::pk2id;
use reth_primitives::{
mainnet_nodes, pk2id, Chain, Hardfork, Head, NodeRecord, MAINNET, MAINNET_GENESIS_HASH,
mainnet_nodes, Chain, Hardfork, Head, NodeRecord, MAINNET, MAINNET_GENESIS_HASH,
};
use secp256k1::{SecretKey, SECP256K1};
use tokio::net::TcpStream;