mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Check slashability of attestations in batches to avoid sequential bottleneck (#8516)
Closes: - https://github.com/sigp/lighthouse/issues/1914 Sign attestations prior to checking them against the slashing protection DB. This allows us to avoid the sequential DB checks which are observed in traces here: - https://github.com/sigp/lighthouse/pull/8508#discussion_r2576686107 Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com> Co-Authored-By: Michael Sproul <michael@sigmaprime.io> Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com>
This commit is contained in:
@@ -19,9 +19,9 @@ pub enum Error<T> {
|
||||
Slashable(NotSafe),
|
||||
SameData,
|
||||
GreaterThanCurrentSlot { slot: Slot, current_slot: Slot },
|
||||
GreaterThanCurrentEpoch { epoch: Epoch, current_epoch: Epoch },
|
||||
UnableToSignAttestation(AttestationError),
|
||||
SpecificError(T),
|
||||
ExecutorError,
|
||||
Middleware(String),
|
||||
}
|
||||
|
||||
@@ -103,13 +103,24 @@ pub trait ValidatorStore: Send + Sync {
|
||||
current_slot: Slot,
|
||||
) -> impl Future<Output = Result<SignedBlock<Self::E>, Error<Self::Error>>> + Send;
|
||||
|
||||
fn sign_attestation(
|
||||
&self,
|
||||
validator_pubkey: PublicKeyBytes,
|
||||
validator_committee_position: usize,
|
||||
attestation: &mut Attestation<Self::E>,
|
||||
current_epoch: Epoch,
|
||||
) -> impl Future<Output = Result<(), Error<Self::Error>>> + Send;
|
||||
/// Sign a batch of `attestations` and apply slashing protection to them.
|
||||
///
|
||||
/// Only successfully signed attestations that pass slashing protection are returned, along with
|
||||
/// the validator index of the signer. Eventually this will be replaced by `SingleAttestation`
|
||||
/// use.
|
||||
///
|
||||
/// Input:
|
||||
///
|
||||
/// * Vec of (validator_index, pubkey, validator_committee_index, attestation).
|
||||
///
|
||||
/// Output:
|
||||
///
|
||||
/// * Vec of (validator_index, signed_attestation).
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn sign_attestations(
|
||||
self: &Arc<Self>,
|
||||
attestations: Vec<(u64, PublicKeyBytes, usize, Attestation<Self::E>)>,
|
||||
) -> impl Future<Output = Result<Vec<(u64, Attestation<Self::E>)>, Error<Self::Error>>> + Send;
|
||||
|
||||
fn sign_validator_registration_data(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user