diff --git a/common/src/pallet_tests.rs b/common/src/pallet_tests.rs index 33baa9897cc..980481da4a1 100644 --- a/common/src/pallet_tests.rs +++ b/common/src/pallet_tests.rs @@ -251,7 +251,7 @@ macro_rules! impl_pallet_staking_inner { // 8 eras for unbonding pub const BondingDuration: u32 = 8; pub const SlashDeferDuration: u32 = 7; - pub const MaxExposurePageSize: u32 = 512; + pub const MaxExposurePageSize: u32 = 256; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); pub const HistoryDepth: u32 = 84; pub const MaxNominations: u32 = 16; diff --git a/runtime/vara/src/lib.rs b/runtime/vara/src/lib.rs index 14dd2784fa4..020dbcc7a1d 100644 --- a/runtime/vara/src/lib.rs +++ b/runtime/vara/src/lib.rs @@ -699,7 +699,7 @@ parameter_types! { pub const BondingDuration: sp_staking::EraIndex = 14; // 41 eras during which slashes can be cancelled (slightly less than 7 days) pub const SlashDeferDuration: sp_staking::EraIndex = 13; - pub const MaxExposurePageSize: u32 = 512; + pub const MaxExposurePageSize: u32 = 256; // Note: this is not really correct as Max Nominators is (MaxExposurePageSize * page_count) but // this is an unbounded number. We just set it to a reasonably high value, 1 full page // of nominators. diff --git a/runtime/vara/src/tests.rs b/runtime/vara/src/tests.rs index 73a16b621e4..90278d5b260 100644 --- a/runtime/vara/src/tests.rs +++ b/runtime/vara/src/tests.rs @@ -18,13 +18,16 @@ use super::*; use crate::Runtime; -use frame_support::traits::StorageInstance; +use frame_support::{dispatch::GetDispatchInfo, traits::StorageInstance}; +use frame_system::limits::WeightsPerClass; use gear_core::costs::LazyPagesCosts; use pallet_gear::{InstructionWeights, MemoryWeights, SyscallWeights}; +use pallet_staking::WeightInfo as _; use runtime_common::weights::{ check_instructions_weights, check_lazy_pages_costs, check_pages_costs, check_syscall_weights, PagesCosts, }; +use sp_runtime::AccountId32; #[cfg(feature = "dev")] #[test] @@ -71,6 +74,38 @@ fn bridge_session_timer_is_correct() { ); } +#[test] +fn payout_stakers_fits_in_block() { + let expected_weight = + ::WeightInfo::payout_stakers_alive_staked( + ::MaxExposurePageSize::get(), + ); + + let call: ::RuntimeCall = + RuntimeCall::Staking(pallet_staking::Call::payout_stakers { + validator_stash: AccountId32::new(Default::default()), + era: Default::default(), + }); + + let dispatch_info = call.get_dispatch_info(); + + assert_eq!(dispatch_info.class, DispatchClass::Normal); + assert_eq!(dispatch_info.weight, expected_weight); + + let block_weights = ::BlockWeights::get(); + + let normal_class_weights: WeightsPerClass = + block_weights.per_class.get(DispatchClass::Normal).clone(); + + let normal_ref_time = normal_class_weights + .max_extrinsic + .unwrap_or(Weight::MAX) + .ref_time(); + let base_weight = normal_class_weights.base_extrinsic.ref_time(); + + assert!(normal_ref_time - base_weight > expected_weight.ref_time()); +} + #[test] fn normal_dispatch_length_suits_minimal() { const MB: u32 = 1024 * 1024;