@djrtwo's feedback

This commit is contained in:
terence tsao 2020-06-18 12:39:48 -07:00 committed by GitHub
parent db81f88c4e
commit 3888dc27a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -876,6 +876,7 @@ def process_crosslink_for_shard(state: BeaconState,
on_time_attestation_slot = compute_previous_slot(state.slot) on_time_attestation_slot = compute_previous_slot(state.slot)
committee = get_beacon_committee(state, on_time_attestation_slot, committee_index) committee = get_beacon_committee(state, on_time_attestation_slot, committee_index)
online_indices = get_online_validator_indices(state) online_indices = get_online_validator_indices(state)
shard = compute_shard_from_committee_index(state, committee_index, on_time_attestation_slot)
# Loop over all shard transition roots # Loop over all shard transition roots
shard_transition_roots = set([a.data.shard_transition_root for a in attestations]) shard_transition_roots = set([a.data.shard_transition_root for a in attestations])
@ -901,7 +902,7 @@ def process_crosslink_for_shard(state: BeaconState,
assert shard_transition_root == hash_tree_root(shard_transition) assert shard_transition_root == hash_tree_root(shard_transition)
# Apply transition # Apply transition
apply_shard_transition(state, attestations[0].data.shard, shard_transition) apply_shard_transition(state, shard, shard_transition)
# Apply proposer reward and cost # Apply proposer reward and cost
beacon_proposer_index = get_beacon_proposer_index(state) beacon_proposer_index = get_beacon_proposer_index(state)
estimated_attester_reward = sum([get_base_reward(state, attester) for attester in transition_participants]) estimated_attester_reward = sum([get_base_reward(state, attester) for attester in transition_participants])
@ -909,11 +910,11 @@ def process_crosslink_for_shard(state: BeaconState,
increase_balance(state, beacon_proposer_index, proposer_reward) increase_balance(state, beacon_proposer_index, proposer_reward)
states_slots_lengths = zip( states_slots_lengths = zip(
shard_transition.shard_states, shard_transition.shard_states,
get_offset_slots(state, attestations[0].data.shard), get_offset_slots(state, shard),
shard_transition.shard_block_lengths shard_transition.shard_block_lengths
) )
for shard_state, slot, length in states_slots_lengths: for shard_state, slot, length in states_slots_lengths:
proposer_index = get_shard_proposer_index(state, slot, attestations[0].data.shard) proposer_index = get_shard_proposer_index(state, slot, shard)
decrease_balance(state, proposer_index, shard_state.gasprice * length) decrease_balance(state, proposer_index, shard_state.gasprice * length)
# Return winning transition root # Return winning transition root