mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Deprecate RewardDestination::Controller (#2380)
Deprecates `RewardDestination::Controller` variant. - [x] `RewardDestination::Controller` annotated with `#[deprecated]`. - [x] `Controller` variant is now handled the same way as `Stash` in `payout_stakers`. - [x] `set_payee` errors if `RewardDestination::Controller` is provided. - [x] Added `update_payee` call to lazily migrate `RewardDestination::Controller` `Payee` storage entries to `RewardDestination::Account(controller)` . - [x] `payout_stakers_dead_controller` has been removed from benches & weights - was not used. - [x] Tests no longer use `RewardDestination::Controller`. --------- Co-authored-by: command-bot <> Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: georgepisaltu <52418509+georgepisaltu@users.noreply.github.com>
This commit is contained in:
@@ -464,16 +464,28 @@ benchmarks! {
|
||||
}
|
||||
|
||||
set_payee {
|
||||
let (stash, controller) = create_stash_controller::<T>(USER_SEED, 100, Default::default())?;
|
||||
let (stash, controller) = create_stash_controller::<T>(USER_SEED, 100, RewardDestination::Staked)?;
|
||||
assert_eq!(Payee::<T>::get(&stash), RewardDestination::Staked);
|
||||
whitelist_account!(controller);
|
||||
}: _(RawOrigin::Signed(controller), RewardDestination::Controller)
|
||||
}: _(RawOrigin::Signed(controller.clone()), RewardDestination::Account(controller.clone()))
|
||||
verify {
|
||||
assert_eq!(Payee::<T>::get(&stash), RewardDestination::Controller);
|
||||
assert_eq!(Payee::<T>::get(&stash), RewardDestination::Account(controller));
|
||||
}
|
||||
|
||||
update_payee {
|
||||
let (stash, controller) = create_stash_controller::<T>(USER_SEED, 100, RewardDestination::Staked)?;
|
||||
Payee::<T>::insert(&stash, {
|
||||
#[allow(deprecated)]
|
||||
RewardDestination::Controller
|
||||
});
|
||||
whitelist_account!(controller);
|
||||
}: _(RawOrigin::Signed(controller.clone()), controller.clone())
|
||||
verify {
|
||||
assert_eq!(Payee::<T>::get(&stash), RewardDestination::Account(controller));
|
||||
}
|
||||
|
||||
set_controller {
|
||||
let (stash, ctlr) = create_unique_stash_controller::<T>(9000, 100, Default::default(), false)?;
|
||||
let (stash, ctlr) = create_unique_stash_controller::<T>(9000, 100, RewardDestination::Staked, false)?;
|
||||
// ensure `ctlr` is the currently stored controller.
|
||||
assert!(!Ledger::<T>::contains_key(&stash));
|
||||
assert!(Ledger::<T>::contains_key(&ctlr));
|
||||
@@ -551,40 +563,6 @@ benchmarks! {
|
||||
assert_eq!(UnappliedSlashes::<T>::get(&era).len(), (MAX_SLASHES - s) as usize);
|
||||
}
|
||||
|
||||
payout_stakers_dead_controller {
|
||||
let n in 0 .. T::MaxExposurePageSize::get() as u32;
|
||||
let (validator, nominators) = create_validator_with_nominators::<T>(
|
||||
n,
|
||||
T::MaxExposurePageSize::get() as u32,
|
||||
true,
|
||||
true,
|
||||
RewardDestination::Controller,
|
||||
)?;
|
||||
|
||||
let current_era = CurrentEra::<T>::get().unwrap();
|
||||
// set the commission for this particular era as well.
|
||||
<ErasValidatorPrefs<T>>::insert(current_era, validator.clone(), <Staking<T>>::validators(&validator));
|
||||
|
||||
let caller = whitelisted_caller();
|
||||
let validator_controller = <Bonded<T>>::get(&validator).unwrap();
|
||||
let balance_before = T::Currency::free_balance(&validator_controller);
|
||||
for (_, controller) in &nominators {
|
||||
let balance = T::Currency::free_balance(controller);
|
||||
ensure!(balance.is_zero(), "Controller has balance, but should be dead.");
|
||||
}
|
||||
}: payout_stakers_by_page(RawOrigin::Signed(caller), validator, current_era, 0)
|
||||
verify {
|
||||
let balance_after = T::Currency::free_balance(&validator_controller);
|
||||
ensure!(
|
||||
balance_before < balance_after,
|
||||
"Balance of validator controller should have increased after payout.",
|
||||
);
|
||||
for (_, controller) in &nominators {
|
||||
let balance = T::Currency::free_balance(controller);
|
||||
ensure!(!balance.is_zero(), "Payout not given to controller.");
|
||||
}
|
||||
}
|
||||
|
||||
payout_stakers_alive_staked {
|
||||
let n in 0 .. T::MaxExposurePageSize::get() as u32;
|
||||
let (validator, nominators) = create_validator_with_nominators::<T>(
|
||||
|
||||
Reference in New Issue
Block a user