2020-11-23 03:43:22 +00:00
|
|
|
#![deny(missing_debug_implementations)]
|
2022-08-15 01:30:56 +00:00
|
|
|
#![cfg_attr(
|
|
|
|
not(any(feature = "mdbx", feature = "lmdb")),
|
|
|
|
allow(unused, clippy::drop_non_drop)
|
|
|
|
)]
|
2020-11-23 03:43:22 +00:00
|
|
|
|
|
|
|
mod array;
|
|
|
|
mod attestation_queue;
|
|
|
|
mod attester_record;
|
2020-12-16 03:44:01 +00:00
|
|
|
mod batch_stats;
|
2020-11-23 03:43:22 +00:00
|
|
|
mod block_queue;
|
|
|
|
pub mod config;
|
|
|
|
mod database;
|
|
|
|
mod error;
|
2020-12-16 03:44:01 +00:00
|
|
|
pub mod metrics;
|
2020-12-28 05:09:19 +00:00
|
|
|
mod migrate;
|
2020-11-23 03:43:22 +00:00
|
|
|
mod slasher;
|
|
|
|
pub mod test_utils;
|
|
|
|
|
|
|
|
pub use crate::slasher::Slasher;
|
2021-11-08 00:01:09 +00:00
|
|
|
pub use attestation_queue::{AttestationBatch, AttestationQueue, SimpleBatch};
|
2021-12-21 08:23:17 +00:00
|
|
|
pub use attester_record::{AttesterRecord, CompactAttesterRecord, IndexedAttesterRecord};
|
2020-11-23 03:43:22 +00:00
|
|
|
pub use block_queue::BlockQueue;
|
2023-06-07 01:50:33 +00:00
|
|
|
pub use config::{Config, DatabaseBackend, DatabaseBackendOverride};
|
2022-08-15 01:30:56 +00:00
|
|
|
pub use database::{
|
|
|
|
interface::{Database, Environment, RwTransaction},
|
|
|
|
IndexedAttestationId, SlasherDB,
|
|
|
|
};
|
2020-11-23 03:43:22 +00:00
|
|
|
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,
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|