mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
add new operation tests
This commit is contained in:
@@ -6,6 +6,9 @@ use serde::Deserialize;
|
|||||||
use ssz::Decode;
|
use ssz::Decode;
|
||||||
use state_processing::common::update_progressive_balances_cache::initialize_progressive_balances_cache;
|
use state_processing::common::update_progressive_balances_cache::initialize_progressive_balances_cache;
|
||||||
use state_processing::epoch_cache::initialize_epoch_cache;
|
use state_processing::epoch_cache::initialize_epoch_cache;
|
||||||
|
use state_processing::per_block_processing::process_operations::{
|
||||||
|
process_consolidations, process_deposit_receipts, process_execution_layer_withdrawal_requests,
|
||||||
|
};
|
||||||
use state_processing::{
|
use state_processing::{
|
||||||
per_block_processing::{
|
per_block_processing::{
|
||||||
errors::BlockProcessingError,
|
errors::BlockProcessingError,
|
||||||
@@ -22,8 +25,9 @@ use std::fmt::Debug;
|
|||||||
use types::{
|
use types::{
|
||||||
Attestation, AttesterSlashing, BeaconBlock, BeaconBlockBody, BeaconBlockBodyBellatrix,
|
Attestation, AttesterSlashing, BeaconBlock, BeaconBlockBody, BeaconBlockBodyBellatrix,
|
||||||
BeaconBlockBodyCapella, BeaconBlockBodyDeneb, BeaconBlockBodyElectra, BeaconState,
|
BeaconBlockBodyCapella, BeaconBlockBodyDeneb, BeaconBlockBodyElectra, BeaconState,
|
||||||
BlindedPayload, Deposit, ExecutionPayload, FullPayload, ProposerSlashing,
|
BlindedPayload, Deposit, DepositReceipt, ExecutionLayerWithdrawalRequest, ExecutionPayload,
|
||||||
SignedBlsToExecutionChange, SignedVoluntaryExit, SyncAggregate,
|
FullPayload, ProposerSlashing, SignedBlsToExecutionChange, SignedConsolidation,
|
||||||
|
SignedVoluntaryExit, SyncAggregate,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Deserialize)]
|
#[derive(Debug, Clone, Default, Deserialize)]
|
||||||
@@ -437,6 +441,75 @@ impl<E: EthSpec> Operation<E> for SignedBlsToExecutionChange {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<E: EthSpec> Operation<E> for ExecutionLayerWithdrawalRequest {
|
||||||
|
fn handler_name() -> String {
|
||||||
|
"execution_layer_withdrawal_request".into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
|
||||||
|
fork_name >= ForkName::Electra
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decode(path: &Path, _fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> {
|
||||||
|
ssz_decode_file(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply_to(
|
||||||
|
&self,
|
||||||
|
state: &mut BeaconState<E>,
|
||||||
|
spec: &ChainSpec,
|
||||||
|
_extra: &Operations<E, Self>,
|
||||||
|
) -> Result<(), BlockProcessingError> {
|
||||||
|
process_execution_layer_withdrawal_requests(state, &[self.clone()], spec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<E: EthSpec> Operation<E> for DepositReceipt {
|
||||||
|
fn handler_name() -> String {
|
||||||
|
"deposit_receipt".into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
|
||||||
|
fork_name >= ForkName::Electra
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decode(path: &Path, _fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> {
|
||||||
|
ssz_decode_file(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply_to(
|
||||||
|
&self,
|
||||||
|
state: &mut BeaconState<E>,
|
||||||
|
spec: &ChainSpec,
|
||||||
|
_extra: &Operations<E, Self>,
|
||||||
|
) -> Result<(), BlockProcessingError> {
|
||||||
|
process_deposit_receipts(state, &[self.clone()], spec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<E: EthSpec> Operation<E> for SignedConsolidation {
|
||||||
|
fn handler_name() -> String {
|
||||||
|
"consolidation".into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
|
||||||
|
fork_name >= ForkName::Electra
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decode(path: &Path, _fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> {
|
||||||
|
ssz_decode_file(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply_to(
|
||||||
|
&self,
|
||||||
|
state: &mut BeaconState<E>,
|
||||||
|
spec: &ChainSpec,
|
||||||
|
_extra: &Operations<E, Self>,
|
||||||
|
) -> Result<(), BlockProcessingError> {
|
||||||
|
process_consolidations(state, &[self.clone()], VerifySignatures::True, spec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<E: EthSpec, O: Operation<E>> LoadCase for Operations<E, O> {
|
impl<E: EthSpec, O: Operation<E>> LoadCase for Operations<E, O> {
|
||||||
fn load_from_dir(path: &Path, fork_name: ForkName) -> Result<Self, Error> {
|
fn load_from_dir(path: &Path, fork_name: ForkName) -> Result<Self, Error> {
|
||||||
let spec = &testing_spec::<E>(fork_name);
|
let spec = &testing_spec::<E>(fork_name);
|
||||||
|
|||||||
Reference in New Issue
Block a user