diff --git a/programs/stake/src/stake_instruction.rs b/programs/stake/src/stake_instruction.rs index bb77cefe4..c26800988 100644 --- a/programs/stake/src/stake_instruction.rs +++ b/programs/stake/src/stake_instruction.rs @@ -481,7 +481,7 @@ mod tests { account_utils::StateMut, clock::{Epoch, UnixTimestamp}, epoch_schedule::EpochSchedule, - feature_set::{reduce_stake_warmup_cooldown::NewWarmupCooldownRateEpoch, FeatureSet}, + feature_set::FeatureSet, instruction::{AccountMeta, Instruction}, pubkey::Pubkey, rent::Rent, diff --git a/programs/stake/src/stake_state.rs b/programs/stake/src/stake_state.rs index 9557544e8..713054ae6 100644 --- a/programs/stake/src/stake_state.rs +++ b/programs/stake/src/stake_state.rs @@ -14,10 +14,7 @@ use { account::{AccountSharedData, ReadableAccount, WritableAccount}, account_utils::StateMut, clock::{Clock, Epoch}, - feature_set::{ - self, reduce_stake_warmup_cooldown::NewWarmupCooldownRateEpoch, - stake_merge_with_unmatched_credits_observed, FeatureSet, - }, + feature_set::{self, stake_merge_with_unmatched_credits_observed, FeatureSet}, instruction::{checked_add, InstructionError}, pubkey::Pubkey, rent::Rent, diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index e110778a9..4c957f75f 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -137,7 +137,6 @@ use { self, add_set_tx_loaded_accounts_data_size_instruction, enable_early_verification_of_account_modifications, include_loaded_accounts_data_size_in_fee_calculation, - reduce_stake_warmup_cooldown::NewWarmupCooldownRateEpoch, remove_congestion_multiplier_from_fee_calculation, remove_deprecated_request_unit_ix, FeatureSet, }, @@ -2986,6 +2985,7 @@ impl Bank { VoteAccount::try_from(account).ok() }; + let new_warmup_cooldown_rate_epoch = self.new_warmup_cooldown_rate_epoch(); let (points, measure_us) = measure_us!(thread_pool.install(|| { stake_delegations .par_iter() @@ -3007,7 +3007,7 @@ impl Bank { stake_account.stake_state(), vote_state, Some(stake_history), - self.new_warmup_cooldown_rate_epoch(), + new_warmup_cooldown_rate_epoch, ) .unwrap_or(0) }) @@ -3026,6 +3026,7 @@ impl Bank { thread_pool: &ThreadPool, metrics: &RewardsMetrics, ) -> Option { + let new_warmup_cooldown_rate_epoch = self.new_warmup_cooldown_rate_epoch(); let (points, measure) = measure!(thread_pool.install(|| { vote_with_stake_delegations_map .par_iter() @@ -3043,7 +3044,7 @@ impl Bank { stake_account.stake_state(), vote_state, Some(stake_history), - self.new_warmup_cooldown_rate_epoch(), + new_warmup_cooldown_rate_epoch, ) .unwrap_or(0) }) @@ -3089,6 +3090,7 @@ impl Bank { VoteAccount::try_from(account).ok() }; + let new_warmup_cooldown_rate_epoch = self.new_warmup_cooldown_rate_epoch(); let vote_account_rewards: VoteRewards = DashMap::new(); let total_stake_rewards = AtomicU64::default(); let (stake_rewards, measure_stake_rewards_us) = measure_us!(thread_pool.install(|| { @@ -3130,7 +3132,7 @@ impl Bank { &point_value, Some(stake_history), reward_calc_tracer.as_ref(), - self.new_warmup_cooldown_rate_epoch(), + new_warmup_cooldown_rate_epoch, ); let post_lamport = stake_account.lamports(); @@ -3202,6 +3204,7 @@ impl Bank { reward_calc_tracer: Option, metrics: &mut RewardsMetrics, ) -> (VoteRewards, StakeRewards) { + let new_warmup_cooldown_rate_epoch = self.new_warmup_cooldown_rate_epoch(); let vote_account_rewards: VoteRewards = DashMap::with_capacity(vote_with_stake_delegations_map.len()); let stake_delegation_iterator = vote_with_stake_delegations_map.into_par_iter().flat_map( @@ -3248,7 +3251,7 @@ impl Bank { &point_value, Some(stake_history), reward_calc_tracer.as_ref(), - self.new_warmup_cooldown_rate_epoch(), + new_warmup_cooldown_rate_epoch, ); if let Ok((stakers_reward, voters_reward)) = redeemed { // track voter rewards @@ -6604,11 +6607,12 @@ impl Bank { ) { assert!(!self.freeze_started()); let mut m = Measure::start("stakes_cache.check_and_store"); + let new_warmup_cooldown_rate_epoch = self.new_warmup_cooldown_rate_epoch(); (0..accounts.len()).for_each(|i| { self.stakes_cache.check_and_store( accounts.pubkey(i), accounts.account(i), - self.new_warmup_cooldown_rate_epoch(), + new_warmup_cooldown_rate_epoch, ) }); self.rc.accounts.store_accounts_cached(accounts); @@ -7730,6 +7734,7 @@ impl Bank { ) { debug_assert_eq!(txs.len(), execution_results.len()); debug_assert_eq!(txs.len(), loaded_txs.len()); + let new_warmup_cooldown_rate_epoch = self.new_warmup_cooldown_rate_epoch(); izip!(txs, execution_results, loaded_txs) .filter(|(_, execution_result, _)| execution_result.was_executed_successfully()) .flat_map(|(tx, _, (load_result, _))| { @@ -7741,11 +7746,8 @@ impl Bank { .for_each(|(pubkey, account)| { // note that this could get timed to: self.rc.accounts.accounts_db.stats.stakes_cache_check_and_store_us, // but this code path is captured separately in ExecuteTimingType::UpdateStakesCacheUs - self.stakes_cache.check_and_store( - pubkey, - account, - self.new_warmup_cooldown_rate_epoch(), - ); + self.stakes_cache + .check_and_store(pubkey, account, new_warmup_cooldown_rate_epoch); }); } diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index 418d32874..9a52f20dd 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -20,6 +20,7 @@ use { lazy_static::lazy_static, + solana_program::{epoch_schedule::EpochSchedule, stake_history::Epoch}, solana_sdk::{ clock::Slot, hash::{Hash, Hasher}, @@ -665,18 +666,7 @@ pub mod last_restart_slot_sysvar { } pub mod reduce_stake_warmup_cooldown { - use solana_program::{epoch_schedule::EpochSchedule, stake_history::Epoch}; solana_sdk::declare_id!("GwtDQBghCTBgmX2cpEGNPxTEBUTQRaDMGTr5qychdGMj"); - - pub trait NewWarmupCooldownRateEpoch { - fn new_warmup_cooldown_rate_epoch(&self, epoch_schedule: &EpochSchedule) -> Option; - } - impl NewWarmupCooldownRateEpoch for super::FeatureSet { - fn new_warmup_cooldown_rate_epoch(&self, epoch_schedule: &EpochSchedule) -> Option { - self.activated_slot(&id()) - .map(|slot| epoch_schedule.get_epoch(slot)) - } - } } pub mod revise_turbine_epoch_stakes { @@ -960,6 +950,11 @@ impl FeatureSet { self.active.remove(feature_id); self.inactive.insert(*feature_id); } + + pub fn new_warmup_cooldown_rate_epoch(&self, epoch_schedule: &EpochSchedule) -> Option { + self.activated_slot(&reduce_stake_warmup_cooldown::id()) + .map(|slot| epoch_schedule.get_epoch(slot)) + } } #[cfg(test)]