Split snapshot_utils.rs into snapshot_bank_utils.rs (#32612)
This commit is contained in:
parent
36b37221f2
commit
aba637d5d9
|
@ -591,7 +591,7 @@ mod tests {
|
|||
rand::seq::SliceRandom,
|
||||
solana_gossip::contact_info::ContactInfo,
|
||||
solana_runtime::{
|
||||
snapshot_package::SnapshotType, snapshot_utils::DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
|
||||
snapshot_bank_utils::DISABLED_SNAPSHOT_ARCHIVE_INTERVAL, snapshot_package::SnapshotType,
|
||||
},
|
||||
solana_sdk::{
|
||||
signature::{Keypair, Signer},
|
||||
|
|
|
@ -204,6 +204,7 @@ mod tests {
|
|||
rand::seq::SliceRandom,
|
||||
solana_runtime::{
|
||||
snapshot_archive_info::SnapshotArchiveInfo,
|
||||
snapshot_bank_utils,
|
||||
snapshot_hash::SnapshotHash,
|
||||
snapshot_package::{SnapshotPackage, SnapshotType},
|
||||
snapshot_utils::{self, ArchiveFormat, SnapshotVersion},
|
||||
|
@ -253,7 +254,7 @@ mod tests {
|
|||
let num_snapshots = 1;
|
||||
|
||||
let genesis_config = GenesisConfig::default();
|
||||
let bank = snapshot_utils::create_snapshot_dirs_for_tests(
|
||||
let bank = snapshot_bank_utils::create_snapshot_dirs_for_tests(
|
||||
&genesis_config,
|
||||
&bank_snapshots_dir,
|
||||
num_snapshots,
|
||||
|
@ -265,7 +266,7 @@ mod tests {
|
|||
let snapshot_storages = bank.get_snapshot_storages(None);
|
||||
let archive_format = ArchiveFormat::TarBzip2;
|
||||
|
||||
let full_archive = snapshot_utils::package_and_archive_full_snapshot(
|
||||
let full_archive = snapshot_bank_utils::package_and_archive_full_snapshot(
|
||||
&bank,
|
||||
&bank_snapshot_info,
|
||||
full_snapshot_archives_dir,
|
||||
|
|
|
@ -94,11 +94,11 @@ use {
|
|||
prioritization_fee_cache::PrioritizationFeeCache,
|
||||
runtime_config::RuntimeConfig,
|
||||
snapshot_archive_info::SnapshotArchiveInfoGetter,
|
||||
snapshot_bank_utils::{self, DISABLED_SNAPSHOT_ARCHIVE_INTERVAL},
|
||||
snapshot_config::SnapshotConfig,
|
||||
snapshot_hash::StartingSnapshotHashes,
|
||||
snapshot_utils::{
|
||||
self, clean_orphaned_account_snapshot_dirs, move_and_async_delete_path_contents,
|
||||
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
|
||||
},
|
||||
},
|
||||
solana_sdk::{
|
||||
|
@ -1921,7 +1921,7 @@ fn maybe_warp_slot(
|
|||
);
|
||||
leader_schedule_cache.set_root(&bank_forks.root_bank());
|
||||
|
||||
let full_snapshot_archive_info = match snapshot_utils::bank_to_full_snapshot_archive(
|
||||
let full_snapshot_archive_info = match snapshot_bank_utils::bank_to_full_snapshot_archive(
|
||||
ledger_path,
|
||||
&bank_forks.root_bank(),
|
||||
None,
|
||||
|
@ -2582,24 +2582,24 @@ mod tests {
|
|||
));
|
||||
|
||||
let default_accounts_hash_interval =
|
||||
snapshot_utils::DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS;
|
||||
snapshot_bank_utils::DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS;
|
||||
assert!(is_snapshot_config_valid(
|
||||
&new_snapshot_config(
|
||||
snapshot_utils::DEFAULT_FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
snapshot_utils::DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS
|
||||
snapshot_bank_utils::DEFAULT_FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
snapshot_bank_utils::DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS
|
||||
),
|
||||
default_accounts_hash_interval,
|
||||
));
|
||||
assert!(is_snapshot_config_valid(
|
||||
&new_snapshot_config(
|
||||
snapshot_utils::DEFAULT_FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
snapshot_bank_utils::DEFAULT_FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL
|
||||
),
|
||||
default_accounts_hash_interval
|
||||
));
|
||||
assert!(is_snapshot_config_valid(
|
||||
&new_snapshot_config(
|
||||
snapshot_utils::DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
snapshot_bank_utils::DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL
|
||||
),
|
||||
default_accounts_hash_interval
|
||||
|
|
|
@ -22,6 +22,7 @@ use {
|
|||
genesis_utils::{self, GenesisConfigInfo},
|
||||
runtime_config::RuntimeConfig,
|
||||
snapshot_archive_info::SnapshotArchiveInfoGetter,
|
||||
snapshot_bank_utils,
|
||||
snapshot_config::SnapshotConfig,
|
||||
snapshot_utils,
|
||||
},
|
||||
|
@ -439,7 +440,7 @@ fn test_snapshots_have_expected_epoch_accounts_hash() {
|
|||
};
|
||||
|
||||
let (_tmp_dir, accounts_dir) = create_tmp_accounts_dir_for_tests();
|
||||
let deserialized_bank = snapshot_utils::bank_from_snapshot_archives(
|
||||
let deserialized_bank = snapshot_bank_utils::bank_from_snapshot_archives(
|
||||
&[accounts_dir],
|
||||
&snapshot_config.bank_snapshots_dir,
|
||||
&full_snapshot_archive_info,
|
||||
|
|
|
@ -25,13 +25,13 @@ use {
|
|||
genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo},
|
||||
runtime_config::RuntimeConfig,
|
||||
snapshot_archive_info::FullSnapshotArchiveInfo,
|
||||
snapshot_bank_utils::{self, DISABLED_SNAPSHOT_ARCHIVE_INTERVAL},
|
||||
snapshot_config::SnapshotConfig,
|
||||
snapshot_hash::SnapshotHash,
|
||||
snapshot_package::{AccountsPackage, AccountsPackageType, SnapshotPackage, SnapshotType},
|
||||
snapshot_utils::{
|
||||
self,
|
||||
SnapshotVersion::{self, V1_2_0},
|
||||
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
|
||||
},
|
||||
status_cache::MAX_CACHE_ENTRIES,
|
||||
},
|
||||
|
@ -154,7 +154,7 @@ fn restore_from_snapshot(
|
|||
let full_snapshot_archive_info =
|
||||
FullSnapshotArchiveInfo::new_from_path(full_snapshot_archive_path).unwrap();
|
||||
|
||||
let (deserialized_bank, _timing) = snapshot_utils::bank_from_snapshot_archives(
|
||||
let (deserialized_bank, _timing) = snapshot_bank_utils::bank_from_snapshot_archives(
|
||||
account_paths,
|
||||
&snapshot_config.bank_snapshots_dir,
|
||||
&full_snapshot_archive_info,
|
||||
|
@ -347,7 +347,7 @@ fn test_concurrent_snapshot_packaging(
|
|||
let bank0 = bank_forks.get(0).unwrap();
|
||||
let storages = bank0.get_snapshot_storages(None);
|
||||
let slot_deltas = bank0.status_cache.read().unwrap().root_slot_deltas();
|
||||
snapshot_utils::add_bank_snapshot(
|
||||
snapshot_bank_utils::add_bank_snapshot(
|
||||
bank_snapshots_dir,
|
||||
&bank0,
|
||||
&storages,
|
||||
|
@ -399,7 +399,7 @@ fn test_concurrent_snapshot_packaging(
|
|||
|
||||
let snapshot_storages = bank.get_snapshot_storages(None);
|
||||
let slot_deltas = bank.status_cache.read().unwrap().root_slot_deltas();
|
||||
let bank_snapshot_info = snapshot_utils::add_bank_snapshot(
|
||||
let bank_snapshot_info = snapshot_bank_utils::add_bank_snapshot(
|
||||
bank_snapshots_dir,
|
||||
&bank,
|
||||
&snapshot_storages,
|
||||
|
@ -813,7 +813,7 @@ fn make_full_snapshot_archive(
|
|||
"did not find bank snapshot with this path",
|
||||
)
|
||||
})?;
|
||||
snapshot_utils::package_and_archive_full_snapshot(
|
||||
snapshot_bank_utils::package_and_archive_full_snapshot(
|
||||
bank,
|
||||
&bank_snapshot_info,
|
||||
&snapshot_config.full_snapshot_archives_dir,
|
||||
|
@ -851,7 +851,7 @@ fn make_incremental_snapshot_archive(
|
|||
)
|
||||
})?;
|
||||
let storages = bank.get_snapshot_storages(Some(incremental_snapshot_base_slot));
|
||||
snapshot_utils::package_and_archive_incremental_snapshot(
|
||||
snapshot_bank_utils::package_and_archive_incremental_snapshot(
|
||||
bank,
|
||||
incremental_snapshot_base_slot,
|
||||
&bank_snapshot_info,
|
||||
|
@ -873,7 +873,7 @@ fn restore_from_snapshots_and_check_banks_are_equal(
|
|||
accounts_dir: PathBuf,
|
||||
genesis_config: &GenesisConfig,
|
||||
) -> snapshot_utils::Result<()> {
|
||||
let (deserialized_bank, ..) = snapshot_utils::bank_from_latest_snapshot_archives(
|
||||
let (deserialized_bank, ..) = snapshot_bank_utils::bank_from_latest_snapshot_archives(
|
||||
&snapshot_config.bank_snapshots_dir,
|
||||
&snapshot_config.full_snapshot_archives_dir,
|
||||
&snapshot_config.incremental_snapshot_archives_dir,
|
||||
|
@ -1088,7 +1088,7 @@ fn test_snapshots_with_background_services(
|
|||
|
||||
// Load the snapshot and ensure it matches what's in BankForks
|
||||
let (_tmp_dir, temporary_accounts_dir) = create_tmp_accounts_dir_for_tests();
|
||||
let (deserialized_bank, ..) = snapshot_utils::bank_from_latest_snapshot_archives(
|
||||
let (deserialized_bank, ..) = snapshot_bank_utils::bank_from_latest_snapshot_archives(
|
||||
&snapshot_test_config.snapshot_config.bank_snapshots_dir,
|
||||
&snapshot_test_config
|
||||
.snapshot_config
|
||||
|
|
|
@ -54,9 +54,10 @@ use {
|
|||
hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
||||
runtime_config::RuntimeConfig,
|
||||
snapshot_archive_info::SnapshotArchiveInfoGetter,
|
||||
snapshot_bank_utils,
|
||||
snapshot_minimizer::SnapshotMinimizer,
|
||||
snapshot_utils::{
|
||||
self, ArchiveFormat, SnapshotVersion, DEFAULT_ARCHIVE_COMPRESSION,
|
||||
ArchiveFormat, SnapshotVersion, DEFAULT_ARCHIVE_COMPRESSION,
|
||||
SUPPORTED_ARCHIVE_COMPRESSION,
|
||||
},
|
||||
},
|
||||
|
@ -3130,7 +3131,7 @@ fn main() {
|
|||
}
|
||||
|
||||
let incremental_snapshot_archive_info =
|
||||
snapshot_utils::bank_to_incremental_snapshot_archive(
|
||||
snapshot_bank_utils::bank_to_incremental_snapshot_archive(
|
||||
ledger_path,
|
||||
&bank,
|
||||
full_snapshot_slot,
|
||||
|
@ -3155,7 +3156,7 @@ fn main() {
|
|||
);
|
||||
} else {
|
||||
let full_snapshot_archive_info =
|
||||
snapshot_utils::bank_to_full_snapshot_archive(
|
||||
snapshot_bank_utils::bank_to_full_snapshot_archive(
|
||||
ledger_path,
|
||||
&bank,
|
||||
Some(snapshot_version),
|
||||
|
|
|
@ -17,6 +17,7 @@ use {
|
|||
snapshot_archive_info::{
|
||||
FullSnapshotArchiveInfo, IncrementalSnapshotArchiveInfo, SnapshotArchiveInfoGetter,
|
||||
},
|
||||
snapshot_bank_utils,
|
||||
snapshot_config::SnapshotConfig,
|
||||
snapshot_hash::{FullSnapshotHash, IncrementalSnapshotHash, StartingSnapshotHashes},
|
||||
snapshot_utils,
|
||||
|
@ -249,7 +250,7 @@ fn bank_forks_from_snapshot(
|
|||
// the archives, causing the out-of-memory problem. So, purge the snapshot dirs upfront before loading from the archive.
|
||||
snapshot_utils::purge_old_bank_snapshots(&snapshot_config.bank_snapshots_dir, 0, None);
|
||||
|
||||
let (bank, _) = snapshot_utils::bank_from_snapshot_archives(
|
||||
let (bank, _) = snapshot_bank_utils::bank_from_snapshot_archives(
|
||||
&account_paths,
|
||||
&snapshot_config.bank_snapshots_dir,
|
||||
&full_snapshot_archive_info,
|
||||
|
@ -310,7 +311,7 @@ fn bank_forks_from_snapshot(
|
|||
);
|
||||
}
|
||||
|
||||
let (bank, _) = snapshot_utils::bank_from_snapshot_dir(
|
||||
let (bank, _) = snapshot_bank_utils::bank_from_snapshot_dir(
|
||||
&account_paths,
|
||||
&bank_snapshot,
|
||||
genesis_config,
|
||||
|
|
|
@ -20,10 +20,8 @@ use {
|
|||
},
|
||||
solana_rpc_client::rpc_client::RpcClient,
|
||||
solana_runtime::{
|
||||
snapshot_config::SnapshotConfig,
|
||||
snapshot_utils::{
|
||||
create_accounts_run_and_snapshot_dirs, DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
|
||||
},
|
||||
snapshot_bank_utils::DISABLED_SNAPSHOT_ARCHIVE_INTERVAL, snapshot_config::SnapshotConfig,
|
||||
snapshot_utils::create_accounts_run_and_snapshot_dirs,
|
||||
},
|
||||
solana_sdk::{
|
||||
account::AccountSharedData,
|
||||
|
|
|
@ -45,6 +45,7 @@ use {
|
|||
commitment::VOTE_THRESHOLD_SIZE,
|
||||
hardened_unpack::open_genesis_config,
|
||||
snapshot_archive_info::SnapshotArchiveInfoGetter,
|
||||
snapshot_bank_utils,
|
||||
snapshot_config::SnapshotConfig,
|
||||
snapshot_package::SnapshotType,
|
||||
snapshot_utils::{self, create_accounts_run_and_snapshot_dirs},
|
||||
|
@ -2191,7 +2192,7 @@ fn create_snapshot_to_hard_fork(
|
|||
)
|
||||
.unwrap();
|
||||
let bank = bank_forks.read().unwrap().get(snapshot_slot).unwrap();
|
||||
let full_snapshot_archive_info = snapshot_utils::bank_to_full_snapshot_archive(
|
||||
let full_snapshot_archive_info = snapshot_bank_utils::bank_to_full_snapshot_archive(
|
||||
ledger_path,
|
||||
&bank,
|
||||
Some(snapshot_config.snapshot_version),
|
||||
|
|
|
@ -9,6 +9,7 @@ use {
|
|||
accounts_hash::CalcAccountsHashConfig,
|
||||
bank::{Bank, BankSlotDelta, DropCallback},
|
||||
bank_forks::BankForks,
|
||||
snapshot_bank_utils,
|
||||
snapshot_config::SnapshotConfig,
|
||||
snapshot_package::{self, AccountsPackage, AccountsPackageType, SnapshotType},
|
||||
snapshot_utils::{self, SnapshotError},
|
||||
|
@ -383,10 +384,10 @@ impl SnapshotRequestHandler {
|
|||
|
||||
// Snapshot the bank and send over an accounts package
|
||||
let mut snapshot_time = Measure::start("snapshot_time");
|
||||
let snapshot_storages = snapshot_utils::get_snapshot_storages(&snapshot_root_bank);
|
||||
let snapshot_storages = snapshot_bank_utils::get_snapshot_storages(&snapshot_root_bank);
|
||||
let accounts_package = match request_type {
|
||||
SnapshotRequestType::Snapshot => {
|
||||
let bank_snapshot_info = snapshot_utils::add_bank_snapshot(
|
||||
let bank_snapshot_info = snapshot_bank_utils::add_bank_snapshot(
|
||||
&self.snapshot_config.bank_snapshots_dir,
|
||||
&snapshot_root_bank,
|
||||
&snapshot_storages,
|
||||
|
|
|
@ -18,6 +18,7 @@ mod tests {
|
|||
reserialize_bank_with_new_accounts_hash, BankIncrementalSnapshotPersistence,
|
||||
SerdeAccountsHash, SerdeIncrementalAccountsHash, SerdeStyle, SnapshotStreams,
|
||||
},
|
||||
snapshot_bank_utils,
|
||||
snapshot_utils::{
|
||||
self, create_tmp_accounts_dir_for_tests, get_storages_to_serialize, ArchiveFormat,
|
||||
StorageAndNextAppendVecId, BANK_SNAPSHOT_PRE_FILENAME_EXTENSION,
|
||||
|
@ -464,7 +465,7 @@ mod tests {
|
|||
let incremental_snapshot_archives_dir = TempDir::new().unwrap();
|
||||
|
||||
// Serialize
|
||||
let snapshot_archive_info = snapshot_utils::bank_to_full_snapshot_archive(
|
||||
let snapshot_archive_info = snapshot_bank_utils::bank_to_full_snapshot_archive(
|
||||
&bank_snapshots_dir,
|
||||
&bank,
|
||||
None,
|
||||
|
@ -477,7 +478,7 @@ mod tests {
|
|||
.unwrap();
|
||||
|
||||
// Deserialize
|
||||
let (dbank, _) = snapshot_utils::bank_from_snapshot_archives(
|
||||
let (dbank, _) = snapshot_bank_utils::bank_from_snapshot_archives(
|
||||
&[accounts_dir],
|
||||
bank_snapshots_dir.path(),
|
||||
&snapshot_archive_info,
|
||||
|
|
|
@ -61,6 +61,7 @@ pub mod secondary_index;
|
|||
pub mod serde_snapshot;
|
||||
mod shared_buffer_reader;
|
||||
pub mod snapshot_archive_info;
|
||||
pub mod snapshot_bank_utils;
|
||||
pub mod snapshot_config;
|
||||
pub mod snapshot_hash;
|
||||
pub mod snapshot_minimizer;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,8 @@
|
|||
use {
|
||||
crate::snapshot_utils::{self, ArchiveFormat, SnapshotVersion},
|
||||
crate::{
|
||||
snapshot_bank_utils,
|
||||
snapshot_utils::{self, ArchiveFormat, SnapshotVersion},
|
||||
},
|
||||
solana_sdk::clock::Slot,
|
||||
std::{num::NonZeroUsize, path::PathBuf},
|
||||
};
|
||||
|
@ -50,9 +53,9 @@ impl Default for SnapshotConfig {
|
|||
Self {
|
||||
usage: SnapshotUsage::LoadAndGenerate,
|
||||
full_snapshot_archive_interval_slots:
|
||||
snapshot_utils::DEFAULT_FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
snapshot_bank_utils::DEFAULT_FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
incremental_snapshot_archive_interval_slots:
|
||||
snapshot_utils::DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
snapshot_bank_utils::DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
full_snapshot_archives_dir: PathBuf::default(),
|
||||
incremental_snapshot_archives_dir: PathBuf::default(),
|
||||
bank_snapshots_dir: PathBuf::default(),
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -27,10 +27,12 @@ use {
|
|||
DEFAULT_ACCOUNTS_SHRINK_OPTIMIZE_TOTAL_SPACE, DEFAULT_ACCOUNTS_SHRINK_RATIO,
|
||||
},
|
||||
hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
||||
snapshot_utils::{
|
||||
SnapshotVersion, DEFAULT_ARCHIVE_COMPRESSION,
|
||||
snapshot_bank_utils::{
|
||||
DEFAULT_FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||
},
|
||||
snapshot_utils::{
|
||||
SnapshotVersion, DEFAULT_ARCHIVE_COMPRESSION,
|
||||
DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
||||
DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN, SUPPORTED_ARCHIVE_COMPRESSION,
|
||||
},
|
||||
|
|
|
@ -46,10 +46,11 @@ use {
|
|||
},
|
||||
partitioned_rewards::TestPartitionedEpochRewards,
|
||||
runtime_config::RuntimeConfig,
|
||||
snapshot_bank_utils::DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
|
||||
snapshot_config::{SnapshotConfig, SnapshotUsage},
|
||||
snapshot_utils::{
|
||||
self, create_all_accounts_run_and_snapshot_dirs, create_and_canonicalize_directories,
|
||||
ArchiveFormat, SnapshotVersion, DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
|
||||
ArchiveFormat, SnapshotVersion,
|
||||
},
|
||||
},
|
||||
solana_sdk::{
|
||||
|
|
Loading…
Reference in New Issue