feedback from mikhail

This commit is contained in:
Danny Ryan 2019-12-10 10:12:51 -07:00
parent 9989f3ea9d
commit 2c5c9cb71a
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 5 additions and 5 deletions

View File

@ -105,15 +105,15 @@ def get_genesis_store(genesis_state: BeaconState) -> Store:
#### `get_slots_since_genesis`
```python
def get_slots_since_genesis(store: Store) -> Slot:
return Slot((store.time - store.genesis_time) // SECONDS_PER_SLOT)
def get_slots_since_genesis(store: Store) -> int:
return (store.time - store.genesis_time) // SECONDS_PER_SLOT
```
#### `get_current_slot`
```python
def get_current_slot(store: Store) -> Slot:
return GENESIS_SLOT + get_slots_since_genesis(store)
return Slot(GENESIS_SLOT + get_slots_since_genesis(store))
```
#### `compute_slots_since_epoch_start`
@ -277,7 +277,7 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
assert block.parent_root in store.block_states
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 store.time >= pre_state.genesis_time + block.slot * SECONDS_PER_SLOT
assert get_current_slot(store) >= block.slot
# Add new block to the store
store.blocks[hash_tree_root(block)] = block
# Check block is a descendant of the finalized block
@ -325,7 +325,7 @@ def on_attestation(store: Store, attestation: Attestation) -> None:
assert target.root in store.blocks
# Attestations cannot be from future epochs. If they are, delay consideration until the epoch arrives
base_state = store.block_states[target.root].copy()
assert store.time >= base_state.genesis_time + compute_start_slot_at_epoch(target.epoch) * SECONDS_PER_SLOT
assert get_current_slot(store) >= compute_start_slot_at_epoch(target.epoch)
# Attestations must be for a known block. If block is unknown, delay consideration until the block is found
assert attestation.data.beacon_block_root in store.blocks