mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
upgrade clap to v4.5 (#5273)
* upgrade clap to v4.5 * cli fixes * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * value parser for mnemonic * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * merge unstable * default --format val * fix eth sim * fix eth sim * merge conflicts * resolve beta compiler issue * add num args, version * add custom flag parser, make rate limiter flags clap friendly * remove unneeded check * fmt * update * alphabetic order * resolve merge conflict * fix test * resolve conflicts * fix test * revert removed if statement * fmt got me again * fix broken flag * make cli * make cli * update * remove -e files * update * cli help updates * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * cli help updates * md files * merge conflict * merge conflicts * md * help text, text width, and a few flag fixes * fmt * merge * revert * revert * resolve merge conflicts * merge conflicts * revert simulator changes * require at least one arg * fix eth sim cli * resolve merge conflicts * book changes * md changes * cli check * cli check * retry cli check * retry cli check * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * cli * Merge remote-tracking branch 'origin/unstable' into upgrade-clap-cli * Update CLI docs for Goerli removal * Fix cargo lock
This commit is contained in:
@@ -1,18 +1,29 @@
|
||||
//! Simple logic for spawning a Lighthouse BootNode.
|
||||
|
||||
use clap::{App, Arg};
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use clap_utils::{get_color_style, FLAG_HEADER};
|
||||
|
||||
// TODO: Add DOS prevention CLI params
|
||||
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
App::new("boot_node")
|
||||
pub fn cli_app() -> Command {
|
||||
Command::new("boot_node")
|
||||
.about("Start a special Lighthouse process that only serves as a discv5 boot-node. This \
|
||||
process will *not* import blocks or perform most typical beacon node functions. Instead, it \
|
||||
will simply run the discv5 service and assist nodes on the network to discover each other. \
|
||||
This is the recommended way to provide a network boot-node since it has a reduced attack \
|
||||
surface compared to a full beacon node.")
|
||||
.settings(&[clap::AppSettings::ColoredHelp])
|
||||
.styles(get_color_style())
|
||||
.display_order(0)
|
||||
.arg(
|
||||
Arg::with_name("enr-address")
|
||||
Arg::new("help")
|
||||
.long("help")
|
||||
.short('h')
|
||||
.help("Prints help information")
|
||||
.action(ArgAction::HelpLong)
|
||||
.display_order(0)
|
||||
.help_heading(FLAG_HEADER)
|
||||
)
|
||||
.arg(
|
||||
Arg::new("enr-address")
|
||||
.long("enr-address")
|
||||
.value_name("ADDRESS")
|
||||
.help("The IP address/ DNS address to broadcast to other peers on how to reach \
|
||||
@@ -21,31 +32,33 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
discovery. Set this only if you are sure other nodes can connect to your \
|
||||
local node on this address. This will update the `ip4` or `ip6` ENR fields \
|
||||
accordingly. To update both, set this flag twice with the different values.")
|
||||
.multiple(true)
|
||||
.max_values(2)
|
||||
.action(ArgAction::Append)
|
||||
.num_args(1..=2)
|
||||
.required(true)
|
||||
.conflicts_with("network-dir")
|
||||
.takes_value(true),
|
||||
.display_order(0)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("port")
|
||||
Arg::new("port")
|
||||
.long("port")
|
||||
.value_name("PORT")
|
||||
.help("The UDP port to listen on.")
|
||||
.default_value("9000")
|
||||
.takes_value(true)
|
||||
.action(ArgAction::Set)
|
||||
.display_order(0)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("port6")
|
||||
Arg::new("port6")
|
||||
.long("port6")
|
||||
.value_name("PORT")
|
||||
.help("The UDP port to listen on over IpV6 when listening over both Ipv4 and \
|
||||
Ipv6. Defaults to 9090 when required.")
|
||||
.default_value("9090")
|
||||
.takes_value(true),
|
||||
.action(ArgAction::Set)
|
||||
.display_order(0)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("listen-address")
|
||||
Arg::new("listen-address")
|
||||
.long("listen-address")
|
||||
.value_name("ADDRESS")
|
||||
.help("The address the bootnode will listen for UDP communications. To listen \
|
||||
@@ -56,53 +69,63 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
- --listen-address '0.0.0.0' --listen-address '::' will listen over both \
|
||||
Ipv4 and Ipv6. The order of the given addresses is not relevant. However, \
|
||||
multiple Ipv4, or multiple Ipv6 addresses will not be accepted.")
|
||||
.multiple(true)
|
||||
.max_values(2)
|
||||
.num_args(1..=2)
|
||||
.default_value("0.0.0.0")
|
||||
.takes_value(true)
|
||||
.action(ArgAction::Append)
|
||||
.display_order(0)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("boot-nodes")
|
||||
Arg::new("boot-nodes")
|
||||
.long("boot-nodes")
|
||||
.allow_hyphen_values(true)
|
||||
.value_name("ENR-LIST/Multiaddr")
|
||||
.help("One or more comma-delimited base64-encoded ENR's or multiaddr strings of peers to initially add to the local routing table")
|
||||
.takes_value(true),
|
||||
.action(ArgAction::Set)
|
||||
.display_order(0)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("enr-udp-port")
|
||||
Arg::new("enr-udp-port")
|
||||
.long("enr-port")
|
||||
.value_name("PORT")
|
||||
.help("The UDP port of the boot node's ENR. This is the port that external peers will dial to reach this boot node. Set this only if the external port differs from the listening port.")
|
||||
.takes_value(true)
|
||||
.action(ArgAction::Set)
|
||||
.conflicts_with("network-dir")
|
||||
.display_order(0)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("enr-udp6-port")
|
||||
Arg::new("enr-udp6-port")
|
||||
.long("enr-udp6-port")
|
||||
.value_name("PORT")
|
||||
.help("The UDP6 port of the local ENR. Set this only if you are sure other nodes \
|
||||
can connect to your local node on this port over IpV6.")
|
||||
.conflicts_with("network-dir")
|
||||
.takes_value(true),
|
||||
.action(ArgAction::Set)
|
||||
.display_order(0)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("enable-enr-auto-update")
|
||||
.short("x")
|
||||
Arg::new("enable-enr-auto-update")
|
||||
.short('x')
|
||||
.action(ArgAction::SetTrue)
|
||||
.help_heading(FLAG_HEADER)
|
||||
.long("enable-enr-auto-update")
|
||||
.help("Discovery can automatically update the node's local ENR with an external IP address and port as seen by other peers on the network. \
|
||||
This enables this feature.")
|
||||
.display_order(0)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("disable-packet-filter")
|
||||
Arg::new("disable-packet-filter")
|
||||
.action(ArgAction::SetTrue)
|
||||
.help_heading(FLAG_HEADER)
|
||||
.long("disable-packet-filter")
|
||||
.help("Disables discv5 packet filter. Useful for testing in smaller networks")
|
||||
.display_order(0)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("network-dir")
|
||||
Arg::new("network-dir")
|
||||
.value_name("NETWORK_DIR")
|
||||
.long("network-dir")
|
||||
.help("The directory which contains the enr and it's associated private key")
|
||||
.takes_value(true)
|
||||
.action(ArgAction::Set)
|
||||
.display_order(0)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -25,11 +25,10 @@ pub struct BootNodeConfig<E: EthSpec> {
|
||||
|
||||
impl<E: EthSpec> BootNodeConfig<E> {
|
||||
pub async fn new(
|
||||
matches: &ArgMatches<'_>,
|
||||
matches: &ArgMatches,
|
||||
eth2_network_config: &Eth2NetworkConfig,
|
||||
) -> Result<Self, String> {
|
||||
let data_dir = get_data_dir(matches);
|
||||
|
||||
// Try and obtain bootnodes
|
||||
|
||||
let boot_nodes = {
|
||||
@@ -39,7 +38,7 @@ impl<E: EthSpec> BootNodeConfig<E> {
|
||||
boot_nodes.extend_from_slice(enr);
|
||||
}
|
||||
|
||||
if let Some(nodes) = matches.value_of("boot-nodes") {
|
||||
if let Some(nodes) = matches.get_one::<String>("boot-nodes") {
|
||||
boot_nodes.extend_from_slice(
|
||||
&nodes
|
||||
.split(',')
|
||||
@@ -81,14 +80,14 @@ impl<E: EthSpec> BootNodeConfig<E> {
|
||||
};
|
||||
|
||||
// By default this is enabled. If it is not set, revert to false.
|
||||
if !matches.is_present("enable-enr-auto-update") {
|
||||
if !matches.get_flag("enable-enr-auto-update") {
|
||||
network_config.discv5_config.enr_update = false;
|
||||
}
|
||||
|
||||
let private_key = load_private_key(&network_config, &logger);
|
||||
let local_key = CombinedKey::from_libp2p(private_key)?;
|
||||
|
||||
let local_enr = if let Some(dir) = matches.value_of("network-dir") {
|
||||
let local_enr = if let Some(dir) = matches.get_one::<String>("network-dir") {
|
||||
let network_dir: PathBuf = dir.into();
|
||||
load_enr_from_disk(&network_dir)?
|
||||
} else {
|
||||
|
||||
@@ -14,8 +14,8 @@ const LOG_CHANNEL_SIZE: usize = 2048;
|
||||
|
||||
/// Run the bootnode given the CLI configuration.
|
||||
pub fn run(
|
||||
lh_matches: &ArgMatches<'_>,
|
||||
bn_matches: &ArgMatches<'_>,
|
||||
lh_matches: &ArgMatches,
|
||||
bn_matches: &ArgMatches,
|
||||
eth_spec_id: EthSpecId,
|
||||
eth2_network_config: &Eth2NetworkConfig,
|
||||
debug_level: String,
|
||||
@@ -67,8 +67,8 @@ pub fn run(
|
||||
}
|
||||
|
||||
fn main<E: EthSpec>(
|
||||
lh_matches: &ArgMatches<'_>,
|
||||
bn_matches: &ArgMatches<'_>,
|
||||
lh_matches: &ArgMatches,
|
||||
bn_matches: &ArgMatches,
|
||||
eth2_network_config: &Eth2NetworkConfig,
|
||||
log: slog::Logger,
|
||||
) -> Result<(), String> {
|
||||
|
||||
@@ -12,8 +12,8 @@ use slog::info;
|
||||
use types::EthSpec;
|
||||
|
||||
pub async fn run<E: EthSpec>(
|
||||
lh_matches: &ArgMatches<'_>,
|
||||
bn_matches: &ArgMatches<'_>,
|
||||
lh_matches: &ArgMatches,
|
||||
bn_matches: &ArgMatches,
|
||||
eth2_network_config: &Eth2NetworkConfig,
|
||||
log: slog::Logger,
|
||||
) -> Result<(), String> {
|
||||
@@ -28,7 +28,7 @@ pub async fn run<E: EthSpec>(
|
||||
ð2_network_config.chain_spec::<E>()?,
|
||||
)?;
|
||||
|
||||
if lh_matches.is_present("immediate-shutdown") {
|
||||
if lh_matches.get_flag("immediate-shutdown") {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user