Merge branch 'master' into master-sf

This commit is contained in:
pawanjay176
2020-04-28 18:19:33 +05:30
164 changed files with 5444 additions and 2104 deletions

View File

@@ -1,12 +1,12 @@
use super::*;
use crate::case_result::compare_result;
use crate::cases::common::BlsCase;
use bls::{AggregatePublicKey, AggregateSignature};
use bls::{AggregateSignature, PublicKey};
use serde_derive::Deserialize;
#[derive(Debug, Clone, Deserialize)]
pub struct BlsAggregatePair {
pub pubkey: AggregatePublicKey,
pub pubkey: PublicKey,
pub message: String,
}

View File

@@ -23,7 +23,6 @@ impl Case for BlsSign {
// Convert private_key and message to required types
let mut sk = hex::decode(&self.input.privkey[2..])
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
pad_to_48(&mut sk);
let sk = SecretKey::from_bytes(&sk).unwrap();
let msg = hex::decode(&self.input.message[2..])
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
@@ -37,10 +36,3 @@ impl Case for BlsSign {
compare_result::<Vec<u8>, Vec<u8>>(&Ok(signature.as_bytes()), &Some(decoded))
}
}
// Increase the size of an array to 48 bytes
fn pad_to_48(array: &mut Vec<u8>) {
while array.len() < 48 {
array.insert(0, 0);
}
}

View File

@@ -13,7 +13,9 @@ fn config_test<E: EthSpec + TypeName>() {
.join("config.yaml");
let yaml_config = YamlConfig::from_file(&config_path).expect("config file loads OK");
let spec = E::default_spec();
let yaml_from_spec = YamlConfig::from_spec::<E>(&spec);
assert_eq!(yaml_config.apply_to_chain_spec::<E>(&spec), Some(spec));
assert_eq!(yaml_from_spec, yaml_config);
}
#[test]

View File

@@ -78,27 +78,31 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.short("s")
.long("speedup")
.takes_value(true)
.help("Speed up factor for eth1 blocks and slot production (default 15)"),
.default_value("15")
.help("Speed up factor for eth1 blocks and slot production"),
)
.arg(
Arg::with_name("initial_delay")
.short("i")
.long("initial_delay")
.takes_value(true)
.help("Epoch delay for new beacon node to start syncing (default 50)"),
.default_value("5")
.help("Epoch delay for new beacon node to start syncing"),
)
.arg(
Arg::with_name("sync_timeout")
.long("sync_timeout")
.takes_value(true)
.help("Number of epochs after which newly added beacon nodes must be synced (default 10)"),
.default_value("10")
.help("Number of epochs after which newly added beacon nodes must be synced"),
)
.arg(
Arg::with_name("strategy")
.long("strategy")
.takes_value(true)
.default_value("all")
.possible_values(&["one-node", "two-nodes", "mixed", "all"])
.help("Sync verification strategy to run. (default all)"),
.help("Sync verification strategy to run."),
),
)
}

View File

@@ -12,14 +12,14 @@ use tokio::timer::Interval;
use types::{Epoch, EthSpec};
pub fn run_syncing_sim(matches: &ArgMatches) -> Result<(), String> {
let initial_delay = value_t!(matches, "initial_delay", u64).unwrap_or(50);
let sync_delay = value_t!(matches, "sync_delay", u64).unwrap_or(10);
let speed_up_factor = value_t!(matches, "speedup", u64).unwrap_or(15);
let strategy = value_t!(matches, "strategy", String).unwrap_or("all".into());
let initial_delay = value_t!(matches, "initial_delay", u64).unwrap();
let sync_timeout = value_t!(matches, "sync_timeout", u64).unwrap();
let speed_up_factor = value_t!(matches, "speedup", u64).unwrap();
let strategy = value_t!(matches, "strategy", String).unwrap();
println!("Syncing Simulator:");
println!(" initial_delay:{}", initial_delay);
println!(" sync delay:{}", sync_delay);
println!(" sync timeout: {}", sync_timeout);
println!(" speed up factor:{}", speed_up_factor);
println!(" strategy:{}", strategy);
@@ -29,7 +29,7 @@ pub fn run_syncing_sim(matches: &ArgMatches) -> Result<(), String> {
syncing_sim(
speed_up_factor,
initial_delay,
sync_delay,
sync_timeout,
strategy,
log_level,
log_format,
@@ -39,7 +39,7 @@ pub fn run_syncing_sim(matches: &ArgMatches) -> Result<(), String> {
fn syncing_sim(
speed_up_factor: u64,
initial_delay: u64,
sync_delay: u64,
sync_timeout: u64,
strategy: String,
log_level: &str,
log_format: Option<&str>,
@@ -108,7 +108,7 @@ fn syncing_sim(
beacon_config.clone(),
slot_duration,
initial_delay,
sync_delay,
sync_timeout,
))
.join(final_future)
.map(|_| network)
@@ -353,27 +353,24 @@ pub fn verify_syncing<E: EthSpec>(
pub fn check_still_syncing<E: EthSpec>(
network: &LocalNetwork<E>,
) -> impl Future<Item = bool, Error = String> {
let net = network.clone();
network
.remote_nodes()
.into_future()
// get all head epochs
// get syncing status of nodes
.and_then(|remote_nodes| {
stream::unfold(remote_nodes.into_iter(), |mut iter| {
iter.next().map(|remote_node| {
remote_node
.http
.beacon()
.get_head()
.map(|head| head.finalized_slot.epoch(E::slots_per_epoch()))
.map(|epoch| (epoch, iter))
.map_err(|e| format!("Get head via http failed: {:?}", e))
.node()
.syncing_status()
.map(|status| status.is_syncing)
.map(|status| (status, iter))
.map_err(|e| format!("Get syncing status via http failed: {:?}", e))
})
})
.collect()
})
// find current epoch
.and_then(move |epochs| net.bootnode_epoch().map(|epoch| (epochs, epoch)))
.and_then(move |(epochs, epoch)| Ok(epochs.iter().any(|head_epoch| *head_epoch != epoch)))
.and_then(move |status| Ok(status.iter().any(|is_syncing| *is_syncing)))
.map_err(|e| format!("Failed syncing check: {:?}", e))
}