Merge pull request #2361 from ericsson49/ericsson49/fix_committee_index_typing_problems

Fix typing problems: convert to CommitteeIndex
This commit is contained in:
Danny Ryan 2021-04-27 12:16:11 -06:00 committed by GitHub
commit ca1680dc8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -671,7 +671,8 @@ def process_pending_headers(state: BeaconState) -> None:
previous_epoch = get_previous_epoch(state) previous_epoch = get_previous_epoch(state)
previous_epoch_start_slot = compute_start_slot_at_epoch(previous_epoch) previous_epoch_start_slot = compute_start_slot_at_epoch(previous_epoch)
for slot in range(previous_epoch_start_slot, previous_epoch_start_slot + SLOTS_PER_EPOCH): for slot in range(previous_epoch_start_slot, previous_epoch_start_slot + SLOTS_PER_EPOCH):
for shard in range(get_active_shard_count(state, previous_epoch)): for shard_index in range(get_active_shard_count(state, previous_epoch)):
shard = Shard(shard_index)
# Pending headers for this (slot, shard) combo # Pending headers for this (slot, shard) combo
candidates = [ candidates = [
c for c in state.previous_epoch_pending_shard_headers c for c in state.previous_epoch_pending_shard_headers
@ -682,7 +683,8 @@ def process_pending_headers(state: BeaconState) -> None:
continue continue
# The entire committee (and its balance) # The entire committee (and its balance)
full_committee = get_beacon_committee(state, slot, shard) index = compute_committee_index_from_shard(state, slot, shard)
full_committee = get_beacon_committee(state, slot, index)
# The set of voters who voted for each header (and their total balances) # The set of voters who voted for each header (and their total balances)
voting_sets = [ voting_sets = [
set(v for i, v in enumerate(full_committee) if c.votes[i]) set(v for i, v in enumerate(full_committee) if c.votes[i])
@ -718,7 +720,8 @@ def charge_confirmed_header_fees(state: BeaconState) -> None:
) )
previous_epoch_start_slot = compute_start_slot_at_epoch(get_previous_epoch(state)) previous_epoch_start_slot = compute_start_slot_at_epoch(get_previous_epoch(state))
for slot in range(previous_epoch_start_slot, previous_epoch_start_slot + SLOTS_PER_EPOCH): for slot in range(previous_epoch_start_slot, previous_epoch_start_slot + SLOTS_PER_EPOCH):
for shard in range(SHARD_COUNT): for shard_index in range(SHARD_COUNT):
shard = Shard(shard_index)
confirmed_candidates = [ confirmed_candidates = [
c for c in state.previous_epoch_pending_shard_headers c for c in state.previous_epoch_pending_shard_headers
if (c.slot, c.shard, c.confirmed) == (slot, shard, True) if (c.slot, c.shard, c.confirmed) == (slot, shard, True)
@ -753,8 +756,9 @@ def reset_pending_headers(state: BeaconState) -> None:
next_epoch_start_slot = compute_start_slot_at_epoch(next_epoch) next_epoch_start_slot = compute_start_slot_at_epoch(next_epoch)
for slot in range(next_epoch_start_slot, next_epoch_start_slot + SLOTS_PER_EPOCH): for slot in range(next_epoch_start_slot, next_epoch_start_slot + SLOTS_PER_EPOCH):
for index in range(get_committee_count_per_slot(state, next_epoch)): for index in range(get_committee_count_per_slot(state, next_epoch)):
shard = compute_shard_from_committee_index(state, slot, index) committee_index = CommitteeIndex(index)
committee_length = len(get_beacon_committee(state, slot, shard)) shard = compute_shard_from_committee_index(state, slot, committee_index)
committee_length = len(get_beacon_committee(state, slot, committee_index))
state.current_epoch_pending_shard_headers.append(PendingShardHeader( state.current_epoch_pending_shard_headers.append(PendingShardHeader(
slot=slot, slot=slot,
shard=shard, shard=shard,