program: Updates for better 1 SOL minimum delegation support#756
program: Updates for better 1 SOL minimum delegation support#756joncinque wants to merge 5 commits into
Conversation
| && u64::from(preferred_validator_info.active_stake_lamports) | ||
| >= minimum_lamports_with_tolerance |
There was a problem hiding this comment.
I think >= is correct here, since if the stake account has exactly minimum_lamports_with_tolerance, it should be possible to withdraw a stake account
There was a problem hiding this comment.
I agree, that >= is correct, but it is inconsistent with our previous check on has_withdrawable_active_stake, as there we check that it is >.
So we can get into the situation, that preferred_validator_info.active_stake_lamports == minimum_lamports_with_tolerance and this guard will fire. But actually withdrawing this amount will not take the same path, as the has_withdrawable_active_stake is false for preferred_validator , so it will go into validator removal, which is not actually necessary as far as I see.
|
#757 will fix the audit failure |
3713760 to
1d2b801
Compare
Problem
The version of solana-program-test used by the repo doesn't properly add the BPF version of the stake program in tests -- if you take the current main branch, use the BPF stake program currently on mainnet, and run the tests, you'll see the minimum delegation reported is just 1 lamport.
On top of that, with the 1 SOL minimum delegation, the minimum limits used during
withdraw_staketo figure out if one of the edge cases apply is too strict. It currently requires that the stake account withdrawn from has at leastrent_exemption + minimum_delegation + 1, assuming that we can split 1 lamport from a stake account.Since we need to split at least 1 SOL, we can have a situation where a stake account has
rent_exemption + 1_999_999_999lamports. The stake pool program forces you to withdraw from that account, but it isn't possible.Summary of changes
The first two commits just bump everything to the newest dependencies, update the stake program fixture, and use it correctly in program-test. Note that we have to use v4.1 because of the incompatible wincode bump in the SDK.
After that, modify
withdraw_staketo use a looser bound ofrent_exemption + minimum_delegation * 2 + lamports_per_pool_tokenas the limit where a user can withdraw from transient accounts / remove validators.Only one existing test is tripped by the new behavior, so fix that, and add a new one.