From ca37873e16ef71691f4cc24baf276d9cd42193ae Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Fri, 6 Aug 2021 09:30:40 -0500 Subject: [PATCH] rework bank::new_with_paths (#19087) * rework bank::new_with_paths * missing 1 bench --- core/tests/snapshots.rs | 2 +- ledger/src/blockstore_processor.rs | 4 +-- runtime/benches/accounts.rs | 4 +-- runtime/src/bank.rs | 58 +++++++++++++++++++++++++++--- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/core/tests/snapshots.rs b/core/tests/snapshots.rs index f1fd001cb1..704144fae7 100644 --- a/core/tests/snapshots.rs +++ b/core/tests/snapshots.rs @@ -110,7 +110,7 @@ mod tests { let snapshot_archives_dir = TempDir::new().unwrap(); let mut genesis_config_info = create_genesis_config(10_000); genesis_config_info.genesis_config.cluster_type = cluster_type; - let bank0 = Bank::new_with_paths( + let bank0 = Bank::new_with_paths_for_tests( &genesis_config_info.genesis_config, vec![accounts_dir.path().to_path_buf()], &[], diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index ece7e1fb84..b134faa12a 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -406,7 +406,7 @@ pub fn process_blockstore( } // Setup bank for slot 0 - let bank0 = Bank::new_with_paths( + let bank0 = Bank::new_with_paths_production( genesis_config, account_paths, &opts.frozen_accounts, @@ -3126,7 +3126,7 @@ pub mod tests { genesis_config: &GenesisConfig, account_paths: Vec, ) -> EpochSchedule { - let bank = Bank::new_with_paths( + let bank = Bank::new_with_paths_for_tests( genesis_config, account_paths, &[], diff --git a/runtime/benches/accounts.rs b/runtime/benches/accounts.rs index 1b69685a6a..919624d731 100644 --- a/runtime/benches/accounts.rs +++ b/runtime/benches/accounts.rs @@ -44,7 +44,7 @@ fn deposit_many(bank: &Bank, pubkeys: &mut Vec, num: usize) -> Result<() #[bench] fn test_accounts_create(bencher: &mut Bencher) { let (genesis_config, _) = create_genesis_config(10_000); - let bank0 = Bank::new_with_paths( + let bank0 = Bank::new_with_paths_for_benches( &genesis_config, vec![PathBuf::from("bench_a0")], &[], @@ -65,7 +65,7 @@ fn test_accounts_create(bencher: &mut Bencher) { fn test_accounts_squash(bencher: &mut Bencher) { let (mut genesis_config, _) = create_genesis_config(100_000); genesis_config.rent.burn_percent = 100; // Avoid triggering an assert in Bank::distribute_rent_to_validators() - let mut prev_bank = Arc::new(Bank::new_with_paths( + let mut prev_bank = Arc::new(Bank::new_with_paths_for_benches( &genesis_config, vec![PathBuf::from("bench_a1")], &[], diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 08c1a48ff0..0c89224315 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1065,7 +1065,7 @@ impl Bank { pub fn new_for_tests(genesis_config: &GenesisConfig) -> Self { // this will diverge - Self::new_with_paths( + Self::new_with_paths_for_tests( genesis_config, Vec::new(), &[], @@ -1079,7 +1079,7 @@ impl Bank { } pub fn new_no_wallclock_throttle_for_tests(genesis_config: &GenesisConfig) -> Self { - let mut bank = Self::new_with_paths( + let mut bank = Self::new_with_paths_for_tests( genesis_config, Vec::new(), &[], @@ -1102,7 +1102,7 @@ impl Bank { accounts_db_caching_enabled: bool, shrink_ratio: AccountShrinkThreshold, ) -> Self { - Self::new_with_paths( + Self::new_with_paths_for_tests( genesis_config, Vec::new(), &[], @@ -1174,7 +1174,55 @@ impl Bank { } } - pub fn new_with_paths( + pub fn new_with_paths_for_tests( + genesis_config: &GenesisConfig, + paths: Vec, + frozen_account_pubkeys: &[Pubkey], + debug_keys: Option>>, + additional_builtins: Option<&Builtins>, + account_indexes: AccountSecondaryIndexes, + accounts_db_caching_enabled: bool, + shrink_ratio: AccountShrinkThreshold, + debug_do_not_add_builtins: bool, + ) -> Self { + Self::new_with_paths_production( + genesis_config, + paths, + frozen_account_pubkeys, + debug_keys, + additional_builtins, + account_indexes, + accounts_db_caching_enabled, + shrink_ratio, + debug_do_not_add_builtins, + ) + } + + pub fn new_with_paths_for_benches( + genesis_config: &GenesisConfig, + paths: Vec, + frozen_account_pubkeys: &[Pubkey], + debug_keys: Option>>, + additional_builtins: Option<&Builtins>, + account_indexes: AccountSecondaryIndexes, + accounts_db_caching_enabled: bool, + shrink_ratio: AccountShrinkThreshold, + debug_do_not_add_builtins: bool, + ) -> Self { + Self::new_with_paths_production( + genesis_config, + paths, + frozen_account_pubkeys, + debug_keys, + additional_builtins, + account_indexes, + accounts_db_caching_enabled, + shrink_ratio, + debug_do_not_add_builtins, + ) + } + + pub fn new_with_paths_production( genesis_config: &GenesisConfig, paths: Vec, frozen_account_pubkeys: &[Pubkey], @@ -12211,7 +12259,7 @@ pub(crate) mod tests { feature_builtins: (vec![]), }; - let bank0 = Arc::new(Bank::new_with_paths( + let bank0 = Arc::new(Bank::new_with_paths_for_tests( &genesis_config, Vec::new(), &[],