remove clean_up_delegation_errors feature (#32848)
This commit is contained in:
parent
aad3390372
commit
5e5b6f7d33
|
@ -15,8 +15,7 @@ use {
|
||||||
account_utils::StateMut,
|
account_utils::StateMut,
|
||||||
clock::{Clock, Epoch},
|
clock::{Clock, Epoch},
|
||||||
feature_set::{
|
feature_set::{
|
||||||
self, clean_up_delegation_errors,
|
self, reduce_stake_warmup_cooldown::NewWarmupCooldownRateEpoch,
|
||||||
reduce_stake_warmup_cooldown::NewWarmupCooldownRateEpoch,
|
|
||||||
stake_merge_with_unmatched_credits_observed, FeatureSet,
|
stake_merge_with_unmatched_credits_observed, FeatureSet,
|
||||||
},
|
},
|
||||||
instruction::{checked_add, InstructionError},
|
instruction::{checked_add, InstructionError},
|
||||||
|
@ -700,7 +699,6 @@ pub fn split(
|
||||||
split_index,
|
split_index,
|
||||||
lamports,
|
lamports,
|
||||||
&meta,
|
&meta,
|
||||||
Some(&stake),
|
|
||||||
minimum_delegation,
|
minimum_delegation,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@ -727,11 +725,7 @@ pub fn split(
|
||||||
// Otherwise, the new split stake should reflect the entire split
|
// Otherwise, the new split stake should reflect the entire split
|
||||||
// requested, less any lamports needed to cover the split_rent_exempt_reserve.
|
// requested, less any lamports needed to cover the split_rent_exempt_reserve.
|
||||||
|
|
||||||
if invoke_context
|
if stake.delegation.stake.saturating_sub(lamports) < minimum_delegation {
|
||||||
.feature_set
|
|
||||||
.is_active(&clean_up_delegation_errors::id())
|
|
||||||
&& stake.delegation.stake.saturating_sub(lamports) < minimum_delegation
|
|
||||||
{
|
|
||||||
return Err(StakeError::InsufficientDelegation.into());
|
return Err(StakeError::InsufficientDelegation.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,11 +739,7 @@ pub fn split(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
if invoke_context
|
if split_stake_amount < minimum_delegation {
|
||||||
.feature_set
|
|
||||||
.is_active(&clean_up_delegation_errors::id())
|
|
||||||
&& split_stake_amount < minimum_delegation
|
|
||||||
{
|
|
||||||
return Err(StakeError::InsufficientDelegation.into());
|
return Err(StakeError::InsufficientDelegation.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,7 +765,6 @@ pub fn split(
|
||||||
split_index,
|
split_index,
|
||||||
lamports,
|
lamports,
|
||||||
&meta,
|
&meta,
|
||||||
None,
|
|
||||||
0, // additional_required_lamports
|
0, // additional_required_lamports
|
||||||
)?;
|
)?;
|
||||||
let mut split_meta = meta;
|
let mut split_meta = meta;
|
||||||
|
@ -1205,7 +1194,6 @@ fn validate_split_amount(
|
||||||
destination_account_index: IndexOfAccount,
|
destination_account_index: IndexOfAccount,
|
||||||
lamports: u64,
|
lamports: u64,
|
||||||
source_meta: &Meta,
|
source_meta: &Meta,
|
||||||
source_stake: Option<&Stake>,
|
|
||||||
additional_required_lamports: u64,
|
additional_required_lamports: u64,
|
||||||
) -> Result<ValidatedSplitInfo, InstructionError> {
|
) -> Result<ValidatedSplitInfo, InstructionError> {
|
||||||
let source_account = instruction_context
|
let source_account = instruction_context
|
||||||
|
@ -1261,25 +1249,6 @@ fn validate_split_amount(
|
||||||
return Err(InstructionError::InsufficientFunds);
|
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 {
|
Ok(ValidatedSplitInfo {
|
||||||
source_remaining_balance,
|
source_remaining_balance,
|
||||||
destination_rent_exempt_reserve,
|
destination_rent_exempt_reserve,
|
||||||
|
|
Loading…
Reference in New Issue