Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
2c029fd
Allow duplicate topics in smart contract events (#13065)
xgreenx Jan 11, 2023
293c1f2
[NFTs] Track item's metadata depositor (#13124)
jsidorenko Jan 11, 2023
e752af1
`IntegrityTest` implementation should be feature gated (#13094)
bkchr Jan 11, 2023
ad58606
Bump git2 from 0.14.4 to 0.16.0 (#13123)
dependabot[bot] Jan 11, 2023
6d3596f
Scheduler is already at V4 (#13105)
ggwpez Jan 11, 2023
f9d1dcd
Optimize merkle proofs for efficient verification in Solidity (#12857)
doubledup Jan 12, 2023
e9b0fac
client/beefy: fix logs (#13130)
acatangiu Jan 12, 2023
2bfc1dd
Stop keeping track of epoch changes for the sync gap (#13127)
davxy Jan 12, 2023
d92281a
CI: Unpin `ci-linux` and use Rust 1.66.1 (#13134)
rcny Jan 13, 2023
88be4b6
sp-beefy: align authority id key type with its signature type (#13131)
acatangiu Jan 13, 2023
cbc525f
Use the balance trait as we have one (#13136)
gilescope Jan 13, 2023
30641ee
CI: Code mark to request a pipeline failure (#13139)
rcny Jan 13, 2023
49962f7
Annotate thiserror for sp_core::crypto::SecretStringError (#13144)
jasl Jan 15, 2023
70f2e36
pallet-offences-benchmarking: Box events in verify (#13151)
bkchr Jan 16, 2023
ea00240
More improvements for the crate publishing pipeline (#13153)
joao-paulo-parity Jan 16, 2023
7ff6fa2
txpool: don't maintain the pool during major sync (#13004)
michalkucharczyk Jan 16, 2023
2893730
[client/network] Add support for `/wss` addresses (#13152)
melekes Jan 17, 2023
6bac243
NIS should retain funds in reserve (#12928)
gavofyork Jan 17, 2023
414caff
Refactory of `next_slot` method (#13155)
davxy Jan 17, 2023
f7e53fe
Breakout mock runtimes to separate files (#13150)
gilescope Jan 17, 2023
42f38db
frame-benchmarking: Macros should not force a particular env (#13161)
bkchr Jan 17, 2023
cfe9262
Fix the `storage_size`/`state_getStorageSize` RPC call (#13154)
koute Jan 18, 2023
a447f03
[contracts] Adapt storage reading host functions to Weights V2 (#12976)
agryaznov Jan 18, 2023
af5a499
zobmienet tests are not supposed to fail (#13015)
michalkucharczyk Jan 18, 2023
cba5977
[contracts] Add integrity checks by pallet hook (#12993)
agryaznov Jan 18, 2023
911c9ab
Expose `UnknownBlock` error via `ApiError` (#12707)
tdimitrov Jan 19, 2023
d4384f2
Notification-based block pinning (#13157)
skunert Jan 19, 2023
0b6aec5
Make DispatchError impl MEL (#13169)
gavofyork Jan 19, 2023
b85d631
Remove fixtures from crate (#13181)
athei Jan 19, 2023
d7acf9e
txpool: LOG_TARGET const added (#13180)
michalkucharczyk Jan 19, 2023
de943ee
Fix potential huge allocation as a result of `validate_block` output …
mrcnski Jan 20, 2023
593c76b
sc-network: Ensure private addresses are disabled if requested (#13185)
bkchr Jan 20, 2023
38ec2d8
Warn validators with slow hardware (#12620)
Szegoo Jan 20, 2023
2c16842
Use year 2023 in the License headers (#13193)
ggwpez Jan 20, 2023
355e4a9
Move slow hardware warning print logic to CLI (#13198)
ggwpez Jan 21, 2023
79cb2e6
Fix flaky BABE test (#13199)
bkchr Jan 21, 2023
1f70226
Add debug info in assert_has_event and assert_last_event (#12979)
zjb0807 Jan 22, 2023
ed3f055
new proc-macro-based benchmarking syntax (#12924)
sam0x17 Jan 23, 2023
d0a2c4a
Rename `*-private-ipv4` to `*-private-ip` CLI args (#13208)
bkchr Jan 23, 2023
e72f72f
Remove dead code (#13213)
koute Jan 23, 2023
419b840
[Fix] CountedMap::set now takes Counter into account (#13214)
ruseinov Jan 23, 2023
52d72b3
debug assert events at genesis (#13217)
muharem Jan 23, 2023
9052607
BlockId removal: refactor: CallExecutor trait (#13173)
michalkucharczyk Jan 24, 2023
ca5a505
service: storage monitor added (#13082)
michalkucharczyk Jan 24, 2023
84af672
beefy: Add LOG_TARGET constant (#13222)
al3mart Jan 24, 2023
09de7b4
Upgrade wasm-opt to 0.111.0 (#13038)
brson Jan 24, 2023
5749760
storage-monitor: statvfs arithmetic bug fixed (#13234)
michalkucharczyk Jan 24, 2023
d2afb5d
Bump parity-db (#13226)
arkpar Jan 24, 2023
1314eec
pallet-assets: Rename `total_supply` to `amount` (#13229)
bkchr Jan 25, 2023
e393874
Babe: bad epoch index with skipped epochs and warp sync (#13135)
davxy Jan 25, 2023
1a1600b
contracts: Deprecate random interface (#13204)
athei Jan 25, 2023
d74eab8
[contracts] Add upfront weight of merkle trie proofs for storage read…
agryaznov Jan 25, 2023
d22e68c
CI: Rewrite `check-each-crate` in python (#13238)
bkchr Jan 25, 2023
d029225
Fix try-runtime with create-snapshot (#13223)
zjb0807 Jan 25, 2023
8b4331c
reduce exec time of fast-unstake benchmarks (#13120)
kianenigma Jan 25, 2023
9db957c
Rework the trie cache (#12982)
koute Jan 26, 2023
64a1a36
Add task type label to metrics (#13240)
sandreim Jan 26, 2023
f4bc993
upgrade nix to 0.26.1 (#13230)
michalkucharczyk Jan 26, 2023
2dbf625
Add WeightToFee and LengthToFee impls to transaction-payment Runtime …
notlesh Jan 26, 2023
495cc0e
Correct arithmetical semantic of `PerDispatchClass` (#13194)
ggwpez Jan 26, 2023
65d1d03
Aura: Fix warp syncing (#13221)
bkchr Jan 26, 2023
ff9921a
Add Proof Size to Weight Output (#11637)
shawntabrizi Jan 26, 2023
248fdf0
Use non-binary pronouns in comments. (#13209)
DanHenton Jan 27, 2023
ce2cee3
migrate new benchmarking syntax from `frame_support::benchmarking` to…
sam0x17 Jan 27, 2023
9762613
mutate_exists for StorageValue with ValueQuery (#13245)
muraca Jan 27, 2023
1e6b892
Fix derive PassByInner with generics (#13247)
conr2d Jan 28, 2023
ece32a7
docs: Fix broken documentation links for pallets (#13241)
Jonathas-Conceicao Jan 28, 2023
0100b3b
sc-finality-grandpa: Warp proof generation can not expect justificati…
bkchr Jan 28, 2023
6c11190
update criterion to v0.4.0 (#13142)
koushiro Jan 28, 2023
f4caddb
fix up template (#13205)
shawntabrizi Jan 29, 2023
fdff2b2
Remove `uncles` related code (#13216)
bkchr Jan 29, 2023
a9c4334
Implement RIType traits for u8 array with an arbitrary size (#13256)
conr2d Jan 30, 2023
129fee7
grandpa: cleanup stale entries in set id session mapping (#13237)
andresilva Jan 30, 2023
8cfe326
Benchmark's successful origin api update (#13146)
muharem Feb 1, 2023
c4b2db5
hooks default impl missing where clause (#13264)
kianenigma Feb 1, 2023
b2b2e65
implemented `contains_prefix` for StorageDoubleMap and StorageNMap (#…
muraca Feb 1, 2023
3bc3742
Calling proxy doesn't remove announcement (#13267)
Szegoo Feb 1, 2023
5a281ce
Fix block pruning (#13323)
arkpar Feb 7, 2023
15e218a
grandpa: don't error if best block and finality target are inconsiste…
andresilva Feb 12, 2023
18bb7c7
benchmarks: EnsureRankedMember must add ranked members (#13297) (#13348)
muharem Feb 13, 2023
c304070
Merge remote-tracking branch 'upstream/polkadot-v0.9.38' into polkado…
kacperzuk-neti Apr 17, 2023
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
Warn validators with slow hardware (#12620)
* move Metric

* run hardware bench if validiator flag is being used

* fix rustdoc & update node-template

* fix

* unused improt

* warn

* move Requirement

* bench_result

* ensure_requirements

* make the code compile

* check if authority

* Update client/sysinfo/src/sysinfo.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* nit fixes

* warning signs

* Update client/sysinfo/src/sysinfo.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  • Loading branch information
Szegoo and ggwpez authored Jan 20, 2023
commit 38ec2d8957d843fa424397f79a484d773eea1454
7 changes: 6 additions & 1 deletion 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 Down Expand Up @@ -320,7 +321,11 @@ pub fn new_full_base(
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))
sc_sysinfo::gather_hwbench(
Some(database_path),
SUBSTRATE_REFERENCE_HARDWARE.clone(),
config.role.is_authority(),
)
})
} else {
None
Expand Down
3 changes: 2 additions & 1 deletion client/sysinfo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ 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, Throughput,
serialize_throughput, serialize_throughput_option, Metric, Requirement, Requirements,
Throughput,
};

/// The operating system part of the current target triplet.
Expand Down
135 changes: 131 additions & 4 deletions client/sysinfo/src/sysinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ use crate::{ExecutionLimit, HwBench};
use sc_telemetry::SysInfo;
use sp_core::{sr25519, Pair};
use sp_io::crypto::sr25519_verify;
use sp_std::{fmt, prelude::*};
use sp_std::{fmt, fmt::Formatter, prelude::*};

use rand::{seq::SliceRandom, Rng, RngCore};
use serde::Serializer;
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};
use std::{
fs::File,
io::{Seek, SeekFrom, Write},
Expand All @@ -33,6 +33,43 @@ use std::{
time::{Duration, Instant},
};

/// A single hardware metric.
#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq)]
pub enum Metric {
/// SR25519 signature verification.
Sr25519Verify,
/// Blake2-256 hashing algorithm.
Blake2256,
/// Copying data in RAM.
MemCopy,
/// Disk sequential write.
DiskSeqWrite,
/// Disk random write.
DiskRndWrite,
}

impl Metric {
/// The category of the metric.
pub fn category(&self) -> &'static str {
match self {
Self::Sr25519Verify | Self::Blake2256 => "CPU",
Self::MemCopy => "Memory",
Self::DiskSeqWrite | Self::DiskRndWrite => "Disk",
}
}

/// The name of the metric. It is always prefixed by the [`self.category()`].
pub fn name(&self) -> &'static str {
match self {
Self::Sr25519Verify => "SR25519-Verify",
Self::Blake2256 => "BLAKE2-256",
Self::MemCopy => "Copy",
Self::DiskSeqWrite => "Seq Write",
Self::DiskRndWrite => "Rnd Write",
}
}
}

/// The unit in which the [`Throughput`] (bytes per second) is denoted.
pub enum Unit {
GiBs,
Expand Down Expand Up @@ -137,6 +174,54 @@ where
serializer.serialize_none()
}

/// Serializes throughput into MiBs and represents it as `f64`.
fn serialize_throughput_as_f64<S>(throughput: &Throughput, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_f64(throughput.as_mibs())
}

struct ThroughputVisitor;
impl<'de> Visitor<'de> for ThroughputVisitor {
type Value = Throughput;

fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
formatter.write_str("A value that is a f64.")
}

fn visit_f64<E>(self, value: f64) -> Result<Self::Value, E>
where
E: serde::de::Error,
{
Ok(Throughput::from_mibs(value))
}
}

fn deserialize_throughput<'de, D>(deserializer: D) -> Result<Throughput, D::Error>
where
D: Deserializer<'de>,
{
Ok(deserializer.deserialize_f64(ThroughputVisitor))?
}

/// Multiple requirements for the hardware.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct Requirements(pub Vec<Requirement>);

/// A single requirement for the hardware.
#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq)]
pub struct Requirement {
/// The metric to measure.
pub metric: Metric,
/// The minimal throughput that needs to be archived for this requirement.
#[serde(
serialize_with = "serialize_throughput_as_f64",
deserialize_with = "deserialize_throughput"
)]
pub minimum: Throughput,
}

#[inline(always)]
pub(crate) fn benchmark<E>(
name: &str,
Expand Down Expand Up @@ -503,8 +588,14 @@ 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>) -> HwBench {
/// Optionally accepts a path to a `scratch_directory` to use to benchmark the
/// disk. Also accepts the `requirements` for the hardware benchmark and a
/// boolean to specify if the node is an authority.
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 @@ -534,9 +625,45 @@ pub fn gather_hwbench(scratch_directory: Option<&Path>) -> HwBench {
};
}

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

hwbench
}

fn ensure_requirements(hwbench: HwBench, requirements: Requirements) {
let mut failed = 0;
for requirement in requirements.0.iter() {
match requirement.metric {
Metric::Blake2256 =>
if requirement.minimum > hwbench.cpu_hashrate_score {
failed += 1;
},
Metric::MemCopy =>
if requirement.minimum > hwbench.memory_memcpy_score {
failed += 1;
},
Metric::DiskSeqWrite =>
if let Some(score) = hwbench.disk_sequential_write_score {
if requirement.minimum > score {
failed += 1;
}
},
Metric::DiskRndWrite =>
if let Some(score) = hwbench.disk_random_write_score {
if requirement.minimum > score {
failed += 1;
}
},
Metric::Sr25519Verify => {},
}
}
if failed != 0 {
log::warn!("⚠️ Your hardware performance score was less than expected for role 'Authority'. See https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#reference-hardware");
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion utils/frame/benchmarking-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod storage;

pub use block::BlockCmd;
pub use extrinsic::{ExtrinsicBuilder, ExtrinsicCmd, ExtrinsicFactory};
pub use machine::{MachineCmd, Requirements, SUBSTRATE_REFERENCE_HARDWARE};
pub use machine::{MachineCmd, SUBSTRATE_REFERENCE_HARDWARE};
pub use overhead::OverheadCmd;
pub use pallet::PalletCmd;
pub use sc_service::BasePath;
Expand Down
91 changes: 1 addition & 90 deletions utils/frame/benchmarking-cli/src/machine/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,7 @@
//! Contains types to define hardware requirements.

use lazy_static::lazy_static;
use sc_sysinfo::Throughput;
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};
use sp_std::{fmt, fmt::Formatter};

/// Serializes throughput into MiBs and represents it as `f64`.
fn serialize_throughput_as_f64<S>(throughput: &Throughput, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_f64(throughput.as_mibs())
}

struct ThroughputVisitor;
impl<'de> Visitor<'de> for ThroughputVisitor {
type Value = Throughput;

fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
formatter.write_str("A value that is a f64.")
}

fn visit_f64<E>(self, value: f64) -> Result<Self::Value, E>
where
E: serde::de::Error,
{
Ok(Throughput::from_mibs(value))
}
}

fn deserialize_throughput<'de, D>(deserializer: D) -> Result<Throughput, D::Error>
where
D: Deserializer<'de>,
{
Ok(deserializer.deserialize_f64(ThroughputVisitor))?
}
use sc_sysinfo::Requirements;

lazy_static! {
/// The hardware requirements as measured on reference hardware.
Expand All @@ -67,62 +34,6 @@ lazy_static! {
};
}

/// Multiple requirements for the hardware.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct Requirements(pub Vec<Requirement>);

/// A single requirement for the hardware.
#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq)]
pub struct Requirement {
/// The metric to measure.
pub metric: Metric,
/// The minimal throughput that needs to be archived for this requirement.
#[serde(
serialize_with = "serialize_throughput_as_f64",
deserialize_with = "deserialize_throughput"
)]
pub minimum: Throughput,
}

/// A single hardware metric.
///
/// The implementation of these is in `sc-sysinfo`.
#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq)]
pub enum Metric {
/// SR25519 signature verification.
Sr25519Verify,
/// Blake2-256 hashing algorithm.
Blake2256,
/// Copying data in RAM.
MemCopy,
/// Disk sequential write.
DiskSeqWrite,
/// Disk random write.
DiskRndWrite,
}

impl Metric {
/// The category of the metric.
pub fn category(&self) -> &'static str {
match self {
Self::Sr25519Verify | Self::Blake2256 => "CPU",
Self::MemCopy => "Memory",
Self::DiskSeqWrite | Self::DiskRndWrite => "Disk",
}
}

/// The name of the metric. It is always prefixed by the [`self::category()`].
pub fn name(&self) -> &'static str {
match self {
Self::Sr25519Verify => "SR25519-Verify",
Self::Blake2256 => "BLAKE2-256",
Self::MemCopy => "Copy",
Self::DiskSeqWrite => "Seq Write",
Self::DiskRndWrite => "Rnd Write",
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
5 changes: 3 additions & 2 deletions utils/frame/benchmarking-cli/src/machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ use sc_cli::{CliConfiguration, Result, SharedParams};
use sc_service::Configuration;
use sc_sysinfo::{
benchmark_cpu, benchmark_disk_random_writes, benchmark_disk_sequential_writes,
benchmark_memory, benchmark_sr25519_verify, ExecutionLimit, Throughput,
benchmark_memory, benchmark_sr25519_verify, ExecutionLimit, Metric, Requirement, Requirements,
Throughput,
};

use crate::shared::check_build_profile;
pub use hardware::{Metric, Requirement, Requirements, SUBSTRATE_REFERENCE_HARDWARE};
pub use hardware::SUBSTRATE_REFERENCE_HARDWARE;

/// Command to benchmark the hardware.
///
Expand Down