mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 11:41:51 +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 @@
|
||||
pub use lighthouse_metrics::{set_gauge, try_create_int_gauge, *};
|
||||
|
||||
use std::fs;
|
||||
use directory::size_of_dir;
|
||||
use std::path::Path;
|
||||
|
||||
lazy_static! {
|
||||
@@ -134,17 +134,3 @@ pub fn scrape_for_metrics(db_path: &Path, freezer_db_path: &Path) {
|
||||
let freezer_db_size = size_of_dir(freezer_db_path);
|
||||
set_gauge(&FREEZER_DB_SIZE, freezer_db_size as i64);
|
||||
}
|
||||
|
||||
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