mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 04:48:21 +00:00
Move account_manager under lighthouse binary
This commit is contained in:
@@ -13,3 +13,4 @@ slog-async = "2.3.0"
|
|||||||
validator_client = { path = "../validator_client" }
|
validator_client = { path = "../validator_client" }
|
||||||
types = { path = "../eth2/types" }
|
types = { path = "../eth2/types" }
|
||||||
dirs = "2.0.2"
|
dirs = "2.0.2"
|
||||||
|
environment = { path = "../lighthouse/environment" }
|
||||||
|
|||||||
54
account_manager/src/cli.rs
Normal file
54
account_manager/src/cli.rs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
use clap::{App, Arg, SubCommand};
|
||||||
|
|
||||||
|
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||||
|
App::new("Account Manager")
|
||||||
|
.visible_aliases(&["am", "accounts", "accounts_manager"])
|
||||||
|
.version("0.0.1")
|
||||||
|
.author("Sigma Prime <contact@sigmaprime.io>")
|
||||||
|
.about("Eth 2.0 Accounts Manager")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("logfile")
|
||||||
|
.long("logfile")
|
||||||
|
.value_name("logfile")
|
||||||
|
.help("File path where output will be written.")
|
||||||
|
.takes_value(true),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("datadir")
|
||||||
|
.long("datadir")
|
||||||
|
.short("d")
|
||||||
|
.value_name("DIR")
|
||||||
|
.help("Data directory for keys and databases.")
|
||||||
|
.takes_value(true),
|
||||||
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("generate")
|
||||||
|
.about("Generates a new validator private key")
|
||||||
|
.version("0.0.1")
|
||||||
|
.author("Sigma Prime <contact@sigmaprime.io>"),
|
||||||
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("generate_deterministic")
|
||||||
|
.about("Generates a deterministic validator private key FOR TESTING")
|
||||||
|
.version("0.0.1")
|
||||||
|
.author("Sigma Prime <contact@sigmaprime.io>")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("validator index")
|
||||||
|
.long("index")
|
||||||
|
.short("i")
|
||||||
|
.value_name("index")
|
||||||
|
.help("The index of the validator, for which the test key is generated")
|
||||||
|
.takes_value(true)
|
||||||
|
.required(true),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("validator count")
|
||||||
|
.long("validator_count")
|
||||||
|
.short("n")
|
||||||
|
.value_name("validator_count")
|
||||||
|
.help("If supplied along with `index`, generates keys `i..i + n`.")
|
||||||
|
.takes_value(true)
|
||||||
|
.default_value("1"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,72 +1,21 @@
|
|||||||
|
mod cli;
|
||||||
|
|
||||||
use bls::Keypair;
|
use bls::Keypair;
|
||||||
use clap::{App, Arg, SubCommand};
|
use clap::ArgMatches;
|
||||||
use slog::{crit, debug, info, o, Drain};
|
use environment::RuntimeContext;
|
||||||
|
use slog::{crit, debug, info};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use types::test_utils::generate_deterministic_keypair;
|
use types::{test_utils::generate_deterministic_keypair, EthSpec};
|
||||||
use validator_client::Config as ValidatorClientConfig;
|
use validator_client::Config as ValidatorClientConfig;
|
||||||
|
|
||||||
|
pub use cli::cli_app;
|
||||||
|
|
||||||
pub const DEFAULT_DATA_DIR: &str = ".lighthouse-validator";
|
pub const DEFAULT_DATA_DIR: &str = ".lighthouse-validator";
|
||||||
pub const CLIENT_CONFIG_FILENAME: &str = "account-manager.toml";
|
pub const CLIENT_CONFIG_FILENAME: &str = "account-manager.toml";
|
||||||
|
|
||||||
fn main() {
|
pub fn run<T: EthSpec>(matches: &ArgMatches, context: RuntimeContext<T>) {
|
||||||
// Logging
|
let mut log = context.log;
|
||||||
let decorator = slog_term::TermDecorator::new().build();
|
|
||||||
let drain = slog_term::CompactFormat::new(decorator).build().fuse();
|
|
||||||
let drain = slog_async::Async::new(drain).build().fuse();
|
|
||||||
let mut log = slog::Logger::root(drain, o!());
|
|
||||||
|
|
||||||
// CLI
|
|
||||||
let matches = App::new("Lighthouse Accounts Manager")
|
|
||||||
.version("0.0.1")
|
|
||||||
.author("Sigma Prime <contact@sigmaprime.io>")
|
|
||||||
.about("Eth 2.0 Accounts Manager")
|
|
||||||
.arg(
|
|
||||||
Arg::with_name("logfile")
|
|
||||||
.long("logfile")
|
|
||||||
.value_name("logfile")
|
|
||||||
.help("File path where output will be written.")
|
|
||||||
.takes_value(true),
|
|
||||||
)
|
|
||||||
.arg(
|
|
||||||
Arg::with_name("datadir")
|
|
||||||
.long("datadir")
|
|
||||||
.short("d")
|
|
||||||
.value_name("DIR")
|
|
||||||
.help("Data directory for keys and databases.")
|
|
||||||
.takes_value(true),
|
|
||||||
)
|
|
||||||
.subcommand(
|
|
||||||
SubCommand::with_name("generate")
|
|
||||||
.about("Generates a new validator private key")
|
|
||||||
.version("0.0.1")
|
|
||||||
.author("Sigma Prime <contact@sigmaprime.io>"),
|
|
||||||
)
|
|
||||||
.subcommand(
|
|
||||||
SubCommand::with_name("generate_deterministic")
|
|
||||||
.about("Generates a deterministic validator private key FOR TESTING")
|
|
||||||
.version("0.0.1")
|
|
||||||
.author("Sigma Prime <contact@sigmaprime.io>")
|
|
||||||
.arg(
|
|
||||||
Arg::with_name("validator index")
|
|
||||||
.long("index")
|
|
||||||
.short("i")
|
|
||||||
.value_name("index")
|
|
||||||
.help("The index of the validator, for which the test key is generated")
|
|
||||||
.takes_value(true)
|
|
||||||
.required(true),
|
|
||||||
)
|
|
||||||
.arg(
|
|
||||||
Arg::with_name("validator count")
|
|
||||||
.long("validator_count")
|
|
||||||
.short("n")
|
|
||||||
.value_name("validator_count")
|
|
||||||
.help("If supplied along with `index`, generates keys `i..i + n`.")
|
|
||||||
.takes_value(true)
|
|
||||||
.default_value("1"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.get_matches();
|
|
||||||
|
|
||||||
let data_dir = match matches
|
let data_dir = match matches
|
||||||
.value_of("datadir")
|
.value_of("datadir")
|
||||||
@@ -18,3 +18,4 @@ slog-async = "^2.3.0"
|
|||||||
environment = { path = "./environment" }
|
environment = { path = "./environment" }
|
||||||
futures = "0.1.25"
|
futures = "0.1.25"
|
||||||
validator_client = { "path" = "../validator_client" }
|
validator_client = { "path" = "../validator_client" }
|
||||||
|
account_manager = { "path" = "../account_manager" }
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ fn main() {
|
|||||||
)
|
)
|
||||||
.subcommand(beacon_node::cli_app())
|
.subcommand(beacon_node::cli_app())
|
||||||
.subcommand(validator_client::cli_app())
|
.subcommand(validator_client::cli_app())
|
||||||
|
.subcommand(account_manager::cli_app())
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
macro_rules! run_with_spec {
|
macro_rules! run_with_spec {
|
||||||
@@ -115,6 +116,16 @@ fn run<E: EthSpec>(
|
|||||||
//
|
//
|
||||||
// Creating a command which can run both might be useful future works.
|
// Creating a command which can run both might be useful future works.
|
||||||
|
|
||||||
|
if let Some(sub_matches) = matches.subcommand_matches("Account Manager") {
|
||||||
|
let runtime_context = environment.core_context();
|
||||||
|
|
||||||
|
account_manager::run(sub_matches, runtime_context);
|
||||||
|
|
||||||
|
// Exit early if the account manager was run. It does not used the tokio executor, so no
|
||||||
|
// need to wait for it to shutdown.
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let beacon_node = if let Some(sub_matches) = matches.subcommand_matches("Beacon Node") {
|
let beacon_node = if let Some(sub_matches) = matches.subcommand_matches("Beacon Node") {
|
||||||
let runtime_context = environment.core_context();
|
let runtime_context = environment.core_context();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user