Rename AccountsPacakge to SnapshotPackage and AccountsPackagePre to AccountsPackage (#19231)
Renaming these types to better communicate their usages, which will further diverge as incremental snapshot support is added. With the new names, AccountsPacakge now refers to the type between AccountsBackgroundProcess and AccountsHashVerifier, and SnapshotPackage refers to the type between AccountsHashVerifier and SnapshotPackagerService.
This commit is contained in:
@ -11,7 +11,8 @@ use solana_runtime::{
|
||||
accounts_db,
|
||||
snapshot_archive_info::SnapshotArchiveInfoGetter,
|
||||
snapshot_config::SnapshotConfig,
|
||||
snapshot_package::{AccountsPackage, AccountsPackagePre, AccountsPackageReceiver},
|
||||
snapshot_package::{AccountsPackage, AccountsPackageReceiver, SnapshotPackage},
|
||||
snapshot_utils,
|
||||
};
|
||||
use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
@ -61,7 +62,7 @@ impl AccountsHashVerifier {
|
||||
Some(accounts_db::make_min_priority_thread_pool());
|
||||
}
|
||||
|
||||
Self::process_accounts_package_pre(
|
||||
Self::process_accounts_package(
|
||||
accounts_package,
|
||||
&cluster_info,
|
||||
trusted_validators.as_ref(),
|
||||
@ -86,8 +87,8 @@ impl AccountsHashVerifier {
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn process_accounts_package_pre(
|
||||
accounts_package: AccountsPackagePre,
|
||||
fn process_accounts_package(
|
||||
accounts_package: AccountsPackage,
|
||||
cluster_info: &ClusterInfo,
|
||||
trusted_validators: Option<&HashSet<Pubkey>>,
|
||||
halt_on_trusted_validator_accounts_hash_mismatch: bool,
|
||||
@ -98,13 +99,10 @@ impl AccountsHashVerifier {
|
||||
snapshot_config: Option<&SnapshotConfig>,
|
||||
thread_pool: Option<&ThreadPool>,
|
||||
) {
|
||||
let accounts_package = solana_runtime::snapshot_utils::process_accounts_package_pre(
|
||||
accounts_package,
|
||||
thread_pool,
|
||||
None,
|
||||
);
|
||||
Self::process_accounts_package(
|
||||
accounts_package,
|
||||
let snapshot_package =
|
||||
snapshot_utils::process_accounts_package(accounts_package, thread_pool, None);
|
||||
Self::process_snapshot_package(
|
||||
snapshot_package,
|
||||
cluster_info,
|
||||
trusted_validators,
|
||||
halt_on_trusted_validator_accounts_hash_mismatch,
|
||||
@ -116,8 +114,8 @@ impl AccountsHashVerifier {
|
||||
);
|
||||
}
|
||||
|
||||
fn process_accounts_package(
|
||||
accounts_package: AccountsPackage,
|
||||
fn process_snapshot_package(
|
||||
snapshot_package: SnapshotPackage,
|
||||
cluster_info: &ClusterInfo,
|
||||
trusted_validators: Option<&HashSet<Pubkey>>,
|
||||
halt_on_trusted_validator_accounts_hash_mismatch: bool,
|
||||
@ -127,19 +125,19 @@ impl AccountsHashVerifier {
|
||||
fault_injection_rate_slots: u64,
|
||||
snapshot_config: Option<&SnapshotConfig>,
|
||||
) {
|
||||
let hash = *accounts_package.hash();
|
||||
let hash = *snapshot_package.hash();
|
||||
if fault_injection_rate_slots != 0
|
||||
&& accounts_package.slot() % fault_injection_rate_slots == 0
|
||||
&& snapshot_package.slot() % fault_injection_rate_slots == 0
|
||||
{
|
||||
// For testing, publish an invalid hash to gossip.
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_sdk::hash::extend_and_hash;
|
||||
warn!("inserting fault at slot: {}", accounts_package.slot());
|
||||
warn!("inserting fault at slot: {}", snapshot_package.slot());
|
||||
let rand = thread_rng().gen_range(0, 10);
|
||||
let hash = extend_and_hash(&hash, &[rand]);
|
||||
hashes.push((accounts_package.slot(), hash));
|
||||
hashes.push((snapshot_package.slot(), hash));
|
||||
} else {
|
||||
hashes.push((accounts_package.slot(), hash));
|
||||
hashes.push((snapshot_package.slot(), hash));
|
||||
}
|
||||
|
||||
while hashes.len() > MAX_SNAPSHOT_HASHES {
|
||||
@ -157,11 +155,11 @@ impl AccountsHashVerifier {
|
||||
}
|
||||
|
||||
if let Some(snapshot_config) = snapshot_config {
|
||||
if accounts_package.block_height % snapshot_config.full_snapshot_archive_interval_slots
|
||||
if snapshot_package.block_height % snapshot_config.full_snapshot_archive_interval_slots
|
||||
== 0
|
||||
{
|
||||
if let Some(pending_snapshot_package) = pending_snapshot_package {
|
||||
*pending_snapshot_package.lock().unwrap() = Some(accounts_package);
|
||||
*pending_snapshot_package.lock().unwrap() = Some(snapshot_package);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,7 +304,7 @@ mod tests {
|
||||
let hash = hash(&[i as u8]);
|
||||
let archive_format = ArchiveFormat::TarBzip2;
|
||||
let snapshot_version = SnapshotVersion::default();
|
||||
let accounts_package = AccountsPackage::new(
|
||||
let snapshot_package = SnapshotPackage::new(
|
||||
slot,
|
||||
block_height,
|
||||
slot_deltas,
|
||||
@ -318,8 +316,8 @@ mod tests {
|
||||
snapshot_version,
|
||||
);
|
||||
|
||||
AccountsHashVerifier::process_accounts_package(
|
||||
accounts_package,
|
||||
AccountsHashVerifier::process_snapshot_package(
|
||||
snapshot_package,
|
||||
&cluster_info,
|
||||
Some(&trusted_validators),
|
||||
false,
|
||||
|
Reference in New Issue
Block a user