diff --git a/beacon_chain/spec/validator.nim b/beacon_chain/spec/validator.nim index 803fc8cb0..ed99f571c 100644 --- a/beacon_chain/spec/validator.nim +++ b/beacon_chain/spec/validator.nim @@ -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 diff --git a/tests/test_attestation_pool.nim b/tests/test_attestation_pool.nim index 51ac3a6d5..aac347f0a 100644 --- a/tests/test_attestation_pool.nim +++ b/tests/test_attestation_pool.nim @@ -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)