-
Notifications
You must be signed in to change notification settings - Fork 241
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
Domains staking: Epoch transition and Pending unlocks #1657
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a631690
finalize domain operator switch during the old domain epoch transition
vedhavyas 2838994
ability to unlock operator at specific domain block number
vedhavyas 226070e
finalize the operators deregistration
vedhavyas cdccaf8
define error type for epoch transitions
vedhavyas ab875d8
add operator withdrawal finalization at epoch and adjust the Operator…
vedhavyas 0b4aed5
operator deposit finalization at the end od epoch
vedhavyas 15138e5
add domain epoch finalization and begins next epoch
vedhavyas 0c07426
unlock all the pending operators and nomination withdrawals
vedhavyas e45668e
track operator balances within staking summary for easier proof verif…
vedhavyas 5be738f
process all operator related info and then remove the operator once u…
vedhavyas beb4f72
Merge branch 'main' into domains/epoch_transition
vedhavyas 3d7e79a
Merge branch 'main' into domains/epoch_transition
vedhavyas 648b9bb
Merge branch 'main' into domains/epoch_transition
vedhavyas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 may not need to update these 2 variables in every iteration if we introduce a
remaining_stake
and update it instead which is also more straightforward IMHO, non-blocker.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
total_stake
here will act asremaining_stake
at the end. As for thetotal_shares
, not sure what you mean here. We would still need track the remaining shares to calculate the nominator's stake. Am I missing something here ?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 I mean was something like this:
Currently, we updating
total_stake
andtotal_share
and using them to calculatenominator_staked_amount
at the same time, it is not straightforward to see the calculation is correct IMO.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.
That is incorrect. You suggestion does not account for shares that are burned. If you don't update the shares, then
nominator_share
will be always be incorrect.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 do you mean by burned shares? If there are 10 total shares and 2 nominators with 3 and 7 shares respectively, the
nominator_share
of them should be3/10
and7/10
, right?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.
Rounding loss can be captured by
remaining_stake
.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.
but it is not captured when calculating the nominator share. If that is possible, please give me an example here
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
remaining_stake
is initialized tototal_stake
said 100, for every nominator we deductnominator_staked_amount
(assume rounding loss is0.1
, the value will be19.9
,29.9
, and49.9
respectively) fromremaining_stake
, thus after all deduction theremaining_stake
left0.3
which is the rounding loss.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.
Yes that is what we get with the current implementation. But you are not calculating share_percentage of each nominator after every
depositWithdraw. You are assuming the share_percentage is not changing which is not true. Here we are calculating nominator's share_percentage after every withdrawal so that (total_shares_left/total_stake_remaining) are upto date instead of pre calculating them earlier to account for those small increments of percentage due to a rounding down in the previous withdrawalThere 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
share_percentage
is not (and should) changed even in current impl, the only calculation of share istotal_shares = total_shares.checked_sub((&nominator.shares))
which does not bring any rounding loss.But I do see the difference now, in the current impl nominators can get a cut of the rounding loss. In the above example, after the first nominator is processed, the
total_stake
becomes80.1
and the second nominator can withdraw80.1 * 3/8
while my proposal is100 * 3/10
and leave all rounding loss to treasury.