From c2c2b4c4441590da1e7c2286176d883f1578638a Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Fri, 19 Jun 2020 22:19:21 +0800 Subject: [PATCH] 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()` --- specs/phase1/beacon-chain.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/specs/phase1/beacon-chain.md b/specs/phase1/beacon-chain.md index a1a940adf..aa250f9c4 100644 --- a/specs/phase1/beacon-chain.md +++ b/specs/phase1/beacon-chain.md @@ -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 >=