Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ALTAIR_FORK_EPOCH instead of ALTAIR_FORK_SLOT #2342

Merged
merged 1 commit into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

Expand Down
2 changes: 1 addition & 1 deletion configs/mainnet/altair.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ DOMAIN_CONTRIBUTION_AND_PROOF: 0x09000000
# 0x01000000
ALTAIR_FORK_VERSION: 0x01000000
# TBD
ALTAIR_FORK_SLOT: 18446744073709551615
ALTAIR_FORK_EPOCH: 18446744073709551615


# Sync protocol
Expand Down
2 changes: 1 addition & 1 deletion configs/mainnet/merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# ---------------------------------------------------------------
MERGE_FORK_VERSION: 0x02000000
# TBD, temporarily max uint64 value: 2**64 - 1
MERGE_FORK_SLOT: 18446744073709551615
MERGE_FORK_EPOCH: 18446744073709551615
2 changes: 1 addition & 1 deletion configs/mainnet/sharding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ---------------------------------------------------------------
SHARDING_FORK_VERSION: 0x03000000
# TBD, temporarily max uint64 value: 2**64 - 1
SHARDING_FORK_SLOT: 18446744073709551615
SHARDING_FORK_EPOCH: 18446744073709551615


# Beacon-chain
Expand Down
2 changes: 1 addition & 1 deletion configs/minimal/altair.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ DOMAIN_CONTRIBUTION_AND_PROOF: 0x09000000
# [customized] Highest byte set to 0x01 to avoid collisions with mainnet versioning
ALTAIR_FORK_VERSION: 0x01000001
# [customized]
ALTAIR_FORK_SLOT: 18446744073709551615
ALTAIR_FORK_EPOCH: 18446744073709551615


# Sync protocol
Expand Down
2 changes: 1 addition & 1 deletion configs/minimal/merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# ---------------------------------------------------------------
MERGE_FORK_VERSION: 0x02000001
# TBD, temporarily max uint64 value: 2**64 - 1
MERGE_FORK_SLOT: 18446744073709551615
MERGE_FORK_EPOCH: 18446744073709551615
2 changes: 1 addition & 1 deletion configs/minimal/sharding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ---------------------------------------------------------------
SHARDING_FORK_VERSION: 0x03000001
# TBD, temporarily max uint64 value: 2**64 - 1
MERGE_FORK_SLOT: 18446744073709551615
MERGE_FORK_EPOCH: 18446744073709551615


# Beacon-chain
Expand Down
6 changes: 3 additions & 3 deletions specs/altair/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ Warning: this configuration is not definitive.
| Name | Value |
| - | - |
| `ALTAIR_FORK_VERSION` | `Version('0x01000000')` |
| `ALTAIR_FORK_SLOT` | `Slot(18446744073709551615)` **TBD** |
| `ALTAIR_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** |

## Fork to Altair

### 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

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
def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState:
Expand Down
2 changes: 1 addition & 1 deletion specs/das/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_new_dependencies(state: BeaconState) -> Set[DataCommitment]:

```python
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()
else:
latest = get_new_dependencies(store.block_states[hash_tree_root(block)])
Expand Down
5 changes: 3 additions & 2 deletions tests/core/pyspec/eth2spec/test/helpers/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ def transition_to_slot_via_block(spec, state, slot):

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)


Expand Down