Skip to content
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

Update Stake with the additional deactivation flag #4504

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stake-pool/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ fn command_deposit_stake(
println!("Depositing stake account {:?}", stake_state);
}
let vote_account = match stake_state {
stake::state::StakeState::Stake(_, stake) => Ok(stake.delegation.voter_pubkey),
stake::state::StakeState::Stake(_, stake, _) => Ok(stake.delegation.voter_pubkey),
_ => Err("Wrong stake account state, must be delegated to validator"),
}?;

Expand Down Expand Up @@ -865,7 +865,7 @@ fn command_deposit_all_stake(
let stake_state = get_stake_state(&config.rpc_client, &stake_address)?;

let vote_account = match stake_state {
stake::state::StakeState::Stake(_, stake) => Ok(stake.delegation.voter_pubkey),
stake::state::StakeState::Stake(_, stake, _) => Ok(stake.delegation.voter_pubkey),
_ => Err("Wrong stake account state, must be delegated to validator"),
}?;

Expand Down
10 changes: 5 additions & 5 deletions stake-pool/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn get_stake_state(
let stake_state =
try_from_slice_unchecked::<stake::state::StakeState>(&stake_account_info.data.borrow())?;
match stake_state {
stake::state::StakeState::Stake(meta, stake) => Ok((meta, stake)),
stake::state::StakeState::Stake(meta, stake, _) => Ok((meta, stake)),
_ => Err(StakePoolError::WrongStakeState.into()),
}
}
Expand Down Expand Up @@ -1738,7 +1738,7 @@ impl Processor {
)?;
match stake_state {
// if it was delegated on or before this epoch, we're good
stake::state::StakeState::Stake(_, stake)
stake::state::StakeState::Stake(_, stake, _)
if stake.delegation.activation_epoch <= clock.epoch => {}
// all other situations, delegate!
_ => {
Expand Down Expand Up @@ -2275,7 +2275,7 @@ impl Processor {
}
}
}
Some(stake::state::StakeState::Stake(meta, stake)) => {
Some(stake::state::StakeState::Stake(meta, stake, _)) => {
if stake_is_usable_by_pool(
&meta,
withdraw_authority_info.key,
Expand All @@ -2297,7 +2297,7 @@ impl Processor {
)?;
validator_stake_record.status.remove_transient_stake();
} else if stake.delegation.activation_epoch < clock.epoch {
if let Some(stake::state::StakeState::Stake(_, validator_stake)) =
if let Some(stake::state::StakeState::Stake(_, validator_stake, _)) =
validator_stake_state
{
if validator_stake.delegation.activation_epoch < clock.epoch {
Expand Down Expand Up @@ -2338,7 +2338,7 @@ impl Processor {
)
.ok();
match validator_stake_state {
Some(stake::state::StakeState::Stake(meta, stake)) => {
Some(stake::state::StakeState::Stake(meta, stake, _)) => {
let additional_lamports = validator_stake_info
.lamports()
.saturating_sub(stake.delegation.stake)
Expand Down
4 changes: 3 additions & 1 deletion stake-pool/program/tests/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,9 @@ pub fn add_validator_stake_account(
let stake_account = SolanaAccount::create(
stake_amount + STAKE_ACCOUNT_RENT_EXEMPTION,
bincode::serialize::<stake::state::StakeState>(&stake::state::StakeState::Stake(
meta, stake,
meta,
stake,
stake::stake_flags::StakeFlags::empty(),
))
.unwrap(),
stake::program::id(),
Expand Down
4 changes: 2 additions & 2 deletions stake-pool/program/tests/vsa_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async fn success() {
let stake = get_account(&mut banks_client, &validator_stake.stake_account).await;
let stake_state = deserialize::<stake::state::StakeState>(&stake.data).unwrap();
match stake_state {
stake::state::StakeState::Stake(meta, _) => {
stake::state::StakeState::Stake(meta, _, _) => {
assert_eq!(
&meta.authorized.staker,
&stake_pool_accounts.withdraw_authority
Expand Down Expand Up @@ -595,7 +595,7 @@ async fn success_with_lamports_in_account() {
let stake = get_account(&mut banks_client, &validator_stake.stake_account).await;
let stake_state = deserialize::<stake::state::StakeState>(&stake.data).unwrap();
match stake_state {
stake::state::StakeState::Stake(meta, _) => {
stake::state::StakeState::Stake(meta, _, _) => {
assert_eq!(
&meta.authorized.staker,
&stake_pool_accounts.withdraw_authority
Expand Down
2 changes: 1 addition & 1 deletion stake-pool/single-pool-cli/src/quarantine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub async fn get_stake_info(
.await?
{
match bincode::deserialize::<StakeState>(&stake_account.data)? {
StakeState::Stake(meta, stake) => Ok(Some((meta, stake))),
StakeState::Stake(meta, stake, _) => Ok(Some((meta, stake))),
StakeState::Initialized(_) => {
Err(format!("Stake account {} is undelegated", stake_account_address).into())
}
Expand Down
2 changes: 1 addition & 1 deletion stake-pool/single-pool/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn get_stake_state(stake_account_info: &AccountInfo) -> Result<(Meta, Stake), Pr
let stake_state = try_from_slice_unchecked::<StakeState>(&stake_account_info.data.borrow())?;

match stake_state {
StakeState::Stake(meta, stake) => Ok((meta, stake)),
StakeState::Stake(meta, stake, _) => Ok((meta, stake)),
_ => Err(SinglePoolError::WrongStakeState.into()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion stake-pool/single-pool/tests/helpers/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub async fn get_stake_account(
let lamports = stake_account.lamports;
match deserialize::<StakeState>(&stake_account.data).unwrap() {
StakeState::Initialized(meta) => (meta, None, lamports),
StakeState::Stake(meta, stake) => (meta, Some(stake), lamports),
StakeState::Stake(meta, stake, _) => (meta, Some(stake), lamports),
_ => unimplemented!(),
}
}
Expand Down