add validator option --accounts-db-skip-shrink (#19028)
* add validator option --accounts-db-skip-shrink * typo
This commit is contained in:
parent
68cc71409e
commit
3280ae3e9f
|
@ -138,6 +138,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_skip_shrink: bool,
|
||||||
pub accounts_db_use_index_hash_calculation: bool,
|
pub accounts_db_use_index_hash_calculation: bool,
|
||||||
pub tpu_coalesce_ms: u64,
|
pub tpu_coalesce_ms: u64,
|
||||||
pub validator_exit: Arc<RwLock<Exit>>,
|
pub validator_exit: Arc<RwLock<Exit>>,
|
||||||
|
@ -194,6 +195,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_skip_shrink: false,
|
||||||
accounts_db_use_index_hash_calculation: true,
|
accounts_db_use_index_hash_calculation: true,
|
||||||
tpu_coalesce_ms: DEFAULT_TPU_COALESCE_MS,
|
tpu_coalesce_ms: DEFAULT_TPU_COALESCE_MS,
|
||||||
validator_exit: Arc::new(RwLock::new(Exit::default())),
|
validator_exit: Arc::new(RwLock::new(Exit::default())),
|
||||||
|
@ -1131,6 +1133,8 @@ fn new_banks_from_ledger(
|
||||||
account_indexes: config.account_indexes.clone(),
|
account_indexes: config.account_indexes.clone(),
|
||||||
accounts_db_caching_enabled: config.accounts_db_caching_enabled,
|
accounts_db_caching_enabled: config.accounts_db_caching_enabled,
|
||||||
shrink_ratio: config.accounts_shrink_ratio,
|
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()
|
..blockstore_processor::ProcessOptions::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,7 @@ mod tests {
|
||||||
accounts_db::AccountShrinkThreshold::default(),
|
accounts_db::AccountShrinkThreshold::default(),
|
||||||
check_hash_calculation,
|
check_hash_calculation,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -842,6 +843,7 @@ mod tests {
|
||||||
accounts_db::AccountShrinkThreshold::default(),
|
accounts_db::AccountShrinkThreshold::default(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
|
|
|
@ -143,6 +143,7 @@ fn load_from_snapshot(
|
||||||
process_options.limit_load_slot_count_from_snapshot,
|
process_options.limit_load_slot_count_from_snapshot,
|
||||||
process_options.shrink_ratio,
|
process_options.shrink_ratio,
|
||||||
process_options.accounts_db_test_hash_calculation,
|
process_options.accounts_db_test_hash_calculation,
|
||||||
|
process_options.accounts_db_skip_shrink,
|
||||||
process_options.verify_index,
|
process_options.verify_index,
|
||||||
)
|
)
|
||||||
.expect("Load from snapshot failed");
|
.expect("Load from snapshot failed");
|
||||||
|
|
|
@ -384,6 +384,7 @@ pub struct ProcessOptions {
|
||||||
pub limit_load_slot_count_from_snapshot: Option<usize>,
|
pub limit_load_slot_count_from_snapshot: Option<usize>,
|
||||||
pub allow_dead_slots: bool,
|
pub allow_dead_slots: bool,
|
||||||
pub accounts_db_test_hash_calculation: bool,
|
pub accounts_db_test_hash_calculation: bool,
|
||||||
|
pub accounts_db_skip_shrink: bool,
|
||||||
pub verify_index: bool,
|
pub verify_index: bool,
|
||||||
pub shrink_ratio: AccountShrinkThreshold,
|
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,
|
accounts_db_caching_enabled: config.accounts_db_caching_enabled,
|
||||||
warp_slot: config.warp_slot,
|
warp_slot: config.warp_slot,
|
||||||
accounts_db_test_hash_calculation: config.accounts_db_test_hash_calculation,
|
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,
|
accounts_db_use_index_hash_calculation: config.accounts_db_use_index_hash_calculation,
|
||||||
tpu_coalesce_ms: config.tpu_coalesce_ms,
|
tpu_coalesce_ms: config.tpu_coalesce_ms,
|
||||||
validator_exit: Arc::new(RwLock::new(Exit::default())),
|
validator_exit: Arc::new(RwLock::new(Exit::default())),
|
||||||
|
|
|
@ -126,6 +126,7 @@ fn initialize_from_snapshot(
|
||||||
process_options.limit_load_slot_count_from_snapshot,
|
process_options.limit_load_slot_count_from_snapshot,
|
||||||
process_options.shrink_ratio,
|
process_options.shrink_ratio,
|
||||||
process_options.accounts_db_test_hash_calculation,
|
process_options.accounts_db_test_hash_calculation,
|
||||||
|
false,
|
||||||
process_options.verify_index,
|
process_options.verify_index,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -4876,7 +4876,11 @@ impl Bank {
|
||||||
|
|
||||||
/// A snapshot bank should be purged of 0 lamport accounts which are not part of the hash
|
/// A snapshot bank should be purged of 0 lamport accounts which are not part of the hash
|
||||||
/// calculation and could shield other real accounts.
|
/// 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..");
|
info!("cleaning..");
|
||||||
let mut clean_time = Measure::start("clean");
|
let mut clean_time = Measure::start("clean");
|
||||||
if self.slot() > 0 {
|
if self.slot() > 0 {
|
||||||
|
@ -4884,9 +4888,9 @@ impl Bank {
|
||||||
}
|
}
|
||||||
clean_time.stop();
|
clean_time.stop();
|
||||||
|
|
||||||
info!("shrinking..");
|
|
||||||
let mut shrink_all_slots_time = Measure::start("shrink_all_slots");
|
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);
|
self.shrink_all_slots(true);
|
||||||
}
|
}
|
||||||
shrink_all_slots_time.stop();
|
shrink_all_slots_time.stop();
|
||||||
|
@ -8674,11 +8678,11 @@ pub(crate) mod tests {
|
||||||
bank.transfer(1_000, &mint_keypair, &pubkey).unwrap();
|
bank.transfer(1_000, &mint_keypair, &pubkey).unwrap();
|
||||||
bank.freeze();
|
bank.freeze();
|
||||||
bank.update_accounts_hash();
|
bank.update_accounts_hash();
|
||||||
assert!(bank.verify_snapshot_bank(true));
|
assert!(bank.verify_snapshot_bank(true, false));
|
||||||
|
|
||||||
// tamper the bank after freeze!
|
// tamper the bank after freeze!
|
||||||
bank.increment_signature_count(1);
|
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.
|
// Test that two bank forks with the same accounts should not hash to the same value.
|
||||||
|
|
|
@ -844,6 +844,7 @@ pub fn bank_from_snapshot_archives<P>(
|
||||||
limit_load_slot_count_from_snapshot: Option<usize>,
|
limit_load_slot_count_from_snapshot: Option<usize>,
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
shrink_ratio: AccountShrinkThreshold,
|
||||||
test_hash_calculation: bool,
|
test_hash_calculation: bool,
|
||||||
|
accounts_db_skip_shrink: bool,
|
||||||
verify_index: bool,
|
verify_index: bool,
|
||||||
) -> Result<(Bank, BankFromArchiveTimings)>
|
) -> Result<(Bank, BankFromArchiveTimings)>
|
||||||
where
|
where
|
||||||
|
@ -916,7 +917,7 @@ where
|
||||||
info!("{}", measure_rebuild);
|
info!("{}", measure_rebuild);
|
||||||
|
|
||||||
let mut measure_verify = Measure::start("verify");
|
let mut measure_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()
|
&& limit_load_slot_count_from_snapshot.is_none()
|
||||||
{
|
{
|
||||||
panic!("Snapshot bank for slot {} failed to verify", bank.slot());
|
panic!("Snapshot bank for slot {} failed to verify", bank.slot());
|
||||||
|
@ -2497,6 +2498,7 @@ mod tests {
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -2587,6 +2589,7 @@ mod tests {
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -2696,6 +2699,7 @@ mod tests {
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -1812,6 +1812,12 @@ pub fn main() {
|
||||||
.long("no-accounts-db-caching")
|
.long("no-accounts-db-caching")
|
||||||
.help("Disables accounts 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(
|
||||||
Arg::with_name("accounts_db_test_hash_calculation")
|
Arg::with_name("accounts_db_test_hash_calculation")
|
||||||
.long("accounts-db-test-hash-calculation")
|
.long("accounts-db-test-hash-calculation")
|
||||||
|
@ -2379,6 +2385,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_skip_shrink: matches.is_present("accounts_db_skip_shrink"),
|
||||||
accounts_db_use_index_hash_calculation: matches.is_present("accounts_db_index_hashing"),
|
accounts_db_use_index_hash_calculation: matches.is_present("accounts_db_index_hashing"),
|
||||||
tpu_coalesce_ms,
|
tpu_coalesce_ms,
|
||||||
no_wait_for_vote_to_start_leader: matches.is_present("no_wait_for_vote_to_start_leader"),
|
no_wait_for_vote_to_start_leader: matches.is_present("no_wait_for_vote_to_start_leader"),
|
||||||
|
|
Loading…
Reference in New Issue