mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
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
27 lines
601 B
Rust
27 lines
601 B
Rust
use parking_lot::Mutex;
|
|
use types::SignedBeaconBlockHeader;
|
|
|
|
#[derive(Debug, Default)]
|
|
pub struct BlockQueue {
|
|
blocks: Mutex<Vec<SignedBeaconBlockHeader>>,
|
|
}
|
|
|
|
impl BlockQueue {
|
|
pub fn queue(&self, block_header: SignedBeaconBlockHeader) {
|
|
self.blocks.lock().push(block_header)
|
|
}
|
|
|
|
pub fn dequeue(&self) -> Vec<SignedBeaconBlockHeader> {
|
|
let mut blocks = self.blocks.lock();
|
|
std::mem::replace(&mut *blocks, vec![])
|
|
}
|
|
|
|
pub fn len(&self) -> usize {
|
|
self.blocks.lock().len()
|
|
}
|
|
|
|
pub fn is_empty(&self) -> bool {
|
|
self.len() == 0
|
|
}
|
|
}
|