From afea8046f976ba6e433420ade3daa348c58dddc1 Mon Sep 17 00:00:00 2001 From: Uncle Stinky Date: Wed, 2 Sep 2026 03:06:41 +0300 Subject: [PATCH] put benchmarking under the feature flag at once Signed-off-by: Uncle Stinky --- Cargo.toml | 2 +- cli/src/cli.rs | 1 + cli/src/command.rs | 40 ++++++++++++++-------------------------- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6093ed5..920d26f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ homepage.workspace = true [workspace.package] license = "GPL-3.0-only" authors = ["571nky", "57r37ch", "f4750"] -version = "0.9.0" +version = "0.9.1" edition = "2021" homepage = "https://ghostchain.io" repository = "https://git.ghostchain.io/ghostchain/ghost-node" diff --git a/cli/src/cli.rs b/cli/src/cli.rs index eb5fb60..1a789a0 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -55,6 +55,7 @@ pub enum Subcommand { /// Revert the chain to a previous state. Revert(sc_cli::RevertCmd), + #[cfg(feature = "runtime-benchmarks")] /// The custom benchmark subcommmand benchmarking runtime pallets. #[clap(subcommand)] Benchmark(frame_benchmarking_cli::BenchmarkCmd), diff --git a/cli/src/command.rs b/cli/src/command.rs index 6a0c700..e6e3ec6 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -279,22 +279,13 @@ pub fn run() -> Result<()> { task_manager, )) })?) - } + }, + #[cfg(feature = "runtime-benchmarks")] Some(Subcommand::Benchmark(cmd)) => { let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?; let chain_spec = &runner.config().chain_spec; match cmd { - #[cfg(not(feature = "runtime-benchmarks"))] - BenchmarkCmd::Storage(_) => { - return Err(sc_cli::Error::Input( - "Compile with `--feature=runtime-benchmarks \ - to enable storage benchmarks." - .into(), - ) - .into()) - } - #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => runner.sync_run(|mut config| { let (client, backend, _, _) = service::new_chain_ops(&mut config)?; let db = backend.expose_db(); @@ -350,21 +341,11 @@ pub fn run() -> Result<()> { BenchmarkCmd::Pallet(cmd) => { set_ss58_version(chain_spec); - if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| { - cmd.run_with_spec::, ()>( - Some(config.chain_spec), - ) - .map_err(|e| Error::SubstrateCli(e)) - }) - } else { - Err(sc_cli::Error::Input( - "Benchmarking wasn't enabled when building the node. \ - You can enable it with `--features=runtime-benchmarks`." - .into(), - ) - .into()) - } + runner.sync_run(|config| { + cmd.run_with_spec::, ()>( + Some(config.chain_spec), + ).map_err(|e| Error::SubstrateCli(e)) + }) } BenchmarkCmd::Machine(cmd) => runner.sync_run(|config| { cmd.run( @@ -379,6 +360,13 @@ pub fn run() -> Result<()> { _ => Err(Error::CommandNotImplemented), } } + #[cfg(not(feature = "runtime-benchmarks"))] + Some(Subcommand::Benchmark(_)) => { + return Err(sc_cli::Error::Input( + "Benchmarking wasn't enabled when building the node. \ + You can enable it with `--features=runtime-benchmarks`.".into(), + ).into()) + }, Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?), Some(Subcommand::ChainInfo(cmd)) => { let runner = cli.create_runner(cmd)?;