Skip to content

Commit

Permalink
Adjust ledger-tool bigtable upload starting-slot default value
Browse files Browse the repository at this point in the history
Currently, if starting-slot is unspecified, a value of 0 will be chosen.
In the common case where someone is operating on a range much more
recent, this will result in a ton of wasted operations.

Instead, choose a smarter default value for starting-slot based on what
we detect is currently in the blockstore.
  • Loading branch information
Steven Czabaniuk committed Dec 23, 2022
1 parent 0a7d852 commit 16dcac2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ledger-tool/src/bigtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use {

async fn upload(
blockstore: Blockstore,
mut starting_slot: Slot,
starting_slot: Option<Slot>,
ending_slot: Option<Slot>,
force_reupload: bool,
config: solana_storage_bigtable::LedgerStorageConfig,
Expand All @@ -53,6 +53,16 @@ async fn upload(
};
let blockstore = Arc::new(blockstore);

let starting_slot = if let Some(starting_slot) = starting_slot {
Ok(starting_slot)
} else {
// It is possible that the slot returned here could get pruned before
// the value is later used by upload_confirmed_blocks(). This is ok as
// that method doesn't need the exact slot to exist; rather, the slot
// returned here is used as a lower bound to search for roots.
blockstore.get_first_available_block()
};
let mut starting_slot = starting_slot?;
let ending_slot = ending_slot.unwrap_or_else(|| blockstore.last_root());

while starting_slot <= ending_slot {
Expand Down Expand Up @@ -640,7 +650,7 @@ pub fn bigtable_process_command(

let future = match (subcommand, sub_matches) {
("upload", Some(arg_matches)) => {
let starting_slot = value_t!(arg_matches, "starting_slot", Slot).unwrap_or(0);
let starting_slot = value_t!(arg_matches, "starting_slot", Slot).ok();
let ending_slot = value_t!(arg_matches, "ending_slot", Slot).ok();
let force_reupload = arg_matches.is_present("force_reupload");
let blockstore = crate::open_blockstore(
Expand Down

0 comments on commit 16dcac2

Please sign in to comment.