diff --git a/AllTests-mainnet.md b/AllTests-mainnet.md index 8cabf90083..fccf9ec5f3 100644 --- a/AllTests-mainnet.md +++ b/AllTests-mainnet.md @@ -8,11 +8,12 @@ OK: 1/1 Fail: 0/1 Skip: 0/1 ## Attestation pool electra processing [Preset: mainnet] ```diff + Aggregated attestations with disjoint comittee bits into a single on-chain aggregate [Pres OK ++ Aggregating across committees [Preset: mainnet] OK + Attestations with disjoint comittee bits and equal data into single on-chain aggregate [Pr OK + Can add and retrieve simple electra attestations [Preset: mainnet] OK + Working with electra aggregates [Preset: mainnet] OK ``` -OK: 4/4 Fail: 0/4 Skip: 0/4 +OK: 5/5 Fail: 0/5 Skip: 0/5 ## Attestation pool processing [Preset: mainnet] ```diff + Attestation from different branch [Preset: mainnet] OK @@ -1149,4 +1150,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2 OK: 9/9 Fail: 0/9 Skip: 0/9 ---TOTAL--- -OK: 778/783 Fail: 0/783 Skip: 5/783 +OK: 779/784 Fail: 0/784 Skip: 5/784 diff --git a/tests/test_attestation_pool.nim b/tests/test_attestation_pool.nim index b19d9d4268..24c8cbb655 100644 --- a/tests/test_attestation_pool.nim +++ b/tests/test_attestation_pool.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2024 Status Research & Development GmbH +# Copyright (c) 2018-2025 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -1105,4 +1105,74 @@ suite "Attestation pool electra processing" & preset(): # Total aggregations size should be one for that root check: pool[].getElectraAggregatedAttestation(1.Slot, hash_tree_root(att4.data), - 0.CommitteeIndex).get().aggregation_bits.countOnes() == 1 \ No newline at end of file + 0.CommitteeIndex).get().aggregation_bits.countOnes() == 1 + + proc verifyAttestationSignature( + pool: AttestationPool, + state: ref ForkedHashedBeaconState, + cache: var StateCache, + attestation: electra.Attestation): bool = + withState(state[]): + when consensusFork == ConsensusFork.Electra: + let + fork = pool.dag.cfg.forkAtEpoch(forkyState.data.slot.epoch) + attesting_indices = get_attesting_indices( + forkyState.data, attestation.data, attestation.aggregation_bits, + attestation.committee_bits, cache) + verify_attestation_signature( + fork, pool.dag.genesis_validators_root, attestation.data, + attesting_indices.mapIt(forkyState.data.validators.item(it).pubkey), + attestation.signature) + else: + raiseAssert "must be electra" + + test "Aggregating across committees" & preset(): + # Add attestation from different committee + var maxSlot = 0.Slot + for i in 0 ..< 4: + let + bc = get_beacon_committee( + state[], getStateField(state[], slot), i.CommitteeIndex, cache) + att = makeElectraAttestation( + state[], state[].latest_block_root, bc[0], cache) + var att2 = makeElectraAttestation( + state[], state[].latest_block_root, bc[1], cache) + att2.combine(att) + + pool[].addAttestation( + att, @[bc[0]], att.aggregation_bits.len, att.loadSig, + att.data.slot.start_beacon_time) + + pool[].addAttestation( + att2, @[bc[0], bc[1]], att2.aggregation_bits.len, att2.loadSig, + att2.data.slot.start_beacon_time) + + pool[].addAttestation( + att, @[bc[0]], att.aggregation_bits.len, att.loadSig, + att.data.slot.start_beacon_time) + + pool[].addAttestation( + att2, @[bc[0], bc[1]], att2.aggregation_bits.len, att2.loadSig, + att2.data.slot.start_beacon_time) + + if att.data.slot > maxSlot: + maxSlot = att.data.slot + + check process_slots( + defaultRuntimeConfig, state[], + maxSlot + MIN_ATTESTATION_INCLUSION_DELAY, cache, + info, {}).isOk() + + let attestations = pool[].getElectraAttestationsForBlock(state[], cache) + check: + attestations.len() == 2 + attestations[0].aggregation_bits.countOnes() == 4 + attestations[0].committee_bits.countOnes() == 2 + attestations[1].aggregation_bits.countOnes() == 4 + attestations[1].committee_bits.countOnes() == 2 + check_attestation( + state[].electraData.data, attestations[0], {}, cache, true).isOk + check_attestation( + state[].electraData.data, attestations[1], {}, cache, true).isOk + pool[].verifyAttestationSignature(state, cache, attestations[0]) + pool[].verifyAttestationSignature(state, cache, attestations[1])