cleanup feature consistent_recent_blockhashes_sysvar (#18932)

This commit is contained in:
Jack May 2021-07-28 10:25:33 -07:00 committed by GitHub
parent 65ccfed868
commit 0167daa116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 43 deletions

View File

@ -890,7 +890,6 @@ impl Accounts {
loaded: &'a mut [TransactionLoadResult], loaded: &'a mut [TransactionLoadResult],
rent_collector: &RentCollector, rent_collector: &RentCollector,
last_blockhash_with_fee_calculator: &(Hash, FeeCalculator), last_blockhash_with_fee_calculator: &(Hash, FeeCalculator),
fix_recent_blockhashes_sysvar_delay: bool,
rent_for_sysvars: bool, rent_for_sysvars: bool,
) { ) {
let accounts_to_store = self.collect_accounts_to_store( let accounts_to_store = self.collect_accounts_to_store(
@ -899,7 +898,6 @@ impl Accounts {
loaded, loaded,
rent_collector, rent_collector,
last_blockhash_with_fee_calculator, last_blockhash_with_fee_calculator,
fix_recent_blockhashes_sysvar_delay,
rent_for_sysvars, rent_for_sysvars,
); );
self.accounts_db.store_cached(slot, &accounts_to_store); self.accounts_db.store_cached(slot, &accounts_to_store);
@ -924,7 +922,6 @@ impl Accounts {
loaded: &'a mut [TransactionLoadResult], loaded: &'a mut [TransactionLoadResult],
rent_collector: &RentCollector, rent_collector: &RentCollector,
last_blockhash_with_fee_calculator: &(Hash, FeeCalculator), last_blockhash_with_fee_calculator: &(Hash, FeeCalculator),
fix_recent_blockhashes_sysvar_delay: bool,
rent_for_sysvars: bool, rent_for_sysvars: bool,
) -> Vec<(&'a Pubkey, &'a AccountSharedData)> { ) -> Vec<(&'a Pubkey, &'a AccountSharedData)> {
let mut accounts = Vec::with_capacity(loaded.len()); let mut accounts = Vec::with_capacity(loaded.len());
@ -963,7 +960,6 @@ impl Accounts {
res, res,
maybe_nonce_rollback, maybe_nonce_rollback,
last_blockhash_with_fee_calculator, last_blockhash_with_fee_calculator,
fix_recent_blockhashes_sysvar_delay,
); );
if fee_payer_index.is_none() { if fee_payer_index.is_none() {
fee_payer_index = Some(i); fee_payer_index = Some(i);
@ -1011,21 +1007,13 @@ pub fn prepare_if_nonce_account(
tx_result: &Result<()>, tx_result: &Result<()>,
maybe_nonce_rollback: Option<(&Pubkey, &AccountSharedData, Option<&AccountSharedData>)>, maybe_nonce_rollback: Option<(&Pubkey, &AccountSharedData, Option<&AccountSharedData>)>,
last_blockhash_with_fee_calculator: &(Hash, FeeCalculator), last_blockhash_with_fee_calculator: &(Hash, FeeCalculator),
fix_recent_blockhashes_sysvar_delay: bool,
) -> bool { ) -> bool {
if let Some((nonce_key, nonce_acc, _maybe_fee_account)) = maybe_nonce_rollback { if let Some((nonce_key, nonce_acc, _maybe_fee_account)) = maybe_nonce_rollback {
if account_pubkey == nonce_key { if account_pubkey == nonce_key {
let overwrite = if tx_result.is_err() { if tx_result.is_err() {
// Nonce TX failed with an InstructionError. Roll back // Nonce TX failed with an InstructionError. Roll back
// its account state // its account state
*account = nonce_acc.clone(); *account = nonce_acc.clone();
true
} else {
// Retain overwrite on successful transactions until
// recent_blockhashes_sysvar_delay fix is activated
!fix_recent_blockhashes_sysvar_delay
};
if overwrite {
// Since hash_age_kind is DurableNonce, unwrap is safe here // Since hash_age_kind is DurableNonce, unwrap is safe here
let state = StateMut::<nonce::state::Versions>::state(nonce_acc) let state = StateMut::<nonce::state::Versions>::state(nonce_acc)
.unwrap() .unwrap()
@ -1987,7 +1975,6 @@ mod tests {
&rent_collector, &rent_collector,
&(Hash::default(), FeeCalculator::default()), &(Hash::default(), FeeCalculator::default()),
true, true,
true,
); );
assert_eq!(collected_accounts.len(), 2); assert_eq!(collected_accounts.len(), 2);
assert!(collected_accounts assert!(collected_accounts
@ -2140,7 +2127,6 @@ mod tests {
tx_result, tx_result,
maybe_nonce_rollback, maybe_nonce_rollback,
last_blockhash_with_fee_calculator, last_blockhash_with_fee_calculator,
true,
); );
expect_account == account expect_account == account
} }
@ -2358,7 +2344,6 @@ mod tests {
&rent_collector, &rent_collector,
&(next_blockhash, FeeCalculator::default()), &(next_blockhash, FeeCalculator::default()),
true, true,
true,
); );
assert_eq!(collected_accounts.len(), 2); assert_eq!(collected_accounts.len(), 2);
assert_eq!( assert_eq!(
@ -2475,7 +2460,6 @@ mod tests {
&rent_collector, &rent_collector,
&(next_blockhash, FeeCalculator::default()), &(next_blockhash, FeeCalculator::default()),
true, true,
true,
); );
assert_eq!(collected_accounts.len(), 1); assert_eq!(collected_accounts.len(), 1);
let collected_nonce_account = collected_accounts let collected_nonce_account = collected_accounts

View File

@ -1297,10 +1297,6 @@ impl Bank {
new.update_stake_history(Some(parent_epoch)); new.update_stake_history(Some(parent_epoch));
new.update_clock(Some(parent_epoch)); new.update_clock(Some(parent_epoch));
new.update_fees(); new.update_fees();
if !new.fix_recent_blockhashes_sysvar_delay() {
new.update_recent_blockhashes();
}
new new
} }
@ -2662,10 +2658,8 @@ impl Bank {
let mut w_blockhash_queue = self.blockhash_queue.write().unwrap(); let mut w_blockhash_queue = self.blockhash_queue.write().unwrap();
if self.is_block_boundary(self.tick_height.load(Relaxed) + 1) { if self.is_block_boundary(self.tick_height.load(Relaxed) + 1) {
w_blockhash_queue.register_hash(hash, &self.fee_calculator); w_blockhash_queue.register_hash(hash, &self.fee_calculator);
if self.fix_recent_blockhashes_sysvar_delay() {
self.update_recent_blockhashes_locked(&w_blockhash_queue); self.update_recent_blockhashes_locked(&w_blockhash_queue);
} }
}
// ReplayStage will start computing the accounts delta hash when it // ReplayStage will start computing the accounts delta hash when it
// detects the tick height has reached the boundary, so the system // detects the tick height has reached the boundary, so the system
// needs to guarantee all account updates for the slot have been // needs to guarantee all account updates for the slot have been
@ -3524,7 +3518,6 @@ impl Bank {
loaded_txs, loaded_txs,
&self.rent_collector, &self.rent_collector,
&self.last_blockhash_with_fee_calculator(), &self.last_blockhash_with_fee_calculator(),
self.fix_recent_blockhashes_sysvar_delay(),
self.rent_for_sysvars(), self.rent_for_sysvars(),
); );
let rent_debits = self.collect_rent(executed, loaded_txs); let rent_debits = self.collect_rent(executed, loaded_txs);
@ -5496,15 +5489,6 @@ impl Bank {
} }
} }
fn fix_recent_blockhashes_sysvar_delay(&self) -> bool {
match self.cluster_type() {
ClusterType::Development | ClusterType::Devnet | ClusterType::Testnet => true,
ClusterType::MainnetBeta => self
.feature_set
.is_active(&feature_set::consistent_recent_blockhashes_sysvar::id()),
}
}
fn rent_for_sysvars(&self) -> bool { fn rent_for_sysvars(&self) -> bool {
self.feature_set self.feature_set
.is_active(&feature_set::rent_for_sysvars::id()) .is_active(&feature_set::rent_for_sysvars::id())
@ -10885,25 +10869,25 @@ pub(crate) mod tests {
if bank.slot == 0 { if bank.slot == 0 {
assert_eq!( assert_eq!(
bank.hash().to_string(), bank.hash().to_string(),
"BfvaoHkrQwrkQo7T1mW6jmJXveRy11rut8bva2H1Rt5H" "DqaWg7EVKzb5Fpe92zNBtXAWqLwcedgHDicYrCBnf3QK"
); );
} }
if bank.slot == 32 { if bank.slot == 32 {
assert_eq!( assert_eq!(
bank.hash().to_string(), bank.hash().to_string(),
"JBGPApnSMPKZaYiR16v46XSSGcKxy8kCbVtN1CG1XDxW" "AYdhzhKrM74r9XuZBDGcHeFzg2DEtp1boggnEnzDjZSq"
); );
} }
if bank.slot == 64 { if bank.slot == 64 {
assert_eq!( assert_eq!(
bank.hash().to_string(), bank.hash().to_string(),
"BDCt9cGPfxpgJXzp8Tq1nX1zSqpbs8xrkAFyRhmXKiuX" "EsbPVYzo1qz5reEUH5okKW4ExB6WbcidkVdW5mzpFn7C"
); );
} }
if bank.slot == 128 { if bank.slot == 128 {
assert_eq!( assert_eq!(
bank.hash().to_string(), bank.hash().to_string(),
"4zUpK4VUhKLaPUgeMMSeDR2w827goriRL5NndJxGDVmz" "H3DWrQ6FqbLkFNDxbWQ62UKRbw2dbuxf3oVF2VpBk6Ga"
); );
break; break;
} }

View File

@ -30,10 +30,6 @@ pub mod instructions_sysvar_enabled {
solana_sdk::declare_id!("EnvhHCLvg55P7PDtbvR1NwuTuAeodqpusV3MR5QEK8gs"); solana_sdk::declare_id!("EnvhHCLvg55P7PDtbvR1NwuTuAeodqpusV3MR5QEK8gs");
} }
pub mod consistent_recent_blockhashes_sysvar {
solana_sdk::declare_id!("3h1BQWPDS5veRsq6mDBWruEpgPxRJkfwGexg5iiQ9mYg");
}
pub mod deprecate_rewards_sysvar { pub mod deprecate_rewards_sysvar {
solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu"); solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu");
} }
@ -203,7 +199,6 @@ lazy_static! {
/// Map of feature identifiers to user-visible description /// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [ pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
(instructions_sysvar_enabled::id(), "instructions sysvar"), (instructions_sysvar_enabled::id(), "instructions sysvar"),
(consistent_recent_blockhashes_sysvar::id(), "consistent recentblockhashes sysvar"),
(deprecate_rewards_sysvar::id(), "deprecate unused rewards sysvar"), (deprecate_rewards_sysvar::id(), "deprecate unused rewards sysvar"),
(pico_inflation::id(), "pico inflation"), (pico_inflation::id(), "pico inflation"),
(full_inflation::devnet_and_testnet::id(), "full inflation on devnet and testnet"), (full_inflation::devnet_and_testnet::id(), "full inflation on devnet and testnet"),