diff --git a/runtime/common/src/constants.rs b/runtime/common/src/constants.rs index fc3037a88beebd4757db116a097822ff588a345f..135e5bad62db4acbad6a182b07e128ca31d5aa24 100644 --- a/runtime/common/src/constants.rs +++ b/runtime/common/src/constants.rs @@ -69,7 +69,7 @@ pub fn block_weights( expected_block_weight: Weight, normal_ratio: sp_arithmetic::Perbill, ) -> frame_system::limits::BlockWeights { - let base_weight = DbWeight::get().reads(1) + DbWeight::get().writes(1); + let base_weight = crate::weights::extrinsic_weights::ExtrinsicBaseWeight::get(); let normal_weight = normal_ratio * expected_block_weight; frame_system::limits::BlockWeights::builder() .base_block(crate::weights::block_weights::BlockExecutionWeight::get()) diff --git a/runtime/common/src/weights.rs b/runtime/common/src/weights.rs index 4ba7c758564d5a17cd3c2a1a9cd81176196e8262..952423d90b95fdfacfd4f13e4faa6432b0b1e67c 100644 --- a/runtime/common/src/weights.rs +++ b/runtime/common/src/weights.rs @@ -20,6 +20,7 @@ #![allow(clippy::unnecessary_cast)] pub mod block_weights; +pub mod extrinsic_weights; pub mod frame_system; pub mod pallet_babe; pub mod pallet_balances; diff --git a/runtime/common/src/weights/extrinsic_weights.rs b/runtime/common/src/weights/extrinsic_weights.rs new file mode 100644 index 0000000000000000000000000000000000000000..de39f7a43019778c932c81b4e6acf7c30aa4f4ac --- /dev/null +++ b/runtime/common/src/weights/extrinsic_weights.rs @@ -0,0 +1,63 @@ + +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-19 (Y/M/D) +//! HOSTNAME: `benjamin-xps139380`, CPU: `Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz` +//! +//! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Development` +//! WARMUPS: `10`, REPEAT: `100` +//! WEIGHT-PATH: `runtime/common/src/weights/` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` + +// Executed Command: +// target/release/duniter +// benchmark +// overhead +// --chain=gdev-benchmark +// --execution=wasm +// --wasm-execution=compiled +// --weight-path=runtime/common/src/weights/ +// --warmup=10 + +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_PER_NANOS, Weight}; + +parameter_types! { + /// Time to execute a NO-OP extrinsic, for example `System::remark`. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. + /// + /// Stats nanoseconds: + /// Min, Max: 203_855, 206_882 + /// Average: 204_580 + /// Median: 204_521 + /// Std-Dev: 405.03 + /// + /// Percentiles nanoseconds: + /// 99th: 205_581 + /// 95th: 205_130 + /// 75th: 204_772 + pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(204_580); +} + +#[cfg(test)] +mod test_weights { + use sp_weights::constants; + + /// Checks that the weight exists and is sane. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + let w = super::ExtrinsicBaseWeight::get(); + + // At least 10 µs. + assert!( + w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 10 µs." + ); + // At most 1 ms. + assert!( + w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 1 ms." + ); + } +}