Disable hostperfcheck by default (#6640)

This feature should only be activated by the polkadot binary. Otherwise
parachains may accidentally activate this feature.
This commit is contained in:
Bastian Köcher
2023-02-07 14:31:04 +01:00
committed by GitHub
parent e004d5a5ed
commit 6dbf1cb443
6 changed files with 49 additions and 26 deletions
+2 -2
View File
@@ -19,7 +19,7 @@ repository = "https://github.com/paritytech/polkadot.git"
version = "0.9.37" version = "0.9.37"
[dependencies] [dependencies]
polkadot-cli = { path = "cli", features = [ "kusama-native", "westend-native", "rococo-native" ] } polkadot-cli = { path = "cli", features = [ "kusama-native", "westend-native", "rococo-native", "hostperfcheck" ] }
color-eyre = { version = "0.6.1", default-features = false } color-eyre = { version = "0.6.1", default-features = false }
tikv-jemallocator = "0.5.0" tikv-jemallocator = "0.5.0"
@@ -30,7 +30,7 @@ tempfile = "3.2.0"
tokio = "1.24.2" tokio = "1.24.2"
substrate-rpc-client = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-rpc-client = { git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-core-primitives = { path = "core-primitives" } polkadot-core-primitives = { path = "core-primitives" }
[workspace] [workspace]
members = [ members = [
"cli", "cli",
+1 -1
View File
@@ -42,7 +42,7 @@ sc-storage-monitor = { git = "https://github.com/paritytech/substrate", branch =
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
[features] [features]
default = ["db", "cli", "hostperfcheck", "full-node", "polkadot-native"] default = ["db", "cli", "full-node", "polkadot-native"]
db = ["service/db"] db = ["service/db"]
cli = [ cli = [
"clap", "clap",
+16 -12
View File
@@ -28,6 +28,7 @@ use sp_keyring::Sr25519Keyring;
use std::net::ToSocketAddrs; use std::net::ToSocketAddrs;
pub use crate::{error::Error, service::BlockId}; pub use crate::{error::Error, service::BlockId};
#[cfg(feature = "hostperfcheck")]
pub use polkadot_performance_test::PerfCheckError; pub use polkadot_performance_test::PerfCheckError;
impl From<String> for Error { impl From<String> for Error {
@@ -238,7 +239,11 @@ macro_rules! unwrap_client {
#[cfg(feature = "rococo-native")] #[cfg(feature = "rococo-native")]
polkadot_client::Client::Rococo($client) => $code, polkadot_client::Client::Rococo($client) => $code,
#[allow(unreachable_patterns)] #[allow(unreachable_patterns)]
_ => Err(Error::CommandNotImplemented), _ => {
let _ = $client;
Err(Error::CommandNotImplemented)
},
} }
}; };
} }
@@ -246,21 +251,20 @@ macro_rules! unwrap_client {
/// Runs performance checks. /// Runs performance checks.
/// Should only be used in release build since the check would take too much time otherwise. /// Should only be used in release build since the check would take too much time otherwise.
fn host_perf_check() -> Result<()> { fn host_perf_check() -> Result<()> {
#[cfg(not(build_type = "release"))] #[cfg(not(feature = "hostperfcheck"))]
{
return Err(Error::FeatureNotEnabled { feature: "hostperfcheck" }.into())
}
#[cfg(all(not(build_type = "release"), feature = "hostperfcheck"))]
{ {
return Err(PerfCheckError::WrongBuildType.into()) return Err(PerfCheckError::WrongBuildType.into())
} }
#[cfg(build_type = "release")]
#[cfg(all(feature = "hostperfcheck", build_type = "release"))]
{ {
#[cfg(not(feature = "hostperfcheck"))] crate::host_perf_check::host_perf_check()?;
{ return Ok(())
return Err(PerfCheckError::FeatureNotEnabled { feature: "hostperfcheck" }.into())
}
#[cfg(feature = "hostperfcheck")]
{
crate::host_perf_check::host_perf_check()?;
return Ok(())
}
} }
} }
+4
View File
@@ -29,6 +29,7 @@ pub enum Error {
SubstrateTracing(#[from] sc_tracing::logging::Error), SubstrateTracing(#[from] sc_tracing::logging::Error),
#[error(transparent)] #[error(transparent)]
#[cfg(feature = "hostperfcheck")]
PerfCheck(#[from] polkadot_performance_test::PerfCheckError), PerfCheck(#[from] polkadot_performance_test::PerfCheckError),
#[cfg(not(feature = "pyroscope"))] #[cfg(not(feature = "pyroscope"))]
@@ -53,4 +54,7 @@ pub enum Error {
#[error("Other: {0}")] #[error("Other: {0}")]
Other(String), Other(String),
#[error("This subcommand is only available when compiled with `{feature}`")]
FeatureNotEnabled { feature: &'static str },
} }
+26 -8
View File
@@ -1355,32 +1355,36 @@ pub fn new_chain_ops(
> { > {
config.keystore = service::config::KeystoreConfig::InMemory; config.keystore = service::config::KeystoreConfig::InMemory;
let telemetry_worker_handle = None;
#[cfg(feature = "rococo-native")] #[cfg(feature = "rococo-native")]
if config.chain_spec.is_rococo() || if config.chain_spec.is_rococo() ||
config.chain_spec.is_wococo() || config.chain_spec.is_wococo() ||
config.chain_spec.is_versi() config.chain_spec.is_versi()
{ {
return chain_ops!(config, jaeger_agent, telemetry_worker_handle; rococo_runtime, RococoExecutorDispatch, Rococo) return chain_ops!(config, jaeger_agent, None; rococo_runtime, RococoExecutorDispatch, Rococo)
} }
#[cfg(feature = "kusama-native")] #[cfg(feature = "kusama-native")]
if config.chain_spec.is_kusama() { if config.chain_spec.is_kusama() {
return chain_ops!(config, jaeger_agent, telemetry_worker_handle; kusama_runtime, KusamaExecutorDispatch, Kusama) return chain_ops!(config, jaeger_agent, None; kusama_runtime, KusamaExecutorDispatch, Kusama)
} }
#[cfg(feature = "westend-native")] #[cfg(feature = "westend-native")]
if config.chain_spec.is_westend() { if config.chain_spec.is_westend() {
return chain_ops!(config, jaeger_agent, telemetry_worker_handle; westend_runtime, WestendExecutorDispatch, Westend) return chain_ops!(config, jaeger_agent, None; westend_runtime, WestendExecutorDispatch, Westend)
} }
#[cfg(feature = "polkadot-native")] #[cfg(feature = "polkadot-native")]
{ {
return chain_ops!(config, jaeger_agent, telemetry_worker_handle; polkadot_runtime, PolkadotExecutorDispatch, Polkadot) return chain_ops!(config, jaeger_agent, None; polkadot_runtime, PolkadotExecutorDispatch, Polkadot)
} }
#[cfg(not(feature = "polkadot-native"))] #[cfg(not(feature = "polkadot-native"))]
Err(Error::NoRuntime) {
let _ = config;
let _ = jaeger_agent;
Err(Error::NoRuntime)
}
} }
/// Build a full node. /// Build a full node.
@@ -1488,7 +1492,21 @@ pub fn build_full(
} }
#[cfg(not(feature = "polkadot-native"))] #[cfg(not(feature = "polkadot-native"))]
Err(Error::NoRuntime) {
let _ = config;
let _ = is_collator;
let _ = grandpa_pause;
let _ = enable_beefy;
let _ = jaeger_agent;
let _ = telemetry_worker_handle;
let _ = overseer_enable_anyways;
let _ = overseer_gen;
let _ = overseer_message_channel_override;
let _ = malus_finality_delay;
let _ = hwbench;
Err(Error::NoRuntime)
}
} }
/// Reverts the node state down to at most the last finalized block. /// Reverts the node state down to at most the last finalized block.
@@ -36,9 +36,6 @@ pub enum PerfCheckError {
#[error("This subcommand is only available in release mode")] #[error("This subcommand is only available in release mode")]
WrongBuildType, 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")] #[error("No wasm code found for running the performance test")]
WasmBinaryMissing, WasmBinaryMissing,