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.
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 available stake #441
base: master
Are you sure you want to change the base?
Withdraw available stake #441
Changes from 8 commits
da13df2
2267dde
67e9d07
7bc4fe9
115a662
265faf7
f9ede8e
a89030f
2db734a
290a620
7123c42
7f51740
574ce66
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
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.
I made change to get the
from_rent_exempt_minimum
withSpendAmount::Available
case.Then I subtract from the balance 👍
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.
Is this issue still open intentionally? I'm looking for ways to pitch in, but don't want to duplicate efforts.
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.
Unfortunately, there's one more way this is broken.
Currently, the stake program takes a conservative approach to partially activated accounts.
agave/programs/stake/src/stake_state.rs
Lines 742 to 745 in 025ed45
In other words, if a stake account has some active stake, the entire delegation at the point when it started delegating is locked to withdrawals, even if some of it is still activating over multiple epochs.
The fix here is to also subtract
state.activating_stake.unwrap_or_default()
Sorry for not catching this sooner; in truth, we ought to work up a series of withdrawal integration tests here, using
SpendAmount::Available
(andSpendAmount::All
) to catch all these edge cases. Please let me know if that's something you're interested/willing to work on.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.
No problem !
So when I have
Some state.active_stake
I need to also subtractactivating_stake
at L134?Regarding the stake account state I see other fields like
delegated_stake
deactivating_stake
. Is it something to take into consideration?About the integration tests, should it be done in this PR or in another one?
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.
No, when you have any activating_stake it needs to be subtracted. So this needs to happen outside of the
if let Some(active_stake)
case.No,
deactivating_stake
is already included inactive_stake
, anddelegated_stake
doesn't reflect activation or deactivation history.However, to understand all the fields better, I recommend you start with this method, and read upstream to
Delegation::stake_activating_and_deactivating()
If you are up for it in this PR, that would be best. That way we can be confident we are not merging any edge-case bugs.
Thank you!