Skip to content

Commit

Permalink
chore(deps): bump enr, discv5, secp256k1; remove ethers from dev-depe…
Browse files Browse the repository at this point in the history
…ndencies
  • Loading branch information
DaniPopes committed Apr 4, 2024
1 parent 4a8d2f4 commit e28b4a3
Show file tree
Hide file tree
Showing 14 changed files with 482 additions and 424 deletions.
593 changes: 373 additions & 220 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,10 @@ alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", rev = "7e39
alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }

# TODO: Remove
ethers-core = { version = "2.0.14", default-features = false }
ethers-providers = { version = "2.0.14", default-features = false }

# misc
aquamarine = "0.5"
bytes = "1.5"
Expand Down Expand Up @@ -320,9 +318,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.4.1"
igd-next = "0.14.3"

# rpc
Expand All @@ -331,11 +330,11 @@ jsonrpsee-core = "0.20"
jsonrpsee-types = "0.20"

# 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"] }
enr = { version = "0.11", default-features = false, features = ["k256"] }

# for eip-4844
c-kzg = "1.0.0"
Expand All @@ -355,3 +354,7 @@ proptest-derive = "0.4"
serial_test = "3"
similar-asserts = "1.5.0"
test-fuzz = "5"

[patch.crates-io]
discv5 = { git = "https://github.com/sigp/discv5" }
enr = { git = "https://github.com/danipopes/enr", branch = "advance-decode-buffer" }
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
1 change: 0 additions & 1 deletion crates/net/discv4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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
# 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 e28b4a3

Please sign in to comment.