mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 21:38:31 +00:00
De-duplicate attestations in the slasher (#2767)
## Issue Addressed
Closes https://github.com/sigp/lighthouse/issues/2112
Closes https://github.com/sigp/lighthouse/issues/1861
## Proposed Changes
Collect attestations by validator index in the slasher, and use the magic of reference counting to automatically discard redundant attestations. This results in us storing only 1-2% of the attestations observed when subscribed to all subnets, which carries over to a 50-100x reduction in data stored 🎉
## Additional Info
There's some nuance to the configuration of the `slot-offset`. It has a profound effect on the effictiveness of de-duplication, see the docs added to the book for an explanation: 5442e695e5/book/src/slasher.md (slot-offset)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::sync::Arc;
|
||||
use tree_hash::TreeHash as _;
|
||||
use tree_hash_derive::TreeHash;
|
||||
use types::{AggregateSignature, EthSpec, Hash256, IndexedAttestation, VariableList};
|
||||
@@ -11,6 +12,21 @@ pub struct AttesterRecord {
|
||||
pub indexed_attestation_hash: Hash256,
|
||||
}
|
||||
|
||||
/// Bundling of an `IndexedAttestation` with an `AttesterRecord`.
|
||||
///
|
||||
/// This struct gets `Arc`d and passed around between each stage of queueing and processing.
|
||||
#[derive(Debug)]
|
||||
pub struct IndexedAttesterRecord<E: EthSpec> {
|
||||
pub indexed: IndexedAttestation<E>,
|
||||
pub record: AttesterRecord,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> IndexedAttesterRecord<E> {
|
||||
pub fn new(indexed: IndexedAttestation<E>, record: AttesterRecord) -> Arc<Self> {
|
||||
Arc::new(IndexedAttesterRecord { indexed, record })
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Encode, Decode, TreeHash)]
|
||||
struct IndexedAttestationHeader<T: EthSpec> {
|
||||
pub attesting_indices: VariableList<u64, T::MaxValidatorsPerCommittee>,
|
||||
|
||||
Reference in New Issue
Block a user