Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate validator client to clap derive #6300

Open
wants to merge 37 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4513851
add derive cli definitions
eserilev Aug 19, 2024
bea2b48
update
eserilev Aug 19, 2024
3768588
change cli
eserilev Aug 19, 2024
1e19018
fix test
eserilev Aug 23, 2024
1a9ad30
cli docs
eserilev Aug 23, 2024
a80452b
fmt
eserilev Aug 23, 2024
99007eb
fix lint issue
eserilev Aug 23, 2024
5f4bf78
fix flag name
eserilev Aug 26, 2024
a944744
fix cli
eserilev Aug 26, 2024
9e7bed2
Merge branch 'unstable' of https://github.com/sigp/lighthouse into cl…
eserilev Aug 26, 2024
49da4e9
reintroduce deprecated flag
eserilev Aug 26, 2024
e8b7996
fix test
eserilev Aug 26, 2024
d986f84
cli fix
eserilev Aug 26, 2024
c90d977
fix test
eserilev Aug 26, 2024
5e96273
fix another test
eserilev Aug 26, 2024
461cc22
fix test
eserilev Sep 3, 2024
4344953
fix test
eserilev Sep 4, 2024
9117690
linting
eserilev Sep 4, 2024
41e0c1a
fix validator crash
eserilev Sep 4, 2024
ea322d2
add additional test
eserilev Sep 4, 2024
8d3c91e
fix vc
eserilev Oct 16, 2024
1fc4429
resolve merge conflicts
eserilev Oct 16, 2024
d0929b9
Fix test
eserilev Oct 16, 2024
68fb7bd
Lint
eserilev Oct 16, 2024
c016661
Fix tests
eserilev Oct 16, 2024
e484019
fix
eserilev Oct 16, 2024
f4fcb77
fix
eserilev Oct 16, 2024
ef9165b
Fix tests
eserilev Oct 16, 2024
bb06e14
Fix tests
eserilev Oct 16, 2024
a273157
Fix tests
eserilev Oct 16, 2024
09920aa
resolve conflicts
eserilev Oct 22, 2024
63b8d60
fix
eserilev Oct 22, 2024
9efccb0
fix
eserilev Oct 23, 2024
26708ac
Merge branch 'unstable' of https://github.com/sigp/lighthouse into cl…
eserilev Oct 23, 2024
80bb142
Fix tests
eserilev Oct 23, 2024
3901113
fix tests
eserilev Oct 24, 2024
7ae2e2a
make gas limit config value non optional
eserilev Oct 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lighthouse/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use clap::Parser;
use database_manager::cli::DatabaseManager;
use serde::{Deserialize, Serialize};
use validator_client::cli::ValidatorClient;

#[derive(Parser, Clone, Deserialize, Serialize, Debug)]
pub enum LighthouseSubcommands {
#[clap(name = "database_manager")]
DatabaseManager(DatabaseManager),
#[clap(name = "validator_client")]
ValidatorClient(ValidatorClient),
}
112 changes: 76 additions & 36 deletions lighthouse/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ fn main() {
)
.subcommand(beacon_node::cli_app())
.subcommand(boot_node::cli_app())
.subcommand(validator_client::cli_app())
.subcommand(account_manager::cli_app())
.subcommand(validator_manager::cli_app());

Expand Down Expand Up @@ -682,81 +681,122 @@ fn run<E: EthSpec>(
return Ok(());
}

if let Ok(LighthouseSubcommands::DatabaseManager(db_manager_config)) =
LighthouseSubcommands::from_arg_matches(matches)
{
info!(log, "Running database manager for {} network", network_name);
database_manager::run(matches, &db_manager_config, environment)?;
return Ok(());
};

info!(log, "Lighthouse started"; "version" => VERSION);
info!(
log,
"Configured for network";
"name" => &network_name
);

