* 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,
|
None,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
bank0.freeze();
|
bank0.freeze();
|
||||||
let mut bank_forks = BankForks::new(bank0);
|
let mut bank_forks = BankForks::new(bank0);
|
||||||
|
@ -149,10 +149,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(),
|
||||||
|
@ -401,6 +401,7 @@ pub fn process_blockstore(
|
|||||||
Some(&crate::builtins::get(opts.bpf_jit)),
|
Some(&crate::builtins::get(opts.bpf_jit)),
|
||||||
opts.account_indexes.clone(),
|
opts.account_indexes.clone(),
|
||||||
opts.accounts_db_caching_enabled,
|
opts.accounts_db_caching_enabled,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
let bank0 = Arc::new(bank0);
|
let bank0 = Arc::new(bank0);
|
||||||
info!("processing ledger for slot 0...");
|
info!("processing ledger for slot 0...");
|
||||||
@ -3096,6 +3097,7 @@ pub mod tests {
|
|||||||
None,
|
None,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
*bank.epoch_schedule()
|
*bank.epoch_schedule()
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ fn test_accounts_create(bencher: &mut Bencher) {
|
|||||||
None,
|
None,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
bencher.iter(|| {
|
bencher.iter(|| {
|
||||||
let mut pubkeys: Vec<Pubkey> = vec![];
|
let mut pubkeys: Vec<Pubkey> = vec![];
|
||||||
@ -78,6 +79,7 @@ fn test_accounts_squash(bencher: &mut Bencher) {
|
|||||||
None,
|
None,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
false,
|
false,
|
||||||
|
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();
|
||||||
|
@ -1010,6 +1010,7 @@ impl Bank {
|
|||||||
None,
|
None,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1022,6 +1023,7 @@ impl Bank {
|
|||||||
None,
|
None,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
bank.ns_per_slot = std::u128::MAX;
|
bank.ns_per_slot = std::u128::MAX;
|
||||||
@ -1042,6 +1044,7 @@ impl Bank {
|
|||||||
None,
|
None,
|
||||||
account_indexes,
|
account_indexes,
|
||||||
accounts_db_caching_enabled,
|
accounts_db_caching_enabled,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1053,6 +1056,7 @@ impl Bank {
|
|||||||
additional_builtins: Option<&Builtins>,
|
additional_builtins: Option<&Builtins>,
|
||||||
account_indexes: AccountSecondaryIndexes,
|
account_indexes: AccountSecondaryIndexes,
|
||||||
accounts_db_caching_enabled: bool,
|
accounts_db_caching_enabled: bool,
|
||||||
|
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()]);
|
||||||
@ -1066,7 +1070,11 @@ impl Bank {
|
|||||||
accounts_db_caching_enabled,
|
accounts_db_caching_enabled,
|
||||||
));
|
));
|
||||||
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)
|
||||||
@ -1287,6 +1295,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()
|
||||||
@ -1349,7 +1358,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
|
||||||
@ -4233,6 +4246,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());
|
||||||
@ -4246,12 +4260,14 @@ impl Bank {
|
|||||||
.feature_builtins
|
.feature_builtins
|
||||||
.extend_from_slice(&additional_builtins.feature_builtins);
|
.extend_from_slice(&additional_builtins.feature_builtins);
|
||||||
}
|
}
|
||||||
for builtin in builtins.genesis_builtins {
|
if !debug_do_not_add_builtins {
|
||||||
self.add_builtin(
|
for builtin in builtins.genesis_builtins {
|
||||||
&builtin.name,
|
self.add_builtin(
|
||||||
builtin.id,
|
&builtin.name,
|
||||||
builtin.process_instruction_with_context,
|
builtin.id,
|
||||||
);
|
builtin.process_instruction_with_context,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.feature_builtins = Arc::new(builtins.feature_builtins);
|
self.feature_builtins = Arc::new(builtins.feature_builtins);
|
||||||
|
|
||||||
@ -11879,7 +11895,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());
|
||||||
}
|
}
|
||||||
|
@ -266,12 +266,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)
|
||||||
|
@ -650,7 +650,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();
|
||||||
|
Reference in New Issue
Block a user