diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 42e7ffbe4261..e11ad1595b42 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -42,7 +42,7 @@ sp-trie = { git = "https://github.com/futureverse-root/substrate", default-featu substrate-build-script-utils = { git = "https://github.com/futureverse-root/substrate", branch = "polkadot-v0.9.23" } [features] -default = ["wasmtime", "db", "cli", "full-node", "trie-memory-tracker", "polkadot-native"] +default = ["wasmtime", "db", "cli", "hostperfcheck", "full-node", "trie-memory-tracker", "polkadot-native"] wasmtime = ["sc-cli/wasmtime"] db = ["service/db"] cli = [ @@ -54,7 +54,6 @@ cli = [ "try-runtime-cli", "polkadot-client", "polkadot-node-core-pvf", - "polkadot-performance-test", ] runtime-benchmarks = ["service/runtime-benchmarks", "polkadot-node-metrics/runtime-benchmarks"] trie-memory-tracker = ["sp-trie/memory-tracker"] @@ -62,6 +61,7 @@ full-node = ["service/full-node"] try-runtime = ["service/try-runtime"] fast-runtime = ["service/fast-runtime"] pyroscope = ["pyro"] +hostperfcheck = ["polkadot-performance-test"] # Configure the native runtimes to use. Polkadot is enabled by default. # diff --git a/cli/src/command.rs b/cli/src/command.rs index c4c69440b5dc..279bd4ad6504 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -258,12 +258,19 @@ macro_rules! unwrap_client { fn host_perf_check() -> Result<()> { #[cfg(not(build_type = "release"))] { - Err(PerfCheckError::WrongBuildType.into()) + return Err(PerfCheckError::WrongBuildType.into()) } #[cfg(build_type = "release")] { - crate::host_perf_check::host_perf_check()?; - Ok(()) + #[cfg(not(feature = "hostperfcheck"))] + { + return Err(PerfCheckError::FeatureNotEnabled { feature: "hostperfcheck" }.into()) + } + #[cfg(feature = "hostperfcheck")] + { + crate::host_perf_check::host_perf_check()?; + return Ok(()) + } } } diff --git a/cli/src/lib.rs b/cli/src/lib.rs index b4ee9f868b2e..b31cf5dca8dc 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -24,7 +24,7 @@ mod cli; mod command; #[cfg(feature = "cli")] mod error; -#[cfg(all(feature = "cli", build_type = "release"))] +#[cfg(all(feature = "hostperfcheck", build_type = "release"))] mod host_perf_check; #[cfg(feature = "full-node")] diff --git a/node/test/performance-test/src/lib.rs b/node/test/performance-test/src/lib.rs index e80b5e7589f2..762c530e5d20 100644 --- a/node/test/performance-test/src/lib.rs +++ b/node/test/performance-test/src/lib.rs @@ -36,6 +36,9 @@ pub enum PerfCheckError { #[error("This subcommand is only available in release mode")] WrongBuildType, + #[error("This subcommand is only available when compiled with `{feature}`")] + FeatureNotEnabled { feature: &'static str }, + #[error("No wasm code found for running the performance test")] WasmBinaryMissing,