* add validator option --accounts-db-skip-shrink (#19028)
* add validator option --accounts-db-skip-shrink
* typo
(cherry picked from commit 3280ae3e9f
)
# Conflicts:
# core/tests/snapshots.rs
# ledger/src/bank_forks_utils.rs
# ledger/src/blockstore_processor.rs
# replica-node/src/replica_node.rs
# runtime/src/snapshot_utils.rs
* Fix conflicts
Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
@@ -135,6 +135,7 @@ pub struct ValidatorConfig {
|
||||
pub accounts_db_caching_enabled: bool,
|
||||
pub warp_slot: Option<Slot>,
|
||||
pub accounts_db_test_hash_calculation: bool,
|
||||
pub accounts_db_skip_shrink: bool,
|
||||
pub accounts_db_use_index_hash_calculation: bool,
|
||||
pub tpu_coalesce_ms: u64,
|
||||
pub validator_exit: Arc<RwLock<Exit>>,
|
||||
@@ -191,6 +192,7 @@ impl Default for ValidatorConfig {
|
||||
accounts_db_caching_enabled: false,
|
||||
warp_slot: None,
|
||||
accounts_db_test_hash_calculation: false,
|
||||
accounts_db_skip_shrink: false,
|
||||
accounts_db_use_index_hash_calculation: true,
|
||||
tpu_coalesce_ms: DEFAULT_TPU_COALESCE_MS,
|
||||
validator_exit: Arc::new(RwLock::new(Exit::default())),
|
||||
@@ -1112,6 +1114,8 @@ fn new_banks_from_ledger(
|
||||
account_indexes: config.account_indexes.clone(),
|
||||
accounts_db_caching_enabled: config.accounts_db_caching_enabled,
|
||||
shrink_ratio: config.accounts_shrink_ratio,
|
||||
accounts_db_test_hash_calculation: config.accounts_db_test_hash_calculation,
|
||||
accounts_db_skip_shrink: config.accounts_db_skip_shrink,
|
||||
..blockstore_processor::ProcessOptions::default()
|
||||
};
|
||||
|
||||
|
@@ -171,6 +171,7 @@ mod tests {
|
||||
None,
|
||||
accounts_db::AccountShrinkThreshold::default(),
|
||||
check_hash_calculation,
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@@ -144,6 +144,7 @@ fn load_from_snapshot(
|
||||
process_options.limit_load_slot_count_from_snapshot,
|
||||
process_options.shrink_ratio,
|
||||
process_options.accounts_db_test_hash_calculation,
|
||||
process_options.accounts_db_skip_shrink,
|
||||
)
|
||||
.expect("Load from snapshot failed");
|
||||
if let Some(shrink_paths) = shrink_paths {
|
||||
|
@@ -377,6 +377,7 @@ pub struct ProcessOptions {
|
||||
pub limit_load_slot_count_from_snapshot: Option<usize>,
|
||||
pub allow_dead_slots: bool,
|
||||
pub accounts_db_test_hash_calculation: bool,
|
||||
pub accounts_db_skip_shrink: bool,
|
||||
pub shrink_ratio: AccountShrinkThreshold,
|
||||
}
|
||||
|
||||
|
@@ -50,6 +50,7 @@ pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig {
|
||||
accounts_db_caching_enabled: config.accounts_db_caching_enabled,
|
||||
warp_slot: config.warp_slot,
|
||||
accounts_db_test_hash_calculation: config.accounts_db_test_hash_calculation,
|
||||
accounts_db_skip_shrink: config.accounts_db_skip_shrink,
|
||||
accounts_db_use_index_hash_calculation: config.accounts_db_use_index_hash_calculation,
|
||||
tpu_coalesce_ms: config.tpu_coalesce_ms,
|
||||
validator_exit: Arc::new(RwLock::new(Exit::default())),
|
||||
|
@@ -4759,7 +4759,11 @@ impl Bank {
|
||||
|
||||
/// A snapshot bank should be purged of 0 lamport accounts which are not part of the hash
|
||||
/// calculation and could shield other real accounts.
|
||||
pub fn verify_snapshot_bank(&self, test_hash_calculation: bool) -> bool {
|
||||
pub fn verify_snapshot_bank(
|
||||
&self,
|
||||
test_hash_calculation: bool,
|
||||
accounts_db_skip_shrink: bool,
|
||||
) -> bool {
|
||||
info!("cleaning..");
|
||||
let mut clean_time = Measure::start("clean");
|
||||
if self.slot() > 0 {
|
||||
@@ -4767,9 +4771,9 @@ impl Bank {
|
||||
}
|
||||
clean_time.stop();
|
||||
|
||||
info!("shrinking..");
|
||||
let mut shrink_all_slots_time = Measure::start("shrink_all_slots");
|
||||
if self.slot() > 0 {
|
||||
if !accounts_db_skip_shrink && self.slot() > 0 {
|
||||
info!("shrinking..");
|
||||
self.shrink_all_slots(true);
|
||||
}
|
||||
shrink_all_slots_time.stop();
|
||||
@@ -8557,11 +8561,11 @@ pub(crate) mod tests {
|
||||
bank.transfer(1_000, &mint_keypair, &pubkey).unwrap();
|
||||
bank.freeze();
|
||||
bank.update_accounts_hash();
|
||||
assert!(bank.verify_snapshot_bank(true));
|
||||
assert!(bank.verify_snapshot_bank(true, false));
|
||||
|
||||
// tamper the bank after freeze!
|
||||
bank.increment_signature_count(1);
|
||||
assert!(!bank.verify_snapshot_bank(true));
|
||||
assert!(!bank.verify_snapshot_bank(true, false));
|
||||
}
|
||||
|
||||
// Test that two bank forks with the same accounts should not hash to the same value.
|
||||
|
@@ -632,6 +632,7 @@ pub fn bank_from_archive<P: AsRef<Path> + std::marker::Sync>(
|
||||
limit_load_slot_count_from_snapshot: Option<usize>,
|
||||
shrink_ratio: AccountShrinkThreshold,
|
||||
test_hash_calculation: bool,
|
||||
accounts_db_skip_shrink: bool,
|
||||
) -> Result<(Bank, BankFromArchiveTimings)> {
|
||||
let unpack_dir = tempfile::Builder::new()
|
||||
.prefix(TMP_SNAPSHOT_PREFIX)
|
||||
@@ -676,7 +677,7 @@ pub fn bank_from_archive<P: AsRef<Path> + std::marker::Sync>(
|
||||
measure.stop();
|
||||
|
||||
let mut verify = Measure::start("verify");
|
||||
if !bank.verify_snapshot_bank(test_hash_calculation)
|
||||
if !bank.verify_snapshot_bank(test_hash_calculation, accounts_db_skip_shrink)
|
||||
&& limit_load_slot_count_from_snapshot.is_none()
|
||||
{
|
||||
panic!("Snapshot bank for slot {} failed to verify", bank.slot());
|
||||
|
@@ -1802,6 +1802,12 @@ pub fn main() {
|
||||
.long("no-accounts-db-caching")
|
||||
.help("Disables accounts caching"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("accounts_db_skip_shrink")
|
||||
.long("accounts-db-skip-shrink")
|
||||
.help("Enables faster starting of validators by skipping shrink. \
|
||||
This option is for use during testing."),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("accounts_db_test_hash_calculation")
|
||||
.long("accounts-db-test-hash-calculation")
|
||||
@@ -2318,6 +2324,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_skip_shrink: matches.is_present("accounts_db_skip_shrink"),
|
||||
accounts_db_use_index_hash_calculation: matches.is_present("accounts_db_index_hashing"),
|
||||
tpu_coalesce_ms,
|
||||
no_wait_for_vote_to_start_leader: matches.is_present("no_wait_for_vote_to_start_leader"),
|
||||
|
Reference in New Issue
Block a user