Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
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
5 changes: 0 additions & 5 deletions cli/src/cluster_query.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -1749,8 +1748,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 {
Expand All @@ -1766,7 +1763,6 @@ pub fn process_show_stakes(
use_lamports_unit,
&stake_history,
&clock,
stake_program_v2_enabled,
),
});
}
Expand All @@ -1785,7 +1781,6 @@ pub fn process_show_stakes(
use_lamports_unit,
&stake_history,
&clock,
stake_program_v2_enabled,
),
});
}
Expand Down
21 changes: 3 additions & 18 deletions cli/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -1950,7 +1949,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(
Expand All @@ -1962,12 +1960,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 {
Expand Down Expand Up @@ -2156,7 +2151,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() {
Expand Down Expand Up @@ -2338,15 +2332,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::*;
Expand Down
99 changes: 0 additions & 99 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ use solana_runtime::{
use solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount},
clock::{Epoch, Slot},
feature::{self, Feature},
feature_set,
genesis_config::{ClusterType, GenesisConfig},
hash::Hash,
inflation::Inflation,
Expand Down Expand Up @@ -1383,14 +1381,6 @@ fn main() {
.possible_values(&["pico", "full", "none"])
.help("Overwrite inflation when warping"),
)
.arg(
Arg::with_name("enable_stake_program_v2")
.required(false)
.long("enable-stake-program-v2")
.takes_value(false)
.help("Enable stake program v2 (several inflation-related staking \
bugs are feature-gated behind this)"),
)
.arg(
Arg::with_name("recalculate_capitalization")
.required(false)
Expand Down Expand Up @@ -2406,95 +2396,6 @@ fn main() {
.lazy_rent_collection
.store(true, std::sync::atomic::Ordering::Relaxed);

let feature_account_balance = std::cmp::max(
genesis_config.rent.minimum_balance(Feature::size_of()),
1,
);
if arg_matches.is_present("enable_stake_program_v2") {
let mut force_enabled_count = 0;
if base_bank
.get_account(&feature_set::stake_program_v2::id())
.is_none()
{
base_bank.store_account(
&feature_set::stake_program_v2::id(),
&feature::create_account(
&Feature { activated_at: None },
feature_account_balance,
),
);
force_enabled_count += 1;
}
if base_bank
.get_account(&feature_set::rewrite_stake::id())
.is_none()
{
base_bank.store_account(
&feature_set::rewrite_stake::id(),
&feature::create_account(
&Feature { activated_at: None },
feature_account_balance,
),
);
force_enabled_count += 1;
}

if force_enabled_count == 0 {
warn!("Already stake_program_v2 is activated (or scheduled)");
}

let mut store_failed_count = 0;
if force_enabled_count >= 1 {
if base_bank
.get_account(&feature_set::spl_token_v2_multisig_fix::id())
.is_some()
{
// steal some lamports from the pretty old feature not to affect
// capitalizaion, which doesn't affect inflation behavior!
base_bank.store_account(
&feature_set::spl_token_v2_multisig_fix::id(),
&AccountSharedData::default(),
);
force_enabled_count -= 1;
} else {
store_failed_count += 1;
}
}

if force_enabled_count >= 1 {
if base_bank
.get_account(&feature_set::instructions_sysvar_enabled::id())
.is_some()
{
// steal some lamports from the pretty old feature not to affect
// capitalizaion, which doesn't affect inflation behavior!
base_bank.store_account(
&feature_set::instructions_sysvar_enabled::id(),
&AccountSharedData::default(),
);
force_enabled_count -= 1;
} else {
store_failed_count += 1;
}
}
assert_eq!(force_enabled_count, store_failed_count);
if store_failed_count >= 1 {
// we have no choice; maybe locally created blank cluster with
// not-Development cluster type.
let old_cap = base_bank.set_capitalization();
let new_cap = base_bank.capitalization();
warn!(
"Skewing capitalization a bit to enable stake_program_v2 as \
requested: increasing {} from {} to {}",
feature_account_balance, old_cap, new_cap,
);
assert_eq!(
old_cap + feature_account_balance * store_failed_count,
new_cap
);
}
}

#[derive(Default, Debug)]
struct PointDetail {
epoch: Epoch,
Expand Down
2 changes: 1 addition & 1 deletion program-test/tests/warp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ async fn stake_rewards_from_warp() {
assert_matches!(
stake
.delegation
.stake_activating_and_deactivating(clock.epoch, Some(&stake_history), true,),
.stake_activating_and_deactivating(clock.epoch, Some(&stake_history)),
(_, 0, 0)
);
}
Loading