58e52f8f40
## Issue Addressed Closes https://github.com/sigp/lighthouse/issues/2159 ## Proposed Changes Rather than trying to write the validator definitions to disk directly, use a temporary file called `.validator_defintions.yml.tmp` and then atomically rename it to `validator_definitions.yml`. This avoids truncating the primary file, which can cause permanent damage when the disk is full. The same treatment is also applied to the validator key cache, although the situation is less dire if it becomes corrupted because it can just be deleted without the user having to reimport keys or resupply passwords. ## Additional Info * `File::create` truncates upon opening: https://doc.rust-lang.org/std/fs/struct.File.html#method.create * `fs::rename` uses `rename` on UNIX and `MoveFileEx` on Windows: https://doc.rust-lang.org/std/fs/fn.rename.html * UNIX `rename` call is atomic: https://unix.stackexchange.com/questions/322038/is-mv-atomic-on-my-fs * Windows `MoveFileEx` is _not_ atomic in general, and Windows lacks any clear API for atomic file renames :( https://stackoverflow.com/questions/167414/is-an-atomic-file-rename-with-overwrite-possible-on-windows ## Further Work * Consider whether we want to try a different Windows syscall as part of #2333. The `rust-atomicwrites` crate seems promising, but actually uses the same syscall under the hood presently: https://github.com/untitaker/rust-atomicwrites/issues/27. |
||
---|---|---|
.. | ||
account_utils | ||
clap_utils | ||
compare_fields | ||
compare_fields_derive | ||
deposit_contract | ||
directory | ||
eth2 | ||
eth2_config | ||
eth2_interop_keypairs | ||
eth2_network_config | ||
eth2_wallet_manager | ||
fallback | ||
hashset_delay | ||
lighthouse_metrics | ||
lighthouse_version | ||
lockfile | ||
logging | ||
lru_cache | ||
remote_signer_consumer | ||
rest_types | ||
sensitive_url | ||
slot_clock | ||
task_executor | ||
test_random_derive | ||
validator_dir | ||
warp_utils | ||
README.md |
eth2
Common crates containing eth2-specific logic.