Allow process_blocktree() to start processing from any root (#5484)

* Remove unnecessary entry_height from BankInfo

* Refactor process_blocktree to support process_blocktree_from_root

* Refactor to process blocktree after loading from snapshot

* On restart make sure bank_forks contains all the banks between the root and the tip of each fork, not just the head of each fork

* Account for 1 tick_per_slot in bank 0 so that blockhash of bank0 matches the tick
This commit is contained in:
carllin
2019-08-13 17:20:14 -07:00
committed by GitHub
parent 58d4e32c97
commit cd14a940d8
7 changed files with 452 additions and 293 deletions

View File

@@ -355,30 +355,28 @@ fn get_bank_forks(
// Check that the snapshot tar exists, try to load the snapshot if it does
if tar.exists() {
// Fail hard here if snapshot fails to load, don't silently continue
let bank_forks = BankForks::load_from_snapshot(
//&genesis_block,
let deserialized_bank = snapshot_utils::bank_from_archive(
account_paths
.clone()
.expect("Account paths not present when booting from snapshot"),
snapshot_config,
tar,
&tar,
)
.expect("Load from snapshot failed");
let bank = &bank_forks.working_bank();
let fork_info = BankForksInfo {
bank_slot: bank.slot(),
entry_height: bank.tick_height(),
};
result = Some((
bank_forks,
vec![fork_info],
LeaderScheduleCache::new_from_bank(bank),
));
result = Some(
blocktree_processor::process_blocktree_from_root(
blocktree,
Arc::new(deserialized_bank),
verify_ledger,
dev_halt_at_slot,
)
.expect("processing blocktree after loading snapshot failed"),
);
}
}
// If loading from a snapshot failed/snapshot didn't exist
// If a snapshot doesn't exist
if result.is_none() {
result = Some(
blocktree_processor::process_blocktree(