allow accounts hash calc to specify enable_rehashing (#27615)

This commit is contained in:
Jeff Washington (jwash) 2022-09-07 10:16:52 -07:00 committed by GitHub
parent a31d4a597d
commit 22007a3c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 24 deletions

View File

@ -130,6 +130,8 @@ impl AccountsHashVerifier {
}; };
timings.calc_storage_size_quartiles(&accounts_package.snapshot_storages); timings.calc_storage_size_quartiles(&accounts_package.snapshot_storages);
let enable_rehashing = true;
let (accounts_hash, lamports) = accounts_package let (accounts_hash, lamports) = accounts_package
.accounts .accounts
.accounts_db .accounts_db
@ -143,6 +145,7 @@ impl AccountsHashVerifier {
rent_collector: &accounts_package.rent_collector, rent_collector: &accounts_package.rent_collector,
store_detailed_debug_info_on_failure: false, store_detailed_debug_info_on_failure: false,
full_snapshot: None, full_snapshot: None,
enable_rehashing,
}, },
&sorted_storages, &sorted_storages,
timings, timings,
@ -166,6 +169,7 @@ impl AccountsHashVerifier {
rent_collector: &accounts_package.rent_collector, rent_collector: &accounts_package.rent_collector,
store_detailed_debug_info_on_failure: false, store_detailed_debug_info_on_failure: false,
full_snapshot: None, full_snapshot: None,
enable_rehashing,
}, },
); );
info!( info!(
@ -186,6 +190,7 @@ impl AccountsHashVerifier {
// now that we've failed, store off the failing contents that produced a bad capitalization // now that we've failed, store off the failing contents that produced a bad capitalization
store_detailed_debug_info_on_failure: true, store_detailed_debug_info_on_failure: true,
full_snapshot: None, full_snapshot: None,
enable_rehashing,
}, },
&sorted_storages, &sorted_storages,
HashStats::default(), HashStats::default(),

View File

@ -195,6 +195,7 @@ impl SnapshotRequestHandler {
rent_collector: snapshot_root_bank.rent_collector(), rent_collector: snapshot_root_bank.rent_collector(),
store_detailed_debug_info_on_failure: false, store_detailed_debug_info_on_failure: false,
full_snapshot: None, full_snapshot: None,
enable_rehashing: true,
}, },
).unwrap(); ).unwrap();
assert_eq!(previous_hash, this_hash); assert_eq!(previous_hash, this_hash);

View File

@ -1840,18 +1840,24 @@ impl<'a, T: Fn(Slot) -> Option<Slot> + Sync + Send + Clone> AppendVecScan for Sc
let balance = loaded_account.lamports(); let balance = loaded_account.lamports();
let loaded_hash = loaded_account.loaded_hash(); let loaded_hash = loaded_account.loaded_hash();
let new_hash = ExpectedRentCollection::maybe_rehash_skipped_rewrite( let new_hash = self
loaded_account, .config
&loaded_hash, .enable_rehashing
pubkey, .then(|| {
self.current_slot, ExpectedRentCollection::maybe_rehash_skipped_rewrite(
self.config.epoch_schedule, loaded_account,
self.config.rent_collector, &loaded_hash,
self.stats, pubkey,
&self.max_slot_info, self.current_slot,
self.find_unskipped_slot, self.config.epoch_schedule,
self.filler_account_suffix, self.config.rent_collector,
); self.stats,
&self.max_slot_info,
self.find_unskipped_slot,
self.filler_account_suffix,
)
})
.flatten();
let loaded_hash = new_hash.unwrap_or(loaded_hash); let loaded_hash = new_hash.unwrap_or(loaded_hash);
let source_item = CalculateHashIntermediate::new(loaded_hash, balance, *pubkey); let source_item = CalculateHashIntermediate::new(loaded_hash, balance, *pubkey);
@ -6433,18 +6439,19 @@ impl AccountsDb {
self.find_unskipped_slot(slot, config.ancestors) self.find_unskipped_slot(slot, config.ancestors)
}; };
let loaded_hash = loaded_account.loaded_hash(); let loaded_hash = loaded_account.loaded_hash();
let new_hash = ExpectedRentCollection::maybe_rehash_skipped_rewrite( let new_hash = config.enable_rehashing
&loaded_account, .then(|| ExpectedRentCollection::maybe_rehash_skipped_rewrite(
&loaded_hash, &loaded_account,
pubkey, &loaded_hash,
*slot, pubkey,
config.epoch_schedule, *slot,
config.rent_collector, config.epoch_schedule,
&stats, config.rent_collector,
&max_slot_info, &stats,
find_unskipped_slot, &max_slot_info,
self.filler_account_suffix.as_ref(), find_unskipped_slot,
); self.filler_account_suffix.as_ref(),
)).flatten();
let loaded_hash = new_hash.unwrap_or(loaded_hash); let loaded_hash = new_hash.unwrap_or(loaded_hash);
let balance = loaded_account.lamports(); let balance = loaded_account.lamports();
if config.check_hash && !self.is_filler_account(pubkey) { // this will not be supported anymore if config.check_hash && !self.is_filler_account(pubkey) { // this will not be supported anymore
@ -6997,6 +7004,7 @@ impl AccountsDb {
rent_collector, rent_collector,
store_detailed_debug_info_on_failure: false, store_detailed_debug_info_on_failure: false,
full_snapshot: None, full_snapshot: None,
enable_rehashing: true,
}, },
expected_capitalization, expected_capitalization,
) )
@ -7295,6 +7303,7 @@ impl AccountsDb {
rent_collector, rent_collector,
store_detailed_debug_info_on_failure: store_hash_raw_data_for_debug, store_detailed_debug_info_on_failure: store_hash_raw_data_for_debug,
full_snapshot: None, full_snapshot: None,
enable_rehashing: true,
}, },
None, None,
)?; )?;
@ -11911,6 +11920,7 @@ pub mod tests {
rent_collector: &RENT_COLLECTOR, rent_collector: &RENT_COLLECTOR,
store_detailed_debug_info_on_failure: false, store_detailed_debug_info_on_failure: false,
full_snapshot: None, full_snapshot: None,
enable_rehashing: true,
} }
} }
} }

View File

@ -54,6 +54,8 @@ pub struct CalcAccountsHashConfig<'a> {
pub rent_collector: &'a RentCollector, pub rent_collector: &'a RentCollector,
/// used for tracking down hash mismatches after the fact /// used for tracking down hash mismatches after the fact
pub store_detailed_debug_info_on_failure: bool, pub store_detailed_debug_info_on_failure: bool,
/// true if hash calculation can rehash based on skipped rewrites
pub enable_rehashing: bool,
/// `Some` if this is an incremental snapshot which only hashes slots since the base full snapshot /// `Some` if this is an incremental snapshot which only hashes slots since the base full snapshot
pub full_snapshot: Option<FullSnapshotAccountsHashInfo>, pub full_snapshot: Option<FullSnapshotAccountsHashInfo>,
} }