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

[mtg-577] Add decrease rewards penalty instruction #42

Merged
merged 2 commits into from
Sep 6, 2024

Conversation

kstepanovdev
Copy link
Collaborator

No description provided.

@kstepanovdev kstepanovdev requested a review from StanChe September 5, 2024 10:01
@kstepanovdev kstepanovdev self-assigned this Sep 5, 2024
Copy link
Collaborator

@StanChe StanChe left a comment

Choose a reason for hiding this comment

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

Great job! Some comments would really help.

.share
.safe_sub(decreased_weighted_stake_number)?;

for (_, stake_diff) in self.weighted_stake_diffs.iter_mut().rev() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

A little comment on what's going on here is much appreciated. As far as I got it - we go backwards through the rbtree and update the last diff to apply penalty.

.safe_sub(decreased_weighted_stake_number)?;

for (_, stake_diff) in self.weighted_stake_diffs.iter_mut().rev() {
if stake_diff > &mut decreased_weighted_stake_number {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if stake_diff > &mut decreased_weighted_stake_number {
if stake_diff >= &mut decreased_weighted_stake_number {

@kstepanovdev kstepanovdev merged commit efbce88 into penalties/slashing Sep 6, 2024
3 checks passed
@kstepanovdev kstepanovdev deleted the penalties/decrease-rewards branch September 6, 2024 12:05
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.

2 participants