ledger tool limit_load_slot_count_from_snapshot avoids assert failures (#17974)

This commit is contained in:
Jeff Washington (jwash) 2021-06-15 15:39:22 -05:00 committed by GitHub
parent 0323ea9f7e
commit dbd4dc04b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 14 deletions

View File

@ -107,6 +107,7 @@ mod tests {
AccountSecondaryIndexes::default(), AccountSecondaryIndexes::default(),
false, false,
accounts_db::AccountShrinkThreshold::default(), accounts_db::AccountShrinkThreshold::default(),
false,
); );
bank0.freeze(); bank0.freeze();
let mut bank_forks = BankForks::new(bank0); let mut bank_forks = BankForks::new(bank0);

View File

@ -150,10 +150,6 @@ fn load_from_snapshot(
deserialized_bank.set_shrink_paths(shrink_paths); 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 = ( let deserialized_bank_slot_and_hash = (
deserialized_bank.slot(), deserialized_bank.slot(),
deserialized_bank.get_accounts_hash(), deserialized_bank.get_accounts_hash(),

View File

@ -404,6 +404,7 @@ pub fn process_blockstore(
opts.account_indexes.clone(), opts.account_indexes.clone(),
opts.accounts_db_caching_enabled, opts.accounts_db_caching_enabled,
opts.shrink_ratio, opts.shrink_ratio,
false,
); );
let bank0 = Arc::new(bank0); let bank0 = Arc::new(bank0);
info!("processing ledger for slot 0..."); info!("processing ledger for slot 0...");
@ -3100,6 +3101,7 @@ pub mod tests {
AccountSecondaryIndexes::default(), AccountSecondaryIndexes::default(),
false, false,
AccountShrinkThreshold::default(), AccountShrinkThreshold::default(),
false,
); );
*bank.epoch_schedule() *bank.epoch_schedule()
} }

View File

