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
This commit is contained in:
Jeff Washington (jwash) 2021-02-16 15:13:48 -06:00 committed by GitHub
parent f79c9d4094
commit ba02452d75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 8 deletions

View File

@ -80,6 +80,7 @@ pub struct TvuConfig {
pub accounts_hash_fault_injection_slots: u64, pub accounts_hash_fault_injection_slots: u64,
pub accounts_db_caching_enabled: bool, pub accounts_db_caching_enabled: bool,
pub test_hash_calculation: bool, pub test_hash_calculation: bool,
pub use_index_hash_calculation: bool,
pub rocksdb_compaction_interval: Option<u64>, pub rocksdb_compaction_interval: Option<u64>,
pub rocksdb_max_compaction_jitter: Option<u64>, pub rocksdb_max_compaction_jitter: Option<u64>,
} }
@ -282,6 +283,7 @@ impl Tvu {
accounts_background_request_handler, accounts_background_request_handler,
tvu_config.accounts_db_caching_enabled, tvu_config.accounts_db_caching_enabled,
tvu_config.test_hash_calculation, tvu_config.test_hash_calculation,
tvu_config.use_index_hash_calculation,
); );
Tvu { Tvu {

View File

@ -124,6 +124,7 @@ pub struct ValidatorConfig {
pub accounts_db_caching_enabled: bool, pub accounts_db_caching_enabled: bool,
pub warp_slot: Option<Slot>, pub warp_slot: Option<Slot>,
pub accounts_db_test_hash_calculation: bool, pub accounts_db_test_hash_calculation: bool,
pub accounts_db_use_index_hash_calculation: bool,
} }
impl Default for ValidatorConfig { impl Default for ValidatorConfig {
@ -174,6 +175,7 @@ impl Default for ValidatorConfig {
accounts_db_caching_enabled: false, accounts_db_caching_enabled: false,
warp_slot: None, warp_slot: None,
accounts_db_test_hash_calculation: false, 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_hash_fault_injection_slots: config.accounts_hash_fault_injection_slots,
accounts_db_caching_enabled: config.accounts_db_caching_enabled, accounts_db_caching_enabled: config.accounts_db_caching_enabled,
test_hash_calculation: config.accounts_db_test_hash_calculation, 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_compaction_interval: config.rocksdb_compaction_interval,
rocksdb_max_compaction_jitter: config.rocksdb_compaction_interval, rocksdb_max_compaction_jitter: config.rocksdb_compaction_interval,
}, },

View File

@ -219,7 +219,7 @@ mod tests {
// set_root should send a snapshot request // set_root should send a snapshot request
bank_forks.set_root(bank.slot(), &request_sender, None); bank_forks.set_root(bank.slot(), &request_sender, None);
bank.update_accounts_hash(); bank.update_accounts_hash();
snapshot_request_handler.handle_snapshot_requests(false, false); snapshot_request_handler.handle_snapshot_requests(false, false, false);
} }
} }

View File

@ -81,6 +81,7 @@ impl SnapshotRequestHandler {
&self, &self,
accounts_db_caching_enabled: bool, accounts_db_caching_enabled: bool,
test_hash_calculation: bool, test_hash_calculation: bool,
use_index_hash_calculation: bool,
) -> Option<u64> { ) -> Option<u64> {
self.snapshot_request_receiver self.snapshot_request_receiver
.try_iter() .try_iter()
@ -129,9 +130,10 @@ impl SnapshotRequestHandler {
flush_accounts_cache_time.stop(); flush_accounts_cache_time.stop();
let mut hash_time = Measure::start("hash_time"); let mut hash_time = Measure::start("hash_time");
const USE_INDEX: bool = true; let this_hash = snapshot_root_bank.update_accounts_hash_with_index_option(
let this_hash = snapshot_root_bank use_index_hash_calculation,
.update_accounts_hash_with_index_option(USE_INDEX, test_hash_calculation); test_hash_calculation,
);
let hash_for_testing = if test_hash_calculation { let hash_for_testing = if test_hash_calculation {
assert_eq!(previous_hash, this_hash); assert_eq!(previous_hash, this_hash);
Some(snapshot_root_bank.get_accounts_hash()) Some(snapshot_root_bank.get_accounts_hash())
@ -241,12 +243,16 @@ impl ABSRequestHandler {
&self, &self,
accounts_db_caching_enabled: bool, accounts_db_caching_enabled: bool,
test_hash_calculation: bool, test_hash_calculation: bool,
use_index_hash_calculation: bool,
) -> Option<u64> { ) -> Option<u64> {
self.snapshot_request_handler self.snapshot_request_handler
.as_ref() .as_ref()
.and_then(|snapshot_request_handler| { .and_then(|snapshot_request_handler| {
snapshot_request_handler snapshot_request_handler.handle_snapshot_requests(
.handle_snapshot_requests(accounts_db_caching_enabled, test_hash_calculation) accounts_db_caching_enabled,
test_hash_calculation,
use_index_hash_calculation,
)
}) })
} }
@ -272,6 +278,7 @@ impl AccountsBackgroundService {
request_handler: ABSRequestHandler, request_handler: ABSRequestHandler,
accounts_db_caching_enabled: bool, accounts_db_caching_enabled: bool,
test_hash_calculation: bool, test_hash_calculation: bool,
use_index_hash_calculation: bool,
) -> Self { ) -> Self {
info!("AccountsBackgroundService active"); info!("AccountsBackgroundService active");
let exit = exit.clone(); let exit = exit.clone();
@ -314,8 +321,11 @@ impl AccountsBackgroundService {
// request for `N` to the snapshot request channel before setting a root `R > N`, and // 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 // snapshot_request_handler.handle_requests() will always look for the latest
// available snapshot in the channel. // available snapshot in the channel.
let snapshot_block_height = request_handler let snapshot_block_height = request_handler.handle_snapshot_requests(
.handle_snapshot_requests(accounts_db_caching_enabled, test_hash_calculation); accounts_db_caching_enabled,
test_hash_calculation,
use_index_hash_calculation,
);
if accounts_db_caching_enabled { if accounts_db_caching_enabled {
// Note that the flush will do an internal clean of the // Note that the flush will do an internal clean of the
// cache up to bank.slot(), so should be safe as long // cache up to bank.slot(), so should be safe as long

View File

@ -1440,6 +1440,11 @@ pub fn main() {
.long("accounts-db-test-hash-calculation") .long("accounts-db-test-hash-calculation")
.help("Enables testing of hash calculation using stores in AccountsHashVerifier. This has a computational cost."), .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( .arg(
// legacy nop argument // legacy nop argument
Arg::with_name("accounts_db_caching_enabled") Arg::with_name("accounts_db_caching_enabled")
@ -1656,6 +1661,7 @@ pub fn main() {
account_indexes, account_indexes,
accounts_db_caching_enabled: !matches.is_present("no_accounts_db_caching"), 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_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() ..ValidatorConfig::default()
}; };