From 767c89526ad3df32718e549a35d1406e84fa8ab5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 21:18:59 +0000 Subject: [PATCH] add validator flag no-accounts-db-index-hashing (bp #15350) (#15413) * add validator flag no-accounts-db-index-hashing (#15350) * add validator flag no_accounts_db_index_hashing * add validator flag no_accounts_db_index_hashing (cherry picked from commit ba02452d7556306fd46e6d37f1d9eb36b93ac7ef) # Conflicts: # runtime/src/accounts_background_service.rs * fix merge error Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com> Co-authored-by: Jeff Washington (jwash) --- core/src/tvu.rs | 2 ++ core/src/validator.rs | 3 +++ core/tests/snapshots.rs | 2 +- runtime/src/accounts_background_service.rs | 24 +++++++++++++++------- validator/src/main.rs | 6 ++++++ 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/core/src/tvu.rs b/core/src/tvu.rs index 2364a3421c..6074a01118 100644 --- a/core/src/tvu.rs +++ b/core/src/tvu.rs @@ -80,6 +80,7 @@ pub struct TvuConfig { pub accounts_hash_fault_injection_slots: u64, pub accounts_db_caching_enabled: bool, pub test_hash_calculation: bool, + pub use_index_hash_calculation: bool, pub rocksdb_compaction_interval: Option, pub rocksdb_max_compaction_jitter: Option, } @@ -282,6 +283,7 @@ impl Tvu { accounts_background_request_handler, tvu_config.accounts_db_caching_enabled, tvu_config.test_hash_calculation, + tvu_config.use_index_hash_calculation, ); Tvu { diff --git a/core/src/validator.rs b/core/src/validator.rs index 2964d34098..3bcaad773d 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -124,6 +124,7 @@ pub struct ValidatorConfig { pub accounts_db_caching_enabled: bool, pub warp_slot: Option, pub accounts_db_test_hash_calculation: bool, + pub accounts_db_use_index_hash_calculation: bool, } impl Default for ValidatorConfig { @@ -174,6 +175,7 @@ impl Default for ValidatorConfig { accounts_db_caching_enabled: false, warp_slot: None, accounts_db_test_hash_calculation: false, + accounts_db_use_index_hash_calculation: true, } } } @@ -648,6 +650,7 @@ impl Validator { accounts_hash_fault_injection_slots: config.accounts_hash_fault_injection_slots, accounts_db_caching_enabled: config.accounts_db_caching_enabled, test_hash_calculation: config.accounts_db_test_hash_calculation, + use_index_hash_calculation: config.accounts_db_use_index_hash_calculation, rocksdb_compaction_interval: config.rocksdb_compaction_interval, rocksdb_max_compaction_jitter: config.rocksdb_compaction_interval, }, diff --git a/core/tests/snapshots.rs b/core/tests/snapshots.rs index ed091d0c4d..9196437b3d 100644 --- a/core/tests/snapshots.rs +++ b/core/tests/snapshots.rs @@ -220,7 +220,7 @@ mod tests { // set_root should send a snapshot request bank_forks.set_root(bank.slot(), &request_sender, None); bank.update_accounts_hash(); - snapshot_request_handler.handle_snapshot_requests(false, false); + snapshot_request_handler.handle_snapshot_requests(false, false, false); } } diff --git a/runtime/src/accounts_background_service.rs b/runtime/src/accounts_background_service.rs index 13eabeb645..5cb74a8856 100644 --- a/runtime/src/accounts_background_service.rs +++ b/runtime/src/accounts_background_service.rs @@ -81,6 +81,7 @@ impl SnapshotRequestHandler { &self, accounts_db_caching_enabled: bool, test_hash_calculation: bool, + use_index_hash_calculation: bool, ) -> Option { self.snapshot_request_receiver .try_iter() @@ -122,9 +123,10 @@ impl SnapshotRequestHandler { let mut hash_time = Measure::start("hash_time"); let mut hash_for_testing = None; - const USE_INDEX: bool = true; - snapshot_root_bank - .update_accounts_hash_with_index_option(!USE_INDEX, test_hash_calculation); + snapshot_root_bank.update_accounts_hash_with_index_option( + !use_index_hash_calculation, + test_hash_calculation, + ); if test_hash_calculation { hash_for_testing = Some(snapshot_root_bank.get_accounts_hash()); } @@ -231,12 +233,16 @@ impl ABSRequestHandler { &self, accounts_db_caching_enabled: bool, test_hash_calculation: bool, + use_index_hash_calculation: bool, ) -> Option { self.snapshot_request_handler .as_ref() .and_then(|snapshot_request_handler| { - snapshot_request_handler - .handle_snapshot_requests(accounts_db_caching_enabled, test_hash_calculation) + snapshot_request_handler.handle_snapshot_requests( + accounts_db_caching_enabled, + test_hash_calculation, + use_index_hash_calculation, + ) }) } @@ -262,6 +268,7 @@ impl AccountsBackgroundService { request_handler: ABSRequestHandler, accounts_db_caching_enabled: bool, test_hash_calculation: bool, + use_index_hash_calculation: bool, ) -> Self { info!("AccountsBackgroundService active"); let exit = exit.clone(); @@ -304,8 +311,11 @@ impl AccountsBackgroundService { // request for `N` to the snapshot request channel before setting a root `R > N`, and // snapshot_request_handler.handle_requests() will always look for the latest // available snapshot in the channel. - let snapshot_block_height = request_handler - .handle_snapshot_requests(accounts_db_caching_enabled, test_hash_calculation); + let snapshot_block_height = request_handler.handle_snapshot_requests( + accounts_db_caching_enabled, + test_hash_calculation, + use_index_hash_calculation, + ); if accounts_db_caching_enabled { // Note that the flush will do an internal clean of the // cache up to bank.slot(), so should be safe as long diff --git a/validator/src/main.rs b/validator/src/main.rs index b8d21ce326..2d88535a86 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -1438,6 +1438,11 @@ pub fn main() { .long("accounts-db-test-hash-calculation") .help("Enables testing of hash calculation using stores in AccountsHashVerifier. This has a computational cost."), ) + .arg( + Arg::with_name("no_accounts_db_index_hashing") + .long("no-accounts-db-index-hashing") + .help("Disables the use of the index in hash calculation in AccountsHashVerifier/Accounts Background Service."), + ) .arg( // legacy nop argument Arg::with_name("accounts_db_caching_enabled") @@ -1649,6 +1654,7 @@ pub fn main() { account_indexes, accounts_db_caching_enabled: !matches.is_present("no_accounts_db_caching"), accounts_db_test_hash_calculation: matches.is_present("accounts_db_test_hash_calculation"), + accounts_db_use_index_hash_calculation: !matches.is_present("no_accounts_db_index_hashing"), ..ValidatorConfig::default() };