stake: Remove v2 program references (backport #19308) (#19336)

* stake: Remove v2 program references (#19308)

* stake: Remove v2 program references

* Remove stake v2 feature, along with stake rewrite

(cherry picked from commit 73aa004c59)

# Conflicts:
#	runtime/src/bank.rs

* Fix merge conflict

* Fix uses of old `stake` function

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
This commit is contained in:
mergify[bot]
2021-08-20 07:32:24 +00:00
committed by GitHub
parent caea9c99cd
commit b5b1ed2a55
12 changed files with 103 additions and 629 deletions

View File

@@ -1,7 +1,6 @@
use crate::{
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
stake::is_stake_program_v2_enabled,
};
use clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand};
use console::{style, Emoji};
@@ -1750,8 +1749,6 @@ pub fn process_show_stakes(
let stake_history = from_account(&stake_history_account).ok_or_else(|| {
CliError::RpcRequestError("Failed to deserialize stake history".to_string())
})?;
// At v1.6, this check can be removed and simply passed as `true`
let stake_program_v2_enabled = is_stake_program_v2_enabled(rpc_client)?;
let mut stake_accounts: Vec<CliKeyedStakeState> = vec![];
for (stake_pubkey, stake_account) in all_stake_accounts {
@@ -1767,7 +1764,6 @@ pub fn process_show_stakes(
use_lamports_unit,
&stake_history,
&clock,
stake_program_v2_enabled,
),
});
}
@@ -1786,7 +1782,6 @@ pub fn process_show_stakes(
use_lamports_unit,
&stake_history,
&clock,
stake_program_v2_enabled,
),
});
}

View File

@@ -33,7 +33,6 @@ use solana_sdk::{
account_utils::StateMut,
clock::{Clock, UnixTimestamp, SECONDS_PER_DAY},
epoch_schedule::EpochSchedule,
feature, feature_set,
message::Message,
pubkey::Pubkey,
stake::{
@@ -1957,7 +1956,6 @@ pub fn build_stake_state(
use_lamports_unit: bool,
stake_history: &StakeHistory,
clock: &Clock,
stake_program_v2_enabled: bool,
) -> CliStakeState {
match stake_state {
StakeState::Stake(
@@ -1969,12 +1967,9 @@ pub fn build_stake_state(
stake,
) => {
let current_epoch = clock.epoch;
let (active_stake, activating_stake, deactivating_stake) =
stake.delegation.stake_activating_and_deactivating(
current_epoch,
Some(stake_history),
stake_program_v2_enabled,
);
let (active_stake, activating_stake, deactivating_stake) = stake
.delegation
.stake_activating_and_deactivating(current_epoch, Some(stake_history));
let lockup = if lockup.is_in_force(clock, None) {
Some(lockup.into())
} else {
@@ -2163,7 +2158,6 @@ pub fn process_show_stake_account(
use_lamports_unit,
&stake_history,
&clock,
is_stake_program_v2_enabled(rpc_client)?, // At v1.6, this check can be removed and simply passed as `true`
);
if state.stake_type == CliStakeType::Stake && state.activation_epoch.is_some() {
@@ -2346,15 +2340,6 @@ pub fn process_delegate_stake(
}
}
pub fn is_stake_program_v2_enabled(
rpc_client: &RpcClient,
) -> Result<bool, Box<dyn std::error::Error>> {
let feature_account = rpc_client.get_account(&feature_set::stake_program_v2::id())?;
Ok(feature::from_account(&feature_account)
.and_then(|feature| feature.activated_at)
.is_some())
}
#[cfg(test)]
mod tests {
use super::*;