Skip to content

Commit

Permalink
Ledger-tool CLI can specify accounts hash cache path (solana-labs#33118)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Sep 2, 2023
1 parent fb1ba21 commit adee97f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ledger-tool/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ use {
crate::LEDGER_TOOL_DIRECTORY,
clap::{value_t, values_t_or_exit, ArgMatches},
solana_accounts_db::{
accounts_db::{AccountsDbConfig, FillerAccountsConfig},
accounts_db::{AccountsDb, AccountsDbConfig, FillerAccountsConfig},
accounts_index::{AccountsIndexConfig, IndexLimitMb},
partitioned_rewards::TestPartitionedEpochRewards,
},
solana_runtime::snapshot_utils,
solana_sdk::clock::Slot,
std::path::{Path, PathBuf},
};
Expand Down Expand Up @@ -57,9 +58,25 @@ pub fn get_accounts_db_config(
size: value_t!(arg_matches, "accounts_filler_size", usize).unwrap_or(0),
};

let accounts_hash_cache_path = arg_matches
.value_of("accounts_hash_cache_path")
.map(Into::into)
.unwrap_or_else(|| {
ledger_tool_ledger_path.join(AccountsDb::DEFAULT_ACCOUNTS_HASH_CACHE_DIR)
});
let accounts_hash_cache_path =
snapshot_utils::create_and_canonicalize_directories(&[accounts_hash_cache_path])
.unwrap_or_else(|err| {
eprintln!("Unable to access accounts hash cache path: {err}");
std::process::exit(1);
})
.pop()
.unwrap();

AccountsDbConfig {
index: Some(accounts_index_config),
base_working_path: Some(ledger_tool_ledger_path),
accounts_hash_cache_path: Some(accounts_hash_cache_path),
filler_accounts_config,
ancient_append_vec_offset: value_t!(arg_matches, "accounts_db_ancient_append_vecs", i64)
.ok(),
Expand Down
10 changes: 10 additions & 0 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,11 @@ fn main() {
.value_name("PATHS")
.takes_value(true)
.help("Comma separated persistent accounts location");
let accounts_hash_cache_path_arg = Arg::with_name("accounts_hash_cache_path")
.long("accounts-hash-cache-path")
.value_name("PATH")
.takes_value(true)
.help("Use PATH as accounts hash cache location");
let accounts_index_path_arg = Arg::with_name("accounts_index_path")
.long("accounts-index-path")
.value_name("PATH")
Expand Down Expand Up @@ -1593,6 +1598,7 @@ fn main() {
.about("Verify the ledger")
.arg(&no_snapshot_arg)
.arg(&account_paths_arg)
.arg(&accounts_hash_cache_path_arg)
.arg(&accounts_index_path_arg)
.arg(&halt_at_slot_arg)
.arg(&limit_load_slot_count_from_snapshot_arg)
Expand Down Expand Up @@ -1676,6 +1682,7 @@ fn main() {
.about("Create a Graphviz rendering of the ledger")
.arg(&no_snapshot_arg)
.arg(&account_paths_arg)
.arg(&accounts_hash_cache_path_arg)
.arg(&accounts_index_bins)
.arg(&accounts_index_limit)
.arg(&disable_disk_index)
Expand Down Expand Up @@ -1711,6 +1718,7 @@ fn main() {
.about("Create a new ledger snapshot")
.arg(&no_snapshot_arg)
.arg(&account_paths_arg)
.arg(&accounts_hash_cache_path_arg)
.arg(&accounts_index_bins)
.arg(&accounts_index_limit)
.arg(&disable_disk_index)
Expand Down Expand Up @@ -1904,6 +1912,7 @@ fn main() {
.about("Print account stats and contents after processing the ledger")
.arg(&no_snapshot_arg)
.arg(&account_paths_arg)
.arg(&accounts_hash_cache_path_arg)
.arg(&accounts_index_bins)
.arg(&accounts_index_limit)
.arg(&disable_disk_index)
Expand Down Expand Up @@ -1937,6 +1946,7 @@ fn main() {
.about("Print capitalization (aka, total supply) while checksumming it")
.arg(&no_snapshot_arg)
.arg(&account_paths_arg)
.arg(&accounts_hash_cache_path_arg)
.arg(&accounts_index_bins)
.arg(&accounts_index_limit)
.arg(&disable_disk_index)
Expand Down

0 comments on commit adee97f

Please sign in to comment.