@ -61,6 +61,7 @@ fn test_accounts_create(bencher: &mut Bencher) {
AccountSecondaryIndexes::default(), AccountSecondaryIndexes::default(),
false, false,
AccountShrinkThreshold::default(), AccountShrinkThreshold::default(),
false,
); );
bencher.iter(|| { bencher.iter(|| {
let mut pubkeys: Vec<Pubkey> = vec![]; let mut pubkeys: Vec<Pubkey> = vec![];
@ -81,6 +82,7 @@ fn test_accounts_squash(bencher: &mut Bencher) {
AccountSecondaryIndexes::default(), AccountSecondaryIndexes::default(),
false, false,
AccountShrinkThreshold::default(), AccountShrinkThreshold::default(),
false,
)); ));
let mut pubkeys: Vec<Pubkey> = vec![]; let mut pubkeys: Vec<Pubkey> = vec![];
deposit_many(&prev_bank, &mut pubkeys, 250_000).unwrap(); deposit_many(&prev_bank, &mut pubkeys, 250_000).unwrap();

View File

@ -1015,6 +1015,7 @@ impl Bank {
AccountSecondaryIndexes::default(), AccountSecondaryIndexes::default(),
false, false,
AccountShrinkThreshold::default(), AccountShrinkThreshold::default(),
false,
) )
} }
@ -1028,6 +1029,7 @@ impl Bank {
AccountSecondaryIndexes::default(), AccountSecondaryIndexes::default(),
false, false,
AccountShrinkThreshold::default(), AccountShrinkThreshold::default(),
false,
); );
bank.ns_per_slot = std::u128::MAX; bank.ns_per_slot = std::u128::MAX;
@ -1050,6 +1052,7 @@ impl Bank {
account_indexes, account_indexes,
accounts_db_caching_enabled, accounts_db_caching_enabled,
shrink_ratio, shrink_ratio,
false,
) )
} }
@ -1062,6 +1065,7 @@ impl Bank {
account_indexes: AccountSecondaryIndexes, account_indexes: AccountSecondaryIndexes,
accounts_db_caching_enabled: bool, accounts_db_caching_enabled: bool,
shrink_ratio: AccountShrinkThreshold, shrink_ratio: AccountShrinkThreshold,
debug_do_not_add_builtins: bool,
) -> Self { ) -> Self {
let mut bank = Self::default(); let mut bank = Self::default();
bank.ancestors = Ancestors::from(vec![bank.slot()]); bank.ancestors = Ancestors::from(vec![bank.slot()]);
@ -1076,7 +1080,11 @@ impl Bank {
shrink_ratio, shrink_ratio,
)); ));
bank.process_genesis_config(genesis_config); 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 // 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) Arc::get_mut(&mut Arc::get_mut(&mut bank.rc.accounts).unwrap().accounts_db)
@ -1299,6 +1307,7 @@ impl Bank {
fields: BankFieldsToDeserialize, fields: BankFieldsToDeserialize,
debug_keys: Option<Arc<HashSet<Pubkey>>>, debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>, additional_builtins: Option<&Builtins>,
debug_do_not_add_builtins: bool,
) -> Self { ) -> Self {
fn new<T: Default>() -> T { fn new<T: Default>() -> T {
T::default() T::default()
@ -1361,7 +1370,11 @@ impl Bank {
drop_callback: RwLock::new(OptionalDropCallback(None)), drop_callback: RwLock::new(OptionalDropCallback(None)),
freeze_started: AtomicBool::new(fields.hash != Hash::default()), 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 // Sanity assertions between bank snapshot and genesis config
// Consider removing from serializable bank state // Consider removing from serializable bank state
@ -4249,6 +4262,7 @@ impl Bank {
&mut self, &mut self,
genesis_config: &GenesisConfig, genesis_config: &GenesisConfig,
additional_builtins: Option<&Builtins>, additional_builtins: Option<&Builtins>,
debug_do_not_add_builtins: bool,
) { ) {
self.rewards_pool_pubkeys = self.rewards_pool_pubkeys =
Arc::new(genesis_config.rewards_pools.keys().cloned().collect()); Arc::new(genesis_config.rewards_pools.keys().cloned().collect());
@ -4262,6 +4276,7 @@ impl Bank {
.feature_builtins .feature_builtins
.extend_from_slice(&additional_builtins.feature_builtins); .extend_from_slice(&additional_builtins.feature_builtins);
} }
if !debug_do_not_add_builtins {
for builtin in builtins.genesis_builtins { for builtin in builtins.genesis_builtins {
self.add_builtin( self.add_builtin(
&builtin.name, &builtin.name,
@ -4269,6 +4284,7 @@ impl Bank {
builtin.process_instruction_with_context, builtin.process_instruction_with_context,
); );
} }
}
self.feature_builtins = Arc::new(builtins.feature_builtins); self.feature_builtins = Arc::new(builtins.feature_builtins);
self.apply_feature_activations(true); self.apply_feature_activations(true);
@ -11920,7 +11936,7 @@ pub(crate) mod tests {
fn test_debug_bank() { fn test_debug_bank() {
let (genesis_config, _mint_keypair) = create_genesis_config(50000); let (genesis_config, _mint_keypair) = create_genesis_config(50000);
let mut bank = Bank::new(&genesis_config); let mut bank = Bank::new(&genesis_config);
bank.finish_init(&genesis_config, None); bank.finish_init(&genesis_config, None, false);
let debug = format!("{:#?}", bank); let debug = format!("{:#?}", bank);
assert!(!debug.is_empty()); assert!(!debug.is_empty());
} }

View File

@ -271,12 +271,16 @@ where
); );
let bank_rc = BankRc::new(Accounts::new_empty(accounts_db), bank_fields.slot); 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( let bank = Bank::new_from_fields(
bank_rc, bank_rc,
genesis_config, genesis_config,
bank_fields, bank_fields,
debug_keys, debug_keys,
additional_builtins, additional_builtins,
debug_do_not_add_builtins,
); );
Ok(bank) Ok(bank)

View File

@ -652,7 +652,9 @@ pub fn bank_from_archive<P: AsRef<Path>>(
measure.stop(); measure.stop();
let mut verify = Measure::start("verify"); 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()); panic!("Snapshot bank for slot {} failed to verify", bank.slot());
} }
verify.stop(); verify.stop();