Skip to content

Commit

Permalink
Special case slot 0 for block connectness check in ledger tool (#29860)
Browse files Browse the repository at this point in the history
* special case is_connected check for slot 0 so that we can load snapshot 0 for gce cluster boostrapting

* remove obsolete comments

* refactor with match expr

* update comments

* Update ledger-tool/src/main.rs

Co-authored-by: steviez <[email protected]>

* Update ledger-tool/src/main.rs

Co-authored-by: steviez <[email protected]>

Co-authored-by: steviez <[email protected]>
  • Loading branch information
HaoranYi and steviez authored Jan 25, 2023
1 parent 40bbf99 commit 2194551
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,19 +1065,26 @@ fn load_bank_forks(
})
};

if let Some(halt_slot) = process_options.halt_at_slot {
if halt_slot < starting_slot {
eprintln!(
match process_options.halt_at_slot {
// Skip the following checks for sentinel values of Some(0) and None.
// For Some(0), no slots will be be replayed after starting_slot.
// For None, all available children of starting_slot will be replayed.
None | Some(0) => {}
Some(halt_slot) => {
if halt_slot < starting_slot {
eprintln!(
"Unable to load bank forks at slot {halt_slot} because it is less than the starting slot {starting_slot}. \
The starting slot will be the latest snapshot slot, or genesis if --no-snapshot flag specified or no snapshots found."
);
exit(1);
}
// Check if we have the slot data necessary to replay from starting_slot to <= halt_slot.
// - This will not catch the case when loading from genesis without a full slot 0.
if !blockstore.slot_range_connected(starting_slot, halt_slot) {
eprintln!("Unable to load bank forks at slot {halt_slot} due to disconnected blocks.",);
exit(1);
exit(1);
}
// Check if we have the slot data necessary to replay from starting_slot to >= halt_slot.
if !blockstore.slot_range_connected(starting_slot, halt_slot) {
eprintln!(
"Unable to load bank forks at slot {halt_slot} due to disconnected blocks.",
);
exit(1);
}
}
}

Expand Down

0 comments on commit 2194551

Please sign in to comment.