Crosslink bugfix

1. Fix `is_winning_attestation` condition
2. Fix `process_crosslink_for_shard`: we can only check
`shard_data_roots` if `shard_transition != ShardTransition()`
This commit is contained in:
Hsiao-Wei Wang 2020-06-19 22:19:21 +08:00
parent 3117cf3140
commit c2c2b4c444
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
1 changed files with 5 additions and 4 deletions

View File

@ -671,7 +671,7 @@ def is_winning_attestation(state: BeaconState,
``winning_root`` formed by ``committee_index`` committee at the current slot.
"""
return (
attestation.data.slot == state.slot
is_on_time_attestation(state, attestation)
and attestation.data.index == committee_index
and attestation.data.shard_transition_root == winning_root
)
@ -886,9 +886,10 @@ def process_crosslink_for_shard(state: BeaconState,
for attestation in transition_attestations:
participants = get_attesting_indices(state, attestation.data, attestation.aggregation_bits)
transition_participants = transition_participants.union(participants)
assert attestation.data.shard_head_root == shard_transition.shard_data_roots[
len(shard_transition.shard_data_roots) - 1
]
if len(shard_transition.shard_data_roots) > 0:
# Is the `shard_transition` candidate
last_offset_index = len(shard_transition.shard_data_roots) - 1
assert attestation.data.shard_head_root == shard_transition.shard_data_roots[last_offset_index]
enough_online_stake = (
get_total_balance(state, online_indices.intersection(transition_participants)) * 3 >=