superstruct the AttesterSlashing (#5636)

* `superstruct` Attester Fork Variants

* Push a little further

* Deal with Encode / Decode of AttesterSlashing

* not so sure about this..

* Stop Encode/Decode Bounds from Propagating Out

* Tons of Changes..

* More Conversions to AttestationRef

* Add AsReference trait (#15)

* Add AsReference trait

* Fix some snafus

* Got it Compiling! :D

* Got Tests Building

* Get beacon chain tests compiling

---------

Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
ethDreamer
2024-05-02 18:00:21 -05:00
committed by GitHub
parent 3b7132bc0d
commit e6c7f145dd
53 changed files with 1405 additions and 437 deletions

View File

@@ -23,8 +23,9 @@ use state_processing::state_advance::complete_state_advance;
use std::future::Future;
use std::sync::Arc;
use std::time::Duration;
use types::AttesterSlashingBase;
use types::{
Attestation, AttesterSlashing, BeaconBlock, BeaconState, BlobSidecar, BlobsList, Checkpoint,
Attestation, AttesterSlashingRef, BeaconBlock, BeaconState, BlobSidecar, BlobsList, Checkpoint,
ExecutionBlockHash, Hash256, IndexedAttestation, KzgProof, ProposerPreparationData,
SignedBeaconBlock, Slot, Uint256,
};
@@ -131,8 +132,9 @@ pub struct ForkChoiceTest<E: EthSpec> {
pub anchor_state: BeaconState<E>,
pub anchor_block: BeaconBlock<E>,
#[allow(clippy::type_complexity)]
// TODO(electra): these tests will need to be updated to use new types
pub steps: Vec<
Step<SignedBeaconBlock<E>, BlobsList<E>, Attestation<E>, AttesterSlashing<E>, PowBlock>,
Step<SignedBeaconBlock<E>, BlobsList<E>, Attestation<E>, AttesterSlashingBase<E>, PowBlock>,
>,
}
@@ -249,7 +251,7 @@ impl<E: EthSpec> Case for ForkChoiceTest<E> {
} => tester.process_block(block.clone(), blobs.clone(), proofs.clone(), *valid)?,
Step::Attestation { attestation } => tester.process_attestation(attestation)?,
Step::AttesterSlashing { attester_slashing } => {
tester.process_attester_slashing(attester_slashing)
tester.process_attester_slashing(AttesterSlashingRef::Base(attester_slashing))
}
Step::PowBlock { pow_block } => tester.process_pow_block(pow_block),
Step::OnPayloadInfo {
@@ -591,7 +593,7 @@ impl<E: EthSpec> Tester<E> {
.map_err(|e| Error::InternalError(format!("attestation import failed with {:?}", e)))
}
pub fn process_attester_slashing(&self, attester_slashing: &AttesterSlashing<E>) {
pub fn process_attester_slashing(&self, attester_slashing: AttesterSlashingRef<E>) {
self.harness
.chain
.canonical_head

View File

@@ -93,7 +93,7 @@ impl<E: EthSpec> Operation<E> for Attestation<E> {
match state {
BeaconState::Base(_) => base::process_attestations(
state,
&[self.clone()],
[self.clone().to_ref()].into_iter(),
VerifySignatures::True,
&mut ctxt,
spec,
@@ -106,7 +106,7 @@ impl<E: EthSpec> Operation<E> for Attestation<E> {
initialize_progressive_balances_cache(state, spec)?;
altair_deneb::process_attestation(
state,
self,
self.to_ref(),
0,
&mut ctxt,
VerifySignatures::True,
@@ -123,7 +123,7 @@ impl<E: EthSpec> Operation<E> for AttesterSlashing<E> {
}
fn decode(path: &Path, _fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> {
ssz_decode_file(path)
Ok(Self::Base(ssz_decode_file(path)?))
}
fn apply_to(
@@ -136,7 +136,7 @@ impl<E: EthSpec> Operation<E> for AttesterSlashing<E> {
initialize_progressive_balances_cache(state, spec)?;
process_attester_slashings(
state,
&[self.clone()],
[self.clone().to_ref()].into_iter(),
VerifySignatures::True,
&mut ctxt,
spec,