Skip to content

Commit

Permalink
pass include_slot_in_hash through hash calcs to allow rehashing if ha…
Browse files Browse the repository at this point in the history
…sh 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
  • Loading branch information
jeffwashington authored May 11, 2023
1 parent d9cfb31 commit 122b05b
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 37 deletions.
4 changes: 3 additions & 1 deletion accounts-bench/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(clippy::integer_arithmetic)]

#[macro_use]
extern crate log;
use {
Expand All @@ -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,
Expand Down Expand Up @@ -133,6 +134,7 @@ fn main() {
&EpochSchedule::default(),
&RentCollector::default(),
true,
INCLUDE_SLOT_IN_HASH_TESTS,
);
time_store.stop();
if results != results_store {
Expand Down
2 changes: 2 additions & 0 deletions core/src/accounts_hash_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!(
Expand Down
5 changes: 4 additions & 1 deletion core/tests/epoch_accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion runtime/benches/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
}
))
});
Expand Down
1 change: 1 addition & 0 deletions runtime/src/accounts_background_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 122b05b

Please sign in to comment.