Merge branch 'master' into spec-v0.12

This commit is contained in:
Paul Hauner
2020-06-21 10:33:02 +10:00
60 changed files with 1812 additions and 1107 deletions

View File

@@ -61,8 +61,8 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true),
)
.arg(
Arg::with_name("maxpeers")
.long("maxpeers")
Arg::with_name("max_peers")
.long("max-peers")
.help("The maximum number of peers.")
.default_value("50")
.takes_value(true),
@@ -125,24 +125,6 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
without an ENR.")
.takes_value(true),
)
.arg(
Arg::with_name("p2p-priv-key")
.long("p2p-priv-key")
.value_name("HEX")
.help("A secp256k1 secret key, represented as ASCII-encoded hex bytes (with or \
without 0x prefix). Default is either loaded from disk or generated \
automatically.")
.takes_value(true),
)
.arg(
Arg::with_name("random-propagation")
.long("random-propagation")
.value_name("INTEGER")
.takes_value(true)
.help("Specifies (as a percentage) the likelihood of propagating blocks and \
attestations. This should only be used for testing networking elements. The \
value must like in the range 1-100. Default is 100.")
)
/* REST API related arguments */
.arg(
Arg::with_name("http")

View File

@@ -102,7 +102,7 @@ pub fn get_config<E: EthSpec>(
client_config.network.listen_address = listen_address;
}
if let Some(max_peers_str) = cli_args.value_of("maxpeers") {
if let Some(max_peers_str) = cli_args.value_of("max-peers") {
client_config.network.max_peers = max_peers_str
.parse::<usize>()
.map_err(|_| format!("Invalid number of max peers: {}", max_peers_str))?;
@@ -208,24 +208,6 @@ pub fn get_config<E: EthSpec>(
client_config.network.discv5_config.enr_update = false;
}
if let Some(p2p_priv_key) = cli_args.value_of("p2p-priv-key") {
client_config.network.secret_key_hex = Some(p2p_priv_key.to_string());
}
// Define a percentage of messages that should be propogated, useful for simulating bad network
// conditions.
//
// WARNING: setting this to anything less than 100 will cause bad behaviour.
if let Some(propagation_percentage_string) = cli_args.value_of("random-propagation") {
let percentage = propagation_percentage_string
.parse::<u8>()
.map_err(|_| "Unable to parse the propagation percentage".to_string())?;
if percentage > 100 {
return Err("Propagation percentage greater than 100".to_string());
}
client_config.network.propagation_percentage = Some(percentage);
}
/*
* Http server
*/

View File

@@ -82,6 +82,8 @@ impl<E: EthSpec> ProductionBeaconNode<E> {
let db_path = client_config.create_db_path()?;
let freezer_db_path_res = client_config.create_freezer_db_path();
let executor = context.executor.clone();
let builder = ClientBuilder::new(context.eth_spec_instance.clone())
.runtime_context(context)
.chain_spec(spec)
@@ -119,6 +121,9 @@ impl<E: EthSpec> ProductionBeaconNode<E> {
.system_time_slot_clock()?
.tee_event_handler(client_config.websocket_server.clone())?;
// Inject the executor into the discv5 network config.
client_config.network.discv5_config.executor = Some(Box::new(executor));
let builder = builder
.build_beacon_chain()?
.network(&mut client_config.network)?