mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore(deps): rm discv4 dep from eth-wire (#9344)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -7132,7 +7132,6 @@ dependencies = [
|
|||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
"reth-codecs",
|
"reth-codecs",
|
||||||
"reth-discv4",
|
|
||||||
"reth-ecies",
|
"reth-ecies",
|
||||||
"reth-eth-wire-types",
|
"reth-eth-wire-types",
|
||||||
"reth-metrics",
|
"reth-metrics",
|
||||||
|
|||||||
@ -33,7 +33,7 @@ alloy-rlp.workspace = true
|
|||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
futures-util.workspace = true
|
futures-util.workspace = true
|
||||||
pin-project.workspace = true
|
pin-project.workspace = true
|
||||||
tokio = { workspace = true, features = ["sync", "fs"] }
|
tokio = { workspace = true, features = ["sync", "fs", "io-util"] }
|
||||||
tokio-stream.workspace = true
|
tokio-stream.workspace = true
|
||||||
tokio-util = { workspace = true, features = ["codec"] }
|
tokio-util = { workspace = true, features = ["codec"] }
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,6 @@ reth-codecs.workspace = true
|
|||||||
reth-primitives.workspace = true
|
reth-primitives.workspace = true
|
||||||
reth-ecies.workspace = true
|
reth-ecies.workspace = true
|
||||||
alloy-rlp = { workspace = true, features = ["derive"] }
|
alloy-rlp = { workspace = true, features = ["derive"] }
|
||||||
reth-discv4.workspace = true
|
|
||||||
reth-eth-wire-types.workspace = true
|
reth-eth-wire-types.workspace = true
|
||||||
reth-network-peers.workspace = true
|
reth-network-peers.workspace = true
|
||||||
|
|
||||||
@ -29,7 +28,7 @@ bytes.workspace = true
|
|||||||
derive_more.workspace = true
|
derive_more.workspace = true
|
||||||
thiserror.workspace = true
|
thiserror.workspace = true
|
||||||
serde = { workspace = true, optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
tokio = { workspace = true, features = ["net", "sync", "time"] }
|
tokio = { workspace = true, features = ["macros", "net", "sync", "time"] }
|
||||||
tokio-util = { workspace = true, features = ["io", "codec"] }
|
tokio-util = { workspace = true, features = ["io", "codec"] }
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
tokio-stream.workspace = true
|
tokio-stream.workspace = true
|
||||||
|
|||||||
@ -348,12 +348,12 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
broadcast::BlockHashNumber,
|
broadcast::BlockHashNumber,
|
||||||
errors::{EthHandshakeError, EthStreamError},
|
errors::{EthHandshakeError, EthStreamError},
|
||||||
|
hello::DEFAULT_TCP_PORT,
|
||||||
p2pstream::{ProtocolVersion, UnauthedP2PStream},
|
p2pstream::{ProtocolVersion, UnauthedP2PStream},
|
||||||
EthMessage, EthStream, EthVersion, HelloMessageWithProtocols, PassthroughCodec, Status,
|
EthMessage, EthStream, EthVersion, HelloMessageWithProtocols, PassthroughCodec, Status,
|
||||||
};
|
};
|
||||||
use futures::{SinkExt, StreamExt};
|
use futures::{SinkExt, StreamExt};
|
||||||
use reth_chainspec::NamedChain;
|
use reth_chainspec::NamedChain;
|
||||||
use reth_discv4::DEFAULT_DISCOVERY_PORT;
|
|
||||||
use reth_ecies::stream::ECIESStream;
|
use reth_ecies::stream::ECIESStream;
|
||||||
use reth_network_peers::pk2id;
|
use reth_network_peers::pk2id;
|
||||||
use reth_primitives::{ForkFilter, Head, B256, U256};
|
use reth_primitives::{ForkFilter, Head, B256, U256};
|
||||||
@ -624,7 +624,7 @@ mod tests {
|
|||||||
protocol_version: ProtocolVersion::V5,
|
protocol_version: ProtocolVersion::V5,
|
||||||
client_version: "bitcoind/1.0.0".to_string(),
|
client_version: "bitcoind/1.0.0".to_string(),
|
||||||
protocols: vec![EthVersion::Eth67.into()],
|
protocols: vec![EthVersion::Eth67.into()],
|
||||||
port: DEFAULT_DISCOVERY_PORT,
|
port: DEFAULT_TCP_PORT,
|
||||||
id: pk2id(&server_key.public_key(SECP256K1)),
|
id: pk2id(&server_key.public_key(SECP256K1)),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -652,7 +652,7 @@ mod tests {
|
|||||||
protocol_version: ProtocolVersion::V5,
|
protocol_version: ProtocolVersion::V5,
|
||||||
client_version: "bitcoind/1.0.0".to_string(),
|
client_version: "bitcoind/1.0.0".to_string(),
|
||||||
protocols: vec![EthVersion::Eth67.into()],
|
protocols: vec![EthVersion::Eth67.into()],
|
||||||
port: DEFAULT_DISCOVERY_PORT,
|
port: DEFAULT_TCP_PORT,
|
||||||
id: pk2id(&client_key.public_key(SECP256K1)),
|
id: pk2id(&client_key.public_key(SECP256K1)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
use crate::{capability::Capability, EthVersion, ProtocolVersion};
|
use crate::{capability::Capability, EthVersion, ProtocolVersion};
|
||||||
use alloy_rlp::{RlpDecodable, RlpEncodable};
|
use alloy_rlp::{RlpDecodable, RlpEncodable};
|
||||||
use reth_codecs::derive_arbitrary;
|
use reth_codecs::derive_arbitrary;
|
||||||
use reth_discv4::DEFAULT_DISCOVERY_PORT;
|
|
||||||
use reth_network_peers::PeerId;
|
use reth_network_peers::PeerId;
|
||||||
use reth_primitives::constants::RETH_CLIENT_VERSION;
|
use reth_primitives::constants::RETH_CLIENT_VERSION;
|
||||||
|
|
||||||
|
/// The default tcp port for p2p.
|
||||||
|
///
|
||||||
|
/// Note: this is the same as discovery port: `DEFAULT_DISCOVERY_PORT`
|
||||||
|
pub(crate) const DEFAULT_TCP_PORT: u16 = 30303;
|
||||||
|
|
||||||
use crate::protocol::Protocol;
|
use crate::protocol::Protocol;
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -29,6 +33,8 @@ pub struct HelloMessageWithProtocols {
|
|||||||
/// The list of supported capabilities and their versions.
|
/// The list of supported capabilities and their versions.
|
||||||
pub protocols: Vec<Protocol>,
|
pub protocols: Vec<Protocol>,
|
||||||
/// The port that the client is listening on, zero indicates the client is not listening.
|
/// The port that the client is listening on, zero indicates the client is not listening.
|
||||||
|
///
|
||||||
|
/// By default this is `30303` which is the same as the default discovery port.
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
/// The secp256k1 public key corresponding to the node's private key.
|
/// The secp256k1 public key corresponding to the node's private key.
|
||||||
pub id: PeerId,
|
pub id: PeerId,
|
||||||
@ -200,7 +206,7 @@ impl HelloMessageBuilder {
|
|||||||
protocols: protocols.unwrap_or_else(|| {
|
protocols: protocols.unwrap_or_else(|| {
|
||||||
vec![EthVersion::Eth68.into(), EthVersion::Eth67.into(), EthVersion::Eth66.into()]
|
vec![EthVersion::Eth68.into(), EthVersion::Eth67.into(), EthVersion::Eth66.into()]
|
||||||
}),
|
}),
|
||||||
port: port.unwrap_or(DEFAULT_DISCOVERY_PORT),
|
port: port.unwrap_or(DEFAULT_TCP_PORT),
|
||||||
id,
|
id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,14 +214,12 @@ impl HelloMessageBuilder {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use alloy_rlp::{Decodable, Encodable, EMPTY_STRING_CODE};
|
|
||||||
use reth_discv4::DEFAULT_DISCOVERY_PORT;
|
|
||||||
use reth_network_peers::pk2id;
|
|
||||||
use secp256k1::{SecretKey, SECP256K1};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
capability::Capability, p2pstream::P2PMessage, EthVersion, HelloMessage, ProtocolVersion,
|
capability::Capability, p2pstream::P2PMessage, EthVersion, HelloMessage, ProtocolVersion,
|
||||||
};
|
};
|
||||||
|
use alloy_rlp::{Decodable, Encodable, EMPTY_STRING_CODE};
|
||||||
|
use reth_network_peers::pk2id;
|
||||||
|
use secp256k1::{SecretKey, SECP256K1};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hello_encoding_round_trip() {
|
fn test_hello_encoding_round_trip() {
|
||||||
@ -225,7 +229,7 @@ mod tests {
|
|||||||
protocol_version: ProtocolVersion::V5,
|
protocol_version: ProtocolVersion::V5,
|
||||||
client_version: "reth/0.1.0".to_string(),
|
client_version: "reth/0.1.0".to_string(),
|
||||||
capabilities: vec![Capability::new_static("eth", EthVersion::Eth67 as usize)],
|
capabilities: vec![Capability::new_static("eth", EthVersion::Eth67 as usize)],
|
||||||
port: DEFAULT_DISCOVERY_PORT,
|
port: 30303,
|
||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -245,7 +249,7 @@ mod tests {
|
|||||||
protocol_version: ProtocolVersion::V5,
|
protocol_version: ProtocolVersion::V5,
|
||||||
client_version: "reth/0.1.0".to_string(),
|
client_version: "reth/0.1.0".to_string(),
|
||||||
capabilities: vec![Capability::new_static("eth", EthVersion::Eth67 as usize)],
|
capabilities: vec![Capability::new_static("eth", EthVersion::Eth67 as usize)],
|
||||||
port: DEFAULT_DISCOVERY_PORT,
|
port: 30303,
|
||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -264,7 +268,7 @@ mod tests {
|
|||||||
protocol_version: ProtocolVersion::V5,
|
protocol_version: ProtocolVersion::V5,
|
||||||
client_version: "reth/0.1.0".to_string(),
|
client_version: "reth/0.1.0".to_string(),
|
||||||
capabilities: vec![Capability::new_static("eth", EthVersion::Eth67 as usize)],
|
capabilities: vec![Capability::new_static("eth", EthVersion::Eth67 as usize)],
|
||||||
port: DEFAULT_DISCOVERY_PORT,
|
port: 30303,
|
||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
//! Utilities for testing p2p protocol.
|
//! Utilities for testing p2p protocol.
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
EthVersion, HelloMessageWithProtocols, P2PStream, ProtocolVersion, Status, UnauthedP2PStream,
|
hello::DEFAULT_TCP_PORT, EthVersion, HelloMessageWithProtocols, P2PStream, ProtocolVersion,
|
||||||
|
Status, UnauthedP2PStream,
|
||||||
};
|
};
|
||||||
use reth_chainspec::Chain;
|
use reth_chainspec::Chain;
|
||||||
use reth_discv4::DEFAULT_DISCOVERY_PORT;
|
|
||||||
use reth_network_peers::pk2id;
|
use reth_network_peers::pk2id;
|
||||||
use reth_primitives::{ForkFilter, Head, B256, U256};
|
use reth_primitives::{ForkFilter, Head, B256, U256};
|
||||||
use secp256k1::{SecretKey, SECP256K1};
|
use secp256k1::{SecretKey, SECP256K1};
|
||||||
@ -22,7 +22,7 @@ pub fn eth_hello() -> (HelloMessageWithProtocols, SecretKey) {
|
|||||||
protocol_version: ProtocolVersion::V5,
|
protocol_version: ProtocolVersion::V5,
|
||||||
client_version: "eth/1.0.0".to_string(),
|
client_version: "eth/1.0.0".to_string(),
|
||||||
protocols,
|
protocols,
|
||||||
port: DEFAULT_DISCOVERY_PORT,
|
port: DEFAULT_TCP_PORT,
|
||||||
id: pk2id(&server_key.public_key(SECP256K1)),
|
id: pk2id(&server_key.public_key(SECP256K1)),
|
||||||
};
|
};
|
||||||
(hello, server_key)
|
(hello, server_key)
|
||||||
|
|||||||
Reference in New Issue
Block a user