Improve ergonomics of adding a new network config (#2489)

## Issue Addressed

NA

## Proposed Changes

This PR adds some more fancy macro magic to make it easier to add a new built-in (aka "baked-in") testnet config to the `lighthouse` binary.

Previously, a user needed to modify several files and repeat themselves several times. Now, they only need to add a single definition in the `eth2_config` crate. No repetition 🎉
This commit is contained in:
Paul Hauner
2021-08-30 23:27:28 +00:00
parent b4dd98b3c6
commit 1031f79aca
6 changed files with 191 additions and 66 deletions

View File

@@ -8,7 +8,7 @@ use clap_utils::flags::DISABLE_MALLOC_TUNING_FLAG;
use env_logger::{Builder, Env};
use environment::EnvironmentBuilder;
use eth2_hashing::have_sha_extensions;
use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK};
use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK, HARDCODED_NET_NAMES};
use lighthouse_version::VERSION;
use malloc_utils::configure_memory_allocator;
use slog::{crit, info, warn};
@@ -127,7 +127,7 @@ fn main() {
.long("network")
.value_name("network")
.help("Name of the Eth2 chain Lighthouse will sync and follow.")
.possible_values(&["pyrmont", "mainnet", "prater"])
.possible_values(HARDCODED_NET_NAMES)
.conflicts_with("testnet-dir")
.takes_value(true)
.global(true)