From 3728a026439ad62cc5a4e6fb6bc033e846c8bc5e Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Tue, 19 Jul 2022 17:09:28 +0200 Subject: [PATCH 1/3] allow re-use and avoid compiling kusama parachain code --- cli/Cargo.toml | 4 ++-- cli/src/command.rs | 11 +++++++---- cli/src/lib.rs | 2 +- node/test/performance-test/src/lib.rs | 3 +++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 68c297f7eeda..b1066167e4fb 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -43,7 +43,7 @@ sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" } [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 = [ @@ -55,7 +55,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"] @@ -63,6 +62,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 dfa4c05c2147..c816d2e6acbf 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -247,10 +247,13 @@ macro_rules! unwrap_client { /// Should only be used in release build since the check would take too much time otherwise. fn host_perf_check() -> Result<()> { #[cfg(not(build_type = "release"))] - { - Err(PerfCheckError::WrongBuildType.into()) - } - #[cfg(build_type = "release")] + return Err(PerfCheckError::WrongBuildType.into()) + + #[allow(unreachable_code)] + #[cfg(not(feature = "hostperfcheck"))] + return Err(PerfCheckError::FeatureNotEnabled { feature: "hostperfcheck" }.into()) + + #[cfg(all(build_type = "release", feature = "hostperfcheck"))] { crate::host_perf_check::host_perf_check()?; 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, From a02a42778edb665800cf76f1e52e0deae3a5f6ec Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Wed, 20 Jul 2022 10:28:05 +0200 Subject: [PATCH 2/3] fixup removed trailing ; --- cli/src/command.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/command.rs b/cli/src/command.rs index c816d2e6acbf..79dc81f3e61c 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -247,11 +247,11 @@ macro_rules! unwrap_client { /// Should only be used in release build since the check would take too much time otherwise. fn host_perf_check() -> Result<()> { #[cfg(not(build_type = "release"))] - return Err(PerfCheckError::WrongBuildType.into()) + return Err(PerfCheckError::WrongBuildType.into()); #[allow(unreachable_code)] #[cfg(not(feature = "hostperfcheck"))] - return Err(PerfCheckError::FeatureNotEnabled { feature: "hostperfcheck" }.into()) + return Err(PerfCheckError::FeatureNotEnabled { feature: "hostperfcheck" }.into()); #[cfg(all(build_type = "release", feature = "hostperfcheck"))] { From 539d4c5f63b6f707e3d1113417a406b4086d9217 Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Wed, 20 Jul 2022 10:51:38 +0200 Subject: [PATCH 3/3] make it compat with rustfmt +nightly --- cli/src/command.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/cli/src/command.rs b/cli/src/command.rs index 79dc81f3e61c..de9cdbf2b8cd 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -247,16 +247,20 @@ macro_rules! unwrap_client { /// Should only be used in release build since the check would take too much time otherwise. fn host_perf_check() -> Result<()> { #[cfg(not(build_type = "release"))] - return Err(PerfCheckError::WrongBuildType.into()); - - #[allow(unreachable_code)] - #[cfg(not(feature = "hostperfcheck"))] - return Err(PerfCheckError::FeatureNotEnabled { feature: "hostperfcheck" }.into()); - - #[cfg(all(build_type = "release", feature = "hostperfcheck"))] { - crate::host_perf_check::host_perf_check()?; - Ok(()) + return Err(PerfCheckError::WrongBuildType.into()) + } + #[cfg(build_type = "release")] + { + #[cfg(not(feature = "hostperfcheck"))] + { + return Err(PerfCheckError::FeatureNotEnabled { feature: "hostperfcheck" }.into()) + } + #[cfg(feature = "hostperfcheck")] + { + crate::host_perf_check::host_perf_check()?; + return Ok(()) + } } }