Merge pull request #2342 from ethereum/fork-epoch

Use `ALTAIR_FORK_EPOCH` instead of `ALTAIR_FORK_SLOT`
This commit is contained in:
Danny Ryan 2021-04-20 12:58:02 -06:00 committed by GitHub
commit 765e994123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 14 additions and 13 deletions

View File

@ -15,7 +15,7 @@ Over time, the need to sync an older state may be deprecated.
In this case, the prefix on the new constant may be removed, and the old constant will keep a special name before completely being removed. In this case, the prefix on the new constant may be removed, and the old constant will keep a special name before completely being removed.
A previous iteration of forking made use of "timelines", but this collides with the definitions used in the spec (constants for special forking slots, etc.), and was not integrated sufficiently in any of the spec tools or implementations. A previous iteration of forking made use of "timelines", but this collides with the definitions used in the spec (constants for special forking slots, etc.), and was not integrated sufficiently in any of the spec tools or implementations.
Instead, the config essentially doubles as fork definition now, e.g. changing the value for `ALTAIR_FORK_SLOT` changes the fork. Instead, the config essentially doubles as fork definition now, e.g. changing the value for `ALTAIR_FORK_EPOCH` changes the fork.
Another reason to prefer forking through constants is the ability to program a forking moment based on context, instead of being limited to a static slot number. Another reason to prefer forking through constants is the ability to program a forking moment based on context, instead of being limited to a static slot number.

View File

@ -38,7 +38,7 @@ DOMAIN_CONTRIBUTION_AND_PROOF: 0x09000000
# 0x01000000 # 0x01000000
ALTAIR_FORK_VERSION: 0x01000000 ALTAIR_FORK_VERSION: 0x01000000
# TBD # TBD
ALTAIR_FORK_SLOT: 18446744073709551615 ALTAIR_FORK_EPOCH: 18446744073709551615
# Sync protocol # Sync protocol

View File

@ -4,4 +4,4 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
MERGE_FORK_VERSION: 0x02000000 MERGE_FORK_VERSION: 0x02000000
# TBD, temporarily max uint64 value: 2**64 - 1 # TBD, temporarily max uint64 value: 2**64 - 1
MERGE_FORK_SLOT: 18446744073709551615 MERGE_FORK_EPOCH: 18446744073709551615

View File

@ -4,7 +4,7 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
SHARDING_FORK_VERSION: 0x03000000 SHARDING_FORK_VERSION: 0x03000000
# TBD, temporarily max uint64 value: 2**64 - 1 # TBD, temporarily max uint64 value: 2**64 - 1
SHARDING_FORK_SLOT: 18446744073709551615 SHARDING_FORK_EPOCH: 18446744073709551615
# Beacon-chain # Beacon-chain

View File

@ -38,7 +38,7 @@ DOMAIN_CONTRIBUTION_AND_PROOF: 0x09000000
# [customized] Highest byte set to 0x01 to avoid collisions with mainnet versioning # [customized] Highest byte set to 0x01 to avoid collisions with mainnet versioning
ALTAIR_FORK_VERSION: 0x01000001 ALTAIR_FORK_VERSION: 0x01000001
# [customized] # [customized]
ALTAIR_FORK_SLOT: 18446744073709551615 ALTAIR_FORK_EPOCH: 18446744073709551615
# Sync protocol # Sync protocol

View File

@ -4,4 +4,4 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
MERGE_FORK_VERSION: 0x02000001 MERGE_FORK_VERSION: 0x02000001
# TBD, temporarily max uint64 value: 2**64 - 1 # TBD, temporarily max uint64 value: 2**64 - 1
MERGE_FORK_SLOT: 18446744073709551615 MERGE_FORK_EPOCH: 18446744073709551615

View File

@ -4,7 +4,7 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
SHARDING_FORK_VERSION: 0x03000001 SHARDING_FORK_VERSION: 0x03000001
# TBD, temporarily max uint64 value: 2**64 - 1 # TBD, temporarily max uint64 value: 2**64 - 1
MERGE_FORK_SLOT: 18446744073709551615 MERGE_FORK_EPOCH: 18446744073709551615
# Beacon-chain # Beacon-chain

View File

@ -26,17 +26,17 @@ Warning: this configuration is not definitive.
| Name | Value | | Name | Value |
| - | - | | - | - |
| `ALTAIR_FORK_VERSION` | `Version('0x01000000')` | | `ALTAIR_FORK_VERSION` | `Version('0x01000000')` |
| `ALTAIR_FORK_SLOT` | `Slot(18446744073709551615)` **TBD** | | `ALTAIR_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** |
## Fork to Altair ## Fork to Altair
### Fork trigger ### Fork trigger
TBD. Social consensus, along with state conditions such as epoch boundary, finality, deposits, active validator count, etc. may be part of the decision process to trigger the fork. For now we assume the condition will be triggered at slot `ALTAIR_FORK_SLOT`, where `ALTAIR_FORK_SLOT % SLOTS_PER_EPOCH == 0`. TBD. Social consensus, along with state conditions such as epoch boundary, finality, deposits, active validator count, etc. may be part of the decision process to trigger the fork. For now we assume the condition will be triggered at epoch `ALTAIR_FORK_EPOCH`.
### Upgrading the state ### Upgrading the state
After `process_slots` of Phase 0 finishes, if `state.slot == ALTAIR_FORK_SLOT`, an irregular state change is made to upgrade to Altair. After `process_slots` of Phase 0 finishes, if `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == ALTAIR_FORK_EPOCH`, an irregular state change is made to upgrade to Altair.
```python ```python
def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState: def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState:

View File

@ -37,7 +37,7 @@ def get_new_dependencies(state: BeaconState) -> Set[DataCommitment]:
```python ```python
def get_all_dependencies(store: Store, block: BeaconBlock) -> Set[DataCommitment]: def get_all_dependencies(store: Store, block: BeaconBlock) -> Set[DataCommitment]:
if block.slot < SHARDING_FORK_SLOT: if compute_epoch_at_slot(block.slot) < SHARDING_FORK_EPOCH:
return set() return set()
else: else:
latest = get_new_dependencies(store.block_states[hash_tree_root(block)]) latest = get_new_dependencies(store.block_states[hash_tree_root(block)])

View File

@ -42,9 +42,10 @@ def transition_to_slot_via_block(spec, state, slot):
def transition_to_valid_shard_slot(spec, state): def transition_to_valid_shard_slot(spec, state):
""" """
Transition to slot `spec.SHARDING_FORK_SLOT + 1` and fork at `spec.SHARDING_FORK_SLOT`. Transition to slot `compute_epoch_at_slot(spec.SHARDING_FORK_EPOCH) + 1`
and fork at `compute_epoch_at_slot(spec.SHARDING_FORK_EPOCH)`.
""" """
transition_to(spec, state, spec.SHARDING_FORK_SLOT) transition_to(spec, state, spec.compute_epoch_at_slot(spec.SHARDING_FORK_EPOCH))
next_slot(spec, state) next_slot(spec, state)