diff --git a/bench-tps/tests/bench_tps.rs b/bench-tps/tests/bench_tps.rs index f8098fbe7f..6b9abe7b66 100644 --- a/bench-tps/tests/bench_tps.rs +++ b/bench-tps/tests/bench_tps.rs @@ -63,6 +63,7 @@ fn test_bench_tps_local_cluster(config: Config) { cluster_lamports: 200_000_000, validator_configs: make_identical_validator_configs( &ValidatorConfig { + accounts_db_caching_enabled: true, rpc_config: JsonRpcConfig { faucet_addr: Some(faucet_addr), ..JsonRpcConfig::default_for_test() diff --git a/core/tests/epoch_accounts_hash.rs b/core/tests/epoch_accounts_hash.rs index 4ecc5885d1..48ae957c74 100755 --- a/core/tests/epoch_accounts_hash.rs +++ b/core/tests/epoch_accounts_hash.rs @@ -14,7 +14,7 @@ use { accounts_db::AccountShrinkThreshold, accounts_hash::CalcAccountsHashConfig, accounts_index::AccountSecondaryIndexes, - bank::Bank, + bank::{bank_test_config_caching_enabled, Bank}, bank_forks::BankForks, epoch_accounts_hash::{self, EpochAccountsHash}, genesis_utils::{self, GenesisConfigInfo}, @@ -107,8 +107,10 @@ impl TestEnvironment { ..snapshot_config }; - let mut bank_forks = - BankForks::new(Bank::new_for_tests(&genesis_config_info.genesis_config)); + let mut bank_forks = BankForks::new(Bank::new_for_tests_with_config( + &genesis_config_info.genesis_config, + bank_test_config_caching_enabled(), + )); bank_forks.set_snapshot_config(Some(snapshot_config.clone())); bank_forks.set_accounts_hash_interval_slots(Self::ACCOUNTS_HASH_INTERVAL); let bank_forks = Arc::new(RwLock::new(bank_forks)); @@ -219,7 +221,7 @@ impl BackgroundServices { snapshot_request_handler, pruned_banks_request_handler, }, - false, + true, false, None, ); @@ -581,6 +583,14 @@ fn test_epoch_accounts_hash_and_warping() { let eah_stop_offset = epoch_accounts_hash::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 + bank_forks.write().unwrap().set_root( + bank.slot(), + &test_environment + .background_services + .accounts_background_request_sender, + None, + ); let bank = bank_forks.write().unwrap().insert(Bank::warp_from_parent( &bank, &Pubkey::default(), diff --git a/core/tests/snapshots.rs b/core/tests/snapshots.rs index f412f0328b..f045630202 100644 --- a/core/tests/snapshots.rs +++ b/core/tests/snapshots.rs @@ -101,7 +101,7 @@ impl SnapshotTestConfig { Arc::::default(), vec![accounts_dir.path().to_path_buf()], AccountSecondaryIndexes::default(), - false, + true, accounts_db::AccountShrinkThreshold::default(), ); bank0.freeze(); @@ -252,7 +252,7 @@ fn run_bank_forks_snapshot_n( // set_root should send a snapshot request bank_forks.set_root(bank.slot(), &request_sender, None); bank.update_accounts_hash_for_tests(); - snapshot_request_handler.handle_snapshot_requests(false, false, 0, &mut None); + snapshot_request_handler.handle_snapshot_requests(true, false, 0, &mut None); } } @@ -784,7 +784,7 @@ fn test_bank_forks_incremental_snapshot( bank_forks.set_root(bank.slot(), &request_sender, None); bank.update_accounts_hash_for_tests(); snapshot_request_handler.handle_snapshot_requests( - false, + true, false, 0, &mut last_full_snapshot_slot, @@ -1041,7 +1041,7 @@ fn test_snapshots_with_background_services( bank_forks.clone(), &exit, abs_request_handler, - false, + true, false, None, ); diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 1e931c23ed..1167b21eaf 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -4791,6 +4791,7 @@ pub mod tests { let (bank_forks, mint_keypair, leader_vote_keypair) = new_bank_forks_with_config(BankTestConfig { secondary_indexes: config.account_indexes.clone(), + accounts_db_caching_enabled: true, }); let ledger_path = get_tmp_ledger_path!(); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index ac73c9cd8d..4cf59fe5d2 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1150,6 +1150,14 @@ pub struct NewBankOptions { #[derive(Debug, Default)] pub struct BankTestConfig { pub secondary_indexes: AccountSecondaryIndexes, + pub accounts_db_caching_enabled: bool, +} + +pub fn bank_test_config_caching_enabled() -> BankTestConfig { + BankTestConfig { + accounts_db_caching_enabled: true, + ..BankTestConfig::default() + } } #[derive(Debug)] @@ -1224,7 +1232,7 @@ impl Bank { Self::new_with_config_for_tests( genesis_config, test_config.secondary_indexes, - false, + test_config.accounts_db_caching_enabled, AccountShrinkThreshold::default(), ) } diff --git a/test-validator/src/lib.rs b/test-validator/src/lib.rs index d1d94a0450..67e88fd196 100644 --- a/test-validator/src/lib.rs +++ b/test-validator/src/lib.rs @@ -152,7 +152,7 @@ impl Default for TestValidatorGenesis { max_ledger_shreds: Option::::default(), max_genesis_archive_unpacked_size: Option::::default(), geyser_plugin_config_files: Option::>::default(), - accounts_db_caching_enabled: bool::default(), + accounts_db_caching_enabled: true, deactivate_feature_set: HashSet::::default(), compute_unit_limit: Option::::default(), log_messages_bytes_limit: Option::::default(),