Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
check if authority
  • Loading branch information
Szegoo committed Nov 13, 2022
commit befdd842fd16e0404dd79d682657832d21f2e5e0
9 changes: 6 additions & 3 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
//! Service implementation. Specialized wrapper over substrate service.

use codec::Encode;
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use frame_system_rpc_runtime_api::AccountNonceApi;
use futures::prelude::*;
use kitchensink_runtime::RuntimeApi;
Expand All @@ -32,7 +33,6 @@ use sc_executor::NativeElseWasmExecutor;
use sc_network::NetworkService;
use sc_network_common::{protocol::event::Event, service::NetworkEventStream};
use sc_service::{config::Configuration, error::Error as ServiceError, RpcHandlers, TaskManager};
use sc_sysinfo::Requirements;
use sc_telemetry::{Telemetry, TelemetryWorker};
use sp_api::ProvideRuntimeApi;
use sp_core::crypto::Pair;
Expand Down Expand Up @@ -318,11 +318,14 @@ pub fn new_full_base(
&sc_consensus_babe::BabeLink<Block>,
),
) -> Result<NewFullBase, ServiceError> {
let requirements: Requirements = Requirements(vec![]);
let hwbench = if !disable_hardware_benchmarks {
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(&database_path);
sc_sysinfo::gather_hwbench(Some(database_path), requirements)
sc_sysinfo::gather_hwbench(
Some(database_path),
SUBSTRATE_REFERENCE_HARDWARE.clone(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its a bit unfortunate that we have to pass this in twice now; once for the sysinfo and once for the machine benchmarking.
But I dont see how it could be done better.

config.role.is_authority(),
)
})
} else {
None
Expand Down
12 changes: 9 additions & 3 deletions client/sysinfo/src/sysinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,11 @@ pub fn benchmark_sr25519_verify(limit: ExecutionLimit) -> Throughput {
/// Benchmarks the hardware and returns the results of those benchmarks.
///
/// Optionally accepts a path to a `scratch_directory` to use to benchmark the disk.
pub fn gather_hwbench(scratch_directory: Option<&Path>, requirements: Requirements) -> HwBench {
pub fn gather_hwbench(
scratch_directory: Option<&Path>,
requirements: Requirements,
is_authority: bool,
) -> HwBench {
#[allow(unused_mut)]
let mut hwbench = HwBench {
cpu_hashrate_score: benchmark_cpu(DEFAULT_CPU_EXECUTION_LIMIT),
Expand Down Expand Up @@ -618,8 +622,10 @@ pub fn gather_hwbench(scratch_directory: Option<&Path>, requirements: Requiremen
},
};
}
// if validator
ensure_requirements(hwbench.clone(), requirements);

if is_authority {
ensure_requirements(hwbench.clone(), requirements);
}

hwbench
}
Expand Down