Companion for Substrate#11062 (#1113)

* Align to changes in Substrate

* Align to the newest changes in substrate

* Update `Cargo.lock`

* Add hwbenches to `parachain-template` too

* update lockfile for {"polkadot"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Koute
2022-04-26 18:51:18 +09:00
committed by GitHub
parent f0b61c91ce
commit 9550172cb9
11 changed files with 400 additions and 253 deletions
+1
View File
@@ -58,6 +58,7 @@ sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master
sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
+10
View File
@@ -109,6 +109,16 @@ pub struct Cli {
#[clap(flatten)]
pub run: cumulus_client_cli::RunCmd,
/// Disable automatic hardware benchmarks.
///
/// By default these benchmarks are automatically ran at startup and measure
/// the CPU speed, the memory bandwidth and the disk speed.
///
/// The results are then printed out in the logs, and also sent as part of
/// telemetry, if telemetry is enabled.
#[clap(long)]
pub no_hardware_benchmarks: bool,
/// Relay chain arguments
#[clap(raw = true, conflicts_with = "relay-chain-rpc-url")]
pub relaychain_args: Vec<String>,
+16 -1
View File
@@ -543,6 +543,15 @@ pub fn run() -> Result<()> {
let collator_options = cli.run.collator_options();
runner.run_node_until_exit(|config| async move {
let hwbench = if !cli.no_hardware_benchmarks {
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(&database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
})
} else {
None
};
let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
.ok_or_else(|| "Could not find parachain extension in chain-spec.")?;
@@ -581,7 +590,7 @@ pub fn run() -> Result<()> {
crate::service::start_statemint_node::<
statemint_runtime::RuntimeApi,
StatemintAuraId,
>(config, polkadot_config, collator_options, id)
>(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0)
.map_err(Into::into)
@@ -591,6 +600,7 @@ pub fn run() -> Result<()> {
polkadot_config,
collator_options,
id,
hwbench,
)
.await
.map(|r| r.0)
@@ -601,6 +611,7 @@ pub fn run() -> Result<()> {
polkadot_config,
collator_options,
id,
hwbench,
)
.await
.map(|r| r.0)
@@ -611,6 +622,7 @@ pub fn run() -> Result<()> {
polkadot_config,
collator_options,
id,
hwbench,
)
.await
.map(|r| r.0)
@@ -621,6 +633,7 @@ pub fn run() -> Result<()> {
polkadot_config,
collator_options,
id,
hwbench,
)
.await
.map(|r| r.0)
@@ -631,6 +644,7 @@ pub fn run() -> Result<()> {
polkadot_config,
collator_options,
id,
hwbench,
)
.await
.map(|r| r.0)
@@ -641,6 +655,7 @@ pub fn run() -> Result<()> {
polkadot_config,
collator_options,
id,
hwbench,
)
.await
.map(|r| r.0)
@@ -291,6 +291,7 @@ async fn build_relay_chain_interface(
telemetry_worker_handle: Option<TelemetryWorkerHandle>,
task_manager: &mut TaskManager,
collator_options: CollatorOptions,
hwbench: Option<sc_sysinfo::HwBench>,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
match collator_options.relay_chain_rpc_url {
Some(relay_chain_url) =>
@@ -300,6 +301,7 @@ async fn build_relay_chain_interface(
parachain_config,
telemetry_worker_handle,
task_manager,
hwbench,
),
}
}
@@ -316,6 +318,7 @@ async fn start_shell_node_impl<RuntimeApi, RB, BIQ, BIC>(
rpc_ext_builder: RB,
build_import_queue: BIQ,
build_consensus: BIC,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(
TaskManager,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
@@ -389,6 +392,7 @@ where
telemetry_worker_handle,
&mut task_manager,
collator_options.clone(),
hwbench.clone(),
)
.await
.map_err(|e| match e {
@@ -432,6 +436,19 @@ where
telemetry: telemetry.as_mut(),
})?;
if let Some(hwbench) = hwbench {
sc_sysinfo::print_hwbench(&hwbench);
if let Some(ref mut telemetry) = telemetry {
let telemetry_handle = telemetry.handle();
task_manager.spawn_handle().spawn(
"telemetry_hwbench",
None,
sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),
);
}
}
let announce_block = {
let network = network.clone();
Arc::new(move |hash, data| network.announce_block(hash, data))
@@ -501,6 +518,7 @@ async fn start_node_impl<RuntimeApi, RB, BIQ, BIC>(
_rpc_ext_builder: RB,
build_import_queue: BIQ,
build_consensus: BIC,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(
TaskManager,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
@@ -575,6 +593,7 @@ where
telemetry_worker_handle,
&mut task_manager,
collator_options.clone(),
hwbench.clone(),
)
.await
.map_err(|e| match e {
@@ -630,6 +649,19 @@ where
telemetry: telemetry.as_mut(),
})?;
if let Some(hwbench) = hwbench {
sc_sysinfo::print_hwbench(&hwbench);
if let Some(ref mut telemetry) = telemetry {
let telemetry_handle = telemetry.handle();
task_manager.spawn_handle().spawn(
"telemetry_hwbench",
None,
sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),
);
}
}
let announce_block = {
let network = network.clone();
Arc::new(move |hash, data| network.announce_block(hash, data))
@@ -740,6 +772,7 @@ pub async fn start_rococo_parachain_node(
polkadot_config: Configuration,
collator_options: CollatorOptions,
id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(
TaskManager,
Arc<TFullClient<Block, rococo_parachain_runtime::RuntimeApi, WasmExecutor<HostFunctions>>>,
@@ -817,6 +850,7 @@ pub async fn start_rococo_parachain_node(
},
))
},
hwbench,
)
.await
}
@@ -865,6 +899,7 @@ pub async fn start_shell_node<RuntimeApi>(
polkadot_config: Configuration,
collator_options: CollatorOptions,
id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(
TaskManager,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
@@ -936,6 +971,7 @@ where
},
))
},
hwbench,
)
.await
}
@@ -1133,6 +1169,7 @@ pub async fn start_statemint_node<RuntimeApi, AuraId: AppKey>(
polkadot_config: Configuration,
collator_options: CollatorOptions,
id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(
TaskManager,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
@@ -1289,6 +1326,7 @@ where
Ok(parachain_consensus)
},
hwbench,
)
.await
}
@@ -1302,6 +1340,7 @@ async fn start_canvas_kusama_node_impl<RuntimeApi, RB, BIQ, BIC>(
_rpc_ext_builder: RB,
build_import_queue: BIQ,
build_consensus: BIC,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(
TaskManager,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
@@ -1377,6 +1416,7 @@ where
telemetry_worker_handle,
&mut task_manager,
collator_options.clone(),
hwbench.clone(),
)
.await
.map_err(|e| match e {
@@ -1432,6 +1472,19 @@ where
telemetry: telemetry.as_mut(),
})?;
if let Some(hwbench) = hwbench {
sc_sysinfo::print_hwbench(&hwbench);
if let Some(ref mut telemetry) = telemetry {
let telemetry_handle = telemetry.handle();
task_manager.spawn_handle().spawn(
"telemetry_hwbench",
None,
sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),
);
}
}
let announce_block = {
let network = network.clone();
Arc::new(move |hash, data| network.announce_block(hash, data))
@@ -1540,6 +1593,7 @@ pub async fn start_canvas_kusama_node(
polkadot_config: Configuration,
collator_options: CollatorOptions,
id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(
TaskManager,
Arc<TFullClient<Block, canvas_kusama_runtime::RuntimeApi, WasmExecutor<HostFunctions>>>,
@@ -1616,6 +1670,7 @@ pub async fn start_canvas_kusama_node(
},
))
},
hwbench,
)
.await
}