Validator payouts are lazy, and paged. Meaning for each era, and page of nominators (see MaxExposurePageSize), the reward needs to be claimed by calling Staking::payout_stakers.
Validators generally run a bot to claim these. They have HistoryDepth eras (84 eras in dotsama) after which these claims are dropped/become unavailable.
Probably the best place to schedule this is when a new era is triggered and we set the exposure for the validators.
Other requirements
The tasks should also keep track of pages. This can be as easy as, not remove validator from task until all pages of validator has been paid out.
We also need to have a way to make sure we don't just keep backfilling tasks while not having enough time to process them. I would suggest something like dropping tasks more than X=3 eras (where X is configurable) old.
Context
Validator payouts are lazy, and paged. Meaning for each era, and page of nominators (see MaxExposurePageSize), the reward needs to be claimed by calling Staking::payout_stakers.
Validators generally run a bot to claim these. They have HistoryDepth eras (84 eras in dotsama) after which these claims are dropped/become unavailable.
To Do
Utilize tasks to payout rewards.
Probably the best place to schedule this is when a new era is triggered and we set the exposure for the validators.
Other requirements
The tasks should also keep track of pages. This can be as easy as, not remove validator from task until all pages of validator has been paid out.
We also need to have a way to make sure we don't just keep backfilling tasks while not having enough time to process them. I would suggest something like dropping tasks more than X=3 eras (where X is configurable) old.
Related
https://github.com/paritytech/polkadot-sdk/issues/4630 is very similar to this issue.