add compute_time_at_slot helper in validator doc

This commit is contained in:
Danny Ryan 2020-01-06 12:13:15 -07:00
parent 8515aec7aa
commit 9ea03dce60
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 7 additions and 3 deletions

View File

@ -260,11 +260,15 @@ Let `get_eth1_data(block: Eth1Block) -> Eth1Data` be the function that returns t
An honest block proposer sets `block.body.eth1_data = get_eth1_vote(state)` where: An honest block proposer sets `block.body.eth1_data = get_eth1_vote(state)` where:
```python
def compute_time_at_slot(state: BeaconState, slot: Slot) -> uint64:
return state.genesis_time + slot * SECONDS_PER_SLOT
```
```python ```python
def voting_period_start_time(state: BeaconState) -> uint64: def voting_period_start_time(state: BeaconState) -> uint64:
eth1_voting_period_start_slot = state.slot % SLOTS_PER_ETH1_VOTING_PERIOD eth1_voting_period_start_slot = Slot(state.slot % SLOTS_PER_ETH1_VOTING_PERIOD)
time_since_genesis = (eth1_voting_period_start_slot - GENESIS_SLOT) * SECONDS_PER_SLOT return compute_time_at_slot(state, eth1_voting_period_start_slot)
return state.genesis_time + time_since_genesis
``` ```
```python ```python