Files
lighthouse/boot_node/src/lib.rs
Michael Sproul 36bd4d87f0 Update to spec v1.0.0-rc.0 and BLSv4 (#1765)
## 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>
2020-10-28 22:19:38 +00:00

75 lines
2.6 KiB
Rust

//! Creates a simple DISCV5 server which can be used to bootstrap an Eth2 network.
use clap::ArgMatches;
use slog::{o, Drain, Level, Logger};
use std::convert::TryFrom;
mod cli;
mod config;
mod server;
pub use cli::cli_app;
use config::BootNodeConfig;
use types::{EthSpec, EthSpecId};
const LOG_CHANNEL_SIZE: usize = 2048;
/// Run the bootnode given the CLI configuration.
pub fn run(matches: &ArgMatches<'_>, eth_spec_id: EthSpecId, debug_level: String) {
let debug_level = match debug_level.as_str() {
"trace" => log::Level::Trace,
"debug" => log::Level::Debug,
"info" => log::Level::Info,
"warn" => log::Level::Warn,
"error" => log::Level::Error,
"crit" => log::Level::Error,
_ => unreachable!(),
};
// Setting up the initial logger format and building it.
let drain = {
let decorator = slog_term::TermDecorator::new().build();
let decorator = logging::AlignedTermDecorator::new(decorator, logging::MAX_MESSAGE_WIDTH);
let drain = slog_term::FullFormat::new(decorator).build().fuse();
slog_async::Async::new(drain)
.chan_size(LOG_CHANNEL_SIZE)
.build()
};
let drain = match debug_level {
log::Level::Info => drain.filter_level(Level::Info),
log::Level::Debug => drain.filter_level(Level::Debug),
log::Level::Trace => drain.filter_level(Level::Trace),
log::Level::Warn => drain.filter_level(Level::Warning),
log::Level::Error => drain.filter_level(Level::Error),
};
let logger = Logger::root(drain.fuse(), o!());
let _scope_guard = slog_scope::set_global_logger(logger);
let _log_guard = slog_stdlog::init_with_level(debug_level).unwrap();
let log = slog_scope::logger();
// Run the main function emitting any errors
if let Err(e) = match eth_spec_id {
EthSpecId::Minimal => main::<types::MinimalEthSpec>(matches, log),
EthSpecId::Mainnet => main::<types::MainnetEthSpec>(matches, log),
EthSpecId::V012Legacy => main::<types::V012LegacyEthSpec>(matches, log),
} {
slog::crit!(slog_scope::logger(), "{}", e);
}
}
fn main<T: EthSpec>(matches: &ArgMatches<'_>, log: slog::Logger) -> Result<(), String> {
// Builds a custom executor for the bootnode
let mut runtime = tokio::runtime::Builder::new()
.threaded_scheduler()
.enable_all()
.build()
.map_err(|e| format!("Failed to build runtime: {}", e))?;
// parse the CLI args into a useable config
let config: BootNodeConfig<T> = BootNodeConfig::try_from(matches)?;
// Run the boot node
runtime.block_on(server::run(config, log));
Ok(())
}