Remove halt_at_slot from RuntimeConfig, it's not a runtime concern

This commit is contained in:
Michael Vines 2022-04-19 15:06:30 -07:00
parent 32c008e02a
commit 9e4999ef6a
7 changed files with 22 additions and 43 deletions

View File

@ -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<Slot>,
pub expected_genesis_hash: Option<Hash>,
pub expected_bank_hash: Option<Hash>,
pub expected_shred_version: Option<u16>,
@ -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(),

View File

@ -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);

View File

@ -547,6 +547,7 @@ pub type ProcessCallback = Arc<dyn Fn(&Bank) + Sync + Send>;
pub struct ProcessOptions {
pub poh_verify: bool,
pub full_leader_cache: bool,
pub halt_at_slot: Option<Slot>,
pub entry_callback: Option<ProcessCallback>,
pub override_num_threads: Option<usize>,
pub new_hard_forks: Option<Vec<Slot>>,
@ -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);

View File

@ -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,

View File

@ -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<Slot>,
pub compute_budget: Option<ComputeBudget>,
}

View File

@ -681,7 +681,6 @@ impl TestValidator {
max_units,
..ComputeBudget::default()
}),
..RuntimeConfig::default()
};
let mut validator_config = ValidatorConfig {

View File

@ -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()
},