@@ -138,25 +138,6 @@ def get_hashes_to_sign(latest_block_hashes: Sequence[Hash32],
138
138
yield block .hash
139
139
140
140
141
- @to_tuple
142
- def get_signed_parent_hashes (latest_block_hashes : Sequence [Hash32 ],
143
- block : 'BaseBeaconBlock' ,
144
- attestation : 'AttestationRecord' ,
145
- epoch_length : int ) -> Iterable [Hash32 ]:
146
- """
147
- Given an attestation and the block they were included in,
148
- the list of hashes that were included in the signature.
149
- """
150
- yield from get_hashes_from_latest_block_hashes (
151
- latest_block_hashes ,
152
- block .slot ,
153
- from_slot = attestation .slot - epoch_length + 1 ,
154
- to_slot = attestation .slot - len (attestation .oblique_parent_hashes ),
155
- epoch_length = epoch_length ,
156
- )
157
- yield from attestation .oblique_parent_hashes
158
-
159
-
160
141
@to_tuple
161
142
def get_new_latest_block_hashes (old_block_hashes : Sequence [Hash32 ],
162
143
parent_slot : int ,
@@ -199,7 +180,7 @@ def get_shard_committees_at_slot(state: 'BeaconState',
199
180
slot : int ,
200
181
epoch_length : int ) -> Tuple [ShardCommittee ]:
201
182
"""
202
- Returns the ``ShardCommittee`` for the ``slot``.
183
+ Return the ``ShardCommittee`` for the ``slot``.
203
184
"""
204
185
return _get_shard_committees_at_slot (
205
186
latest_state_recalculation_slot = state .latest_state_recalculation_slot ,
@@ -209,30 +190,9 @@ def get_shard_committees_at_slot(state: 'BeaconState',
209
190
)
210
191
211
192
212
- @to_tuple
213
- def get_attestation_indices (crystallized_state : 'CrystallizedState' ,
214
- attestation : 'AttestationRecord' ,
215
- epoch_length : int ) -> Iterable [int ]:
216
- """
217
- FIXME
218
- Return committee of the given attestation.
219
- """
220
- shard_id = attestation .shard_id
221
-
222
- shards_committees_for_slot = get_shard_committees_at_slot (
223
- crystallized_state ,
224
- attestation .slot ,
225
- epoch_length ,
226
- )
227
-
228
- for shard_committee in shards_committees_for_slot :
229
- if shard_committee .shard_id == shard_id :
230
- yield from shard_committee .committee
231
-
232
-
233
193
def get_active_validator_indices (validators : Sequence ['ValidatorRecord' ]) -> Tuple [int , ...]:
234
194
"""
235
- Gets indices of active validators from ``validators``.
195
+ Get indices of active validators from ``validators``.
236
196
"""
237
197
return tuple (
238
198
i for i , v in enumerate (validators )
@@ -250,7 +210,7 @@ def _get_shards_committees_for_shard_indices(
250
210
total_validator_count : int ,
251
211
shard_count : int ) -> Iterable [ShardCommittee ]:
252
212
"""
253
- Returns filled [ShardCommittee] tuple.
213
+ Return filled [ShardCommittee] tuple.
254
214
"""
255
215
for index , indices in enumerate (shard_indices ):
256
216
yield ShardCommittee (
@@ -383,7 +343,7 @@ def get_beacon_proposer_index(state: 'BeaconState',
383
343
slot : int ,
384
344
epoch_length : int ) -> int :
385
345
"""
386
- Returns the beacon proposer index for the ``slot``.
346
+ Return the beacon proposer index for the ``slot``.
387
347
"""
388
348
shard_committees = get_shard_committees_at_slot (
389
349
state ,
@@ -408,14 +368,6 @@ def get_beacon_proposer_index(state: 'BeaconState',
408
368
#
409
369
# Bitfields
410
370
#
411
- @to_tuple
412
- def _get_shard_committees (shard_committees : Sequence [ShardCommittee ],
413
- shard : int ) -> Iterable [ShardCommittee ]:
414
- for item in shard_committees :
415
- if item .shard == shard :
416
- yield item
417
-
418
-
419
371
@to_tuple
420
372
def get_attestation_participants (state : 'BeaconState' ,
421
373
slot : int ,
@@ -427,14 +379,21 @@ def get_attestation_participants(state: 'BeaconState',
427
379
from ``participation_bitfield``.
428
380
"""
429
381
# Find the relevant committee
430
- shard_committees = _get_shard_committees (
431
- shard_committees = get_shard_committees_at_slot (
432
- state ,
433
- slot ,
434
- epoch_length ,
435
- ),
436
- shard = shard ,
382
+ # Filter by slot
383
+ shard_committees_at_slot = get_shard_committees_at_slot (
384
+ state ,
385
+ slot ,
386
+ epoch_length ,
387
+ )
388
+ # Filter by shard
389
+ shard_committees = tuple (
390
+ [
391
+ shard_committee
392
+ for shard_committee in shard_committees_at_slot
393
+ if shard_committee .shard == shard
394
+ ]
437
395
)
396
+
438
397
try :
439
398
shard_committee = shard_committees [0 ]
440
399
except IndexError :
0 commit comments