diff --git a/CHANGELOG.md b/CHANGELOG.md index f059d4705..2bd6a01b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ At the moment this project **does not** adhere to ## [[Unreleased]](https://github.com/entropyxyz/entropy-core/compare/release/v0.0.10...master) +### Added +- Add ValidatorSubgroupRotated event ([#618](https://github.com/entropyxyz/entropy-core/pull/618)) + ## [0.0.10](https://github.com/entropyxyz/entropy-core/compare/release/v0.0.9...release/v0.0.10) - 2024-01-24 A lot of the changes introduced in this release are program related. diff --git a/pallets/staking/src/benchmarking.rs b/pallets/staking/src/benchmarking.rs index e85457405..c25362a51 100644 --- a/pallets/staking/src/benchmarking.rs +++ b/pallets/staking/src/benchmarking.rs @@ -15,6 +15,7 @@ //! Benchmarking setup for pallet-propgation #![allow(unused_imports)] +use entropy_shared::SIGNING_PARTY_SIZE; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_support::{ assert_ok, ensure, @@ -178,7 +179,11 @@ benchmarks! { let current_validators = create_validators::(c, SEED); let new_validators = create_validators::(n, SEED_2); let _ =Staking::::new_session_handler(¤t_validators); - + let mut current_subgroups: Vec::ValidatorId>> = vec![]; + for signing_group in 0..SIGNING_PARTY_SIZE { + let current_subgroup = SigningGroups::::get(signing_group as u8).unwrap(); + current_subgroups.push(current_subgroup) + }; }: { let _ = Staking::::new_session_handler(&new_validators); } verify { @@ -188,6 +193,12 @@ benchmarks! { assert!(!new_validators.contains(&one_current_validator[0])); } } else { + let mut new_subgroups: Vec::ValidatorId>> = vec![]; + for signing_group in 0..SIGNING_PARTY_SIZE { + let new_subgroup = SigningGroups::::get(signing_group as u8).unwrap(); + new_subgroups.push(new_subgroup) + }; + assert_last_event::(Event::::ValidatorSubgroupsRotated(current_subgroups, new_subgroups).into()); assert!(new_validators.contains(&one_current_validator[0])); } } diff --git a/pallets/staking/src/lib.rs b/pallets/staking/src/lib.rs index 23d7b8f24..d467d2da9 100644 --- a/pallets/staking/src/lib.rs +++ b/pallets/staking/src/lib.rs @@ -239,6 +239,11 @@ pub mod pallet { NodeInfoRemoved(T::AccountId), /// Validator sync status changed [who, sync_status] ValidatorSyncStatus(::ValidatorId, bool), + /// Validators subgroups rotated [old, new] + ValidatorSubgroupsRotated( + Vec::ValidatorId>>, + Vec::ValidatorId>>, + ), } #[pallet::call] @@ -425,7 +430,6 @@ pub mod pallet { unplaced_validators_set.push(new_validator.clone()); } } - // Evenly distribute new validators. while let Some(curr) = unplaced_validators_set.pop() { let mut min_sg_len = u64::MAX; @@ -445,6 +449,10 @@ pub mod pallet { pallet_staking_extension::SigningGroups::::remove(sg as u8); pallet_staking_extension::SigningGroups::::insert(sg as u8, vs); } + Self::deposit_event(Event::ValidatorSubgroupsRotated( + curr_validators_set.clone(), + new_validators_set.clone(), + )); frame_system::Pallet::::register_extra_weight_unchecked( ::WeightInfo::new_session_handler_helper( curr_validators_set.len() as u32,