mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-01 05:14:49 +00:00
working through test issues
This commit is contained in:
parent
fb34e162ef
commit
cd3d2ce692
@ -372,19 +372,7 @@ 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
|
||||
```
|
||||
|
||||
#### `on_attestation`
|
||||
|
@ -166,6 +166,7 @@ def add_block(spec,
|
||||
raise
|
||||
|
||||
block_root = signed_block.message.hash_tree_root()
|
||||
print(encode_hex(block_root))
|
||||
assert store.blocks[block_root] == signed_block.message
|
||||
assert store.block_states[block_root].hash_tree_root() == signed_block.message.state_root
|
||||
test_steps.append({
|
||||
@ -186,6 +187,7 @@ def add_block(spec,
|
||||
},
|
||||
}
|
||||
})
|
||||
print(test_steps[-1])
|
||||
|
||||
return store.block_states[signed_block.message.hash_tree_root()]
|
||||
|
||||
|
@ -658,6 +658,7 @@ def test_new_finalized_slot_is_justified_checkpoint_ancestor(spec, state):
|
||||
"""
|
||||
test_steps = []
|
||||
# Initialization
|
||||
print("INIT")
|
||||
store, anchor_block = get_genesis_forkchoice_store_and_block(spec, state)
|
||||
yield 'anchor_state', state
|
||||
yield 'anchor_block', anchor_block
|
||||
@ -679,12 +680,14 @@ def test_new_finalized_slot_is_justified_checkpoint_ancestor(spec, state):
|
||||
state, store, _ = yield from apply_next_epoch_with_attestations(
|
||||
spec, state, store, False, True, test_steps=test_steps)
|
||||
|
||||
print("INIT FIN")
|
||||
assert state.finalized_checkpoint.epoch == store.finalized_checkpoint.epoch == 2
|
||||
assert state.current_justified_checkpoint.epoch == store.justified_checkpoint.epoch == 4
|
||||
assert store.justified_checkpoint == state.current_justified_checkpoint
|
||||
|
||||
# Create another chain
|
||||
# Forking from epoch 3
|
||||
print("FORK")
|
||||
all_blocks = []
|
||||
slot = spec.compute_start_slot_at_epoch(3)
|
||||
block_root = spec.get_block_root_at_slot(state, slot)
|
||||
@ -696,6 +699,7 @@ def test_new_finalized_slot_is_justified_checkpoint_ancestor(spec, state):
|
||||
assert another_state.finalized_checkpoint.epoch == 3
|
||||
assert another_state.current_justified_checkpoint.epoch == 4
|
||||
|
||||
print("APPLY FORK TO FORK CHOICE")
|
||||
pre_store_justified_checkpoint_root = store.justified_checkpoint.root
|
||||
for block in all_blocks:
|
||||
# FIXME: Once `on_block` and `on_attestation` logic is fixed,
|
||||
@ -707,6 +711,9 @@ def test_new_finalized_slot_is_justified_checkpoint_ancestor(spec, state):
|
||||
assert ancestor_at_finalized_slot == store.finalized_checkpoint.root
|
||||
|
||||
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
|
||||
print(store.finalized_checkpoint)
|
||||
print(store.justified_checkpoint)
|
||||
|
||||
yield 'steps', test_steps
|
||||
|
Loading…
x
Reference in New Issue
Block a user