Skip to content

chore(l1): move all benchmarks to benches/ folder#6472

Open
azteca1998 wants to merge 1 commit intomainfrom
chore/move-benchmarks-to-benches
Open

chore(l1): move all benchmarks to benches/ folder#6472
azteca1998 wants to merge 1 commit intomainfrom
chore/move-benchmarks-to-benches

Conversation

@azteca1998
Copy link
Copy Markdown
Contributor

Summary

Consolidates all benchmarks into the benches/ folder for easier maintenance and cleaner crate structure.

Changes

  • Moved benchmark files:

    • crates/common/rlp/benches/decode.rsbenches/benches/rlp_decode.rs
    • crates/common/rlp/benches/encode.rsbenches/benches/rlp_encode.rs
    • crates/networking/p2p/benches/decode.rsbenches/benches/p2p_decode.rs
  • Updated benches/Cargo.toml:

    • Added dependencies: ethrex-rlp, ethrex-trie, ethrex-p2p, ethereum-types, rand = "0.9.2", once_cell = "1"
    • Updated criterion to version 0.7.0 (to match RLP benchmarks)
    • Added benchmark targets for rlp_decode, rlp_encode, and p2p_decode
  • Cleaned up crate Cargo.tomls:

    • Removed benchmark-related dev-dependencies from crates/common/rlp/Cargo.toml
    • Removed benchmark entry from crates/networking/p2p/Cargo.toml
    • Deleted old benchmark directories

Benefits

  • All benchmarks in one location for easier discovery and maintenance
  • Reduces clutter in individual crate directories
  • Consistent with the existing benches/ structure

Test Plan

  • cargo check -p ethrex-benches --benches compiles cleanly
  • CI passes

Notes

The p2p_decode.rs file has deprecation warnings due to using old rand 0.8 API. This is expected and doesn't affect functionality. We can update it later to use the newer rand 0.9 API for consistency.

- Move RLP decode benchmarks to benches/benches/rlp_decode.rs
- Move RLP encode benchmarks to benches/benches/rlp_encode.rs
- Move P2P decode benchmarks to benches/benches/p2p_decode.rs
- Update benches/Cargo.toml with new dependencies and benchmark targets
- Remove benchmark entries from crates/common/rlp/Cargo.toml
- Remove benchmark entry from crates/networking/p2p/Cargo.toml
- Delete old benchmark directories from crates/

This consolidates all benchmarks in a single location for easier
maintenance and avoids cluttering individual crate directories.
@github-actions
Copy link
Copy Markdown

🤖 Claude Code Review

PR Review: chore: move all benchmarks to benches/ folder

Overall: Clean housekeeping PR with no logic changes. The consolidation is straightforward — all three benchmark files are pure renames with zero content modifications.


benches/Cargo.toml — Minor Issue

rand and once_cell are added with inline version constraints rather than via the workspace:

rand = "0.9.2"
once_cell = "1"

The rest of the file uses *.workspace = true for all other dependencies. If rand and once_cell are already declared in the root Cargo.toml workspace (which they should be, since ethrex-rlp previously pulled them in as dev-deps), these should follow the same convention:

rand.workspace = true
once_cell.workspace = true

Using inline versions risks version drift if the workspace pins are ever updated — the benches crate would silently stay on a different version. This is the only meaningful concern in the entire diff.


Cargo.lock — Good

The net effect is correct: criterion 0.5.1, criterion-plot 0.5.0, and is-terminal 0.4.17 are all removed, as they were exclusively pulled in by the old p2p dev-dependency. Lockfile shrinks by ~57 lines — straightforward.


crates/common/rlp/Cargo.toml and crates/networking/p2p/Cargo.toml

Clean removals. No stray entries left behind.


Pre-existing Technical Debt (Not Introduced Here)

p2p_decode.rs uses the old rand 0.8 API, which will produce deprecation warnings under rand 0.9.2. This is correctly called out in the PR description as pre-existing. It's acceptable to track as a follow-up rather than block this PR.


Summary

One actionable item:

  • benches/Cargo.toml lines for rand and once_cell — switch to *.workspace = true for consistency and to avoid version drift.

Everything else is correct. Once CI passes and the rand/once_cell workspace alignment is addressed, this is ready to merge.


Automated review by Claude (Anthropic) · sonnet · custom prompt

@azteca1998 azteca1998 changed the title chore: move all benchmarks to benches/ folder chore(l1): move all benchmarks to benches/ folder Apr 14, 2026
@github-actions github-actions bot added the L1 Ethereum client label Apr 14, 2026
@github-actions
Copy link
Copy Markdown

