-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[do not merge] Decouple rewards from ledger #13023
Conversation
/cmd queue -c bench-bot $ pallet dev pallet_staking |
@Ank4n https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2213163 was started for your command Comment |
@Ank4n Command |
@@ -273,6 +263,26 @@ impl<T: Config> Pallet<T> { | |||
<Ledger<T>>::insert(controller, ledger); | |||
} | |||
|
|||
fn get_era_reward_points( |
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.
fn get_era_reward_points( | |
fn temp_get_era_reward_points( |
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.
since this can be removed later, right?
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 mostly good, but I want to give it an in-depth review later. Also want to look into the tests again. Would be good if you revise the tests as well, as the existing ones might be mediocre at best.
While this PR will solve the existing issue of moving I will wait for comments/opinions but will probably close it in couple of days. |
Related to paritytech/polkadot-sdk#439.
This PR changes the way we prevent double claim for validator rewards. We keep track of
EraRewardPoints
for each validator for current era, and in subsequent eras, when validator reward is claimed, their reward points are dropped fromEraRewardPoints
.Since we store 84 eras of past reward claim history, in order to avoid doing a large migration (total nominator count * history_depth), we will do a lazy migration. After this change, no new data will be written to
StakingLedger.legacy_claimed_rewards
(renamed fromclaimed_rewards
). Instead for any era going forward, we will just drop theEraRewardPoints
for the validator as discussed above. When distributing rewards, we checkStakingLedger.legacy_claimed_rewards
to make sure if any past claim has been recorded there.After 84 eras. we can be fully confident that
StakingLedger.legacy_claimed_rewards
has no relevant history that we need to preserve and we can do a new migration to remove it from ledger as well as clean up the code.Tasks
claimed_rewards
is checked before paying out stakers.claimed_rewards
for new stakers.claimed_rewards
code, Tracker issue for cleaning up old non-paged exposure logic in staking pallet polkadot-sdk#433.