Skip to content

Commit

Permalink
feature: on accounts hash calculation, do not try to rehash accounts (#…
Browse files Browse the repository at this point in the history
…28935)

* add feature #28934

* feature: on accounts hash calculation, do not try to rehash accounts #28934

* Delete syscalls.txt

* retain feature 28541

Co-authored-by: Brooks Prumo <brooks@prumo.org>
  • Loading branch information
jeffwashington and brooksprumo committed Nov 28, 2022
1 parent 103d069 commit af329cf
Show file tree
Hide file tree
Showing 13 changed files with 1,435 additions and 8 deletions.
4 changes: 3 additions & 1 deletion accounts-bench/src/main.rs
Expand Up @@ -10,7 +10,7 @@ use {
test_utils::{create_test_accounts, update_accounts_bench},
Accounts,
},
accounts_db::AccountShrinkThreshold,
accounts_db::{AccountShrinkThreshold, TEST_DISABLE_REHASH_FOR_RENT_EPOCH},
accounts_index::AccountSecondaryIndexes,
ancestors::Ancestors,
rent_collector::RentCollector,
Expand Down Expand Up @@ -125,6 +125,7 @@ fn main() {
&ancestors,
&EpochSchedule::default(),
&RentCollector::default(),
TEST_DISABLE_REHASH_FOR_RENT_EPOCH,
);
time.stop();
let mut time_store = Measure::start("hash using store");
Expand All @@ -138,6 +139,7 @@ fn main() {
&EpochSchedule::default(),
&RentCollector::default(),
false,
TEST_DISABLE_REHASH_FOR_RENT_EPOCH,
);
time_store.stop();
if results != results_store {
Expand Down
5 changes: 5 additions & 0 deletions core/src/accounts_hash_verifier.rs
Expand Up @@ -143,6 +143,7 @@ impl AccountsHashVerifier {
rent_collector: &accounts_package.rent_collector,
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
disable_rehash_for_rent_epoch: accounts_package.disable_rehash_for_rent_epoch,
},
&sorted_storages,
timings,
Expand All @@ -166,6 +167,8 @@ 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,
disable_rehash_for_rent_epoch: accounts_package
.disable_rehash_for_rent_epoch,
},
&sorted_storages,
HashStats::default(),
Expand Down Expand Up @@ -336,6 +339,7 @@ mod tests {
super::*,
solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo},
solana_runtime::{
accounts_db::TEST_DISABLE_REHASH_FOR_RENT_EPOCH,
rent_collector::RentCollector,
snapshot_utils::{ArchiveFormat, SnapshotVersion},
},
Expand Down Expand Up @@ -429,6 +433,7 @@ mod tests {
accounts: Arc::clone(&accounts),
epoch_schedule: EpochSchedule::default(),
rent_collector: RentCollector::default(),
disable_rehash_for_rent_epoch: TEST_DISABLE_REHASH_FOR_RENT_EPOCH,
};

AccountsHashVerifier::process_accounts_package(
Expand Down
5 changes: 4 additions & 1 deletion runtime/benches/accounts.rs
Expand Up @@ -9,7 +9,7 @@ use {
rayon::iter::{IntoParallelRefIterator, ParallelIterator},
solana_runtime::{
accounts::{test_utils::create_test_accounts, AccountAddressFilter, Accounts},
accounts_db::AccountShrinkThreshold,
accounts_db::{AccountShrinkThreshold, TEST_DISABLE_REHASH_FOR_RENT_EPOCH},
accounts_index::{AccountSecondaryIndexes, ScanConfig},
ancestors::Ancestors,
bank::*,
Expand Down Expand Up @@ -114,6 +114,7 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
&ancestors,
&EpochSchedule::default(),
&RentCollector::default(),
TEST_DISABLE_REHASH_FOR_RENT_EPOCH,
);
let test_hash_calculation = false;
bencher.iter(|| {
Expand All @@ -128,6 +129,7 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
false,
false,
false,
TEST_DISABLE_REHASH_FOR_RENT_EPOCH,
))
});
}
Expand All @@ -151,6 +153,7 @@ fn test_update_accounts_hash(bencher: &mut Bencher) {
&ancestors,
&EpochSchedule::default(),
&RentCollector::default(),
TEST_DISABLE_REHASH_FOR_RENT_EPOCH,
);
});
}
Expand Down
4 changes: 4 additions & 0 deletions runtime/src/accounts.rs
Expand Up @@ -814,6 +814,7 @@ impl Accounts {
debug_verify: bool,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
disable_rehash_for_rent_epoch: bool,
) -> u64 {
let use_index = false;
let is_startup = true;
Expand All @@ -828,6 +829,7 @@ impl Accounts {
epoch_schedule,
rent_collector,
is_startup,
disable_rehash_for_rent_epoch,
)
.1
}
Expand All @@ -847,6 +849,7 @@ impl Accounts {
ignore_mismatch: bool,
store_detailed_debug_info: bool,
use_bg_thread_pool: bool,
disable_rehash_for_rent_epoch: bool,
) -> bool {
if let Err(err) = self.accounts_db.verify_bank_hash_and_lamports_new(
slot,
Expand All @@ -859,6 +862,7 @@ impl Accounts {
ignore_mismatch,
store_detailed_debug_info,
use_bg_thread_pool,
disable_rehash_for_rent_epoch,
) {
warn!("verify_bank_hash failed: {:?}, slot: {}", err, slot);
false
Expand Down
1 change: 1 addition & 0 deletions runtime/src/accounts_background_service.rs
Expand Up @@ -244,6 +244,7 @@ impl SnapshotRequestHandler {
rent_collector: snapshot_root_bank.rent_collector(),
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
disable_rehash_for_rent_epoch: snapshot_root_bank.feature_set.is_active(&solana_sdk::feature_set::disable_rehash_for_rent_epoch::id()),
},
).unwrap();
assert_eq!(previous_hash, this_hash);
Expand Down

0 comments on commit af329cf

Please sign in to comment.