From 618b1240404f078e64f2bf74b69456341f8a3a83 Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:24:52 +0200 Subject: [PATCH 1/2] move test-vectors and feature gate it --- .github/workflows/bench.yml | 2 +- Cargo.lock | 6 +++--- bin/reth/Cargo.toml | 9 ++------- bin/reth/src/cli/mod.rs | 6 +++++- bin/reth/src/commands/mod.rs | 1 - book/SUMMARY.md | 2 -- book/cli/SUMMARY.md | 2 -- book/cli/reth.md | 1 - crates/cli/commands/Cargo.toml | 17 ++++++++++++++++- crates/cli/commands/src/lib.rs | 2 ++ .../cli/commands/src}/test_vectors/mod.rs | 0 .../cli/commands/src}/test_vectors/tables.rs | 0 12 files changed, 29 insertions(+), 19 deletions(-) rename {bin/reth/src/commands => crates/cli/commands/src}/test_vectors/mod.rs (100%) rename {bin/reth/src/commands => crates/cli/commands/src}/test_vectors/tables.rs (100%) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 7d1524e60375..f8d1d475e300 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -49,7 +49,7 @@ jobs: with: ref: ${{ github.base_ref || 'main' }} - name: Generate test vectors - run: cargo run --bin reth -- test-vectors tables + run: cargo run --bin reth --features dev -- test-vectors tables - name: Save baseline run: cargo bench -p reth-db --bench iai --profile profiling --features test-utils -- --save-baseline=$BASELINE - name: Checkout PR diff --git a/Cargo.lock b/Cargo.lock index e17cbbe1062d..7f4b8d4ee9e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6310,7 +6310,6 @@ version = "1.0.0" dependencies = [ "alloy-rlp", "aquamarine", - "arbitrary", "backon", "clap", "confy", @@ -6321,8 +6320,6 @@ dependencies = [ "itertools 0.13.0", "libc", "metrics-process", - "proptest", - "proptest-arbitrary-interop", "reth-basic-payload-builder", "reth-beacon-consensus", "reth-blockchain-tree", @@ -6612,6 +6609,7 @@ name = "reth-cli-commands" version = "1.0.0" dependencies = [ "ahash", + "arbitrary", "clap", "comfy-table", "confy", @@ -6619,6 +6617,8 @@ dependencies = [ "eyre", "human_bytes", "itertools 0.13.0", + "proptest", + "proptest-arbitrary-interop", "ratatui", "reth-beacon-consensus", "reth-chainspec", diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 9f8e08b0cda7..d67436121e7c 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -87,12 +87,6 @@ toml = { workspace = true, features = ["display"] } # metrics metrics-process.workspace = true -# test vectors generation -proptest.workspace = true -arbitrary.workspace = true -proptest-arbitrary-interop.workspace = true - - # async tokio = { workspace = true, features = [ "sync", @@ -122,10 +116,11 @@ libc = "0.2" reth-discv4.workspace = true - [features] default = ["jemalloc"] +dev = ["reth-cli-commands/dev"] + asm-keccak = ["reth-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator", "reth-node-core/jemalloc"] diff --git a/bin/reth/src/cli/mod.rs b/bin/reth/src/cli/mod.rs index a7e8a759a0f7..3c5b08b2fdd3 100644 --- a/bin/reth/src/cli/mod.rs +++ b/bin/reth/src/cli/mod.rs @@ -8,13 +8,15 @@ use crate::{ commands::{ config_cmd, debug_cmd, dump_genesis, import, init_cmd, init_state, node::{self, NoArgs}, - p2p, prune, recover, stage, test_vectors, + p2p, prune, recover, stage, }, version::{LONG_VERSION, SHORT_VERSION}, }; use clap::{value_parser, Parser, Subcommand}; use reth_chainspec::ChainSpec; use reth_cli_commands::db; +#[cfg(feature = "dev")] +use reth_cli_commands::test_vectors; use reth_cli_runner::CliRunner; use reth_db::DatabaseEnv; use reth_node_builder::{NodeBuilder, WithLaunchContext}; @@ -161,6 +163,7 @@ impl Cli { Commands::Db(command) => runner.run_blocking_until_ctrl_c(command.execute()), Commands::Stage(command) => runner.run_command_until_exit(|ctx| command.execute(ctx)), Commands::P2P(command) => runner.run_until_ctrl_c(command.execute()), + #[cfg(feature = "dev")] Commands::TestVectors(command) => runner.run_until_ctrl_c(command.execute()), Commands::Config(command) => runner.run_until_ctrl_c(command.execute()), Commands::Debug(command) => runner.run_command_until_exit(|ctx| command.execute(ctx)), @@ -214,6 +217,7 @@ pub enum Commands { #[command(name = "p2p")] P2P(p2p::Command), /// Generate Test Vectors + #[cfg(feature = "dev")] #[command(name = "test-vectors")] TestVectors(test_vectors::Command), /// Write config to stdout diff --git a/bin/reth/src/commands/mod.rs b/bin/reth/src/commands/mod.rs index a8f5ff3fdf8a..23d54e098228 100644 --- a/bin/reth/src/commands/mod.rs +++ b/bin/reth/src/commands/mod.rs @@ -11,4 +11,3 @@ pub mod p2p; pub mod prune; pub mod recover; pub mod stage; -pub mod test_vectors; diff --git a/book/SUMMARY.md b/book/SUMMARY.md index ad1a54633674..af03aa32a849 100644 --- a/book/SUMMARY.md +++ b/book/SUMMARY.md @@ -61,8 +61,6 @@ - [`reth p2p`](./cli/reth/p2p.md) - [`reth p2p header`](./cli/reth/p2p/header.md) - [`reth p2p body`](./cli/reth/p2p/body.md) - - [`reth test-vectors`](./cli/reth/test-vectors.md) - - [`reth test-vectors tables`](./cli/reth/test-vectors/tables.md) - [`reth config`](./cli/reth/config.md) - [`reth debug`](./cli/reth/debug.md) - [`reth debug execution`](./cli/reth/debug/execution.md) diff --git a/book/cli/SUMMARY.md b/book/cli/SUMMARY.md index 9f9d0fdb1dc3..5f02f1e9ee04 100644 --- a/book/cli/SUMMARY.md +++ b/book/cli/SUMMARY.md @@ -32,8 +32,6 @@ - [`reth p2p`](./reth/p2p.md) - [`reth p2p header`](./reth/p2p/header.md) - [`reth p2p body`](./reth/p2p/body.md) - - [`reth test-vectors`](./reth/test-vectors.md) - - [`reth test-vectors tables`](./reth/test-vectors/tables.md) - [`reth config`](./reth/config.md) - [`reth debug`](./reth/debug.md) - [`reth debug execution`](./reth/debug/execution.md) diff --git a/book/cli/reth.md b/book/cli/reth.md index 0a761e5089cf..cebeb44e2378 100644 --- a/book/cli/reth.md +++ b/book/cli/reth.md @@ -15,7 +15,6 @@ Commands: db Database debugging utilities stage Manipulate individual stages p2p P2P Debugging utilities - test-vectors Generate Test Vectors config Write config to stdout debug Various debug routines recover Scripts for node recovery diff --git a/crates/cli/commands/Cargo.toml b/crates/cli/commands/Cargo.toml index bc9532b24349..909e00eb749a 100644 --- a/crates/cli/commands/Cargo.toml +++ b/crates/cli/commands/Cargo.toml @@ -44,4 +44,19 @@ comfy-table = "7.0" crossterm = "0.27.0" ratatui = { version = "0.27", default-features = false, features = [ "crossterm", -] } \ No newline at end of file +] } + +# reth test-vectors +proptest = { workspace = true, optional = true } +arbitrary = { workspace = true, optional = true } +proptest-arbitrary-interop = { workspace = true, optional = true } + +[features] +default = [] +dev = [ + "dep:proptest", + "dep:arbitrary", + "dep:proptest-arbitrary-interop", + "reth-primitives/arbitrary", + "reth-db-api/arbitrary" +] \ No newline at end of file diff --git a/crates/cli/commands/src/lib.rs b/crates/cli/commands/src/lib.rs index 5f94de798c7f..e63d039d1cfd 100644 --- a/crates/cli/commands/src/lib.rs +++ b/crates/cli/commands/src/lib.rs @@ -10,3 +10,5 @@ pub mod common; pub mod db; +#[cfg(feature = "dev")] +pub mod test_vectors; diff --git a/bin/reth/src/commands/test_vectors/mod.rs b/crates/cli/commands/src/test_vectors/mod.rs similarity index 100% rename from bin/reth/src/commands/test_vectors/mod.rs rename to crates/cli/commands/src/test_vectors/mod.rs diff --git a/bin/reth/src/commands/test_vectors/tables.rs b/crates/cli/commands/src/test_vectors/tables.rs similarity index 100% rename from bin/reth/src/commands/test_vectors/tables.rs rename to crates/cli/commands/src/test_vectors/tables.rs From 2b75dad2fd8678e834579e1e9aa7ef9d654fb564 Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:36:36 +0200 Subject: [PATCH 2/2] no feature imports --- bin/reth/src/cli/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/reth/src/cli/mod.rs b/bin/reth/src/cli/mod.rs index 3c5b08b2fdd3..cc9911898b0a 100644 --- a/bin/reth/src/cli/mod.rs +++ b/bin/reth/src/cli/mod.rs @@ -15,8 +15,6 @@ use crate::{ use clap::{value_parser, Parser, Subcommand}; use reth_chainspec::ChainSpec; use reth_cli_commands::db; -#[cfg(feature = "dev")] -use reth_cli_commands::test_vectors; use reth_cli_runner::CliRunner; use reth_db::DatabaseEnv; use reth_node_builder::{NodeBuilder, WithLaunchContext}; @@ -219,7 +217,7 @@ pub enum Commands { /// Generate Test Vectors #[cfg(feature = "dev")] #[command(name = "test-vectors")] - TestVectors(test_vectors::Command), + TestVectors(reth_cli_commands::test_vectors::Command), /// Write config to stdout #[command(name = "config")] Config(config_cmd::Command),