mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
## Issue Addressed Closes #2119 ## Proposed Changes Update the slasher schema version to v2 for the breaking changes to the config introduced in #2079. Implement a migration from v1 to v2 so that users can seamlessly upgrade from any version of Lighthouse <=1.0.5. Users who deleted their database for v1.0.5 can upgrade to a release including this patch without any manual intervention. Similarly, any users still on v1.0.4 or earlier can now upgrade without having to drop their database.
67 lines
2.0 KiB
Rust
67 lines
2.0 KiB
Rust
#![deny(missing_debug_implementations)]
|
|
|
|
mod array;
|
|
mod attestation_queue;
|
|
mod attester_record;
|
|
mod batch_stats;
|
|
mod block_queue;
|
|
pub mod config;
|
|
mod database;
|
|
mod error;
|
|
pub mod metrics;
|
|
mod migrate;
|
|
mod slasher;
|
|
pub mod test_utils;
|
|
mod utils;
|
|
|
|
pub use crate::slasher::Slasher;
|
|
pub use attestation_queue::{AttestationBatch, AttestationQueue};
|
|
pub use attester_record::AttesterRecord;
|
|
pub use block_queue::BlockQueue;
|
|
pub use config::Config;
|
|
pub use database::SlasherDB;
|
|
pub use error::Error;
|
|
|
|
use types::{AttesterSlashing, EthSpec, IndexedAttestation, ProposerSlashing};
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum AttesterSlashingStatus<E: EthSpec> {
|
|
NotSlashable,
|
|
/// A weird outcome that can occur when we go to lookup an attestation by its target
|
|
/// epoch for a surround slashing, but find a different attestation -- indicating that
|
|
/// the validator has already been caught double voting.
|
|
AlreadyDoubleVoted,
|
|
DoubleVote(Box<IndexedAttestation<E>>),
|
|
SurroundsExisting(Box<IndexedAttestation<E>>),
|
|
SurroundedByExisting(Box<IndexedAttestation<E>>),
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum ProposerSlashingStatus {
|
|
NotSlashable,
|
|
DoubleVote(Box<ProposerSlashing>),
|
|
}
|
|
|
|
impl<E: EthSpec> AttesterSlashingStatus<E> {
|
|
pub fn into_slashing(
|
|
self,
|
|
new_attestation: &IndexedAttestation<E>,
|
|
) -> Option<AttesterSlashing<E>> {
|
|
use AttesterSlashingStatus::*;
|
|
|
|
// The surrounding attestation must be in `attestation_1` to be valid.
|
|
match self {
|
|
NotSlashable => None,
|
|
AlreadyDoubleVoted => None,
|
|
DoubleVote(existing) | SurroundedByExisting(existing) => Some(AttesterSlashing {
|
|
attestation_1: *existing,
|
|
attestation_2: new_attestation.clone(),
|
|
}),
|
|
SurroundsExisting(existing) => Some(AttesterSlashing {
|
|
attestation_1: new_attestation.clone(),
|
|
attestation_2: *existing,
|
|
}),
|
|
}
|
|
}
|
|
}
|