Move block timing assertion 1st
This commit is contained in:
parent
e88a96c45e
commit
f90469ea25
|
@ -140,13 +140,14 @@ def on_tick(store: Store, time: int) -> None:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def on_block(store: Store, block: BeaconBlock) -> None:
|
def on_block(store: Store, block: BeaconBlock) -> None:
|
||||||
|
# Blocks cannot be in the future. If they are, their consideration must be delayed until the are in the past.
|
||||||
|
assert store.time >= pre_state.genesis_time + block.slot * SECONDS_PER_SLOT
|
||||||
# Add new block to the store
|
# Add new block to the store
|
||||||
store.blocks[signing_root(block)] = block
|
store.blocks[signing_root(block)] = block
|
||||||
# Check block is a descendant of the finalized block
|
# Check block is a descendant of the finalized block
|
||||||
assert get_ancestor(store, signing_root(block), store.blocks[store.finalized_root].slot) == store.finalized_root
|
assert get_ancestor(store, signing_root(block), store.blocks[store.finalized_root].slot) == store.finalized_root
|
||||||
# Check block slot against Unix time
|
# Check block slot against Unix time
|
||||||
pre_state = store.states[block.parent_root].copy()
|
pre_state = store.states[block.parent_root].copy()
|
||||||
assert store.time >= pre_state.genesis_time + block.slot * SECONDS_PER_SLOT
|
|
||||||
# Check the block is valid and compute the post-state
|
# Check the block is valid and compute the post-state
|
||||||
state = state_transition(pre_state, block)
|
state = state_transition(pre_state, block)
|
||||||
# Add new state to the store
|
# Add new state to the store
|
||||||
|
|
Loading…
Reference in New Issue