mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 05:48:31 +00:00
Implement slasher (#1567)
This is an implementation of a slasher that lives inside the BN and can be enabled via `lighthouse bn --slasher`. Features included in this PR: - [x] Detection of attester slashing conditions (double votes, surrounds existing, surrounded by existing) - [x] Integration into Lighthouse's attestation verification flow - [x] Detection of proposer slashing conditions - [x] Extraction of attestations from blocks as they are verified - [x] Compression of chunks - [x] Configurable history length - [x] Pruning of old attestations and blocks - [x] More tests Future work: * Focus on a slice of history separate from the most recent N epochs (e.g. epochs `current - K` to `current - M`) * Run out-of-process * Ingest attestations from the chain without a resync Design notes are here https://hackmd.io/@sproul/HJSEklmPL
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use clap::ArgMatches;
|
||||
pub use eth2_testnet_config::DEFAULT_HARDCODED_TESTNET;
|
||||
use std::fs::create_dir_all;
|
||||
use std::fs::{self, create_dir_all};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Names for the default directories.
|
||||
@@ -58,3 +58,21 @@ pub fn parse_path_or_default_with_flag(
|
||||
.join(flag),
|
||||
)
|
||||
}
|
||||
|
||||
/// Get the approximate size of a directory and its contents.
|
||||
///
|
||||
/// Will skip unreadable files, and files. Not 100% accurate if files are being created and deleted
|
||||
/// while this function is running.
|
||||
pub fn size_of_dir(path: &Path) -> u64 {
|
||||
if let Ok(iter) = fs::read_dir(path) {
|
||||
iter.filter_map(std::result::Result::ok)
|
||||
.map(size_of_dir_entry)
|
||||
.sum()
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fn size_of_dir_entry(dir: fs::DirEntry) -> u64 {
|
||||
dir.metadata().map(|m| m.len()).unwrap_or(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user