mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Fix genesis state download panic when running in debug mode (#4753)
## Issue Addressed #4738 ## Proposed Changes See the above issue for details. Went with option #2 to use the async reqwest client in `Eth2NetworkConfig` and propagate the async-ness.
This commit is contained in:
@@ -25,7 +25,7 @@ pub struct BootNodeConfig<T: EthSpec> {
|
||||
}
|
||||
|
||||
impl<T: EthSpec> BootNodeConfig<T> {
|
||||
pub fn new(
|
||||
pub async fn new(
|
||||
matches: &ArgMatches<'_>,
|
||||
eth2_network_config: &Eth2NetworkConfig,
|
||||
) -> Result<Self, String> {
|
||||
@@ -99,7 +99,7 @@ impl<T: EthSpec> BootNodeConfig<T> {
|
||||
|
||||
if eth2_network_config.genesis_state_is_known() {
|
||||
let genesis_state = eth2_network_config
|
||||
.genesis_state::<T>(genesis_state_url.as_deref(), genesis_state_url_timeout, &logger)?
|
||||
.genesis_state::<T>(genesis_state_url.as_deref(), genesis_state_url_timeout, &logger).await?
|
||||
.ok_or_else(|| {
|
||||
"The genesis state for this network is not known, this is an unsupported mode"
|
||||
.to_string()
|
||||
|
||||
@@ -7,7 +7,7 @@ mod cli;
|
||||
pub mod config;
|
||||
mod server;
|
||||
pub use cli::cli_app;
|
||||
use config::{BootNodeConfig, BootNodeConfigSerialization};
|
||||
use config::BootNodeConfig;
|
||||
use types::{EthSpec, EthSpecId};
|
||||
|
||||
const LOG_CHANNEL_SIZE: usize = 2048;
|
||||
@@ -81,20 +81,13 @@ fn main<T: EthSpec>(
|
||||
.build()
|
||||
.map_err(|e| format!("Failed to build runtime: {}", e))?;
|
||||
|
||||
// parse the CLI args into a useable config
|
||||
let config: BootNodeConfig<T> = BootNodeConfig::new(bn_matches, eth2_network_config)?;
|
||||
|
||||
// Dump configs if `dump-config` or `dump-chain-config` flags are set
|
||||
let config_sz = BootNodeConfigSerialization::from_config_ref(&config);
|
||||
clap_utils::check_dump_configs::<_, T>(
|
||||
lh_matches,
|
||||
&config_sz,
|
||||
ð2_network_config.chain_spec::<T>()?,
|
||||
)?;
|
||||
|
||||
// Run the boot node
|
||||
if !lh_matches.is_present("immediate-shutdown") {
|
||||
runtime.block_on(server::run(config, log));
|
||||
}
|
||||
runtime.block_on(server::run::<T>(
|
||||
lh_matches,
|
||||
bn_matches,
|
||||
eth2_network_config,
|
||||
log,
|
||||
))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! The main bootnode server execution.
|
||||
|
||||
use super::BootNodeConfig;
|
||||
use crate::config::BootNodeConfigSerialization;
|
||||
use clap::ArgMatches;
|
||||
use eth2_network_config::Eth2NetworkConfig;
|
||||
use lighthouse_network::{
|
||||
discv5::{enr::NodeId, Discv5, Discv5Event},
|
||||
EnrExt, Eth2Enr,
|
||||
@@ -8,7 +11,27 @@ use lighthouse_network::{
|
||||
use slog::info;
|
||||
use types::EthSpec;
|
||||
|
||||
pub async fn run<T: EthSpec>(config: BootNodeConfig<T>, log: slog::Logger) {
|
||||
pub async fn run<T: EthSpec>(
|
||||
lh_matches: &ArgMatches<'_>,
|
||||
bn_matches: &ArgMatches<'_>,
|
||||
eth2_network_config: &Eth2NetworkConfig,
|
||||
log: slog::Logger,
|
||||
) -> Result<(), String> {
|
||||
// parse the CLI args into a useable config
|
||||
let config: BootNodeConfig<T> = BootNodeConfig::new(bn_matches, eth2_network_config).await?;
|
||||
|
||||
// Dump configs if `dump-config` or `dump-chain-config` flags are set
|
||||
let config_sz = BootNodeConfigSerialization::from_config_ref(&config);
|
||||
clap_utils::check_dump_configs::<_, T>(
|
||||
lh_matches,
|
||||
&config_sz,
|
||||
ð2_network_config.chain_spec::<T>()?,
|
||||
)?;
|
||||
|
||||
if lh_matches.is_present("immediate-shutdown") {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let BootNodeConfig {
|
||||
boot_nodes,
|
||||
local_enr,
|
||||
@@ -65,8 +88,7 @@ pub async fn run<T: EthSpec>(config: BootNodeConfig<T>, log: slog::Logger) {
|
||||
|
||||
// start the server
|
||||
if let Err(e) = discv5.start().await {
|
||||
slog::crit!(log, "Could not start discv5 server"; "error" => %e);
|
||||
return;
|
||||
return Err(format!("Could not start discv5 server: {e:?}"));
|
||||
}
|
||||
|
||||
// if there are peers in the local routing table, establish a session by running a query
|
||||
@@ -82,8 +104,7 @@ pub async fn run<T: EthSpec>(config: BootNodeConfig<T>, log: slog::Logger) {
|
||||
let mut event_stream = match discv5.event_stream().await {
|
||||
Ok(stream) => stream,
|
||||
Err(e) => {
|
||||
slog::crit!(log, "Failed to obtain event stream"; "error" => %e);
|
||||
return;
|
||||
return Err(format!("Failed to obtain event stream: {e:?}"));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user