Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions accounts-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use {
solana_epoch_schedule::EpochSchedule,
solana_measure::measure::Measure,
solana_pubkey::Pubkey,
solana_rent_collector::RentCollector,
std::{env, fs, path::PathBuf, sync::Arc},
};

Expand Down Expand Up @@ -131,7 +130,6 @@ fn main() {
&ancestors,
None,
&EpochSchedule::default(),
&RentCollector::default(),
true,
);
time_store.stop();
Expand Down
4 changes: 2 additions & 2 deletions accounts-db/benches/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use {
accounts_index::ScanConfig,
ancestors::Ancestors,
},
solana_clock::Epoch,
solana_hash::Hash,
solana_pubkey::Pubkey,
solana_rent_collector::RentCollector,
solana_sysvar::epoch_schedule::EpochSchedule,
std::{
collections::{HashMap, HashSet},
Expand Down Expand Up @@ -64,7 +64,7 @@ fn bench_accounts_hash_bank_hash(bencher: &mut Bencher) {
ancestors: &ancestors,
test_hash_calculation: false,
epoch_schedule: &EpochSchedule::default(),
rent_collector: &RentCollector::default(),
epoch: Epoch::default(),
ignore_mismatch: false,
store_detailed_debug_info: false,
use_bg_thread_pool: false,
Expand Down
16 changes: 7 additions & 9 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ use {
solana_nohash_hasher::{BuildNoHashHasher, IntMap, IntSet},
solana_pubkey::Pubkey,
solana_rayon_threadlimit::get_thread_count,
solana_rent_collector::RentCollector,
solana_transaction::sanitized::SanitizedTransaction,
std::{
borrow::Cow,
Expand Down Expand Up @@ -185,8 +184,8 @@ pub struct VerifyAccountsHashAndLamportsConfig<'a> {
pub test_hash_calculation: bool,
/// epoch_schedule
pub epoch_schedule: &'a EpochSchedule,
/// rent_collector
pub rent_collector: &'a RentCollector,
/// epoch
pub epoch: Epoch,
/// true to ignore mismatches
pub ignore_mismatch: bool,
/// true to dump debug log if mismatch happens
Expand Down Expand Up @@ -6256,7 +6255,6 @@ impl AccountsDb {
ancestors,
None,
&EpochSchedule::default(),
&RentCollector::default(),
is_startup,
)
}
Expand Down Expand Up @@ -6417,9 +6415,9 @@ impl AccountsDb {
ancestors: &Ancestors,
expected_capitalization: Option<u64>,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
is_startup: bool,
) -> (AccountsHash, u64) {
let epoch = epoch_schedule.get_epoch(slot);
let (accounts_hash, total_lamports) = self.calculate_accounts_hash_with_verify_from(
data_source,
debug_verify,
Expand All @@ -6428,7 +6426,7 @@ impl AccountsDb {
use_bg_thread_pool: !is_startup,
ancestors: Some(ancestors),
epoch_schedule,
rent_collector,
epoch,
store_detailed_debug_info_on_failure: false,
},
expected_capitalization,
Expand Down Expand Up @@ -6772,7 +6770,7 @@ impl AccountsDb {
use_bg_thread_pool: config.use_bg_thread_pool,
ancestors: Some(config.ancestors),
epoch_schedule: config.epoch_schedule,
rent_collector: config.rent_collector,
epoch: config.epoch,
store_detailed_debug_info_on_failure: config.store_detailed_debug_info,
};
let hash_mismatch_is_error = !config.ignore_mismatch;
Expand Down Expand Up @@ -8788,13 +8786,13 @@ impl<'a> VerifyAccountsHashAndLamportsConfig<'a> {
pub fn new_for_test(
ancestors: &'a Ancestors,
epoch_schedule: &'a EpochSchedule,
rent_collector: &'a RentCollector,
epoch: Epoch,
) -> Self {
Self {
ancestors,
test_hash_calculation: true,
epoch_schedule,
rent_collector,
epoch,
ignore_mismatch: false,
store_detailed_debug_info: false,
use_bg_thread_pool: false,
Expand Down
5 changes: 1 addition & 4 deletions accounts-db/src/accounts_db/scan_account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,7 @@ impl AccountsDb {
config.epoch_schedule,
snapshot_storages.max_slot_inclusive(),
);
let slots_per_epoch = config
.rent_collector
.epoch_schedule
.get_slots_in_epoch(config.rent_collector.epoch);
let slots_per_epoch = config.epoch_schedule.get_slots_in_epoch(config.epoch);
let one_epoch_old = snapshot_storages
.range()
.end
Expand Down
40 changes: 13 additions & 27 deletions accounts-db/src/accounts_db/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2105,16 +2105,14 @@ fn test_hash_stored_account() {

pub static EPOCH_SCHEDULE: std::sync::LazyLock<EpochSchedule> =
std::sync::LazyLock::new(EpochSchedule::default);
pub static RENT_COLLECTOR: std::sync::LazyLock<RentCollector> =
std::sync::LazyLock::new(RentCollector::default);

impl CalcAccountsHashConfig<'_> {
pub(crate) fn default() -> Self {
Self {
use_bg_thread_pool: false,
ancestors: None,
epoch_schedule: &EPOCH_SCHEDULE,
rent_collector: &RENT_COLLECTOR,
epoch: 0,
store_detailed_debug_info_on_failure: false,
}
}
Expand All @@ -2131,17 +2129,14 @@ fn test_verify_accounts_hash() {
let account = AccountSharedData::new(1, some_data_len, &key);
let ancestors = vec![(some_slot, 0)].into_iter().collect();
let epoch_schedule = EpochSchedule::default();
let rent_collector = RentCollector::default();
let epoch = Epoch::default();

db.store_for_tests(some_slot, &[(&key, &account)]);
db.add_root_and_flush_write_cache(some_slot);
let (_, capitalization) = db.update_accounts_hash_for_tests(some_slot, &ancestors, true, true);

let config = VerifyAccountsHashAndLamportsConfig::new_for_test(
&ancestors,
&epoch_schedule,
&rent_collector,
);
let config =
VerifyAccountsHashAndLamportsConfig::new_for_test(&ancestors, &epoch_schedule, epoch);

assert_matches!(
db.verify_accounts_hash_and_lamports_for_tests(some_slot, 1, config.clone()),
Expand Down Expand Up @@ -2181,12 +2176,9 @@ fn test_verify_bank_capitalization() {
let account = AccountSharedData::new(1, some_data_len, &key);
let ancestors = vec![(some_slot, 0)].into_iter().collect();
let epoch_schedule = EpochSchedule::default();
let rent_collector = RentCollector::default();
let config = VerifyAccountsHashAndLamportsConfig::new_for_test(
&ancestors,
&epoch_schedule,
&rent_collector,
);
let epoch = Epoch::default();
let config =
VerifyAccountsHashAndLamportsConfig::new_for_test(&ancestors, &epoch_schedule, epoch);

db.store_for_tests(some_slot, &[(&key, &account)]);
if pass == 0 {
Expand Down Expand Up @@ -2235,12 +2227,9 @@ fn test_verify_accounts_hash_no_account() {
db.update_accounts_hash_for_tests(some_slot, &ancestors, true, true);

let epoch_schedule = EpochSchedule::default();
let rent_collector = RentCollector::default();
let config = VerifyAccountsHashAndLamportsConfig::new_for_test(
&ancestors,
&epoch_schedule,
&rent_collector,
);
let epoch = Epoch::default();
let config =
VerifyAccountsHashAndLamportsConfig::new_for_test(&ancestors, &epoch_schedule, epoch);

assert_matches!(
db.verify_accounts_hash_and_lamports_for_tests(some_slot, 0, config),
Expand All @@ -2267,12 +2256,9 @@ fn test_verify_accounts_hash_bad_account_hash() {
db.add_root_and_flush_write_cache(some_slot);

let epoch_schedule = EpochSchedule::default();
let rent_collector = RentCollector::default();
let config = VerifyAccountsHashAndLamportsConfig::new_for_test(
&ancestors,
&epoch_schedule,
&rent_collector,
);
let epoch = Epoch::default();
let config =
VerifyAccountsHashAndLamportsConfig::new_for_test(&ancestors, &epoch_schedule, epoch);

assert_matches!(
db.verify_accounts_hash_and_lamports_for_tests(some_slot, 1, config),
Expand Down
6 changes: 3 additions & 3 deletions accounts-db/src/accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ use {
bytemuck_derive::{Pod, Zeroable},
log::*,
rayon::prelude::*,
solana_clock::Slot,
solana_clock::{Epoch, Slot},
solana_hash::{Hash, HASH_BYTES},
solana_lattice_hash::lt_hash::LtHash,
solana_measure::{measure::Measure, measure_us},
solana_pubkey::Pubkey,
solana_rent_collector::RentCollector,
solana_sha256_hasher::Hasher,
solana_sysvar::epoch_schedule::EpochSchedule,
std::{
Expand Down Expand Up @@ -97,9 +96,10 @@ pub struct CalcAccountsHashConfig<'a> {
/// does hash calc need to consider account data that exists in the write cache?
/// if so, 'ancestors' will be used for this purpose as well as storages.
pub epoch_schedule: &'a EpochSchedule,
pub rent_collector: &'a RentCollector,
/// used for tracking down hash mismatches after the fact
pub store_detailed_debug_info_on_failure: bool,
/// used to calculate the number of slots in the given epoch
pub epoch: Epoch,
}

// smallest, 3 quartiles, largest, average
Expand Down
10 changes: 8 additions & 2 deletions core/src/accounts_hash_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,14 @@ impl AccountsHashVerifier {
};
timings.calc_storage_size_quartiles(&accounts_package.snapshot_storages);

let epoch = accounts_package
.epoch_schedule
.get_epoch(accounts_package.slot);
let calculate_accounts_hash_config = CalcAccountsHashConfig {
use_bg_thread_pool: true,
ancestors: None,
epoch_schedule: &accounts_package.epoch_schedule,
rent_collector: &accounts_package.rent_collector,
epoch,
store_detailed_debug_info_on_failure: false,
};

Expand Down Expand Up @@ -403,11 +406,14 @@ impl AccountsHashVerifier {
});
let sorted_storages = SortedStorages::new_with_slots(incremental_storages, None, None);

let epoch = accounts_package
.epoch_schedule
.get_epoch(accounts_package.slot);
let calculate_accounts_hash_config = CalcAccountsHashConfig {
use_bg_thread_pool: true,
ancestors: None,
epoch_schedule: &accounts_package.epoch_schedule,
rent_collector: &accounts_package.rent_collector,
epoch,
store_detailed_debug_info_on_failure: false,
};

Expand Down
2 changes: 1 addition & 1 deletion core/tests/epoch_accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ fn test_epoch_accounts_hash_basic(test_environment: TestEnvironment) {
use_bg_thread_pool: false,
ancestors: Some(&bank.ancestors),
epoch_schedule: bank.epoch_schedule(),
rent_collector: bank.rent_collector(),
epoch: bank.epoch(),
store_detailed_debug_info_on_failure: false,
},
);
Expand Down
1 change: 0 additions & 1 deletion ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3118,7 +3118,6 @@ fn main() {

assert_capitalization(&bank);
println!("Inflation: {:?}", bank.inflation());
println!("RentCollector: {:?}", bank.rent_collector());
println!("Capitalization: {}", Sol(bank.capitalization()));
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/accounts_background_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl SnapshotRequestHandler {
use_bg_thread_pool: true,
ancestors: None,
epoch_schedule: snapshot_root_bank.epoch_schedule(),
rent_collector: snapshot_root_bank.rent_collector(),
epoch: snapshot_root_bank.epoch(),
store_detailed_debug_info_on_failure: false,
},
);
Expand Down
9 changes: 2 additions & 7 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5262,7 +5262,7 @@ impl Bank {
let verify_config = VerifyAccountsHashAndLamportsConfig {
ancestors: &self.ancestors,
epoch_schedule: self.epoch_schedule(),
rent_collector: self.rent_collector(),
epoch: self.epoch(),
test_hash_calculation: config.test_hash_calculation,
ignore_mismatch: config.ignore_mismatch,
store_detailed_debug_info: config.store_hash_raw_data_for_debug,
Expand All @@ -5278,7 +5278,6 @@ impl Bank {
let accounts_ = Arc::clone(&accounts);
let ancestors = self.ancestors.clone();
let epoch_schedule = self.epoch_schedule().clone();
let rent_collector = self.rent_collector().clone();
let expected_accounts_lt_hash = self.accounts_lt_hash.lock().unwrap().clone();
accounts.accounts_db.verify_accounts_hash_in_bg.start(|| {
Builder::new()
Expand Down Expand Up @@ -5328,7 +5327,6 @@ impl Bank {
VerifyAccountsHashAndLamportsConfig {
ancestors: &ancestors,
epoch_schedule: &epoch_schedule,
rent_collector: &rent_collector,
..verify_config
},
));
Expand Down Expand Up @@ -5533,7 +5531,6 @@ impl Bank {
&self.ancestors,
None,
self.epoch_schedule(),
&self.rent_collector,
is_startup,
)
.1
Expand Down Expand Up @@ -5668,7 +5665,6 @@ impl Bank {
&self.ancestors,
Some(self.capitalization()),
self.epoch_schedule(),
&self.rent_collector,
is_startup,
);
if total_lamports != self.capitalization() {
Expand All @@ -5692,7 +5688,6 @@ impl Bank {
&self.ancestors,
Some(self.capitalization()),
self.epoch_schedule(),
&self.rent_collector,
is_startup,
);

Expand All @@ -5712,7 +5707,7 @@ impl Bank {
use_bg_thread_pool: true,
ancestors: None, // does not matter, will not be used
epoch_schedule: &self.epoch_schedule,
rent_collector: &self.rent_collector,
epoch: self.epoch,
store_detailed_debug_info_on_failure: false,
};
let storages = self.get_snapshot_storages(Some(base_slot));
Expand Down
16 changes: 6 additions & 10 deletions runtime/src/serde_snapshot/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ mod serde_snapshot_tests {
accounts_hash::AccountsHash,
ancestors::Ancestors,
},
solana_clock::Slot,
solana_clock::{Epoch, Slot},
solana_epoch_schedule::EpochSchedule,
solana_hash::Hash,
solana_nohash_hasher::BuildNoHashHasher,
solana_pubkey::Pubkey,
solana_rent_collector::RentCollector,
std::{
fs::File,
io::{self, BufReader, Cursor, Read, Write},
Expand Down Expand Up @@ -524,12 +523,9 @@ mod serde_snapshot_tests {

let ancestors = Ancestors::default();
let epoch_schedule = EpochSchedule::default();
let rent_collector = RentCollector::default();
let config = VerifyAccountsHashAndLamportsConfig::new_for_test(
&ancestors,
&epoch_schedule,
&rent_collector,
);
let epoch = Epoch::default();
let config =
VerifyAccountsHashAndLamportsConfig::new_for_test(&ancestors, &epoch_schedule, epoch);

accounts
.verify_accounts_hash_and_lamports_for_tests(4, 1222, config)
Expand Down Expand Up @@ -819,11 +815,11 @@ mod serde_snapshot_tests {
let no_ancestors = Ancestors::default();

let epoch_schedule = EpochSchedule::default();
let rent_collector = RentCollector::default();
let epoch = Epoch::default();
let config = VerifyAccountsHashAndLamportsConfig::new_for_test(
&no_ancestors,
&epoch_schedule,
&rent_collector,
epoch,
);

accounts.update_accounts_hash_for_tests(current_slot, &no_ancestors, false, false);
Expand Down
Loading
Loading