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:
Michael Sproul
2020-11-26 11:25:46 +00:00
parent fc07cc3fdf
commit 3486d6a809
21 changed files with 282 additions and 411 deletions

22
Cargo.lock generated
View File

@@ -2074,6 +2074,7 @@ version = "0.1.0"
dependencies = [
"eth2_keystore",
"eth2_wallet",
"lockfile",
"tempfile",
]
@@ -2273,6 +2274,16 @@ dependencies = [
"percent-encoding 2.1.0",
]
[[package]]
name = "fs2"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
dependencies = [
"libc",
"winapi 0.3.9",
]
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
@@ -3791,6 +3802,14 @@ dependencies = [
"scopeguard",
]
[[package]]
name = "lockfile"
version = "0.1.0"
dependencies = [
"fs2",
"tempdir",
]
[[package]]
name = "log"
version = "0.3.9"
@@ -7387,6 +7406,7 @@ dependencies = [
"libsecp256k1",
"lighthouse_metrics",
"lighthouse_version",
"lockfile",
"logging",
"parking_lot 0.11.1",
"rand 0.7.3",
@@ -7419,8 +7439,10 @@ version = "0.1.0"
dependencies = [
"bls",
"deposit_contract",
"derivative",
"eth2_keystore",
"hex",
"lockfile",
"rand 0.7.3",
"rayon",
"slog",