mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +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:
@@ -17,8 +17,10 @@ use beacon_chain::{
|
||||
};
|
||||
use clap::ArgMatches;
|
||||
use environment::RuntimeContext;
|
||||
use slasher::Slasher;
|
||||
use slog::{info, warn};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::Arc;
|
||||
use types::EthSpec;
|
||||
|
||||
/// A type-alias to the tighten the definition of a production-intended `Client`.
|
||||
@@ -82,6 +84,16 @@ impl<E: EthSpec> ProductionBeaconNode<E> {
|
||||
.http_api_config(client_config.http_api.clone())
|
||||
.disk_store(&db_path, &freezer_db_path_res?, store_config)?;
|
||||
|
||||
let builder = if let Some(slasher_config) = client_config.slasher.clone() {
|
||||
let slasher = Arc::new(
|
||||
Slasher::open(slasher_config, log.new(slog::o!("service" => "slasher")))
|
||||
.map_err(|e| format!("Slasher open error: {:?}", e))?,
|
||||
);
|
||||
builder.slasher(slasher)
|
||||
} else {
|
||||
builder
|
||||
};
|
||||
|
||||
let builder = builder
|
||||
.beacon_chain_builder(client_genesis, client_config_1)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user