mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-19 21:04:41 +00:00
SSZ bump in a single clean commit
This commit is contained in:
@@ -60,6 +60,7 @@ pub enum BlockProcessingError {
|
||||
SignatureSetError(SignatureSetError),
|
||||
SszTypesError(ssz_types::Error),
|
||||
SszDecodeError(DecodeError),
|
||||
BitfieldError(ssz::BitfieldError),
|
||||
MerkleTreeError(MerkleTreeError),
|
||||
ArithError(ArithError),
|
||||
InconsistentBlockFork(InconsistentFork),
|
||||
@@ -153,6 +154,7 @@ impl From<BlockOperationError<HeaderInvalid>> for BlockProcessingError {
|
||||
BlockOperationError::BeaconStateError(e) => BlockProcessingError::BeaconStateError(e),
|
||||
BlockOperationError::SignatureSetError(e) => BlockProcessingError::SignatureSetError(e),
|
||||
BlockOperationError::SszTypesError(e) => BlockProcessingError::SszTypesError(e),
|
||||
BlockOperationError::BitfieldError(e) => BlockProcessingError::BitfieldError(e),
|
||||
BlockOperationError::ConsensusContext(e) => BlockProcessingError::ConsensusContext(e),
|
||||
BlockOperationError::ArithError(e) => BlockProcessingError::ArithError(e),
|
||||
}
|
||||
@@ -181,6 +183,7 @@ macro_rules! impl_into_block_processing_error_with_index {
|
||||
BlockOperationError::BeaconStateError(e) => BlockProcessingError::BeaconStateError(e),
|
||||
BlockOperationError::SignatureSetError(e) => BlockProcessingError::SignatureSetError(e),
|
||||
BlockOperationError::SszTypesError(e) => BlockProcessingError::SszTypesError(e),
|
||||
BlockOperationError::BitfieldError(e) => BlockProcessingError::BitfieldError(e),
|
||||
BlockOperationError::ConsensusContext(e) => BlockProcessingError::ConsensusContext(e),
|
||||
BlockOperationError::ArithError(e) => BlockProcessingError::ArithError(e),
|
||||
}
|
||||
@@ -215,6 +218,7 @@ pub enum BlockOperationError<T> {
|
||||
BeaconStateError(BeaconStateError),
|
||||
SignatureSetError(SignatureSetError),
|
||||
SszTypesError(ssz_types::Error),
|
||||
BitfieldError(ssz::BitfieldError),
|
||||
ConsensusContext(ContextError),
|
||||
ArithError(ArithError),
|
||||
}
|
||||
@@ -242,6 +246,12 @@ impl<T> From<ssz_types::Error> for BlockOperationError<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<ssz::BitfieldError> for BlockOperationError<T> {
|
||||
fn from(error: ssz::BitfieldError) -> Self {
|
||||
BlockOperationError::BitfieldError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<ArithError> for BlockOperationError<T> {
|
||||
fn from(e: ArithError) -> Self {
|
||||
BlockOperationError::ArithError(e)
|
||||
@@ -367,6 +377,7 @@ impl From<BlockOperationError<IndexedAttestationInvalid>>
|
||||
BlockOperationError::BeaconStateError(e) => BlockOperationError::BeaconStateError(e),
|
||||
BlockOperationError::SignatureSetError(e) => BlockOperationError::SignatureSetError(e),
|
||||
BlockOperationError::SszTypesError(e) => BlockOperationError::SszTypesError(e),
|
||||
BlockOperationError::BitfieldError(e) => BlockOperationError::BitfieldError(e),
|
||||
BlockOperationError::ConsensusContext(e) => BlockOperationError::ConsensusContext(e),
|
||||
BlockOperationError::ArithError(e) => BlockOperationError::ArithError(e),
|
||||
}
|
||||
|
||||
@@ -19,9 +19,10 @@ pub enum EpochProcessingError {
|
||||
BeaconStateError(BeaconStateError),
|
||||
InclusionError(InclusionError),
|
||||
SszTypesError(ssz_types::Error),
|
||||
BitfieldError(ssz::BitfieldError),
|
||||
ArithError(safe_arith::ArithError),
|
||||
InconsistentStateFork(InconsistentFork),
|
||||
InvalidJustificationBit(ssz_types::Error),
|
||||
InvalidJustificationBit(ssz::BitfieldError),
|
||||
InvalidFlagIndex(usize),
|
||||
MilhouseError(milhouse::Error),
|
||||
EpochCache(EpochCacheError),
|
||||
@@ -49,6 +50,12 @@ impl From<ssz_types::Error> for EpochProcessingError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ssz::BitfieldError> for EpochProcessingError {
|
||||
fn from(e: ssz::BitfieldError) -> EpochProcessingError {
|
||||
EpochProcessingError::BitfieldError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<safe_arith::ArithError> for EpochProcessingError {
|
||||
fn from(e: safe_arith::ArithError) -> EpochProcessingError {
|
||||
EpochProcessingError::ArithError(e)
|
||||
|
||||
@@ -18,6 +18,7 @@ use super::{
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {
|
||||
SszTypesError(ssz_types::Error),
|
||||
BitfieldError(ssz::BitfieldError),
|
||||
AlreadySigned(usize),
|
||||
IncorrectStateVariant,
|
||||
InvalidCommitteeLength,
|
||||
@@ -223,7 +224,7 @@ impl<E: EthSpec> Attestation<E> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_aggregation_bit(&self, index: usize) -> Result<bool, ssz_types::Error> {
|
||||
pub fn get_aggregation_bit(&self, index: usize) -> Result<bool, ssz::BitfieldError> {
|
||||
match self {
|
||||
Attestation::Base(att) => att.aggregation_bits.get(index),
|
||||
Attestation::Electra(att) => att.aggregation_bits.get(index),
|
||||
@@ -353,13 +354,13 @@ impl<E: EthSpec> AttestationElectra<E> {
|
||||
if self
|
||||
.aggregation_bits
|
||||
.get(committee_position)
|
||||
.map_err(Error::SszTypesError)?
|
||||
.map_err(Error::BitfieldError)?
|
||||
{
|
||||
Err(Error::AlreadySigned(committee_position))
|
||||
} else {
|
||||
self.aggregation_bits
|
||||
.set(committee_position, true)
|
||||
.map_err(Error::SszTypesError)?;
|
||||
.map_err(Error::BitfieldError)?;
|
||||
|
||||
self.signature.add_assign(signature);
|
||||
|
||||
@@ -427,13 +428,13 @@ impl<E: EthSpec> AttestationBase<E> {
|
||||
if self
|
||||
.aggregation_bits
|
||||
.get(committee_position)
|
||||
.map_err(Error::SszTypesError)?
|
||||
.map_err(Error::BitfieldError)?
|
||||
{
|
||||
Err(Error::AlreadySigned(committee_position))
|
||||
} else {
|
||||
self.aggregation_bits
|
||||
.set(committee_position, true)
|
||||
.map_err(Error::SszTypesError)?;
|
||||
.map_err(Error::BitfieldError)?;
|
||||
|
||||
self.signature.add_assign(signature);
|
||||
|
||||
@@ -443,7 +444,7 @@ impl<E: EthSpec> AttestationBase<E> {
|
||||
|
||||
pub fn extend_aggregation_bits(
|
||||
&self,
|
||||
) -> Result<BitList<E::MaxValidatorsPerSlot>, ssz_types::Error> {
|
||||
) -> Result<BitList<E::MaxValidatorsPerSlot>, ssz::BitfieldError> {
|
||||
self.aggregation_bits.resize::<E::MaxValidatorsPerSlot>()
|
||||
}
|
||||
}
|
||||
@@ -600,12 +601,12 @@ mod tests {
|
||||
let attestation_data = size_of::<AttestationData>();
|
||||
let signature = size_of::<AggregateSignature>();
|
||||
|
||||
assert_eq!(aggregation_bits, 56);
|
||||
assert_eq!(aggregation_bits, 152);
|
||||
assert_eq!(attestation_data, 128);
|
||||
assert_eq!(signature, 288 + 16);
|
||||
|
||||
let attestation_expected = aggregation_bits + attestation_data + signature;
|
||||
assert_eq!(attestation_expected, 488);
|
||||
assert_eq!(attestation_expected, 584);
|
||||
assert_eq!(
|
||||
size_of::<AttestationBase<MainnetEthSpec>>(),
|
||||
attestation_expected
|
||||
@@ -623,13 +624,13 @@ mod tests {
|
||||
size_of::<BitList<<MainnetEthSpec as EthSpec>::MaxCommitteesPerSlot>>();
|
||||
let signature = size_of::<AggregateSignature>();
|
||||
|
||||
assert_eq!(aggregation_bits, 56);
|
||||
assert_eq!(committee_bits, 56);
|
||||
assert_eq!(aggregation_bits, 152);
|
||||
assert_eq!(committee_bits, 152);
|
||||
assert_eq!(attestation_data, 128);
|
||||
assert_eq!(signature, 288 + 16);
|
||||
|
||||
let attestation_expected = aggregation_bits + committee_bits + attestation_data + signature;
|
||||
assert_eq!(attestation_expected, 544);
|
||||
assert_eq!(attestation_expected, 736);
|
||||
assert_eq!(
|
||||
size_of::<AttestationElectra<MainnetEthSpec>>(),
|
||||
attestation_expected
|
||||
|
||||
@@ -11,6 +11,7 @@ use tree_hash_derive::TreeHash;
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {
|
||||
SszTypesError(ssz_types::Error),
|
||||
BitfieldError(ssz::BitfieldError),
|
||||
ArithError(ArithError),
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ impl<E: EthSpec> SyncAggregate<E> {
|
||||
sync_aggregate
|
||||
.sync_committee_bits
|
||||
.set(participant_index, true)
|
||||
.map_err(Error::SszTypesError)?;
|
||||
.map_err(Error::BitfieldError)?;
|
||||
}
|
||||
}
|
||||
sync_aggregate
|
||||
|
||||
@@ -9,6 +9,7 @@ use tree_hash_derive::TreeHash;
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {
|
||||
SszTypesError(ssz_types::Error),
|
||||
BitfieldError(ssz::BitfieldError),
|
||||
AlreadySigned(usize),
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ impl<E: EthSpec> SyncCommitteeContribution<E> {
|
||||
) -> Result<Self, Error> {
|
||||
let mut bits = BitVector::new();
|
||||
bits.set(validator_sync_committee_index, true)
|
||||
.map_err(Error::SszTypesError)?;
|
||||
.map_err(Error::BitfieldError)?;
|
||||
Ok(Self {
|
||||
slot: message.slot,
|
||||
beacon_block_root: message.beacon_block_root,
|
||||
|
||||
Reference in New Issue
Block a user