port phase0 forkchocie changes to merge

This commit is contained in:
Danny Ryan 2021-11-17 18:37:45 -07:00
parent eb00f8f735
commit 3d4ece44df
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
3 changed files with 1 additions and 24 deletions

View File

@ -186,17 +186,5 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
# Update finalized checkpoint # Update finalized checkpoint
if state.finalized_checkpoint.epoch > store.finalized_checkpoint.epoch: if state.finalized_checkpoint.epoch > store.finalized_checkpoint.epoch:
store.finalized_checkpoint = state.finalized_checkpoint store.finalized_checkpoint = state.finalized_checkpoint
store.justified_checkpoint = state.current_justified_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
``` ```

View File

@ -386,9 +386,6 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
# Update finalized checkpoint # Update finalized checkpoint
if state.finalized_checkpoint.epoch > store.finalized_checkpoint.epoch: 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.finalized_checkpoint = state.finalized_checkpoint
store.justified_checkpoint = state.current_justified_checkpoint store.justified_checkpoint = state.current_justified_checkpoint
``` ```

View File

@ -694,21 +694,13 @@ def test_new_finalized_slot_is_justified_checkpoint_ancestor(spec, state):
pre_store_justified_checkpoint_root = store.justified_checkpoint.root pre_store_justified_checkpoint_root = store.justified_checkpoint.root
for block in all_blocks: 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) yield from tick_and_add_block(spec, store, block, test_steps)
finalized_slot = spec.compute_start_slot_at_epoch(store.finalized_checkpoint.epoch) 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) ancestor_at_finalized_slot = spec.get_ancestor(store, pre_store_justified_checkpoint_root, finalized_slot)
assert ancestor_at_finalized_slot == store.finalized_checkpoint.root 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 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 assert store.justified_checkpoint == another_state.current_justified_checkpoint
yield 'steps', test_steps yield 'steps', test_steps