Skip to content

Commit

Permalink
rework bank::new_with_paths (solana-labs#19087)
Browse files Browse the repository at this point in the history
* rework bank::new_with_paths

* missing 1 bench
  • Loading branch information
jeffwashington authored Aug 6, 2021
1 parent 8878f52 commit ca37873
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
&[],
Expand Down
4 changes: 2 additions & 2 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -3126,7 +3126,7 @@ pub mod tests {
genesis_config: &GenesisConfig,
account_paths: Vec<PathBuf>,
) -> EpochSchedule {
let bank = Bank::new_with_paths(
let bank = Bank::new_with_paths_for_tests(
genesis_config,
account_paths,
&[],
Expand Down
4 changes: 2 additions & 2 deletions runtime/benches/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn deposit_many(bank: &Bank, pubkeys: &mut Vec<Pubkey>, 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")],
&[],
Expand All @@ -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")],
&[],
Expand Down
58 changes: 53 additions & 5 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
&[],
Expand All @@ -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(),
&[],
Expand All @@ -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(),
&[],
Expand Down Expand Up @@ -1174,7 +1174,55 @@ impl Bank {
}
}

pub fn new_with_paths(
pub fn new_with_paths_for_tests(
genesis_config: &GenesisConfig,
paths: Vec<PathBuf>,
frozen_account_pubkeys: &[Pubkey],
debug_keys: Option<Arc<HashSet<Pubkey>>>,
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<PathBuf>,
frozen_account_pubkeys: &[Pubkey],
debug_keys: Option<Arc<HashSet<Pubkey>>>,
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<PathBuf>,
frozen_account_pubkeys: &[Pubkey],
Expand Down Expand Up @@ -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(),
&[],
Expand Down

0 comments on commit ca37873

Please sign in to comment.