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

View File

@ -195,6 +195,7 @@ impl SnapshotRequestHandler {
rent_collector: snapshot_root_bank.rent_collector(),
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
enable_rehashing: true,
},
).unwrap();
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 loaded_hash = loaded_account.loaded_hash();
let new_hash = ExpectedRentCollection::maybe_rehash_skipped_rewrite(
loaded_account,
&loaded_hash,
pubkey,
self.current_slot,
self.config.epoch_schedule,
self.config.rent_collector,
self.stats,
&self.max_slot_info,
self.find_unskipped_slot,
self.filler_account_suffix,
);
let new_hash = self
.config
.enable_rehashing
.then(|| {
ExpectedRentCollection::maybe_rehash_skipped_rewrite(
loaded_account,
&loaded_hash,
pubkey,
self.current_slot,
self.config.epoch_schedule,
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 source_item = CalculateHashIntermediate::new(loaded_hash, balance, *pubkey);
@ -6433,18 +6439,19 @@ impl AccountsDb {
self.find_unskipped_slot(slot, config.ancestors)
};
let loaded_hash = loaded_account.loaded_hash();
let new_hash = ExpectedRentCollection::maybe_rehash_skipped_rewrite(
&loaded_account,
&loaded_hash,
pubkey,
*slot,
config.epoch_schedule,
config.rent_collector,
&stats,
&max_slot_info,
find_unskipped_slot,
self.filler_account_suffix.as_ref(),
);
let new_hash = config.enable_rehashing
.then(|| ExpectedRentCollection::maybe_rehash_skipped_rewrite(
&loaded_account,
&loaded_hash,
pubkey,
*slot,
config.epoch_schedule,
config.rent_collector,
&stats,
&max_slot_info,
find_unskipped_slot,
self.filler_account_suffix.as_ref(),
)).flatten();
let loaded_hash = new_hash.unwrap_or(loaded_hash);
let balance = loaded_account.lamports();
if config.check_hash && !self.is_filler_account(pubkey) { // this will not be supported anymore
@ -6997,6 +7004,7 @@ impl AccountsDb {
rent_collector,
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
enable_rehashing: true,
},
expected_capitalization,
)
@ -7295,6 +7303,7 @@ impl AccountsDb {
rent_collector,
store_detailed_debug_info_on_failure: store_hash_raw_data_for_debug,
full_snapshot: None,
enable_rehashing: true,
},
None,
)?;
@ -11911,6 +11920,7 @@ pub mod tests {
rent_collector: &RENT_COLLECTOR,
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
enable_rehashing: true,
}
}
}

View File

@ -54,6 +54,8 @@ 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,
/// 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
pub full_snapshot: Option<FullSnapshotAccountsHashInfo>,
}