Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
CriesofCarrots committed Sep 20, 2023
1 parent a929f98 commit 9eb709c
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 197 deletions.
9 changes: 1 addition & 8 deletions cli/tests/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ fn test_stake_split() {
config.signers = vec![&default_signer];

let minimum_balance = rpc_client
.get_minimum_balance_for_rent_exemption(StakeStateV2::size_of())
.get_minimum_balance_for_rent_exemption(StakeState::size_of())
.unwrap();

let mut config_offline = CliConfig::recent_for_tests();
Expand Down Expand Up @@ -1498,14 +1498,7 @@ fn test_stake_split() {
check_balance!(1_000_000_000_000, &rpc_client, &offline_pubkey);

// Create stake account, identity is authority
<<<<<<< HEAD
let stake_balance = rpc_client
.get_minimum_balance_for_rent_exemption(StakeState::size_of())
.unwrap()
+ 10_000_000_000;
=======
let stake_balance = minimum_balance + 10_000_000_000;
>>>>>>> bca41edf20 (Make active stake consistent in split (#33295))
let stake_keypair = keypair_from_seed(&[0u8; 32]).unwrap();
let stake_account_pubkey = stake_keypair.pubkey();
config.signers.push(&stake_keypair);
Expand Down
140 changes: 18 additions & 122 deletions programs/stake/src/stake_instruction.rs

Large diffs are not rendered by default.

46 changes: 14 additions & 32 deletions programs/stake/src/stake_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,13 +824,9 @@ pub fn split(
split_index,
lamports,
&meta,
<<<<<<< HEAD
None,
additional_required_lamports,
=======
0, // additional_required_lamports
false,
>>>>>>> bca41edf20 (Make active stake consistent in split (#33295))
)?;
let mut split_meta = meta;
split_meta.rent_exempt_reserve = validated_split_info.destination_rent_exempt_reserve;
Expand Down Expand Up @@ -992,18 +988,8 @@ pub fn redelegate(
let vote_state = vote_account.get_state::<VoteStateVersions>()?;

let (stake_meta, effective_stake) =
<<<<<<< HEAD
if let StakeState::Stake(meta, stake) = stake_account.get_state()? {
let stake_history = invoke_context.get_sysvar_cache().get_stake_history()?;
let status = stake.delegation.stake_activating_and_deactivating(
clock.epoch,
Some(&stake_history),
new_warmup_cooldown_rate_epoch(invoke_context),
);
=======
if let StakeStateV2::Stake(meta, stake, _stake_flags) = stake_account.get_state()? {
let status = get_stake_status(invoke_context, &stake, &clock)?;
>>>>>>> bca41edf20 (Make active stake consistent in split (#33295))
if status.effective == 0 || status.activating != 0 || status.deactivating != 0 {
ic_msg!(invoke_context, "stake is not active");
return Err(StakeError::RedelegateTransientOrInactiveStake.into());
Expand Down Expand Up @@ -1268,6 +1254,7 @@ struct ValidatedSplitInfo {
/// minimum balance requirements, which is the rent exempt reserve plus the minimum stake
/// delegation, and that the source account has enough lamports for the request split amount. If
/// not, return an error.
#[allow(clippy::too_many_arguments)]
fn validate_split_amount(
invoke_context: &InvokeContext,
transaction_context: &TransactionContext,
Expand Down Expand Up @@ -1320,8 +1307,19 @@ fn validate_split_amount(
// nothing to do here
}

let rent = invoke_context.get_sysvar_cache().get_rent()?;
let destination_rent_exempt_reserve = rent.minimum_balance(destination_data_len);
let destination_rent_exempt_reserve = if invoke_context
.feature_set
.is_active(&stake_split_uses_rent_sysvar::ID)
{
let rent = invoke_context.get_sysvar_cache().get_rent()?;
rent.minimum_balance(destination_data_len)
} else {
calculate_split_rent_exempt_reserve(
source_meta.rent_exempt_reserve,
source_data_len as u64,
destination_data_len as u64,
)
};

// As of feature `require_rent_exempt_split_destination`, if the source is active stake, one of
// these criteria must be met:
Expand All @@ -1341,22 +1339,6 @@ fn validate_split_amount(
// This must handle:
// 1. The destination account having a different rent exempt reserve due to data size changes
// 2. The destination account being prefunded, which would lower the minimum split amount
<<<<<<< HEAD
let destination_rent_exempt_reserve = if invoke_context
.feature_set
.is_active(&stake_split_uses_rent_sysvar::ID)
{
let rent = invoke_context.get_sysvar_cache().get_rent()?;
rent.minimum_balance(destination_data_len)
} else {
calculate_split_rent_exempt_reserve(
source_meta.rent_exempt_reserve,
source_data_len as u64,
destination_data_len as u64,
)
};
=======
>>>>>>> bca41edf20 (Make active stake consistent in split (#33295))
let destination_minimum_balance =
destination_rent_exempt_reserve.saturating_add(additional_required_lamports);
let destination_balance_deficit =
Expand Down
6 changes: 1 addition & 5 deletions runtime/tests/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,18 +426,14 @@ fn test_stake_account_lifetime() {
let split_stake_keypair = Keypair::new();
let split_stake_pubkey = split_stake_keypair.pubkey();

<<<<<<< HEAD
let bank_client = BankClient::new_shared(&bank);
=======
bank.transfer(
stake_rent_exempt_reserve,
&mint_keypair,
&split_stake_pubkey,
)
.unwrap();
let bank_client = BankClient::new_shared(bank.clone());
let bank_client = BankClient::new_shared(&bank);

>>>>>>> bca41edf20 (Make active stake consistent in split (#33295))
// Test split
let split_starting_delegation = stake_minimum_delegation + bonus_delegation;
let message = Message::new(
Expand Down
26 changes: 0 additions & 26 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,29 +674,10 @@ pub mod revise_turbine_epoch_stakes {
solana_sdk::declare_id!("BTWmtJC8U5ZLMbBUUA1k6As62sYjPEjAiNAT55xYGdJU");
}

<<<<<<< HEAD
=======
pub mod enable_poseidon_syscall {
solana_sdk::declare_id!("FL9RsQA6TVUoh5xJQ9d936RHSebA1NLQqe3Zv9sXZRpr");
}

pub mod timely_vote_credits {
solana_sdk::declare_id!("2oXpeh141pPZCTCFHBsvCwG2BtaHZZAtrVhwaxSy6brS");
}

pub mod remaining_compute_units_syscall_enabled {
solana_sdk::declare_id!("5TuppMutoyzhUSfuYdhgzD47F92GL1g89KpCZQKqedxP");
}

pub mod enable_program_runtime_v2_and_loader_v4 {
solana_sdk::declare_id!("8oBxsYqnCvUTGzgEpxPcnVf7MLbWWPYddE33PftFeBBd");
}

pub mod require_rent_exempt_split_destination {
solana_sdk::declare_id!("D2aip4BBr8NPWtU9vLrwrBvbuaQ8w1zV38zFLxx4pfBV");
}

>>>>>>> bca41edf20 (Make active stake consistent in split (#33295))
lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -860,14 +841,7 @@ lazy_static! {
(bpf_account_data_direct_mapping::id(), "use memory regions to map account data into the rbpf vm instead of copying the data"),
(reduce_stake_warmup_cooldown::id(), "reduce stake warmup cooldown from 25% to 9%"),
(revise_turbine_epoch_stakes::id(), "revise turbine epoch stakes"),
<<<<<<< HEAD
=======
(enable_poseidon_syscall::id(), "Enable Poseidon syscall"),
(timely_vote_credits::id(), "use timeliness of votes in determining credits to award"),
(remaining_compute_units_syscall_enabled::id(), "enable the remaining_compute_units syscall"),
(enable_program_runtime_v2_and_loader_v4::id(), "Enable Program-Runtime-v2 and Loader-v4 #33293"),
(require_rent_exempt_split_destination::id(), "Require stake split destination account to be rent exempt"),
>>>>>>> bca41edf20 (Make active stake consistent in split (#33295))
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down
4 changes: 2 additions & 2 deletions tokens/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use {
signature::{unique_signers, Signature, Signer},
stake::{
instruction::{self as stake_instruction, LockupArgs},
state::{Authorized, Lockup, StakeAuthorize, StakeStateV2},
state::{Authorized, Lockup, StakeAuthorize, StakeState},
},
system_instruction,
transaction::Transaction,
Expand Down Expand Up @@ -1187,7 +1187,7 @@ pub fn test_process_distribute_stake_with_client(client: &RpcClient, sender_keyp
let output_path = output_file.path().to_str().unwrap().to_string();

let rent_exempt_reserve = client
.get_minimum_balance_for_rent_exemption(StakeStateV2::size_of())
.get_minimum_balance_for_rent_exemption(StakeState::size_of())
.unwrap();
let sender_stake_args = SenderStakeArgs {
stake_account_address,
Expand Down
4 changes: 2 additions & 2 deletions tokens/src/stake.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use {
crate::{args::StakeArgs, commands::Error},
solana_rpc_client::rpc_client::RpcClient,
solana_sdk::stake::state::StakeStateV2,
solana_sdk::stake::state::StakeState,
};

pub fn update_stake_args(client: &RpcClient, args: &mut Option<StakeArgs>) -> Result<(), Error> {
if let Some(stake_args) = args {
if let Some(sender_args) = &mut stake_args.sender_stake_args {
let rent = client.get_minimum_balance_for_rent_exemption(StakeStateV2::size_of())?;
let rent = client.get_minimum_balance_for_rent_exemption(StakeState::size_of())?;
sender_args.rent_exempt_reserve = Some(rent);
}
}
Expand Down

0 comments on commit 9eb709c

Please sign in to comment.