diff --git a/core/tests/snapshots.rs b/core/tests/snapshots.rs index 710e769870..f989a4256b 100644 --- a/core/tests/snapshots.rs +++ b/core/tests/snapshots.rs @@ -106,6 +106,7 @@ mod tests { None, AccountSecondaryIndexes::default(), false, + 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 b80209b519..da9cd1eed0 100644 --- a/ledger/src/bank_forks_utils.rs +++ b/ledger/src/bank_forks_utils.rs @@ -149,10 +149,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 c452d223c1..d2ecc9384d 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -401,6 +401,7 @@ pub fn process_blockstore( Some(&crate::builtins::get(opts.bpf_jit)), opts.account_indexes.clone(), opts.accounts_db_caching_enabled, + false, ); let bank0 = Arc::new(bank0); info!("processing ledger for slot 0..."); @@ -3096,6 +3097,7 @@ pub mod tests { None, AccountSecondaryIndexes::default(), false, + false, ); *bank.epoch_schedule() } diff --git a/runtime/benches/accounts.rs b/runtime/benches/accounts.rs index b83b32863f..63c3981f4b 100644 --- a/runtime/benches/accounts.rs +++ b/runtime/benches/accounts.rs @@ -59,6 +59,7 @@ fn test_accounts_create(bencher: &mut Bencher) { None, AccountSecondaryIndexes::default(), false, + false, ); bencher.iter(|| { let mut pubkeys: Vec = vec![]; @@ -78,6 +79,7 @@ fn test_accounts_squash(bencher: &mut Bencher) { None, AccountSecondaryIndexes::default(), false, + 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 addfb0a05e..1e8ad1a3ff 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1010,6 +1010,7 @@ impl Bank { None, AccountSecondaryIndexes::default(), false, + false, ) } @@ -1022,6 +1023,7 @@ impl Bank { None, AccountSecondaryIndexes::default(), false, + false, ); bank.ns_per_slot = std::u128::MAX; @@ -1042,6 +1044,7 @@ impl Bank { None, account_indexes, accounts_db_caching_enabled, + false, ) } @@ -1053,6 +1056,7 @@ impl Bank { additional_builtins: Option<&Builtins>, account_indexes: AccountSecondaryIndexes, accounts_db_caching_enabled: bool, + debug_do_not_add_builtins: bool, ) -> Self { let mut bank = Self::default(); bank.ancestors = Ancestors::from(vec![bank.slot()]); @@ -1066,7 +1070,11 @@ impl Bank { accounts_db_caching_enabled, )); 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) @@ -1287,6 +1295,7 @@ impl Bank { fields: BankFieldsToDeserialize, debug_keys: Option>>, additional_builtins: Option<&Builtins>, + debug_do_not_add_builtins: bool, ) -> Self { fn new() -> T { T::default() @@ -1349,7 +1358,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 @@ -4233,6 +4246,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()); @@ -4246,12 +4260,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); @@ -11879,7 +11895,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 1385f104c4..b46c83445e 100644 --- a/runtime/src/serde_snapshot.rs +++ b/runtime/src/serde_snapshot.rs @@ -266,12 +266,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 e4bd019e28..8cbcdb25c0 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -650,7 +650,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();