Remove ValidatorConfig derive Clone, and fix local-cluster tests (#15647)
* Remove ValidatorConfig derive Clone * Add local-cluster ValidatorConfig helpers * Fix benches
This commit is contained in:
@ -2,3 +2,4 @@
|
||||
pub mod cluster;
|
||||
pub mod cluster_tests;
|
||||
pub mod local_cluster;
|
||||
pub mod validator_configs;
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::{
|
||||
cluster::{Cluster, ClusterValidatorInfo, ValidatorInfo},
|
||||
cluster_tests,
|
||||
validator_configs::*,
|
||||
};
|
||||
use itertools::izip;
|
||||
use log::*;
|
||||
@ -45,7 +46,7 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct ClusterConfig {
|
||||
/// The validator config that should be applied to every node in the cluster
|
||||
pub validator_configs: Vec<ValidatorConfig>,
|
||||
@ -110,7 +111,10 @@ impl LocalCluster {
|
||||
let mut config = ClusterConfig {
|
||||
node_stakes: stakes,
|
||||
cluster_lamports,
|
||||
validator_configs: vec![ValidatorConfig::default(); num_nodes],
|
||||
validator_configs: make_identical_validator_configs(
|
||||
&ValidatorConfig::default(),
|
||||
num_nodes,
|
||||
),
|
||||
..ClusterConfig::default()
|
||||
};
|
||||
Self::new(&mut config)
|
||||
@ -193,7 +197,7 @@ impl LocalCluster {
|
||||
|
||||
let (leader_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_config);
|
||||
let leader_contact_info = leader_node.info.clone();
|
||||
let mut leader_config = config.validator_configs[0].clone();
|
||||
let mut leader_config = safe_clone_config(&config.validator_configs[0]);
|
||||
leader_config.rpc_addrs = Some((leader_node.info.rpc, leader_node.info.rpc_pubsub));
|
||||
leader_config.account_paths = vec![leader_ledger_path.join("accounts")];
|
||||
let leader_keypair = Arc::new(Keypair::from_bytes(&leader_keypair.to_bytes()).unwrap());
|
||||
@ -217,10 +221,9 @@ impl LocalCluster {
|
||||
ledger_path: leader_ledger_path,
|
||||
contact_info: leader_contact_info.clone(),
|
||||
};
|
||||
|
||||
let cluster_leader = ClusterValidatorInfo::new(
|
||||
leader_info,
|
||||
config.validator_configs[0].clone(),
|
||||
safe_clone_config(&config.validator_configs[0]),
|
||||
leader_server,
|
||||
);
|
||||
|
||||
@ -255,10 +258,8 @@ impl LocalCluster {
|
||||
);
|
||||
}
|
||||
|
||||
let listener_config = ValidatorConfig {
|
||||
voting_disabled: true,
|
||||
..config.validator_configs[0].clone()
|
||||
};
|
||||
let mut listener_config = safe_clone_config(&config.validator_configs[0]);
|
||||
listener_config.voting_disabled = true;
|
||||
(0..config.num_listeners).for_each(|_| {
|
||||
cluster.add_validator(&listener_config, 0, Arc::new(Keypair::new()), None);
|
||||
});
|
||||
@ -339,7 +340,7 @@ impl LocalCluster {
|
||||
}
|
||||
}
|
||||
|
||||
let mut config = validator_config.clone();
|
||||
let mut config = safe_clone_config(validator_config);
|
||||
config.rpc_addrs = Some((validator_node.info.rpc, validator_node.info.rpc_pubsub));
|
||||
config.account_paths = vec![ledger_path.join("accounts")];
|
||||
let voting_keypair = voting_keypair.unwrap();
|
||||
@ -362,7 +363,7 @@ impl LocalCluster {
|
||||
ledger_path,
|
||||
contact_info,
|
||||
},
|
||||
validator_config.clone(),
|
||||
safe_clone_config(validator_config),
|
||||
validator_server,
|
||||
);
|
||||
|
||||
@ -710,7 +711,10 @@ mod test {
|
||||
validator_config.rpc_config.enable_validator_exit = true;
|
||||
const NUM_NODES: usize = 1;
|
||||
let mut config = ClusterConfig {
|
||||
validator_configs: vec![ValidatorConfig::default(); NUM_NODES],
|
||||
validator_configs: make_identical_validator_configs(
|
||||
&ValidatorConfig::default(),
|
||||
NUM_NODES,
|
||||
),
|
||||
node_stakes: vec![3; NUM_NODES],
|
||||
cluster_lamports: 100,
|
||||
ticks_per_slot: 8,
|
||||
|
67
local-cluster/src/validator_configs.rs
Normal file
67
local-cluster/src/validator_configs.rs
Normal file
@ -0,0 +1,67 @@
|
||||
use solana_core::validator::{ValidatorConfig, ValidatorExit};
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig {
|
||||
ValidatorConfig {
|
||||
dev_halt_at_slot: config.dev_halt_at_slot,
|
||||
expected_genesis_hash: config.expected_genesis_hash,
|
||||
expected_bank_hash: config.expected_bank_hash,
|
||||
expected_shred_version: config.expected_shred_version,
|
||||
voting_disabled: config.voting_disabled,
|
||||
account_paths: config.account_paths.clone(),
|
||||
account_shrink_paths: config.account_shrink_paths.clone(),
|
||||
rpc_config: config.rpc_config.clone(),
|
||||
rpc_addrs: config.rpc_addrs,
|
||||
pubsub_config: config.pubsub_config.clone(),
|
||||
snapshot_config: config.snapshot_config.clone(),
|
||||
max_ledger_shreds: config.max_ledger_shreds,
|
||||
broadcast_stage_type: config.broadcast_stage_type.clone(),
|
||||
enable_partition: config.enable_partition.clone(),
|
||||
enforce_ulimit_nofile: config.enforce_ulimit_nofile,
|
||||
fixed_leader_schedule: config.fixed_leader_schedule.clone(),
|
||||
wait_for_supermajority: config.wait_for_supermajority,
|
||||
new_hard_forks: config.new_hard_forks.clone(),
|
||||
trusted_validators: config.trusted_validators.clone(),
|
||||
repair_validators: config.repair_validators.clone(),
|
||||
gossip_validators: config.gossip_validators.clone(),
|
||||
halt_on_trusted_validators_accounts_hash_mismatch: config
|
||||
.halt_on_trusted_validators_accounts_hash_mismatch,
|
||||
accounts_hash_fault_injection_slots: config.accounts_hash_fault_injection_slots,
|
||||
frozen_accounts: config.frozen_accounts.clone(),
|
||||
no_rocksdb_compaction: config.no_rocksdb_compaction,
|
||||
rocksdb_compaction_interval: config.rocksdb_compaction_interval,
|
||||
rocksdb_max_compaction_jitter: config.rocksdb_max_compaction_jitter,
|
||||
accounts_hash_interval_slots: config.accounts_hash_interval_slots,
|
||||
max_genesis_archive_unpacked_size: config.max_genesis_archive_unpacked_size,
|
||||
wal_recovery_mode: config.wal_recovery_mode.clone(),
|
||||
poh_verify: config.poh_verify,
|
||||
cuda: config.cuda,
|
||||
require_tower: config.require_tower,
|
||||
debug_keys: config.debug_keys.clone(),
|
||||
contact_debug_interval: config.contact_debug_interval,
|
||||
contact_save_interval: config.contact_save_interval,
|
||||
bpf_jit: config.bpf_jit,
|
||||
send_transaction_retry_ms: config.send_transaction_retry_ms,
|
||||
send_transaction_leader_forward_count: config.send_transaction_leader_forward_count,
|
||||
no_poh_speed_test: config.no_poh_speed_test,
|
||||
poh_pinned_cpu_core: config.poh_pinned_cpu_core,
|
||||
account_indexes: config.account_indexes.clone(),
|
||||
accounts_db_caching_enabled: config.accounts_db_caching_enabled,
|
||||
warp_slot: config.warp_slot,
|
||||
accounts_db_test_hash_calculation: config.accounts_db_test_hash_calculation,
|
||||
accounts_db_use_index_hash_calculation: config.accounts_db_use_index_hash_calculation,
|
||||
tpu_coalesce_ms: config.tpu_coalesce_ms,
|
||||
validator_exit: Arc::new(RwLock::new(ValidatorExit::default())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn make_identical_validator_configs(
|
||||
config: &ValidatorConfig,
|
||||
num: usize,
|
||||
) -> Vec<ValidatorConfig> {
|
||||
let mut configs = vec![];
|
||||
for _ in 0..num {
|
||||
configs.push(safe_clone_config(config));
|
||||
}
|
||||
configs
|
||||
}
|
Reference in New Issue
Block a user