6ea3bc5e52
## Issue Addressed NA ## Proposed Changes - Implements a HTTP API for the validator client. - Creates EIP-2335 keystores with an empty `description` field, instead of a missing `description` field. Adds option to set name. - Be more graceful with setups without any validators (yet) - Remove an error log when there are no validators. - Create the `validator` dir if it doesn't exist. - Allow building a `ValidatorDir` without a withdrawal keystore (required for the API method where we only post a voting keystore). - Add optional `description` field to `validator_definitions.yml` ## TODO - [x] Signature header, as per https://github.com/sigp/lighthouse/issues/1269#issuecomment-649879855 - [x] Return validator descriptions - [x] Return deposit data - [x] Respect the mnemonic offset - [x] Check that mnemonic can derive returned keys - [x] Be strict about non-localhost - [x] Allow graceful start without any validators (+ create validator dir) - [x] Docs final pass - [x] Swap to EIP-2335 description field. - [x] Fix Zerioze TODO in VC api types. - [x] Zeroize secp256k1 key ## Endpoints - [x] `GET /lighthouse/version` - [x] `GET /lighthouse/health` - [x] `GET /lighthouse/validators` - [x] `POST /lighthouse/validators/hd` - [x] `POST /lighthouse/validators/keystore` - [x] `PATCH /lighthouse/validators/:validator_pubkey` - [ ] ~~`POST /lighthouse/validators/:validator_pubkey/exit/:epoch`~~ Future works ## Additional Info TBC
35 lines
1.2 KiB
Rust
35 lines
1.2 KiB
Rust
use clap::ArgMatches;
|
|
use std::fs;
|
|
use std::path::PathBuf;
|
|
use validator_dir::Builder as ValidatorBuilder;
|
|
|
|
pub fn run(matches: &ArgMatches) -> Result<(), String> {
|
|
let validator_count: usize = clap_utils::parse_required(matches, "count")?;
|
|
let validators_dir: PathBuf = clap_utils::parse_required(matches, "validators-dir")?;
|
|
let secrets_dir: PathBuf = clap_utils::parse_required(matches, "secrets-dir")?;
|
|
|
|
if !validators_dir.exists() {
|
|
fs::create_dir_all(&validators_dir)
|
|
.map_err(|e| format!("Unable to create validators dir: {:?}", e))?;
|
|
}
|
|
|
|
if !secrets_dir.exists() {
|
|
fs::create_dir_all(&secrets_dir)
|
|
.map_err(|e| format!("Unable to create secrets dir: {:?}", e))?;
|
|
}
|
|
|
|
for i in 0..validator_count {
|
|
println!("Validator {}/{}", i + 1, validator_count);
|
|
|
|
ValidatorBuilder::new(validators_dir.clone())
|
|
.password_dir(secrets_dir.clone())
|
|
.store_withdrawal_keystore(false)
|
|
.insecure_voting_keypair(i)
|
|
.map_err(|e| format!("Unable to generate keys: {:?}", e))?
|
|
.build()
|
|
.map_err(|e| format!("Unable to build validator: {:?}", e))?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|