Skip to content

Commit

Permalink
chore(deps): bump enr, discv5, secp256k1
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Apr 9, 2024
1 parent e43b2f4 commit e9bbbb6
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 254 deletions.
76 changes: 28 additions & 48 deletions Cargo.lock

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

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,10 @@ futures-util = "0.3.25"
hyper = "0.14.25"
tower = "0.4"
tower-http = "0.4"
reqwest = "0.12"

# p2p
discv5 = { git = "https://github.com/sigp/discv5", rev = "04ac004" }
discv5 = "0.5.0"
igd-next = "0.14.3"

# rpc
Expand All @@ -336,11 +337,12 @@ jsonrpsee-core = "0.22"
jsonrpsee-types = "0.22"

# crypto
secp256k1 = { version = "0.27.0", default-features = false, features = [
secp256k1 = { version = "0.28", default-features = false, features = [
"global-context",
"recovery",
] }
enr = { version = "=0.10.0", default-features = false, features = ["k256"] }
# TODO: Remove `k256` feature: https://github.com/sigp/enr/pull/74
enr = { version = "0.11.1", default-features = false, features = ["k256", "rust-secp256k1"] }

# for eip-4844
c-kzg = "1.0.0"
Expand Down
14 changes: 7 additions & 7 deletions crates/interfaces/src/test_utils/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use reth_primitives::{
SealedHeader, StorageEntry, Transaction, TransactionKind, TransactionSigned, TxLegacy, B256,
U256,
};
use secp256k1::{KeyPair, Secp256k1};
use secp256k1::{Keypair, Secp256k1};
use std::{
cmp::{max, min},
collections::{hash_map::DefaultHasher, BTreeMap},
Expand Down Expand Up @@ -92,22 +92,22 @@ pub fn random_tx<R: Rng>(rng: &mut R) -> Transaction {
/// - There is no guarantee that the nonce is not used twice for the same account
pub fn random_signed_tx<R: Rng>(rng: &mut R) -> TransactionSigned {
let secp = Secp256k1::new();
let key_pair = KeyPair::new(&secp, rng);
let key_pair = Keypair::new(&secp, rng);
let tx = random_tx(rng);
sign_tx_with_key_pair(key_pair, tx)
}

/// Signs the [Transaction] with the given key pair.
pub fn sign_tx_with_key_pair(key_pair: KeyPair, tx: Transaction) -> TransactionSigned {
pub fn sign_tx_with_key_pair(key_pair: Keypair, tx: Transaction) -> TransactionSigned {
let signature =
sign_message(B256::from_slice(&key_pair.secret_bytes()[..]), tx.signature_hash()).unwrap();
TransactionSigned::from_transaction_and_signature(tx, signature)
}

/// Generates a set of [KeyPair]s based on the desired count.
pub fn generate_keys<R: Rng>(rng: &mut R, count: usize) -> Vec<KeyPair> {
/// Generates a set of [Keypair]s based on the desired count.
pub fn generate_keys<R: Rng>(rng: &mut R, count: usize) -> Vec<Keypair> {
let secp = Secp256k1::new();
(0..count).map(|_| KeyPair::new(&secp, rng)).collect()
(0..count).map(|_| Keypair::new(&secp, rng)).collect()
}

/// Generate a random block filled with signed transactions (generated using
Expand Down Expand Up @@ -405,7 +405,7 @@ mod tests {
let signature_hash = tx.signature_hash();

for _ in 0..100 {
let key_pair = KeyPair::new(&secp, &mut rand::thread_rng());
let key_pair = Keypair::new(&secp, &mut rand::thread_rng());

let signature =
sign_message(B256::from_slice(&key_pair.secret_bytes()[..]), signature_hash)
Expand Down
3 changes: 1 addition & 2 deletions crates/net/discv4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ reth-net-nat.workspace = true
alloy-rlp = { workspace = true, features = ["derive"] }
discv5.workspace = true
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery", "serde"] }
enr = { workspace = true, default-features = false, features = ["rust-secp256k1"] }
rlp = "0.5" # needed for enr
enr.workspace = true
# async/futures
tokio = { workspace = true, features = ["io-util", "net", "time"] }
tokio-stream.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/net/discv4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use discv5::{
};
use enr::Enr;
use parking_lot::Mutex;
use proto::{EnrRequest, EnrResponse, EnrWrapper};
use proto::{EnrRequest, EnrResponse};
use reth_primitives::{bytes::Bytes, hex, ForkId, PeerId, B256};
use secp256k1::SecretKey;
use std::{
Expand Down Expand Up @@ -1279,7 +1279,7 @@ impl Discv4Service {
self.send_packet(
Message::EnrResponse(EnrResponse {
request_hash,
enr: EnrWrapper::new(self.local_eip_868_enr.clone()),
enr: self.local_eip_868_enr.clone(),
}),
remote_addr,
);
Expand Down
Loading

0 comments on commit e9bbbb6

Please sign in to comment.