Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ pub fn run<CliConfig: crate::cli::CliConfig>(cmd_config: RunConfig) -> Result<()
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))
sc_sysinfo::gather_hwbench(
Some(database_path),
&SUBSTRATE_REFERENCE_HARDWARE,
)
}))
.flatten();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ where
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 let Err(err) = frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE.check_hardware(hwbench) {
if let Err(err) =
frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE.check_hardware(hwbench, false)
{
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",
Expand Down
2 changes: 1 addition & 1 deletion polkadot/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ where
let hwbench = (!cli.run.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))
sc_sysinfo::gather_hwbench(Some(database_path), &SUBSTRATE_REFERENCE_HARDWARE)
}))
.flatten();

Expand Down
31 changes: 25 additions & 6 deletions polkadot/node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ pub fn new_full<
use polkadot_availability_recovery::FETCH_CHUNKS_THRESHOLD;
use polkadot_node_network_protocol::request_response::IncomingRequest;
use sc_network_sync::WarpSyncConfig;
use sc_sysinfo::Metric;

let is_offchain_indexing_enabled = config.offchain_worker.indexing_enabled;
let role = config.role;
Expand Down Expand Up @@ -1080,13 +1081,31 @@ pub fn new_full<

if let Some(hwbench) = hwbench {
sc_sysinfo::print_hwbench(&hwbench);
match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) {
match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench, role.is_authority()) {
Err(err) if role.is_authority() => {
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",
err
);
if err
.0
.iter()
.any(|failure| matches!(failure.metric, Metric::Blake2256Parallel { .. }))
{
log::warn!(
"⚠️ Starting January 2025 the hardware will fail the minimal physical CPU cores requirements {} for role 'Authority',\n\
find out more when this will become mandatory at:\n\
https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#reference-hardware",
err
);
}
if err
.0
.iter()
.any(|failure| !matches!(failure.metric, Metric::Blake2256Parallel { .. }))
{
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",
err
);
}
},
_ => {},
}
Expand Down
25 changes: 25 additions & 0 deletions prdoc/pr_5127.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
title: Add benchmark to check upcoming minimum required hw cores

doc:
- audience: Node Operator
description: |
Add benchmark that checks hardware satisifies the minimum required hardware cores
for a validators. The new minimum requirements are schedule to come into effect
in January 2025, for more details see: https://polkadot.subsquare.io/referenda/1051.


crates:
- name: sc-sysinfo
bump: major
- name: frame-benchmarking-cli
bump: major
- name: staging-node-cli
bump: patch
- name: polkadot-service
bump: patch
- name: polkadot-parachain-lib
bump: patch
- name: polkadot-cli
bump: patch
- name: parachain-template-node
bump: patch
4 changes: 2 additions & 2 deletions substrate/bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
let hwbench = (!disable_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))
sc_sysinfo::gather_hwbench(Some(database_path), &SUBSTRATE_REFERENCE_HARDWARE)
}))
.flatten();

Expand Down Expand Up @@ -553,7 +553,7 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(

if let Some(hwbench) = hwbench {
sc_sysinfo::print_hwbench(&hwbench);
match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) {
match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench, false) {
Err(err) if role.is_authority() => {
log::warn!(
"⚠️ The hardware does not meet the minimal requirements {} for role 'Authority'.",
Expand Down
22 changes: 17 additions & 5 deletions substrate/client/sysinfo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ mod sysinfo;
mod sysinfo_linux;

pub use sysinfo::{
benchmark_cpu, benchmark_disk_random_writes, benchmark_disk_sequential_writes,
benchmark_memory, benchmark_sr25519_verify, gather_hwbench, gather_sysinfo,
serialize_throughput, serialize_throughput_option, Metric, Requirement, Requirements,
Throughput,
benchmark_cpu, benchmark_cpu_parallelism, benchmark_disk_random_writes,
benchmark_disk_sequential_writes, benchmark_memory, benchmark_sr25519_verify, gather_hwbench,
gather_sysinfo, serialize_throughput, serialize_throughput_option, Metric, Requirement,
Requirements, Throughput,
};

/// The operating system part of the current target triplet.
Expand All @@ -48,6 +48,12 @@ pub struct HwBench {
/// The CPU speed, as measured in how many MB/s it can hash using the BLAKE2b-256 hash.
#[serde(serialize_with = "serialize_throughput")]
pub cpu_hashrate_score: Throughput,
/// The parallel CPU speed, as measured in how many MB/s it can hash in parallel using the
/// BLAKE2b-256 hash.
#[serde(serialize_with = "serialize_throughput")]
pub parallel_cpu_hashrate_score: Throughput,
/// The number of expected cores used for computing the parallel CPU speed.
pub parallel_cpu_cores: usize,
/// Memory bandwidth in MB/s, calculated by measuring the throughput of `memcpy`.
#[serde(serialize_with = "serialize_throughput")]
pub memory_memcpy_score: Throughput,
Expand All @@ -65,6 +71,7 @@ pub struct HwBench {
pub disk_random_write_score: Option<Throughput>,
}

#[derive(Copy, Clone, Debug)]
/// Limit the execution time of a benchmark.
pub enum ExecutionLimit {
/// Limit by the maximal duration.
Expand Down Expand Up @@ -132,7 +139,12 @@ pub fn print_sysinfo(sysinfo: &sc_telemetry::SysInfo) {

/// Prints out the results of the hardware benchmarks in the logs.
pub fn print_hwbench(hwbench: &HwBench) {
log::info!("🏁 CPU score: {}", hwbench.cpu_hashrate_score);
log::info!(
"🏁 CPU single core score: {}, parallelism score: {} with expected cores: {}",
hwbench.cpu_hashrate_score,
hwbench.parallel_cpu_hashrate_score,
hwbench.parallel_cpu_cores,
);
log::info!("🏁 Memory score: {}", hwbench.memory_memcpy_score);

if let Some(score) = hwbench.disk_sequential_write_score {
Expand Down
Loading