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

Change rlp to alloy-rlp #212

Merged
merged 33 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3251638
alloy-rlp encode decode
armaganyildirak Sep 15, 2023
d1ee3ac
fmt
armaganyildirak Sep 15, 2023
33b7dae
remove unused dependency
armaganyildirak Sep 15, 2023
ed9a5ba
working on tests
armaganyildirak Sep 18, 2023
edb5707
fmt
armaganyildirak Sep 18, 2023
68eb282
clippy
armaganyildirak Sep 18, 2023
e14790a
improve encode decode
armaganyildirak Sep 21, 2023
a331c5b
improve encode decode
armaganyildirak Sep 25, 2023
cf247bd
change enr version to my latest commit
armaganyildirak Sep 25, 2023
85ea39b
update rpc Request encode
armaganyildirak Sep 27, 2023
c92175e
reject the extra bytes
armaganyildirak Sep 28, 2023
c402e1c
fix couple problems after run fuzzers
armaganyildirak Sep 29, 2023
d1fe67d
change alloy_rlp and enr version
armaganyildirak Oct 9, 2023
ff0c21f
clippy
armaganyildirak Oct 12, 2023
cc5ef2c
fix max enr size issue
armaganyildirak Oct 12, 2023
2f00024
Merge branch 'master' into alloy-rlp
armaganyildirak Oct 20, 2023
f0fc832
update enr create with latest commits
armaganyildirak Oct 20, 2023
6675a89
fix merge confilicts
armaganyildirak Oct 20, 2023
785e599
fmt
armaganyildirak Oct 20, 2023
9079111
fix merge confilicts
armaganyildirak Oct 23, 2023
cb7a0f0
fmt
armaganyildirak Oct 23, 2023
292d07a
fix merge conflicts
armaganyildirak Nov 6, 2023
7d24962
update enr version
armaganyildirak Nov 29, 2023
c344f54
check payload size for preventing crashes
armaganyildirak Nov 29, 2023
7d975fc
fmt
armaganyildirak Nov 29, 2023
c767adf
update enr version
armaganyildirak Nov 30, 2023
957e382
fix merge conflicts
armaganyildirak Dec 1, 2023
21caf58
Merge branch 'master' into alloy-rlp
armaganyildirak Dec 11, 2023
f86b64a
Merge branch 'master' into alloy-rlp
armaganyildirak Dec 13, 2023
9b49325
Merge branch 'master' into alloy-rlp
armaganyildirak Mar 15, 2024
9110d4e
Change the enr version
armaganyildirak Mar 15, 2024
9914904
Change the alloy-rlp version
armaganyildirak Mar 15, 2024
dece56b
change enr version 10.1 to 11.0
armaganyildirak Mar 18, 2024
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ categories = ["network-programming", "asynchronous"]
exclude = [".gitignore", ".github/*"]

[dependencies]
enr = { version = "0.10", features = ["k256", "ed25519"] }
enr = { version = "0.11.0", features = ["k256", "ed25519"] }
tokio = { version = "1", features = ["net", "sync", "macros", "rt"] }
libp2p = { version = "0.53", features = ["ed25519", "secp256k1"], optional = true }
zeroize = { version = "1", features = ["zeroize_derive"] }
futures = "0.3"
uint = { version = "0.9", default-features = false }
rlp = "0.5"
alloy-rlp = { version = "0.3.4", default-features = true }
# This version must be kept up to date do it uses the same dependencies as ENR
hkdf = "0.12"
hex = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/request_enr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use discv5::ConfigBuilder;
#[cfg(feature = "libp2p")]
use discv5::ListenConfig;
#[cfg(feature = "libp2p")]
use discv5::{enr, enr::CombinedKey, Discv5};
use discv5::{enr::CombinedKey, Discv5};
#[cfg(feature = "libp2p")]
use std::net::Ipv4Addr;

