From 5e5b6f7d336deb48232ec4379e9ba067bbbec2d0 Mon Sep 17 00:00:00 2001 From: hana <81144685+2501babe@users.noreply.github.com> Date: Wed, 16 Aug 2023 09:15:43 -0700 Subject: [PATCH] remove clean_up_delegation_errors feature (#32848) --- programs/stake/src/stake_state.rs | 37 +++---------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/programs/stake/src/stake_state.rs b/programs/stake/src/stake_state.rs index abbbb61df2..9557544e81 100644 --- a/programs/stake/src/stake_state.rs +++ b/programs/stake/src/stake_state.rs @@ -15,8 +15,7 @@ use { account_utils::StateMut, clock::{Clock, Epoch}, feature_set::{ - self, clean_up_delegation_errors, - reduce_stake_warmup_cooldown::NewWarmupCooldownRateEpoch, + self, reduce_stake_warmup_cooldown::NewWarmupCooldownRateEpoch, stake_merge_with_unmatched_credits_observed, FeatureSet, }, instruction::{checked_add, InstructionError}, @@ -700,7 +699,6 @@ pub fn split( split_index, lamports, &meta, - Some(&stake), minimum_delegation, )?; @@ -727,11 +725,7 @@ pub fn split( // Otherwise, the new split stake should reflect the entire split // requested, less any lamports needed to cover the split_rent_exempt_reserve. - if invoke_context - .feature_set - .is_active(&clean_up_delegation_errors::id()) - && stake.delegation.stake.saturating_sub(lamports) < minimum_delegation - { + if stake.delegation.stake.saturating_sub(lamports) < minimum_delegation { return Err(StakeError::InsufficientDelegation.into()); } @@ -745,11 +739,7 @@ pub fn split( ) }; - if invoke_context - .feature_set - .is_active(&clean_up_delegation_errors::id()) - && split_stake_amount < minimum_delegation - { + if split_stake_amount < minimum_delegation { return Err(StakeError::InsufficientDelegation.into()); } @@ -775,7 +765,6 @@ pub fn split( split_index, lamports, &meta, - None, 0, // additional_required_lamports )?; let mut split_meta = meta; @@ -1205,7 +1194,6 @@ fn validate_split_amount( destination_account_index: IndexOfAccount, lamports: u64, source_meta: &Meta, - source_stake: Option<&Stake>, additional_required_lamports: u64, ) -> Result { let source_account = instruction_context @@ -1261,25 +1249,6 @@ fn validate_split_amount( return Err(InstructionError::InsufficientFunds); } - // If the source account is already staked, the destination will end up staked as well. Verify - // the destination account's delegation amount is at least the minimum delegation. - // - // The *delegation* requirements are different than the *balance* requirements. If the - // destination account is prefunded with a balance of `rent exempt reserve + minimum stake - // delegation - 1`, the minimum split amount to satisfy the *balance* requirements is 1 - // lamport. And since *only* the split amount is immediately staked in the destination - // account, the split amount must be at least the minimum stake delegation. So if the minimum - // stake delegation was 10 lamports, then a split amount of 1 lamport would not meet the - // *delegation* requirements. - if !invoke_context - .feature_set - .is_active(&clean_up_delegation_errors::id()) - && source_stake.is_some() - && lamports < additional_required_lamports - { - return Err(InstructionError::InsufficientFunds); - } - Ok(ValidatedSplitInfo { source_remaining_balance, destination_rent_exempt_reserve,