Merge pull request #1556 from ethereum/constant-genesis-slot
move GENESIS_SLOT/EPOCH to constants
This commit is contained in:
commit
c3f7f0bc2b
|
@ -63,8 +63,6 @@ EFFECTIVE_BALANCE_INCREMENT: 1000000000
|
||||||
|
|
||||||
# Initial values
|
# Initial values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# 0, GENESIS_EPOCH is derived from this constant
|
|
||||||
GENESIS_SLOT: 0
|
|
||||||
# Mainnet initial fork version, recommend altering for testnets
|
# Mainnet initial fork version, recommend altering for testnets
|
||||||
GENESIS_FORK_VERSION: 0x00000000
|
GENESIS_FORK_VERSION: 0x00000000
|
||||||
BLS_WITHDRAWAL_PREFIX: 0x00
|
BLS_WITHDRAWAL_PREFIX: 0x00
|
||||||
|
|
|
@ -63,8 +63,6 @@ EFFECTIVE_BALANCE_INCREMENT: 1000000000
|
||||||
|
|
||||||
# Initial values
|
# Initial values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# 0, GENESIS_EPOCH is derived from this constant
|
|
||||||
GENESIS_SLOT: 0
|
|
||||||
# Highest byte set to 0x01 to avoid collisions with mainnet versioning
|
# Highest byte set to 0x01 to avoid collisions with mainnet versioning
|
||||||
GENESIS_FORK_VERSION: 0x00000001
|
GENESIS_FORK_VERSION: 0x00000001
|
||||||
BLS_WITHDRAWAL_PREFIX: 0x00
|
BLS_WITHDRAWAL_PREFIX: 0x00
|
||||||
|
|
|
@ -158,6 +158,8 @@ The following values are (non-configurable) constants used throughout the specif
|
||||||
|
|
||||||
| Name | Value |
|
| Name | Value |
|
||||||
| - | - |
|
| - | - |
|
||||||
|
| `GENESIS_SLOT` | `Slot(0)` |
|
||||||
|
| `GENESIS_EPOCH` | `Epoch(0)` |
|
||||||
| `FAR_FUTURE_EPOCH` | `Epoch(2**64 - 1)` |
|
| `FAR_FUTURE_EPOCH` | `Epoch(2**64 - 1)` |
|
||||||
| `BASE_REWARDS_PER_EPOCH` | `4` |
|
| `BASE_REWARDS_PER_EPOCH` | `4` |
|
||||||
| `DEPOSIT_CONTRACT_TREE_DEPTH` | `2**5` (= 32) |
|
| `DEPOSIT_CONTRACT_TREE_DEPTH` | `2**5` (= 32) |
|
||||||
|
@ -196,8 +198,6 @@ The following values are (non-configurable) constants used throughout the specif
|
||||||
|
|
||||||
| Name | Value |
|
| Name | Value |
|
||||||
| - | - |
|
| - | - |
|
||||||
| `GENESIS_SLOT` | `Slot(0)` |
|
|
||||||
| `GENESIS_EPOCH` | `Epoch(0)` |
|
|
||||||
| `GENESIS_FORK_VERSION` | `Version('0x00000000')` |
|
| `GENESIS_FORK_VERSION` | `Version('0x00000000')` |
|
||||||
| `BLS_WITHDRAWAL_PREFIX` | `Bytes1('0x00')` |
|
| `BLS_WITHDRAWAL_PREFIX` | `Bytes1('0x00')` |
|
||||||
|
|
||||||
|
|
|
@ -260,10 +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 - state.slot % SLOTS_PER_ETH1_VOTING_PERIOD)
|
||||||
return state.genesis_time + eth1_voting_period_start_slot * SECONDS_PER_SLOT
|
return compute_time_at_slot(state, eth1_voting_period_start_slot)
|
||||||
```
|
```
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
Loading…
Reference in New Issue