pass include_slot_in_hash through hash calcs to allow rehashing if hash is not stored (#31579)
* pass include_slot_in_hash through hash calcs to allow rehashing * tests use each include_slot_in_hash value * move include_slot_in_hash * typo * reorder struct init * spelling is hard
This commit is contained in:
parent
d9cfb31bba
commit
122b05b9f5
|
@ -1,4 +1,5 @@
|
|||
#![allow(clippy::integer_arithmetic)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
use {
|
||||
|
@ -9,7 +10,7 @@ use {
|
|||
accounts::Accounts,
|
||||
accounts_db::{
|
||||
test_utils::{create_test_accounts, update_accounts_bench},
|
||||
AccountShrinkThreshold, CalcAccountsHashDataSource,
|
||||
AccountShrinkThreshold, CalcAccountsHashDataSource, INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
},
|
||||
accounts_index::AccountSecondaryIndexes,
|
||||
ancestors::Ancestors,
|
||||
|
@ -133,6 +134,7 @@ fn main() {
|
|||
&EpochSchedule::default(),
|
||||
&RentCollector::default(),
|
||||
true,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
);
|
||||
time_store.stop();
|
||||
if results != results_store {
|
||||
|
|
|
@ -334,6 +334,7 @@ impl AccountsHashVerifier {
|
|||
epoch_schedule: &accounts_package.epoch_schedule,
|
||||
rent_collector: &accounts_package.rent_collector,
|
||||
store_detailed_debug_info_on_failure: false,
|
||||
include_slot_in_hash: accounts_package.include_slot_in_hash,
|
||||
};
|
||||
|
||||
let ((accounts_hash, lamports), measure_hash_us) = measure_us!(accounts_package
|
||||
|
@ -428,6 +429,7 @@ impl AccountsHashVerifier {
|
|||
epoch_schedule: &accounts_package.epoch_schedule,
|
||||
rent_collector: &accounts_package.rent_collector,
|
||||
store_detailed_debug_info_on_failure: false,
|
||||
include_slot_in_hash: accounts_package.include_slot_in_hash,
|
||||
};
|
||||
|
||||
let (incremental_accounts_hash, measure_hash_us) = measure_us!(
|
||||
|
|
|
@ -12,7 +12,9 @@ use {
|
|||
AbsRequestHandlers, AbsRequestSender, AccountsBackgroundService, DroppedSlotsReceiver,
|
||||
PrunedBanksRequestHandler, SnapshotRequestHandler,
|
||||
},
|
||||
accounts_db::{AccountShrinkThreshold, CalcAccountsHashDataSource},
|
||||
accounts_db::{
|
||||
AccountShrinkThreshold, CalcAccountsHashDataSource, INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
},
|
||||
accounts_hash::CalcAccountsHashConfig,
|
||||
accounts_index::AccountSecondaryIndexes,
|
||||
bank::{Bank, BankTestConfig},
|
||||
|
@ -317,6 +319,7 @@ fn test_epoch_accounts_hash_basic(test_environment: TestEnvironment) {
|
|||
epoch_schedule: bank.epoch_schedule(),
|
||||
rent_collector: bank.rent_collector(),
|
||||
store_detailed_debug_info_on_failure: false,
|
||||
include_slot_in_hash: INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
|
|
@ -11,7 +11,7 @@ use {
|
|||
accounts::{AccountAddressFilter, Accounts},
|
||||
accounts_db::{
|
||||
test_utils::create_test_accounts, AccountShrinkThreshold,
|
||||
VerifyAccountsHashAndLamportsConfig,
|
||||
VerifyAccountsHashAndLamportsConfig, INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
},
|
||||
accounts_index::{AccountSecondaryIndexes, ScanConfig},
|
||||
ancestors::Ancestors,
|
||||
|
@ -114,6 +114,7 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
|
|||
ignore_mismatch: false,
|
||||
store_detailed_debug_info: false,
|
||||
use_bg_thread_pool: false,
|
||||
include_slot_in_hash: INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
}
|
||||
))
|
||||
});
|
||||
|
|
|
@ -333,6 +333,7 @@ impl SnapshotRequestHandler {
|
|||
epoch_schedule: snapshot_root_bank.epoch_schedule(),
|
||||
rent_collector: snapshot_root_bank.rent_collector(),
|
||||
store_detailed_debug_info_on_failure: false,
|
||||
include_slot_in_hash: snapshot_root_bank.include_slot_in_hash(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
|
|
@ -213,6 +213,7 @@ pub struct VerifyAccountsHashAndLamportsConfig<'a> {
|
|||
pub store_detailed_debug_info: bool,
|
||||
/// true to use dedicated background thread pool for verification
|
||||
pub use_bg_thread_pool: bool,
|
||||
pub include_slot_in_hash: IncludeSlotInHash,
|
||||
}
|
||||
|
||||
pub(crate) trait ShrinkCollectRefs<'a>: Sync + Send {
|
||||
|
@ -297,12 +298,6 @@ pub const INCLUDE_SLOT_IN_HASH_TESTS: IncludeSlotInHash = IncludeSlotInHash::Inc
|
|||
pub const INCLUDE_SLOT_IN_HASH_IRRELEVANT_APPEND_VEC_OPERATION: IncludeSlotInHash =
|
||||
IncludeSlotInHash::IrrelevantAssertOnUse;
|
||||
|
||||
// This value is irrelevant because the the debug-only check_hash debug option is not possible to enable at the moment.
|
||||
// This has been true for some time now, due to fallout from disabling rewrites.
|
||||
// The check_hash debug option can be re-enabled once this feature and the 'rent_epoch' features are enabled.
|
||||
pub const INCLUDE_SLOT_IN_HASH_IRRELEVANT_CHECK_HASH: IncludeSlotInHash =
|
||||
IncludeSlotInHash::IrrelevantAssertOnUse;
|
||||
|
||||
pub enum StoreReclaims {
|
||||
/// normal reclaim mode
|
||||
Default,
|
||||
|
@ -2324,26 +2319,28 @@ impl<'a> AppendVecScan for ScanState<'a> {
|
|||
self.pubkey_to_bin_index -= self.bin_range.start;
|
||||
|
||||
let balance = loaded_account.lamports();
|
||||
let loaded_hash = loaded_account.loaded_hash();
|
||||
let source_item = CalculateHashIntermediate::new(loaded_hash, balance, *pubkey);
|
||||
let mut loaded_hash = loaded_account.loaded_hash();
|
||||
|
||||
if self.config.check_hash
|
||||
let hash_is_missing = loaded_hash == Hash::default();
|
||||
if (self.config.check_hash || hash_is_missing)
|
||||
&& !AccountsDb::is_filler_account_helper(pubkey, self.filler_account_suffix)
|
||||
{
|
||||
// this will not be supported anymore
|
||||
let computed_hash = loaded_account.compute_hash(
|
||||
self.current_slot,
|
||||
pubkey,
|
||||
INCLUDE_SLOT_IN_HASH_IRRELEVANT_CHECK_HASH,
|
||||
self.config.include_slot_in_hash,
|
||||
);
|
||||
if computed_hash != source_item.hash {
|
||||
if hash_is_missing {
|
||||
loaded_hash = computed_hash;
|
||||
} else if self.config.check_hash && computed_hash != loaded_hash {
|
||||
info!(
|
||||
"hash mismatch found: computed: {}, loaded: {}, pubkey: {}",
|
||||
computed_hash, source_item.hash, pubkey
|
||||
computed_hash, loaded_hash, pubkey
|
||||
);
|
||||
self.mismatch_found.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
let source_item = CalculateHashIntermediate::new(loaded_hash, balance, *pubkey);
|
||||
self.init_accum(self.range);
|
||||
self.accum[self.pubkey_to_bin_index].push(source_item);
|
||||
}
|
||||
|
@ -6950,12 +6947,16 @@ impl AccountsDb {
|
|||
.get_loaded_account()
|
||||
.and_then(
|
||||
|loaded_account| {
|
||||
let loaded_hash = loaded_account.loaded_hash();
|
||||
let mut loaded_hash = loaded_account.loaded_hash();
|
||||
let balance = loaded_account.lamports();
|
||||
if config.check_hash && !self.is_filler_account(pubkey) { // this will not be supported anymore
|
||||
let hash_is_missing = loaded_hash == Hash::default();
|
||||
if (config.check_hash || hash_is_missing) && !self.is_filler_account(pubkey) {
|
||||
let computed_hash =
|
||||
loaded_account.compute_hash(*slot, pubkey, INCLUDE_SLOT_IN_HASH_IRRELEVANT_CHECK_HASH);
|
||||
if computed_hash != loaded_hash {
|
||||
loaded_account.compute_hash(*slot, pubkey, config.include_slot_in_hash);
|
||||
if hash_is_missing {
|
||||
loaded_hash = computed_hash;
|
||||
}
|
||||
else if config.check_hash && computed_hash != loaded_hash {
|
||||
info!("hash mismatch found: computed: {}, loaded: {}, pubkey: {}", computed_hash, loaded_hash, pubkey);
|
||||
mismatch_found
|
||||
.fetch_add(1, Ordering::Relaxed);
|
||||
|
@ -7030,6 +7031,7 @@ impl AccountsDb {
|
|||
&EpochSchedule::default(),
|
||||
&RentCollector::default(),
|
||||
is_startup,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -7358,6 +7360,7 @@ impl AccountsDb {
|
|||
epoch_schedule: &EpochSchedule,
|
||||
rent_collector: &RentCollector,
|
||||
is_startup: bool,
|
||||
include_slot_in_hash: IncludeSlotInHash,
|
||||
) -> (AccountsHash, u64) {
|
||||
let check_hash = false;
|
||||
let (accounts_hash, total_lamports) = self
|
||||
|
@ -7372,6 +7375,7 @@ impl AccountsDb {
|
|||
epoch_schedule,
|
||||
rent_collector,
|
||||
store_detailed_debug_info_on_failure: false,
|
||||
include_slot_in_hash,
|
||||
},
|
||||
expected_capitalization,
|
||||
)
|
||||
|
@ -7733,11 +7737,12 @@ impl AccountsDb {
|
|||
use AccountsHashVerificationError::*;
|
||||
let calc_config = CalcAccountsHashConfig {
|
||||
use_bg_thread_pool: config.use_bg_thread_pool,
|
||||
check_hash: false, // this will not be supported anymore
|
||||
check_hash: false,
|
||||
ancestors: Some(config.ancestors),
|
||||
epoch_schedule: config.epoch_schedule,
|
||||
rent_collector: config.rent_collector,
|
||||
store_detailed_debug_info_on_failure: config.store_detailed_debug_info,
|
||||
include_slot_in_hash: config.include_slot_in_hash,
|
||||
};
|
||||
let hash_mismatch_is_error = !config.ignore_mismatch;
|
||||
|
||||
|
@ -9583,6 +9588,7 @@ pub mod tests {
|
|||
bins: usize,
|
||||
bin_range: &Range<usize>,
|
||||
check_hash: bool,
|
||||
include_slot_in_hash: IncludeSlotInHash,
|
||||
) -> Result<Vec<CacheHashDataFile>, AccountsHashVerificationError> {
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let accounts_hash_cache_path = temp_dir.path().to_path_buf();
|
||||
|
@ -9594,6 +9600,7 @@ pub mod tests {
|
|||
bin_range,
|
||||
&CalcAccountsHashConfig {
|
||||
check_hash,
|
||||
include_slot_in_hash,
|
||||
..CalcAccountsHashConfig::default()
|
||||
},
|
||||
None,
|
||||
|
@ -9716,6 +9723,7 @@ pub mod tests {
|
|||
ignore_mismatch: false,
|
||||
store_detailed_debug_info: false,
|
||||
use_bg_thread_pool: false,
|
||||
include_slot_in_hash: INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9959,7 +9967,14 @@ pub mod tests {
|
|||
let accounts_db = AccountsDb::new_single_for_tests();
|
||||
|
||||
accounts_db
|
||||
.scan_snapshot_stores(&empty_storages(), &mut stats, 2, &bounds, false)
|
||||
.scan_snapshot_stores(
|
||||
&empty_storages(),
|
||||
&mut stats,
|
||||
2,
|
||||
&bounds,
|
||||
false,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
#[test]
|
||||
|
@ -9972,7 +9987,14 @@ pub mod tests {
|
|||
|
||||
let accounts_db = AccountsDb::new_single_for_tests();
|
||||
accounts_db
|
||||
.scan_snapshot_stores(&empty_storages(), &mut stats, 2, &bounds, false)
|
||||
.scan_snapshot_stores(
|
||||
&empty_storages(),
|
||||
&mut stats,
|
||||
2,
|
||||
&bounds,
|
||||
false,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
@ -9986,13 +10008,21 @@ pub mod tests {
|
|||
|
||||
let accounts_db = AccountsDb::new_single_for_tests();
|
||||
accounts_db
|
||||
.scan_snapshot_stores(&empty_storages(), &mut stats, 2, &bounds, false)
|
||||
.scan_snapshot_stores(
|
||||
&empty_storages(),
|
||||
&mut stats,
|
||||
2,
|
||||
&bounds,
|
||||
false,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn sample_storages_and_account_in_slot(
|
||||
slot: Slot,
|
||||
accounts: &AccountsDb,
|
||||
include_slot_in_hash: IncludeSlotInHash,
|
||||
) -> (
|
||||
Vec<Arc<AccountStorageEntry>>,
|
||||
Vec<CalculateHashIntermediate>,
|
||||
|
@ -10028,9 +10058,9 @@ pub mod tests {
|
|||
slot,
|
||||
&raw_accounts[i],
|
||||
&raw_expected[i].pubkey,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
include_slot_in_hash,
|
||||
);
|
||||
if slot == 1 {
|
||||
if slot == 1 && matches!(include_slot_in_hash, IncludeSlotInHash::IncludeSlot) {
|
||||
assert_eq!(hash, expected_hashes[i]);
|
||||
}
|
||||
raw_expected[i].hash = hash;
|
||||
|
@ -10058,11 +10088,12 @@ pub mod tests {
|
|||
|
||||
fn sample_storages_and_accounts(
|
||||
accounts: &AccountsDb,
|
||||
include_slot_in_hash: IncludeSlotInHash,
|
||||
) -> (
|
||||
Vec<Arc<AccountStorageEntry>>,
|
||||
Vec<CalculateHashIntermediate>,
|
||||
) {
|
||||
sample_storages_and_account_in_slot(1, accounts)
|
||||
sample_storages_and_account_in_slot(1, accounts, include_slot_in_hash)
|
||||
}
|
||||
|
||||
fn get_storage_refs(input: &[Arc<AccountStorageEntry>]) -> SortedStorages {
|
||||
|
@ -10127,12 +10158,140 @@ pub mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_accountsdb_scan_snapshot_stores_hash_not_stored() {
|
||||
solana_logger::setup();
|
||||
for include_slot_in_hash in [
|
||||
IncludeSlotInHash::IncludeSlot,
|
||||
IncludeSlotInHash::RemoveSlot,
|
||||
] {
|
||||
let accounts_db = AccountsDb::new_single_for_tests();
|
||||
let (storages, raw_expected) =
|
||||
sample_storages_and_accounts(&accounts_db, include_slot_in_hash);
|
||||
storages.iter().for_each(|storage| {
|
||||
accounts_db.storage.remove(&storage.slot(), false);
|
||||
});
|
||||
|
||||
let hash = Hash::default();
|
||||
|
||||
// replace the sample storages, storing default hash values so that we rehash during scan
|
||||
let storages = storages
|
||||
.iter()
|
||||
.map(|storage| {
|
||||
let slot = storage.slot();
|
||||
let copied_storage = accounts_db.create_and_insert_store(slot, 10000, "test");
|
||||
let all_accounts = storage
|
||||
.all_accounts()
|
||||
.iter()
|
||||
.map(|acct| (*acct.pubkey(), acct.to_account_shared_data()))
|
||||
.collect::<Vec<_>>();
|
||||
let accounts = all_accounts
|
||||
.iter()
|
||||
.map(|stored| (&stored.0, &stored.1))
|
||||
.collect::<Vec<_>>();
|
||||
let slice = &accounts[..];
|
||||
let account_data = (slot, slice, include_slot_in_hash);
|
||||
let hashes = (0..account_data.len()).map(|_| &hash).collect();
|
||||
let write_versions = (0..account_data.len()).map(|_| 0).collect();
|
||||
let storable_accounts =
|
||||
StorableAccountsWithHashesAndWriteVersions::new_with_hashes_and_write_versions(
|
||||
&account_data,
|
||||
hashes,
|
||||
write_versions,
|
||||
);
|
||||
copied_storage
|
||||
.accounts
|
||||
.append_accounts(&storable_accounts, 0);
|
||||
copied_storage
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_test_scan(accounts_db, storages, raw_expected, include_slot_in_hash);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "MismatchedAccountsHash")]
|
||||
fn test_accountsdb_scan_snapshot_stores_check_hash() {
|
||||
solana_logger::setup();
|
||||
let accounts_db = AccountsDb::new_single_for_tests();
|
||||
let (storages, _raw_expected) =
|
||||
sample_storages_and_accounts(&accounts_db, INCLUDE_SLOT_IN_HASH_TESTS);
|
||||
let max_slot = storages.iter().map(|storage| storage.slot()).max().unwrap();
|
||||
|
||||
let hash = Hash::from_str("7JcmM6TFZMkcDkZe6RKVkGaWwN5dXciGC4fa3RxvqQc9").unwrap();
|
||||
|
||||
// replace the sample storages, storing bogus hash values so that we trigger the hash mismatch
|
||||
let storages = storages
|
||||
.iter()
|
||||
.map(|storage| {
|
||||
let slot = storage.slot() + max_slot;
|
||||
let copied_storage = accounts_db.create_and_insert_store(slot, 10000, "test");
|
||||
let all_accounts = storage
|
||||
.all_accounts()
|
||||
.iter()
|
||||
.map(|acct| (*acct.pubkey(), acct.to_account_shared_data()))
|
||||
.collect::<Vec<_>>();
|
||||
let accounts = all_accounts
|
||||
.iter()
|
||||
.map(|stored| (&stored.0, &stored.1))
|
||||
.collect::<Vec<_>>();
|
||||
let slice = &accounts[..];
|
||||
let account_data = (slot, slice, INCLUDE_SLOT_IN_HASH_TESTS);
|
||||
let hashes = (0..account_data.len()).map(|_| &hash).collect();
|
||||
let write_versions = (0..account_data.len()).map(|_| 0).collect();
|
||||
let storable_accounts =
|
||||
StorableAccountsWithHashesAndWriteVersions::new_with_hashes_and_write_versions(
|
||||
&account_data,
|
||||
hashes,
|
||||
write_versions,
|
||||
);
|
||||
copied_storage
|
||||
.accounts
|
||||
.append_accounts(&storable_accounts, 0);
|
||||
copied_storage
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let bins = 1;
|
||||
let mut stats = HashStats::default();
|
||||
|
||||
accounts_db
|
||||
.scan_snapshot_stores(
|
||||
&get_storage_refs(&storages),
|
||||
&mut stats,
|
||||
bins,
|
||||
&Range {
|
||||
start: 0,
|
||||
end: bins,
|
||||
},
|
||||
true, // checking hash here
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_accountsdb_scan_snapshot_stores() {
|
||||
solana_logger::setup();
|
||||
let accounts_db = AccountsDb::new_single_for_tests();
|
||||
let (storages, raw_expected) = sample_storages_and_accounts(&accounts_db);
|
||||
let (storages, raw_expected) =
|
||||
sample_storages_and_accounts(&accounts_db, INCLUDE_SLOT_IN_HASH_TESTS);
|
||||
|
||||
assert_test_scan(
|
||||
accounts_db,
|
||||
storages,
|
||||
raw_expected,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
);
|
||||
}
|
||||
|
||||
fn assert_test_scan(
|
||||
accounts_db: AccountsDb,
|
||||
storages: Vec<Arc<AccountStorageEntry>>,
|
||||
raw_expected: Vec<CalculateHashIntermediate>,
|
||||
include_slot_in_hash: IncludeSlotInHash,
|
||||
) {
|
||||
let bins = 1;
|
||||
let mut stats = HashStats::default();
|
||||
|
||||
|
@ -10145,7 +10304,8 @@ pub mod tests {
|
|||
start: 0,
|
||||
end: bins,
|
||||
},
|
||||
false,
|
||||
true, // checking hash here
|
||||
include_slot_in_hash,
|
||||
)
|
||||
.unwrap();
|
||||
assert_scan(result, vec![vec![raw_expected.clone()]], bins, 0, bins);
|
||||
|
@ -10162,6 +10322,7 @@ pub mod tests {
|
|||
end: bins,
|
||||
},
|
||||
false,
|
||||
include_slot_in_hash,
|
||||
)
|
||||
.unwrap();
|
||||
let mut expected = vec![Vec::new(); bins];
|
||||
|
@ -10183,6 +10344,7 @@ pub mod tests {
|
|||
end: bins,
|
||||
},
|
||||
false,
|
||||
include_slot_in_hash,
|
||||
)
|
||||
.unwrap();
|
||||
let mut expected = vec![Vec::new(); bins];
|
||||
|
@ -10204,6 +10366,7 @@ pub mod tests {
|
|||
end: bins,
|
||||
},
|
||||
false,
|
||||
include_slot_in_hash,
|
||||
)
|
||||
.unwrap();
|
||||
let mut expected = vec![Vec::new(); bins];
|
||||
|
@ -10220,7 +10383,8 @@ pub mod tests {
|
|||
// enough stores to get to 2nd chunk
|
||||
let bins = 1;
|
||||
let slot = MAX_ITEMS_PER_CHUNK as Slot;
|
||||
let (storages, raw_expected) = sample_storages_and_account_in_slot(slot, &accounts_db);
|
||||
let (storages, raw_expected) =
|
||||
sample_storages_and_account_in_slot(slot, &accounts_db, INCLUDE_SLOT_IN_HASH_TESTS);
|
||||
let storage_data = vec![(&storages[0], slot)];
|
||||
|
||||
let sorted_storages =
|
||||
|
@ -10237,6 +10401,7 @@ pub mod tests {
|
|||
end: bins,
|
||||
},
|
||||
false,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -10247,7 +10412,8 @@ pub mod tests {
|
|||
fn test_accountsdb_scan_snapshot_stores_binning() {
|
||||
let mut stats = HashStats::default();
|
||||
let accounts_db = AccountsDb::new_single_for_tests();
|
||||
let (storages, raw_expected) = sample_storages_and_accounts(&accounts_db);
|
||||
let (storages, raw_expected) =
|
||||
sample_storages_and_accounts(&accounts_db, INCLUDE_SLOT_IN_HASH_TESTS);
|
||||
|
||||
// just the first bin of 2
|
||||
let bins = 2;
|
||||
|
@ -10262,6 +10428,7 @@ pub mod tests {
|
|||
end: half_bins,
|
||||
},
|
||||
false,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
.unwrap();
|
||||
let mut expected = vec![Vec::new(); half_bins];
|
||||
|
@ -10281,6 +10448,7 @@ pub mod tests {
|
|||
end: bins,
|
||||
},
|
||||
false,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -10305,6 +10473,7 @@ pub mod tests {
|
|||
end: bin + 1,
|
||||
},
|
||||
false,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
.unwrap();
|
||||
let mut expected = vec![Vec::new(); 1];
|
||||
|
@ -10327,6 +10496,7 @@ pub mod tests {
|
|||
end: bin + range,
|
||||
},
|
||||
false,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
.unwrap();
|
||||
let mut expected = vec![];
|
||||
|
@ -10357,7 +10527,8 @@ pub mod tests {
|
|||
// range is for only 1 bin out of 256.
|
||||
let bins = 256;
|
||||
let slot = MAX_ITEMS_PER_CHUNK as Slot;
|
||||
let (storages, raw_expected) = sample_storages_and_account_in_slot(slot, &accounts_db);
|
||||
let (storages, raw_expected) =
|
||||
sample_storages_and_account_in_slot(slot, &accounts_db, INCLUDE_SLOT_IN_HASH_TESTS);
|
||||
let storage_data = vec![(&storages[0], slot)];
|
||||
|
||||
let sorted_storages =
|
||||
|
@ -10376,6 +10547,7 @@ pub mod tests {
|
|||
end: start + range,
|
||||
},
|
||||
false,
|
||||
INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(result.len(), 1); // 2 chunks, but 1 is empty so not included
|
||||
|
@ -10415,7 +10587,8 @@ pub mod tests {
|
|||
solana_logger::setup();
|
||||
|
||||
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
||||
let (storages, raw_expected) = sample_storages_and_accounts(&db);
|
||||
let (storages, raw_expected) =
|
||||
sample_storages_and_accounts(&db, INCLUDE_SLOT_IN_HASH_TESTS);
|
||||
let expected_hash =
|
||||
AccountsHasher::compute_merkle_root_loop(raw_expected.clone(), MERKLE_FANOUT, |item| {
|
||||
&item.hash
|
||||
|
@ -12633,6 +12806,7 @@ pub mod tests {
|
|||
epoch_schedule: &EPOCH_SCHEDULE,
|
||||
rent_collector: &RENT_COLLECTOR,
|
||||
store_detailed_debug_info_on_failure: false,
|
||||
include_slot_in_hash: INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use {
|
||||
crate::{
|
||||
accounts_db::{AccountStorageEntry, PUBKEY_BINS_FOR_CALCULATING_HASHES},
|
||||
accounts_db::{AccountStorageEntry, IncludeSlotInHash, PUBKEY_BINS_FOR_CALCULATING_HASHES},
|
||||
ancestors::Ancestors,
|
||||
rent_collector::RentCollector,
|
||||
},
|
||||
|
@ -101,7 +101,6 @@ pub struct CalcAccountsHashConfig<'a> {
|
|||
/// true to use a thread pool dedicated to bg operations
|
||||
pub use_bg_thread_pool: bool,
|
||||
/// verify every hash in append vec/write cache with a recalculated hash
|
||||
/// this option will be removed
|
||||
pub check_hash: bool,
|
||||
/// 'ancestors' is used to get storages
|
||||
pub ancestors: Option<&'a Ancestors>,
|
||||
|
@ -111,6 +110,7 @@ pub struct CalcAccountsHashConfig<'a> {
|
|||
pub rent_collector: &'a RentCollector,
|
||||
/// used for tracking down hash mismatches after the fact
|
||||
pub store_detailed_debug_info_on_failure: bool,
|
||||
pub include_slot_in_hash: IncludeSlotInHash,
|
||||
}
|
||||
|
||||
// smallest, 3 quartiles, largest, average
|
||||
|
|
|
@ -5565,7 +5565,8 @@ impl Bank {
|
|||
}
|
||||
|
||||
/// true if we should include the slot in account hash
|
||||
fn include_slot_in_hash(&self) -> IncludeSlotInHash {
|
||||
/// This is governed by a feature.
|
||||
pub(crate) fn include_slot_in_hash(&self) -> IncludeSlotInHash {
|
||||
if self
|
||||
.feature_set
|
||||
.is_active(&feature_set::account_hash_ignore_slot::id())
|
||||
|
@ -6662,6 +6663,7 @@ impl Bank {
|
|||
let cap = self.capitalization();
|
||||
let epoch_schedule = self.epoch_schedule();
|
||||
let rent_collector = self.rent_collector();
|
||||
let include_slot_in_hash = self.include_slot_in_hash();
|
||||
if config.run_in_background {
|
||||
let ancestors = ancestors.clone();
|
||||
let accounts = Arc::clone(accounts);
|
||||
|
@ -6687,6 +6689,7 @@ impl Bank {
|
|||
ignore_mismatch: config.ignore_mismatch,
|
||||
store_detailed_debug_info: config.store_hash_raw_data_for_debug,
|
||||
use_bg_thread_pool: true,
|
||||
include_slot_in_hash,
|
||||
},
|
||||
);
|
||||
accounts_
|
||||
|
@ -6711,6 +6714,7 @@ impl Bank {
|
|||
ignore_mismatch: config.ignore_mismatch,
|
||||
store_detailed_debug_info: config.store_hash_raw_data_for_debug,
|
||||
use_bg_thread_pool: false, // fg is waiting for this to run, so we can use the fg thread pool
|
||||
include_slot_in_hash,
|
||||
},
|
||||
);
|
||||
self.set_initial_accounts_hash_verification_completed();
|
||||
|
@ -6848,6 +6852,7 @@ impl Bank {
|
|||
self.epoch_schedule(),
|
||||
&self.rent_collector,
|
||||
is_startup,
|
||||
self.include_slot_in_hash(),
|
||||
)
|
||||
.1
|
||||
}
|
||||
|
@ -6936,6 +6941,7 @@ impl Bank {
|
|||
self.epoch_schedule(),
|
||||
&self.rent_collector,
|
||||
is_startup,
|
||||
self.include_slot_in_hash(),
|
||||
);
|
||||
if total_lamports != self.capitalization() {
|
||||
datapoint_info!(
|
||||
|
@ -6958,6 +6964,7 @@ impl Bank {
|
|||
self.epoch_schedule(),
|
||||
&self.rent_collector,
|
||||
is_startup,
|
||||
self.include_slot_in_hash(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -6984,6 +6991,7 @@ impl Bank {
|
|||
epoch_schedule: &self.epoch_schedule,
|
||||
rent_collector: &self.rent_collector,
|
||||
store_detailed_debug_info_on_failure: false,
|
||||
include_slot_in_hash: self.include_slot_in_hash(),
|
||||
};
|
||||
let storages = self.get_snapshot_storages(Some(base_slot));
|
||||
let sorted_storages = SortedStorages::new(&storages);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
accounts::Accounts,
|
||||
accounts_db::AccountStorageEntry,
|
||||
accounts_db::{AccountStorageEntry, IncludeSlotInHash, INCLUDE_SLOT_IN_HASH_TESTS},
|
||||
accounts_hash::{AccountsHash, AccountsHashEnum},
|
||||
bank::Bank,
|
||||
epoch_accounts_hash::EpochAccountsHash,
|
||||
|
@ -34,6 +34,7 @@ pub struct AccountsPackage {
|
|||
pub epoch_schedule: EpochSchedule,
|
||||
pub rent_collector: RentCollector,
|
||||
pub is_incremental_accounts_hash_feature_enabled: bool,
|
||||
pub include_slot_in_hash: IncludeSlotInHash,
|
||||
|
||||
/// Supplemental information needed for snapshots
|
||||
pub snapshot_info: Option<SupplementalSnapshotInfo>,
|
||||
|
@ -131,6 +132,7 @@ impl AccountsPackage {
|
|||
epoch_schedule: *bank.epoch_schedule(),
|
||||
rent_collector: bank.rent_collector().clone(),
|
||||
is_incremental_accounts_hash_feature_enabled,
|
||||
include_slot_in_hash: bank.include_slot_in_hash(),
|
||||
snapshot_info,
|
||||
enqueued: Instant::now(),
|
||||
}
|
||||
|
@ -150,6 +152,7 @@ impl AccountsPackage {
|
|||
epoch_schedule: EpochSchedule::default(),
|
||||
rent_collector: RentCollector::default(),
|
||||
is_incremental_accounts_hash_feature_enabled: bool::default(),
|
||||
include_slot_in_hash: INCLUDE_SLOT_IN_HASH_TESTS,
|
||||
snapshot_info: Some(SupplementalSnapshotInfo {
|
||||
bank_snapshot_dir: PathBuf::default(),
|
||||
archive_format: ArchiveFormat::Tar,
|
||||
|
|
|
@ -5508,6 +5508,7 @@ mod tests {
|
|||
epoch_schedule: deserialized_bank.epoch_schedule(),
|
||||
rent_collector: deserialized_bank.rent_collector(),
|
||||
store_detailed_debug_info_on_failure: false,
|
||||
include_slot_in_hash: bank.include_slot_in_hash(),
|
||||
},
|
||||
&SortedStorages::new(&other_incremental_snapshot_storages),
|
||||
HashStats::default(),
|
||||
|
|
Loading…
Reference in New Issue