-
Notifications
You must be signed in to change notification settings - Fork 47
feat: staking payout refactor #384
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
Conversation
ntn-x2
left a comment
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.
It will probably look much easier to follow and understand once refactored, so we are on the right path 🙂
pallets/parachain-staking/src/lib.rs
Outdated
|
|
||
| // TODO: Benchmark, unit tests, docs | ||
| #[pallet::weight(0)] | ||
| pub fn claim_rewards_for(origin: OriginFor<T>, target: <T::Lookup as StaticLookup>::Source) -> DispatchResult { |
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.
Any specific reason why we would allow anyone to trigger a payout for anyone else? I still don't understand what would be the use case for this, if I want to have control over when I would claim my rewards. If I want to delegate, I could set up a proxy,
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.
IMO, the main reason would be to cleanup storage and consume tiny rewards that have not been claimed by potentially exited users. I understand that's a very unlikely scenario and each user has an incentive to claim their rewards.
Moreover, in frame staking this is also possible by triggering a payout for a validator which rewards their nominators as well.
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.
I am completely fine changing this and would be interested in @weichweich 's opinion.
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.
Yeah I think Parity does that because otherwise users would just forget and keep piling up stuff, I think. Which would be fine in our case if that is the assumption. But of course the downside is that I can't simply decide to trigger my reward at any time, because someone else inside my delegation pool might do it for me.
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's first start with the more restrictive version. We might be able to change that later if we feel the need for it.
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.
By more restrictive you are referring to Antonio's proposal, e.g. origins can only claim for themselves?
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.
Co-authored-by: Antonio <[email protected]>
* tests: 80% * feat: rm delegate_another_candidate and more * docs: remove deprecated weight * Apply suggestions from code review Co-authored-by: Antonio <[email protected]> Co-authored-by: Antonio <[email protected]>
…f/1930-staking-refactor-tmp
ntn-x2
left a comment
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.
I have one main question about the rewards for delegators. It seems to me they are incentivised to jump onboard right before some other event is supposed to happen (like a stake change or an inflation change). Is my understanding correct? Is that by design? Or am I missing something?
Co-authored-by: Antonio <[email protected]>
ntn-x2
left a comment
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.
LGTM!
b98a254 to
02eb407
Compare
|
@weichweich Please review when you have the time, thanks! |
weichweich
left a comment
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.
Looks good. I would say we can merge it as it is. I just have a few naming suggestions and the RewardCounter is a bit hard to understand. Maybe my suggestion could make this part a bit easier to understand?
The yearly inflation config update is moved from on_initialize to a call that can be called by anyone? Is there a reason for that?
weichweich
left a comment
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.
LGTM very beautiful PR. Love the links to the commits. Nice comments.
Co-authored-by: Albrecht <[email protected]>
fixes KILTProtocol/ticket#1930
Follow-up PRs
TLDR Description
claim_rewardswhich enables any signed origin to trigger a payout for themselvesLengthy Description
The proposed solution goes more into the direction of Substrate staking. Every time a collator authors a block, their rewards counter is incremented. The counter can be consumed to increment accumulated rewards. The rewards need to be actively claimed by the new
claim_rewards_forextrinsic.There are a lot of events which automatically consume the
RewardCounterand increment the accumulated rewards since the last actively requested payout:Background
The main reason for this refactor is that the current solution is not highly scalable as it inherently emits a
Rewardedevent for each address that gets rewarded. For the current configuration of delegators, this is rather unproblematic.Moreover, we currently enforce the taxable
Rewardedevent onto all stakers and it occurs very frequently. Therefore, it is quite a challenge to summarize all such events.TODO
Extrinsics
Checklist:
array[3]useget(3), ...)