Skip to content

Commit 5a900c7

Browse files
committed
Add dynamic size for AggregationBits
1 parent 80cbb22 commit 5a900c7

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

spec/electra/attestation.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ import (
2828
)
2929

3030
// Attestation is the Ethereum 2 attestation structure.
31+
//
32+
//nolint:tagalign
3133
type Attestation struct {
3234
// bitfield.Bitlist has size of n bits + 1 length bit, e.g. an 8 bit list will require a 2 byte array.
33-
AggregationBits bitfield.Bitlist `ssz-max:"16385"`
35+
AggregationBits bitfield.Bitlist `ssz-max:"16385" dynssz-size:"((MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT)/8 + 1)"`
3436
Data *phase0.AttestationData
3537
Signature phase0.BLSSignature `ssz-size:"96"`
3638
// bitfield.Bitvector64 is an 8 byte array so dynamic sizing doesn't make sense.

spec/electra/attestation_ssz.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/electra/attestation_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ func TestAttestation_SSZ(t *testing.T) {
163163

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

167168
// Set a bit beyond the bit vector.
168169
committeeBits.SetBitAt(committeeSize, true)

0 commit comments

Comments
 (0)