Jelajahi Sumber

Move snapshot_archive_info to agave-snapshots (#8721)

Kamil Skalski 3 minggu lalu
induk
melakukan
e65003def4

+ 2 - 2
core/src/validator.rs

@@ -35,7 +35,8 @@ use {
         tvu::{Tvu, TvuConfig, TvuSockets},
     },
     agave_snapshots::{
-        snapshot_config::SnapshotConfig, snapshot_hash::StartingSnapshotHashes, SnapshotInterval,
+        snapshot_archive_info::SnapshotArchiveInfoGetter as _, snapshot_config::SnapshotConfig,
+        snapshot_hash::StartingSnapshotHashes, SnapshotInterval,
     },
     anyhow::{anyhow, Context, Result},
     crossbeam_channel::{bounded, unbounded, Receiver},
@@ -126,7 +127,6 @@ use {
         dependency_tracker::DependencyTracker,
         prioritization_fee_cache::PrioritizationFeeCache,
         runtime_config::RuntimeConfig,
-        snapshot_archive_info::SnapshotArchiveInfoGetter,
         snapshot_bank_utils,
         snapshot_controller::SnapshotController,
         snapshot_utils::{self, clean_orphaned_account_snapshot_dirs},

+ 6 - 4
core/tests/snapshots.rs

@@ -2,7 +2,10 @@
 
 use {
     crate::snapshot_utils::create_tmp_accounts_dir_for_tests,
-    agave_snapshots::{paths as snapshot_paths, snapshot_config::SnapshotConfig, SnapshotInterval},
+    agave_snapshots::{
+        paths as snapshot_paths, snapshot_archive_info::FullSnapshotArchiveInfo,
+        snapshot_config::SnapshotConfig, SnapshotInterval,
+    },
     crossbeam_channel::unbounded,
     itertools::Itertools,
     log::{info, trace},
@@ -22,7 +25,6 @@ use {
         bank_forks::BankForks,
         genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo},
         runtime_config::RuntimeConfig,
-        snapshot_archive_info::FullSnapshotArchiveInfo,
         snapshot_bank_utils,
         snapshot_controller::SnapshotController,
         snapshot_utils,
@@ -681,7 +683,7 @@ fn test_snapshots_with_background_services() {
         // If a snapshot should be taken this slot, wait for it to complete
         if slot % FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS == 0 {
             let timer = Instant::now();
-            while snapshot_utils::get_highest_full_snapshot_archive_slot(
+            while snapshot_paths::get_highest_full_snapshot_archive_slot(
                 &snapshot_test_config
                     .snapshot_config
                     .full_snapshot_archives_dir,
@@ -699,7 +701,7 @@ fn test_snapshots_with_background_services() {
             && latest_full_snapshot_slot.is_some()
         {
             let timer = Instant::now();
-            while snapshot_utils::get_highest_incremental_snapshot_archive_slot(
+            while snapshot_paths::get_highest_incremental_snapshot_archive_slot(
                 &snapshot_test_config
                     .snapshot_config
                     .incremental_snapshot_archives_dir,

+ 3 - 3
ledger-tool/src/ledger_utils.rs

@@ -1,7 +1,7 @@
 use {
     crate::LEDGER_TOOL_DIRECTORY,
     agave_snapshots::{
-        paths::BANK_SNAPSHOTS_DIR,
+        paths::{self as snapshot_paths, BANK_SNAPSHOTS_DIR},
         snapshot_config::{SnapshotConfig, SnapshotUsage},
         snapshot_hash::StartingSnapshotHashes,
     },
@@ -155,10 +155,10 @@ pub fn load_and_process_ledger(
             .map(PathBuf::from)
             .unwrap_or_else(|| snapshots_dir.clone());
         if let Some(full_snapshot_slot) =
-            snapshot_utils::get_highest_full_snapshot_archive_slot(&full_snapshot_archives_dir)
+            snapshot_paths::get_highest_full_snapshot_archive_slot(&full_snapshot_archives_dir)
         {
             let incremental_snapshot_slot =
-                snapshot_utils::get_highest_incremental_snapshot_archive_slot(
+                snapshot_paths::get_highest_incremental_snapshot_archive_slot(
                     &incremental_snapshot_archives_dir,
                     full_snapshot_slot,
                 )

+ 2 - 2
ledger-tool/src/main.rs

@@ -15,7 +15,8 @@ use {
     agave_feature_set::{self as feature_set, FeatureSet},
     agave_reserved_account_keys::ReservedAccountKeys,
     agave_snapshots::{
-        ArchiveFormat, SnapshotVersion, DEFAULT_ARCHIVE_COMPRESSION, SUPPORTED_ARCHIVE_COMPRESSION,
+        snapshot_archive_info::SnapshotArchiveInfoGetter as _, ArchiveFormat, SnapshotVersion,
+        DEFAULT_ARCHIVE_COMPRESSION, SUPPORTED_ARCHIVE_COMPRESSION,
     },
     clap::{
         crate_description, crate_name, value_t, value_t_or_exit, values_t_or_exit, App,
@@ -67,7 +68,6 @@ use {
         bank_forks::BankForks,
         inflation_rewards::points::{InflationPointCalculationEvent, PointValue},
         installed_scheduler_pool::BankWithScheduler,
-        snapshot_archive_info::SnapshotArchiveInfoGetter,
         snapshot_bank_utils,
         snapshot_minimizer::SnapshotMinimizer,
     },

+ 7 - 9
ledger/src/bank_forks_utils.rs

@@ -10,19 +10,17 @@ use {
     },
     agave_snapshots::{
         error::SnapshotError,
+        paths as snapshot_paths,
+        snapshot_archive_info::{
+            FullSnapshotArchiveInfo, IncrementalSnapshotArchiveInfo, SnapshotArchiveInfoGetter,
+        },
         snapshot_config::SnapshotConfig,
         snapshot_hash::{FullSnapshotHash, IncrementalSnapshotHash, StartingSnapshotHashes},
     },
     log::*,
     solana_accounts_db::accounts_update_notifier_interface::AccountsUpdateNotifier,
     solana_genesis_config::GenesisConfig,
-    solana_runtime::{
-        bank_forks::BankForks,
-        snapshot_archive_info::{
-            FullSnapshotArchiveInfo, IncrementalSnapshotArchiveInfo, SnapshotArchiveInfoGetter,
-        },
-        snapshot_bank_utils, snapshot_utils,
-    },
+    solana_runtime::{bank_forks::BankForks, snapshot_bank_utils, snapshot_utils},
     std::{
         path::PathBuf,
         result,
@@ -139,7 +137,7 @@ pub fn load_bank_forks(
         };
 
         let Some(full_snapshot_archive_info) =
-            snapshot_utils::get_highest_full_snapshot_archive_info(
+            snapshot_paths::get_highest_full_snapshot_archive_info(
                 &snapshot_config.full_snapshot_archives_dir,
             )
         else {
@@ -151,7 +149,7 @@ pub fn load_bank_forks(
         };
 
         let incremental_snapshot_archive_info =
-            snapshot_utils::get_highest_incremental_snapshot_archive_info(
+            snapshot_paths::get_highest_incremental_snapshot_archive_info(
                 &snapshot_config.incremental_snapshot_archives_dir,
                 full_snapshot_archive_info.slot(),
             );

+ 7 - 7
local-cluster/src/local_cluster_snapshot_utils.rs

@@ -1,12 +1,12 @@
 use {
     crate::local_cluster::LocalCluster,
-    log::*,
-    solana_runtime::{
+    agave_snapshots::{
+        paths as snapshot_paths,
         snapshot_archive_info::{
             FullSnapshotArchiveInfo, IncrementalSnapshotArchiveInfo, SnapshotArchiveInfoGetter,
         },
-        snapshot_utils,
     },
+    log::*,
     std::{
         path::Path,
         thread::sleep,
@@ -70,12 +70,12 @@ impl LocalCluster {
         max_wait_duration: Option<Duration>,
     ) -> NextSnapshotResult {
         let full_snapshot_slot =
-            snapshot_utils::get_highest_full_snapshot_archive_slot(&full_snapshot_archives_dir);
+            snapshot_paths::get_highest_full_snapshot_archive_slot(&full_snapshot_archives_dir);
         let last_slot = match next_snapshot_type {
             NextSnapshotType::FullSnapshot => full_snapshot_slot,
             NextSnapshotType::IncrementalAndFullSnapshot => {
                 full_snapshot_slot.and_then(|full_snapshot_slot| {
-                    snapshot_utils::get_highest_incremental_snapshot_archive_slot(
+                    snapshot_paths::get_highest_incremental_snapshot_archive_slot(
                         incremental_snapshot_archives_dir.as_ref().unwrap(),
                         full_snapshot_slot,
                     )
@@ -92,7 +92,7 @@ impl LocalCluster {
         let timer = Instant::now();
         let next_snapshot = loop {
             if let Some(full_snapshot_archive_info) =
-                snapshot_utils::get_highest_full_snapshot_archive_info(&full_snapshot_archives_dir)
+                snapshot_paths::get_highest_full_snapshot_archive_info(&full_snapshot_archives_dir)
             {
                 match next_snapshot_type {
                     NextSnapshotType::FullSnapshot => {
@@ -102,7 +102,7 @@ impl LocalCluster {
                     }
                     NextSnapshotType::IncrementalAndFullSnapshot => {
                         if let Some(incremental_snapshot_archive_info) =
-                            snapshot_utils::get_highest_incremental_snapshot_archive_info(
+                            snapshot_paths::get_highest_incremental_snapshot_archive_info(
                                 incremental_snapshot_archives_dir.as_ref().unwrap(),
                                 full_snapshot_archive_info.slot(),
                             )

+ 22 - 19
local-cluster/tests/local_cluster.rs

@@ -1,6 +1,9 @@
 #![allow(clippy::arithmetic_side_effects)]
 use {
-    agave_snapshots::{paths as snapshot_paths, snapshot_config::SnapshotConfig, SnapshotInterval},
+    agave_snapshots::{
+        paths as snapshot_paths, snapshot_archive_info::SnapshotArchiveInfoGetter,
+        snapshot_config::SnapshotConfig, SnapshotInterval,
+    },
     assert_matches::assert_matches,
     crossbeam_channel::{unbounded, Receiver},
     gag::BufferRedirect,
@@ -69,8 +72,8 @@ use {
         response::RpcSignatureResult,
     },
     solana_runtime::{
-        commitment::VOTE_THRESHOLD_SIZE, snapshot_archive_info::SnapshotArchiveInfoGetter,
-        snapshot_bank_utils, snapshot_package::SnapshotKind, snapshot_utils,
+        commitment::VOTE_THRESHOLD_SIZE, snapshot_bank_utils, snapshot_package::SnapshotKind,
+        snapshot_utils,
     },
     solana_signer::Signer,
     solana_stake_interface::{self as stake, state::NEW_WARMUP_COOLDOWN_RATE},
@@ -841,7 +844,7 @@ fn test_incremental_snapshot_download_with_crossing_full_snapshot_interval_at_st
         &mut None,
     )
     .unwrap();
-    let downloaded_full_snapshot_archive = snapshot_utils::get_highest_full_snapshot_archive_info(
+    let downloaded_full_snapshot_archive = snapshot_paths::get_highest_full_snapshot_archive_info(
         validator_snapshot_test_config
             .full_snapshot_archives_dir
             .path(),
@@ -879,7 +882,7 @@ fn test_incremental_snapshot_download_with_crossing_full_snapshot_interval_at_st
     )
     .unwrap();
     let downloaded_incremental_snapshot_archive =
-        snapshot_utils::get_highest_incremental_snapshot_archive_info(
+        snapshot_paths::get_highest_incremental_snapshot_archive_info(
             validator_snapshot_test_config
                 .incremental_snapshot_archives_dir
                 .path(),
@@ -1028,7 +1031,7 @@ fn test_incremental_snapshot_download_with_crossing_full_snapshot_interval_at_st
     //
     // Putting this all in its own block so its clear we're only intended to keep the leader's info
     let leader_full_snapshot_archive_for_comparison = {
-        let validator_full_snapshot = snapshot_utils::get_highest_full_snapshot_archive_info(
+        let validator_full_snapshot = snapshot_paths::get_highest_full_snapshot_archive_info(
             validator_snapshot_test_config
                 .full_snapshot_archives_dir
                 .path(),
@@ -1036,7 +1039,7 @@ fn test_incremental_snapshot_download_with_crossing_full_snapshot_interval_at_st
         .unwrap();
 
         // Now get the same full snapshot on the LEADER that we just got from the validator
-        let mut leader_full_snapshots = snapshot_utils::get_full_snapshot_archives(
+        let mut leader_full_snapshots = snapshot_paths::get_full_snapshot_archives(
             leader_snapshot_test_config
                 .full_snapshot_archives_dir
                 .path(),
@@ -1098,7 +1101,7 @@ fn test_incremental_snapshot_download_with_crossing_full_snapshot_interval_at_st
 
     // Get the highest full snapshot slot *before* restarting, as a comparison
     let validator_full_snapshot_slot_at_startup =
-        snapshot_utils::get_highest_full_snapshot_archive_slot(
+        snapshot_paths::get_highest_full_snapshot_archive_slot(
             validator_snapshot_test_config
                 .full_snapshot_archives_dir
                 .path(),
@@ -1129,14 +1132,14 @@ fn test_incremental_snapshot_download_with_crossing_full_snapshot_interval_at_st
     );
     let timer = Instant::now();
     loop {
-        if let Some(full_snapshot_slot) = snapshot_utils::get_highest_full_snapshot_archive_slot(
+        if let Some(full_snapshot_slot) = snapshot_paths::get_highest_full_snapshot_archive_slot(
             validator_snapshot_test_config
                 .full_snapshot_archives_dir
                 .path(),
         ) {
             if full_snapshot_slot >= validator_next_full_snapshot_slot {
                 if let Some(incremental_snapshot_slot) =
-                    snapshot_utils::get_highest_incremental_snapshot_archive_slot(
+                    snapshot_paths::get_highest_incremental_snapshot_archive_slot(
                         validator_snapshot_test_config
                             .incremental_snapshot_archives_dir
                             .path(),
@@ -1170,7 +1173,7 @@ fn test_incremental_snapshot_download_with_crossing_full_snapshot_interval_at_st
 
     // Check to make sure that the full snapshot the validator created during startup is the same
     // or one greater than the snapshot the leader created.
-    let validator_full_snapshot_archives = snapshot_utils::get_full_snapshot_archives(
+    let validator_full_snapshot_archives = snapshot_paths::get_full_snapshot_archives(
         validator_snapshot_test_config
             .full_snapshot_archives_dir
             .path(),
@@ -1336,7 +1339,7 @@ fn test_snapshots_blockstore_floor() {
 
     let archive_info = loop {
         let archive =
-            snapshot_utils::get_highest_full_snapshot_archive_info(full_snapshot_archives_dir);
+            snapshot_paths::get_highest_full_snapshot_archive_info(full_snapshot_archives_dir);
         if archive.is_some() {
             trace!("snapshot exists");
             break archive.unwrap();
@@ -5175,12 +5178,12 @@ fn test_boot_from_local_state() {
         let timer = Instant::now();
         loop {
             if let Some(other_full_snapshot_slot) =
-                snapshot_utils::get_highest_full_snapshot_archive_slot(
+                snapshot_paths::get_highest_full_snapshot_archive_slot(
                     &other_validator_config.full_snapshot_archives_dir,
                 )
             {
                 let other_incremental_snapshot_slot =
-                    snapshot_utils::get_highest_incremental_snapshot_archive_slot(
+                    snapshot_paths::get_highest_incremental_snapshot_archive_slot(
                         &other_validator_config.incremental_snapshot_archives_dir,
                         other_full_snapshot_slot,
                     );
@@ -5196,7 +5199,7 @@ fn test_boot_from_local_state() {
             );
             std::thread::yield_now();
         }
-        let other_full_snapshot_archives = snapshot_utils::get_full_snapshot_archives(
+        let other_full_snapshot_archives = snapshot_paths::get_full_snapshot_archives(
             &other_validator_config.full_snapshot_archives_dir,
         );
         debug!("validator{i} full snapshot archives: {other_full_snapshot_archives:?}");
@@ -5221,7 +5224,7 @@ fn test_boot_from_local_state() {
                 .collect::<Vec<_>>(),
         );
 
-        let other_incremental_snapshot_archives = snapshot_utils::get_incremental_snapshot_archives(
+        let other_incremental_snapshot_archives = snapshot_paths::get_incremental_snapshot_archives(
             &other_validator_config.incremental_snapshot_archives_dir,
         );
         debug!(
@@ -5311,10 +5314,10 @@ fn test_boot_from_local_state_missing_archive() {
     );
     debug!(
         "snapshot archives:\n\tfull: {:?}\n\tincr: {:?}",
-        snapshot_utils::get_full_snapshot_archives(
+        snapshot_paths::get_full_snapshot_archives(
             validator_config.full_snapshot_archives_dir.path()
         ),
-        snapshot_utils::get_incremental_snapshot_archives(
+        snapshot_paths::get_incremental_snapshot_archives(
             validator_config.incremental_snapshot_archives_dir.path()
         ),
     );
@@ -5328,7 +5331,7 @@ fn test_boot_from_local_state_missing_archive() {
     info!("Stopping validator... DONE");
 
     info!("Deleting latest full snapshot archive...");
-    let highest_full_snapshot = snapshot_utils::get_highest_full_snapshot_archive_info(
+    let highest_full_snapshot = snapshot_paths::get_highest_full_snapshot_archive_info(
         validator_config.full_snapshot_archives_dir.path(),
     )
     .unwrap();

+ 3 - 4
rpc/src/rpc.rs

@@ -7,7 +7,7 @@ use {
         optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
         parsed_token_accounts::*, rpc_cache::LargestAccountsCache, rpc_health::*,
     },
-    agave_snapshots::snapshot_config::SnapshotConfig,
+    agave_snapshots::{paths as snapshot_paths, snapshot_config::SnapshotConfig},
     base64::{prelude::BASE64_STANDARD, Engine},
     bincode::{config::Options, serialize},
     crossbeam_channel::{unbounded, Receiver, Sender},
@@ -70,7 +70,6 @@ use {
         commitment::{BlockCommitmentArray, BlockCommitmentCache},
         non_circulating_supply::{calculate_non_circulating_supply, NonCirculatingSupply},
         prioritization_fee_cache::PrioritizationFeeCache,
-        snapshot_utils,
     },
     solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
     solana_send_transaction_service::send_transaction_service::TransactionInfo,
@@ -2857,10 +2856,10 @@ pub mod rpc_minimal {
                 .unwrap();
 
             let full_snapshot_slot =
-                snapshot_utils::get_highest_full_snapshot_archive_slot(full_snapshot_archives_dir)
+                snapshot_paths::get_highest_full_snapshot_archive_slot(full_snapshot_archives_dir)
                     .ok_or(RpcCustomError::NoSnapshot)?;
             let incremental_snapshot_slot =
-                snapshot_utils::get_highest_incremental_snapshot_archive_slot(
+                snapshot_paths::get_highest_incremental_snapshot_archive_slot(
                     incremental_snapshot_archives_dir,
                     full_snapshot_slot,
                 );

+ 6 - 4
rpc/src/rpc_service.rs

@@ -9,7 +9,10 @@ use {
         rpc_cache::LargestAccountsCache,
         rpc_health::*,
     },
-    agave_snapshots::{paths as snapshot_paths, snapshot_config::SnapshotConfig, SnapshotInterval},
+    agave_snapshots::{
+        paths as snapshot_paths, snapshot_archive_info::SnapshotArchiveInfoGetter,
+        snapshot_config::SnapshotConfig, SnapshotInterval,
+    },
     crossbeam_channel::unbounded,
     jsonrpc_core::{futures::prelude::*, MetaIoHandler},
     jsonrpc_http_server::{
@@ -38,7 +41,6 @@ use {
         bank::Bank, bank_forks::BankForks, commitment::BlockCommitmentCache,
         non_circulating_supply::calculate_non_circulating_supply,
         prioritization_fee_cache::PrioritizationFeeCache,
-        snapshot_archive_info::SnapshotArchiveInfoGetter, snapshot_utils,
     },
     solana_send_transaction_service::{
         send_transaction_service::{self, SendTransactionService},
@@ -348,7 +350,7 @@ impl RequestMiddleware for RpcRequestMiddleware {
             {
                 // Convenience redirect to the latest snapshot
                 let full_snapshot_archive_info =
-                    snapshot_utils::get_highest_full_snapshot_archive_info(
+                    snapshot_paths::get_highest_full_snapshot_archive_info(
                         &snapshot_config.full_snapshot_archives_dir,
                     );
                 let snapshot_archive_info =
@@ -356,7 +358,7 @@ impl RequestMiddleware for RpcRequestMiddleware {
                         if request.uri().path() == FULL_SNAPSHOT_REQUEST_PATH {
                             Some(full_snapshot_archive_info.snapshot_archive_info().clone())
                         } else {
-                            snapshot_utils::get_highest_incremental_snapshot_archive_info(
+                            snapshot_paths::get_highest_incremental_snapshot_archive_info(
                                 &snapshot_config.incremental_snapshot_archives_dir,
                                 full_snapshot_archive_info.slot(),
                             )

+ 0 - 1
runtime/src/lib.rs

@@ -31,7 +31,6 @@ mod read_optimized_dashmap;
 pub mod rent_collector;
 pub mod runtime_config;
 pub mod serde_snapshot;
-pub mod snapshot_archive_info;
 pub mod snapshot_bank_utils;
 pub mod snapshot_controller;
 pub mod snapshot_minimizer;

+ 8 - 6
runtime/src/snapshot_bank_utils.rs

@@ -18,13 +18,9 @@ use {
         serde_snapshot::{
             self, reconstruct_bank_from_fields, SnapshotAccountsDbFields, SnapshotBankFields,
         },
-        snapshot_archive_info::{
-            FullSnapshotArchiveInfo, IncrementalSnapshotArchiveInfo, SnapshotArchiveInfoGetter,
-        },
         snapshot_package::{SnapshotKind, SnapshotPackage},
         snapshot_utils::{
-            self, get_highest_bank_snapshot, get_highest_full_snapshot_archive_info,
-            get_highest_incremental_snapshot_archive_info, rebuild_storages_from_snapshot_dir,
+            self, get_highest_bank_snapshot, rebuild_storages_from_snapshot_dir,
             verify_and_unarchive_snapshots, BankSnapshotInfo, StorageAndNextAccountsFileId,
             UnarchivedSnapshots,
         },
@@ -35,7 +31,13 @@ use {
         error::{
             SnapshotError, VerifyEpochStakesError, VerifySlotDeltasError, VerifySlotHistoryError,
         },
-        paths as snapshot_paths,
+        paths::{
+            self as snapshot_paths, get_highest_full_snapshot_archive_info,
+            get_highest_incremental_snapshot_archive_info,
+        },
+        snapshot_archive_info::{
+            FullSnapshotArchiveInfo, IncrementalSnapshotArchiveInfo, SnapshotArchiveInfoGetter,
+        },
         snapshot_config::SnapshotConfig,
         snapshot_hash::SnapshotHash,
         ArchiveFormat, SnapshotVersion,

+ 16 - 108
runtime/src/snapshot_utils.rs

@@ -8,10 +8,6 @@ use {
             SerializableAccountStorageEntry, SnapshotAccountsDbFields, SnapshotBankFields,
             SnapshotStreams,
         },
-        snapshot_archive_info::{
-            FullSnapshotArchiveInfo, IncrementalSnapshotArchiveInfo, SnapshotArchiveInfo,
-            SnapshotArchiveInfoGetter,
-        },
         snapshot_package::{SnapshotKind, SnapshotPackage},
         snapshot_utils::snapshot_storage_rebuilder::{
             get_slot_and_append_vec_id, SnapshotStorageRebuilder,
@@ -23,7 +19,11 @@ use {
             HardLinkStoragesToSnapshotError, SnapshotError, SnapshotFastbootError,
             SnapshotNewFromDirError,
         },
-        paths as snapshot_paths,
+        paths::{self as snapshot_paths, get_incremental_snapshot_archives},
+        snapshot_archive_info::{
+            FullSnapshotArchiveInfo, IncrementalSnapshotArchiveInfo, SnapshotArchiveInfo,
+            SnapshotArchiveInfoGetter,
+        },
         snapshot_config::SnapshotConfig,
         snapshot_hash::SnapshotHash,
         streaming_unarchive_snapshot, ArchiveFormat, Result, SnapshotVersion,
@@ -1802,105 +1802,6 @@ fn check_are_snapshots_compatible(
         })
 }
 
-/// Walk down the snapshot archive to collect snapshot archive file info
-fn get_snapshot_archives<T, F>(snapshot_archives_dir: &Path, cb: F) -> Vec<T>
-where
-    F: Fn(PathBuf) -> Result<T>,
-{
-    let walk_dir = |dir: &Path| -> Vec<T> {
-        let entry_iter = fs::read_dir(dir);
-        match entry_iter {
-            Err(err) => {
-                info!(
-                    "Unable to read snapshot archives directory '{}': {err}",
-                    dir.display(),
-                );
-                vec![]
-            }
-            Ok(entries) => entries
-                .filter_map(|entry| entry.map_or(None, |entry| cb(entry.path()).ok()))
-                .collect(),
-        }
-    };
-
-    let mut ret = walk_dir(snapshot_archives_dir);
-    let remote_dir = snapshot_paths::build_snapshot_archives_remote_dir(snapshot_archives_dir);
-    if remote_dir.exists() {
-        ret.append(&mut walk_dir(remote_dir.as_ref()));
-    }
-    ret
-}
-
-/// Get a list of the full snapshot archives from a directory
-pub fn get_full_snapshot_archives(
-    full_snapshot_archives_dir: impl AsRef<Path>,
-) -> Vec<FullSnapshotArchiveInfo> {
-    get_snapshot_archives(
-        full_snapshot_archives_dir.as_ref(),
-        FullSnapshotArchiveInfo::new_from_path,
-    )
-}
-
-/// Get a list of the incremental snapshot archives from a directory
-pub fn get_incremental_snapshot_archives(
-    incremental_snapshot_archives_dir: impl AsRef<Path>,
-) -> Vec<IncrementalSnapshotArchiveInfo> {
-    get_snapshot_archives(
-        incremental_snapshot_archives_dir.as_ref(),
-        IncrementalSnapshotArchiveInfo::new_from_path,
-    )
-}
-
-/// Get the highest slot of the full snapshot archives in a directory
-pub fn get_highest_full_snapshot_archive_slot(
-    full_snapshot_archives_dir: impl AsRef<Path>,
-) -> Option<Slot> {
-    get_highest_full_snapshot_archive_info(full_snapshot_archives_dir)
-        .map(|full_snapshot_archive_info| full_snapshot_archive_info.slot())
-}
-
-/// Get the highest slot of the incremental snapshot archives in a directory, for a given full
-/// snapshot slot
-pub fn get_highest_incremental_snapshot_archive_slot(
-    incremental_snapshot_archives_dir: impl AsRef<Path>,
-    full_snapshot_slot: Slot,
-) -> Option<Slot> {
-    get_highest_incremental_snapshot_archive_info(
-        incremental_snapshot_archives_dir,
-        full_snapshot_slot,
-    )
-    .map(|incremental_snapshot_archive_info| incremental_snapshot_archive_info.slot())
-}
-
-/// Get the path (and metadata) for the full snapshot archive with the highest slot in a directory
-pub fn get_highest_full_snapshot_archive_info(
-    full_snapshot_archives_dir: impl AsRef<Path>,
-) -> Option<FullSnapshotArchiveInfo> {
-    let mut full_snapshot_archives = get_full_snapshot_archives(full_snapshot_archives_dir);
-    full_snapshot_archives.sort_unstable();
-    full_snapshot_archives.into_iter().next_back()
-}
-
-/// Get the path for the incremental snapshot archive with the highest slot, for a given full
-/// snapshot slot, in a directory
-pub fn get_highest_incremental_snapshot_archive_info(
-    incremental_snapshot_archives_dir: impl AsRef<Path>,
-    full_snapshot_slot: Slot,
-) -> Option<IncrementalSnapshotArchiveInfo> {
-    // Since we want to filter down to only the incremental snapshot archives that have the same
-    // full snapshot slot as the value passed in, perform the filtering before sorting to avoid
-    // doing unnecessary work.
-    let mut incremental_snapshot_archives =
-        get_incremental_snapshot_archives(incremental_snapshot_archives_dir)
-            .into_iter()
-            .filter(|incremental_snapshot_archive_info| {
-                incremental_snapshot_archive_info.base_slot() == full_snapshot_slot
-            })
-            .collect::<Vec<_>>();
-    incremental_snapshot_archives.sort_unstable();
-    incremental_snapshot_archives.into_iter().next_back()
-}
-
 pub fn purge_old_snapshot_archives(
     full_snapshot_archives_dir: impl AsRef<Path>,
     incremental_snapshot_archives_dir: impl AsRef<Path>,
@@ -1913,7 +1814,8 @@ pub fn purge_old_snapshot_archives(
         maximum_full_snapshot_archives_to_retain
     );
 
-    let mut full_snapshot_archives = get_full_snapshot_archives(&full_snapshot_archives_dir);
+    let mut full_snapshot_archives =
+        snapshot_paths::get_full_snapshot_archives(&full_snapshot_archives_dir);
     full_snapshot_archives.sort_unstable();
     full_snapshot_archives.reverse();
 
@@ -2153,9 +2055,15 @@ pub fn create_tmp_accounts_dir_for_tests() -> (TempDir, PathBuf) {
 mod tests {
     use {
         super::*,
-        agave_snapshots::snapshot_config::{
-            DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
-            DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
+        agave_snapshots::{
+            paths::{
+                get_full_snapshot_archives, get_highest_full_snapshot_archive_slot,
+                get_highest_incremental_snapshot_archive_slot,
+            },
+            snapshot_config::{
+                DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
+                DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
+            },
         },
         assert_matches::assert_matches,
         bincode::{deserialize_from, serialize_into},

+ 1 - 0
snapshots/src/lib.rs

@@ -12,6 +12,7 @@ mod archive_format;
 pub mod error;
 pub mod hardened_unpack;
 pub mod paths;
+pub mod snapshot_archive_info;
 pub mod snapshot_config;
 pub mod snapshot_hash;
 mod snapshot_interval;

+ 109 - 1
snapshots/src/paths.rs

@@ -1,9 +1,18 @@
 use {
-    crate::{error::SnapshotError, snapshot_hash::SnapshotHash, ArchiveFormat, Result},
+    crate::{
+        error::SnapshotError,
+        snapshot_archive_info::{
+            FullSnapshotArchiveInfo, IncrementalSnapshotArchiveInfo, SnapshotArchiveInfoGetter as _,
+        },
+        snapshot_hash::SnapshotHash,
+        ArchiveFormat, Result,
+    },
+    log::*,
     regex::Regex,
     solana_clock::Slot,
     solana_hash::Hash,
     std::{
+        fs,
         path::{Path, PathBuf},
         sync::LazyLock,
     },
@@ -156,6 +165,105 @@ pub fn get_bank_snapshot_dir(bank_snapshots_dir: impl AsRef<Path>, slot: Slot) -
         .join(get_snapshot_file_name(slot))
 }
 
+/// Walk down the snapshot archive to collect snapshot archive file info
+fn get_snapshot_archives<T, F>(snapshot_archives_dir: &Path, cb: F) -> Vec<T>
+where
+    F: Fn(PathBuf) -> Result<T>,
+{
+    let walk_dir = |dir: &Path| -> Vec<T> {
+        let entry_iter = fs::read_dir(dir);
+        match entry_iter {
+            Err(err) => {
+                info!(
+                    "Unable to read snapshot archives directory '{}': {err}",
+                    dir.display(),
+                );
+                vec![]
+            }
+            Ok(entries) => entries
+                .filter_map(|entry| entry.map_or(None, |entry| cb(entry.path()).ok()))
+                .collect(),
+        }
+    };
+
+    let mut ret = walk_dir(snapshot_archives_dir);
+    let remote_dir = build_snapshot_archives_remote_dir(snapshot_archives_dir);
+    if remote_dir.exists() {
+        ret.append(&mut walk_dir(remote_dir.as_ref()));
+    }
+    ret
+}
+
+/// Get a list of the full snapshot archives from a directory
+pub fn get_full_snapshot_archives(
+    full_snapshot_archives_dir: impl AsRef<Path>,
+) -> Vec<FullSnapshotArchiveInfo> {
+    get_snapshot_archives(
+        full_snapshot_archives_dir.as_ref(),
+        FullSnapshotArchiveInfo::new_from_path,
+    )
+}
+
+/// Get a list of the incremental snapshot archives from a directory
+pub fn get_incremental_snapshot_archives(
+    incremental_snapshot_archives_dir: impl AsRef<Path>,
+) -> Vec<IncrementalSnapshotArchiveInfo> {
+    get_snapshot_archives(
+        incremental_snapshot_archives_dir.as_ref(),
+        IncrementalSnapshotArchiveInfo::new_from_path,
+    )
+}
+
+/// Get the highest slot of the full snapshot archives in a directory
+pub fn get_highest_full_snapshot_archive_slot(
+    full_snapshot_archives_dir: impl AsRef<Path>,
+) -> Option<Slot> {
+    get_highest_full_snapshot_archive_info(full_snapshot_archives_dir)
+        .map(|full_snapshot_archive_info| full_snapshot_archive_info.slot())
+}
+
+/// Get the highest slot of the incremental snapshot archives in a directory, for a given full
+/// snapshot slot
+pub fn get_highest_incremental_snapshot_archive_slot(
+    incremental_snapshot_archives_dir: impl AsRef<Path>,
+    full_snapshot_slot: Slot,
+) -> Option<Slot> {
+    get_highest_incremental_snapshot_archive_info(
+        incremental_snapshot_archives_dir,
+        full_snapshot_slot,
+    )
+    .map(|incremental_snapshot_archive_info| incremental_snapshot_archive_info.slot())
+}
+
+/// Get the path (and metadata) for the full snapshot archive with the highest slot in a directory
+pub fn get_highest_full_snapshot_archive_info(
+    full_snapshot_archives_dir: impl AsRef<Path>,
+) -> Option<FullSnapshotArchiveInfo> {
+    let mut full_snapshot_archives = get_full_snapshot_archives(full_snapshot_archives_dir);
+    full_snapshot_archives.sort_unstable();
+    full_snapshot_archives.into_iter().next_back()
+}
+
+/// Get the path for the incremental snapshot archive with the highest slot, for a given full
+/// snapshot slot, in a directory
+pub fn get_highest_incremental_snapshot_archive_info(
+    incremental_snapshot_archives_dir: impl AsRef<Path>,
+    full_snapshot_slot: Slot,
+) -> Option<IncrementalSnapshotArchiveInfo> {
+    // Since we want to filter down to only the incremental snapshot archives that have the same
+    // full snapshot slot as the value passed in, perform the filtering before sorting to avoid
+    // doing unnecessary work.
+    let mut incremental_snapshot_archives =
+        get_incremental_snapshot_archives(incremental_snapshot_archives_dir)
+            .into_iter()
+            .filter(|incremental_snapshot_archive_info| {
+                incremental_snapshot_archive_info.base_slot() == full_snapshot_slot
+            })
+            .collect::<Vec<_>>();
+    incremental_snapshot_archives.sort_unstable();
+    incremental_snapshot_archives.into_iter().next_back()
+}
+
 #[cfg(test)]
 mod tests {
     use {super::*, crate::ZstdConfig};

+ 3 - 5
runtime/src/snapshot_archive_info.rs → snapshots/src/snapshot_archive_info.rs

@@ -1,9 +1,7 @@
 //! Information about snapshot archives
 
 use {
-    agave_snapshots::{
-        paths as snapshot_paths, snapshot_hash::SnapshotHash, ArchiveFormat, Result,
-    },
+    crate::{paths as snapshot_paths, snapshot_hash::SnapshotHash, ArchiveFormat, Result},
     solana_clock::Slot,
     std::{cmp::Ordering, path::PathBuf},
 };
@@ -71,7 +69,7 @@ impl FullSnapshotArchiveInfo {
         }))
     }
 
-    pub(crate) fn new(snapshot_archive_info: SnapshotArchiveInfo) -> Self {
+    pub fn new(snapshot_archive_info: SnapshotArchiveInfo) -> Self {
         Self(snapshot_archive_info)
     }
 }
@@ -125,7 +123,7 @@ impl IncrementalSnapshotArchiveInfo {
         ))
     }
 
-    pub(crate) fn new(base_slot: Slot, snapshot_archive_info: SnapshotArchiveInfo) -> Self {
+    pub fn new(base_slot: Slot, snapshot_archive_info: SnapshotArchiveInfo) -> Self {
         Self {
             base_slot,
             inner: snapshot_archive_info,

+ 8 - 8
validator/src/bootstrap.rs

@@ -1,4 +1,7 @@
 use {
+    agave_snapshots::{
+        paths as snapshot_paths, snapshot_archive_info::SnapshotArchiveInfoGetter as _,
+    },
     itertools::Itertools,
     log::*,
     rand::{seq::SliceRandom, thread_rng, Rng},
@@ -21,10 +24,7 @@ use {
     solana_metrics::datapoint_info,
     solana_pubkey::Pubkey,
     solana_rpc_client::rpc_client::RpcClient,
-    solana_runtime::{
-        snapshot_archive_info::SnapshotArchiveInfoGetter, snapshot_package::SnapshotKind,
-        snapshot_utils,
-    },
+    solana_runtime::snapshot_package::SnapshotKind,
     solana_signer::Signer,
     solana_streamer::socket::SocketAddrSpace,
     solana_vote_program::vote_state::VoteStateV4,
@@ -788,10 +788,10 @@ fn get_highest_local_snapshot_hash(
     incremental_snapshot_archives_dir: impl AsRef<Path>,
     incremental_snapshot_fetch: bool,
 ) -> Option<(Slot, Hash)> {
-    snapshot_utils::get_highest_full_snapshot_archive_info(full_snapshot_archives_dir)
+    snapshot_paths::get_highest_full_snapshot_archive_info(full_snapshot_archives_dir)
         .and_then(|full_snapshot_info| {
             if incremental_snapshot_fetch {
-                snapshot_utils::get_highest_incremental_snapshot_archive_info(
+                snapshot_paths::get_highest_incremental_snapshot_archive_info(
                     incremental_snapshot_archives_dir,
                     full_snapshot_info.slot(),
                 )
@@ -1131,7 +1131,7 @@ fn download_snapshots(
     }
 
     // Check and see if we've already got the full snapshot; if not, download it
-    if snapshot_utils::get_full_snapshot_archives(full_snapshot_archives_dir)
+    if snapshot_paths::get_full_snapshot_archives(full_snapshot_archives_dir)
         .into_iter()
         .any(|snapshot_archive| {
             snapshot_archive.slot() == full_snapshot_hash.0
@@ -1160,7 +1160,7 @@ fn download_snapshots(
     if bootstrap_config.incremental_snapshot_fetch {
         // Check and see if we've already got the incremental snapshot; if not, download it
         if let Some(incremental_snapshot_hash) = incremental_snapshot_hash {
-            if snapshot_utils::get_incremental_snapshot_archives(incremental_snapshot_archives_dir)
+            if snapshot_paths::get_incremental_snapshot_archives(incremental_snapshot_archives_dir)
                 .into_iter()
                 .any(|snapshot_archive| {
                     snapshot_archive.slot() == incremental_snapshot_hash.0

+ 7 - 5
wen-restart/src/wen_restart.rs

@@ -14,6 +14,12 @@ use {
             LastVotedForkSlotsRecord, State as RestartState, WenRestartProgress,
         },
     },
+    agave_snapshots::{
+        paths::{
+            get_highest_full_snapshot_archive_slot, get_highest_incremental_snapshot_archive_slot,
+        },
+        snapshot_archive_info::SnapshotArchiveInfoGetter,
+    },
     anyhow::Result,
     log::*,
     prost::Message,
@@ -35,15 +41,11 @@ use {
         accounts_background_service::AbsStatus,
         bank::Bank,
         bank_forks::BankForks,
-        snapshot_archive_info::SnapshotArchiveInfoGetter,
         snapshot_bank_utils::{
             bank_to_full_snapshot_archive, bank_to_incremental_snapshot_archive,
         },
         snapshot_controller::SnapshotController,
-        snapshot_utils::{
-            get_highest_full_snapshot_archive_slot, get_highest_incremental_snapshot_archive_slot,
-            purge_all_bank_snapshots,
-        },
+        snapshot_utils::purge_all_bank_snapshots,
     },
     solana_shred_version::compute_shred_version,
     solana_svm_timings::ExecuteTimings,