Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Warn validators with slow hardware #1863

Merged
merged 12 commits into from
Jan 21, 2023
7 changes: 2 additions & 5 deletions parachain-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,11 @@ 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 {
let hwbench = (!cli.no_hardware_benchmarks).then_some(
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(&database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
})
} else {
None
};
})).flatten();

let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
Expand Down
9 changes: 9 additions & 0 deletions parachain-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use cumulus_primitives_core::ParaId;
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface};

// Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use sc_consensus::ImportQueue;
use sc_executor::NativeElseWasmExecutor;
use sc_network::NetworkService;
Expand Down Expand Up @@ -229,6 +230,14 @@ async fn start_node_impl(

if let Some(hwbench) = hwbench {
sc_sysinfo::print_hwbench(&hwbench);
// Here you can check whether the hardware meets your chains' requirements. Putting a link
// in there and swapping out the requirements for your own are probably a good idea. The
// requirements for a para-chain are dictated by its relay-chain.
if !SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) && validator {
log::warn!(
"⚠️ The hardware does not meet the minimal requirements for role 'Authority'."
);
}

if let Some(ref mut telemetry) = telemetry {
let telemetry_handle = telemetry.handle();
Expand Down
7 changes: 2 additions & 5 deletions polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,14 +771,11 @@ 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 {
let hwbench = (!cli.no_hardware_benchmarks).then_some(
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(&database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
})
} else {
None
};
})).flatten();

let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
Expand Down
21 changes: 21 additions & 0 deletions polkadot-parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ where

if let Some(hwbench) = hwbench {
sc_sysinfo::print_hwbench(&hwbench);
if validator {
warn_if_slow_hardware(&hwbench);
}

if let Some(ref mut telemetry) = telemetry {
let telemetry_handle = telemetry.handle();
Expand Down Expand Up @@ -613,6 +616,9 @@ where

if let Some(hwbench) = hwbench {
sc_sysinfo::print_hwbench(&hwbench);
if validator {
warn_if_slow_hardware(&hwbench);
}

if let Some(ref mut telemetry) = telemetry {
let telemetry_handle = telemetry.handle();
Expand Down Expand Up @@ -1383,6 +1389,9 @@ where

if let Some(hwbench) = hwbench {
sc_sysinfo::print_hwbench(&hwbench);
if validator {
warn_if_slow_hardware(&hwbench);
}

if let Some(ref mut telemetry) = telemetry {
let telemetry_handle = telemetry.handle();
Expand Down Expand Up @@ -1580,3 +1589,15 @@ pub async fn start_contracts_rococo_node(
)
.await
}

/// Checks that the hardware meets the requirements and print a warning otherwise.
fn warn_if_slow_hardware(hwbench: &sc_sysinfo::HwBench) {
// Polkadot para-chains should generally use these requirements to ensure that the relay-chain
// will not take longer than expected to import its blocks.
if !frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE.check_hardware(hwbench) {
log::warn!(
"⚠️ The hardware does not meet the minimal requirements for role 'Authority' find out more at:\n\
https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#reference-hardware"
);
}
}