avoid combining multiple aggregates from same committee (#6642)

This commit is contained in:
tersec 2024-10-15 04:02:36 +00:00 committed by GitHub
parent 585deb8f90
commit acad28d05b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 15 deletions

View File

@ -577,7 +577,6 @@ proc compute_on_chain_aggregate*(
for i, a in aggregates:
totalLen += a.aggregation_bits.len
# TODO doesn't work if a committee is skipped
var aggregation_bits = ElectraCommitteeValidatorsBits.init(totalLen)
var pos = 0
var prev_committee_index: Opt[CommitteeIndex]
@ -586,12 +585,11 @@ proc compute_on_chain_aggregate*(
committee_index = ? get_committee_index_one(a.committee_bits)
first = pos == 0
when false:
if prev_committee_index.isNone:
prev_committee_index = Opt.some committee_index
elif committee_index.distinctBase <= prev_committee_index.get.distinctBase:
continue
if prev_committee_index.isNone:
prev_committee_index = Opt.some committee_index
elif committee_index.distinctBase <= prev_committee_index.get.distinctBase:
continue
prev_committee_index = Opt.some committee_index
for b in a.aggregation_bits:
aggregation_bits[pos] = b

View File

@ -968,7 +968,6 @@ suite "Attestation pool electra processing" & preset():
attestations[0].aggregation_bits.countOnes() == 3
attestations[0].committee_bits.countOnes() == 2
test "Working with electra aggregates" & preset():
let
# Create an attestation for slot 1!
@ -1048,11 +1047,11 @@ suite "Attestation pool electra processing" & preset():
let attestations = pool[].getElectraAttestationsForBlock(state[], cache)
check:
attestations.len() == 1
attestations[0].aggregation_bits.countOnes() == 6
#TODO: verifyAttestationSignature(attestations[0]) fails
attestations[0].aggregation_bits.countOnes() == 3
verifyAttestationSignature(attestations[0])
# Can get either aggregate here, random!
pool[].getElectraAggregatedAttestation(
1.Slot, hash_tree_root(attestations[0].data), 0.CommitteeIndex).isSome()
verifyAttestationSignature(pool[].getElectraAggregatedAttestation(
1.Slot, hash_tree_root(attestations[0].data), 0.CommitteeIndex).get)
# Add in attestation 0 as single - attestation 1 is now a superset of the
# aggregates in the pool, so everything else should be removed
@ -1065,12 +1064,12 @@ suite "Attestation pool electra processing" & preset():
attestations.len() == 1
attestations[0].aggregation_bits.countOnes() == 4
verifyAttestationSignature(attestations[0])
pool[].getElectraAggregatedAttestation(
1.Slot, hash_tree_root(attestations[0].data), 0.CommitteeIndex).isSome()
verifyAttestationSignature(pool[].getElectraAggregatedAttestation(
1.Slot, hash_tree_root(attestations[0].data), 0.CommitteeIndex).get)
# Someone votes for a different root
let
att4 = makeElectraAttestation(state[], ZERO_HASH, bc0[4], cache)
let att4 = makeElectraAttestation(state[], ZERO_HASH, bc0[4], cache)
check: verifyAttestationSignature(att4)
pool[].addAttestation(
att4, @[bc0[4]], att4.loadSig, att4.data.slot.start_beacon_time)