test-validator: Add --max-compute-units flag (#24130)

* test-validator: Add `--max-compute-units` flag

* Add `RuntimeConfig` for tweaking runtime behavior

* Actually add the file

* Move RuntimeConfig to runtime
This commit is contained in:
Jon Cinque
2022-04-12 02:28:10 +02:00
committed by GitHub
parent 4fd184c131
commit 9b8850f99e
12 changed files with 106 additions and 29 deletions

View File

@ -211,14 +211,16 @@ fn bank_forks_from_snapshot(
process::exit(1);
}
let (deserialized_bank, full_snapshot_archive_info, incremental_snapshot_archive_info) =
let (mut deserialized_bank, full_snapshot_archive_info, incremental_snapshot_archive_info) =
snapshot_utils::bank_from_latest_snapshot_archives(
&snapshot_config.bank_snapshots_dir,
&snapshot_config.snapshot_archives_dir,
&account_paths,
genesis_config,
process_options.debug_keys.clone(),
Some(&crate::builtins::get(process_options.bpf_jit)),
Some(&crate::builtins::get(
process_options.runtime_config.bpf_jit,
)),
process_options.account_indexes.clone(),
process_options.accounts_db_caching_enabled,
process_options.limit_load_slot_count_from_snapshot,
@ -235,6 +237,8 @@ fn bank_forks_from_snapshot(
deserialized_bank.set_shrink_paths(shrink_paths);
}
deserialized_bank.set_compute_budget(process_options.runtime_config.compute_budget);
let full_snapshot_hash = FullSnapshotHash {
hash: (
full_snapshot_archive_info.slot(),

View File

@ -30,6 +30,7 @@ use {
block_cost_limits::*,
commitment::VOTE_THRESHOLD_SIZE,
cost_model::CostModel,
runtime_config::RuntimeConfig,
snapshot_config::SnapshotConfig,
snapshot_package::{PendingAccountsPackage, SnapshotType},
snapshot_utils,
@ -544,10 +545,8 @@ pub type ProcessCallback = Arc<dyn Fn(&Bank) + Sync + Send>;
#[derive(Default, Clone)]
pub struct ProcessOptions {
pub bpf_jit: bool,
pub poh_verify: bool,
pub full_leader_cache: bool,
pub dev_halt_at_slot: Option<Slot>,
pub entry_callback: Option<ProcessCallback>,
pub override_num_threads: Option<usize>,
pub new_hard_forks: Option<Vec<Slot>>,
@ -561,6 +560,7 @@ pub struct ProcessOptions {
pub accounts_db_config: Option<AccountsDbConfig>,
pub verify_index: bool,
pub shrink_ratio: AccountShrinkThreshold,
pub runtime_config: RuntimeConfig,
}
pub fn test_process_blockstore(
@ -603,11 +603,11 @@ pub(crate) fn process_blockstore_for_bank_0(
accounts_update_notifier: Option<AccountsUpdateNotifier>,
) -> BankForks {
// Setup bank for slot 0
let bank0 = Bank::new_with_paths(
let mut bank0 = Bank::new_with_paths(
genesis_config,
account_paths,
opts.debug_keys.clone(),
Some(&crate::builtins::get(opts.bpf_jit)),
Some(&crate::builtins::get(opts.runtime_config.bpf_jit)),
opts.account_indexes.clone(),
opts.accounts_db_caching_enabled,
opts.shrink_ratio,
@ -615,6 +615,7 @@ pub(crate) fn process_blockstore_for_bank_0(
opts.accounts_db_config.clone(),
accounts_update_notifier,
);
bank0.set_compute_budget(opts.runtime_config.compute_budget);
let bank_forks = BankForks::new(bank0);
info!("processing ledger for slot 0...");
@ -1147,7 +1148,10 @@ fn load_frozen_forks(
&mut pending_slots,
)?;
let dev_halt_at_slot = opts.dev_halt_at_slot.unwrap_or(std::u64::MAX);
let dev_halt_at_slot = opts
.runtime_config
.dev_halt_at_slot
.unwrap_or(std::u64::MAX);
if bank_forks.root() != dev_halt_at_slot {
while !pending_slots.is_empty() {
timing.details.per_program_timings.clear();
@ -3084,8 +3088,11 @@ pub mod tests {
// Specify halting at slot 0
let opts = ProcessOptions {
poh_verify: true,
dev_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);