From 9e4999ef6adf879dbd4ca49c87315d67c175bede Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 19 Apr 2022 15:06:30 -0700 Subject: [PATCH] Remove halt_at_slot from RuntimeConfig, it's not a runtime concern --- core/src/validator.rs | 7 +++-- ledger-tool/src/main.rs | 36 +++++++------------------- ledger/src/blockstore_processor.rs | 15 ++++------- local-cluster/src/validator_configs.rs | 1 + runtime/src/runtime_config.rs | 3 +-- test-validator/src/lib.rs | 1 - validator/src/main.rs | 2 +- 7 files changed, 22 insertions(+), 43 deletions(-) diff --git a/core/src/validator.rs b/core/src/validator.rs index a9bc188350..004b34acec 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -116,6 +116,7 @@ const MAX_COMPLETED_DATA_SETS_IN_CHANNEL: usize = 100_000; const WAIT_FOR_SUPERMAJORITY_THRESHOLD_PERCENT: u64 = 80; pub struct ValidatorConfig { + pub halt_at_slot: Option, pub expected_genesis_hash: Option, pub expected_bank_hash: Option, pub expected_shred_version: Option, @@ -175,6 +176,7 @@ pub struct ValidatorConfig { impl Default for ValidatorConfig { fn default() -> Self { Self { + halt_at_slot: None, expected_genesis_hash: None, expected_bank_hash: None, expected_shred_version: None, @@ -846,7 +848,7 @@ impl Validator { (None, None, None, None) }; - if config.runtime_config.dev_halt_at_slot.is_some() { + if config.halt_at_slot.is_some() { // Simulate a confirmed root to avoid RPC errors with CommitmentConfig::finalized() and // to ensure RPC endpoints like getConfirmedBlock, which require a confirmed root, work block_commitment_cache @@ -1047,7 +1049,7 @@ impl Validator { validator_exit: config.validator_exit.clone(), cluster_info, bank_forks, - blockstore: blockstore.clone(), + blockstore, geyser_plugin_service, ledger_metric_report_service, accounts_background_service, @@ -1387,6 +1389,7 @@ fn load_blockstore( let process_options = blockstore_processor::ProcessOptions { poh_verify: config.poh_verify, + halt_at_slot: config.halt_at_slot, new_hard_forks: config.new_hard_forks.clone(), debug_keys: config.debug_keys.clone(), account_indexes: config.account_indexes.clone(), diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index dcbe7dcee7..da87856b0b 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -1787,11 +1787,8 @@ fn main() { ("shred-version", Some(arg_matches)) => { let process_options = ProcessOptions { new_hard_forks: hardforks_of(arg_matches, "hard_forks"), + halt_at_slot: Some(0), poh_verify: false, - runtime_config: RuntimeConfig { - dev_halt_at_slot: Some(0), - ..RuntimeConfig::default() - }, ..ProcessOptions::default() }; let genesis_config = open_genesis_config_by(&ledger_path, arg_matches); @@ -1875,11 +1872,8 @@ fn main() { ("bank-hash", Some(arg_matches)) => { let process_options = ProcessOptions { new_hard_forks: hardforks_of(arg_matches, "hard_forks"), + halt_at_slot: Some(0), poh_verify: false, - runtime_config: RuntimeConfig { - dev_halt_at_slot: Some(0), - ..RuntimeConfig::default() - }, ..ProcessOptions::default() }; let genesis_config = open_genesis_config_by(&ledger_path, arg_matches); @@ -2108,6 +2102,7 @@ fn main() { let process_options = ProcessOptions { new_hard_forks: hardforks_of(arg_matches, "hard_forks"), poh_verify: !arg_matches.is_present("skip_poh_verify"), + halt_at_slot: value_t!(arg_matches, "halt_at_slot", Slot).ok(), accounts_db_caching_enabled: !arg_matches.is_present("no_accounts_db_caching"), limit_load_slot_count_from_snapshot: value_t!( arg_matches, @@ -2122,7 +2117,6 @@ fn main() { .is_present("accounts_db_test_hash_calculation"), accounts_db_skip_shrink: arg_matches.is_present("accounts_db_skip_shrink"), runtime_config: RuntimeConfig { - dev_halt_at_slot: value_t!(arg_matches, "halt_at_slot", Slot).ok(), bpf_jit: !matches.is_present("no_bpf_jit"), ..RuntimeConfig::default() }, @@ -2163,11 +2157,8 @@ fn main() { let process_options = ProcessOptions { new_hard_forks: hardforks_of(arg_matches, "hard_forks"), + halt_at_slot: value_t!(arg_matches, "halt_at_slot", Slot).ok(), poh_verify: false, - runtime_config: RuntimeConfig { - dev_halt_at_slot: value_t!(arg_matches, "halt_at_slot", Slot).ok(), - ..RuntimeConfig::default() - }, ..ProcessOptions::default() }; @@ -2294,11 +2285,8 @@ fn main() { &blockstore, ProcessOptions { new_hard_forks, + halt_at_slot: Some(snapshot_slot), poh_verify: false, - runtime_config: RuntimeConfig { - dev_halt_at_slot: Some(snapshot_slot), - ..RuntimeConfig::default() - }, ..ProcessOptions::default() }, snapshot_archive_path, @@ -2593,14 +2581,11 @@ fn main() { } } ("accounts", Some(arg_matches)) => { - let dev_halt_at_slot = value_t!(arg_matches, "halt_at_slot", Slot).ok(); + let halt_at_slot = value_t!(arg_matches, "halt_at_slot", Slot).ok(); let process_options = ProcessOptions { new_hard_forks: hardforks_of(arg_matches, "hard_forks"), + halt_at_slot, poh_verify: false, - runtime_config: RuntimeConfig { - dev_halt_at_slot, - ..RuntimeConfig::default() - }, ..ProcessOptions::default() }; let genesis_config = open_genesis_config_by(&ledger_path, arg_matches); @@ -2659,14 +2644,11 @@ fn main() { println!("{:#?}", total_accounts_stats); } ("capitalization", Some(arg_matches)) => { - let dev_halt_at_slot = value_t!(arg_matches, "halt_at_slot", Slot).ok(); + let halt_at_slot = value_t!(arg_matches, "halt_at_slot", Slot).ok(); let process_options = ProcessOptions { new_hard_forks: hardforks_of(arg_matches, "hard_forks"), + halt_at_slot, poh_verify: false, - runtime_config: RuntimeConfig { - dev_halt_at_slot, - ..RuntimeConfig::default() - }, ..ProcessOptions::default() }; let genesis_config = open_genesis_config_by(&ledger_path, arg_matches); diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 39f10f3084..ad26f7b4ba 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -547,6 +547,7 @@ pub type ProcessCallback = Arc; pub struct ProcessOptions { pub poh_verify: bool, pub full_leader_cache: bool, + pub halt_at_slot: Option, pub entry_callback: Option, pub override_num_threads: Option, pub new_hard_forks: Option>, @@ -1188,11 +1189,8 @@ fn load_frozen_forks( &mut pending_slots, )?; - let dev_halt_at_slot = opts - .runtime_config - .dev_halt_at_slot - .unwrap_or(std::u64::MAX); - if bank_forks.read().unwrap().root() != dev_halt_at_slot { + let halt_at_slot = opts.halt_at_slot.unwrap_or(std::u64::MAX); + if bank_forks.read().unwrap().root() != halt_at_slot { while !pending_slots.is_empty() { timing.details.per_program_timings.clear(); let (meta, bank, last_entry_hash) = pending_slots.pop().unwrap(); @@ -1373,7 +1371,7 @@ fn load_frozen_forks( &mut pending_slots, )?; - if slot >= dev_halt_at_slot { + if slot >= halt_at_slot { bank.force_flush_accounts_cache(); let _ = bank.verify_bank_hash(false); break; @@ -3134,11 +3132,8 @@ pub mod tests { // Specify halting at slot 0 let opts = ProcessOptions { poh_verify: true, + halt_at_slot: Some(0), accounts_db_test_hash_calculation: true, - runtime_config: RuntimeConfig { - dev_halt_at_slot: Some(0), - ..RuntimeConfig::default() - }, ..ProcessOptions::default() }; let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts); diff --git a/local-cluster/src/validator_configs.rs b/local-cluster/src/validator_configs.rs index 23ab368d97..abed01ca85 100644 --- a/local-cluster/src/validator_configs.rs +++ b/local-cluster/src/validator_configs.rs @@ -6,6 +6,7 @@ use { pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig { ValidatorConfig { + halt_at_slot: config.halt_at_slot, expected_genesis_hash: config.expected_genesis_hash, expected_bank_hash: config.expected_bank_hash, expected_shred_version: config.expected_shred_version, diff --git a/runtime/src/runtime_config.rs b/runtime/src/runtime_config.rs index 199f04ad10..18acbd131e 100644 --- a/runtime/src/runtime_config.rs +++ b/runtime/src/runtime_config.rs @@ -1,9 +1,8 @@ -use {solana_program_runtime::compute_budget::ComputeBudget, solana_sdk::clock::Slot}; +use solana_program_runtime::compute_budget::ComputeBudget; /// Encapsulates flags that can be used to tweak the runtime behavior. #[derive(Default, Clone)] pub struct RuntimeConfig { pub bpf_jit: bool, - pub dev_halt_at_slot: Option, pub compute_budget: Option, } diff --git a/test-validator/src/lib.rs b/test-validator/src/lib.rs index 7233628311..13e0d3895d 100644 --- a/test-validator/src/lib.rs +++ b/test-validator/src/lib.rs @@ -681,7 +681,6 @@ impl TestValidator { max_units, ..ComputeBudget::default() }), - ..RuntimeConfig::default() }; let mut validator_config = ValidatorConfig { diff --git a/validator/src/main.rs b/validator/src/main.rs index cbb071390e..59d9055a85 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -2330,6 +2330,7 @@ pub fn main() { let mut validator_config = ValidatorConfig { require_tower: matches.is_present("require_tower"), tower_storage, + halt_at_slot: value_t!(matches, "dev_halt_at_slot", Slot).ok(), expected_genesis_hash: matches .value_of("expected_genesis_hash") .map(|s| Hash::from_str(s).unwrap()), @@ -2442,7 +2443,6 @@ pub fn main() { no_wait_for_vote_to_start_leader: matches.is_present("no_wait_for_vote_to_start_leader"), accounts_shrink_ratio, runtime_config: RuntimeConfig { - dev_halt_at_slot: value_t!(matches, "dev_halt_at_slot", Slot).ok(), bpf_jit: !matches.is_present("no_bpf_jit"), ..RuntimeConfig::default() },