Expand Down
4 changes: 2 additions & 2 deletions src/discv5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
service::{QueryKind, Service, ServiceRequest, TalkRequest},
Config, DefaultProtocolId, Enr, IpMode,
};
use enr::{CombinedKey, EnrError, EnrKey, NodeId};
use enr::{CombinedKey, EnrKey, Error as EnrError, NodeId};
use parking_lot::RwLock;
use std::{
future::Future,
Expand Down Expand Up @@ -433,7 +433,7 @@ impl<P: ProtocolIdentity> Discv5<P> {
}

/// Allows application layer to insert an arbitrary field into the local ENR.
pub fn enr_insert<T: rlp::Encodable>(
pub fn enr_insert<T: alloy_rlp::Encodable>(
&self,
key: &str,
value: &T,
Expand Down
10 changes: 6 additions & 4 deletions src/discv5/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![cfg(test)]

use crate::{socket::ListenConfig, Discv5, *};
use alloy_rlp::bytes::Bytes;
use enr::{k256, CombinedKey, Enr, EnrKey, NodeId};
use rand_core::{RngCore, SeedableRng};
use std::{
Expand All @@ -14,7 +15,7 @@ fn init() {
.try_init();
}

fn update_enr<T: rlp::Encodable>(discv5: &mut Discv5, key: &str, value: &T) -> bool {
fn update_enr<T: alloy_rlp::Encodable>(discv5: &mut Discv5, key: &str, value: &T) -> bool {
discv5.enr_insert(key, value).is_ok()
}

Expand Down Expand Up @@ -675,8 +676,9 @@ async fn test_predicate_search() {

// Update `num_nodes` with the required attnet value
let num_nodes = total_nodes / 2;
let required_attnet_value = vec![1, 0, 0, 0];
let unwanted_attnet_value = vec![0, 0, 0, 0];

let required_attnet_value = Bytes::copy_from_slice(&[1, 0, 0, 0]);
let unwanted_attnet_value = Bytes::copy_from_slice(&[0, 0, 0, 0]);
println!("Bootstrap node: {}", bootstrap_node.local_enr().node_id());
println!("Target node: {}", target_node.local_enr().node_id());

Expand All @@ -703,7 +705,7 @@ async fn test_predicate_search() {
// Predicate function for filtering enrs
let predicate = move |enr: &Enr<CombinedKey>| {
if let Some(v) = enr.get("attnets") {
v == required_attnet_value.as_slice()
v == required_attnet_value.to_vec().as_slice()
} else {
false
}
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{handler::Challenge, node_info::NonContactable};
use rlp::DecoderError;
use alloy_rlp::Error as DecoderError;
use std::fmt;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
//! A simple example of creating this service is as follows:
//!
//! ```rust
//! use discv5::{enr, enr::{CombinedKey, NodeId}, TokioExecutor, Discv5, ConfigBuilder};
//! use discv5::{enr, enr::{CombinedKey, Enr, NodeId}, TokioExecutor, Discv5, ConfigBuilder};
//! use discv5::socket::ListenConfig;
//! use std::net::{Ipv4Addr, SocketAddr};
//!
Expand Down
5 changes: 3 additions & 2 deletions src/packet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use aes::{
cipher::{generic_array::GenericArray, NewCipher, StreamCipher},
Aes128Ctr,
};
use alloy_rlp::Decodable;
use enr::NodeId;
use rand::Rng;
use std::convert::TryInto;
Expand Down Expand Up @@ -173,7 +174,7 @@ impl PacketKind {
} => {
let sig_size = id_nonce_sig.len();
let pubkey_size = ephem_pubkey.len();
let node_record = enr_record.as_ref().map(rlp::encode);
let node_record = enr_record.as_ref().map(alloy_rlp::encode);
let expected_len = 34
+ sig_size
+ pubkey_size
Expand Down Expand Up @@ -259,7 +260,7 @@ impl PacketKind {

let enr_record = if remaining_data.len() > total_size {
Some(
rlp::decode::<Enr>(&remaining_data[total_size..])
<Enr>::decode(&mut &remaining_data[total_size..])
.map_err(PacketError::InvalidEnr)?,
)
} else {
Expand Down
Loading
Loading