diff --git a/substrate/bin/node/cli/Cargo.toml b/substrate/bin/node/cli/Cargo.toml index 9842fd2ee4..c15769a98a 100644 --- a/substrate/bin/node/cli/Cargo.toml +++ b/substrate/bin/node/cli/Cargo.toml @@ -149,7 +149,10 @@ cli = [ "structopt", "substrate-build-script-utils", ] -runtime-benchmarks = [ "node-runtime/runtime-benchmarks" ] +runtime-benchmarks = [ + "node-runtime/runtime-benchmarks", + "frame-benchmarking-cli", +] [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/substrate/bin/node/cli/src/command.rs b/substrate/bin/node/cli/src/command.rs index 37b77d3bb7..179a61cee8 100644 --- a/substrate/bin/node/cli/src/command.rs +++ b/substrate/bin/node/cli/src/command.rs @@ -80,9 +80,15 @@ pub fn run() -> Result<()> { runner.sync_run(|config| cmd.run::(config)) } Some(Subcommand::Benchmark(cmd)) => { - let runner = cli.create_runner(cmd)?; + if cfg!(feature = "runtime-benchmarks") { + let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run::(config)) + runner.sync_run(|config| cmd.run::(config)) + } else { + println!("Benchmarking wasn't enabled when building the node. \ + You can enable it with `--features runtime-benchmarks`."); + Ok(()) + } } Some(Subcommand::Factory(cmd)) => { let runner = cli.create_runner(cmd)?;