Add default() to SnapshotConfig (#19776)
This commit is contained in:
@ -338,12 +338,7 @@ mod tests {
|
|||||||
let snapshot_config = SnapshotConfig {
|
let snapshot_config = SnapshotConfig {
|
||||||
full_snapshot_archive_interval_slots,
|
full_snapshot_archive_interval_slots,
|
||||||
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
||||||
snapshot_archives_dir: PathBuf::default(),
|
..SnapshotConfig::default()
|
||||||
bank_snapshots_dir: PathBuf::default(),
|
|
||||||
archive_format: ArchiveFormat::Tar,
|
|
||||||
snapshot_version: SnapshotVersion::default(),
|
|
||||||
maximum_full_snapshot_archives_to_retain: usize::MAX,
|
|
||||||
maximum_incremental_snapshot_archives_to_retain: usize::MAX,
|
|
||||||
};
|
};
|
||||||
for i in 0..MAX_SNAPSHOT_HASHES + 1 {
|
for i in 0..MAX_SNAPSHOT_HASHES + 1 {
|
||||||
let accounts_package = AccountsPackage {
|
let accounts_package = AccountsPackage {
|
||||||
|
@ -14,12 +14,7 @@ use {
|
|||||||
solana_rpc::rpc::JsonRpcConfig,
|
solana_rpc::rpc::JsonRpcConfig,
|
||||||
solana_runtime::{
|
solana_runtime::{
|
||||||
genesis_utils::create_genesis_config_with_leader_ex,
|
genesis_utils::create_genesis_config_with_leader_ex,
|
||||||
hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE, snapshot_config::SnapshotConfig,
|
||||||
snapshot_config::SnapshotConfig,
|
|
||||||
snapshot_utils::{
|
|
||||||
ArchiveFormat, SnapshotVersion, DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
account::{Account, AccountSharedData},
|
account::{Account, AccountSharedData},
|
||||||
@ -526,12 +521,7 @@ impl TestValidator {
|
|||||||
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
||||||
bank_snapshots_dir: ledger_path.join("snapshot"),
|
bank_snapshots_dir: ledger_path.join("snapshot"),
|
||||||
snapshot_archives_dir: ledger_path.to_path_buf(),
|
snapshot_archives_dir: ledger_path.to_path_buf(),
|
||||||
archive_format: ArchiveFormat::Tar,
|
..SnapshotConfig::default()
|
||||||
snapshot_version: SnapshotVersion::default(),
|
|
||||||
maximum_full_snapshot_archives_to_retain:
|
|
||||||
DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
maximum_incremental_snapshot_archives_to_retain:
|
|
||||||
DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
}),
|
}),
|
||||||
enforce_ulimit_nofile: false,
|
enforce_ulimit_nofile: false,
|
||||||
warp_slot: config.warp_slot,
|
warp_slot: config.warp_slot,
|
||||||
|
@ -69,10 +69,7 @@ mod tests {
|
|||||||
snapshot_package::{
|
snapshot_package::{
|
||||||
AccountsPackage, PendingSnapshotPackage, SnapshotPackage, SnapshotType,
|
AccountsPackage, PendingSnapshotPackage, SnapshotPackage, SnapshotType,
|
||||||
},
|
},
|
||||||
snapshot_utils::{
|
snapshot_utils::{self, ArchiveFormat, SnapshotVersion},
|
||||||
self, ArchiveFormat, SnapshotVersion, DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
},
|
|
||||||
status_cache::MAX_CACHE_ENTRIES,
|
status_cache::MAX_CACHE_ENTRIES,
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
@ -146,12 +143,8 @@ mod tests {
|
|||||||
incremental_snapshot_archive_interval_slots,
|
incremental_snapshot_archive_interval_slots,
|
||||||
snapshot_archives_dir: snapshot_archives_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(),
|
bank_snapshots_dir: bank_snapshots_dir.path().to_path_buf(),
|
||||||
archive_format: ArchiveFormat::TarBzip2,
|
|
||||||
snapshot_version,
|
snapshot_version,
|
||||||
maximum_full_snapshot_archives_to_retain:
|
..SnapshotConfig::default()
|
||||||
DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
maximum_incremental_snapshot_archives_to_retain:
|
|
||||||
DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
};
|
};
|
||||||
bank_forks.set_snapshot_config(Some(snapshot_config.clone()));
|
bank_forks.set_snapshot_config(Some(snapshot_config.clone()));
|
||||||
SnapshotTestConfig {
|
SnapshotTestConfig {
|
||||||
|
@ -35,7 +35,6 @@ use solana_runtime::{
|
|||||||
snapshot_config::SnapshotConfig,
|
snapshot_config::SnapshotConfig,
|
||||||
snapshot_utils::{
|
snapshot_utils::{
|
||||||
self, ArchiveFormat, SnapshotVersion, DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
self, ArchiveFormat, SnapshotVersion, DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
||||||
DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
@ -719,11 +718,7 @@ fn load_bank_forks(
|
|||||||
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
||||||
snapshot_archives_dir,
|
snapshot_archives_dir,
|
||||||
bank_snapshots_dir,
|
bank_snapshots_dir,
|
||||||
archive_format: ArchiveFormat::TarBzip2,
|
..SnapshotConfig::default()
|
||||||
snapshot_version: SnapshotVersion::default(),
|
|
||||||
maximum_full_snapshot_archives_to_retain: DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
maximum_incremental_snapshot_archives_to_retain:
|
|
||||||
DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
let account_paths = if let Some(account_paths) = arg_matches.value_of("account_paths") {
|
let account_paths = if let Some(account_paths) = arg_matches.value_of("account_paths") {
|
||||||
|
@ -1467,9 +1467,8 @@ pub mod tests {
|
|||||||
use matches::assert_matches;
|
use matches::assert_matches;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
use solana_entry::entry::{create_ticks, next_entry, next_entry_mut};
|
use solana_entry::entry::{create_ticks, next_entry, next_entry_mut};
|
||||||
use solana_runtime::{
|
use solana_runtime::genesis_utils::{
|
||||||
genesis_utils::{self, create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs},
|
self, create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs,
|
||||||
snapshot_utils::{ArchiveFormat, SnapshotVersion},
|
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{AccountSharedData, WritableAccount},
|
account::{AccountSharedData, WritableAccount},
|
||||||
@ -3167,13 +3166,8 @@ pub mod tests {
|
|||||||
let bank_snapshots_tempdir = TempDir::new().unwrap();
|
let bank_snapshots_tempdir = TempDir::new().unwrap();
|
||||||
let snapshot_config = SnapshotConfig {
|
let snapshot_config = SnapshotConfig {
|
||||||
full_snapshot_archive_interval_slots: FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
full_snapshot_archive_interval_slots: FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||||
incremental_snapshot_archive_interval_slots: Slot::MAX, // value does not matter
|
|
||||||
snapshot_archives_dir: PathBuf::default(), // value does not matter
|
|
||||||
bank_snapshots_dir: bank_snapshots_tempdir.path().to_path_buf(),
|
bank_snapshots_dir: bank_snapshots_tempdir.path().to_path_buf(),
|
||||||
archive_format: ArchiveFormat::TarZstd, // value does not matter
|
..SnapshotConfig::default()
|
||||||
snapshot_version: SnapshotVersion::default(), // value does not matter
|
|
||||||
maximum_full_snapshot_archives_to_retain: usize::MAX, // value does not matter
|
|
||||||
maximum_incremental_snapshot_archives_to_retain: usize::MAX, // value does not matter
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let (accounts_package_sender, accounts_package_receiver) = channel();
|
let (accounts_package_sender, accounts_package_receiver) = channel();
|
||||||
|
@ -3533,12 +3533,7 @@ fn setup_snapshot_validator_config(
|
|||||||
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
||||||
snapshot_archives_dir: snapshot_archives_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(),
|
bank_snapshots_dir: bank_snapshots_dir.path().to_path_buf(),
|
||||||
archive_format: ArchiveFormat::TarBzip2,
|
..SnapshotConfig::default()
|
||||||
snapshot_version: snapshot_utils::SnapshotVersion::default(),
|
|
||||||
maximum_full_snapshot_archives_to_retain:
|
|
||||||
snapshot_utils::DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
maximum_incremental_snapshot_archives_to_retain:
|
|
||||||
snapshot_utils::DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the account paths
|
// Create the account paths
|
||||||
|
@ -21,12 +21,9 @@ use {
|
|||||||
rpc_subscriptions::RpcSubscriptions,
|
rpc_subscriptions::RpcSubscriptions,
|
||||||
},
|
},
|
||||||
solana_runtime::{
|
solana_runtime::{
|
||||||
accounts_index::AccountSecondaryIndexes,
|
accounts_index::AccountSecondaryIndexes, bank_forks::BankForks,
|
||||||
bank_forks::BankForks,
|
commitment::BlockCommitmentCache, hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
||||||
commitment::BlockCommitmentCache,
|
snapshot_config::SnapshotConfig, snapshot_utils,
|
||||||
hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
|
||||||
snapshot_config::SnapshotConfig,
|
|
||||||
snapshot_utils::{self, ArchiveFormat},
|
|
||||||
},
|
},
|
||||||
solana_sdk::{clock::Slot, exit::Exit, genesis_config::GenesisConfig, hash::Hash},
|
solana_sdk::{clock::Slot, exit::Exit, genesis_config::GenesisConfig, hash::Hash},
|
||||||
solana_streamer::socket::SocketAddrSpace,
|
solana_streamer::socket::SocketAddrSpace,
|
||||||
@ -263,16 +260,11 @@ impl ReplicaNode {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let snapshot_config = SnapshotConfig {
|
let snapshot_config = SnapshotConfig {
|
||||||
full_snapshot_archive_interval_slots: std::u64::MAX,
|
full_snapshot_archive_interval_slots: Slot::MAX,
|
||||||
incremental_snapshot_archive_interval_slots: std::u64::MAX,
|
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
||||||
snapshot_archives_dir: replica_config.snapshot_archives_dir.clone(),
|
snapshot_archives_dir: replica_config.snapshot_archives_dir.clone(),
|
||||||
bank_snapshots_dir: replica_config.bank_snapshots_dir.clone(),
|
bank_snapshots_dir: replica_config.bank_snapshots_dir.clone(),
|
||||||
archive_format: ArchiveFormat::TarBzip2,
|
..SnapshotConfig::default()
|
||||||
snapshot_version: snapshot_utils::SnapshotVersion::default(),
|
|
||||||
maximum_full_snapshot_archives_to_retain:
|
|
||||||
snapshot_utils::DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
maximum_incremental_snapshot_archives_to_retain:
|
|
||||||
snapshot_utils::DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let bank_info =
|
let bank_info =
|
||||||
|
@ -16,10 +16,8 @@ use {
|
|||||||
},
|
},
|
||||||
solana_rpc::{rpc::JsonRpcConfig, rpc_pubsub_service::PubSubConfig},
|
solana_rpc::{rpc::JsonRpcConfig, rpc_pubsub_service::PubSubConfig},
|
||||||
solana_runtime::{
|
solana_runtime::{
|
||||||
accounts_index::AccountSecondaryIndexes,
|
accounts_index::AccountSecondaryIndexes, snapshot_archive_info::SnapshotArchiveInfoGetter,
|
||||||
snapshot_archive_info::SnapshotArchiveInfoGetter,
|
snapshot_config::SnapshotConfig, snapshot_utils,
|
||||||
snapshot_config::SnapshotConfig,
|
|
||||||
snapshot_utils::{self, ArchiveFormat},
|
|
||||||
},
|
},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
client::SyncClient,
|
client::SyncClient,
|
||||||
@ -125,12 +123,7 @@ fn setup_snapshot_validator_config(
|
|||||||
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
||||||
snapshot_archives_dir: snapshot_archives_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(),
|
bank_snapshots_dir: bank_snapshots_dir.path().to_path_buf(),
|
||||||
archive_format: ArchiveFormat::TarBzip2,
|
..SnapshotConfig::default()
|
||||||
snapshot_version: snapshot_utils::SnapshotVersion::default(),
|
|
||||||
maximum_full_snapshot_archives_to_retain:
|
|
||||||
snapshot_utils::DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
maximum_incremental_snapshot_archives_to_retain:
|
|
||||||
snapshot_utils::DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the account paths
|
// Create the account paths
|
||||||
|
@ -502,15 +502,8 @@ mod tests {
|
|||||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||||
get_tmp_ledger_path,
|
get_tmp_ledger_path,
|
||||||
},
|
},
|
||||||
solana_runtime::{
|
solana_runtime::bank::Bank,
|
||||||
bank::Bank,
|
|
||||||
snapshot_utils::{
|
|
||||||
ArchiveFormat, SnapshotVersion, DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
clock::Slot,
|
|
||||||
genesis_config::{ClusterType, DEFAULT_GENESIS_ARCHIVE},
|
genesis_config::{ClusterType, DEFAULT_GENESIS_ARCHIVE},
|
||||||
signature::Signer,
|
signature::Signer,
|
||||||
signer::keypair::Keypair,
|
signer::keypair::Keypair,
|
||||||
@ -615,18 +608,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
let rrm_with_snapshot_config = RpcRequestMiddleware::new(
|
let rrm_with_snapshot_config = RpcRequestMiddleware::new(
|
||||||
PathBuf::from("/"),
|
PathBuf::from("/"),
|
||||||
Some(SnapshotConfig {
|
Some(SnapshotConfig::default()),
|
||||||
full_snapshot_archive_interval_slots: Slot::MAX,
|
|
||||||
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
|
||||||
snapshot_archives_dir: PathBuf::from("/"),
|
|
||||||
bank_snapshots_dir: PathBuf::from("/"),
|
|
||||||
archive_format: ArchiveFormat::TarBzip2,
|
|
||||||
snapshot_version: SnapshotVersion::default(),
|
|
||||||
maximum_full_snapshot_archives_to_retain:
|
|
||||||
DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
maximum_incremental_snapshot_archives_to_retain:
|
|
||||||
DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
||||||
}),
|
|
||||||
bank_forks,
|
bank_forks,
|
||||||
RpcHealth::stub(),
|
RpcHealth::stub(),
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use crate::snapshot_utils::ArchiveFormat;
|
use crate::snapshot_utils::{self, ArchiveFormat, SnapshotVersion};
|
||||||
use crate::snapshot_utils::SnapshotVersion;
|
|
||||||
use solana_sdk::clock::Slot;
|
use solana_sdk::clock::Slot;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
@ -31,3 +30,22 @@ pub struct SnapshotConfig {
|
|||||||
/// NOTE: Incremental snapshots will only be kept for the latest full snapshot
|
/// NOTE: Incremental snapshots will only be kept for the latest full snapshot
|
||||||
pub maximum_incremental_snapshot_archives_to_retain: usize,
|
pub maximum_incremental_snapshot_archives_to_retain: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for SnapshotConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
full_snapshot_archive_interval_slots:
|
||||||
|
snapshot_utils::DEFAULT_FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||||
|
incremental_snapshot_archive_interval_slots:
|
||||||
|
snapshot_utils::DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||||
|
snapshot_archives_dir: PathBuf::default(),
|
||||||
|
bank_snapshots_dir: PathBuf::default(),
|
||||||
|
archive_format: ArchiveFormat::TarBzip2,
|
||||||
|
snapshot_version: SnapshotVersion::default(),
|
||||||
|
maximum_full_snapshot_archives_to_retain:
|
||||||
|
snapshot_utils::DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
||||||
|
maximum_incremental_snapshot_archives_to_retain:
|
||||||
|
snapshot_utils::DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user