mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Enforce Optimistic Sync Conditions & CLI Tests (v2) (#3050)
## Description
This PR adds a single, trivial commit (f5d2b27d78) atop #2986 to resolve a tests compile error. The original author (@ethDreamer) is AFK so I'm getting this one merged ☺️
Please see #2986 for more information about the other, significant changes in this PR.
Co-authored-by: Mark Mackey <mark@sigmaprime.io>
Co-authored-by: ethDreamer <37123614+ethDreamer@users.noreply.github.com>
This commit is contained in:
@@ -13,3 +13,7 @@ dirs = "3.0.1"
|
||||
eth2_network_config = { path = "../eth2_network_config" }
|
||||
eth2_ssz = "0.4.1"
|
||||
ethereum-types = "0.12.1"
|
||||
serde = "1.0.116"
|
||||
serde_json = "1.0.59"
|
||||
serde_yaml = "0.8.13"
|
||||
types = { path = "../../consensus/types"}
|
||||
|
||||
@@ -6,6 +6,7 @@ use ethereum_types::U256 as Uint256;
|
||||
use ssz::Decode;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use types::{ChainSpec, Config, EthSpec};
|
||||
|
||||
pub mod flags;
|
||||
|
||||
@@ -52,6 +53,12 @@ pub fn get_eth2_network_config(cli_args: &ArgMatches) -> Result<Eth2NetworkConfi
|
||||
.terminal_block_hash_activation_epoch = epoch;
|
||||
}
|
||||
|
||||
if let Some(slots) = parse_optional(cli_args, "safe-slots-to-import-optimistically")? {
|
||||
eth2_network_config
|
||||
.config
|
||||
.safe_slots_to_import_optimistically = slots;
|
||||
}
|
||||
|
||||
Ok(eth2_network_config)
|
||||
}
|
||||
|
||||
@@ -157,3 +164,29 @@ pub fn parse_ssz_optional<T: Decode>(
|
||||
})
|
||||
.transpose()
|
||||
}
|
||||
|
||||
/// Writes configs to file if `dump-config` or `dump-chain-config` flags are set
|
||||
pub fn check_dump_configs<S, E>(
|
||||
matches: &ArgMatches,
|
||||
config: S,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), String>
|
||||
where
|
||||
S: serde::Serialize,
|
||||
E: EthSpec,
|
||||
{
|
||||
if let Some(dump_path) = parse_optional::<PathBuf>(matches, "dump-config")? {
|
||||
let mut file = std::fs::File::create(dump_path)
|
||||
.map_err(|e| format!("Failed to open file for writing config: {:?}", e))?;
|
||||
serde_json::to_writer(&mut file, &config)
|
||||
.map_err(|e| format!("Error serializing config: {:?}", e))?;
|
||||
}
|
||||
if let Some(dump_path) = parse_optional::<PathBuf>(matches, "dump-chain-config")? {
|
||||
let chain_config = Config::from_chain_spec::<E>(spec);
|
||||
let mut file = std::fs::File::create(dump_path)
|
||||
.map_err(|e| format!("Failed to open file for writing chain config: {:?}", e))?;
|
||||
serde_yaml::to_writer(&mut file, &chain_config)
|
||||
.map_err(|e| format!("Error serializing config: {:?}", e))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ pub enum SensitiveError {
|
||||
}
|
||||
|
||||
// Wrapper around Url which provides a custom `Display` implementation to protect user secrets.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct SensitiveUrl {
|
||||
pub full: Url,
|
||||
pub redacted: String,
|
||||
|
||||
Reference in New Issue
Block a user