mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 18:21:45 +00:00
* multiple broadcast flags * rewrite with single --broadcast option * satisfy cargo fmt * shorten sync-committee-messages * fix a doc comment and a test * use strum * Add broadcast test to simulator * bring --disable-run-on-all flag back with deprecation notice
This commit is contained in:
committed by
GitHub
parent
e856a904ef
commit
b4556a3d62
@@ -10,7 +10,8 @@ use futures::prelude::*;
|
||||
use node_test_rig::environment::RuntimeContext;
|
||||
use node_test_rig::{
|
||||
environment::{EnvironmentBuilder, LoggerConfig},
|
||||
testing_client_config, testing_validator_config, ClientConfig, ClientGenesis, ValidatorFiles,
|
||||
testing_client_config, testing_validator_config, ApiTopic, ClientConfig, ClientGenesis,
|
||||
ValidatorFiles,
|
||||
};
|
||||
use rayon::prelude::*;
|
||||
use sensitive_url::SensitiveUrl;
|
||||
@@ -159,10 +160,25 @@ pub fn run_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
validator_config.fee_recipient = Some(SUGGESTED_FEE_RECIPIENT.into());
|
||||
}
|
||||
println!("Adding validator client {}", i);
|
||||
network_1
|
||||
.add_validator_client(validator_config, i, files, i % 2 == 0)
|
||||
.await
|
||||
.expect("should add validator");
|
||||
|
||||
// Enable broadcast on every 4th node.
|
||||
if i % 4 == 0 {
|
||||
validator_config.broadcast_topics = ApiTopic::all();
|
||||
let beacon_nodes = vec![i, (i + 1) % node_count];
|
||||
network_1
|
||||
.add_validator_client_with_fallbacks(
|
||||
validator_config,
|
||||
i,
|
||||
beacon_nodes,
|
||||
files,
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
network_1
|
||||
.add_validator_client(validator_config, i, files, i % 2 == 0)
|
||||
.await
|
||||
}
|
||||
.expect("should add validator");
|
||||
},
|
||||
"vc",
|
||||
);
|
||||
|
||||
@@ -270,6 +270,48 @@ impl<E: EthSpec> LocalNetwork<E> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn add_validator_client_with_fallbacks(
|
||||
&self,
|
||||
mut validator_config: ValidatorConfig,
|
||||
validator_index: usize,
|
||||
beacon_nodes: Vec<usize>,
|
||||
validator_files: ValidatorFiles,
|
||||
) -> Result<(), String> {
|
||||
let context = self
|
||||
.context
|
||||
.service_context(format!("validator_{}", validator_index));
|
||||
let self_1 = self.clone();
|
||||
let mut beacon_node_urls = vec![];
|
||||
for beacon_node in beacon_nodes {
|
||||
let socket_addr = {
|
||||
let read_lock = self.beacon_nodes.read();
|
||||
let beacon_node = read_lock
|
||||
.get(beacon_node)
|
||||
.ok_or_else(|| format!("No beacon node for index {}", beacon_node))?;
|
||||
beacon_node
|
||||
.client
|
||||
.http_api_listen_addr()
|
||||
.expect("Must have http started")
|
||||
};
|
||||
let beacon_node = SensitiveUrl::parse(
|
||||
format!("http://{}:{}", socket_addr.ip(), socket_addr.port()).as_str(),
|
||||
)
|
||||
.unwrap();
|
||||
beacon_node_urls.push(beacon_node);
|
||||
}
|
||||
|
||||
validator_config.beacon_nodes = beacon_node_urls;
|
||||
|
||||
let validator_client = LocalValidatorClient::production_with_insecure_keypairs(
|
||||
context,
|
||||
validator_config,
|
||||
validator_files,
|
||||
)
|
||||
.await?;
|
||||
self_1.validator_clients.write().push(validator_client);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// For all beacon nodes in `Self`, return a HTTP client to access each nodes HTTP API.
|
||||
pub fn remote_nodes(&self) -> Result<Vec<BeaconNodeHttpClient>, String> {
|
||||
let beacon_nodes = self.beacon_nodes.read();
|
||||
|
||||
Reference in New Issue
Block a user