mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 18:21:45 +00:00
Misc changes for merge testnets (#2667)
* Thread eth1_block_hash into interop genesis state * Add merge-fork-epoch flag * Build LH with minimal spec by default * Add verbose logs to execution_layer * Add --http-allow-sync-stalled flag * Update lcli new-testnet to create genesis state * Fix http test * Fix compile errors in tests
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
use clap::ArgMatches;
|
||||
use clap_utils::parse_ssz_optional;
|
||||
use eth2_network_config::Eth2NetworkConfig;
|
||||
use genesis::interop_genesis_state;
|
||||
use genesis::{interop_genesis_state, DEFAULT_ETH1_BLOCK_HASH};
|
||||
use ssz::Encode;
|
||||
use std::path::PathBuf;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use types::{test_utils::generate_deterministic_keypairs, EthSpec};
|
||||
use types::{test_utils::generate_deterministic_keypairs, EthSpec, Hash256};
|
||||
|
||||
pub fn run<T: EthSpec>(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(), String> {
|
||||
let validator_count = matches
|
||||
@@ -34,7 +34,12 @@ pub fn run<T: EthSpec>(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(),
|
||||
}
|
||||
|
||||
let keypairs = generate_deterministic_keypairs(validator_count);
|
||||
let genesis_state = interop_genesis_state::<T>(&keypairs, genesis_time, &spec)?;
|
||||
let genesis_state = interop_genesis_state::<T>(
|
||||
&keypairs,
|
||||
genesis_time,
|
||||
Hash256::from_slice(DEFAULT_ETH1_BLOCK_HASH),
|
||||
&spec,
|
||||
)?;
|
||||
|
||||
eth2_network_config.genesis_state_bytes = Some(genesis_state.as_ssz_bytes());
|
||||
eth2_network_config.force_write_to_file(testnet_dir)?;
|
||||
|
||||
@@ -284,6 +284,14 @@ fn main() {
|
||||
.takes_value(false)
|
||||
.help("Overwrites any previous testnet configurations"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("interop-genesis-state")
|
||||
.long("interop-genesis-state")
|
||||
.takes_value(false)
|
||||
.help(
|
||||
"If present, a interop-style genesis.ssz file will be generated.",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("min-genesis-time")
|
||||
.long("min-genesis-time")
|
||||
@@ -402,6 +410,36 @@ fn main() {
|
||||
"The epoch at which to enable the Altair hard fork",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("merge-fork-epoch")
|
||||
.long("merge-fork-epoch")
|
||||
.value_name("EPOCH")
|
||||
.takes_value(true)
|
||||
.help(
|
||||
"The epoch at which to enable the Merge hard fork",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("eth1-block-hash")
|
||||
.long("eth1-block-hash")
|
||||
.value_name("BLOCK_HASH")
|
||||
.takes_value(true)
|
||||
.help("The eth1 block hash used when generating a genesis state."),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("validator-count")
|
||||
.long("validator-count")
|
||||
.value_name("INTEGER")
|
||||
.takes_value(true)
|
||||
.help("The number of validators when generating a genesis state."),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("genesis-time")
|
||||
.long("genesis-time")
|
||||
.value_name("INTEGER")
|
||||
.takes_value(true)
|
||||
.help("The genesis time when generating a genesis state."),
|
||||
)
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("check-deposit-data")
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
use clap::ArgMatches;
|
||||
use clap_utils::{parse_optional, parse_required, parse_ssz_optional};
|
||||
use eth2_network_config::Eth2NetworkConfig;
|
||||
use genesis::interop_genesis_state;
|
||||
use ssz::Encode;
|
||||
use std::path::PathBuf;
|
||||
use types::{Address, Config, EthSpec};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use types::{test_utils::generate_deterministic_keypairs, Address, Config, EthSpec};
|
||||
|
||||
pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Result<(), String> {
|
||||
let deposit_contract_address: Address = parse_required(matches, "deposit-contract-address")?;
|
||||
@@ -54,10 +57,35 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
|
||||
spec.altair_fork_epoch = Some(fork_epoch);
|
||||
}
|
||||
|
||||
if let Some(fork_epoch) = parse_optional(matches, "merge-fork-epoch")? {
|
||||
spec.merge_fork_epoch = Some(fork_epoch);
|
||||
}
|
||||
|
||||
let genesis_state_bytes = if matches.is_present("interop-genesis-state") {
|
||||
let eth1_block_hash = parse_required(matches, "eth1-block-hash")?;
|
||||
let validator_count = parse_required(matches, "validator-count")?;
|
||||
let genesis_time = if let Some(time) = parse_optional(matches, "genesis-time")? {
|
||||
time
|
||||
} else {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map_err(|e| format!("Unable to get time: {:?}", e))?
|
||||
.as_secs()
|
||||
};
|
||||
|
||||
let keypairs = generate_deterministic_keypairs(validator_count);
|
||||
let genesis_state =
|
||||
interop_genesis_state::<T>(&keypairs, genesis_time, eth1_block_hash, &spec)?;
|
||||
|
||||
Some(genesis_state.as_ssz_bytes())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let testnet = Eth2NetworkConfig {
|
||||
deposit_contract_deploy_block,
|
||||
boot_enr: Some(vec![]),
|
||||
genesis_state_bytes: None,
|
||||
genesis_state_bytes,
|
||||
config: Config::from_chain_spec::<T>(&spec),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user