🤖 Kimi Code Review

Review: Benchmark Centralization & Criterion Upgrade

This PR consolidates benchmarks into a dedicated benches crate and upgrades Criterion from 0.5.1 to 0.7.0. The refactoring is sound but carries compilation risks due to file relocation.

Critical Issues

1. Potential Broken Imports in Moved Benchmarks (benches/benches/*.rs)
The diff shows files moved with 100% similarity (lines 100% identical). If the original benchmarks used use crate:: to access internal APIs from within ethrex-rlp or ethrex-p2p, they will fail to compile in the new location.

  • Action Required: Verify that rlp_decode.rs, rlp_encode.rs, and p2p_decode.rs use only public crate paths (e.g., use ethrex_rlp::..., use ethrex_p2p::...). If they referenced internal modules, update to public paths or re-export those items.

Medium Risk

2. Criterion API Breaking Changes (0.5 → 0.7) (benches/Cargo.toml:28)
Criterion 0.7 removed deprecated APIs present in 0.5 (e.g., changes to BenchmarkId, Throughput handling, and async setup). Since the benchmark file contents aren't shown in the diff:

  • Action Required: Confirm that cargo bench compiles successfully. Common breaking changes include:
    • criterion::async_executor module reorganization
    • Changes to Criterion::bench_with_input signature

3. Orphaned Unit Tests in Source Crates (crates/common/rlp/Cargo.toml, crates/networking/p2p/Cargo.toml)
The PR removes rand, once_cell, ethrex-common, and ethrex-trie from rlp's dev-dependencies and criterion from p2p's dev-dependencies.

  • Risk: If rlp or p2p have #[cfg(test)] modules (not benchmarks) using these dependencies, cargo test will fail in those crates.
  • Action Required: Verify no remaining tests in crates/common/rlp/src/ or crates/networking/p2p/src/ use the removed dev-deps.

Minor Issues

4. Unused Dependency Check (benches/Cargo.toml)
The new dependencies once_cell and rand are added. Ensure these are actually used by the moved benchmarks and aren't just artifacts from copying the old Cargo.toml entries.

5. Criterion Dependency Classification (benches/Cargo.toml:28)
Criterion is listed under [dev-dependencies]. While this works for cargo bench, for a crate whose sole purpose is benchmarking, consider moving it to [dependencies] to make the intent explicit, though this is stylistic.

Positive Observations

  • Dependency Cleanup: Removal of criterion 0.5.1 and is-terminal reduces the dependency tree (visible in Cargo.lock diff), improving build times and supply chain security.
  • Workspace Consistency: Centralizing benchmarks prevents feature unification issues when multiple crates depend on different Criterion versions.
  • Proper Bench Registration: The [[bench]] entries in benches/Cargo.toml correctly reference the moved files with harness = false.

Summary

The PR is architecturally sound but requires verification that:

  1. The moved benchmark files compile without crate:: imports (or that these are updated).
  2. No unit tests in the source crates depend on the removed dev-dependencies.
  3. The Criterion 0.7 API is compatible with the existing benchmark logic.

Recommendation: Run cargo bench --no-run to verify compilation before merging.


Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt

@github-actions
Copy link
Copy Markdown

🤖 Codex Code Review

No findings.

This PR is benchmark-only: it moves the RLP and P2P Criterion benches into the workspace ethrex-benches package and trims the old per-crate bench-only dev-dependencies. I did not see any changes to execution paths, consensus logic, gas accounting, trie/storage behavior, or RLP encoding/decoding implementation itself.

Residual risk: I could not fully compile the benches in this sandbox because cargo needed writable ~/.cargo / ~/.rustup state and network access for dependencies. I did check the moved bench sources against their new manifest context and did not find any repo-local references still pointing at the old bench targets.


Automated review by OpenAI Codex · gpt-5.4 · custom prompt

@azteca1998 azteca1998 marked this pull request as ready for review April 14, 2026 12:39
@azteca1998 azteca1998 requested a review from a team as a code owner April 14, 2026 12:39
@ethrex-project-sync ethrex-project-sync bot moved this to In Review in ethrex_l1 Apr 14, 2026
@github-actions
Copy link
Copy Markdown

🤖 Kimi Code Review

Overall Assessment: This is a straightforward refactoring PR that consolidates benchmarks from individual crates into a centralized benches crate. This reduces dependency duplication and maintenance overhead. However, there are potential compilation risks with the moved benchmark files.

Issues to Address:

1. Import Path Compatibility in Moved Benchmarks (Critical)

  • Files: benches/benches/rlp_decode.rs, benches/benches/rlp_encode.rs, benches/benches/p2p_decode.rs
  • Risk: If the original benchmark files used use crate::... syntax to reference their respective crates, they will fail to compile in the new location since they're no longer part of those crates.
  • Action Required: Verify these files use explicit crate imports (e.g., use ethrex_rlp::..., use ethrex_p2p::...) rather than relative crate:: imports.

2. Remaining Test Dependencies (High)

  • File: crates/common/rlp/Cargo.toml (lines 15-19 in diff)
  • Issue: The PR removes ethrex-common, ethrex-trie, rand, and once_cell from dev-dependencies. If the RLP crate has unit tests (in src/ or tests/ directories) that depend on these, they will break.
  • Action Required: Confirm these dependencies were exclusively used by the moved benchmarks and not by remaining tests in the RLP crate.

3. Dependency Version Consistency (Medium)

  • File: benches/Cargo.toml (line 22)
  • Issue: rand = "0.9.2" is specified as a direct version dependency rather than using the workspace configuration (rand.workspace = true). If the workspace defines a different rand version, this could lead to duplicate rand compilations.
  • Suggestion: Use rand.workspace = true if available, or verify alignment with the workspace's rand version.

Positive Aspects:

  • Good cleanup removing duplicate criterion 0.5.1 and associated dependencies (criterion-plot 0.5.0, is-terminal) from Cargo.lock
  • Criterion upgrade from 0.5.1 to 0.7.0 is appropriate and includes bug fixes/performance improvements
  • Properly preserves hex-literal in crates/common/rlp/Cargo.toml dev-dependencies (line 15) if needed for remaining tests

Verification Checklist:

  1. Run cargo test --package ethrex-rlp to ensure no test regressions from removed dev-dependencies
  2. Run cargo bench --package ethrex-benches to verify all three moved benchmarks compile and execute
  3. Check that p2p_decode.rs properly imports from ethrex_p2p (or ethrex-p2p) and not from a relative path

The refactoring pattern is sound, but requires validation that the moved code doesn't rely on crate:: local imports.


Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt

@github-actions
Copy link
Copy Markdown

🤖 Codex Code Review

No material findings.

This PR is bench-only plumbing: it moves the RLP/P2P benchmark targets into the workspace ethrex-benches crate and removes now-redundant crate-local bench dependencies. I did not see any impact on EVM behavior, gas accounting, trie/state logic, consensus rules, or validation code.

One non-blocking maintainability note: benches/Cargo.toml:23 introduces rand = "0.9.2" while crates/networking/p2p/Cargo.toml:49 still uses rand = "0.8.5", and benches/benches/p2p_decode.rs:22 still relies on the old thread_rng() / gen() API via compatibility shims. That is probably fine today, but it adds an extra major version to the bench dependency graph and leaves this target closer to future breakage. If you want to tighten it up, align the bench crate to one rand major or fully update the moved P2P bench to 0.9-style rand::rng() / random().

Testing gap: I could not run cargo check -p ethrex-benches --benches in this sandbox because cargo/rustup needed writable ~/.cargo and network/git access for dependencies.


Automated review by OpenAI Codex · gpt-5.4 · custom prompt

@github-actions
Copy link
Copy Markdown

🤖 Claude Code Review

Now I have enough context for a thorough review. Here are my findings:


PR Review: chore(l1): move all benchmarks to benches/ folder

Overall: This is a clean consolidation with no correctness issues. There are a few dependency placement concerns worth addressing.


benches/Cargo.toml — Benchmark deps placed in [dependencies] instead of [dev-dependencies]

The following additions land in [dependencies] (lines 15–24), but they are exclusively consumed by [[bench]] targets:

ethrex-rlp.workspace = true
ethrex-trie.workspace = true
ethrex-p2p.workspace = true
ethereum-types.workspace = true
rand = "0.9.2"
once_cell = "1"

[[bench]] targets compile with both [dependencies] and [dev-dependencies], so moving these to [dev-dependencies] would still give the bench binaries access to them — while preventing them from bloating the normal build graph of any crate that happens to depend on ethrex-benches. criterion itself is already correctly placed under [dev-dependencies]; its companion deps should follow suit.


benches/Cargo.tomlrand 0.9.2 conflicts with workspace rand 0.8.5

The workspace Cargo.toml defines rand = "0.8.5". Adding rand = "0.9.2" here as a bare (non-workspace) dep means both versions will be compiled. This also explains the deprecation warnings in p2p_decode.rs noted in the PR description — the file uses the rand 0.8 API (rand::thread_rng(), rng.r#gen()) but is now compiled against 0.9.2.

Two options:

  • Use rand.workspace = true and run the benches against 0.8 (the existing workspace version).
  • Or, upgrade p2p_decode.rs to rand 0.9 (rand::rng(), .random()) in this same PR and use rand = "0.9.2" only under [dev-dependencies].

Deferring this to "later" (as the PR notes) means CI carries unnecessary dual-version overhead and noise from deprecation warnings from day one.


benches/benches/p2p_decode.rs — Deprecated rand 0.8 API (lines 22–23, 48, 76, 111)

The file uses rand::thread_rng() and rng.r#gen(), both deprecated in rand 0.9. These are easy mechanical replacements:

// Before
let mut rng = rand::thread_rng();
rng.r#gen()
// After
let mut rng = rand::rng();
rng.random()

Given the PR is already touching the Cargo config for this file, fixing the deprecations here avoids introducing known warnings into the consolidated bench crate.


Criterion upgrade from 0.5.1 → 0.7.0

The existing build_block_benchmark.rs silently moves from criterion 0.5 to 0.7. The PR confirms cargo check --benches passes, which is a reasonable signal, but a quick cargo bench --no-run to confirm linkage (not just type-checking) would give stronger confidence that no runtime behaviour changed. Minor point given the API surface used in most criterion benchmarks is stable across these versions.


What looks good

  • The file moves themselves are clean renames with zero content drift.
  • Removing criterion 0.5.1 entirely simplifies the lock file and eliminates the is-terminal / criterion-plot 0.5.0 subtree.
  • once_cell and ethereum-types pinning is consistent with how the moved benchmarks previously used them.
  • The rlp_decode.rs code quality is good — proper use of black_box, BatchSize::SmallInput, and representative data shapes.

Summary of actionable items:

  • Move ethrex-rlp, ethrex-trie, ethrex-p2p, ethereum-types, rand, once_cell to [dev-dependencies].
  • Resolve the rand version conflict: either align p2p_decode.rs to rand 0.9 API and keep 0.9.2 as a dev-dep, or drop to rand.workspace = true and update the API calls accordingly.
  • Optionally verify build_block_benchmark with cargo bench --no-run after the criterion bump.

Automated review by Claude (Anthropic) · sonnet · custom prompt

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 14, 2026

Greptile Summary

This PR consolidates three benchmark files — previously spread across crates/common/rlp/benches/ and crates/networking/p2p/benches/ — into the central benches/benches/ folder, and updates benches/Cargo.toml with the required dependencies and benchmark targets. The code moves are mechanical; no benchmark logic was changed.

Confidence Score: 5/5

  • Safe to merge — all findings are minor style/placement suggestions with no correctness or runtime impact.
  • The PR is a straightforward file move with no logic changes. Both remaining comments are P2 style suggestions (wrong [dependencies] section for bench-only deps, deprecated rand 0.8 API acknowledged by the author). Neither blocks correctness or compilation.
  • benches/Cargo.toml (rand/once_cell dependency placement) and benches/benches/p2p_decode.rs (deprecated rand API).

Important Files Changed

Filename Overview
benches/Cargo.toml Adds ethrex-rlp, ethrex-trie, ethrex-p2p, rand 0.9.2, and once_cell as [dependencies] (not [dev-dependencies]); upgrades criterion to 0.7.0; adds three new [[bench]] targets. rand 0.9.2 duplicates the workspace rand 0.8.5, and both rand + once_cell belong in [dev-dependencies] for a bench-only crate.
benches/benches/p2p_decode.rs Moved from crates/networking/p2p/benches/decode.rs; uses rand 0.8 API (thread_rng(), r#gen()) against the rand 0.9.2 dependency declared in benches/Cargo.toml, producing deprecation warnings as noted by the author.
benches/benches/rlp_decode.rs Moved from crates/common/rlp/benches/decode.rs; cleanly uses rand 0.9 API throughout, no issues found.
benches/benches/rlp_encode.rs Moved from crates/common/rlp/benches/encode.rs; cleanly uses rand 0.9 API, all bench functions are registered in criterion_group!, no issues found.
crates/common/rlp/Cargo.toml Benchmark-related dev-dependencies (criterion, rand, once_cell, ethrex-trie) removed as expected; only hex-literal remains for unit tests.
crates/networking/p2p/Cargo.toml Benchmark [[bench]] entry and associated dev-dependencies removed; no functional dependencies affected.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph Before["Before (scattered)"]
        A["crates/common/rlp/benches/decode.rs"]
        B["crates/common/rlp/benches/encode.rs"]
        C["crates/networking/p2p/benches/decode.rs"]
    end

    subgraph After["After (consolidated)"]
        D["benches/benches/rlp_decode.rs"]
        E["benches/benches/rlp_encode.rs"]
        F["benches/benches/p2p_decode.rs"]
        G["benches/benches/build_block_benchmark.rs"]
    end

    subgraph Deps["benches/Cargo.toml dependencies added"]
        H["ethrex-rlp (workspace)"]
        I["ethrex-trie (workspace)"]
        J["ethrex-p2p (workspace)"]
        K["rand 0.9.2"]
        L["once_cell 1"]
        M["criterion 0.7.0 (upgraded)"]
    end

    A -->|moved| D
    B -->|moved| E
    C -->|moved| F

    H --> D & E
    I --> D & E
    J --> F
    K --> D & E & F
    L --> D & E
    M --> D & E & F & G
Loading

Comments Outside Diff (1)

  1. benches/benches/p2p_decode.rs, line 23 (link)

    P2 Deprecated rand 0.8 API used with rand 0.9 dependency

    rand::thread_rng() and r#gen() are deprecated in rand 0.9 (superseded by rand::rng() and random() respectively). Since the PR author already acknowledged these warnings, consider updating these calls to the 0.9 API at the same time to keep the benchmark consistent with rlp_decode.rs and rlp_encode.rs.

    And replace each .r#gen() call with .random().

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: benches/benches/p2p_decode.rs
    Line: 23
    
    Comment:
    **Deprecated rand 0.8 API used with rand 0.9 dependency**
    
    `rand::thread_rng()` and `r#gen()` are deprecated in rand 0.9 (superseded by `rand::rng()` and `random()` respectively). Since the PR author already acknowledged these warnings, consider updating these calls to the 0.9 API at the same time to keep the benchmark consistent with `rlp_decode.rs` and `rlp_encode.rs`.
    
    
    And replace each `.r#gen()` call with `.random()`.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: benches/Cargo.toml
Line: 23-24

Comment:
**rand and once_cell belong in `[dev-dependencies]`**

`rand` and `once_cell` are only used in benchmark files, so they should live under `[dev-dependencies]` alongside `criterion`. Placing them in `[dependencies]` makes them compile-time dependencies of the crate for all targets. The workspace already declares `rand = "0.8.5"`; using `rand.workspace = true` in `[dev-dependencies]` (or bumping the workspace version to 0.9) would also avoid carrying two semver-incompatible copies of rand in the build graph.

```suggestion
rand = { version = "0.9.2" }
once_cell = "1"
```
Move both lines into `[dev-dependencies]`.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: benches/benches/p2p_decode.rs
Line: 23

Comment:
**Deprecated rand 0.8 API used with rand 0.9 dependency**

`rand::thread_rng()` and `r#gen()` are deprecated in rand 0.9 (superseded by `rand::rng()` and `random()` respectively). Since the PR author already acknowledged these warnings, consider updating these calls to the 0.9 API at the same time to keep the benchmark consistent with `rlp_decode.rs` and `rlp_encode.rs`.

```suggestion
                let mut rng = rand::rng();
```
And replace each `.r#gen()` call with `.random()`.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "chore: move all benchmarks to benches/ f..." | Re-trigger Greptile

Comment thread benches/Cargo.toml
Comment on lines +23 to +24
rand = "0.9.2"
once_cell = "1"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 rand and once_cell belong in [dev-dependencies]

rand and once_cell are only used in benchmark files, so they should live under [dev-dependencies] alongside criterion. Placing them in [dependencies] makes them compile-time dependencies of the crate for all targets. The workspace already declares rand = "0.8.5"; using rand.workspace = true in [dev-dependencies] (or bumping the workspace version to 0.9) would also avoid carrying two semver-incompatible copies of rand in the build graph.

Suggested change
rand = "0.9.2"
once_cell = "1"
rand = { version = "0.9.2" }
once_cell = "1"

Move both lines into [dev-dependencies].

Prompt To Fix With AI
This is a comment left during a code review.
Path: benches/Cargo.toml
Line: 23-24

Comment:
**rand and once_cell belong in `[dev-dependencies]`**

`rand` and `once_cell` are only used in benchmark files, so they should live under `[dev-dependencies]` alongside `criterion`. Placing them in `[dependencies]` makes them compile-time dependencies of the crate for all targets. The workspace already declares `rand = "0.8.5"`; using `rand.workspace = true` in `[dev-dependencies]` (or bumping the workspace version to 0.9) would also avoid carrying two semver-incompatible copies of rand in the build graph.

```suggestion
rand = { version = "0.9.2" }
once_cell = "1"
```
Move both lines into `[dev-dependencies]`.

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants