Skip to content

Commit

Permalink
Prevent panic for different size bitlists (#5233)
Browse files Browse the repository at this point in the history
* Fix #5232
* Merge branch 'master' into bugfix-5232
  • Loading branch information
prestonvanloon committed Mar 28, 2020
1 parent f2a3fad commit 6bc70e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion beacon-chain/operations/attestations/kv/aggregated.go
Expand Up @@ -100,7 +100,7 @@ func (p *AttCaches) DeleteAggregatedAttestation(att *ethpb.Attestation) error {

filtered := make([]*ethpb.Attestation, 0)
for _, a := range attList {
if !att.AggregationBits.Contains(a.AggregationBits) {
if att.AggregationBits.Len() == a.AggregationBits.Len() && !att.AggregationBits.Contains(a.AggregationBits) {
filtered = append(filtered, a)
}
}
Expand Down
3 changes: 2 additions & 1 deletion beacon-chain/operations/attestations/kv/aggregated_test.go
Expand Up @@ -52,7 +52,8 @@ func TestKV_Aggregated_CanDelete(t *testing.T) {
att1 := &ethpb.Attestation{Data: &ethpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}}
att2 := &ethpb.Attestation{Data: &ethpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}}
att3 := &ethpb.Attestation{Data: &ethpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}}
atts := []*ethpb.Attestation{att1, att2, att3}
att4 := &ethpb.Attestation{Data: &ethpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b10101}}
atts := []*ethpb.Attestation{att1, att2, att3, att4}

for _, att := range atts {
if err := cache.SaveAggregatedAttestation(att); err != nil {
Expand Down

0 comments on commit 6bc70e2

Please sign in to comment.