Skip to content

chore: bump discv5 to 0.9 includes NAT fixes + other improvements #1639

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

Merged
merged 1 commit into from
Jan 17, 2025
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
127 changes: 60 additions & 67 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ chrono = "0.4.38"
clap = { version = "4.2.1", features = ["derive"] }
delay_map = "0.4.0"
directories = "3.0"
discv5 = { version = "0.4.1", features = ["serde"] }
discv5 = { git = "https://github.com/kolbyml/discv5", rev = "7dcd74031aa98c220c2984bbc2274c414b6f709f", features = ["serde"] }
env_logger = "0.9.0"
eth_trie = "0.5.0"
ethereum_hashing = "0.7.0"
Expand Down
4 changes: 2 additions & 2 deletions bin/portal-bridge/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ impl FromStr for ClientType {
impl From<&Enr> for ClientType {
fn from(enr: &Enr) -> Self {
let client_id = enr
.get(ENR_PORTAL_CLIENT_KEY)
.and_then(|v| String::from_utf8(v.to_vec()).ok());
.get_decodable::<String>(ENR_PORTAL_CLIENT_KEY)
.and_then(|v| v.ok());
if let Some(client_id) = client_id {
if client_id.starts_with("t") {
ClientType::Trin
Expand Down
1 change: 0 additions & 1 deletion crates/ethportal-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ lazy_static.workspace = true
once_cell = "1.17"
quickcheck.workspace = true
rand.workspace = true
rlp = "0.5.0"
rs_merkle = "1.4.2"
secp256k1 = { version = "0.29.0", features = ["global-context", "recovery", "rand"] }
serde = { workspace = true, features = ["rc"] }
Expand Down
12 changes: 8 additions & 4 deletions crates/ethportal-api/src/types/enr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ use std::{
str::FromStr,
};

use alloy_rlp::{Encodable, RlpDecodableWrapper, RlpEncodableWrapper};
use discv5::enr::{CombinedKey, Enr as Discv5Enr};
use rand::Rng;
use rlp::Encodable;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use ssz::DecodeError;
use validator::ValidationError;

pub type Enr = Discv5Enr<CombinedKey>;

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[derive(
Debug, PartialEq, Clone, Serialize, Deserialize, RlpEncodableWrapper, RlpDecodableWrapper,
)]
pub struct SszEnr(pub Enr);

impl SszEnr {
Expand Down Expand Up @@ -76,11 +78,13 @@ impl ssz::Encode for SszEnr {
}

fn ssz_append(&self, buf: &mut Vec<u8>) {
buf.append(&mut self.rlp_bytes().to_vec());
self.encode(buf);
}

fn ssz_bytes_len(&self) -> usize {
self.rlp_bytes().to_vec().ssz_bytes_len()
let mut buf = vec![];
self.encode(&mut buf);
buf.ssz_bytes_len()
}
}

Expand Down
Loading