Raise minimum stake delegation to 1 SOL (#24603)
This commit is contained in:
parent
8e37e364b1
commit
e6c02f30dd
|
@ -5,7 +5,11 @@
|
|||
note = "Please use `solana_sdk::stake::program::id` or `solana_program::stake::program::id` instead"
|
||||
)]
|
||||
pub use solana_sdk::stake::program::{check_id, id};
|
||||
use solana_sdk::{feature_set::FeatureSet, genesis_config::GenesisConfig};
|
||||
use solana_sdk::{
|
||||
feature_set::{self, FeatureSet},
|
||||
genesis_config::GenesisConfig,
|
||||
native_token::LAMPORTS_PER_SOL,
|
||||
};
|
||||
|
||||
pub mod config;
|
||||
pub mod stake_instruction;
|
||||
|
@ -19,10 +23,12 @@ pub fn add_genesis_accounts(genesis_config: &mut GenesisConfig) -> u64 {
|
|||
/// NOTE: This is also used to calculate the minimum balance of a stake account, which is the
|
||||
/// rent exempt reserve _plus_ the minimum stake delegation.
|
||||
#[inline(always)]
|
||||
pub fn get_minimum_delegation(_feature_set: &FeatureSet) -> u64 {
|
||||
// If/when the minimum delegation amount is changed, the `feature_set` parameter will be used
|
||||
// to chose the correct value. And since the MINIMUM_STAKE_DELEGATION constant cannot be
|
||||
// removed, use it here as to not duplicate magic constants.
|
||||
pub fn get_minimum_delegation(feature_set: &FeatureSet) -> u64 {
|
||||
if feature_set.is_active(&feature_set::stake_raise_minimum_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
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,7 +15,7 @@ use {
|
|||
account_utils::StateMut,
|
||||
clock::{Clock, Epoch},
|
||||
feature_set::{
|
||||
stake_allow_zero_undelegated_amount, stake_merge_with_unmatched_credits_observed,
|
||||
self, stake_allow_zero_undelegated_amount, stake_merge_with_unmatched_credits_observed,
|
||||
stake_split_uses_rent_sysvar, FeatureSet,
|
||||
},
|
||||
instruction::{checked_add, InstructionError},
|
||||
|
@ -1028,12 +1028,10 @@ fn validate_delegated_amount(
|
|||
.get_lamports()
|
||||
.saturating_sub(meta.rent_exempt_reserve); // can't stake the rent
|
||||
|
||||
// Previously, `initialize` checked that the stake account balance met
|
||||
// the minimum delegation amount.
|
||||
// With the `stake_allow_zero_undelegated_amount` feature, stake accounts
|
||||
// may be initialized with a lower balance, so check the minimum in this
|
||||
// function, on delegation.
|
||||
if feature_set.is_active(&stake_allow_zero_undelegated_amount::id())
|
||||
// Stake accounts may be initialized with a stake amount below the minimum delegation so check
|
||||
// that the minimum is met before delegation.
|
||||
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());
|
||||
|
@ -2166,7 +2164,6 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_stop_activating_after_deactivation() {
|
||||
solana_logger::setup();
|
||||
let stake = Delegation {
|
||||
stake: 1_000,
|
||||
activation_epoch: 0,
|
||||
|
|
|
@ -392,6 +392,11 @@ pub mod require_static_program_ids_in_transaction {
|
|||
solana_sdk::declare_id!("8FdwgyHFEjhAdjWfV2vfqk7wA1g9X3fQpKH7SBpEv3kC");
|
||||
}
|
||||
|
||||
pub mod stake_raise_minimum_delegation_to_1_sol {
|
||||
// This is a feature-proposal *feature id*. The feature keypair address is `3YHAo6wWw5rDbQxb59BmJkQ3XwVhX3m8tdBVbtxnJmma`.
|
||||
solana_sdk::declare_id!("4xmyBuR2VCXzy9H6qYpH9ckfgnTuMDQFPFBfTs4eBCY1");
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
/// Map of feature identifiers to user-visible description
|
||||
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
||||
|
@ -483,6 +488,7 @@ lazy_static! {
|
|||
(default_units_per_instruction::id(), "Default max tx-wide compute units calculated per instruction"),
|
||||
(stake_allow_zero_undelegated_amount::id(), "Allow zero-lamport undelegated amount for initialized stakes #24670"),
|
||||
(require_static_program_ids_in_transaction::id(), "require static program ids in versioned transactions"),
|
||||
(stake_raise_minimum_delegation_to_1_sol::id(), "Raise minimum stake delegation to 1.0 SOL #24357"),
|
||||
/*************** ADD NEW FEATURES HERE ***************/
|
||||
]
|
||||
.iter()
|
||||
|
|
Loading…
Reference in New Issue