Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add eth68 to default capabilities #1475

Merged
merged 5 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/net/eth-wire/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions crates/net/eth-wire/src/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
}),
Comment on lines +102 to +104
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what has changed since this comment?

Copy link
Member

@Rjected Rjected Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The devp2p hive tests expect eth/68 in the Status, which at the time I'm not sure we knew due to other errors in the hive tests. So we need to advertise 68 now in the hello, and send an eth/68 status

port: port.unwrap_or(30303),
id,
}
Expand Down
7 changes: 3 additions & 4 deletions crates/net/eth-wire/src/types/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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");
Expand Down
19 changes: 6 additions & 13 deletions crates/net/network/src/session/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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 {
Expand Down Expand Up @@ -852,8 +845,8 @@ mod tests {
protocol_breach_request_timeout: PROTOCOL_BREACH_REQUEST_TIMEOUT,
}
}
_ => {
panic!("unexpected message")
ev => {
panic!("unexpected message {ev:?}")
}
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1081,7 +1074,7 @@ mod tests {
let message = builder.active_session_rx.next().await.unwrap();
match message {
ActiveSessionMessage::ProtocolBreach { .. } => {}
_ => unreachable!(),
ev => unreachable!("{ev:?}"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/tests/it/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}")
Expand Down