Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Create-snapshot check if slot is available on startup #25329

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,13 +741,28 @@ fn load_bank_forks(
} else {
"snapshot.ledger-tool"
});

let mut starting_slot = 0; // default start check with genesis
let snapshot_config = if arg_matches.is_present("no_snapshot") {
None
} else {
let full_snapshot_archives_dir =
snapshot_archive_path.unwrap_or_else(|| blockstore.ledger_path().to_path_buf());
let incremental_snapshot_archives_dir =
incremental_snapshot_archive_path.unwrap_or_else(|| full_snapshot_archives_dir.clone());

if let Some(full_snapshot_slot) =
snapshot_utils::get_highest_full_snapshot_archive_slot(&full_snapshot_archives_dir)
{
let incremental_snapshot_slot =
snapshot_utils::get_highest_incremental_snapshot_archive_slot(
&incremental_snapshot_archives_dir,
full_snapshot_slot,
)
.unwrap_or_default();
starting_slot = std::cmp::max(full_snapshot_slot, incremental_snapshot_slot);
}

Some(SnapshotConfig {
full_snapshot_archive_interval_slots: Slot::MAX,
incremental_snapshot_archive_interval_slots: Slot::MAX,
Expand All @@ -757,6 +772,22 @@ fn load_bank_forks(
..SnapshotConfig::default()
})
};

if let Some(halt_slot) = process_options.halt_at_slot {
for slot in starting_slot..=halt_slot {
if let Ok(Some(slot_meta)) = blockstore.meta(slot) {
if !slot_meta.is_full() {
eprintln!("blockstore slot {} is not full which is required for replaying slots {}..={}",
steviez marked this conversation as resolved.
Show resolved Hide resolved
slot, starting_slot, halt_slot);
exit(1);
}
} else {
eprintln!("blockstore missing data for slot {} which is required for replaying slots {}..={}", slot, starting_slot, halt_slot);
steviez marked this conversation as resolved.
Show resolved Hide resolved
exit(1);
}
}
}

let account_paths = if let Some(account_paths) = arg_matches.value_of("account_paths") {
if !blockstore.is_primary_access() {
// Be defensive, when default account dir is explicitly specified, it's still possible
Expand Down