SSZ bump in a single clean commit

This commit is contained in:
Michael Sproul
2025-03-03 15:59:02 +11:00
parent 6ab6eae40c
commit 8fd4ba7280
13 changed files with 192 additions and 62 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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,