From a1a75a38fe67c763f6d524ae6ce05fbb325186ad Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Thu, 11 Jun 2020 11:51:18 +1000 Subject: [PATCH 1/2] Tidy, add comment --- specs/phase0/fork-choice.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specs/phase0/fork-choice.md b/specs/phase0/fork-choice.md index b9d8ecd3c..3cd45f1c1 100644 --- a/specs/phase0/fork-choice.md +++ b/specs/phase0/fork-choice.md @@ -343,8 +343,9 @@ def on_tick(store: Store, time: uint64) -> None: def on_block(store: Store, signed_block: SignedBeaconBlock) -> None: block = signed_block.message # Make a copy of the state to avoid mutability issues - assert block.parent_root in store.block_states pre_state = store.block_states[block.parent_root].copy() + # Parent block must be known + assert block.parent_root in store.block_states # Blocks cannot be in the future. If they are, their consideration must be delayed until the are in the past. assert get_current_slot(store) >= block.slot # Add new block to the store From 7ad1bb508d6f339b8def65e2dac85eac3614ca89 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sat, 13 Jun 2020 16:04:16 +1000 Subject: [PATCH 2/2] Ensure parent is checked before store lookup --- specs/phase0/fork-choice.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/phase0/fork-choice.md b/specs/phase0/fork-choice.md index 3cd45f1c1..d9cf87330 100644 --- a/specs/phase0/fork-choice.md +++ b/specs/phase0/fork-choice.md @@ -342,10 +342,10 @@ def on_tick(store: Store, time: uint64) -> None: ```python def on_block(store: Store, signed_block: SignedBeaconBlock) -> None: block = signed_block.message - # Make a copy of the state to avoid mutability issues - pre_state = store.block_states[block.parent_root].copy() # Parent block must be known assert block.parent_root in store.block_states + # Make a copy of the state to avoid mutability issues + pre_state = store.block_states[block.parent_root].copy() # Blocks cannot be in the future. If they are, their consideration must be delayed until the are in the past. assert get_current_slot(store) >= block.slot # Add new block to the store