Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

enriquefynn
Copy link
Member

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.

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`.
Copy link
Contributor

@ruuda ruuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kkonevets
Copy link
Collaborator

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

Copy link
Collaborator

@kkonevets kkonevets left a 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)
Copy link
Collaborator

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

Copy link
Contributor

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?

Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants