mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-19 21:04:41 +00:00
Use OS file locks in validator client (#1958)
## Issue Addressed Closes #1823 ## Proposed Changes * Use OS-level file locking for validator keystores, eliminating problems with lockfiles lingering after ungraceful shutdowns (`SIGKILL`, power outage). I'm using the `fs2` crate because it's cross-platform (unlike `file-lock`), and it seems to have the most downloads on crates.io. * Deprecate + disable `--delete-lockfiles` CLI param, it's no longer necessary * Delete the `validator_dir::Manager`, as it was mostly dead code and was only used in the `validator list` command, which has been rewritten to read the validator definitions YAML instead. ## Additional Info Tested on: - [x] Linux - [x] macOS - [x] Docker Linux - [x] Docker macOS - [ ] Windows
This commit is contained in:
@@ -1,24 +1,28 @@
|
||||
use crate::VALIDATOR_DIR_FLAG;
|
||||
use account_utils::validator_definitions::ValidatorDefinitions;
|
||||
use clap::App;
|
||||
use std::path::PathBuf;
|
||||
use validator_dir::Manager as ValidatorManager;
|
||||
|
||||
pub const CMD: &str = "list";
|
||||
|
||||
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
App::new(CMD).about("Lists the names of all validators.")
|
||||
App::new(CMD).about("Lists the public keys of all validators.")
|
||||
}
|
||||
|
||||
pub fn cli_run(validator_dir: PathBuf) -> Result<(), String> {
|
||||
eprintln!("validator-dir path: {:?}", validator_dir);
|
||||
let mgr = ValidatorManager::open(&validator_dir)
|
||||
.map_err(|e| format!("Unable to read --{}: {:?}", VALIDATOR_DIR_FLAG, e))?;
|
||||
let validator_definitions = ValidatorDefinitions::open(&validator_dir).map_err(|e| {
|
||||
format!(
|
||||
"No validator definitions found in {:?}: {:?}",
|
||||
validator_dir, e
|
||||
)
|
||||
})?;
|
||||
|
||||
for (name, _path) in mgr
|
||||
.directory_names()
|
||||
.map_err(|e| format!("Unable to list validators: {:?}", e))?
|
||||
{
|
||||
println!("{}", name)
|
||||
for def in validator_definitions.as_slice() {
|
||||
println!(
|
||||
"{} ({})",
|
||||
def.voting_public_key,
|
||||
if def.enabled { "enabled" } else { "disabled" }
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user