Skip to content

Commit

Permalink
[SVM] Move RuntimeConfig to program-runtime (solana-labs#96)
Browse files Browse the repository at this point in the history
RuntimeConfig doesn't use anything SVM specific and logically belongs
in program runtime rather than SVM.  This change moves the definition
of RuntimeConfig struct from the SVM crate to program-runtime and
adjusts `use` statements accordingly.
  • Loading branch information
dmakarov authored and palinko91 committed May 7, 2024
1 parent 2ce157f commit e691470
Show file tree
Hide file tree
Showing 19 changed files with 2,244 additions and 1,847 deletions.
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 42 additions & 51 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use {
accounts_index::AccountSecondaryIndexes,
accounts_update_notifier_interface::AccountsUpdateNotifier,
hardened_unpack::{open_genesis_config, MAX_GENESIS_ARCHIVE_UNPACKED_SIZE},
starting_snapshot_storages::StartingSnapshotStorages,
utils::{move_and_async_delete_path, move_and_async_delete_path_contents},
},
solana_client::connection_cache::{ConnectionCache, Protocol},
Expand All @@ -47,9 +48,9 @@ use {
ClusterInfo, Node, DEFAULT_CONTACT_DEBUG_INTERVAL_MILLIS,
DEFAULT_CONTACT_SAVE_INTERVAL_MILLIS,
},
contact_info::ContactInfo,
crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS,
gossip_service::GossipService,
legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_ledger::{
bank_forks_utils,
Expand All @@ -73,7 +74,7 @@ use {
poh_recorder::PohRecorder,
poh_service::{self, PohService},
},
solana_rayon_threadlimit::get_max_thread_count,
solana_program_runtime::runtime_config::RuntimeConfig,
solana_rpc::{
max_slots::MaxSlots,
optimistically_confirmed_bank_tracker::{
Expand All @@ -97,7 +98,6 @@ use {
bank_forks::BankForks,
commitment::BlockCommitmentCache,
prioritization_fee_cache::PrioritizationFeeCache,
runtime_config::RuntimeConfig,
snapshot_archive_info::SnapshotArchiveInfoGetter,
snapshot_bank_utils::{self, DISABLED_SNAPSHOT_ARCHIVE_INTERVAL},
snapshot_config::SnapshotConfig,
Expand All @@ -124,7 +124,6 @@ use {
std::{
collections::{HashMap, HashSet},
net::SocketAddr,
num::NonZeroUsize,
path::{Path, PathBuf},
sync::{
atomic::{AtomicBool, AtomicU64, Ordering},
Expand Down Expand Up @@ -262,17 +261,14 @@ pub struct ValidatorConfig {
pub wait_to_vote_slot: Option<Slot>,
pub ledger_column_options: LedgerColumnOptions,
pub runtime_config: RuntimeConfig,
pub replay_slots_concurrently: bool,
pub banking_trace_dir_byte_limit: banking_trace::DirByteLimit,
pub block_verification_method: BlockVerificationMethod,
pub block_production_method: BlockProductionMethod,
pub generator_config: Option<GeneratorConfig>,
pub use_snapshot_archives_at_startup: UseSnapshotArchivesAtStartup,
pub wen_restart_proto_path: Option<PathBuf>,
pub unified_scheduler_handler_threads: Option<usize>,
pub ip_echo_server_threads: NonZeroUsize,
pub replay_forks_threads: NonZeroUsize,
pub replay_transactions_threads: NonZeroUsize,
pub delay_leader_block_for_pending_fork: bool,
}

impl Default for ValidatorConfig {
Expand Down Expand Up @@ -333,17 +329,14 @@ impl Default for ValidatorConfig {
wait_to_vote_slot: None,
ledger_column_options: LedgerColumnOptions::default(),
runtime_config: RuntimeConfig::default(),
replay_slots_concurrently: false,
banking_trace_dir_byte_limit: 0,
block_verification_method: BlockVerificationMethod::default(),
block_production_method: BlockProductionMethod::default(),
generator_config: None,
use_snapshot_archives_at_startup: UseSnapshotArchivesAtStartup::default(),
wen_restart_proto_path: None,
unified_scheduler_handler_threads: None,
ip_echo_server_threads: NonZeroUsize::new(1).expect("1 is non-zero"),
replay_forks_threads: NonZeroUsize::new(1).expect("1 is non-zero"),
replay_transactions_threads: NonZeroUsize::new(1).expect("1 is non-zero"),
delay_leader_block_for_pending_fork: false,
}
}
}
Expand All @@ -353,10 +346,7 @@ impl ValidatorConfig {
Self {
enforce_ulimit_nofile: false,
rpc_config: JsonRpcConfig::default_for_test(),
block_production_method: BlockProductionMethod::default(),
replay_forks_threads: NonZeroUsize::new(1).expect("1 is non-zero"),
replay_transactions_threads: NonZeroUsize::new(get_max_thread_count())
.expect("thread count is non-zero"),
block_production_method: BlockProductionMethod::ThreadLocalMultiIterator,
..Self::default()
}
}
Expand Down Expand Up @@ -512,8 +502,6 @@ impl Validator {
tpu_enable_udp: bool,
admin_rpc_service_post_init: Arc<RwLock<Option<AdminRpcRequestMetadataPostInit>>>,
) -> Result<Self, String> {
let start_time = Instant::now();

let id = identity_keypair.pubkey();
assert_eq!(&id, node.info.pubkey());

Expand Down Expand Up @@ -703,6 +691,7 @@ impl Validator {
completed_slots_receiver,
leader_schedule_cache,
starting_snapshot_hashes,
starting_snapshot_storages,
TransactionHistoryServices {
transaction_status_sender,
transaction_status_service,
Expand Down Expand Up @@ -792,6 +781,7 @@ impl Validator {
accounts_package_sender.clone(),
accounts_package_receiver,
snapshot_package_sender,
starting_snapshot_storages,
exit.clone(),
config.snapshot_config.clone(),
);
Expand Down Expand Up @@ -946,7 +936,7 @@ impl Validator {
bank.clone(),
None,
bank.ticks_per_slot(),
config.delay_leader_block_for_pending_fork,
&id,
blockstore.clone(),
blockstore.get_new_shred_signal(0),
&leader_schedule_cache,
Expand Down Expand Up @@ -1085,7 +1075,6 @@ impl Validator {
None => None,
Some(tcp_listener) => Some(solana_net_utils::ip_echo_server(
tcp_listener,
config.ip_echo_server_threads,
Some(node.info.shred_version()),
)),
};
Expand Down Expand Up @@ -1319,15 +1308,14 @@ impl Validator {
repair_validators: config.repair_validators.clone(),
repair_whitelist: config.repair_whitelist.clone(),
wait_for_vote_to_start_leader,
replay_forks_threads: config.replay_forks_threads,
replay_transactions_threads: config.replay_transactions_threads,
replay_slots_concurrently: config.replay_slots_concurrently,
},
&max_slots,
block_metadata_notifier,
config.wait_to_vote_slot,
accounts_background_request_sender,
config.runtime_config.log_messages_bytes_limit,
json_rpc_service.is_some().then_some(&connection_cache), // for the cache warmer only used for STS for RPC service
&connection_cache,
&prioritization_fee_cache,
banking_tracer.clone(),
turbine_quic_endpoint_sender.clone(),
Expand Down Expand Up @@ -1405,7 +1393,6 @@ impl Validator {
("id", id.to_string(), String),
("version", solana_version::version!(), String),
("cluster_type", genesis_config.cluster_type as u32, i64),
("elapsed_ms", start_time.elapsed().as_millis() as i64, i64),
("waited_for_supermajority", waited_for_supermajority, bool),
("expected_shred_version", config.expected_shred_version, Option<i64>),
);
Expand Down Expand Up @@ -1783,6 +1770,7 @@ fn load_blockstore(
CompletedSlotsReceiver,
LeaderScheduleCache,
Option<StartingSnapshotHashes>,
StartingSnapshotStorages,
TransactionHistoryServices,
blockstore_processor::ProcessOptions,
BlockstoreRootScan,
Expand Down Expand Up @@ -1872,23 +1860,27 @@ fn load_blockstore(
let entry_notifier_service = entry_notifier
.map(|entry_notifier| EntryNotifierService::new(entry_notifier, exit.clone()));

let (bank_forks, mut leader_schedule_cache, starting_snapshot_hashes) =
bank_forks_utils::load_bank_forks(
&genesis_config,
&blockstore,
config.account_paths.clone(),
Some(&config.snapshot_config),
&process_options,
transaction_history_services
.cache_block_meta_sender
.as_ref(),
entry_notifier_service
.as_ref()
.map(|service| service.sender()),
accounts_update_notifier,
exit,
)
.map_err(|err| err.to_string())?;
let (
bank_forks,
mut leader_schedule_cache,
starting_snapshot_hashes,
starting_snapshot_storages,
) = bank_forks_utils::load_bank_forks(
&genesis_config,
&blockstore,
config.account_paths.clone(),
Some(&config.snapshot_config),
&process_options,
transaction_history_services
.cache_block_meta_sender
.as_ref(),
entry_notifier_service
.as_ref()
.map(|service| service.sender()),
accounts_update_notifier,
exit,
)
.map_err(|err| err.to_string())?;

// Before replay starts, set the callbacks in each of the banks in BankForks so that
// all dropped banks come through the `pruned_banks_receiver` channel. This way all bank
Expand All @@ -1914,6 +1906,7 @@ fn load_blockstore(
completed_slots_receiver,
leader_schedule_cache,
starting_snapshot_hashes,
starting_snapshot_storages,
transaction_history_services,
process_options,
blockstore_root_scan,
Expand Down Expand Up @@ -2102,13 +2095,11 @@ fn maybe_warp_slot(
warp_slot,
solana_accounts_db::accounts_db::CalcAccountsHashDataSource::Storages,
));
bank_forks
.set_root(
warp_slot,
accounts_background_request_sender,
Some(warp_slot),
)
.map_err(|err| err.to_string())?;
bank_forks.set_root(
warp_slot,
accounts_background_request_sender,
Some(warp_slot),
);
leader_schedule_cache.set_root(&bank_forks.root_bank());

let full_snapshot_archive_info = match snapshot_bank_utils::bank_to_full_snapshot_archive(
Expand Down Expand Up @@ -2534,7 +2525,7 @@ mod tests {
super::*,
crossbeam_channel::{bounded, RecvTimeoutError},
solana_entry::entry,
solana_gossip::contact_info::ContactInfo,
solana_gossip::contact_info::{ContactInfo, LegacyContactInfo},
solana_ledger::{
blockstore, create_new_tmp_ledger, genesis_utils::create_genesis_config_with_leader,
get_tmp_ledger_path_auto_delete,
Expand Down Expand Up @@ -2574,7 +2565,7 @@ mod tests {
&validator_ledger_path,
&voting_keypair.pubkey(),
Arc::new(RwLock::new(vec![voting_keypair])),
vec![leader_node.info],
vec![LegacyContactInfo::try_from(&leader_node.info).unwrap()],
&config,
true, // should_check_duplicate_instance
None, // rpc_to_plugin_manager_receiver
Expand Down Expand Up @@ -2659,7 +2650,7 @@ mod tests {
&validator_ledger_path,
&vote_account_keypair.pubkey(),
Arc::new(RwLock::new(vec![Arc::new(vote_account_keypair)])),
vec![leader_node.info.clone()],
vec![LegacyContactInfo::try_from(&leader_node.info).unwrap()],
&config,
true, // should_check_duplicate_instance.
None, // rpc_to_plugin_manager_receiver
Expand Down
1 change: 1 addition & 0 deletions core/tests/epoch_accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use {
snapshot_packager_service::SnapshotPackagerService,
},
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
solana_program_runtime::runtime_config::RuntimeConfig,
solana_runtime::{
accounts_background_service::{
AbsRequestHandlers, AbsRequestSender, AccountsBackgroundService, DroppedSlotsReceiver,
Expand Down
1 change: 1 addition & 0 deletions core/tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use {
snapshot_packager_service::SnapshotPackagerService,
},
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
solana_program_runtime::runtime_config::RuntimeConfig,
solana_runtime::{
accounts_background_service::{
AbsRequestHandlers, AbsRequestSender, AccountsBackgroundService,
Expand Down
8 changes: 2 additions & 6 deletions ledger-tool/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
blockstore_processor::ProcessOptions,
use_snapshot_archives_at_startup::{self, UseSnapshotArchivesAtStartup},
},
solana_runtime::runtime_config::RuntimeConfig,
solana_program_runtime::runtime_config::RuntimeConfig,
solana_sdk::clock::Slot,
std::{
collections::HashSet,
Expand All @@ -27,11 +27,7 @@ use {
pub fn parse_process_options(ledger_path: &Path, arg_matches: &ArgMatches<'_>) -> ProcessOptions {
let new_hard_forks = hardforks_of(arg_matches, "hard_forks");
let accounts_db_config = Some(get_accounts_db_config(ledger_path, arg_matches));
let log_messages_bytes_limit = value_t!(arg_matches, "log_messages_bytes_limit", usize).ok();
let runtime_config = RuntimeConfig {
log_messages_bytes_limit,
..RuntimeConfig::default()
};
let runtime_config = RuntimeConfig::default();

if arg_matches.is_present("skip_poh_verify") {
eprintln!("--skip-poh-verify is deprecated. Replace with --skip-verification.");
Expand Down
Loading

0 comments on commit e691470

Please sign in to comment.