diff --git a/beacon-chain/operations/attestations/kv/aggregated.go b/beacon-chain/operations/attestations/kv/aggregated.go index f66b48107bfc..f9a3b5a24d26 100644 --- a/beacon-chain/operations/attestations/kv/aggregated.go +++ b/beacon-chain/operations/attestations/kv/aggregated.go @@ -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) } } diff --git a/beacon-chain/operations/attestations/kv/aggregated_test.go b/beacon-chain/operations/attestations/kv/aggregated_test.go index 63c82fc392cc..99bbf56c8cb4 100644 --- a/beacon-chain/operations/attestations/kv/aggregated_test.go +++ b/beacon-chain/operations/attestations/kv/aggregated_test.go @@ -52,7 +52,8 @@ func TestKV_Aggregated_CanDelete(t *testing.T) { att1 := ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}} att2 := ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}} att3 := ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}} - atts := []*ethpb.Attestation{att1, att2, att3} + att4 := ðpb.Attestation{Data: ðpb.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 {