HashCalc uses self.accounts_hash_cache_path (#23882)
This commit is contained in:
committed by
GitHub
parent
90009f330b
commit
db5d68f01f
@ -20,7 +20,6 @@ use {
|
|||||||
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey},
|
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey},
|
||||||
std::{
|
std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
path::{Path, PathBuf},
|
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
Arc,
|
Arc,
|
||||||
@ -44,7 +43,6 @@ impl AccountsHashVerifier {
|
|||||||
halt_on_known_validators_accounts_hash_mismatch: bool,
|
halt_on_known_validators_accounts_hash_mismatch: bool,
|
||||||
fault_injection_rate_slots: u64,
|
fault_injection_rate_slots: u64,
|
||||||
snapshot_config: Option<SnapshotConfig>,
|
snapshot_config: Option<SnapshotConfig>,
|
||||||
ledger_path: PathBuf,
|
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let exit = exit.clone();
|
let exit = exit.clone();
|
||||||
let cluster_info = cluster_info.clone();
|
let cluster_info = cluster_info.clone();
|
||||||
@ -69,7 +67,6 @@ impl AccountsHashVerifier {
|
|||||||
&exit,
|
&exit,
|
||||||
fault_injection_rate_slots,
|
fault_injection_rate_slots,
|
||||||
snapshot_config.as_ref(),
|
snapshot_config.as_ref(),
|
||||||
&ledger_path,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Err(RecvTimeoutError::Disconnected) => break,
|
Err(RecvTimeoutError::Disconnected) => break,
|
||||||
@ -94,9 +91,8 @@ impl AccountsHashVerifier {
|
|||||||
exit: &Arc<AtomicBool>,
|
exit: &Arc<AtomicBool>,
|
||||||
fault_injection_rate_slots: u64,
|
fault_injection_rate_slots: u64,
|
||||||
snapshot_config: Option<&SnapshotConfig>,
|
snapshot_config: Option<&SnapshotConfig>,
|
||||||
ledger_path: &Path,
|
|
||||||
) {
|
) {
|
||||||
Self::verify_accounts_package_hash(&accounts_package, ledger_path);
|
Self::verify_accounts_package_hash(&accounts_package);
|
||||||
|
|
||||||
Self::push_accounts_hashes_to_cluster(
|
Self::push_accounts_hashes_to_cluster(
|
||||||
&accounts_package,
|
&accounts_package,
|
||||||
@ -111,7 +107,7 @@ impl AccountsHashVerifier {
|
|||||||
Self::submit_for_packaging(accounts_package, pending_snapshot_package, snapshot_config);
|
Self::submit_for_packaging(accounts_package, pending_snapshot_package, snapshot_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn verify_accounts_package_hash(accounts_package: &AccountsPackage, ledger_path: &Path) {
|
fn verify_accounts_package_hash(accounts_package: &AccountsPackage) {
|
||||||
let mut measure_hash = Measure::start("hash");
|
let mut measure_hash = Measure::start("hash");
|
||||||
if let Some(expected_hash) = accounts_package.hash_for_testing {
|
if let Some(expected_hash) = accounts_package.hash_for_testing {
|
||||||
let sorted_storages = SortedStorages::new(&accounts_package.snapshot_storages);
|
let sorted_storages = SortedStorages::new(&accounts_package.snapshot_storages);
|
||||||
@ -119,7 +115,6 @@ impl AccountsHashVerifier {
|
|||||||
.accounts
|
.accounts
|
||||||
.accounts_db
|
.accounts_db
|
||||||
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
||||||
accounts_hash_cache_path: ledger_path,
|
|
||||||
storages: &sorted_storages,
|
storages: &sorted_storages,
|
||||||
use_bg_thread_pool: true,
|
use_bg_thread_pool: true,
|
||||||
stats: HashStats::default(),
|
stats: HashStats::default(),
|
||||||
@ -361,8 +356,6 @@ mod tests {
|
|||||||
accounts: Arc::clone(&accounts),
|
accounts: Arc::clone(&accounts),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ledger_path = TempDir::new().unwrap();
|
|
||||||
|
|
||||||
AccountsHashVerifier::process_accounts_package(
|
AccountsHashVerifier::process_accounts_package(
|
||||||
accounts_package,
|
accounts_package,
|
||||||
&cluster_info,
|
&cluster_info,
|
||||||
@ -373,7 +366,6 @@ mod tests {
|
|||||||
&exit,
|
&exit,
|
||||||
0,
|
0,
|
||||||
Some(&snapshot_config),
|
Some(&snapshot_config),
|
||||||
ledger_path.path(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// sleep for 1ms to create a newer timestmap for gossip entry
|
// sleep for 1ms to create a newer timestmap for gossip entry
|
||||||
|
@ -230,7 +230,6 @@ impl Tvu {
|
|||||||
tvu_config.halt_on_known_validators_accounts_hash_mismatch,
|
tvu_config.halt_on_known_validators_accounts_hash_mismatch,
|
||||||
tvu_config.accounts_hash_fault_injection_slots,
|
tvu_config.accounts_hash_fault_injection_slots,
|
||||||
snapshot_config.clone(),
|
snapshot_config.clone(),
|
||||||
blockstore.ledger_path().to_path_buf(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let (snapshot_request_sender, snapshot_request_handler) = match snapshot_config {
|
let (snapshot_request_sender, snapshot_request_handler) = match snapshot_config {
|
||||||
|
@ -931,7 +931,6 @@ mod tests {
|
|||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
let tmpdir = TempDir::new().unwrap();
|
|
||||||
let accounts_hash_verifier = AccountsHashVerifier::new(
|
let accounts_hash_verifier = AccountsHashVerifier::new(
|
||||||
accounts_package_receiver,
|
accounts_package_receiver,
|
||||||
Some(pending_snapshot_package),
|
Some(pending_snapshot_package),
|
||||||
@ -941,7 +940,6 @@ mod tests {
|
|||||||
false,
|
false,
|
||||||
0,
|
0,
|
||||||
Some(snapshot_test_config.snapshot_config.clone()),
|
Some(snapshot_test_config.snapshot_config.clone()),
|
||||||
tmpdir.path().to_path_buf(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let accounts_background_service = AccountsBackgroundService::new(
|
let accounts_background_service = AccountsBackgroundService::new(
|
||||||
|
@ -5515,7 +5515,6 @@ impl AccountsDb {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
self.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
||||||
accounts_hash_cache_path: &self.accounts_hash_cache_path,
|
|
||||||
storages: &storages,
|
storages: &storages,
|
||||||
use_bg_thread_pool: !is_startup,
|
use_bg_thread_pool: !is_startup,
|
||||||
stats: timings,
|
stats: timings,
|
||||||
@ -5729,7 +5728,7 @@ impl AccountsDb {
|
|||||||
let mut previous_pass = PreviousPass::default();
|
let mut previous_pass = PreviousPass::default();
|
||||||
let mut final_result = (Hash::default(), 0);
|
let mut final_result = (Hash::default(), 0);
|
||||||
|
|
||||||
let cache_hash_data = CacheHashData::new(&config.accounts_hash_cache_path);
|
let cache_hash_data = CacheHashData::new(&self.accounts_hash_cache_path);
|
||||||
|
|
||||||
for pass in 0..num_hash_scan_passes {
|
for pass in 0..num_hash_scan_passes {
|
||||||
let bounds = Range {
|
let bounds = Range {
|
||||||
@ -7897,7 +7896,6 @@ pub mod tests {
|
|||||||
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
||||||
let result = db
|
let result = db
|
||||||
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
||||||
accounts_hash_cache_path: TempDir::new().unwrap().path(),
|
|
||||||
storages: &get_storage_refs(&storages),
|
storages: &get_storage_refs(&storages),
|
||||||
use_bg_thread_pool: false,
|
use_bg_thread_pool: false,
|
||||||
stats: HashStats::default(),
|
stats: HashStats::default(),
|
||||||
@ -7924,7 +7922,6 @@ pub mod tests {
|
|||||||
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
||||||
let result = db
|
let result = db
|
||||||
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
||||||
accounts_hash_cache_path: TempDir::new().unwrap().path(),
|
|
||||||
storages: &get_storage_refs(&storages),
|
storages: &get_storage_refs(&storages),
|
||||||
use_bg_thread_pool: false,
|
use_bg_thread_pool: false,
|
||||||
stats: HashStats::default(),
|
stats: HashStats::default(),
|
||||||
|
@ -10,7 +10,7 @@ use {
|
|||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
},
|
},
|
||||||
std::{borrow::Borrow, convert::TryInto, path::Path, sync::Mutex},
|
std::{borrow::Borrow, convert::TryInto, sync::Mutex},
|
||||||
};
|
};
|
||||||
pub const ZERO_RAW_LAMPORTS_SENTINEL: u64 = std::u64::MAX;
|
pub const ZERO_RAW_LAMPORTS_SENTINEL: u64 = std::u64::MAX;
|
||||||
pub const MERKLE_FANOUT: usize = 16;
|
pub const MERKLE_FANOUT: usize = 16;
|
||||||
@ -24,7 +24,6 @@ pub struct PreviousPass {
|
|||||||
|
|
||||||
/// parameters to calculate accounts hash
|
/// parameters to calculate accounts hash
|
||||||
pub struct CalcAccountsHashConfig<'a> {
|
pub struct CalcAccountsHashConfig<'a> {
|
||||||
pub accounts_hash_cache_path: &'a Path,
|
|
||||||
pub storages: &'a SortedStorages<'a>,
|
pub storages: &'a SortedStorages<'a>,
|
||||||
pub use_bg_thread_pool: bool,
|
pub use_bg_thread_pool: bool,
|
||||||
pub stats: HashStats,
|
pub stats: HashStats,
|
||||||
|
Reference in New Issue
Block a user