-
Notifications
You must be signed in to change notification settings - Fork 44
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
Withdraw inactive stake before unstaking #583
base: main
Are you sure you want to change the base?
Conversation
When the validator is flagged as inactive, we try to unstake everything from it, but we accumulate some inactive stake when we merge stake accounts, this needs to be withdrawn even if it does not exceed the `MINIMUM_WITHDRAW_AMOUNT`.
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!
please take a look (https://github.com/lidofinance/solido/commits/v1_compute_budget) at commits starting at 22f3db7 and to the end. This is a cumulative update of v1 maintainer that includes lots of recent bug fixes also the one that caused a crash after validator deactivation - we need it to be deployed to be able to migrate to v2 |
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.
I tested this commit and it does not do what we expect
Lamports(0) | ||
}; | ||
|
||
if expected_difference_stake > minimum_withdraw_amount || removed_unstake > Lamports(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.
this will not pass if validator is inactive
if expected_difference_stake > minimum_withdraw_amount
minimum_withdraw_amount
would be 0 also as expected_difference_stake
, so 0 > 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?
if validator is inactive
Let’s distinguish two things. There is the .active
field on Validator
. And there are the stake accounts. The case that was failing happens when the active
field is false
, 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, then expected_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
When the validator is flagged as inactive, we try to unstake everything from it, but we accumulate some inactive stake when we merge stake accounts, this needs to be withdrawn even if it does not exceed the
MINIMUM_WITHDRAW_AMOUNT
.