diff --git a/core/tests/snapshots.rs b/core/tests/snapshots.rs index 05b554bc3d..04cb77426a 100644 --- a/core/tests/snapshots.rs +++ b/core/tests/snapshots.rs @@ -107,6 +107,7 @@ mod tests { AccountSecondaryIndexes::default(), false, accounts_db::AccountShrinkThreshold::default(), + false, ); bank0.freeze(); let mut bank_forks = BankForks::new(bank0); diff --git a/ledger/src/bank_forks_utils.rs b/ledger/src/bank_forks_utils.rs index 2b272a911a..bc416f8795 100644 --- a/ledger/src/bank_forks_utils.rs +++ b/ledger/src/bank_forks_utils.rs @@ -150,10 +150,6 @@ fn load_from_snapshot( deserialized_bank.set_shrink_paths(shrink_paths); } - if process_options.accounts_db_test_hash_calculation { - deserialized_bank.update_accounts_hash_with_index_option(false, true); - } - let deserialized_bank_slot_and_hash = ( deserialized_bank.slot(), deserialized_bank.get_accounts_hash(), diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 688332f714..5a49f7f4dc 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -404,6 +404,7 @@ pub fn process_blockstore( opts.account_indexes.clone(), opts.accounts_db_caching_enabled, opts.shrink_ratio, + false, ); let bank0 = Arc::new(bank0); info!("processing ledger for slot 0..."); @@ -3100,6 +3101,7 @@ pub mod tests { AccountSecondaryIndexes::default(), false, AccountShrinkThreshold::default(), + false, ); *bank.epoch_schedule() } diff --git a/runtime/benches/accounts.rs b/runtime/benches/accounts.rs index 08ad50df4e..9c2f0dbfcf 100644 --- a/runtime/benches/accounts.rs +++ b/runtime/benches/accounts.rs @@ -61,6 +61,7 @@ fn test_accounts_create(bencher: &mut Bencher) { AccountSecondaryIndexes::default(), false, AccountShrinkThreshold::default(), + false, ); bencher.iter(|| { let mut pubkeys: Vec = vec![]; @@ -81,6 +82,7 @@ fn test_accounts_squash(bencher: &mut Bencher) { AccountSecondaryIndexes::default(), false, AccountShrinkThreshold::default(), + false, )); let mut pubkeys: Vec = vec![]; deposit_many(&prev_bank, &mut pubkeys, 250_000).unwrap(); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 3c9611678c..22bb5a015b 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1015,6 +1015,7 @@ impl Bank { AccountSecondaryIndexes::default(), false, AccountShrinkThreshold::default(), + false, ) } @@ -1028,6 +1029,7 @@ impl Bank { AccountSecondaryIndexes::default(), false, AccountShrinkThreshold::default(), + false, ); bank.ns_per_slot = std::u128::MAX; @@ -1050,6 +1052,7 @@ impl Bank { account_indexes, accounts_db_caching_enabled, shrink_ratio, + false, ) } @@ -1062,6 +1065,7 @@ impl Bank { account_indexes: AccountSecondaryIndexes, accounts_db_caching_enabled: bool, shrink_ratio: AccountShrinkThreshold, + debug_do_not_add_builtins: bool, ) -> Self { let mut bank = Self::default(); bank.ancestors = Ancestors::from(vec![bank.slot()]); @@ -1076,7 +1080,11 @@ impl Bank { shrink_ratio, )); bank.process_genesis_config(genesis_config); - bank.finish_init(genesis_config, additional_builtins); + bank.finish_init( + genesis_config, + additional_builtins, + debug_do_not_add_builtins, + ); // Freeze accounts after process_genesis_config creates the initial append vecs Arc::get_mut(&mut Arc::get_mut(&mut bank.rc.accounts).unwrap().accounts_db) @@ -1299,6 +1307,7 @@ impl Bank { fields: BankFieldsToDeserialize, debug_keys: Option>>, additional_builtins: Option<&Builtins>, + debug_do_not_add_builtins: bool, ) -> Self { fn new() -> T { T::default() @@ -1361,7 +1370,11 @@ impl Bank { drop_callback: RwLock::new(OptionalDropCallback(None)), freeze_started: AtomicBool::new(fields.hash != Hash::default()), }; - bank.finish_init(genesis_config, additional_builtins); + bank.finish_init( + genesis_config, + additional_builtins, + debug_do_not_add_builtins, + ); // Sanity assertions between bank snapshot and genesis config // Consider removing from serializable bank state @@ -4249,6 +4262,7 @@ impl Bank { &mut self, genesis_config: &GenesisConfig, additional_builtins: Option<&Builtins>, + debug_do_not_add_builtins: bool, ) { self.rewards_pool_pubkeys = Arc::new(genesis_config.rewards_pools.keys().cloned().collect()); @@ -4262,12 +4276,14 @@ impl Bank { .feature_builtins .extend_from_slice(&additional_builtins.feature_builtins); } - for builtin in builtins.genesis_builtins { - self.add_builtin( - &builtin.name, - builtin.id, - builtin.process_instruction_with_context, - ); + if !debug_do_not_add_builtins { + for builtin in builtins.genesis_builtins { + self.add_builtin( + &builtin.name, + builtin.id, + builtin.process_instruction_with_context, + ); + } } self.feature_builtins = Arc::new(builtins.feature_builtins); @@ -11920,7 +11936,7 @@ pub(crate) mod tests { fn test_debug_bank() { let (genesis_config, _mint_keypair) = create_genesis_config(50000); let mut bank = Bank::new(&genesis_config); - bank.finish_init(&genesis_config, None); + bank.finish_init(&genesis_config, None, false); let debug = format!("{:#?}", bank); assert!(!debug.is_empty()); } diff --git a/runtime/src/serde_snapshot.rs b/runtime/src/serde_snapshot.rs index 5077692ed4..776f054c0e 100644 --- a/runtime/src/serde_snapshot.rs +++ b/runtime/src/serde_snapshot.rs @@ -271,12 +271,16 @@ where ); let bank_rc = BankRc::new(Accounts::new_empty(accounts_db), bank_fields.slot); + + // if limit_load_slot_count_from_snapshot is set, then we need to side-step some correctness checks beneath this call + let debug_do_not_add_builtins = limit_load_slot_count_from_snapshot.is_some(); let bank = Bank::new_from_fields( bank_rc, genesis_config, bank_fields, debug_keys, additional_builtins, + debug_do_not_add_builtins, ); Ok(bank) diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index 46f764624c..0f47147df0 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -652,7 +652,9 @@ pub fn bank_from_archive>( measure.stop(); let mut verify = Measure::start("verify"); - if !bank.verify_snapshot_bank(test_hash_calculation) { + if !bank.verify_snapshot_bank(test_hash_calculation) + && limit_load_slot_count_from_snapshot.is_none() + { panic!("Snapshot bank for slot {} failed to verify", bank.slot()); } verify.stop();