Fix blockstore_processor::load_frozen_forks() halt_at_slot behavior (#28317)

load_frozen_forks() finds new slots to process by creating new Banks for
the children of the current slot in process_next_slots(). Prior to this
change, we would then immediately check if we had reached the
halt_at_slot and correctly halt processing when appropriate. As such, it
would be possible for Banks to be created for slots beyond the
halt_at_slot.

While a potential child slot that is past halt_at_slot wouldn't be
replayed, the Bank being created still alters some universal state in
AccountsDb. So, this change moves the halt_at_slot check before we
create children Banks in process_next_slots().
This commit is contained in:
steviez 2022-10-10 15:37:23 -04:00 committed by GitHub
parent cc390f176c
commit 2929c8f7a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 9 deletions

View File

@ -1440,9 +1440,8 @@ fn load_frozen_forks(
&mut pending_slots,
)?;
let halt_at_slot = opts.halt_at_slot.unwrap_or(std::u64::MAX);
let on_halt_store_hash_raw_data_for_debug = opts.on_halt_store_hash_raw_data_for_debug;
if bank_forks.read().unwrap().root() != halt_at_slot {
if Some(bank_forks.read().unwrap().root()) != opts.halt_at_slot {
let mut set_root_us = 0;
let mut root_retain_us = 0;
let mut process_single_slot_us = 0;
@ -1588,6 +1587,17 @@ fn load_frozen_forks(
slot,
);
let done_processing = opts
.halt_at_slot
.map(|halt_at_slot| slot >= halt_at_slot)
.unwrap_or(false);
if done_processing {
if opts.run_final_accounts_hash_calc {
run_final_hash_calc(&bank, on_halt_store_hash_raw_data_for_debug);
}
break;
}
process_next_slots(
&bank,
&meta,
@ -1595,13 +1605,6 @@ fn load_frozen_forks(
leader_schedule_cache,
&mut pending_slots,
)?;
if slot >= halt_at_slot {
if opts.run_final_accounts_hash_calc {
run_final_hash_calc(&bank, on_halt_store_hash_raw_data_for_debug);
}
break;
}
}
} else if on_halt_store_hash_raw_data_for_debug {
run_final_hash_calc(