mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Remove IndexedAttestation faulty Decode impl
This commit is contained in:
@@ -2,7 +2,6 @@ use crate::{test_utils::TestRandom, AggregateSignature, AttestationData, EthSpec
|
|||||||
use core::slice::Iter;
|
use core::slice::Iter;
|
||||||
use derivative::Derivative;
|
use derivative::Derivative;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use ssz::Decode;
|
|
||||||
use ssz::Encode;
|
use ssz::Encode;
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
@@ -187,26 +186,6 @@ impl<'a, E: EthSpec> IndexedAttestationRef<'a, E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: EthSpec> Decode for IndexedAttestation<E> {
|
|
||||||
fn is_ssz_fixed_len() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, ssz::DecodeError> {
|
|
||||||
if let Ok(result) = IndexedAttestationBase::from_ssz_bytes(bytes) {
|
|
||||||
return Ok(IndexedAttestation::Base(result));
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Ok(result) = IndexedAttestationElectra::from_ssz_bytes(bytes) {
|
|
||||||
return Ok(IndexedAttestation::Electra(result));
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(ssz::DecodeError::BytesInvalid(String::from(
|
|
||||||
"bytes not valid for any fork variant",
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Implementation of non-crypto-secure `Hash`, for use with `HashMap` and `HashSet`.
|
/// Implementation of non-crypto-secure `Hash`, for use with `HashMap` and `HashSet`.
|
||||||
///
|
///
|
||||||
/// Guarantees `att1 == att2 -> hash(att1) == hash(att2)`.
|
/// Guarantees `att1 == att2 -> hash(att1) == hash(att2)`.
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ use std::marker::PhantomData;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tree_hash::TreeHash;
|
use tree_hash::TreeHash;
|
||||||
use types::{
|
use types::{
|
||||||
Epoch, EthSpec, Hash256, IndexedAttestation, ProposerSlashing, SignedBeaconBlockHeader, Slot,
|
Epoch, EthSpec, Hash256, IndexedAttestation, IndexedAttestationBase, ProposerSlashing,
|
||||||
|
SignedBeaconBlockHeader, Slot,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Current database schema version, to check compatibility of on-disk DB with software.
|
/// Current database schema version, to check compatibility of on-disk DB with software.
|
||||||
@@ -481,7 +482,11 @@ impl<E: EthSpec> SlasherDB<E> {
|
|||||||
.ok_or(Error::MissingIndexedAttestation {
|
.ok_or(Error::MissingIndexedAttestation {
|
||||||
id: indexed_attestation_id.as_u64(),
|
id: indexed_attestation_id.as_u64(),
|
||||||
})?;
|
})?;
|
||||||
ssz_decode(bytes)
|
// TODO(electra): make slasher fork-aware and return correct variant of attestation. Both
|
||||||
|
// Base and Electra variant can the same SSZ encoding, however the smaller list maximum of
|
||||||
|
// Base can error with an Electra attestation with heavy participation.
|
||||||
|
let indexed_attestation: IndexedAttestationBase<E> = ssz_decode(bytes)?;
|
||||||
|
Ok(IndexedAttestation::Base(indexed_attestation))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_attestation_data_root(
|
fn get_attestation_data_root(
|
||||||
|
|||||||
Reference in New Issue
Block a user