26
26
from eth .beacon .enums .validator_status_codes import (
27
27
ValidatorStatusCode ,
28
28
)
29
- from eth .beacon .types .shard_and_committees import (
30
- ShardAndCommittee ,
29
+ from eth .beacon .types .shard_committees import (
30
+ ShardCommittee ,
31
31
)
32
32
from eth .beacon .utils .random import (
33
33
shuffle ,
@@ -173,22 +173,22 @@ def get_new_recent_block_hashes(old_block_hashes: Sequence[Hash32],
173
173
def get_shards_and_committees_for_slot (
174
174
crystallized_state : 'CrystallizedState' ,
175
175
slot : int ,
176
- cycle_length : int ) -> Iterable [ShardAndCommittee ]:
176
+ cycle_length : int ) -> Iterable [ShardCommittee ]:
177
177
"""
178
178
FIXME
179
179
"""
180
- if len (crystallized_state .shard_and_committee_for_slots ) != cycle_length * 2 :
180
+ if len (crystallized_state .shard_committee_for_slots ) != cycle_length * 2 :
181
181
raise ValueError (
182
- "Length of shard_and_committee_for_slots != cycle_length * 2"
182
+ "Length of shard_committee_for_slots != cycle_length * 2"
183
183
"\t expected: %s, found: %s" % (
184
- cycle_length * 2 , len (crystallized_state .shard_and_committee_for_slots )
184
+ cycle_length * 2 , len (crystallized_state .shard_committee_for_slots )
185
185
)
186
186
)
187
187
188
188
slot_relative_position = crystallized_state .last_state_recalc - cycle_length
189
189
190
190
yield from _get_element_from_recent_list (
191
- crystallized_state .shard_and_committee_for_slots ,
191
+ crystallized_state .shard_committee_for_slots ,
192
192
slot ,
193
193
slot_relative_position ,
194
194
)
@@ -210,9 +210,9 @@ def get_attestation_indices(crystallized_state: 'CrystallizedState',
210
210
cycle_length ,
211
211
)
212
212
213
- for shard_and_committee in shards_and_committees_for_slot :
214
- if shard_and_committee .shard_id == shard_id :
215
- yield from shard_and_committee .committee
213
+ for shard_committee in shards_and_committees_for_slot :
214
+ if shard_committee .shard_id == shard_id :
215
+ yield from shard_committee .committee
216
216
217
217
218
218
def get_active_validator_indices (validators : Sequence ['ValidatorRecord' ]) -> Tuple [int , ...]:
@@ -232,12 +232,12 @@ def get_active_validator_indices(validators: Sequence['ValidatorRecord']) -> Tup
232
232
def _get_shards_and_committees_for_shard_indices (
233
233
shard_indices : Sequence [Sequence [int ]],
234
234
start_shard : int ,
235
- shard_count : int ) -> Iterable [ShardAndCommittee ]:
235
+ shard_count : int ) -> Iterable [ShardCommittee ]:
236
236
"""
237
- Returns filled [ShardAndCommittee ] tuple.
237
+ Returns filled [ShardCommittee ] tuple.
238
238
"""
239
239
for index , indices in enumerate (shard_indices ):
240
- yield ShardAndCommittee (
240
+ yield ShardCommittee (
241
241
shard = (start_shard + index ) % shard_count ,
242
242
committee = indices
243
243
)
@@ -250,16 +250,16 @@ def get_new_shuffling(*,
250
250
crosslinking_start_shard : int ,
251
251
cycle_length : int ,
252
252
target_committee_size : int ,
253
- shard_count : int ) -> Iterable [Iterable [ShardAndCommittee ]]:
253
+ shard_count : int ) -> Iterable [Iterable [ShardCommittee ]]:
254
254
"""
255
- Return shuffled ``shard_and_committee_for_slots `` (``[[ShardAndCommittee ]]``) of
255
+ Return shuffled ``shard_committee_for_slots `` (``[[ShardCommittee ]]``) of
256
256
the given active ``validators`` using ``seed`` as entropy.
257
257
258
258
Two-dimensional:
259
259
The first layer is ``slot`` number
260
- ``shard_and_committee_for_slots [slot] -> [ShardAndCommittee ]``
260
+ ``shard_committee_for_slots [slot] -> [ShardCommittee ]``
261
261
The second layer is ``shard_indices`` number
262
- ``shard_and_committee_for_slots [slot][shard_indices] -> ShardAndCommittee ``
262
+ ``shard_committee_for_slots [slot][shard_indices] -> ShardCommittee ``
263
263
264
264
Example:
265
265
validators:
@@ -278,18 +278,18 @@ def get_new_shuffling(*,
278
278
[
279
279
# slot 0
280
280
[
281
- ShardAndCommittee (shard_id=0, committee=[6, 0]),
282
- ShardAndCommittee (shard_id=1, committee=[2, 12, 14]),
281
+ ShardCommittee (shard_id=0, committee=[6, 0]),
282
+ ShardCommittee (shard_id=1, committee=[2, 12, 14]),
283
283
],
284
284
# slot 1
285
285
[
286
- ShardAndCommittee (shard_id=2, committee=[8, 10]),
287
- ShardAndCommittee (shard_id=3, committee=[4, 9, 1]),
286
+ ShardCommittee (shard_id=2, committee=[8, 10]),
287
+ ShardCommittee (shard_id=3, committee=[4, 9, 1]),
288
288
],
289
289
# slot 2
290
290
[
291
- ShardAndCommittee (shard_id=4, committee=[5, 13, 15]),
292
- ShardAndCommittee (shard_id=5, committee=[7, 3, 11]),
291
+ ShardCommittee (shard_id=4, committee=[5, 13, 15]),
292
+ ShardCommittee (shard_id=5, committee=[7, 3, 11]),
293
293
],
294
294
]
295
295
"""
@@ -331,14 +331,14 @@ def get_block_committees_info(parent_block: 'BaseBeaconBlock',
331
331
FIXME
332
332
Return the block committees and proposer info with BlockCommitteesInfo pack.
333
333
"""
334
- # `proposer_index_in_committee` th attester in `shard_and_committee `
334
+ # `proposer_index_in_committee` th attester in `shard_committee `
335
335
# is the proposer of the parent block.
336
336
try :
337
- shard_and_committee = shards_and_committees [0 ]
337
+ shard_committee = shards_and_committees [0 ]
338
338
except IndexError :
339
339
raise ValueError ("shards_and_committees should not be empty." )
340
340
341
- proposer_committee_size = len (shard_and_committee .committee )
341
+ proposer_committee_size = len (shard_committee .committee )
342
342
if proposer_committee_size <= 0 :
343
343
raise ValueError (
344
344
"The first committee should not be empty"
@@ -350,12 +350,12 @@ def get_block_committees_info(parent_block: 'BaseBeaconBlock',
350
350
)
351
351
352
352
# The index in CrystallizedState.validators
353
- proposer_index = shard_and_committee .committee [proposer_index_in_committee ]
353
+ proposer_index = shard_committee .committee [proposer_index_in_committee ]
354
354
355
355
return BlockCommitteesInfo (
356
356
proposer_index = proposer_index ,
357
357
proposer_index_in_committee = proposer_index_in_committee ,
358
- proposer_shard_id = shard_and_committee .shard_id ,
358
+ proposer_shard_id = shard_committee .shard_id ,
359
359
proposer_committee_size = proposer_committee_size ,
360
360
shards_and_committees = shards_and_committees ,
361
361
)
0 commit comments