stake: Remove v2 program references (#19308)

* stake: Remove v2 program references

* Remove stake v2 feature, along with stake rewrite
This commit is contained in:
Jon Cinque
2021-08-20 01:08:44 -04:00
committed by GitHub
parent 2a877ae06e
commit 73aa004c59
11 changed files with 100 additions and 618 deletions

View File

@ -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,
@ -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)
@ -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,