Skip to content

Commit

Permalink
Add dynamic size for AggregationBits
Browse files Browse the repository at this point in the history
  • Loading branch information
Bez625 committed Jan 10, 2025
1 parent 79a5ffa commit 0da473e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion spec/electra/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ import (
)

// Attestation is the Ethereum 2 attestation structure.
//
//nolint:tagalign
type Attestation struct {
// bitfield.Bitlist has size of n bits + 1 length bit, e.g. an 8 bit list will require a 2 byte array.
AggregationBits bitfield.Bitlist `ssz-max:"16385"`
AggregationBits bitfield.Bitlist `ssz-max:"16385" dynssz-size:"((MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT)/8 + 1)"`
Data *phase0.AttestationData
Signature phase0.BLSSignature `ssz-size:"96"`
// bitfield.Bitvector64 is an 8 byte array so dynamic sizing doesn't make sense.
Expand Down
2 changes: 1 addition & 1 deletion spec/electra/attestation_ssz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spec/electra/attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func TestAttestation_SSZ(t *testing.T) {

// Should only have the bit that was set on the last bit.
require.Equal(t, 1, len(aggregateBits.BitIndices()))
require.Equal(t, aggregateSize, aggregateBits.Len())

// Set a bit beyond the bit vector.
committeeBits.SetBitAt(committeeSize, true)
Expand Down

0 comments on commit 0da473e

Please sign in to comment.