chore: add eth68 to default capabilities (#1475)

This commit is contained in:
Matthias Seitz
2023-02-21 15:26:09 +01:00
committed by GitHub
parent 93b1a7f49a
commit 1d2bb1f11d
5 changed files with 14 additions and 21 deletions

View File

@ -98,7 +98,7 @@ impl HelloBuilder {
protocol_version: ProtocolVersion::V5,
// TODO: proper client versioning
client_version: "Ethereum/1.0.0".to_string(),
capabilities: vec![EthVersion::Eth67.into()],
capabilities: vec![EthVersion::Eth68.into()],
// TODO: default port config
port: 30303,
id: pubkey,

View File

@ -99,8 +99,9 @@ impl HelloMessageBuilder {
HelloMessage {
protocol_version: protocol_version.unwrap_or_default(),
client_version: client_version.unwrap_or_else(|| DEFAULT_CLIENT_VERSION.to_string()),
capabilities: capabilities
.unwrap_or_else(|| vec![EthVersion::Eth67.into(), EthVersion::Eth66.into()]),
capabilities: capabilities.unwrap_or_else(|| {
vec![EthVersion::Eth68.into(), EthVersion::Eth67.into(), EthVersion::Eth66.into()]
}),
port: port.unwrap_or(30303),
id,
}

View File

@ -50,7 +50,7 @@ impl From<Genesis> for Status {
let chainspec = ChainSpec::from(genesis);
Status {
version: EthVersion::Eth67 as u8,
version: EthVersion::Eth68 as u8,
chain: Chain::Id(chain),
total_difficulty,
blockhash: chainspec.genesis_hash(),
@ -133,7 +133,7 @@ impl Default for Status {
fn default() -> Self {
let mainnet_genesis = MAINNET.genesis_hash();
Status {
version: EthVersion::Eth67 as u8,
version: EthVersion::Eth68 as u8,
chain: Chain::Named(ethers_core::types::Chain::Mainnet),
total_difficulty: U256::from(17_179_869_184u64),
blockhash: mainnet_genesis,
@ -147,6 +147,7 @@ impl Default for Status {
#[cfg(test)]
mod tests {
use crate::types::{EthVersion, Status};
use ethers_core::types::Chain as NamedChain;
use hex_literal::hex;
use rand::Rng;
@ -156,8 +157,6 @@ mod tests {
use reth_rlp::{Decodable, Encodable};
use std::str::FromStr;
use crate::types::{EthVersion, Status};
#[test]
fn encode_eth_status_message() {
let expected = hex!("f85643018a07aac59dabcdd74bc567a0feb27336ca7923f8fab3bd617fcb6e75841538f71c1bcfc267d7838489d9e13da0d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3c684b715077d80");

View File

@ -719,8 +719,7 @@ mod tests {
};
use reth_ecies::util::pk2id;
use reth_eth_wire::{
EthVersion, GetBlockBodies, HelloMessage, ProtocolVersion, Status, StatusBuilder,
UnauthedEthStream, UnauthedP2PStream,
GetBlockBodies, HelloMessage, Status, StatusBuilder, UnauthedEthStream, UnauthedP2PStream,
};
use reth_net_common::bandwidth_meter::BandwidthMeter;
use reth_primitives::{ForkFilter, Hardfork, MAINNET};
@ -730,13 +729,7 @@ mod tests {
/// Returns a testing `HelloMessage` and new secretkey
fn eth_hello(server_key: &SecretKey) -> HelloMessage {
HelloMessage {
protocol_version: ProtocolVersion::V5,
client_version: "reth/1.0.0".to_string(),
capabilities: vec![EthVersion::Eth67.into()],
port: 30303,
id: pk2id(&server_key.public_key(SECP256K1)),
}
HelloMessage::builder(pk2id(&server_key.public_key(SECP256K1))).build()
}
struct SessionBuilder {
@ -852,8 +845,8 @@ mod tests {
protocol_breach_request_timeout: PROTOCOL_BREACH_REQUEST_TIMEOUT,
}
}
_ => {
panic!("unexpected message")
ev => {
panic!("unexpected message {ev:?}")
}
}
}
@ -1048,7 +1041,7 @@ mod tests {
let fut = builder.with_client_stream(local_addr, move |mut client_stream| async move {
client_stream
.send(EthMessage::NewPooledTransactionHashes66(Vec::new().into()))
.send(EthMessage::NewPooledTransactionHashes68(Default::default()))
.await
.unwrap();
let _ = tokio::time::timeout(Duration::from_secs(100), client_stream.next()).await;
@ -1081,7 +1074,7 @@ mod tests {
let message = builder.active_session_rx.next().await.unwrap();
match message {
ActiveSessionMessage::ProtocolBreach { .. } => {}
_ => unreachable!(),
ev => unreachable!("{ev:?}"),
}
}

View File

@ -33,7 +33,7 @@ async fn test_session_established_with_highest_version() {
}
NetworkEvent::SessionEstablished { peer_id, status, .. } => {
assert_eq!(handle1.peer_id(), &peer_id);
assert_eq!(status.version, EthVersion::Eth67 as u8);
assert_eq!(status.version, EthVersion::Eth68 as u8);
}
ev => {
panic!("unexpected event {ev:?}")