-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat!: simplify penalty handling logic #9
Conversation
when insurance is under 5.75% of chunk size, then un-delegate it. now we can make sure that during unbonding or re-delegation period, there must be no case where un-pairing insurance cannot cover penalty. remainings: * fix broken tests * remove re-delegation info's deletable and amt field * add tcs for new logics.
when calc penaltyAmt, must check shares value based on amt.
Those fields are introduced to cover the situation where unpairing ins at previous epoch cannot cover the penalty during re-delegation period. But now we check paired ins with IsEnoughToCoverSlash so we don't need PenaltyAmt and Deletable anymore. Because that scenario will not happen.
Codecov Report
@@ Coverage Diff @@
## liquidstaking-module #9 +/- ##
========================================================
- Coverage 71.62% 71.61% -0.02%
========================================================
Files 158 158
Lines 11123 11083 -40
========================================================
- Hits 7967 7937 -30
+ Misses 2871 2868 -3
+ Partials 285 278 -7
... and 6 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
* panic when validator is invalid (this must not happen) * remove empty branch * fix wrong calc in IsEnoughToCoverSlash feedbacks: * #9 (comment) * #9 (comment)
Of course. I'll rebase it after all comments are resolved. |
by adding IsEnoughToCoverSlash function, the edge cases we were previously worried about are gone. (unpairing ins at previous epoch cannot cover the penalty during re-delegation period). so comments and checking logics for that edge should be deleted as now.
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 fixed logics, please update spec and PR description ( downtime fraction part )
func (suite *KeeperTestSuite) TestQuoInt() { | ||
fmt.Println(sdk.NewDec(7).QuoInt(sdk.NewInt(9)).String()) | ||
fmt.Println(sdk.NewDec(7).Quo(sdk.NewDec(9)).String()) | ||
fmt.Println(sdk.NewDec(7).QuoTruncate(sdk.NewDec(9)).String()) | ||
fmt.Println(sdk.NewDec(7).QuoRoundUp(sdk.NewDec(9)).String()) | ||
fmt.Println(sdk.NewDec(7).Quo(sdk.NewDec(9)).String()) | ||
} |
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 seems like a temporary code added to the development process, so I think you can delete it
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.
Ooops. You are right. I'll delete it and update SPEC docs.
updated spec related with this pr remove tc created during test locally change function name of mustDelegate mustDelegatePenaltyAmt is more readable and meaningful
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 broken links, please merge when workflow passed after applied the suggestions
Co-authored-by: dongsam <dongsamb@gmail.com>
Co-authored-by: dongsam <dongsamb@gmail.com>
Description
when handle paired chunk, check whether paired insurance's balance >= 5.75% (
double_sign_fraction
+down_time_fraction
) or not.when calc penaltyAmt, must check shares value is decimal or integer. if it is decimal, then we must use ceiled value as penaltyAmt to fully cover pantly.
refactored some common code
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...