mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Isolate withdrawals-processing Feature (#3854)
This commit is contained in:
@@ -19,7 +19,6 @@ pub use process_operations::process_operations;
|
||||
pub use verify_attestation::{
|
||||
verify_attestation_for_block_inclusion, verify_attestation_for_state,
|
||||
};
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
pub use verify_bls_to_execution_change::verify_bls_to_execution_change;
|
||||
pub use verify_deposit::{
|
||||
get_existing_validator_index, verify_deposit_merkle_proof, verify_deposit_signature,
|
||||
@@ -36,13 +35,11 @@ pub mod signature_sets;
|
||||
pub mod tests;
|
||||
mod verify_attestation;
|
||||
mod verify_attester_slashing;
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
mod verify_bls_to_execution_change;
|
||||
mod verify_deposit;
|
||||
mod verify_exit;
|
||||
mod verify_proposer_slashing;
|
||||
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
use crate::common::decrease_balance;
|
||||
|
||||
#[cfg(feature = "arbitrary-fuzz")]
|
||||
@@ -165,7 +162,6 @@ pub fn per_block_processing<T: EthSpec, Payload: AbstractExecPayload<T>>(
|
||||
// previous block.
|
||||
if is_execution_enabled(state, block.body()) {
|
||||
let payload = block.body().execution_payload()?;
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
process_withdrawals::<T, Payload>(state, payload, spec)?;
|
||||
process_execution_payload::<T, Payload>(state, payload, spec)?;
|
||||
}
|
||||
@@ -524,12 +520,14 @@ pub fn get_expected_withdrawals<T: EthSpec>(
|
||||
}
|
||||
|
||||
/// Apply withdrawals to the state.
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
pub fn process_withdrawals<'payload, T: EthSpec, Payload: AbstractExecPayload<T>>(
|
||||
state: &mut BeaconState<T>,
|
||||
payload: Payload::Ref<'payload>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), BlockProcessingError> {
|
||||
if cfg!(not(feature = "withdrawals-processing")) {
|
||||
return Ok(());
|
||||
}
|
||||
match state {
|
||||
BeaconState::Merge(_) => Ok(()),
|
||||
BeaconState::Capella(_) | BeaconState::Eip4844(_) => {
|
||||
|
||||
@@ -34,7 +34,6 @@ pub fn process_operations<'a, T: EthSpec, Payload: AbstractExecPayload<T>>(
|
||||
process_deposits(state, block_body.deposits(), spec)?;
|
||||
process_exits(state, block_body.voluntary_exits(), verify_signatures, spec)?;
|
||||
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
if let Ok(bls_to_execution_changes) = block_body.bls_to_execution_changes() {
|
||||
process_bls_to_execution_changes(state, bls_to_execution_changes, verify_signatures, spec)?;
|
||||
}
|
||||
@@ -295,13 +294,15 @@ pub fn process_exits<T: EthSpec>(
|
||||
///
|
||||
/// Returns `Ok(())` if the validation and state updates completed successfully. Otherwise returns
|
||||
/// an `Err` describing the invalid object or cause of failure.
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
pub fn process_bls_to_execution_changes<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
bls_to_execution_changes: &[SignedBlsToExecutionChange],
|
||||
verify_signatures: VerifySignatures,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), BlockProcessingError> {
|
||||
if cfg!(not(feature = "withdrawals-processing")) {
|
||||
return Ok(());
|
||||
}
|
||||
for (i, signed_address_change) in bls_to_execution_changes.iter().enumerate() {
|
||||
verify_bls_to_execution_change(state, signed_address_change, verify_signatures, spec)
|
||||
.map_err(|e| e.into_with_index(i))?;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use crate::per_block_processing::{
|
||||
errors::{
|
||||
AttesterSlashingValidationError, ExitValidationError, ProposerSlashingValidationError,
|
||||
AttesterSlashingValidationError, BlsExecutionChangeValidationError, ExitValidationError,
|
||||
ProposerSlashingValidationError,
|
||||
},
|
||||
verify_attester_slashing, verify_exit, verify_proposer_slashing,
|
||||
verify_attester_slashing, verify_bls_to_execution_change, verify_exit,
|
||||
verify_proposer_slashing,
|
||||
};
|
||||
use crate::VerifySignatures;
|
||||
use derivative::Derivative;
|
||||
@@ -12,15 +14,7 @@ use ssz_derive::{Decode, Encode};
|
||||
use std::marker::PhantomData;
|
||||
use types::{
|
||||
AttesterSlashing, BeaconState, ChainSpec, Epoch, EthSpec, Fork, ForkVersion, ProposerSlashing,
|
||||
SignedVoluntaryExit,
|
||||
};
|
||||
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
use {
|
||||
crate::per_block_processing::{
|
||||
errors::BlsExecutionChangeValidationError, verify_bls_to_execution_change,
|
||||
},
|
||||
types::SignedBlsToExecutionChange,
|
||||
SignedBlsToExecutionChange, SignedVoluntaryExit,
|
||||
};
|
||||
|
||||
const MAX_FORKS_VERIFIED_AGAINST: usize = 2;
|
||||
@@ -202,7 +196,6 @@ impl<E: EthSpec> VerifyOperation<E> for ProposerSlashing {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
impl<E: EthSpec> VerifyOperation<E> for SignedBlsToExecutionChange {
|
||||
type Error = BlsExecutionChangeValidationError;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user