Name snapshots consistently (#19346)
#### Problem Snapshot names are overloaded, and there are multiple terms that mean the same thing. This is confusing. Here's a list of ones in the codebase that I've found: ``` - snapshot_dir - snapshots_dir - snapshot_path - snapshot_output_dir - snapshot_package_output_path - snapshot_archives_dir ``` #### Summary of Changes For all the ones that are about the directory where snapshot archives are stored, ensure they are `snapshot_archives_dir`. For the ones about the (bank) snapshots directory, set to `bank_snapshots_dir`. Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@ -278,12 +278,12 @@ pub fn main() {
|
||||
);
|
||||
|
||||
let ledger_path = PathBuf::from(matches.value_of("ledger_path").unwrap());
|
||||
let snapshot_output_dir = if let Some(snapshots) = matches.value_of("snapshots") {
|
||||
let snapshot_archives_dir = if let Some(snapshots) = matches.value_of("snapshots") {
|
||||
PathBuf::from(snapshots)
|
||||
} else {
|
||||
ledger_path.clone()
|
||||
};
|
||||
let snapshot_path = snapshot_output_dir.join("snapshot");
|
||||
let bank_snapshots_dir = snapshot_archives_dir.join("snapshot");
|
||||
|
||||
let account_paths: Vec<PathBuf> =
|
||||
if let Ok(account_paths) = values_t!(matches, "account_paths", String) {
|
||||
@ -348,7 +348,7 @@ pub fn main() {
|
||||
&node,
|
||||
expected_shred_version,
|
||||
&peer_pubkey,
|
||||
&snapshot_output_dir,
|
||||
&snapshot_archives_dir,
|
||||
socket_addr_space,
|
||||
);
|
||||
|
||||
@ -362,8 +362,8 @@ pub fn main() {
|
||||
rpc_addr: rpc_addrs.0,
|
||||
rpc_pubsub_addr: rpc_addrs.1,
|
||||
ledger_path,
|
||||
snapshot_output_dir,
|
||||
snapshot_path,
|
||||
snapshot_archives_dir,
|
||||
bank_snapshots_dir,
|
||||
account_paths,
|
||||
snapshot_info: snapshot_info.unwrap(),
|
||||
cluster_info,
|
||||
|
@ -44,8 +44,8 @@ pub struct ReplicaNodeConfig {
|
||||
pub rpc_addr: SocketAddr,
|
||||
pub rpc_pubsub_addr: SocketAddr,
|
||||
pub ledger_path: PathBuf,
|
||||
pub snapshot_output_dir: PathBuf,
|
||||
pub snapshot_path: PathBuf,
|
||||
pub snapshot_archives_dir: PathBuf,
|
||||
pub bank_snapshots_dir: PathBuf,
|
||||
pub account_paths: Vec<PathBuf>,
|
||||
pub snapshot_info: (Slot, Hash),
|
||||
pub cluster_info: Arc<ClusterInfo>,
|
||||
@ -82,12 +82,12 @@ fn initialize_from_snapshot(
|
||||
) -> ReplicaBankInfo {
|
||||
info!(
|
||||
"Downloading snapshot from the peer into {:?}",
|
||||
replica_config.snapshot_output_dir
|
||||
replica_config.snapshot_archives_dir
|
||||
);
|
||||
|
||||
download_snapshot(
|
||||
&replica_config.rpc_source_addr,
|
||||
&replica_config.snapshot_output_dir,
|
||||
&replica_config.snapshot_archives_dir,
|
||||
replica_config.snapshot_info,
|
||||
false,
|
||||
snapshot_config.maximum_snapshots_to_retain,
|
||||
@ -95,11 +95,13 @@ fn initialize_from_snapshot(
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
fs::create_dir_all(&snapshot_config.snapshot_path).expect("Couldn't create snapshot directory");
|
||||
fs::create_dir_all(&snapshot_config.bank_snapshots_dir)
|
||||
.expect("Couldn't create bank snapshot directory");
|
||||
|
||||
let archive_info =
|
||||
snapshot_utils::get_highest_full_snapshot_archive_info(&replica_config.snapshot_output_dir)
|
||||
.unwrap();
|
||||
let archive_info = snapshot_utils::get_highest_full_snapshot_archive_info(
|
||||
&replica_config.snapshot_archives_dir,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let process_options = blockstore_processor::ProcessOptions {
|
||||
account_indexes: replica_config.account_indexes.clone(),
|
||||
@ -109,12 +111,12 @@ fn initialize_from_snapshot(
|
||||
|
||||
info!(
|
||||
"Build bank from snapshot archive: {:?}",
|
||||
&snapshot_config.snapshot_path
|
||||
&snapshot_config.bank_snapshots_dir
|
||||
);
|
||||
let (bank0, _) = snapshot_utils::bank_from_snapshot_archives(
|
||||
&replica_config.account_paths,
|
||||
&[],
|
||||
&snapshot_config.snapshot_path,
|
||||
&snapshot_config.bank_snapshots_dir,
|
||||
&archive_info,
|
||||
None,
|
||||
genesis_config,
|
||||
@ -257,8 +259,8 @@ impl ReplicaNode {
|
||||
let snapshot_config = SnapshotConfig {
|
||||
full_snapshot_archive_interval_slots: std::u64::MAX,
|
||||
incremental_snapshot_archive_interval_slots: std::u64::MAX,
|
||||
snapshot_package_output_path: replica_config.snapshot_output_dir.clone(),
|
||||
snapshot_path: replica_config.snapshot_path.clone(),
|
||||
snapshot_archives_dir: replica_config.snapshot_archives_dir.clone(),
|
||||
bank_snapshots_dir: replica_config.bank_snapshots_dir.clone(),
|
||||
archive_format: ArchiveFormat::TarBzip2,
|
||||
snapshot_version: snapshot_utils::SnapshotVersion::default(),
|
||||
maximum_snapshots_to_retain:
|
||||
|
@ -55,7 +55,7 @@ fn get_rpc_peer_node(
|
||||
cluster_entrypoints: &[ContactInfo],
|
||||
expected_shred_version: Option<u16>,
|
||||
peer_pubkey: &Pubkey,
|
||||
snapshot_output_dir: &Path,
|
||||
snapshot_archives_dir: &Path,
|
||||
) -> Option<(ContactInfo, Option<(Slot, Hash)>)> {
|
||||
let mut newer_cluster_snapshot_timeout = None;
|
||||
let mut retry_reason = None;
|
||||
@ -110,7 +110,7 @@ fn get_rpc_peer_node(
|
||||
);
|
||||
|
||||
let mut highest_snapshot_info: Option<(Slot, Hash)> =
|
||||
snapshot_utils::get_highest_full_snapshot_archive_info(snapshot_output_dir).map(
|
||||
snapshot_utils::get_highest_full_snapshot_archive_info(snapshot_archives_dir).map(
|
||||
|snapshot_archive_info| {
|
||||
(snapshot_archive_info.slot(), *snapshot_archive_info.hash())
|
||||
},
|
||||
@ -238,7 +238,7 @@ pub fn get_rpc_peer_info(
|
||||
node: &Node,
|
||||
expected_shred_version: Option<u16>,
|
||||
peer_pubkey: &Pubkey,
|
||||
snapshot_output_dir: &Path,
|
||||
snapshot_archives_dir: &Path,
|
||||
socket_addr_space: SocketAddrSpace,
|
||||
) -> (Arc<ClusterInfo>, ContactInfo, Option<(Slot, Hash)>) {
|
||||
let identity_keypair = Arc::new(identity_keypair);
|
||||
@ -260,7 +260,7 @@ pub fn get_rpc_peer_info(
|
||||
cluster_entrypoints,
|
||||
expected_shred_version,
|
||||
peer_pubkey,
|
||||
snapshot_output_dir,
|
||||
snapshot_archives_dir,
|
||||
);
|
||||
let rpc_node_details = rpc_node_details.unwrap();
|
||||
|
||||
|
@ -45,7 +45,7 @@ const RUST_LOG_FILTER: &str =
|
||||
|
||||
fn wait_for_next_snapshot(
|
||||
cluster: &LocalCluster,
|
||||
snapshot_package_output_path: &Path,
|
||||
snapshot_archives_dir: &Path,
|
||||
) -> (PathBuf, (Slot, Hash)) {
|
||||
// Get slot after which this was generated
|
||||
let client = cluster
|
||||
@ -63,7 +63,7 @@ fn wait_for_next_snapshot(
|
||||
);
|
||||
loop {
|
||||
if let Some(full_snapshot_archive_info) =
|
||||
snapshot_utils::get_highest_full_snapshot_archive_info(snapshot_package_output_path)
|
||||
snapshot_utils::get_highest_full_snapshot_archive_info(snapshot_archives_dir)
|
||||
{
|
||||
trace!(
|
||||
"full snapshot for slot {} exists",
|
||||
@ -117,13 +117,13 @@ fn setup_snapshot_validator_config(
|
||||
num_account_paths: usize,
|
||||
) -> SnapshotValidatorConfig {
|
||||
// Create the snapshot config
|
||||
let snapshot_dir = tempfile::tempdir_in(farf_dir()).unwrap();
|
||||
let bank_snapshots_dir = tempfile::tempdir_in(farf_dir()).unwrap();
|
||||
let snapshot_archives_dir = tempfile::tempdir_in(farf_dir()).unwrap();
|
||||
let snapshot_config = SnapshotConfig {
|
||||
full_snapshot_archive_interval_slots: snapshot_interval_slots,
|
||||
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
||||
snapshot_package_output_path: snapshot_archives_dir.path().to_path_buf(),
|
||||
snapshot_path: snapshot_dir.path().to_path_buf(),
|
||||
snapshot_archives_dir: snapshot_archives_dir.path().to_path_buf(),
|
||||
bank_snapshots_dir: bank_snapshots_dir.path().to_path_buf(),
|
||||
archive_format: ArchiveFormat::TarBzip2,
|
||||
snapshot_version: snapshot_utils::SnapshotVersion::default(),
|
||||
maximum_snapshots_to_retain: snapshot_utils::DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
||||
@ -142,7 +142,7 @@ fn setup_snapshot_validator_config(
|
||||
};
|
||||
|
||||
SnapshotValidatorConfig {
|
||||
_snapshot_dir: snapshot_dir,
|
||||
_snapshot_dir: bank_snapshots_dir,
|
||||
snapshot_archives_dir,
|
||||
account_storage_dirs,
|
||||
validator_config,
|
||||
@ -204,15 +204,15 @@ fn test_replica_bootstrap() {
|
||||
info!("Contact info: {:?}", contact_info);
|
||||
|
||||
// Get slot after which this was generated
|
||||
let snapshot_package_output_path = &leader_snapshot_test_config
|
||||
let snapshot_archives_dir = &leader_snapshot_test_config
|
||||
.validator_config
|
||||
.snapshot_config
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.snapshot_package_output_path;
|
||||
.snapshot_archives_dir;
|
||||
info!("Waiting for snapshot");
|
||||
let (archive_filename, archive_snapshot_hash) =
|
||||
wait_for_next_snapshot(&cluster, snapshot_package_output_path);
|
||||
wait_for_next_snapshot(&cluster, snapshot_archives_dir);
|
||||
info!("found: {:?}", archive_filename);
|
||||
|
||||
let identity_keypair = Keypair::new();
|
||||
@ -228,8 +228,8 @@ fn test_replica_bootstrap() {
|
||||
let ledger_dir = tempfile::tempdir_in(farf_dir()).unwrap();
|
||||
let ledger_path = ledger_dir.path();
|
||||
let snapshot_output_dir = tempfile::tempdir_in(farf_dir()).unwrap();
|
||||
let snapshot_output_path = snapshot_output_dir.path();
|
||||
let snapshot_path = snapshot_output_path.join("snapshot");
|
||||
let snapshot_archives_dir = snapshot_output_dir.path();
|
||||
let bank_snapshots_dir = snapshot_archives_dir.join("snapshot");
|
||||
let account_paths: Vec<PathBuf> = vec![ledger_path.join("accounts")];
|
||||
|
||||
let port = solana_net_utils::find_available_port_in_range(ip_addr, (8301, 8400)).unwrap();
|
||||
@ -253,7 +253,7 @@ fn test_replica_bootstrap() {
|
||||
&node,
|
||||
None,
|
||||
&contact_info.id,
|
||||
snapshot_output_path,
|
||||
snapshot_archives_dir,
|
||||
socket_addr_space,
|
||||
);
|
||||
|
||||
@ -264,8 +264,8 @@ fn test_replica_bootstrap() {
|
||||
rpc_addr,
|
||||
rpc_pubsub_addr,
|
||||
ledger_path: ledger_path.to_path_buf(),
|
||||
snapshot_output_dir: snapshot_output_path.to_path_buf(),
|
||||
snapshot_path,
|
||||
snapshot_archives_dir: snapshot_archives_dir.to_path_buf(),
|
||||
bank_snapshots_dir,
|
||||
account_paths,
|
||||
snapshot_info: archive_snapshot_hash,
|
||||
cluster_info,
|
||||
|
Reference in New Issue
Block a user