diff --git a/accounts-bench/src/main.rs b/accounts-bench/src/main.rs index 1857314a92..60ff67735d 100644 --- a/accounts-bench/src/main.rs +++ b/accounts-bench/src/main.rs @@ -9,7 +9,7 @@ use { accounts::Accounts, accounts_db::{ test_utils::{create_test_accounts, update_accounts_bench}, - AccountShrinkThreshold, CalcAccountsHashDataSource, + AccountShrinkThreshold, AccountsDb, CalcAccountsHashDataSource, }, accounts_index::AccountSecondaryIndexes, ancestors::Ancestors, @@ -19,7 +19,7 @@ use { solana_sdk::{ genesis_config::ClusterType, pubkey::Pubkey, sysvar::epoch_schedule::EpochSchedule, }, - std::{env, fs, path::PathBuf}, + std::{env, fs, path::PathBuf, sync::Arc}, }; fn main() { @@ -69,12 +69,13 @@ fn main() { if fs::remove_dir_all(path.clone()).is_err() { println!("Warning: Couldn't remove {path:?}"); } - let accounts = Accounts::new_with_config_for_benches( + let accounts_db = AccountsDb::new_with_config_for_benches( vec![path], &ClusterType::Testnet, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); println!("Creating {num_accounts} accounts"); let mut create_time = Measure::start("create accounts"); let pubkeys: Vec<_> = (0..num_slots) diff --git a/accounts-db/src/accounts.rs b/accounts-db/src/accounts.rs index 8ca26dfe0e..78119c7e47 100644 --- a/accounts-db/src/accounts.rs +++ b/accounts-db/src/accounts.rs @@ -1,15 +1,10 @@ -#[cfg(feature = "dev-context-only-utils")] -use crate::accounts_db::{ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING}; use { crate::{ accounts_db::{ - AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, AccountsDbConfig, LoadHint, - LoadedAccount, ScanStorageResult, VerifyAccountsHashAndLamportsConfig, + AccountsAddRootTiming, AccountsDb, LoadHint, LoadedAccount, ScanStorageResult, + VerifyAccountsHashAndLamportsConfig, }, - accounts_index::{ - AccountSecondaryIndexes, IndexKey, ScanConfig, ScanError, ScanResult, ZeroLamport, - }, - accounts_update_notifier_interface::AccountsUpdateNotifier, + accounts_index::{IndexKey, ScanConfig, ScanError, ScanResult, ZeroLamport}, ancestors::Ancestors, nonce_info::{NonceFull, NonceInfo}, rent_collector::RentCollector, @@ -24,7 +19,6 @@ use { account_utils::StateMut, address_lookup_table::{self, error::AddressLookupError, state::AddressLookupTable}, clock::{BankId, Slot}, - genesis_config::ClusterType, message::v0::{LoadedAddresses, MessageAddressTableLookup}, nonce::{ state::{DurableNonce, Versions as NonceVersions}, @@ -42,9 +36,8 @@ use { BinaryHeap, HashMap, HashSet, }, ops::RangeBounds, - path::PathBuf, sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, + atomic::{AtomicUsize, Ordering}, Arc, Mutex, }, }, @@ -125,30 +118,6 @@ pub enum AccountAddressFilter { } impl Accounts { - pub fn default_for_tests() -> Self { - Self::new(Arc::new(AccountsDb::default_for_tests())) - } - - pub fn new_with_config( - paths: Vec, - cluster_type: &ClusterType, - account_indexes: AccountSecondaryIndexes, - shrink_ratio: AccountShrinkThreshold, - accounts_db_config: Option, - accounts_update_notifier: Option, - exit: Arc, - ) -> Self { - Self::new(Arc::new(AccountsDb::new_with_config( - paths, - cluster_type, - account_indexes, - shrink_ratio, - accounts_db_config, - accounts_update_notifier, - exit, - ))) - } - pub fn new(accounts_db: Arc) -> Self { Self { accounts_db, @@ -797,44 +766,6 @@ impl Accounts { } } -// These functions/fields are only usable from a dev context (i.e. tests and benches) -#[cfg(feature = "dev-context-only-utils")] -impl Accounts { - pub fn new_with_config_for_tests( - paths: Vec, - cluster_type: &ClusterType, - account_indexes: AccountSecondaryIndexes, - shrink_ratio: AccountShrinkThreshold, - ) -> Self { - Self::new_with_config( - paths, - cluster_type, - account_indexes, - shrink_ratio, - Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), - None, - Arc::default(), - ) - } - - pub fn new_with_config_for_benches( - paths: Vec, - cluster_type: &ClusterType, - account_indexes: AccountSecondaryIndexes, - shrink_ratio: AccountShrinkThreshold, - ) -> Self { - Self::new_with_config( - paths, - cluster_type, - account_indexes, - shrink_ratio, - Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS), - None, - Arc::default(), - ) - } -} - fn prepare_if_nonce_account( address: &Pubkey, account: &mut AccountSharedData, @@ -893,6 +824,8 @@ mod tests { use { super::*, crate::{ + accounts_db::AccountShrinkThreshold, + accounts_index::AccountSecondaryIndexes, rent_collector::RentCollector, transaction_results::{DurableNonceFee, TransactionExecutionDetails}, }, @@ -949,7 +882,8 @@ mod tests { #[test] fn test_hold_range_in_memory() { - let accts = Accounts::default_for_tests(); + let accounts_db = AccountsDb::default_for_tests(); + let accts = Accounts::new(Arc::new(accounts_db)); let range = Pubkey::from([0; 32])..=Pubkey::from([0xff; 32]); accts.hold_range_in_memory(&range, true, &test_thread_pool()); accts.hold_range_in_memory(&range, false, &test_thread_pool()); @@ -961,7 +895,8 @@ mod tests { #[test] fn test_hold_range_in_memory2() { - let accts = Accounts::default_for_tests(); + let accounts_db = AccountsDb::default_for_tests(); + let accts = Accounts::new(Arc::new(accounts_db)); let range = Pubkey::from([0; 32])..=Pubkey::from([0xff; 32]); let idx = &accts.accounts_db.accounts_index; let bins = idx.account_maps.len(); @@ -1004,12 +939,13 @@ mod tests { #[test] fn test_load_lookup_table_addresses_account_not_found() { let ancestors = vec![(0, 0)].into_iter().collect(); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let invalid_table_key = Pubkey::new_unique(); let address_table_lookup = MessageAddressTableLookup { @@ -1031,12 +967,13 @@ mod tests { #[test] fn test_load_lookup_table_addresses_invalid_account_owner() { let ancestors = vec![(0, 0)].into_iter().collect(); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let invalid_table_key = Pubkey::new_unique(); let mut invalid_table_account = AccountSharedData::default(); @@ -1062,12 +999,13 @@ mod tests { #[test] fn test_load_lookup_table_addresses_invalid_account_data() { let ancestors = vec![(0, 0)].into_iter().collect(); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let invalid_table_key = Pubkey::new_unique(); let invalid_table_account = @@ -1093,12 +1031,13 @@ mod tests { #[test] fn test_load_lookup_table_addresses() { let ancestors = vec![(1, 1), (0, 0)].into_iter().collect(); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let table_key = Pubkey::new_unique(); let table_addresses = vec![Pubkey::new_unique(), Pubkey::new_unique()]; @@ -1138,12 +1077,13 @@ mod tests { #[test] fn test_load_by_program_slot() { - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); // Load accounts owned by various programs into AccountsDb let pubkey0 = solana_sdk::pubkey::new_rand(); @@ -1166,24 +1106,26 @@ mod tests { #[test] fn test_accounts_empty_bank_hash_stats() { - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); assert!(accounts.accounts_db.get_bank_hash_stats(0).is_some()); assert!(accounts.accounts_db.get_bank_hash_stats(1).is_none()); } #[test] fn test_lock_accounts_with_duplicates() { - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let keypair = Keypair::new(); let message = Message { @@ -1202,12 +1144,13 @@ mod tests { #[test] fn test_lock_accounts_with_too_many_accounts() { - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let keypair = Keypair::new(); @@ -1267,12 +1210,13 @@ mod tests { let account2 = AccountSharedData::new(3, 0, &Pubkey::default()); let account3 = AccountSharedData::new(4, 0, &Pubkey::default()); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); accounts.store_for_tests(0, &keypair0.pubkey(), &account0); accounts.store_for_tests(0, &keypair1.pubkey(), &account1); accounts.store_for_tests(0, &keypair2.pubkey(), &account2); @@ -1376,12 +1320,13 @@ mod tests { let account1 = AccountSharedData::new(2, 0, &Pubkey::default()); let account2 = AccountSharedData::new(3, 0, &Pubkey::default()); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); accounts.store_for_tests(0, &keypair0.pubkey(), &account0); accounts.store_for_tests(0, &keypair1.pubkey(), &account1); accounts.store_for_tests(0, &keypair2.pubkey(), &account2); @@ -1457,12 +1402,13 @@ mod tests { let account2 = AccountSharedData::new(3, 0, &Pubkey::default()); let account3 = AccountSharedData::new(4, 0, &Pubkey::default()); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); accounts.store_for_tests(0, &keypair0.pubkey(), &account0); accounts.store_for_tests(0, &keypair1.pubkey(), &account1); accounts.store_for_tests(0, &keypair2.pubkey(), &account2); @@ -1533,12 +1479,13 @@ mod tests { let account2 = AccountSharedData::new(3, 0, &Pubkey::default()); let account3 = AccountSharedData::new(4, 0, &Pubkey::default()); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); accounts.store_for_tests(0, &keypair0.pubkey(), &account0); accounts.store_for_tests(0, &keypair1.pubkey(), &account1); accounts.store_for_tests(0, &keypair2.pubkey(), &account2); @@ -1692,12 +1639,13 @@ mod tests { let mut loaded = vec![loaded0, loaded1]; - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); { accounts .account_locks @@ -1743,12 +1691,13 @@ mod tests { #[test] fn huge_clean() { solana_logger::setup(); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let mut old_pubkey = Pubkey::default(); let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner()); info!("storing.."); @@ -2082,12 +2031,13 @@ mod tests { let mut loaded = vec![loaded]; let durable_nonce = DurableNonce::from_blockhash(&Hash::new_unique()); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let txs = vec![tx]; let execution_results = vec![new_execution_result( Err(TransactionError::InstructionError( @@ -2195,12 +2145,13 @@ mod tests { let mut loaded = vec![loaded]; let durable_nonce = DurableNonce::from_blockhash(&Hash::new_unique()); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let txs = vec![tx]; let execution_results = vec![new_execution_result( Err(TransactionError::InstructionError( @@ -2236,12 +2187,13 @@ mod tests { #[test] fn test_load_largest_accounts() { - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); /* This test assumes pubkey0 < pubkey1 < pubkey2. * But the keys created with new_unique() does not gurantee this diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 89f5692053..743768e485 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -9522,6 +9522,40 @@ pub(crate) enum UpdateIndexThreadSelection { // These functions/fields are only usable from a dev context (i.e. tests and benches) #[cfg(feature = "dev-context-only-utils")] impl AccountsDb { + pub fn new_with_config_for_tests( + paths: Vec, + cluster_type: &ClusterType, + account_indexes: AccountSecondaryIndexes, + shrink_ratio: AccountShrinkThreshold, + ) -> Self { + Self::new_with_config( + paths, + cluster_type, + account_indexes, + shrink_ratio, + Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), + None, + Arc::default(), + ) + } + + pub fn new_with_config_for_benches( + paths: Vec, + cluster_type: &ClusterType, + account_indexes: AccountSecondaryIndexes, + shrink_ratio: AccountShrinkThreshold, + ) -> Self { + Self::new_with_config( + paths, + cluster_type, + account_indexes, + shrink_ratio, + Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS), + None, + Arc::default(), + ) + } + pub fn load_without_fixed_root( &self, ancestors: &Ancestors, @@ -9821,23 +9855,6 @@ pub mod tests { } impl AccountsDb { - pub fn new_with_config_for_tests( - paths: Vec, - cluster_type: &ClusterType, - account_indexes: AccountSecondaryIndexes, - shrink_ratio: AccountShrinkThreshold, - ) -> Self { - Self::new_with_config( - paths, - cluster_type, - account_indexes, - shrink_ratio, - Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), - None, - Arc::default(), - ) - } - pub fn new_sized(paths: Vec, file_size: u64) -> Self { AccountsDb { file_size, diff --git a/runtime/benches/accounts.rs b/runtime/benches/accounts.rs index ac74f32eb5..2822c25331 100644 --- a/runtime/benches/accounts.rs +++ b/runtime/benches/accounts.rs @@ -10,7 +10,7 @@ use { solana_accounts_db::{ accounts::{AccountAddressFilter, Accounts}, accounts_db::{ - test_utils::create_test_accounts, AccountShrinkThreshold, + test_utils::create_test_accounts, AccountShrinkThreshold, AccountsDb, VerifyAccountsHashAndLamportsConfig, }, accounts_index::{AccountSecondaryIndexes, ScanConfig}, @@ -99,12 +99,13 @@ fn test_accounts_squash(bencher: &mut Bencher) { #[bench] fn test_accounts_hash_bank_hash(bencher: &mut Bencher) { - let accounts = Accounts::new_with_config_for_benches( + let accounts_db = AccountsDb::new_with_config_for_benches( vec![PathBuf::from("bench_accounts_hash_internal")], &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let mut pubkeys: Vec = vec![]; let num_accounts = 60_000; let slot = 0; @@ -136,12 +137,13 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) { #[bench] fn test_update_accounts_hash(bencher: &mut Bencher) { solana_logger::setup(); - let accounts = Accounts::new_with_config_for_benches( + let accounts_db = AccountsDb::new_with_config_for_benches( vec![PathBuf::from("update_accounts_hash")], &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let mut pubkeys: Vec = vec![]; create_test_accounts(&accounts, &mut pubkeys, 50_000, 0); let ancestors = Ancestors::from(vec![0]); @@ -155,12 +157,13 @@ fn test_update_accounts_hash(bencher: &mut Bencher) { #[bench] fn test_accounts_delta_hash(bencher: &mut Bencher) { solana_logger::setup(); - let accounts = Accounts::new_with_config_for_benches( + let accounts_db = AccountsDb::new_with_config_for_benches( vec![PathBuf::from("accounts_delta_hash")], &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let mut pubkeys: Vec = vec![]; create_test_accounts(&accounts, &mut pubkeys, 100_000, 0); bencher.iter(|| { @@ -171,12 +174,13 @@ fn test_accounts_delta_hash(bencher: &mut Bencher) { #[bench] fn bench_delete_dependencies(bencher: &mut Bencher) { solana_logger::setup(); - let accounts = Accounts::new_with_config_for_benches( + let accounts_db = AccountsDb::new_with_config_for_benches( vec![PathBuf::from("accounts_delete_deps")], &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let mut old_pubkey = Pubkey::default(); let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner()); for i in 0..1000 { @@ -200,7 +204,7 @@ fn store_accounts_with_possible_contention( F: Fn(&Accounts, &[Pubkey]) + Send + Copy, { let num_readers = 5; - let accounts = Arc::new(Accounts::new_with_config_for_benches( + let accounts_db = AccountsDb::new_with_config_for_benches( vec![ PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string())) .join(bench_name), @@ -208,7 +212,8 @@ fn store_accounts_with_possible_contention( &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), - )); + ); + let accounts = Arc::new(Accounts::new(Arc::new(accounts_db))); let num_keys = 1000; let slot = 0; accounts.add_root(slot); @@ -336,7 +341,7 @@ fn bench_rwlock_hashmap_single_reader_with_n_writers(bencher: &mut Bencher) { } fn setup_bench_dashmap_iter() -> (Arc, DashMap) { - let accounts = Arc::new(Accounts::new_with_config_for_benches( + let accounts_db = AccountsDb::new_with_config_for_benches( vec![ PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string())) .join("bench_dashmap_par_iter"), @@ -344,7 +349,8 @@ fn setup_bench_dashmap_iter() -> (Arc, DashMap Vec { let mut hash_queue = BlockhashQueue::new(100); hash_queue.register_hash(&tx.message().recent_blockhash, lamports_per_signature); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); for ka in ka.iter() { accounts.accounts_db.store_for_tests(0, &[(&ka.0, &ka.1)]); } @@ -1387,12 +1388,13 @@ mod tests { #[test] fn test_instructions() { solana_logger::setup(); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let instructions_key = solana_sdk::sysvar::instructions::id(); let keypair = Keypair::new(); @@ -1413,12 +1415,13 @@ mod tests { #[test] fn test_overrides() { solana_logger::setup(); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let mut account_overrides = AccountOverrides::default(); let slot_history_id = sysvar::slot_history::id(); let account = AccountSharedData::new(42, 0, &Pubkey::default()); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index fc1b92fca2..384da6d61e 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1100,7 +1100,7 @@ impl Bank { accounts_update_notifier: Option, exit: Arc, ) -> Self { - let accounts = Accounts::new_with_config( + let accounts_db = AccountsDb::new_with_config( paths, &genesis_config.cluster_type, account_indexes, @@ -1109,6 +1109,7 @@ impl Bank { accounts_update_notifier, exit, ); + let accounts = Accounts::new(Arc::new(accounts_db)); let mut bank = Self::default_with_accounts(accounts); bank.ancestors = Ancestors::from(vec![bank.slot()]); bank.transaction_debug_keys = debug_keys; @@ -8173,7 +8174,9 @@ impl Bank { } pub fn default_for_tests() -> Self { - Self::default_with_accounts(Accounts::default_for_tests()) + let accounts_db = AccountsDb::default_for_tests(); + let accounts = Accounts::new(Arc::new(accounts_db)); + Self::default_with_accounts(accounts) } pub fn new_with_bank_forks_for_tests( diff --git a/runtime/src/serde_snapshot/tests.rs b/runtime/src/serde_snapshot/tests.rs index e305e06262..391617b5eb 100644 --- a/runtime/src/serde_snapshot/tests.rs +++ b/runtime/src/serde_snapshot/tests.rs @@ -223,12 +223,13 @@ mod serde_snapshot_tests { fn test_accounts_serialize_style(serde_style: SerdeStyle) { solana_logger::setup(); let (_accounts_dir, paths) = get_temp_accounts_paths(4).unwrap(); - let accounts = Accounts::new_with_config_for_tests( + let accounts_db = AccountsDb::new_with_config_for_tests( paths, &ClusterType::Development, AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); + let accounts = Accounts::new(Arc::new(accounts_db)); let slot = 0; let mut pubkeys: Vec = vec![]; diff --git a/runtime/src/snapshot_package.rs b/runtime/src/snapshot_package.rs index 8053a13d2c..f5623c550a 100644 --- a/runtime/src/snapshot_package.rs +++ b/runtime/src/snapshot_package.rs @@ -8,7 +8,7 @@ use { log::*, solana_accounts_db::{ accounts::Accounts, - accounts_db::AccountStorageEntry, + accounts_db::{AccountStorageEntry, AccountsDb}, accounts_hash::{AccountsHash, AccountsHashKind}, epoch_accounts_hash::EpochAccountsHash, rent_collector::RentCollector, @@ -159,6 +159,8 @@ impl AccountsPackage { /// Create a new Accounts Package where basically every field is defaulted. /// Only use for tests; many of the fields are invalid! pub fn default_for_tests() -> Self { + let accounts_db = AccountsDb::default_for_tests(); + let accounts = Accounts::new(Arc::new(accounts_db)); Self { package_kind: AccountsPackageKind::AccountsHashVerifier, slot: Slot::default(), @@ -166,7 +168,7 @@ impl AccountsPackage { snapshot_storages: Vec::default(), expected_capitalization: u64::default(), accounts_hash_for_testing: Option::default(), - accounts: Arc::new(Accounts::default_for_tests()), + accounts: Arc::new(accounts), epoch_schedule: EpochSchedule::default(), rent_collector: RentCollector::default(), is_incremental_accounts_hash_feature_enabled: bool::default(),