Move bank specific code out of epoch_accounts_hash/utils.rs (#32623)

* Move bank specific code out of epoch_accounts_hash/utils.rs

* cleanup
This commit is contained in:
Pankaj Garg 2023-07-25 14:12:20 -07:00 committed by GitHub
parent dbac50dcc8
commit ef8d3206d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 26 deletions

View File

@ -16,9 +16,9 @@ use {
},
accounts_hash::CalcAccountsHashConfig,
accounts_index::AccountSecondaryIndexes,
bank::{Bank, BankTestConfig},
bank::{epoch_accounts_hash_utils, Bank, BankTestConfig},
bank_forks::BankForks,
epoch_accounts_hash::{self, EpochAccountsHash},
epoch_accounts_hash::EpochAccountsHash,
genesis_utils::{self, GenesisConfigInfo},
runtime_config::RuntimeConfig,
snapshot_archive_info::SnapshotArchiveInfoGetter,
@ -140,7 +140,7 @@ impl TestEnvironment {
assert!(bank
.feature_set
.is_active(&feature_set::epoch_accounts_hash::id()));
assert!(epoch_accounts_hash::is_enabled_this_epoch(&bank));
assert!(epoch_accounts_hash_utils::is_enabled_this_epoch(&bank));
bank.set_startup_verification_complete();
@ -304,7 +304,7 @@ fn test_epoch_accounts_hash_basic(test_environment: TestEnvironment) {
// To ensure EAH calculations are correct, calculate the accounts hash here, in-band.
// This will be the expected EAH that gets saved into the "stop" bank.
if bank.slot() == epoch_accounts_hash::calculation_start(&bank) {
if bank.slot() == epoch_accounts_hash_utils::calculation_start(&bank) {
bank.freeze();
let (accounts_hash, _) = bank
.rc
@ -332,7 +332,7 @@ fn test_epoch_accounts_hash_basic(test_environment: TestEnvironment) {
}
// Test: Ensure that the "stop" bank has the correct EAH
if bank.slot() == epoch_accounts_hash::calculation_stop(&bank) {
if bank.slot() == epoch_accounts_hash_utils::calculation_stop(&bank) {
// Sometimes AHV does not get scheduled to run, which causes the test to fail
// spuriously. Sleep a bit here to ensure AHV gets a chance to run.
std::thread::sleep(Duration::from_secs(1));
@ -414,7 +414,7 @@ fn test_snapshots_have_expected_epoch_accounts_hash() {
// After submitting an EAH calculation request, wait until it gets handled by ABS so that
// subsequent snapshot requests are not swallowed.
if bank.slot() == epoch_accounts_hash::calculation_start(&bank) {
if bank.slot() == epoch_accounts_hash_utils::calculation_start(&bank) {
while bank.epoch_accounts_hash().is_none() {
std::thread::sleep(Duration::from_secs(1));
}
@ -520,7 +520,7 @@ fn test_background_services_request_handling_for_epoch_accounts_hash() {
// Based on the EAH start and snapshot interval, pick a slot to mass-root all the banks in
// this range such that an EAH request will be sent and also a snapshot request.
let eah_start_slot = epoch_accounts_hash::calculation_start(&bank);
let eah_start_slot = epoch_accounts_hash_utils::calculation_start(&bank);
let set_root_slot = next_multiple_of(eah_start_slot, FULL_SNAPSHOT_INTERVAL);
if bank.block_height() == set_root_slot {
@ -577,7 +577,7 @@ fn test_epoch_accounts_hash_and_warping() {
// Ensure warping past the EAH stop slot is OK
info!("Warping past EAH stop slot...");
let eah_stop_offset = epoch_accounts_hash::calculation_offset_stop(&bank);
let eah_stop_offset = epoch_accounts_hash_utils::calculation_offset_stop(&bank);
let eah_stop_slot_in_next_epoch =
epoch_schedule.get_first_slot_in_epoch(bank.epoch() + 1) + eah_stop_offset;
// have to set root here so that we can flush the write cache
@ -619,7 +619,7 @@ fn test_epoch_accounts_hash_and_warping() {
// Ensure warping past the EAH start slot is OK
info!("Warping past EAH start slot...");
let eah_start_offset = epoch_accounts_hash::calculation_offset_start(&bank);
let eah_start_offset = epoch_accounts_hash_utils::calculation_offset_start(&bank);
let eah_start_slot_in_next_epoch =
epoch_schedule.get_first_slot_in_epoch(bank.epoch() + 1) + eah_start_offset;
// flush the write cache so warping can calculate the accounts hash from storages

View File

@ -774,7 +774,7 @@ mod test {
use {
super::*,
crate::{
epoch_accounts_hash::{self, EpochAccountsHash},
bank::epoch_accounts_hash_utils, epoch_accounts_hash::EpochAccountsHash,
genesis_utils::create_genesis_config,
},
crossbeam_channel::unbounded,
@ -896,7 +896,7 @@ mod test {
// Since we're not using `BankForks::set_root()`, we have to handle sending the
// correct snapshot requests ourself.
if bank.slot() == epoch_accounts_hash::calculation_start(&bank) {
if bank.slot() == epoch_accounts_hash_utils::calculation_start(&bank) {
send_snapshot_request(
Arc::clone(&bank),
SnapshotRequestType::EpochAccountsHash,

View File

@ -57,7 +57,7 @@ use {
bank::metrics::*,
blockhash_queue::BlockhashQueue,
builtins::{BuiltinPrototype, BUILTINS},
epoch_accounts_hash::{self, EpochAccountsHash},
epoch_accounts_hash::EpochAccountsHash,
epoch_rewards_hasher::hash_rewards_into_partitions,
epoch_stakes::{EpochStakes, NodeVoteAccounts},
nonce_info::{NonceInfo, NoncePartial},
@ -209,6 +209,7 @@ struct VerifyAccountsHashConfig {
mod address_lookup_table;
mod builtin_programs;
pub mod epoch_accounts_hash_utils;
mod metrics;
mod serde_snapshot;
mod sysvar_cache;
@ -7030,11 +7031,11 @@ impl Bank {
return false;
}
if !epoch_accounts_hash::is_enabled_this_epoch(self) {
if !epoch_accounts_hash_utils::is_enabled_this_epoch(self) {
return false;
}
let stop_slot = epoch_accounts_hash::calculation_stop(self);
let stop_slot = epoch_accounts_hash_utils::calculation_stop(self);
self.parent_slot() < stop_slot && self.slot() >= stop_slot
}
@ -8086,8 +8087,8 @@ impl Bank {
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);
&& epoch_accounts_hash_utils::is_enabled_this_epoch(self)
&& epoch_accounts_hash_utils::is_in_calculation_window(self);
if !should_get_epoch_accounts_hash {
return None;
}

View File

@ -10,8 +10,11 @@ mod tests {
accounts_file::{AccountsFile, AccountsFileError},
accounts_hash::{AccountsDeltaHash, AccountsHash},
accounts_index::AccountSecondaryIndexes,
bank::{Bank, BankTestConfig, EpochRewardStatus, StartBlockHeightAndRewards},
epoch_accounts_hash::{self, EpochAccountsHash},
bank::{
epoch_accounts_hash_utils, Bank, BankTestConfig, EpochRewardStatus,
StartBlockHeightAndRewards,
},
epoch_accounts_hash::EpochAccountsHash,
genesis_utils::{activate_all_features, activate_feature},
runtime_config::RuntimeConfig,
serde_snapshot::{
@ -97,7 +100,7 @@ mod tests {
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);
let eah_start_slot = epoch_accounts_hash_utils::calculation_start(&bank0);
let bank1 = Bank::new_from_parent(&bank0, &Pubkey::default(), 1);
bank0.squash();

View File

@ -3,8 +3,7 @@
use {
crate::{
accounts_background_service::{AbsRequestSender, SnapshotRequest, SnapshotRequestType},
bank::{Bank, SquashTiming},
epoch_accounts_hash,
bank::{epoch_accounts_hash_utils, Bank, SquashTiming},
snapshot_config::SnapshotConfig,
},
log::*,
@ -636,11 +635,11 @@ impl BankForks {
return false;
}
if !epoch_accounts_hash::is_enabled_this_epoch(bank) {
if !epoch_accounts_hash_utils::is_enabled_this_epoch(bank) {
return false;
}
let start_slot = epoch_accounts_hash::calculation_start(bank);
let start_slot = epoch_accounts_hash_utils::calculation_start(bank);
bank.slot() > self.last_accounts_hash_slot
&& bank.parent_slot() < start_slot
&& bank.slot() >= start_slot

View File

@ -9,9 +9,6 @@
use {crate::accounts_hash::AccountsHash, solana_sdk::hash::Hash};
mod utils;
pub use utils::*;
mod manager;
pub use manager::Manager as EpochAccountsHashManager;