diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index c96ec20..6227265 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-common" -version = "0.4.6" +version = "0.4.7" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index d24c55a..1918e72 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -30,14 +30,14 @@ pub use sp_runtime::BuildStorage; pub use impls::ToAuthor; -/// We assume that an on-initialize consumes 30% of the weight on average, hence +/// We assume that an on-initialize consumes 10% of the weight on average, hence /// a single extrinsic will not be allowed to consume more than -/// `AvailableBlockRatio - 30%`. -pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(30); +/// `AvailableBlockRatio - 10%`. +pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); -/// We allow `Normal` extrinsics to fill up the block up to 60%, the rest can +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can /// be used by `Operational` extrinsics. -pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(60); +pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); /// We allow for 4 seconds of compute with a 12 seconds average block time. /// The storage proof size is not limited so far. @@ -112,19 +112,19 @@ macro_rules! impl_runtime_weights { .for_class(DispatchClass::all(), |weights| { weights.base_extrinsic = $runtime::weights::ExtrinsicBaseWeight::get(); }) - .for_class(DispatchClass::Normal, |weights| { - weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); - }) - .for_class(DispatchClass::Operational, |weights| { - weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); - // Operational transactions have an extra reserved space, so that they - // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. - weights.reserved = Some( - MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT, - ); - }) - .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) - .build_or_panic(); + .for_class(DispatchClass::Normal, |weights| { + weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); + }) + .for_class(DispatchClass::Operational, |weights| { + weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); + // Operational transactions have an extra reserved space, so that they + // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. + weights.reserved = Some( + MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT, + ); + }) + .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) + .build_or_panic(); } }; } @@ -138,8 +138,8 @@ static_assertions::assert_eq_size!(primitives::Balance, u128); /// A reasonable benchmarking config for staking pallet. pub struct StakingBenchmarkingConfig; impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig { - type MaxValidators = ConstU32<500>; - type MaxNominators = ConstU32<10_000>; + type MaxValidators = ConstU32<299>; // MaxActiveValidators: u32 = 300 + type MaxNominators = ConstU32<3_000>; } /// Convert a balance to an unsigned 256-bit number, use in nomination pools. diff --git a/runtime/common/src/weights/block_weights.rs b/runtime/common/src/weights/block_weights.rs deleted file mode 100644 index 8ebd38b..0000000 --- a/runtime/common/src/weights/block_weights.rs +++ /dev/null @@ -1,27 +0,0 @@ -use sp_core::parameter_types; -use sp_weights::{constants::WEIGHT_PER_TIME_PER_NANOS, Weight}; - -parameter_types! { - pub const BlockExecutionWeight: Weight = - Weight::from_ref_time(WEIGHT_PER_TIME_PER_NANOS.saturating_mul(7_955_558)); -} - -#[cfg(test)] -mod test_weights { - use sp_weights::constants; - - #[test] - fn sane() { - let w = super::BlockExecutionWeight::get(); - - assert!( - w.ref_time() >= 5u64 * constants::WEIGHT_PER_TIME_PER_MICROS, - "Weight should be at least 5 µs." - ); - - assert!( - w.ref_time() <= 12u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, - "Weight should be at most 12 ms." - ); - } -} diff --git a/runtime/common/src/weights/extrinsic.rs b/runtime/common/src/weights/extrinsic.rs deleted file mode 100644 index 61bc9cc..0000000 --- a/runtime/common/src/weights/extrinsic.rs +++ /dev/null @@ -1,28 +0,0 @@ -use sp_core::parameter_types; -use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight}; - -parameter_types! { - pub const ExtrinsicBaseWeight: Weight = - Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(94_914)); -} - -#[cfg(test)] -mod test_weights { - use frame_support::traits::Get; - use sp_weights::constants; - - #[test] - fn sane() { - let w = super::ExtrinsicBaseWeight::get(); - - assert!( - w.ref_time() >= 70u64 * constants::WEIGHT_REF_TIME_PER_MICROS, - "Weight should be at least 70 µs." - ); - - assert!( - w.ref_time() <= 120u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, - "Weight should be at most 120 ms." - ); - } -} diff --git a/runtime/common/src/weights/mod.rs b/runtime/common/src/weights/mod.rs deleted file mode 100644 index 34966c6..0000000 --- a/runtime/common/src/weights/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod block_weights; -pub mod extrinsic_weight; - -pub use block_weights::BlockExecutionWeight; -pub use extrinsic_weights::ExtrinsicBaseWeight;