From eafcab7e58bdf5045eb001fcc80f9b7fa8f69d45 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Sun, 14 Apr 2019 08:24:54 +1000 Subject: [PATCH] check crosslinks validity root against previous --- specs/core/0_beacon-chain.md | 4 ++-- tests/phase0/epoch_processing/test_process_crosslinks.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 70b5bac9b..c1dc9de48 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1920,8 +1920,8 @@ def get_crosslink_deltas(state: BeaconState) -> Tuple[List[Gwei], List[Gwei]]: # do not count as success if winning_root did not or cannot form a chain attempted_crosslink = Crosslink(epoch=slot_to_epoch(slot), crosslink_data_root=winning_root, previous_crosslink_root=previous_crosslink_root) - current_crosslink_root = hash_tree_root(state.current_crosslinks[shard]) - if not current_crosslink_root in {previous_crosslink_root, hash_tree_root(attempted_crosslink) }: + actual_crosslink_root = hash_tree_root(state.previous_crosslinks[shard]) + if not actual_crosslink_root in {previous_crosslink_root, hash_tree_root(attempted_crosslink)}: participants = [] participating_balance = get_total_balance(state, participants) diff --git a/tests/phase0/epoch_processing/test_process_crosslinks.py b/tests/phase0/epoch_processing/test_process_crosslinks.py index 06dc07d85..5f080f6f4 100644 --- a/tests/phase0/epoch_processing/test_process_crosslinks.py +++ b/tests/phase0/epoch_processing/test_process_crosslinks.py @@ -81,10 +81,15 @@ def test_single_crosslink_update_from_previous_epoch(state): assert len(state.previous_epoch_attestations) == 1 pre_state, post_state = run_process_crosslinks(state) + crosslink_deltas = get_crosslink_deltas(state) shard = attestation.data.shard assert post_state.previous_crosslinks[shard] != post_state.current_crosslinks[shard] assert pre_state.current_crosslinks[shard] != post_state.current_crosslinks[shard] + # ensure rewarded + slot = attestation.data.slot + assert crosslink_deltas[0][slot % spec.SLOTS_PER_EPOCH] > 0 + assert crosslink_deltas[1][slot % spec.SLOTS_PER_EPOCH] == 0 return pre_state, post_state