mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-16 12:28:24 +00:00
Op pool and gossip for BLS to execution changes (#3726)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use derivative::Derivative;
|
||||
use smallvec::SmallVec;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use ssz::{Decode, Encode};
|
||||
use state_processing::{SigVerifiedOp, VerifyOperation};
|
||||
use std::collections::HashSet;
|
||||
@@ -9,6 +9,9 @@ use types::{
|
||||
SignedVoluntaryExit, Slot,
|
||||
};
|
||||
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
use types::SignedBlsToExecutionChange;
|
||||
|
||||
/// Number of validator indices to store on the stack in `observed_validators`.
|
||||
pub const SMALL_VEC_SIZE: usize = 8;
|
||||
|
||||
@@ -39,7 +42,7 @@ pub enum ObservationOutcome<T: Encode + Decode, E: EthSpec> {
|
||||
AlreadyKnown,
|
||||
}
|
||||
|
||||
/// Trait for exits and slashings which can be observed using `ObservedOperations`.
|
||||
/// Trait for operations which can be observed using `ObservedOperations`.
|
||||
pub trait ObservableOperation<E: EthSpec>: VerifyOperation<E> + Sized {
|
||||
/// The set of validator indices involved in this operation.
|
||||
///
|
||||
@@ -49,13 +52,13 @@ pub trait ObservableOperation<E: EthSpec>: VerifyOperation<E> + Sized {
|
||||
|
||||
impl<E: EthSpec> ObservableOperation<E> for SignedVoluntaryExit {
|
||||
fn observed_validators(&self) -> SmallVec<[u64; SMALL_VEC_SIZE]> {
|
||||
std::iter::once(self.message.validator_index).collect()
|
||||
smallvec![self.message.validator_index]
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> ObservableOperation<E> for ProposerSlashing {
|
||||
fn observed_validators(&self) -> SmallVec<[u64; SMALL_VEC_SIZE]> {
|
||||
std::iter::once(self.signed_header_1.message.proposer_index).collect()
|
||||
smallvec![self.signed_header_1.message.proposer_index]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +83,13 @@ impl<E: EthSpec> ObservableOperation<E> for AttesterSlashing<E> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
impl<E: EthSpec> ObservableOperation<E> for SignedBlsToExecutionChange {
|
||||
fn observed_validators(&self) -> SmallVec<[u64; SMALL_VEC_SIZE]> {
|
||||
smallvec![self.message.validator_index]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ObservableOperation<E>, E: EthSpec> ObservedOperations<T, E> {
|
||||
pub fn verify_and_observe(
|
||||
&mut self,
|
||||
|
||||
Reference in New Issue
Block a user