-
Notifications
You must be signed in to change notification settings - Fork 44
Withdraw inactive stake before unstaking #583
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
Open
enriquefynn
wants to merge
1
commit into
main
Choose a base branch
from
withdraw_all_from_inactive_validator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 hidden or 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.
this will not pass if validator is inactive
if expected_difference_stake > minimum_withdraw_amount
minimum_withdraw_amount
would be 0 also asexpected_difference_stake
, so0 > 0
is false.Take a look here
We should recompute effective stake balance after stake merging
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.
Why would
expected_difference_stake
be zero?Let’s distinguish two things. There is the
.active
field onValidator
. And there are the stake accounts. The case that was failing happens when theactive
field isfalse
, but there is active stake in the stake accounts, which the maintainer tries to deactivate. So in this case,current_stake_balance
definitely greater than zero.effective_stake_balance
is the difference between the recorded balance in stake accounts (which will be greater than zero) and unstake accounts (which will still be zero). If there is excess stake to withdraw, thenexpected_difference_stake
is going to be greater than zero.Am I missing something?
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.
Did you test this commit? I did. After stakes are merged the effective stake balance does not change by itself. It is changed only in WithdrawInactiveStake, but this is what we try to call here. Merging two stakes does not account additional rent exempt amount