Skip to content
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

Drain all AwardedPts after payouts #1880

Closed
wants to merge 2 commits into from

Conversation

notlesh
Copy link
Contributor

@notlesh notlesh commented Oct 19, 2022

What does it do?

Removes AtStake entries that didn't have a corresponding AwardedPts entry. This happens any time a collator produces no blocks for a round.

Note that this is done after the last payout is made.

What important points reviewers should know?

Is there something left for follow-up PRs?

What alternative implementations were considered?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

What value does it bring to the blockchain users?

@@ -1532,6 +1532,9 @@ pub mod pallet {
// clean up storage items that we no longer need
<DelayedPayouts<T>>::remove(paid_for_round);
<Points<T>>::remove(paid_for_round);
// remove any AtStake entries that are left over. this will happen any time a
// selected collator produces no blocks for the entire round.
<AtStake<T>>::iter_prefix(paid_for_round).drain().collect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use remove_prefix here to avoid reading the value in PoV.
https://crates.parity.io/frame_support/storage/types/struct.StorageDoubleMap.html#method.remove_prefix

Suggested change
<AtStake<T>>::iter_prefix(paid_for_round).drain().collect();
<AtStake<T>>::remove_prefix(paid_for_round, None);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I included this fix in #1878 since it's a pre-requisite for the migration.

@librelois
Copy link
Collaborator

@notlesh can we close this PR and merge #1878 instead?

@notlesh
Copy link
Contributor Author

notlesh commented Oct 19, 2022

Closing because #1878 includes this fix.

@notlesh notlesh closed this Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants