mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 11:41:51 +00:00
Use head state for exit verification (#4183)
## Issue Addressed NA ## Proposed Changes Similar to #4181 but without the version bump and a more nuanced fix. Patches the high CPU usage seen after the Capella fork which was caused by processing exits when there are skip slots. ## Additional Info ~~This is an imperfect solution that will cause us to drop some exits at the fork boundary. This is tracked at #4184.~~
This commit is contained in:
@@ -134,7 +134,7 @@ impl<E: EthSpec> VerifyOperation<E> for SignedVoluntaryExit {
|
||||
state: &BeaconState<E>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<SigVerifiedOp<Self, E>, Self::Error> {
|
||||
verify_exit(state, &self, VerifySignatures::True, spec)?;
|
||||
verify_exit(state, None, &self, VerifySignatures::True, spec)?;
|
||||
Ok(SigVerifiedOp::new(self, state))
|
||||
}
|
||||
|
||||
@@ -205,3 +205,35 @@ impl<E: EthSpec> VerifyOperation<E> for SignedBlsToExecutionChange {
|
||||
smallvec![]
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for operations that can be verified and transformed into a
|
||||
/// `SigVerifiedOp`.
|
||||
///
|
||||
/// The `At` suffix indicates that we can specify a particular epoch at which to
|
||||
/// verify the operation.
|
||||
pub trait VerifyOperationAt<E: EthSpec>: VerifyOperation<E> + Sized {
|
||||
fn validate_at(
|
||||
self,
|
||||
state: &BeaconState<E>,
|
||||
validate_at_epoch: Epoch,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<SigVerifiedOp<Self, E>, Self::Error>;
|
||||
}
|
||||
|
||||
impl<E: EthSpec> VerifyOperationAt<E> for SignedVoluntaryExit {
|
||||
fn validate_at(
|
||||
self,
|
||||
state: &BeaconState<E>,
|
||||
validate_at_epoch: Epoch,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<SigVerifiedOp<Self, E>, Self::Error> {
|
||||
verify_exit(
|
||||
state,
|
||||
Some(validate_at_epoch),
|
||||
&self,
|
||||
VerifySignatures::True,
|
||||
spec,
|
||||
)?;
|
||||
Ok(SigVerifiedOp::new(self, state))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user