-
Notifications
You must be signed in to change notification settings - Fork 336
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
Conversation
0d50af2
to
361ca58
Compare
@@ -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; |
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.
@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. :(
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 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...
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 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()); |
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 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.
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 looks like this was the case before this PR...
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 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 😆 )
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.
Changing my request changes
review, the weight issue was present before this PR so I think it can be handled separately.
What does it do?
uses
AtStake
storage to dispatch rewards instead ofAwardedPts
.What important points reviewers should know?
AtStake
storage is a superset ofAwardedPts
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?