Ledger-tool CLI can specify accounts hash cache path (#33118)

This commit is contained in:
Brooks 2023-09-02 16:17:03 -04:00 committed by GitHub
parent fb1ba216f5
commit adee97fe38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 1 deletions

View File

@ -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},
};
@ -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(),

View File

@ -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")
@ -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)
@ -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)
@ -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)
@ -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)
@ -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)