From 1d6b03358fd3a532e4c03153c2ead2154c0670a7 Mon Sep 17 00:00:00 2001 From: steviez Date: Wed, 31 May 2023 21:12:49 -0500 Subject: [PATCH] ledger-tool: Rename load_frozen_forks() and adjust error messages (#31903) This function has morphed as it has been updated, and the existing function name is a bit of misnomer. Update the function name to use terminology that I think is more clear and more consistent with what we use core/src/validator.rs. Additionally, adjust the error messages to be more clear about what exactly is wrong for when we can't process. --- ledger-tool/src/ledger_utils.rs | 14 +++++++++----- ledger-tool/src/main.rs | 14 +++++++------- ledger-tool/src/program.rs | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ledger-tool/src/ledger_utils.rs b/ledger-tool/src/ledger_utils.rs index 77051c9734..db63057b54 100644 --- a/ledger-tool/src/ledger_utils.rs +++ b/ledger-tool/src/ledger_utils.rs @@ -67,7 +67,7 @@ pub fn get_shred_storage_type(ledger_path: &Path, message: &str) -> ShredStorage } } -pub fn load_bank_forks( +pub fn load_and_process_ledger( arg_matches: &ArgMatches, genesis_config: &GenesisConfig, blockstore: Arc, @@ -111,6 +111,8 @@ pub fn load_bank_forks( }) }; + let start_slot_msg = "The starting slot will be the latest snapshot slot, or genesis if \ + the --no-snapshot flag is specified or if no snapshots are found."; 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. @@ -119,15 +121,17 @@ pub fn load_bank_forks( 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 the --no-snapshot flag is specified or if no snapshots are found." - ); + "Unable to process blockstore from starting slot {starting_slot} to \ + {halt_slot}; the ending slot is less than the starting slot. {start_slot_msg}" + ); 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.", + "Unable to process blockstore from starting slot {starting_slot} to \ + {halt_slot}; the blockstore does not contain a replayable chain between these \ + slots. {start_slot_msg}" ); exit(1); } diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index a0e901732d..c92b7c6767 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -2201,7 +2201,7 @@ fn main() { wal_recovery_mode, force_update_to_open, ); - match load_bank_forks( + match load_and_process_ledger( arg_matches, &genesis_config, Arc::new(blockstore), @@ -2293,7 +2293,7 @@ fn main() { wal_recovery_mode, force_update_to_open, ); - match load_bank_forks( + match load_and_process_ledger( arg_matches, &genesis_config, Arc::new(blockstore), @@ -2531,7 +2531,7 @@ fn main() { wal_recovery_mode, force_update_to_open, ); - let (bank_forks, ..) = load_bank_forks( + let (bank_forks, ..) = load_and_process_ledger( arg_matches, &genesis_config, Arc::new(blockstore), @@ -2575,7 +2575,7 @@ fn main() { wal_recovery_mode, force_update_to_open, ); - match load_bank_forks( + match load_and_process_ledger( arg_matches, &open_genesis_config_by(&ledger_path, arg_matches), Arc::new(blockstore), @@ -2745,7 +2745,7 @@ fn main() { output_directory.display() ); - match load_bank_forks( + match load_and_process_ledger( arg_matches, &genesis_config, blockstore.clone(), @@ -3116,7 +3116,7 @@ fn main() { wal_recovery_mode, force_update_to_open, ); - let (bank_forks, ..) = load_bank_forks( + let (bank_forks, ..) = load_and_process_ledger( arg_matches, &genesis_config, Arc::new(blockstore), @@ -3205,7 +3205,7 @@ fn main() { wal_recovery_mode, force_update_to_open, ); - match load_bank_forks( + match load_and_process_ledger( arg_matches, &genesis_config, Arc::new(blockstore), diff --git a/ledger-tool/src/program.rs b/ledger-tool/src/program.rs index 26234373d2..99587c8117 100644 --- a/ledger-tool/src/program.rs +++ b/ledger-tool/src/program.rs @@ -119,7 +119,7 @@ fn load_blockstore(ledger_path: &Path, arg_matches: &ArgMatches<'_>) -> Arc