Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pallet-staking] Add page info to PayoutStarted event #5984

Merged
merged 9 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: minor
Ank4n marked this conversation as resolved.
Show resolved Hide resolved
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
5 changes: 3 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,7 @@ 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
Loading