Skip to content

Commit c7dab68

Browse files
authored
fix(l1, l2): cargo test compilation at workspace level (#4916)
**Motivation** `cargo test` at the workspace level or in `cmd/ethrex` is not compiling. This is because `ethrex-l2-rpc` is a `dev-dependencie`. This issue uncovered a bigger issue, that is the existence of `benches` inside `cmd/ethrex`. **Description** This PR solves the compilation error by moving benchmarks to a separate crate, `benches`. It also removes an unsued benchmark.
1 parent 47c0648 commit c7dab68

File tree

8 files changed

+66
-73
lines changed

8 files changed

+66
-73
lines changed

.github/workflows/pr_perf_build_block_bench.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Benchmark Block building
55
on:
66
workflow_dispatch:
77
#pull_request:
8-
#branches: ["**"]
8+
#branches: ["**"]
99

1010
permissions:
1111
pull-requests: write
@@ -23,7 +23,7 @@ jobs:
2323
- name: Benchmarks
2424
uses: boa-dev/criterion-compare-action@v3
2525
with:
26-
cwd: "cmd/ethrex/bench"
26+
cwd: "benches/benches"
2727
benchName: "build_block_benchmark"
2828
branchName: ${{ github.base_ref }}
2929
token: ${{ secrets.GITHUB_TOKEN }}

Cargo.lock

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = [
3+
"benches",
34
"cmd/ethrex",
45
"crates/blockchain",
56
"crates/blockchain/dev",

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ WORKDIR /ethrex
1717
# This layer is fast and will be invalidated on any source change.
1818
FROM chef AS planner
1919

20+
COPY benches ./benches
2021
COPY crates ./crates
2122
COPY tooling ./tooling
2223
COPY metrics ./metrics
@@ -39,6 +40,7 @@ RUN cargo chef cook --release --recipe-path recipe.json
3940
RUN curl -L -o /usr/bin/solc https://github.com/ethereum/solidity/releases/download/v0.8.29/solc-static-linux \
4041
&& chmod +x /usr/bin/solc
4142

43+
COPY benches ./benches
4244
COPY crates ./crates
4345
COPY cmd ./cmd
4446
COPY metrics ./metrics

benches/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "ethrex-benches"
3+
version.workspace = true
4+
edition.workspace = true
5+
authors.workspace = true
6+
documentation.workspace = true
7+
8+
[dependencies]
9+
ethrex.workspace = true
10+
ethrex-blockchain.workspace = true
11+
ethrex-common.workspace = true
12+
ethrex-config.workspace = true
13+
ethrex-storage.workspace = true
14+
15+
bytes.workspace = true
16+
tokio.workspace = true
17+
serde_json.workspace = true
18+
19+
[dev-dependencies]
20+
criterion = { version = "0.5.1", features = [
21+
"html_reports",
22+
"async_futures",
23+
"async_tokio",
24+
] }
25+
secp256k1.workspace = true
26+
tempfile.workspace = true
27+
ethrex-l2-rpc.workspace = true
28+
29+
[[bench]]
30+
name = "build_block_benchmark"
31+
harness = false
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl ValueFormatter for GasMeasurementFormatter {
103103
}
104104

105105
fn read_private_keys() -> Vec<SecretKey> {
106-
let file = include_str!("../../../fixtures/keys/private_keys_l1.txt");
106+
let file = include_str!("../../fixtures/keys/private_keys_l1.txt");
107107
file.lines()
108108
.map(|line| {
109109
let line = line.trim().strip_prefix("0x").unwrap();
@@ -122,7 +122,7 @@ async fn setup_genesis(accounts: &Vec<Address>) -> (Store, Genesis) {
122122
if std::fs::exists(&storage_path).unwrap_or(false) {
123123
std::fs::remove_dir_all(&storage_path).unwrap();
124124
}
125-
let genesis_file = include_bytes!("../../../fixtures/genesis/l1-dev.json");
125+
let genesis_file = include_bytes!("../../fixtures/genesis/l1-dev.json");
126126
let mut genesis: Genesis = serde_json::from_slice(genesis_file).unwrap();
127127
let store = Store::new(storage_path, EngineType::RocksDB).unwrap();
128128
for address in accounts {

cmd/ethrex/Cargo.toml

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ ethrex-storage.workspace = true
2727
ethrex-storage-rollup = { workspace = true, optional = true }
2828
ethrex-vm.workspace = true
2929

30-
tikv-jemallocator = { version = "0.6.0", optional = true, features = ["stats", "unprefixed_malloc_on_supported_platforms"] }
30+
tikv-jemallocator = { version = "0.6.0", optional = true, features = [
31+
"stats",
32+
"unprefixed_malloc_on_supported_platforms",
33+
] }
3134
bytes.workspace = true
3235
hex.workspace = true
3336
tracing.workspace = true
@@ -55,7 +58,11 @@ url.workspace = true
5558
tui-logger = { workspace = true, optional = true }
5659

5760
[target.'cfg(linux)'.dependencies]
58-
tikv-jemallocator = { version = "0.6.0", optional = true, features = ["stats", "unprefixed_malloc_on_supported_platforms", "background_threads"] }
61+
tikv-jemallocator = { version = "0.6.0", optional = true, features = [
62+
"stats",
63+
"unprefixed_malloc_on_supported_platforms",
64+
"background_threads",
65+
] }
5966

6067
[[bin]]
6168
name = "ethrex"
@@ -102,33 +109,11 @@ l2 = [
102109
"dep:serde_json",
103110
"dep:hex",
104111
]
105-
l2-sql = [
106-
"ethrex-storage-rollup/sql",
107-
]
112+
l2-sql = ["ethrex-storage-rollup/sql"]
108113
sp1 = ["ethrex-prover/sp1"]
109114
gpu = ["ethrex-prover/gpu"]
110115
risc0 = ["ethrex-prover/risc0"]
111116

112-
[dev-dependencies]
113-
criterion = { version = "0.5.1", features = [
114-
"html_reports",
115-
"async_futures",
116-
"async_tokio",
117-
] }
118-
secp256k1.workspace = true
119-
tempfile.workspace = true
120-
ethrex-l2-rpc.workspace = true
121-
122-
[[bench]]
123-
path = "./bench/import_blocks_benchmark.rs"
124-
name = "import_blocks_benchmark"
125-
harness = false
126-
127-
[[bench]]
128-
path = "./bench/build_block_benchmark.rs"
129-
name = "build_block_benchmark"
130-
harness = false
131-
132117
[build-dependencies]
133118
vergen-git2 = { version = "1.0.7", features = ["rustc"] }
134119
ethrex-sdk = { workspace = true, optional = true }

cmd/ethrex/bench/import_blocks_benchmark.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)