From 5de9be051fdf8bf96042aa66f59f7f2b857466b9 Mon Sep 17 00:00:00 2001 From: steviez Date: Mon, 28 Oct 2024 12:36:55 -0500 Subject: [PATCH] Consolidate AccountsDb parameters (#3324) Move shrink_ratio and account_indexes into AccountsDbConfig struct --- accounts-bench/src/main.rs | 6 +- accounts-cluster-bench/src/main.rs | 29 +++++++-- accounts-db/benches/accounts.rs | 8 +-- accounts-db/src/accounts_db.rs | 20 +++--- core/src/validator.rs | 10 +-- core/tests/epoch_accounts_hash.rs | 6 +- core/tests/snapshots.rs | 14 +---- ledger/src/bank_forks_utils.rs | 4 -- ledger/src/blockstore_processor.rs | 23 ++----- local-cluster/src/validator_configs.rs | 2 - program-test/src/lib.rs | 7 +-- rpc/src/rpc.rs | 8 ++- runtime/src/bank.rs | 63 +++++++------------ runtime/src/bank/accounts_lt_hash.rs | 10 +-- .../src/bank/partitioned_epoch_rewards/mod.rs | 9 +-- runtime/src/bank/serde_snapshot.rs | 13 +--- runtime/src/bank/tests.rs | 44 ++++++------- runtime/src/serde_snapshot.rs | 18 +----- runtime/src/serde_snapshot/tests.rs | 8 +-- runtime/src/snapshot_bank_utils.rs | 50 +-------------- test-validator/src/lib.rs | 2 +- validator/src/admin_rpc_service.rs | 12 +++- validator/src/main.rs | 6 +- 23 files changed, 120 insertions(+), 252 deletions(-) diff --git a/accounts-bench/src/main.rs b/accounts-bench/src/main.rs index 2c37452a79f698..28b11af1bd43a1 100644 --- a/accounts-bench/src/main.rs +++ b/accounts-bench/src/main.rs @@ -9,10 +9,8 @@ use { accounts::Accounts, accounts_db::{ test_utils::{create_test_accounts, update_accounts_bench}, - AccountShrinkThreshold, AccountsDb, CalcAccountsHashDataSource, - ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, + AccountsDb, CalcAccountsHashDataSource, ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, }, - accounts_index::AccountSecondaryIndexes, ancestors::Ancestors, }, solana_measure::measure::Measure, @@ -71,8 +69,6 @@ fn main() { } let accounts_db = AccountsDb::new_with_config( vec![path], - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS), None, Arc::default(), diff --git a/accounts-cluster-bench/src/main.rs b/accounts-cluster-bench/src/main.rs index 6c8a15dc69db69..e800945a321cce 100644 --- a/accounts-cluster-bench/src/main.rs +++ b/accounts-cluster-bench/src/main.rs @@ -1056,7 +1056,10 @@ fn main() { pub mod test { use { super::*, - solana_accounts_db::accounts_index::{AccountIndex, AccountSecondaryIndexes}, + solana_accounts_db::{ + accounts_db::ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, + accounts_index::{AccountIndex, AccountSecondaryIndexes}, + }, solana_core::validator::ValidatorConfig, solana_faucet::faucet::run_local_faucet, solana_local_cluster::{ @@ -1072,6 +1075,24 @@ pub mod test { }, }; + fn initialize_and_add_secondary_indexes(validator_config: &mut ValidatorConfig) { + if validator_config.accounts_db_config.is_none() { + validator_config.accounts_db_config = Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS); + } + + let account_indexes = &mut validator_config + .accounts_db_config + .as_mut() + .unwrap() + .account_indexes; + if account_indexes.is_none() { + *account_indexes = Some(AccountSecondaryIndexes::default()); + } + add_secondary_indexes(account_indexes.as_mut().unwrap()); + + add_secondary_indexes(&mut validator_config.rpc_config.account_indexes); + } + fn add_secondary_indexes(indexes: &mut AccountSecondaryIndexes) { indexes.indexes.insert(AccountIndex::SplTokenOwner); indexes.indexes.insert(AccountIndex::SplTokenMint); @@ -1082,9 +1103,8 @@ pub mod test { fn test_accounts_cluster_bench() { solana_logger::setup(); let mut validator_config = ValidatorConfig::default_for_test(); + initialize_and_add_secondary_indexes(&mut validator_config); let num_nodes = 1; - add_secondary_indexes(&mut validator_config.account_indexes); - add_secondary_indexes(&mut validator_config.rpc_config.account_indexes); let mut config = ClusterConfig { cluster_lamports: 10_000_000, poh_config: PohConfig::new_sleep(Duration::from_millis(50)), @@ -1133,9 +1153,8 @@ pub mod test { fn test_halt_accounts_creation_at_max() { solana_logger::setup(); let mut validator_config = ValidatorConfig::default_for_test(); + initialize_and_add_secondary_indexes(&mut validator_config); let num_nodes = 1; - add_secondary_indexes(&mut validator_config.account_indexes); - add_secondary_indexes(&mut validator_config.rpc_config.account_indexes); let mut config = ClusterConfig { cluster_lamports: 10_000_000, poh_config: PohConfig::new_sleep(Duration::from_millis(50)), diff --git a/accounts-db/benches/accounts.rs b/accounts-db/benches/accounts.rs index 53c85149fe63e4..c3d62151faa8f3 100644 --- a/accounts-db/benches/accounts.rs +++ b/accounts-db/benches/accounts.rs @@ -11,10 +11,10 @@ use { account_info::{AccountInfo, StorageLocation}, accounts::{AccountAddressFilter, Accounts}, accounts_db::{ - test_utils::create_test_accounts, AccountFromStorage, AccountShrinkThreshold, - AccountsDb, VerifyAccountsHashAndLamportsConfig, ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, + test_utils::create_test_accounts, AccountFromStorage, AccountsDb, + VerifyAccountsHashAndLamportsConfig, ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, }, - accounts_index::{AccountSecondaryIndexes, ScanConfig}, + accounts_index::ScanConfig, ancestors::Ancestors, }, solana_sdk::{ @@ -36,8 +36,6 @@ use { fn new_accounts_db(account_paths: Vec) -> AccountsDb { AccountsDb::new_with_config( account_paths, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS), None, Arc::default(), diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index e38664a70c965d..484d1fb758a152 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -496,9 +496,11 @@ pub(crate) struct ShrinkCollect<'a, T: ShrinkCollectRefs<'a>> { pub const ACCOUNTS_DB_CONFIG_FOR_TESTING: AccountsDbConfig = AccountsDbConfig { index: Some(ACCOUNTS_INDEX_CONFIG_FOR_TESTING), + account_indexes: None, base_working_path: None, accounts_hash_cache_path: None, shrink_paths: None, + shrink_ratio: DEFAULT_ACCOUNTS_SHRINK_THRESHOLD_OPTION, read_cache_limit_bytes: None, write_cache_limit_bytes: None, ancient_append_vec_offset: None, @@ -516,9 +518,11 @@ pub const ACCOUNTS_DB_CONFIG_FOR_TESTING: AccountsDbConfig = AccountsDbConfig { }; pub const ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS: AccountsDbConfig = AccountsDbConfig { index: Some(ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS), + account_indexes: None, base_working_path: None, accounts_hash_cache_path: None, shrink_paths: None, + shrink_ratio: DEFAULT_ACCOUNTS_SHRINK_THRESHOLD_OPTION, read_cache_limit_bytes: None, write_cache_limit_bytes: None, ancient_append_vec_offset: None, @@ -624,10 +628,12 @@ const ANCIENT_APPEND_VEC_DEFAULT_OFFSET: Option = Some(100_000); #[derive(Debug, Default, Clone)] pub struct AccountsDbConfig { pub index: Option, + pub account_indexes: Option, /// Base directory for various necessary files pub base_working_path: Option, pub accounts_hash_cache_path: Option, pub shrink_paths: Option>, + pub shrink_ratio: AccountShrinkThreshold, /// The low and high watermark sizes for the read cache, in bytes. /// If None, defaults will be used. pub read_cache_limit_bytes: Option<(usize, usize)>, @@ -1839,8 +1845,6 @@ impl AccountsDb { ) -> Self { let mut db = AccountsDb::new_with_config( paths, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), None, Arc::default(), @@ -1851,8 +1855,6 @@ impl AccountsDb { pub fn new_with_config( paths: Vec, - account_indexes: AccountSecondaryIndexes, - shrink_ratio: AccountShrinkThreshold, accounts_db_config: Option, accounts_update_notifier: Option, exit: Arc, @@ -1943,8 +1945,8 @@ impl AccountsDb { ancient_append_vec_offset: accounts_db_config .ancient_append_vec_offset .or(ANCIENT_APPEND_VEC_DEFAULT_OFFSET), - account_indexes, - shrink_ratio, + account_indexes: accounts_db_config.account_indexes.unwrap_or_default(), + shrink_ratio: accounts_db_config.shrink_ratio, accounts_update_notifier, create_ancient_storage: accounts_db_config.create_ancient_storage, read_only_accounts_cache: ReadOnlyAccountsCache::new( @@ -15741,8 +15743,6 @@ pub mod tests { ] { let db = AccountsDb::new_with_config( Vec::new(), - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), Some(AccountsDbConfig { ancient_append_vec_offset: Some(ancient_append_vec_offset as i64), ..ACCOUNTS_DB_CONFIG_FOR_TESTING @@ -15774,8 +15774,6 @@ pub mod tests { let ancient_append_vec_offset = 50_000; let db = AccountsDb::new_with_config( Vec::new(), - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), Some(AccountsDbConfig { ancient_append_vec_offset: Some(ancient_append_vec_offset), ..ACCOUNTS_DB_CONFIG_FOR_TESTING @@ -15828,8 +15826,6 @@ pub mod tests { for starting_slot_offset in [0, avoid_saturation] { let db = AccountsDb::new_with_config( Vec::new(), - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), Some(AccountsDbConfig { ancient_append_vec_offset: Some(ancient_append_vec_offset), ..ACCOUNTS_DB_CONFIG_FOR_TESTING diff --git a/core/src/validator.rs b/core/src/validator.rs index 280fd1c80bb7f3..e11b9f96b751bf 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -37,8 +37,7 @@ use { lazy_static::lazy_static, quinn::Endpoint, solana_accounts_db::{ - accounts_db::{AccountShrinkThreshold, AccountsDbConfig}, - accounts_index::AccountSecondaryIndexes, + accounts_db::{AccountsDbConfig, ACCOUNTS_DB_CONFIG_FOR_TESTING}, accounts_update_notifier_interface::AccountsUpdateNotifier, hardened_unpack::{ open_genesis_config, OpenGenesisConfigError, MAX_GENESIS_ARCHIVE_UNPACKED_SIZE, @@ -261,7 +260,6 @@ pub struct ValidatorConfig { pub poh_pinned_cpu_core: usize, pub poh_hashes_per_batch: u64, pub process_ledger_before_services: bool, - pub account_indexes: AccountSecondaryIndexes, pub accounts_db_config: Option, pub warp_slot: Option, pub accounts_db_test_hash_calculation: bool, @@ -271,7 +269,6 @@ pub struct ValidatorConfig { pub staked_nodes_overrides: Arc>>, pub validator_exit: Arc>, pub no_wait_for_vote_to_start_leader: bool, - pub accounts_shrink_ratio: AccountShrinkThreshold, pub wait_to_vote_slot: Option, pub ledger_column_options: LedgerColumnOptions, pub runtime_config: RuntimeConfig, @@ -335,7 +332,6 @@ impl Default for ValidatorConfig { poh_pinned_cpu_core: poh_service::DEFAULT_PINNED_CPU_CORE, poh_hashes_per_batch: poh_service::DEFAULT_HASHES_PER_BATCH, process_ledger_before_services: false, - account_indexes: AccountSecondaryIndexes::default(), warp_slot: None, accounts_db_test_hash_calculation: false, accounts_db_skip_shrink: false, @@ -344,7 +340,6 @@ impl Default for ValidatorConfig { staked_nodes_overrides: Arc::new(RwLock::new(HashMap::new())), validator_exit: Arc::new(RwLock::new(Exit::default())), no_wait_for_vote_to_start_leader: true, - accounts_shrink_ratio: AccountShrinkThreshold::default(), accounts_db_config: None, wait_to_vote_slot: None, ledger_column_options: LedgerColumnOptions::default(), @@ -371,6 +366,7 @@ impl ValidatorConfig { pub fn default_for_test() -> Self { Self { enforce_ulimit_nofile: false, + accounts_db_config: Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), rpc_config: JsonRpcConfig::default_for_test(), block_production_method: BlockProductionMethod::default(), enable_block_production_forwarding: true, // enable forwarding by default for tests @@ -1943,9 +1939,7 @@ fn load_blockstore( halt_at_slot, new_hard_forks: config.new_hard_forks.clone(), debug_keys: config.debug_keys.clone(), - account_indexes: config.account_indexes.clone(), accounts_db_config: config.accounts_db_config.clone(), - shrink_ratio: config.accounts_shrink_ratio, accounts_db_test_hash_calculation: config.accounts_db_test_hash_calculation, accounts_db_skip_shrink: config.accounts_db_skip_shrink, accounts_db_force_initial_clean: config.accounts_db_force_initial_clean, diff --git a/core/tests/epoch_accounts_hash.rs b/core/tests/epoch_accounts_hash.rs index f70815a640c595..c94fef0e3ffe99 100755 --- a/core/tests/epoch_accounts_hash.rs +++ b/core/tests/epoch_accounts_hash.rs @@ -5,9 +5,7 @@ use { crate::snapshot_utils::create_tmp_accounts_dir_for_tests, log::*, solana_accounts_db::{ - accounts_db::{AccountShrinkThreshold, CalcAccountsHashDataSource}, - accounts_hash::CalcAccountsHashConfig, - accounts_index::AccountSecondaryIndexes, + accounts_db::CalcAccountsHashDataSource, accounts_hash::CalcAccountsHashConfig, epoch_accounts_hash::EpochAccountsHash, }, solana_core::{ @@ -456,9 +454,7 @@ fn test_snapshots_have_expected_epoch_accounts_hash() { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), true, true, false, diff --git a/core/tests/snapshots.rs b/core/tests/snapshots.rs index abda76928dc3dd..11855f60acf819 100644 --- a/core/tests/snapshots.rs +++ b/core/tests/snapshots.rs @@ -6,8 +6,7 @@ use { itertools::Itertools, log::{info, trace}, solana_accounts_db::{ - accounts_db::{self, AccountsDbConfig, ACCOUNTS_DB_CONFIG_FOR_TESTING}, - accounts_index::AccountSecondaryIndexes, + accounts_db::{AccountsDbConfig, ACCOUNTS_DB_CONFIG_FOR_TESTING}, epoch_accounts_hash::EpochAccountsHash, }, solana_core::{ @@ -20,7 +19,7 @@ use { AbsRequestHandlers, AbsRequestSender, AccountsBackgroundService, PrunedBanksRequestHandler, SendDroppedBankCallback, SnapshotRequestHandler, }, - bank::Bank, + bank::{Bank, BankTestConfig}, bank_forks::BankForks, genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo}, runtime_config::RuntimeConfig, @@ -96,9 +95,8 @@ impl SnapshotTestConfig { let bank0 = Bank::new_with_paths_for_tests( &genesis_config_info.genesis_config, Arc::::default(), + BankTestConfig::default(), vec![accounts_dir.clone()], - AccountSecondaryIndexes::default(), - accounts_db::AccountShrinkThreshold::default(), ); bank0.freeze(); bank0.set_startup_verification_complete(); @@ -160,9 +158,7 @@ fn restore_from_snapshot( &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - accounts_db::AccountShrinkThreshold::default(), check_hash_calculation, false, false, @@ -611,9 +607,7 @@ fn restore_from_snapshots_and_check_banks_are_equal( &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - accounts_db::AccountShrinkThreshold::default(), false, false, false, @@ -846,9 +840,7 @@ fn test_snapshots_with_background_services( &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - accounts_db::AccountShrinkThreshold::default(), false, false, false, diff --git a/ledger/src/bank_forks_utils.rs b/ledger/src/bank_forks_utils.rs index b26e5ef5e07c64..3afacad873951f 100644 --- a/ledger/src/bank_forks_utils.rs +++ b/ledger/src/bank_forks_utils.rs @@ -285,9 +285,7 @@ fn bank_forks_from_snapshot( &process_options.runtime_config, process_options.debug_keys.clone(), None, - process_options.account_indexes.clone(), process_options.limit_load_slot_count_from_snapshot, - process_options.shrink_ratio, process_options.verify_index, process_options.accounts_db_config.clone(), accounts_update_notifier, @@ -314,9 +312,7 @@ fn bank_forks_from_snapshot( &process_options.runtime_config, process_options.debug_keys.clone(), None, - process_options.account_indexes.clone(), process_options.limit_load_slot_count_from_snapshot, - process_options.shrink_ratio, process_options.accounts_db_test_hash_calculation, process_options.accounts_db_skip_shrink, process_options.accounts_db_force_initial_clean, diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 52c75a172c9e2e..b8186e7a9a3ee8 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -16,9 +16,7 @@ use { rayon::{prelude::*, ThreadPool}, scopeguard::defer, solana_accounts_db::{ - accounts_db::{AccountShrinkThreshold, AccountsDbConfig}, - accounts_index::AccountSecondaryIndexes, - accounts_update_notifier_interface::AccountsUpdateNotifier, + accounts_db::AccountsDbConfig, accounts_update_notifier_interface::AccountsUpdateNotifier, epoch_accounts_hash::EpochAccountsHash, }, solana_cost_model::cost_model::CostModel, @@ -831,7 +829,6 @@ pub struct ProcessOptions { pub slot_callback: Option, pub new_hard_forks: Option>, pub debug_keys: Option>>, - pub account_indexes: AccountSecondaryIndexes, pub limit_load_slot_count_from_snapshot: Option, pub allow_dead_slots: bool, pub accounts_db_test_hash_calculation: bool, @@ -839,7 +836,6 @@ pub struct ProcessOptions { pub accounts_db_force_initial_clean: bool, pub accounts_db_config: Option, pub verify_index: bool, - pub shrink_ratio: AccountShrinkThreshold, pub runtime_config: RuntimeConfig, pub on_halt_store_hash_raw_data_for_debug: bool, /// true if after processing the contents of the blockstore at startup, we should run an accounts hash calc @@ -938,8 +934,6 @@ pub(crate) fn process_blockstore_for_bank_0( account_paths, opts.debug_keys.clone(), None, - opts.account_indexes.clone(), - opts.shrink_ratio, false, opts.accounts_db_config.clone(), accounts_update_notifier, @@ -2993,7 +2987,7 @@ pub mod tests { let blockstore = Blockstore::open(ledger_path.path()).unwrap(); // Let `last_slot` be the number of slots in the first two epochs - let epoch_schedule = get_epoch_schedule(&genesis_config, Vec::new()); + let epoch_schedule = get_epoch_schedule(&genesis_config); let last_slot = epoch_schedule.get_last_slot_in_epoch(1); // Create a single chain of slots with all indexes in the range [0, v + 1] @@ -4296,17 +4290,8 @@ pub mod tests { assert_eq!(bank0.get_balance(&keypair.pubkey()), 1) } - fn get_epoch_schedule( - genesis_config: &GenesisConfig, - account_paths: Vec, - ) -> EpochSchedule { - let bank = Bank::new_with_paths_for_tests( - genesis_config, - Arc::::default(), - account_paths, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), - ); + fn get_epoch_schedule(genesis_config: &GenesisConfig) -> EpochSchedule { + let bank = Bank::new_for_tests(genesis_config); bank.epoch_schedule().clone() } diff --git a/local-cluster/src/validator_configs.rs b/local-cluster/src/validator_configs.rs index 786d2e39e57aa4..f565273d461f34 100644 --- a/local-cluster/src/validator_configs.rs +++ b/local-cluster/src/validator_configs.rs @@ -45,7 +45,6 @@ pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig { no_os_cpu_stats_reporting: config.no_os_cpu_stats_reporting, no_os_disk_stats_reporting: config.no_os_disk_stats_reporting, poh_pinned_cpu_core: config.poh_pinned_cpu_core, - account_indexes: config.account_indexes.clone(), warp_slot: config.warp_slot, accounts_db_test_hash_calculation: config.accounts_db_test_hash_calculation, accounts_db_skip_shrink: config.accounts_db_skip_shrink, @@ -56,7 +55,6 @@ pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig { poh_hashes_per_batch: config.poh_hashes_per_batch, process_ledger_before_services: config.process_ledger_before_services, no_wait_for_vote_to_start_leader: config.no_wait_for_vote_to_start_leader, - accounts_shrink_ratio: config.accounts_shrink_ratio, accounts_db_config: config.accounts_db_config.clone(), wait_to_vote_slot: config.wait_to_vote_slot, ledger_column_options: config.ledger_column_options.clone(), diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index 38199b270f1d52..1115330888d8a4 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -8,10 +8,7 @@ use { base64::{prelude::BASE64_STANDARD, Engine}, chrono_humanize::{Accuracy, HumanTime, Tense}, log::*, - solana_accounts_db::{ - accounts_db::AccountShrinkThreshold, accounts_index::AccountSecondaryIndexes, - epoch_accounts_hash::EpochAccountsHash, - }, + solana_accounts_db::epoch_accounts_hash::EpochAccountsHash, solana_banks_client::start_client, solana_banks_server::banks_server::start_local_server, solana_bpf_loader_program::serialization::serialize_parameters, @@ -859,8 +856,6 @@ impl ProgramTest { Vec::default(), None, None, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), false, None, None, diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index e29257b3986f2e..40bd47f71c0e16 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -4330,6 +4330,7 @@ pub mod tests { jsonrpc_core::{futures, ErrorCode, MetaIoHandler, Output, Response, Value}, jsonrpc_core_client::transports::local, serde::de::DeserializeOwned, + solana_accounts_db::accounts_db::{AccountsDbConfig, ACCOUNTS_DB_CONFIG_FOR_TESTING}, solana_entry::entry::next_versioned_entry, solana_gossip::socketaddr, solana_ledger::{ @@ -4468,7 +4469,10 @@ pub mod tests { fn start_with_config(config: JsonRpcConfig) -> Self { let (bank_forks, mint_keypair, leader_vote_keypair) = new_bank_forks_with_config(BankTestConfig { - secondary_indexes: config.account_indexes.clone(), + accounts_db_config: AccountsDbConfig { + account_indexes: Some(config.account_indexes.clone()), + ..ACCOUNTS_DB_CONFIG_FOR_TESTING + }, }); let ledger_path = get_tmp_ledger_path!(); @@ -6654,7 +6658,7 @@ pub mod tests { EpochSchedule::custom(TEST_SLOTS_PER_EPOCH, TEST_SLOTS_PER_EPOCH, false); genesis_config.fee_rate_governor = FeeRateGovernor::new(TEST_SIGNATURE_FEE, 0); - let bank = Bank::new_for_tests_with_config(&genesis_config, config); + let bank = Bank::new_with_config_for_tests(&genesis_config, config); ( BankForks::new_rw_arc(bank), mint_keypair, diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 01638b913cec97..a49f391a36a799 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -74,15 +74,14 @@ use { account_locks::validate_account_locks, accounts::{AccountAddressFilter, Accounts, PubkeyAccountSlot}, accounts_db::{ - AccountShrinkThreshold, AccountStorageEntry, AccountsDb, AccountsDbConfig, - CalcAccountsHashDataSource, DuplicatesLtHash, PubkeyHashAccount, - VerifyAccountsHashAndLamportsConfig, + AccountStorageEntry, AccountsDb, AccountsDbConfig, CalcAccountsHashDataSource, + DuplicatesLtHash, PubkeyHashAccount, VerifyAccountsHashAndLamportsConfig, }, accounts_hash::{ AccountHash, AccountsHash, AccountsLtHash, CalcAccountsHashConfig, HashStats, IncrementalAccountsHash, }, - accounts_index::{AccountSecondaryIndexes, IndexKey, ScanConfig, ScanResult}, + accounts_index::{IndexKey, ScanConfig, ScanResult}, accounts_partition::{self, Partition, PartitionIndex}, accounts_update_notifier_interface::AccountsUpdateNotifier, ancestors::{Ancestors, AncestorsForSerialization}, @@ -965,9 +964,19 @@ pub struct NewBankOptions { pub vote_only_bank: bool, } -#[derive(Debug, Default)] +#[cfg(feature = "dev-context-only-utils")] +#[derive(Debug)] pub struct BankTestConfig { - pub secondary_indexes: AccountSecondaryIndexes, + pub accounts_db_config: AccountsDbConfig, +} + +#[cfg(feature = "dev-context-only-utils")] +impl Default for BankTestConfig { + fn default() -> Self { + Self { + accounts_db_config: ACCOUNTS_DB_CONFIG_FOR_TESTING, + } + } } #[derive(Debug)] @@ -1073,8 +1082,6 @@ impl Bank { paths: Vec, debug_keys: Option>>, additional_builtins: Option<&[BuiltinPrototype]>, - account_indexes: AccountSecondaryIndexes, - shrink_ratio: AccountShrinkThreshold, debug_do_not_add_builtins: bool, accounts_db_config: Option, accounts_update_notifier: Option, @@ -1083,14 +1090,8 @@ impl Bank { #[allow(unused)] genesis_hash: Option, #[allow(unused)] feature_set: Option, ) -> Self { - let accounts_db = AccountsDb::new_with_config( - paths, - account_indexes, - shrink_ratio, - accounts_db_config, - accounts_update_notifier, - exit, - ); + let accounts_db = + AccountsDb::new_with_config(paths, accounts_db_config, 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()]); @@ -7023,7 +7024,7 @@ impl Bank { } pub fn new_for_tests(genesis_config: &GenesisConfig) -> Self { - Self::new_for_tests_with_config(genesis_config, BankTestConfig::default()) + Self::new_with_config_for_tests(genesis_config, BankTestConfig::default()) } pub fn new_with_mockup_builtin_for_tests( @@ -7036,17 +7037,6 @@ impl Bank { bank.wrap_with_bank_forks_for_tests() } - pub fn new_for_tests_with_config( - genesis_config: &GenesisConfig, - test_config: BankTestConfig, - ) -> Self { - Self::new_with_config_for_tests( - genesis_config, - test_config.secondary_indexes, - AccountShrinkThreshold::default(), - ) - } - pub fn new_no_wallclock_throttle_for_tests( genesis_config: &GenesisConfig, ) -> (Arc, Arc>) { @@ -7056,26 +7046,23 @@ impl Bank { bank.wrap_with_bank_forks_for_tests() } - pub(crate) fn new_with_config_for_tests( + pub fn new_with_config_for_tests( genesis_config: &GenesisConfig, - account_indexes: AccountSecondaryIndexes, - shrink_ratio: AccountShrinkThreshold, + test_config: BankTestConfig, ) -> Self { Self::new_with_paths_for_tests( genesis_config, Arc::new(RuntimeConfig::default()), + test_config, Vec::new(), - account_indexes, - shrink_ratio, ) } pub fn new_with_paths_for_tests( genesis_config: &GenesisConfig, runtime_config: Arc, + test_config: BankTestConfig, paths: Vec, - account_indexes: AccountSecondaryIndexes, - shrink_ratio: AccountShrinkThreshold, ) -> Self { Self::new_with_paths( genesis_config, @@ -7083,10 +7070,8 @@ impl Bank { paths, None, None, - account_indexes, - shrink_ratio, false, - Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), + Some(test_config.accounts_db_config), None, Some(Pubkey::new_unique()), Arc::default(), @@ -7108,8 +7093,6 @@ impl Bank { paths, None, None, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), false, Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS), None, diff --git a/runtime/src/bank/accounts_lt_hash.rs b/runtime/src/bank/accounts_lt_hash.rs index 7d61abdf4b7b0d..fcd0e9fd10a4ec 100644 --- a/runtime/src/bank/accounts_lt_hash.rs +++ b/runtime/src/bank/accounts_lt_hash.rs @@ -302,12 +302,8 @@ mod tests { runtime_config::RuntimeConfig, snapshot_bank_utils, snapshot_config::SnapshotConfig, snapshot_utils, }, - solana_accounts_db::{ - accounts_db::{ - AccountShrinkThreshold, AccountsDbConfig, DuplicatesLtHash, - ACCOUNTS_DB_CONFIG_FOR_TESTING, - }, - accounts_index::AccountSecondaryIndexes, + solana_accounts_db::accounts_db::{ + AccountsDbConfig, DuplicatesLtHash, ACCOUNTS_DB_CONFIG_FOR_TESTING, }, solana_sdk::{ account::{ReadableAccount as _, WritableAccount as _}, @@ -885,9 +881,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, false, false, diff --git a/runtime/src/bank/partitioned_epoch_rewards/mod.rs b/runtime/src/bank/partitioned_epoch_rewards/mod.rs index c3208a0e3e4f98..7b6ad888e4f8e5 100644 --- a/runtime/src/bank/partitioned_epoch_rewards/mod.rs +++ b/runtime/src/bank/partitioned_epoch_rewards/mod.rs @@ -282,10 +282,7 @@ mod tests { }, assert_matches::assert_matches, solana_accounts_db::{ - accounts_db::{ - AccountShrinkThreshold, AccountsDbConfig, ACCOUNTS_DB_CONFIG_FOR_TESTING, - }, - accounts_index::AccountSecondaryIndexes, + accounts_db::{AccountsDbConfig, ACCOUNTS_DB_CONFIG_FOR_TESTING}, partitioned_rewards::TestPartitionedEpochRewards, }, solana_sdk::{ @@ -398,8 +395,6 @@ mod tests { Vec::new(), None, None, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), false, Some(accounts_db_config), None, @@ -507,8 +502,6 @@ mod tests { Vec::new(), None, None, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), false, Some(accounts_db_config), None, diff --git a/runtime/src/bank/serde_snapshot.rs b/runtime/src/bank/serde_snapshot.rs index 9c27a9082c306b..77b72d3709b830 100644 --- a/runtime/src/bank/serde_snapshot.rs +++ b/runtime/src/bank/serde_snapshot.rs @@ -24,12 +24,11 @@ mod tests { solana_accounts_db::{ account_storage::{AccountStorageMap, AccountStorageReference}, accounts_db::{ - get_temp_accounts_paths, AccountShrinkThreshold, AccountStorageEntry, AccountsDb, - AtomicAccountsFileId, ACCOUNTS_DB_CONFIG_FOR_TESTING, + get_temp_accounts_paths, AccountStorageEntry, AccountsDb, AtomicAccountsFileId, + ACCOUNTS_DB_CONFIG_FOR_TESTING, }, accounts_file::{AccountsFile, AccountsFileError, StorageAccess}, accounts_hash::{AccountsDeltaHash, AccountsHash}, - accounts_index::AccountSecondaryIndexes, epoch_accounts_hash::EpochAccountsHash, }, solana_sdk::{ @@ -246,9 +245,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), None, @@ -360,9 +357,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, Some(solana_accounts_db::accounts_db::ACCOUNTS_DB_CONFIG_FOR_TESTING), None, @@ -419,9 +414,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, false, false, @@ -495,9 +488,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, Some(solana_accounts_db::accounts_db::ACCOUNTS_DB_CONFIG_FOR_TESTING), None, diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index f267eb13ea1df5..cfd91c2592c3cd 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -25,7 +25,7 @@ use { serde::{Deserialize, Serialize}, solana_accounts_db::{ accounts::AccountAddressFilter, - accounts_db::{AccountShrinkThreshold, DEFAULT_ACCOUNTS_SHRINK_RATIO}, + accounts_db::DEFAULT_ACCOUNTS_SHRINK_RATIO, accounts_hash::{AccountsDeltaHash, AccountsHasher}, accounts_index::{ AccountIndex, AccountSecondaryIndexes, IndexKey, ScanConfig, ScanError, ITER_BATCH_SIZE, @@ -4470,10 +4470,15 @@ fn test_get_filtered_indexed_accounts_limit_exceeded() { let (genesis_config, _mint_keypair) = create_genesis_config(500); let mut account_indexes = AccountSecondaryIndexes::default(); account_indexes.indexes.insert(AccountIndex::ProgramId); + let bank_config = BankTestConfig { + accounts_db_config: AccountsDbConfig { + account_indexes: Some(account_indexes), + ..ACCOUNTS_DB_CONFIG_FOR_TESTING + }, + }; let bank = Arc::new(Bank::new_with_config_for_tests( &genesis_config, - account_indexes, - AccountShrinkThreshold::default(), + bank_config, )); let address = Pubkey::new_unique(); @@ -4497,10 +4502,15 @@ fn test_get_filtered_indexed_accounts() { let (genesis_config, _mint_keypair) = create_genesis_config(500); let mut account_indexes = AccountSecondaryIndexes::default(); account_indexes.indexes.insert(AccountIndex::ProgramId); + let bank_config = BankTestConfig { + accounts_db_config: AccountsDbConfig { + account_indexes: Some(account_indexes), + ..ACCOUNTS_DB_CONFIG_FOR_TESTING + }, + }; let bank = Arc::new(Bank::new_with_config_for_tests( &genesis_config, - account_indexes, - AccountShrinkThreshold::default(), + bank_config, )); let address = Pubkey::new_unique(); @@ -6407,8 +6417,7 @@ fn get_shrink_account_size() -> usize { // of the storage for this slot let bank0 = Arc::new(Bank::new_with_config_for_tests( &genesis_config, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), + BankTestConfig::default(), )); bank0.restore_old_behavior_for_fragile_tests(); goto_end_of_slot(bank0.clone()); @@ -6446,8 +6455,7 @@ fn test_clean_nonrooted() { // Set root for bank 0, with caching enabled let bank0 = Arc::new(Bank::new_with_config_for_tests( &genesis_config, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), + BankTestConfig::default(), )); let account_zero = AccountSharedData::new(0, 0, &Pubkey::new_unique()); @@ -6521,8 +6529,7 @@ fn test_shrink_candidate_slots_cached() { // Set root for bank 0, with caching enabled let bank0 = Arc::new(Bank::new_with_config_for_tests( &genesis_config, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), + BankTestConfig::default(), )); bank0.restore_old_behavior_for_fragile_tests(); @@ -8188,8 +8195,7 @@ fn test_store_scan_consistency( genesis_config.rent = Rent::free(); let bank0 = Arc::new(Bank::new_with_config_for_tests( &genesis_config, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), + BankTestConfig::default(), )); bank0.set_callback(drop_callback); @@ -8987,8 +8993,6 @@ fn test_epoch_schedule_from_genesis_config() { Vec::new(), None, None, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), false, Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), None, @@ -9019,8 +9023,6 @@ where Vec::new(), None, None, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), false, Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), None, @@ -12604,8 +12606,6 @@ fn test_rehash_with_skipped_rewrites() { Vec::default(), None, None, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), false, Some(accounts_db_config), None, @@ -12667,8 +12667,6 @@ fn test_rebuild_skipped_rewrites() { Vec::default(), None, None, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), false, Some(accounts_db_config.clone()), None, @@ -12744,9 +12742,7 @@ fn test_rebuild_skipped_rewrites() { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, false, false, @@ -12779,8 +12775,6 @@ fn test_get_accounts_for_bank_hash_details(skip_rewrites: bool) { Vec::default(), None, None, - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), false, Some(accounts_db_config.clone()), None, diff --git a/runtime/src/serde_snapshot.rs b/runtime/src/serde_snapshot.rs index 11ac433507b6fb..3133b3fd0dd3dc 100644 --- a/runtime/src/serde_snapshot.rs +++ b/runtime/src/serde_snapshot.rs @@ -19,13 +19,11 @@ use { account_storage::meta::StoredMetaWriteVersion, accounts::Accounts, accounts_db::{ - stats::BankHashStats, AccountShrinkThreshold, AccountStorageEntry, AccountsDb, - AccountsDbConfig, AccountsFileId, AtomicAccountsFileId, DuplicatesLtHash, - IndexGenerationInfo, + stats::BankHashStats, AccountStorageEntry, AccountsDb, AccountsDbConfig, + AccountsFileId, AtomicAccountsFileId, DuplicatesLtHash, IndexGenerationInfo, }, accounts_file::{AccountsFile, StorageAccess}, accounts_hash::{AccountsDeltaHash, AccountsHash}, - accounts_index::AccountSecondaryIndexes, accounts_update_notifier_interface::AccountsUpdateNotifier, ancestors::AncestorsForSerialization, blockhash_queue::BlockhashQueue, @@ -561,9 +559,7 @@ pub(crate) fn bank_from_streams( runtime_config: &RuntimeConfig, debug_keys: Option>>, additional_builtins: Option<&[BuiltinPrototype]>, - account_secondary_indexes: AccountSecondaryIndexes, limit_load_slot_count_from_snapshot: Option, - shrink_ratio: AccountShrinkThreshold, verify_index: bool, accounts_db_config: Option, accounts_update_notifier: Option, @@ -582,9 +578,7 @@ where storage_and_next_append_vec_id, debug_keys, additional_builtins, - account_secondary_indexes, limit_load_slot_count_from_snapshot, - shrink_ratio, verify_index, accounts_db_config, accounts_update_notifier, @@ -855,9 +849,7 @@ fn reconstruct_bank_from_fields( storage_and_next_append_vec_id: StorageAndNextAccountsFileId, debug_keys: Option>>, additional_builtins: Option<&[BuiltinPrototype]>, - account_secondary_indexes: AccountSecondaryIndexes, limit_load_slot_count_from_snapshot: Option, - shrink_ratio: AccountShrinkThreshold, verify_index: bool, accounts_db_config: Option, accounts_update_notifier: Option, @@ -879,9 +871,7 @@ where account_paths, storage_and_next_append_vec_id, genesis_config, - account_secondary_indexes, limit_load_slot_count_from_snapshot, - shrink_ratio, verify_index, accounts_db_config, accounts_update_notifier, @@ -1046,9 +1036,7 @@ fn reconstruct_accountsdb_from_fields( account_paths: &[PathBuf], storage_and_next_append_vec_id: StorageAndNextAccountsFileId, genesis_config: &GenesisConfig, - account_secondary_indexes: AccountSecondaryIndexes, limit_load_slot_count_from_snapshot: Option, - shrink_ratio: AccountShrinkThreshold, verify_index: bool, accounts_db_config: Option, accounts_update_notifier: Option, @@ -1062,8 +1050,6 @@ where { let mut accounts_db = AccountsDb::new_with_config( account_paths.to_vec(), - account_secondary_indexes, - shrink_ratio, accounts_db_config, accounts_update_notifier, exit, diff --git a/runtime/src/serde_snapshot/tests.rs b/runtime/src/serde_snapshot/tests.rs index 9d28ec6d70a16a..19df0b52877c74 100644 --- a/runtime/src/serde_snapshot/tests.rs +++ b/runtime/src/serde_snapshot/tests.rs @@ -15,13 +15,11 @@ mod serde_snapshot_tests { account_storage::{AccountStorageMap, AccountStorageReference}, accounts::Accounts, accounts_db::{ - get_temp_accounts_paths, test_utils::create_test_accounts, AccountShrinkThreshold, - AccountStorageEntry, AccountsDb, AtomicAccountsFileId, - VerifyAccountsHashAndLamportsConfig, + get_temp_accounts_paths, test_utils::create_test_accounts, AccountStorageEntry, + AccountsDb, AtomicAccountsFileId, VerifyAccountsHashAndLamportsConfig, }, accounts_file::{AccountsFile, AccountsFileError, StorageAccess}, accounts_hash::AccountsHash, - accounts_index::AccountSecondaryIndexes, ancestors::Ancestors, }, solana_sdk::{ @@ -77,9 +75,7 @@ mod serde_snapshot_tests { cluster_type: ClusterType::Development, ..GenesisConfig::default() }, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, Some(solana_accounts_db::accounts_db::ACCOUNTS_DB_CONFIG_FOR_TESTING), None, diff --git a/runtime/src/snapshot_bank_utils.rs b/runtime/src/snapshot_bank_utils.rs index f86ccda9d57446..4d90329a785191 100644 --- a/runtime/src/snapshot_bank_utils.rs +++ b/runtime/src/snapshot_bank_utils.rs @@ -27,11 +27,10 @@ use { log::*, solana_accounts_db::{ accounts_db::{ - AccountShrinkThreshold, AccountStorageEntry, AccountsDbConfig, AtomicAccountsFileId, + AccountStorageEntry, AccountsDbConfig, AtomicAccountsFileId, CalcAccountsHashDataSource, DuplicatesLtHash, }, accounts_file::StorageAccess, - accounts_index::AccountSecondaryIndexes, accounts_update_notifier_interface::AccountsUpdateNotifier, utils::delete_contents_of_path, }, @@ -132,9 +131,7 @@ pub fn bank_from_snapshot_archives( runtime_config: &RuntimeConfig, debug_keys: Option>>, additional_builtins: Option<&[BuiltinPrototype]>, - account_secondary_indexes: AccountSecondaryIndexes, limit_load_slot_count_from_snapshot: Option, - shrink_ratio: AccountShrinkThreshold, test_hash_calculation: bool, accounts_db_skip_shrink: bool, accounts_db_force_initial_clean: bool, @@ -193,9 +190,7 @@ pub fn bank_from_snapshot_archives( runtime_config, debug_keys, additional_builtins, - account_secondary_indexes, limit_load_slot_count_from_snapshot, - shrink_ratio, verify_index, accounts_db_config, accounts_update_notifier, @@ -283,9 +278,7 @@ pub fn bank_from_latest_snapshot_archives( runtime_config: &RuntimeConfig, debug_keys: Option>>, additional_builtins: Option<&[BuiltinPrototype]>, - account_secondary_indexes: AccountSecondaryIndexes, limit_load_slot_count_from_snapshot: Option, - shrink_ratio: AccountShrinkThreshold, test_hash_calculation: bool, accounts_db_skip_shrink: bool, accounts_db_force_initial_clean: bool, @@ -317,9 +310,7 @@ pub fn bank_from_latest_snapshot_archives( runtime_config, debug_keys, additional_builtins, - account_secondary_indexes, limit_load_slot_count_from_snapshot, - shrink_ratio, test_hash_calculation, accounts_db_skip_shrink, accounts_db_force_initial_clean, @@ -345,9 +336,7 @@ pub fn bank_from_snapshot_dir( runtime_config: &RuntimeConfig, debug_keys: Option>>, additional_builtins: Option<&[BuiltinPrototype]>, - account_secondary_indexes: AccountSecondaryIndexes, limit_load_slot_count_from_snapshot: Option, - shrink_ratio: AccountShrinkThreshold, verify_index: bool, accounts_db_config: Option, accounts_update_notifier: Option, @@ -396,9 +385,7 @@ pub fn bank_from_snapshot_dir( runtime_config, debug_keys, additional_builtins, - account_secondary_indexes, limit_load_slot_count_from_snapshot, - shrink_ratio, verify_index, accounts_db_config, accounts_update_notifier, @@ -433,9 +420,7 @@ pub fn bank_from_latest_snapshot_dir( account_paths: &[PathBuf], debug_keys: Option>>, additional_builtins: Option<&[BuiltinPrototype]>, - account_secondary_indexes: AccountSecondaryIndexes, limit_load_slot_count_from_snapshot: Option, - shrink_ratio: AccountShrinkThreshold, verify_index: bool, accounts_db_config: Option, accounts_update_notifier: Option, @@ -451,9 +436,7 @@ pub fn bank_from_latest_snapshot_dir( runtime_config, debug_keys, additional_builtins, - account_secondary_indexes, limit_load_slot_count_from_snapshot, - shrink_ratio, verify_index, accounts_db_config, accounts_update_notifier, @@ -563,9 +546,7 @@ fn rebuild_bank_from_unarchived_snapshots( runtime_config: &RuntimeConfig, debug_keys: Option>>, additional_builtins: Option<&[BuiltinPrototype]>, - account_secondary_indexes: AccountSecondaryIndexes, limit_load_slot_count_from_snapshot: Option, - shrink_ratio: AccountShrinkThreshold, verify_index: bool, accounts_db_config: Option, accounts_update_notifier: Option, @@ -611,9 +592,7 @@ fn rebuild_bank_from_unarchived_snapshots( runtime_config, debug_keys, additional_builtins, - account_secondary_indexes, limit_load_slot_count_from_snapshot, - shrink_ratio, verify_index, accounts_db_config, accounts_update_notifier, @@ -665,9 +644,7 @@ fn rebuild_bank_from_snapshot( runtime_config: &RuntimeConfig, debug_keys: Option>>, additional_builtins: Option<&[BuiltinPrototype]>, - account_secondary_indexes: AccountSecondaryIndexes, limit_load_slot_count_from_snapshot: Option, - shrink_ratio: AccountShrinkThreshold, verify_index: bool, accounts_db_config: Option, accounts_update_notifier: Option, @@ -692,9 +669,7 @@ fn rebuild_bank_from_snapshot( runtime_config, debug_keys, additional_builtins, - account_secondary_indexes, limit_load_slot_count_from_snapshot, - shrink_ratio, verify_index, accounts_db_config, accounts_update_notifier, @@ -1064,7 +1039,7 @@ mod tests { use { super::*, crate::{ - bank::tests::create_simple_test_bank, + bank::{tests::create_simple_test_bank, BankTestConfig}, bank_forks::BankForks, genesis_utils, snapshot_config::SnapshotConfig, @@ -1191,9 +1166,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, false, false, @@ -1305,9 +1278,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, false, false, @@ -1437,9 +1408,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, false, false, @@ -1559,9 +1528,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, false, false, @@ -1617,9 +1584,8 @@ mod tests { let (bank0, bank_forks) = Bank::new_with_paths_for_tests( &genesis_config, Arc::::default(), + BankTestConfig::default(), vec![accounts_dir.clone()], - AccountSecondaryIndexes::default(), - AccountShrinkThreshold::default(), ) .wrap_with_bank_forks_for_tests(); bank0 @@ -1698,9 +1664,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, false, false, @@ -1764,9 +1728,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, false, false, @@ -2102,9 +2064,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, false, false, @@ -2176,9 +2136,7 @@ mod tests { &RuntimeConfig::default(), None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, Some(AccountsDbConfig { storage_access, @@ -2222,9 +2180,7 @@ mod tests { account_paths, None, None, - AccountSecondaryIndexes::default(), None, - AccountShrinkThreshold::default(), false, Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), None, diff --git a/test-validator/src/lib.rs b/test-validator/src/lib.rs index d001dd0c1f8214..40f591548e0238 100644 --- a/test-validator/src/lib.rs +++ b/test-validator/src/lib.rs @@ -975,6 +975,7 @@ impl TestValidator { started_from_validator: true, ..AccountsIndexConfig::default() }), + account_indexes: Some(config.rpc_config.account_indexes.clone()), ..AccountsDbConfig::default() }); @@ -1026,7 +1027,6 @@ impl TestValidator { staked_nodes_overrides: config.staked_nodes_overrides.clone(), accounts_db_config, runtime_config, - account_indexes: config.rpc_config.account_indexes.clone(), ..ValidatorConfig::default_for_test() }; if let Some(ref tower_storage) = config.tower_storage { diff --git a/validator/src/admin_rpc_service.rs b/validator/src/admin_rpc_service.rs index c133ea444886de..059404c907f67f 100644 --- a/validator/src/admin_rpc_service.rs +++ b/validator/src/admin_rpc_service.rs @@ -865,7 +865,10 @@ mod tests { use { super::*, serde_json::Value, - solana_accounts_db::accounts_index::AccountSecondaryIndexes, + solana_accounts_db::{ + accounts_db::{AccountsDbConfig, ACCOUNTS_DB_CONFIG_FOR_TESTING}, + accounts_index::AccountSecondaryIndexes, + }, solana_core::consensus::tower_storage::NullTowerStorage, solana_gossip::cluster_info::ClusterInfo, solana_inline_spl::token, @@ -918,7 +921,10 @@ mod tests { let exit = Arc::new(AtomicBool::new(false)); let validator_exit = create_validator_exit(exit); let (bank_forks, vote_keypair) = new_bank_forks_with_config(BankTestConfig { - secondary_indexes: config.account_indexes, + accounts_db_config: AccountsDbConfig { + account_indexes: Some(config.account_indexes), + ..ACCOUNTS_DB_CONFIG_FOR_TESTING + }, }); let vote_account = vote_keypair.pubkey(); let start_progress = Arc::new(RwLock::new(ValidatorStartProgress::default())); @@ -971,7 +977,7 @@ mod tests { .. } = create_genesis_config(1_000_000_000); - let bank = Bank::new_for_tests_with_config(&genesis_config, config); + let bank = Bank::new_with_config_for_tests(&genesis_config, config); (BankForks::new_rw_arc(bank), Arc::new(voting_keypair)) } diff --git a/validator/src/main.rs b/validator/src/main.rs index 5d218eedd4a9f4..4faff18723049e 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -1110,7 +1110,7 @@ pub fn main() { exit(1); } - let accounts_shrink_ratio = if accounts_shrink_optimize_total_space { + let shrink_ratio = if accounts_shrink_optimize_total_space { AccountShrinkThreshold::TotalSpace { shrink_ratio } } else { AccountShrinkThreshold::IndividualStore { shrink_ratio } @@ -1299,9 +1299,11 @@ pub fn main() { let accounts_db_config = AccountsDbConfig { index: Some(accounts_index_config), + account_indexes: Some(account_indexes.clone()), base_working_path: Some(ledger_path.clone()), accounts_hash_cache_path: Some(accounts_hash_cache_path), shrink_paths: account_shrink_run_paths, + shrink_ratio, read_cache_limit_bytes, write_cache_limit_bytes: value_t!(matches, "accounts_db_cache_limit_mb", u64) .ok() @@ -1523,14 +1525,12 @@ pub fn main() { poh_hashes_per_batch: value_of(&matches, "poh_hashes_per_batch") .unwrap_or(poh_service::DEFAULT_HASHES_PER_BATCH), process_ledger_before_services: matches.is_present("process_ledger_before_services"), - account_indexes, accounts_db_test_hash_calculation: matches.is_present("accounts_db_test_hash_calculation"), accounts_db_config, accounts_db_skip_shrink: true, accounts_db_force_initial_clean: matches.is_present("no_skip_initial_accounts_db_clean"), tpu_coalesce, no_wait_for_vote_to_start_leader: matches.is_present("no_wait_for_vote_to_start_leader"), - accounts_shrink_ratio, runtime_config: RuntimeConfig { log_messages_bytes_limit: value_of(&matches, "log_messages_bytes_limit"), ..RuntimeConfig::default()