* ledger tool limit_load_slot_count_from_snapshot avoids assert failures (#17974)
(cherry picked from commit dbd4dc04b0
)
# Conflicts:
# core/tests/snapshots.rs
# ledger/src/blockstore_processor.rs
# runtime/benches/accounts.rs
# runtime/src/bank.rs
* fix merge errors
Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com>
Co-authored-by: Jeff Washington (jwash) <wash678@gmail.com>
This commit is contained in:
@ -106,6 +106,7 @@ mod tests {
|
||||
None,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
false,
|
||||
);
|
||||
bank0.freeze();
|
||||
let mut bank_forks = BankForks::new(bank0);
|
||||
|
@ -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(),
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ fn test_accounts_create(bencher: &mut Bencher) {
|
||||
None,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
false,
|
||||
);
|
||||
bencher.iter(|| {
|
||||
let mut pubkeys: Vec<Pubkey> = vec![];
|
||||
@ -78,6 +79,7 @@ fn test_accounts_squash(bencher: &mut Bencher) {
|
||||
None,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
false,
|
||||
));
|
||||
let mut pubkeys: Vec<Pubkey> = vec![];
|
||||
deposit_many(&prev_bank, &mut pubkeys, 250_000).unwrap();
|
||||
|
@ -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<Arc<HashSet<Pubkey>>>,
|
||||
additional_builtins: Option<&Builtins>,
|
||||
debug_do_not_add_builtins: bool,
|
||||
) -> Self {
|
||||
fn new<T: Default>() -> 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());
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -650,7 +650,9 @@ pub fn bank_from_archive<P: AsRef<Path>>(
|
||||
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();
|
||||
|
Reference in New Issue
Block a user