match matches.subcommand() {
Some(("beacon_node", matches)) => {
match LighthouseSubcommands::from_arg_matches(matches) {
Ok(LighthouseSubcommands::DatabaseManager(db_manager_config)) => {
info!(log, "Running database manager for {} network", network_name);
database_manager::run(matches, &db_manager_config, environment)?;
return Ok(());
}
Ok(LighthouseSubcommands::ValidatorClient(validator_client_config)) => {
let context = environment.core_context();
let log = context.log().clone();
let executor = context.executor.clone();
let mut config = beacon_node::get_config::<E>(matches, &context)?;
config.logger_config = logger_config;
let config = validator_client::Config::from_cli(
matches,
&validator_client_config,
context.log(),
)
.map_err(|e| format!("Unable to initialize validator config: {}", e))?;
// Dump configs if `dump-config` or `dump-chain-config` flags are set
clap_utils::check_dump_configs::<_, E>(matches, &config, &context.eth2_config.spec)?;

let shutdown_flag = matches.get_flag("immediate-shutdown");
if shutdown_flag {
info!(log, "Beacon node immediate shutdown triggered.");
info!(log, "Validator client immediate shutdown triggered.");
return Ok(());
}

executor.clone().spawn(
async move {
if let Err(e) = ProductionBeaconNode::new(context.clone(), config).await {
crit!(log, "Failed to start beacon node"; "reason" => e);
if let Err(e) = ProductionValidatorClient::new(context, config)
.and_then(|mut vc| async move { vc.start_service().await })
.await
{
crit!(log, "Failed to start validator client"; "reason" => e);
// Ignore the error since it always occurs during normal operation when
// shutting down.
let _ = executor
.shutdown_sender()
.try_send(ShutdownReason::Failure("Failed to start beacon node"));
.try_send(ShutdownReason::Failure("Failed to start validator client"));
}
},
"beacon_node",
"validator_client",
);
}
Some(("validator_client", matches)) => {
Err(_) => (),
};

info!(log, "Lighthouse started"; "version" => VERSION);
info!(
log,
"Configured for network";
"name" => &network_name
);

if let Ok(LighthouseSubcommands::ValidatorClient(validator_client_config)) =
LighthouseSubcommands::from_arg_matches(matches)
{
let context = environment.core_context();
let log = context.log().clone();
let executor = context.executor.clone();
let config =
validator_client::Config::from_cli(matches, &validator_client_config, context.log())
.map_err(|e| format!("Unable to initialize validator config: {}", e))?;
// Dump configs if `dump-config` or `dump-chain-config` flags are set
clap_utils::check_dump_configs::<_, E>(matches, &config, &context.eth2_config.spec)?;

let shutdown_flag = matches.get_flag("immediate-shutdown");
if shutdown_flag {
info!(log, "Validator client immediate shutdown triggered.");
return Ok(());
}

executor.clone().spawn(
async move {
if let Err(e) = ProductionValidatorClient::new(context, config)
.and_then(|mut vc| async move { vc.start_service().await })
.await
{
crit!(log, "Failed to start validator client"; "reason" => e);
// Ignore the error since it always occurs during normal operation when
// shutting down.
let _ = executor
.shutdown_sender()
.try_send(ShutdownReason::Failure("Failed to start validator client"));
}
},
"validator_client",
);
};

match matches.subcommand() {
Some(("beacon_node", matches)) => {
let context = environment.core_context();
let log = context.log().clone();
let executor = context.executor.clone();
let config = validator_client::Config::from_cli(matches, context.log())
.map_err(|e| format!("Unable to initialize validator config: {}", e))?;
let mut config = beacon_node::get_config::<E>(matches, &context)?;
config.logger_config = logger_config;
// Dump configs if `dump-config` or `dump-chain-config` flags are set
clap_utils::check_dump_configs::<_, E>(matches, &config, &context.eth2_config.spec)?;

let shutdown_flag = matches.get_flag("immediate-shutdown");
if shutdown_flag {
info!(log, "Validator client immediate shutdown triggered.");
info!(log, "Beacon node immediate shutdown triggered.");
return Ok(());
}

executor.clone().spawn(
async move {
if let Err(e) = ProductionValidatorClient::new(context, config)
.and_then(|mut vc| async move { vc.start_service().await })
.await
{
crit!(log, "Failed to start validator client"; "reason" => e);
if let Err(e) = ProductionBeaconNode::new(context.clone(), config).await {
crit!(log, "Failed to start beacon node"; "reason" => e);
// Ignore the error since it always occurs during normal operation when
// shutting down.
let _ = executor
.shutdown_sender()
.try_send(ShutdownReason::Failure("Failed to start validator client"));
.try_send(ShutdownReason::Failure("Failed to start beacon node"));
}
},
"validator_client",
"beacon_node",
);
}
_ => {
Expand Down
Loading
Loading