mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-05-02 03:02:54 -04:00
prevent OR on bitlists of different length (#4209)
* prevent OR on bitlists of different length * prevent OR on bitlists of different length
This commit is contained in:
committed by
prylabs-bulldozer[bot]
parent
dc0b8fad4f
commit
cae24068d4
@@ -28,6 +28,9 @@ func NewContainerFromAttestations(atts []*ethpb.Attestation) *AttestationContain
|
||||
func (ac *AttestationContainer) Contains(att *ethpb.Attestation) bool {
|
||||
all := bitfield.NewBitlist(att.AggregationBits.Len())
|
||||
for _, sp := range ac.SignaturePairs {
|
||||
if all.Len() != sp.AggregationBits.Len() {
|
||||
continue
|
||||
}
|
||||
all = all.Or(sp.AggregationBits)
|
||||
}
|
||||
return all.Contains(att.AggregationBits)
|
||||
|
||||
@@ -63,6 +63,16 @@ func TestAttestationContainer_Contains(t *testing.T) {
|
||||
contains: bitfield.Bitlist{0b01000000, 0b1},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
input: []bitfield.Bitlist{
|
||||
{0b10000001, 0b1},
|
||||
{0b10000010, 0b1},
|
||||
{0b10000100, 0b1},
|
||||
{0b10010001, 0b1},
|
||||
},
|
||||
contains: bitfield.Bitlist{0b10000000, 0b10}, // Different length.
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
t.Run(fmt.Sprintf("case_%d", i), func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user