Skip to content

Commit d98b664

Browse files
tersecetan-status
andauthored
add attestation pool checks for aggregating across committees (#6915)
Co-authored-by: Etan Kissling <[email protected]>
1 parent 6532dfb commit d98b664

File tree

2 files changed

+75
-4
lines changed

2 files changed

+75
-4
lines changed

AllTests-mainnet.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
88
## Attestation pool electra processing [Preset: mainnet]
99
```diff
1010
+ Aggregated attestations with disjoint comittee bits into a single on-chain aggregate [Pres OK
11+
+ Aggregating across committees [Preset: mainnet] OK
1112
+ Attestations with disjoint comittee bits and equal data into single on-chain aggregate [Pr OK
1213
+ Can add and retrieve simple electra attestations [Preset: mainnet] OK
1314
+ Working with electra aggregates [Preset: mainnet] OK
1415
```
15-
OK: 4/4 Fail: 0/4 Skip: 0/4
16+
OK: 5/5 Fail: 0/5 Skip: 0/5
1617
## Attestation pool processing [Preset: mainnet]
1718
```diff
1819
+ Attestation from different branch [Preset: mainnet] OK
@@ -1149,4 +1150,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
11491150
OK: 9/9 Fail: 0/9 Skip: 0/9
11501151

11511152
---TOTAL---
1152-
OK: 778/783 Fail: 0/783 Skip: 5/783
1153+
OK: 779/784 Fail: 0/784 Skip: 5/784

tests/test_attestation_pool.nim

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# beacon_chain
2-
# Copyright (c) 2018-2024 Status Research & Development GmbH
2+
# Copyright (c) 2018-2025 Status Research & Development GmbH
33
# Licensed and distributed under either of
44
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
55
# * 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():
11051105
# Total aggregations size should be one for that root
11061106
check:
11071107
pool[].getElectraAggregatedAttestation(1.Slot, hash_tree_root(att4.data),
1108-
0.CommitteeIndex).get().aggregation_bits.countOnes() == 1
1108+
0.CommitteeIndex).get().aggregation_bits.countOnes() == 1
1109+
1110+
proc verifyAttestationSignature(
1111+
pool: AttestationPool,
1112+
state: ref ForkedHashedBeaconState,
1113+
cache: var StateCache,
1114+
attestation: electra.Attestation): bool =
1115+
withState(state[]):
1116+
when consensusFork == ConsensusFork.Electra:
1117+
let
1118+
fork = pool.dag.cfg.forkAtEpoch(forkyState.data.slot.epoch)
1119+
attesting_indices = get_attesting_indices(
1120+
forkyState.data, attestation.data, attestation.aggregation_bits,
1121+
attestation.committee_bits, cache)
1122+
verify_attestation_signature(
1123+
fork, pool.dag.genesis_validators_root, attestation.data,
1124+
attesting_indices.mapIt(forkyState.data.validators.item(it).pubkey),
1125+
attestation.signature)
1126+
else:
1127+
raiseAssert "must be electra"
1128+
1129+
test "Aggregating across committees" & preset():
1130+
# Add attestation from different committee
1131+
var maxSlot = 0.Slot
1132+
for i in 0 ..< 4:
1133+
let
1134+
bc = get_beacon_committee(
1135+
state[], getStateField(state[], slot), i.CommitteeIndex, cache)
1136+
att = makeElectraAttestation(
1137+
state[], state[].latest_block_root, bc[0], cache)
1138+
var att2 = makeElectraAttestation(
1139+
state[], state[].latest_block_root, bc[1], cache)
1140+
att2.combine(att)
1141+
1142+
pool[].addAttestation(
1143+
att, @[bc[0]], att.aggregation_bits.len, att.loadSig,
1144+
att.data.slot.start_beacon_time)
1145+
1146+
pool[].addAttestation(
1147+
att2, @[bc[0], bc[1]], att2.aggregation_bits.len, att2.loadSig,
1148+
att2.data.slot.start_beacon_time)
1149+
1150+
pool[].addAttestation(
1151+
att, @[bc[0]], att.aggregation_bits.len, att.loadSig,
1152+
att.data.slot.start_beacon_time)
1153+
1154+
pool[].addAttestation(
1155+
att2, @[bc[0], bc[1]], att2.aggregation_bits.len, att2.loadSig,
1156+
att2.data.slot.start_beacon_time)
1157+
1158+
if att.data.slot > maxSlot:
1159+
maxSlot = att.data.slot
1160+
1161+
check process_slots(
1162+
defaultRuntimeConfig, state[],
1163+
maxSlot + MIN_ATTESTATION_INCLUSION_DELAY, cache,
1164+
info, {}).isOk()
1165+
1166+
let attestations = pool[].getElectraAttestationsForBlock(state[], cache)
1167+
check:
1168+
attestations.len() == 2
1169+
attestations[0].aggregation_bits.countOnes() == 4
1170+
attestations[0].committee_bits.countOnes() == 2
1171+
attestations[1].aggregation_bits.countOnes() == 4
1172+
attestations[1].committee_bits.countOnes() == 2
1173+
check_attestation(
1174+
state[].electraData.data, attestations[0], {}, cache, true).isOk
1175+
check_attestation(
1176+
state[].electraData.data, attestations[1], {}, cache, true).isOk
1177+
pool[].verifyAttestationSignature(state, cache, attestations[0])
1178+
pool[].verifyAttestationSignature(state, cache, attestations[1])

0 commit comments

Comments
 (0)