Skip to content

Commit

Permalink
[pallet-staking] Add page info to PayoutStarted event (#5984)
Browse files Browse the repository at this point in the history
fixes #5966

---------

Co-authored-by: Guillaume Thiolliere <[email protected]>
  • Loading branch information
Ank4n and gui1117 authored Nov 7, 2024
1 parent 12d9052 commit 8c146a7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
14 changes: 14 additions & 0 deletions prdoc/pr_5984.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Add page information to staking::PayoutStarted event

doc:
- audience: Runtime User
description: |
Adds page index that is claimed, and optional next page that can be claimed. If next is none, then the page is the
last one.

crates:
- name: pallet-staking
bump: major
2 changes: 2 additions & 0 deletions substrate/frame/staking/src/pallet/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ impl<T: Config> Pallet<T> {
Self::deposit_event(Event::<T>::PayoutStarted {
era_index: era,
validator_stash: stash.clone(),
page,
next: EraInfo::<T>::get_next_claimable_page(era, &stash, &ledger),
});

let mut total_imbalance = PositiveImbalanceOf::<T>::zero();
Expand Down
9 changes: 7 additions & 2 deletions substrate/frame/staking/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,13 @@ pub mod pallet {
StakingElectionFailed,
/// An account has stopped participating as either a validator or nominator.
Chilled { stash: T::AccountId },
/// The stakers' rewards are getting paid.
PayoutStarted { era_index: EraIndex, validator_stash: T::AccountId },
/// A Page of stakers rewards are getting paid. `next` is `None` if all pages are claimed.
PayoutStarted {
era_index: EraIndex,
validator_stash: T::AccountId,
page: Page,
next: Option<Page>,
},
/// A validator has set their preferences.
ValidatorPrefsSet { stash: T::AccountId, prefs: ValidatorPrefs },
/// Voters size limit reached.
Expand Down
6 changes: 4 additions & 2 deletions substrate/frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3978,6 +3978,7 @@ fn test_multi_page_payout_stakers_by_page() {
assert!(matches!(
staking_events_since_last_call().as_slice(),
&[
Event::PayoutStarted { era_index: 1, validator_stash: 11, page: 0, next: Some(1) },
..,
Event::Rewarded { stash: 1063, dest: RewardDestination::Stash, amount: 111 },
Event::Rewarded { stash: 1064, dest: RewardDestination::Stash, amount: 111 },
Expand All @@ -4001,7 +4002,7 @@ fn test_multi_page_payout_stakers_by_page() {
assert!(matches!(
events.as_slice(),
&[
Event::PayoutStarted { era_index: 1, validator_stash: 11 },
Event::PayoutStarted { era_index: 1, validator_stash: 11, page: 1, next: None },
Event::Rewarded { stash: 1065, dest: RewardDestination::Stash, amount: 111 },
Event::Rewarded { stash: 1066, dest: RewardDestination::Stash, amount: 111 },
..
Expand Down Expand Up @@ -8011,7 +8012,8 @@ mod ledger_recovery {
assert_eq!(asset::staked::<Test>(&333), lock_333_before); // OK
assert_eq!(Bonded::<Test>::get(&333), Some(444)); // OK
assert!(Payee::<Test>::get(&333).is_some()); // OK
// however, ledger associated with its controller was killed.

// however, ledger associated with its controller was killed.
assert!(Ledger::<Test>::get(&444).is_none()); // NOK

// side effects on 444 - ledger, bonded, payee, lock should be completely removed.
Expand Down

0 comments on commit 8c146a7

Please sign in to comment.