From 04016e3bcf1463bbb5aeda1861767f37a0697843 Mon Sep 17 00:00:00 2001 From: Brooks Prumo Date: Wed, 23 Nov 2022 09:11:28 -0500 Subject: [PATCH] Don't wait for EAH unless feature is enabled (#28938) --- runtime/src/bank.rs | 24 +++++++++++++++--------- runtime/src/serde_snapshot/tests.rs | 5 +++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index c4eeaacc67..f7dad2e36f 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -7787,22 +7787,28 @@ impl Bank { /// EAH *must* be included. This means if an EAH calculation is currently in-flight we will /// wait for it to complete. pub fn get_epoch_accounts_hash_to_serialize(&self) -> Option { - let should_get_epoch_accounts_hash = epoch_accounts_hash::is_enabled_this_epoch(self) + let should_get_epoch_accounts_hash = self + .feature_set + .is_active(&feature_set::epoch_accounts_hash::id()) + && epoch_accounts_hash::is_enabled_this_epoch(self) && epoch_accounts_hash::is_in_calculation_window(self); - let (epoch_accounts_hash, measure) = measure!(should_get_epoch_accounts_hash.then(|| { - self.rc - .accounts - .accounts_db - .epoch_accounts_hash_manager - .wait_get_epoch_accounts_hash() - })); + if !should_get_epoch_accounts_hash { + return None; + } + + let (epoch_accounts_hash, measure) = measure!(self + .rc + .accounts + .accounts_db + .epoch_accounts_hash_manager + .wait_get_epoch_accounts_hash()); datapoint_info!( "bank-get_epoch_accounts_hash_to_serialize", ("slot", self.slot(), i64), ("waiting-time-us", measure.as_us(), i64), ); - epoch_accounts_hash + Some(epoch_accounts_hash) } /// Convenience fn to get the Epoch Accounts Hash diff --git a/runtime/src/serde_snapshot/tests.rs b/runtime/src/serde_snapshot/tests.rs index def07fcd63..7c29430ccf 100644 --- a/runtime/src/serde_snapshot/tests.rs +++ b/runtime/src/serde_snapshot/tests.rs @@ -8,7 +8,7 @@ use { append_vec::AppendVec, bank::{Bank, Rewrites}, epoch_accounts_hash, - genesis_utils::{activate_all_features, activate_feature}, + genesis_utils::{self, activate_all_features, activate_feature}, snapshot_utils::ArchiveFormat, status_cache::StatusCache, }, @@ -17,7 +17,7 @@ use { solana_sdk::{ account::{AccountSharedData, ReadableAccount}, clock::Slot, - feature_set::disable_fee_calculator, + feature_set::{self, disable_fee_calculator}, genesis_config::{create_genesis_config, ClusterType}, pubkey::Pubkey, signature::{Keypair, Signer}, @@ -228,6 +228,7 @@ fn test_bank_serialize_style( ) { solana_logger::setup(); let (mut genesis_config, _) = create_genesis_config(500); + genesis_utils::activate_feature(&mut genesis_config, feature_set::epoch_accounts_hash::id()); genesis_config.epoch_schedule = EpochSchedule::custom(400, 400, false); let bank0 = Arc::new(Bank::new_for_tests(&genesis_config)); let eah_start_slot = epoch_accounts_hash::calculation_start(&bank0);