-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Unlimited number of nominators eligible for Rewards payout #13059
Conversation
bot bench $ pallet dev pallet_staking |
@Ank4n https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2431168 was started for your command Comment |
@Ank4n Command |
bot bench $ runtime westend-dev pallet_staking |
@Ank4n |
bot cancel |
@Ank4n Command |
@@ -596,7 +597,7 @@ impl pallet_fast_unstake::Config for Runtime { | |||
type Staking = Staking; | |||
type MaxErasToCheckPerBlock = ConstU32<1>; | |||
#[cfg(feature = "runtime-benchmarks")] | |||
type MaxBackersPerValidator = MaxNominatorRewardedPerValidator; | |||
type MaxExposurePageSize = MaxExposurePageSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can come from T::Staking
, still feature gated ofc.
@@ -74,7 +74,7 @@ fn setup_staking<T: Config>(v: u32, until: EraIndex) { | |||
.collect::<Vec<_>>(); | |||
|
|||
for era in 0..=until { | |||
let others = (0..T::MaxBackersPerValidator::get()) | |||
let others = (0..T::MaxExposurePageSize::get()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let others = (0..T::MaxExposurePageSize::get()) | |
let others = (0..T::Staking::MaxExposurePageSize::get()) |
|
||
## [14] | ||
|
||
### Added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, much better.
I got couple of feedbacks about lot of noise in this PR caused by upstream merges. Created a new PR with rebased changes here. |
closes paritytech/polkadot-sdk#439 and paritytech/polkadot-sdk#473.
polkadot companion: paritytech/polkadot#6765
Context
Rewards payout is processed today in a single block and limited to
MaxNominatorRewardedPerValidator
. This number is currently512
on both Kusama and Polkadot.This PR tries to scale the nominators payout to an unlimited count in a multi-block fashion. Exposures are stored in pages, with each page capped to a certain number. Practically, this number would be the same as
MaxNominatorRewardedPerValidator
or lower.The PR also intends to be mostly backward compatible.
Note about the release
This PR introduces a new storage item
MaxExposurePageCount
which defaults to minimum value of1
when not set. This means functionally, the pallet will continue to work exactly as before after this release. To enable paged rewards payout,MaxExposurePageCount
can be increased to a bigger number by OpenGov for each runtime separately.How payouts would look like after this change
Staking exposes two calls, 1) the existing
payout_stakers
and 2)payout_stakers_by_page
.payout_stakers
This remains backward compatible with no signature change. If for a given era a validator has multiple pages, they can call
payout_stakers
multiple times. The pages are executed in an ascending sequence and the runtime takes care of preventing double claims.payout_stakers_by_page
Very similar to
payout_stakers
but also accepts an extra parampage_index
. An account can choose to payout rewards only for an explicitly passedpage
.Lets look at an example scenario.
Given an active validator on Kusama had 1100 nominators,
MaxExposurePageCount
set to 10 andMaxExposurePageSize
set to 512 for Erae
. In order to pay out rewards to all nominators, the caller would need to callpayout_stakers
3 times.payout_stakers(origin, stash, e)
=> will pay the first 512 nominators.payout_stakers(origin, stash, e)
=> will pay the second set of 512 nominators.payout_stakers(origin, stash, e)
=> will pay the last set of 76 nominators....
payout_stakers(origin, stash, e
) => calling it the 4th time would return an errorInvalidPage
.The above calls can also be replaced by
payout_stakers_by_page
and passing a page explicitly.Important to note
Storage Changes
Added
ErasStakersOverview
ClaimedRewards
ErasStakersPaged
Deprecated
The following can be cleaned up after 84 eras. Tracker issue for cleaning up.
ErasStakers
.ErasStakersClipped
.StakingLedger.claimed_rewards
, renamed toStakingLedger.legacy_claimed_rewards
.Config Changes
MaxNominatorRewardedPerValidator
toMaxExposurePageSize
.MaxExposurePageCount
TODO
MaxNominatorRewardedPerValidator
->MaxExposurePageSize
.Follow up issues