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

use AtStake to dispatch rewards instead of AwardedPts #1896

Merged
merged 12 commits into from
Nov 10, 2022

Conversation

nbaztec
Copy link
Contributor

@nbaztec nbaztec commented Oct 25, 2022

What does it do?

uses AtStake storage to dispatch rewards instead of AwardedPts.

What important points reviewers should know?

AtStake storage is a superset of AwardedPts hence guaranteed to be cleaned up if round length is >= TopSelected candidates.

Is there something left for follow-up PRs?

What alternative implementations were considered?

#1923 was considered to not change the existing behavior but we went with #1896 as it avoids an else block that is responsible for cleanup and easily missed.

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

What value does it bring to the blockchain users?

@nbaztec nbaztec added B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Oct 25, 2022
@nbaztec nbaztec requested review from crystalin, 4meta5 and notlesh and removed request for crystalin and 4meta5 November 3, 2022 12:25
@@ -9061,7 +9121,7 @@ fn test_on_initialize_weights() {
//
// following this assertion, we add individual weights together to show that we can
// derive this number independently.
let expected_on_init = 3_017_871_000;
let expected_on_init = 2_506_497_000;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@notlesh This is the second time I've had to touch this test and honestly the only thing I do is make the number match the expectation. Could we somehow improve the test so it doesn't require us to update the magic number all the time? I'm afraid that we'd just ignore the failure and always update numbers without realizing what actually went down.

In my case, admittedly, I'd started adding the weight from auto-compounding to extra_weight, and here changed the execution behavior. Even though I knew in both cases what changed I couldn't come up with a good magic number value. :(

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that it's annoying. The point of it is so that we don't accidentally change the overall weight of on_init without realizing it. If you can think of a better way to accomplish that, I'm all for it.

Otherwise I think we could discuss whether it is worth having it at all. I like it for the reason above, but not enough that it should annoy everyone :)

While we're on the subject, I'm surprised that the amount decreased so much...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I wondered about that, my guess was the removal of clear_prefix here.

@@ -1557,22 +1559,25 @@ pub mod pallet {
// 2. we called pay_one_collator_reward when we were actually done with deferred
// payouts
log::warn!("pay_one_collator_reward called with no <Points<T>> for the round!");
return (None, Weight::zero());
return (RewardPayment::Finished, Weight::zero());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this weight fails to capture the <Points<T>> read above, and that may be true for weights returned in other places in this fn.

Copy link
Contributor

Choose a reason for hiding this comment

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

...it looks like this was the case before this PR...

Copy link
Contributor

@notlesh notlesh left a comment

Choose a reason for hiding this comment

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

LGTM except for a couple issues with the weights in pay_one_collator_reward (to be fair, it was probably me that introduced those to begin with 😆 )

Copy link
Contributor

@notlesh notlesh left a comment

Choose a reason for hiding this comment

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

Changing my request changes review, the weight issue was present before this PR so I think it can be handled separately.

@notlesh notlesh added D1-audited👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Dec 14, 2022
imstar15 pushed a commit to AvaProtocol/moonbeam that referenced this pull request May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D1-audited👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants