Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Lazy payouts #4407

Closed
gavofyork opened this issue Dec 17, 2019 · 5 comments · Fixed by #4474
Closed

Lazy payouts #4407

gavofyork opened this issue Dec 17, 2019 · 5 comments · Fixed by #4474
Labels
J0-enhancement An additional feature request.
Milestone

Comments

@gavofyork
Copy link
Member

gavofyork commented Dec 17, 2019

Currently, all payouts from an era are made actively at the end of the era. This is a big task and will only get worse as time goes on and the validator/nominator sets grow. Right now it takes so long that it's stalling the Kusama chain (#4313). It is also problematic as the immediacy conflicts with the fact that the session keys lag one session behind the actual staking selection, leading to the wrong validators being paid for one session in every era where the validation set changes (#4331, #4346 and #4220).

Instead, payouts should happen lazily/passively.

The Session module should, at the end of a session, report the accrued points of each validator together with the era number that the validator set is from back up to the Staking module, giving it full information about which validators should be rewarded. (It should explicitly report so that the number of sessions that the validator set lags behind continues to be immaterial for the Staking module.)

The Staking module should should retain a last_payout_era value for all staked accounts, and should keep a number of past instances of the exposure information on-chain (e.g. last 100 eras) as well as the historical validator points for each session.

There should then be an explicit payout function which pays out any balance owed, taking into account all of the above information. Stakers would need to call it occasionally (at least once every 100 eras =~ 2 weeks on Kusama) to avoid missing out on their rewards.

This will fix #4121, #4331, and #4220 as well as help with #4313 . This fix will supersede #4346.

@gavofyork gavofyork added the J0-enhancement An additional feature request. label Dec 17, 2019
@gavofyork gavofyork added this to the 3.0 milestone Dec 17, 2019
@gavofyork
Copy link
Member Author

CC @thiolliere

@joepetrowski
Copy link
Contributor

Stakers would need to call it occasionally

Do you expect nominators to have to take any action, or do you only refer to validators here? I read this as validators only (triggering a payment to all their nominators) because:

  1. Nomination should be relatively frictionless once you've made the nomination and you're already putting a lot of trust into the validators you nominate. Trusting them to call this function isn't a big stretch.
  2. Letting nominators call this would require calling this function on every validator that is backed by the nominator and keeping tabs on when validators paid each nominator.

That said, perhaps nominators should have a final appeal? E.g. if the limit is 100 eras, then a nominator can report a single validator after 90 eras and claim their reward share from that validator.

@rphmeier
Copy link
Contributor

rphmeier commented Dec 17, 2019

Doing payouts lazily/passively is that it conflicts with rewards accruing onto the stash's bond. If we do it lazily, it would allow validators or nominators to dodge part of slashes.

Let's say you have accrued X DOTs of potential rewards. If you trigger these rewards before an era in which you misbehave, you will be slashed out of prior_balance + reward, because it was accounted for in the election.

If you trigger those rewards after the era where you're slashed, you'll be slashed only out of prior_balance.

I don't see any easy workaround for this problem; it increases the complexity of the slashing code substantially because you would have to find a way to track the slashed portion of the potential reward across all slashing spans.

@gavofyork
Copy link
Member Author

i don't think it will matter in practise. the maximum amount of funds that would not be slashed will be around 4% of the annual (2 weeks/52 weeks), or, assuming 10% reward, 0.4% of your stake. that won't make much of a difference in terms of incentivisation.

@gavofyork
Copy link
Member Author

Stakers would need to call it occasionally

Do you expect nominators to have to take any action

I chose my wording carefully. "Stakers".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants