-
Notifications
You must be signed in to change notification settings - Fork 112
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
go/staking: Enable changing the reward schedule #5352
Conversation
1cf6265
to
ecba4bc
Compare
a13a11a
to
2271f4d
Compare
Codecov Report
@@ Coverage Diff @@
## master #5352 +/- ##
==========================================
+ Coverage 66.93% 67.58% +0.64%
==========================================
Files 525 525
Lines 55763 55772 +9
==========================================
+ Hits 37323 37691 +368
+ Misses 13909 13589 -320
+ Partials 4531 4492 -39
|
.changelog/5352.feature.md
Outdated
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.
This should be breaking.
go/staking/api/sanity_check.go
Outdated
if len(p.RewardSchedule) > 0 { | ||
var prevUntil beacon.EpochTime | ||
for _, step := range p.RewardSchedule { | ||
if step.Until < prevUntil { |
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.
Equality should probably also be disallowed?
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.
if step.Until < prevUntil { | |
if step.Scale.Cmp(Zero) == -1 || step.Scale.Cmp(RewardAmountDenominator) == 1 { | |
fmt.Errorf("reward scale needs to be a non-negative integer not greater than %d", RewardAmountDenominator) | |
} | |
if step.Until == beacon.EpochInvalid { | |
return fmt.Errorf("invalid epoch") | |
} | |
if step.Until <= prevUntil { |
Update tests also.
go/staking/api/sanity_check.go
Outdated
@@ -42,12 +42,24 @@ func (p *ConsensusParameters) SanityCheck() error { | |||
return fmt.Errorf("minimum commission %v/%v over unity", p.CommissionScheduleRules, CommissionRateDenominator) | |||
} | |||
|
|||
// Reward schedule steps must be sequential. | |||
if len(p.RewardSchedule) > 0 { |
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.
if len(p.RewardSchedule) > 0 { |
go/staking/api/sanity_check.go
Outdated
if len(p.RewardSchedule) > 0 { | ||
var prevUntil beacon.EpochTime | ||
for _, step := range p.RewardSchedule { | ||
if step.Until < prevUntil { |
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.
if step.Until < prevUntil { | |
if step.Scale.Cmp(Zero) == -1 || step.Scale.Cmp(RewardAmountDenominator) == 1 { | |
fmt.Errorf("reward scale needs to be a non-negative integer not greater than %d", RewardAmountDenominator) | |
} | |
if step.Until == beacon.EpochInvalid { | |
return fmt.Errorf("invalid epoch") | |
} | |
if step.Until <= prevUntil { |
Update tests also.
2271f4d
to
782345f
Compare
{10, *over}, | ||
}, | ||
} | ||
require.Error(r9.SanityCheck(), "reward schedule step scale should not be greater than the reward amount denominator") |
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 forgot to add that I'm not sure if this must be true.
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 makes sense to me -- can't give more than what is available for rewards, right? :)
This PR adds the ability to change the reward schedule in the staking consensus parameters through a governance vote. An additional e2e test for the rewards was also added.