## Issue Addressed Closes #1504 Closes #1505 Replaces #1703 Closes #1707 ## Proposed Changes * Update BLST and Milagro to versions compatible with BLSv4 spec * Update Lighthouse to spec v1.0.0-rc.0, and update EF test vectors * Use the v1.0.0 constants for `MainnetEthSpec`. * Rename `InteropEthSpec` -> `V012LegacyEthSpec` * Change all constants to suit the mainnet `v0.12.3` specification (i.e., Medalla). * Deprecate the `--spec` flag for the `lighthouse` binary * This value is now obtained from the `config_name` field of the `YamlConfig`. * Built in testnet YAML files have been updated. * Ignore the `--spec` value, if supplied, log a warning that it will be deprecated * `lcli` still has the spec flag, that's fine because it's dev tooling. * Remove the `E: EthSpec` from `YamlConfig` * This means we need to deser the genesis `BeaconState` on-demand, but this is fine. * Swap the old "minimal", "mainnet" strings over to the new `EthSpecId` enum. * Always require a `CONFIG_NAME` field in `YamlConfig` (it used to have a default). ## Additional Info Lots of breaking changes, do not merge! ~~We will likely need a Lighthouse v0.4.0 branch, and possibly a long-term v0.3.0 branch to keep Medalla alive~~. Co-authored-by: Kirk Baird <baird.k@outlook.com> Co-authored-by: Paul Hauner <paul@paulhauner.com>
65 lines
2.3 KiB
Rust
65 lines
2.3 KiB
Rust
use clap::ArgMatches;
|
|
use clap_utils::parse_ssz_optional;
|
|
use environment::Environment;
|
|
use eth2_testnet_config::Eth2TestnetConfig;
|
|
use genesis::interop_genesis_state;
|
|
use ssz::Encode;
|
|
use std::path::PathBuf;
|
|
use std::time::{SystemTime, UNIX_EPOCH};
|
|
use types::{test_utils::generate_deterministic_keypairs, EthSpec};
|
|
|
|
pub fn run<T: EthSpec>(mut env: Environment<T>, matches: &ArgMatches) -> Result<(), String> {
|
|
let validator_count = matches
|
|
.value_of("validator-count")
|
|
.ok_or_else(|| "validator-count not specified")?
|
|
.parse::<usize>()
|
|
.map_err(|e| format!("Unable to parse validator-count: {}", e))?;
|
|
|
|
let genesis_time = if let Some(genesis_time) = matches.value_of("genesis-time") {
|
|
genesis_time
|
|
.parse::<u64>()
|
|
.map_err(|e| format!("Unable to parse genesis-time: {}", e))?
|
|
} else {
|
|
SystemTime::now()
|
|
.duration_since(UNIX_EPOCH)
|
|
.map_err(|e| format!("Unable to get time: {:?}", e))?
|
|
.as_secs()
|
|
};
|
|
|
|
let testnet_dir = matches
|
|
.value_of("testnet-dir")
|
|
.ok_or_else(|| ())
|
|
.and_then(|dir| dir.parse::<PathBuf>().map_err(|_| ()))
|
|
.unwrap_or_else(|_| {
|
|
dirs::home_dir()
|
|
.map(|home| home.join(directory::DEFAULT_ROOT_DIR).join("testnet"))
|
|
.expect("should locate home directory")
|
|
});
|
|
|
|
let mut eth2_testnet_config = Eth2TestnetConfig::load(testnet_dir.clone())?;
|
|
|
|
let mut spec = eth2_testnet_config
|
|
.yaml_config
|
|
.as_ref()
|
|
.ok_or_else(|| "The testnet directory must contain a spec config".to_string())?
|
|
.apply_to_chain_spec::<T>(&env.core_context().eth2_config.spec)
|
|
.ok_or_else(|| {
|
|
format!(
|
|
"The loaded config is not compatible with the {} spec",
|
|
&env.core_context().eth2_config.eth_spec_id
|
|
)
|
|
})?;
|
|
|
|
if let Some(v) = parse_ssz_optional(matches, "genesis-fork-version")? {
|
|
spec.genesis_fork_version = v;
|
|
}
|
|
|
|
let keypairs = generate_deterministic_keypairs(validator_count);
|
|
let genesis_state = interop_genesis_state::<T>(&keypairs, genesis_time, &spec)?;
|
|
|
|
eth2_testnet_config.genesis_state_bytes = Some(genesis_state.as_ssz_bytes());
|
|
eth2_testnet_config.force_write_to_file(testnet_dir)?;
|
|
|
|
Ok(())
|
|
}
|