From 3d4ece44df9b0e32bf07820f9ea820358e9cf626 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Wed, 17 Nov 2021 18:37:45 -0700 Subject: [PATCH] port phase0 forkchocie changes to merge --- specs/merge/fork-choice.md | 14 +------------- specs/phase0/fork-choice.md | 3 --- .../test/phase0/fork_choice/test_on_block.py | 8 -------- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/specs/merge/fork-choice.md b/specs/merge/fork-choice.md index 3f0c67200..d60a07d1c 100644 --- a/specs/merge/fork-choice.md +++ b/specs/merge/fork-choice.md @@ -186,17 +186,5 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None: # Update finalized checkpoint if state.finalized_checkpoint.epoch > store.finalized_checkpoint.epoch: store.finalized_checkpoint = state.finalized_checkpoint - - # Potentially update justified if different from store - if store.justified_checkpoint != state.current_justified_checkpoint: - # Update justified if new justified is later than store justified - if state.current_justified_checkpoint.epoch > store.justified_checkpoint.epoch: - store.justified_checkpoint = state.current_justified_checkpoint - return - - # Update justified if store justified is not in chain with finalized checkpoint - finalized_slot = compute_start_slot_at_epoch(store.finalized_checkpoint.epoch) - ancestor_at_finalized_slot = get_ancestor(store, store.justified_checkpoint.root, finalized_slot) - if ancestor_at_finalized_slot != store.finalized_checkpoint.root: - store.justified_checkpoint = state.current_justified_checkpoint + store.justified_checkpoint = state.current_justified_checkpoint ``` diff --git a/specs/phase0/fork-choice.md b/specs/phase0/fork-choice.md index 723102e4d..6854a8487 100644 --- a/specs/phase0/fork-choice.md +++ b/specs/phase0/fork-choice.md @@ -386,9 +386,6 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None: # Update finalized checkpoint if state.finalized_checkpoint.epoch > store.finalized_checkpoint.epoch: - print("made it") - print(state.finalized_checkpoint) - print(state.current_justified_checkpoint) store.finalized_checkpoint = state.finalized_checkpoint store.justified_checkpoint = state.current_justified_checkpoint ``` diff --git a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py index 3670a883a..ff2d77a8f 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py +++ b/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_on_block.py @@ -694,21 +694,13 @@ def test_new_finalized_slot_is_justified_checkpoint_ancestor(spec, state): pre_store_justified_checkpoint_root = store.justified_checkpoint.root for block in all_blocks: - # FIXME: Once `on_block` and `on_attestation` logic is fixed, - # fix test case and remove allow_invalid_attestations flag yield from tick_and_add_block(spec, store, block, test_steps) finalized_slot = spec.compute_start_slot_at_epoch(store.finalized_checkpoint.epoch) ancestor_at_finalized_slot = spec.get_ancestor(store, pre_store_justified_checkpoint_root, finalized_slot) assert ancestor_at_finalized_slot == store.finalized_checkpoint.root - print(store.finalized_checkpoint) - print(store.justified_checkpoint) - print(another_state.current_justified_checkpoint) - print('spec.get_head(store)', spec.get_head(store)) - assert store.finalized_checkpoint == another_state.finalized_checkpoint - # Thus should fail with the fix. Once show fail, swap to == assert store.justified_checkpoint == another_state.current_justified_checkpoint yield 'steps', test_steps