#![deny(missing_debug_implementations)] mod array; mod attestation_queue; mod attester_record; mod block_queue; pub mod config; mod database; mod error; mod metrics; mod slasher; mod slasher_server; 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; pub use slasher_server::SlasherServer; use types::{AttesterSlashing, EthSpec, IndexedAttestation, ProposerSlashing}; #[derive(Debug, PartialEq)] pub enum AttesterSlashingStatus { 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>), SurroundsExisting(Box>), SurroundedByExisting(Box>), } #[derive(Debug, PartialEq)] pub enum ProposerSlashingStatus { NotSlashable, DoubleVote(Box), } impl AttesterSlashingStatus { pub fn into_slashing( self, new_attestation: &IndexedAttestation, ) -> Option> { 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, }), } } }