|
11 | 11 | import
|
12 | 12 | # Status lib
|
13 | 13 | unittest2,
|
14 |
| - chronicles, chronos, |
15 |
| - stew/[byteutils, endians2], |
16 |
| - taskpools, |
| 14 | + chronicles, |
17 | 15 | # Internal
|
18 |
| - ../beacon_chain/gossip_processing/[gossip_validation], |
19 |
| - ../beacon_chain/fork_choice/[fork_choice_types, fork_choice], |
20 | 16 | ../beacon_chain/consensus_object_pools/[
|
21 |
| - block_quarantine, blockchain_dag, block_clearance, attestation_pool], |
22 |
| - ../beacon_chain/spec/[beaconstate, helpers, state_transition, validator], |
| 17 | + blockchain_dag, block_clearance, attestation_pool], |
| 18 | + ../beacon_chain/spec/[state_transition, validator], |
23 | 19 | ../beacon_chain/beacon_clock,
|
24 | 20 | # Test utilities
|
25 | 21 | ./testutil, ./testdbutil, ./testblockutil, ./consensus_spec/fixtures_utils
|
26 | 22 |
|
27 | 23 | from std/sequtils import mapIt, toSeq
|
| 24 | +from stew/byteutils import `<` |
| 25 | +from ../beacon_chain/consensus_object_pools/block_quarantine import |
| 26 | + Quarantine, init |
| 27 | +from ../beacon_chain/spec/beaconstate import |
| 28 | + attester_dependent_root, check_attestation, get_attesting_indices, |
| 29 | + latest_block_root |
28 | 30 | from ./testbcutil import addHeadBlock
|
29 | 31 |
|
30 | 32 | func combine(tgt: var (phase0.Attestation | electra.Attestation),
|
@@ -873,8 +875,7 @@ suite "Attestation pool electra processing" & preset():
|
873 | 875 | get().aggregation_bits.countOnes() == 2
|
874 | 876 | # requests to get and aggregate from different committees should be empty
|
875 | 877 | pool[].getElectraAggregatedAttestation(
|
876 |
| - 2.Slot, combined[0].data.beacon_block_root, 1.CommitteeIndex).isNone() |
877 |
| - |
| 878 | + 2.Slot, hash_tree_root(combined[0].data), 1.CommitteeIndex).isNone() |
878 | 879 |
|
879 | 880 | test "Attestations with disjoint comittee bits and equal data into single on-chain aggregate" & preset():
|
880 | 881 | let
|
@@ -1176,3 +1177,37 @@ suite "Attestation pool electra processing" & preset():
|
1176 | 1177 | state[].electraData.data, attestations[1], {}, cache, true).isOk
|
1177 | 1178 | pool[].verifyAttestationSignature(state, cache, attestations[0])
|
1178 | 1179 | pool[].verifyAttestationSignature(state, cache, attestations[1])
|
| 1180 | + |
| 1181 | + test "simple add and get with electra nonzero committee" & preset(): |
| 1182 | + let |
| 1183 | + bc0 = get_beacon_committee( |
| 1184 | + state[], getStateField(state[], slot), 0.CommitteeIndex, cache) |
| 1185 | + |
| 1186 | + bc1 = get_beacon_committee( |
| 1187 | + state[], getStateField(state[], slot), 1.CommitteeIndex, cache) |
| 1188 | + |
| 1189 | + attestation_1 = makeElectraAttestation( |
| 1190 | + state[], state[].latest_block_root, bc0[0], cache) |
| 1191 | + |
| 1192 | + attestation_2 = makeElectraAttestation( |
| 1193 | + state[], state[].latest_block_root, bc1[0], cache) |
| 1194 | + |
| 1195 | + pool[].addAttestation( |
| 1196 | + attestation_1, @[bc0[0]], attestation_1.aggregation_bits.len, |
| 1197 | + attestation_1.loadSig, attestation_1.data.slot.start_beacon_time) |
| 1198 | + |
| 1199 | + pool[].addAttestation( |
| 1200 | + attestation_2, @[bc1[0]], attestation_2.aggregation_bits.len, |
| 1201 | + attestation_2.loadSig, attestation_2.data.slot.start_beacon_time) |
| 1202 | + |
| 1203 | + check: |
| 1204 | + process_slots( |
| 1205 | + defaultRuntimeConfig, state[], |
| 1206 | + getStateField(state[], slot) + MIN_ATTESTATION_INCLUSION_DELAY, cache, |
| 1207 | + info, {}).isOk() |
| 1208 | + |
| 1209 | + check: |
| 1210 | + pool[].getElectraAggregatedAttestation(1.Slot, hash_tree_root(attestation_1.data), |
| 1211 | + 0.CommitteeIndex).isOk |
| 1212 | + pool[].getElectraAggregatedAttestation(1.Slot, hash_tree_root(attestation_2.data), |
| 1213 | + 1.CommitteeIndex).isOk |
0 commit comments