diff --git a/pallets/staking/src/lib.rs b/pallets/staking/src/lib.rs index 523d5431b..76af74d3b 100644 --- a/pallets/staking/src/lib.rs +++ b/pallets/staking/src/lib.rs @@ -539,12 +539,13 @@ pub mod pallet { pub fn new_session_handler( validators: &[::ValidatorId], ) -> Result { - let mut weight: Weight = ::WeightInfo::new_session_base_weight(); - let mut current_signers = Self::signers(); let current_signers_length = current_signers.len(); let signers_info = pallet_parameters::Pallet::::signers_info(); + let mut weight: Weight = + ::WeightInfo::new_session_base_weight(current_signers_length as u32); + // Since not enough validators do not allow rotation // TODO: https://github.com/entropyxyz/entropy-core/issues/943 if validators.len() <= current_signers_length { diff --git a/pallets/staking/src/weights.rs b/pallets/staking/src/weights.rs index 704bb3468..25be1c558 100644 --- a/pallets/staking/src/weights.rs +++ b/pallets/staking/src/weights.rs @@ -59,7 +59,7 @@ pub trait WeightInfo { fn declare_synced() -> Weight; fn confirm_key_reshare_confirmed(c: u32) -> Weight; fn confirm_key_reshare_completed() -> Weight; - fn new_session_base_weight() -> Weight; + fn new_session_base_weight(s: u32) -> Weight; fn new_session(c: u32, l: u32) -> Weight; } @@ -194,14 +194,15 @@ impl WeightInfo for SubstrateWeight { } /// Storage: `StakingExtension::Signers` (r:1 w:0) /// Proof: `StakingExtension::Signers` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - fn new_session_base_weight() -> Weight { + fn new_session_base_weight(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `234` - // Estimated: `1719` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(4_000_000, 0) - .saturating_add(Weight::from_parts(0, 1719)) - .saturating_add(T::DbWeight::get().reads(1)) + // Measured: `254 + s * (32 ±0)` + // Estimated: `1739 + s * (32 ±0)` + // Minimum execution time: 7_000_000 picoseconds. + Weight::from_parts(7_682_879, 0) + .saturating_add(Weight::from_parts(0, 1739)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(Weight::from_parts(0, 32).saturating_mul(s.into())) } /// Storage: `StakingExtension::Signers` (r:1 w:0) /// Proof: `StakingExtension::Signers` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -366,14 +367,15 @@ impl WeightInfo for () { } /// Storage: `StakingExtension::Signers` (r:1 w:0) /// Proof: `StakingExtension::Signers` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - fn new_session_base_weight() -> Weight { + fn new_session_base_weight(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `234` - // Estimated: `1719` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(4_000_000, 0) - .saturating_add(Weight::from_parts(0, 1719)) - .saturating_add(RocksDbWeight::get().reads(1)) + // Measured: `254 + s * (32 ±0)` + // Estimated: `1739 + s * (32 ±0)` + // Minimum execution time: 7_000_000 picoseconds. + Weight::from_parts(7_682_879, 0) + .saturating_add(Weight::from_parts(0, 1739)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(Weight::from_parts(0, 32).saturating_mul(s.into())) } /// Storage: `StakingExtension::Signers` (r:1 w:0) /// Proof: `StakingExtension::Signers` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)