-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Raise stake minimum delegation to 1 SOL #24603
Raise stake minimum delegation to 1 SOL #24603
Conversation
51cc796
to
d38b4f8
Compare
d38b4f8
to
6bbdb7e
Compare
6bbdb7e
to
b55196c
Compare
b55196c
to
05c2981
Compare
05c2981
to
9002f63
Compare
9002f63
to
320dbb7
Compare
I still need to figure out local-cluster tests timing out, but I think this PR is in a good enough state to begin the review process. Thanks in advance, reviewers! |
mod old_behavior { | ||
use super::*; | ||
|
||
fn new_feature_set() -> FeatureSet { | ||
let mut feature_set = FeatureSet::all_enabled(); | ||
feature_set.deactivate(&feature_set::raise_minimum_stake_delegation_to_1_sol::id()); | ||
feature_set | ||
} | ||
|
||
#[test] | ||
fn test_stake_process_instruction() { | ||
do_test_stake_process_instruction(new_feature_set()); | ||
} |
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.
You'll see that I now run basically all the tests twice—once for the old minimum delegation, and once for the new minimum delegation. I wanted to be extra sure I didn't break any existing behavior and also had the correct new behavior as well, so this was the best way I found to do that. It would've been nice to change the test's process_instruction()
to just always do both, but since it returns accounts now, that wasn't feasible[^1].
[^1] I could've, by returning a tuple of accounts for old and new behavior, but then tests with multiple calls to process_instruction() wouldn't really be fixed.
programs/stake/src/lib.rs
Outdated
pub fn get_minimum_delegation(feature_set: &FeatureSet) -> u64 { | ||
if feature_set.is_active(&feature_set::raise_minimum_stake_delegation_to_1_sol::id()) { | ||
const MINIMUM_DELEGATION_SOL: u64 = 1; | ||
MINIMUM_DELEGATION_SOL * LAMPORTS_PER_SOL | ||
} else { | ||
#[allow(deprecated)] | ||
solana_sdk::stake::MINIMUM_STAKE_DELEGATION | ||
} |
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.
And here's basically the whole change.
320dbb7
to
1f8d1aa
Compare
if (feature_set.is_active(&stake_allow_zero_undelegated_amount::id()) | ||
|| feature_set.is_active(&feature_set::stake_raise_minimum_delegation_to_1_sol::id())) | ||
&& stake_amount < crate::get_minimum_delegation(feature_set) | ||
{ | ||
return Err(StakeError::InsufficientStake.into()); |
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 could've not added || feature_set.is_active(&feature_set::stake_raise_minimum_delegation_to_1_sol::id()
to this if
, but then I would require that the stake_allow_zero_undelegated_amount
feature got activated first.
Granted, it likely will get activated first, but I didn't want to require it 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.
Sounds good to me
1f8d1aa
to
a4e5394
Compare
let minimum_delegation = crate::get_minimum_delegation(&FeatureSet::all_enabled()); | ||
let stake_lamports = rent_exempt_reserve + minimum_delegation; |
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.
With the stake_allow_zero_undelegated_amount
feature, the minimum balance needed to initialize a stake account is just the rent exempt amount. With a higher minimum delegation, the test below that says // not enough balance for rent
incorrectly passes since it contained extra lamports to still meet the minimum balance requirements.
a4e5394
to
3fa55d8
Compare
3fa55d8
to
2b52884
Compare
CI has finally passed! This PR is now ready to merge, in addition to being ready to review. |
if (feature_set.is_active(&stake_allow_zero_undelegated_amount::id()) | ||
|| feature_set.is_active(&feature_set::stake_raise_minimum_delegation_to_1_sol::id())) | ||
&& stake_amount < crate::get_minimum_delegation(feature_set) | ||
{ | ||
return Err(StakeError::InsufficientStake.into()); |
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.
Sounds good to me
Pull request has been modified.
Codecov Report
@@ Coverage Diff @@
## master #24603 +/- ##
========================================
Coverage 82.0% 82.1%
========================================
Files 598 598
Lines 165882 166376 +494
========================================
+ Hits 136125 136635 +510
+ Misses 29757 29741 -16 |
f4fcd7a
to
f0264b8
Compare
Problem
The minimum stake delegation is too low. For more information, see the main issue: #22559
Summary of Changes
Feature Gate Issue: #24357