mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Electra attestation changes rm decode impl (#5856)
* Remove Crappy Decode impl for Attestation * Remove Inefficient Attestation Decode impl * Implement Schema Upgrade / Downgrade * Update beacon_node/beacon_chain/src/schema_change/migration_schema_v20.rs Co-authored-by: Michael Sproul <micsproul@gmail.com> --------- Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
@@ -12,7 +12,9 @@ use smallvec::{smallvec, SmallVec};
|
||||
use ssz::{Decode, Encode};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::marker::PhantomData;
|
||||
use types::{AttesterSlashing, AttesterSlashingOnDisk, AttesterSlashingRefOnDisk};
|
||||
use types::{
|
||||
AttesterSlashing, AttesterSlashingBase, AttesterSlashingOnDisk, AttesterSlashingRefOnDisk,
|
||||
};
|
||||
use types::{
|
||||
BeaconState, ChainSpec, Epoch, EthSpec, Fork, ForkVersion, ProposerSlashing,
|
||||
SignedBlsToExecutionChange, SignedVoluntaryExit,
|
||||
@@ -366,6 +368,49 @@ impl<E: EthSpec> TransformPersist for AttesterSlashing<E> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this once we no longer support DB schema version 17
|
||||
impl<E: EthSpec> TransformPersist for types::AttesterSlashingBase<E> {
|
||||
type Persistable = Self;
|
||||
type PersistableRef<'a> = &'a Self;
|
||||
|
||||
fn as_persistable_ref(&self) -> Self::PersistableRef<'_> {
|
||||
self
|
||||
}
|
||||
|
||||
fn from_persistable(persistable: Self::Persistable) -> Self {
|
||||
persistable
|
||||
}
|
||||
}
|
||||
// TODO: Remove this once we no longer support DB schema version 17
|
||||
impl<E: EthSpec> From<SigVerifiedOp<AttesterSlashingBase<E>, E>>
|
||||
for SigVerifiedOp<AttesterSlashing<E>, E>
|
||||
{
|
||||
fn from(base: SigVerifiedOp<AttesterSlashingBase<E>, E>) -> Self {
|
||||
SigVerifiedOp {
|
||||
op: AttesterSlashing::Base(base.op),
|
||||
verified_against: base.verified_against,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: Remove this once we no longer support DB schema version 17
|
||||
impl<E: EthSpec> TryFrom<SigVerifiedOp<AttesterSlashing<E>, E>>
|
||||
for SigVerifiedOp<AttesterSlashingBase<E>, E>
|
||||
{
|
||||
type Error = String;
|
||||
|
||||
fn try_from(slashing: SigVerifiedOp<AttesterSlashing<E>, E>) -> Result<Self, Self::Error> {
|
||||
match slashing.op {
|
||||
AttesterSlashing::Base(base) => Ok(SigVerifiedOp {
|
||||
op: base,
|
||||
verified_against: slashing.verified_against,
|
||||
_phantom: PhantomData,
|
||||
}),
|
||||
AttesterSlashing::Electra(_) => Err("non-base attester slashing".to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TransformPersist for ProposerSlashing {
|
||||
type Persistable = Self;
|
||||
type PersistableRef<'a> = &'a Self;
|
||||
|
||||
Reference in New Issue
Block a user