From 1cdd8cad65bed076fce8e13beefc037fe9b7358d Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 14 Oct 2024 09:56:08 +1100 Subject: [PATCH 1/3] Simplify hashing in shuffling --- consensus/swap_or_not_shuffle/src/shuffle_list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/swap_or_not_shuffle/src/shuffle_list.rs b/consensus/swap_or_not_shuffle/src/shuffle_list.rs index b49a26cc373..3e93974fe0f 100644 --- a/consensus/swap_or_not_shuffle/src/shuffle_list.rs +++ b/consensus/swap_or_not_shuffle/src/shuffle_list.rs @@ -45,7 +45,7 @@ impl Buf { /// Hash the entire buffer. fn hash(&self) -> Hash256 { - Hash256::from_slice(&hash_fixed(&self.0)) + Hash256::from(hash_fixed(&self.0)) } } From 5b25fe83b1be0f782b902b3a1e0d94ff64a28d71 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 14 Oct 2024 10:22:20 +1100 Subject: [PATCH 2/3] Fix benchmark deps --- Cargo.toml | 2 +- consensus/swap_or_not_shuffle/Cargo.toml | 1 - consensus/types/Cargo.toml | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 125231ad20e..94ac8e13ff1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,7 +95,7 @@ resolver = "2" edition = "2021" [workspace.dependencies] -alloy-primitives = "0.8" +alloy-primitives = { version = "0.8", features = ["rlp", "getrandom"] } alloy-rlp = "0.3.4" alloy-consensus = "0.3.0" anyhow = "1" diff --git a/consensus/swap_or_not_shuffle/Cargo.toml b/consensus/swap_or_not_shuffle/Cargo.toml index aff0225edd4..dac83e7553f 100644 --- a/consensus/swap_or_not_shuffle/Cargo.toml +++ b/consensus/swap_or_not_shuffle/Cargo.toml @@ -18,4 +18,3 @@ fixed_bytes = { workspace = true } [features] arbitrary = ["alloy-primitives/arbitrary"] -getrandom = ["alloy-primitives/getrandom"] diff --git a/consensus/types/Cargo.toml b/consensus/types/Cargo.toml index c1559a407cf..21a15fc5174 100644 --- a/consensus/types/Cargo.toml +++ b/consensus/types/Cargo.toml @@ -9,7 +9,7 @@ name = "benches" harness = false [dependencies] -alloy-primitives = { workspace = true, features = ["rlp", "getrandom"] } +alloy-primitives = { workspace = true } merkle_proof = { workspace = true } bls = { workspace = true, features = ["arbitrary"] } kzg = { workspace = true } From df2fb24bf4e23a61dd8f344afa6f6d9fd094fc7e Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 14 Oct 2024 10:30:55 +1100 Subject: [PATCH 3/3] Check benchmarks when linting --- Makefile | 2 +- consensus/types/benches/benches.rs | 2 +- crypto/kzg/benches/benchmark.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e6420a4c984..32665d43aed 100644 --- a/Makefile +++ b/Makefile @@ -204,7 +204,7 @@ test-full: cargo-fmt test-release test-debug test-ef test-exec-engine # Lints the code for bad style and potentially unsafe arithmetic using Clippy. # Clippy lints are opt-in per-crate for now. By default, everything is allowed except for performance and correctness lints. lint: - cargo clippy --workspace --tests $(EXTRA_CLIPPY_OPTS) --features "$(TEST_FEATURES)" -- \ + cargo clippy --workspace --benches --tests $(EXTRA_CLIPPY_OPTS) --features "$(TEST_FEATURES)" -- \ -D clippy::fn_to_numeric_cast_any \ -D clippy::manual_let_else \ -D clippy::large_stack_frames \ diff --git a/consensus/types/benches/benches.rs b/consensus/types/benches/benches.rs index effc6a21068..0c8bf36c813 100644 --- a/consensus/types/benches/benches.rs +++ b/consensus/types/benches/benches.rs @@ -78,7 +78,7 @@ fn all_benches(c: &mut Criterion) { || (bytes.clone(), spec.clone()), |(bytes, spec)| { let state: BeaconState = - BeaconState::from_ssz_bytes(&bytes, &spec).expect("should decode"); + BeaconState::from_ssz_bytes(bytes, spec).expect("should decode"); black_box(state) }, BatchSize::SmallInput, diff --git a/crypto/kzg/benches/benchmark.rs b/crypto/kzg/benches/benchmark.rs index 50f5f4e7795..234e624698e 100644 --- a/crypto/kzg/benches/benchmark.rs +++ b/crypto/kzg/benches/benchmark.rs @@ -8,7 +8,7 @@ pub fn bench_init_context(c: &mut Criterion) { .map_err(|e| format!("Unable to read trusted setup file: {}", e)) .expect("should have trusted setup"); - c.bench_function(&format!("Initialize context rust_eth_kzg"), |b| { + c.bench_function("Initialize context rust_eth_kzg", |b| { b.iter(|| { let trusted_setup = PeerDASTrustedSetup::from(&trusted_setup); DASContext::new( @@ -19,7 +19,7 @@ pub fn bench_init_context(c: &mut Criterion) { ) }) }); - c.bench_function(&format!("Initialize context c-kzg (4844)"), |b| { + c.bench_function("Initialize context c-kzg (4844)", |b| { b.iter(|| { let trusted_setup: TrustedSetup = serde_json::from_reader(get_trusted_setup().as_slice())