Ensure parent is checked before store lookup

This commit is contained in:
Paul Hauner 2020-06-13 16:04:16 +10:00 committed by GitHub
parent a1a75a38fe
commit 7ad1bb508d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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