-
Notifications
You must be signed in to change notification settings - Fork 50
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
shield: implement reimbursement for shield claim proposals #132
Conversation
Codecov Report
@@ Coverage Diff @@
## master #132 +/- ##
==========================================
+ Coverage 53.76% 53.78% +0.01%
==========================================
Files 49 49
Lines 3383 3384 +1
==========================================
+ Hits 1819 1820 +1
Misses 1432 1432
Partials 132 132
|
// Update provider's collateral and total withdraw. | ||
provider.Collateral = provider.Collateral.Sub(payout) | ||
provider.Withdrawing = provider.Withdrawing.Sub(payoutFromWithdraw) | ||
|
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.
We could early return here if payoutFromWithdraw
is not positive.
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.
The check will be called once the for loop starts, so I think it's acceptable?
|
||
// Update unbonding delegations between the delegator and the validator. | ||
for i := range unbonding.Entries { | ||
if unbonding.Entries[i].Balance.Equal(ubd.Entries[0].Balance) && unbonding.Entries[i].CompletionTime.Equal(ubd.Entries[0].CompletionTime) { |
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.
what is this doing? why not if i == 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.
ubd
comes from GetSortedUnbondingDelegations()
so it only has one entry, while unbonding
comes from GetUnbondingDelegation
and has multiple entries. Their indices are thus different.
great! Thanks for the work. Considering the number of lines we added in for update 1, we'll need thorough testing until the release to ensure the numbers and logics are correct. 👍 |
* start reimplementation of ClaimLock * ClaimUnlock and RestoreShield * update purchase in ClaimLock * fix obvious errors * update collateral check logic * implement locking * restore claim proposal handler * clean code and fix obvious mistakes * add unbonding info field under withdraw * add unbonding info to withdrawals * add tests and add LockedCollateral type under Provider * delay only necessary amounts * error fix * add claim proposal sim * simulation restored and small bug fixes * implement loss portion-based claim process * fix obvious mistake * update total claimed correctly * fix init genesis * remove unnecessary comment * remove simapp * separate withdraw delay & unbonding delay * error fixes * fix index error * delete purchase queue entry 4 days after protection end time * fix init genesis error * fix purchase dequeue * revise dequeue purchase logic * revise dequeue pool purchaser pair logic * revert name change * comments addressed * additional changes not included in the last commit by mistake * revert securing purchased ratio and address comments * improve secure collateral logic * shield: implement reimbursement for shield claim proposals (#132) * Init reimbursement for claims. * Implemented basic workflow for reimbursement. * Added comments. * Enabled withdraws for reimbursements. * Updated according to latest doc. * Temp commit. Implementing payouts. * Finished skeleton of the new strategy. * Implemented paying by collateral. * Implemented paying from withdraws. * Implemented paying from unbondings. * Fixed an error caused by truncation errors. * Reorganized code to make logics clear. * Fixed PayFromUnbonding. * Fixed PayFromDelegation. * Update unbonding queue when an entry is removed. * Update delegated vesting for vesting accounts. * Fixed UndelegateShares. * Addressed comments. * Reverted some modifications to minimize changes. * A minor change. * Update the module account invariant. * Fixed an incorrect key for reimbursement. * Fixed incorrect collateral updates. * Consider total claimed in simulations. * gov: increase voters and yes votes in simulation (#141) * add debug prints * Update operations.go * remove debug prints * remove debug log * fix certifier voting * Made lint. Co-authored-by: Dan <dan.she@certik.io> * Fixed an incorrect index. * add new max shield consideration to all relevant operations * Fixed total withdraw update and temp disable param change sim in gov. * fix PayFromDelegation and staking source pool * Re-enabled param change sims in gov. To be fixed in another PR. * Fixed incorrect unbonding updates. * Added reimbursements in genesis. * Fixed incorrect payout update in UpdateProviderCollateralForPayout. * Updated descriptions in invariants. * Fixed account update, with debugging lines unremoved. * Update vested coins for manual vesting account in shield. * address most of the comments * Fixed manual vesting account update in shield. * Removed debugging lines. * Fixed simulations of creating pools. * remove vesting types other than manual in sim * shield: add query endpoints for reimbursements (#147) * delay unbonding only if necessary * disable staking param change * reverse iteration of timeslices * additional small fixes and addressing rest of the review comments * add withdraw reimbursement operation to sim * remove debug lines * Fixed simulations for withdrawing reimbursements. * Fixed some naming issues. Co-authored-by: Dan <57596823+dshe-certik@users.noreply.github.com> Co-authored-by: Dan <dan.she@certik.io> Co-authored-by: Ziyi Zhang <66639536+ziyi-zhang-1130@users.noreply.github.com> Co-authored-by: yoongbok-lee <52583590+yoongbok-lee@users.noreply.github.com>
Update master with public latest
Closes: #XXX
Related: #120
Description
Implemented reimbursement for shield claim proposals.
For contributor use:
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerFor admin use:
WIP
,R4R
,docs
, etc)