2021-03-14 21:54:30 +00:00
# Ethereum 2.0 Altair fork
2020-12-15 05:18:20 +00:00
**Notice**: This document is a work-in-progress for researchers and implementers.
## Table of contents
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE - RUN doctoc TO UPDATE -->
- [Introduction ](#introduction )
- [Configuration ](#configuration )
- [Fork to Light-client patch ](#fork-to-light-client-patch )
- [Fork trigger ](#fork-trigger )
- [Upgrading the state ](#upgrading-the-state )
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Introduction
2021-03-14 21:54:30 +00:00
This document describes the process of the first upgrade of Ethereum 2.0: the Altair hardfork, introducing Light Client support.
2020-12-15 05:18:20 +00:00
## Configuration
Warning: this configuration is not definitive.
| Name | Value |
| - | - |
2021-03-11 13:22:38 +00:00
| `ALTAIR_FORK_VERSION` | `Version('0x01000000')` |
| `ALTAIR_FORK_SLOT` | `Slot(0)` **TBD** |
2020-12-15 05:18:20 +00:00
## Fork to Light-client patch
### Fork trigger
2021-03-11 13:22:38 +00:00
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` .
2020-12-15 05:18:20 +00:00
### Upgrading the state
2021-03-14 21:54:30 +00:00
After `process_slots` of Phase 0 finishes, if `state.slot == ALTAIR_FORK_SLOT` , an irregular state change is made to upgrade to Altair.
2020-12-15 05:18:20 +00:00
```python
2021-03-11 13:22:38 +00:00
def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState:
2020-12-15 05:18:20 +00:00
epoch = get_current_epoch(pre)
post = BeaconState(
2021-03-09 22:16:26 +00:00
# Versioning
2020-12-15 05:18:20 +00:00
genesis_time=pre.genesis_time,
2021-01-05 16:42:01 +00:00
genesis_validators_root=pre.genesis_validators_root,
2020-12-15 05:18:20 +00:00
slot=pre.slot,
fork=Fork(
previous_version=pre.fork.current_version,
2021-03-11 13:22:38 +00:00
current_version=ALTAIR_FORK_VERSION,
2020-12-15 05:18:20 +00:00
epoch=epoch,
),
# History
latest_block_header=pre.latest_block_header,
block_roots=pre.block_roots,
state_roots=pre.state_roots,
historical_roots=pre.historical_roots,
# Eth1
eth1_data=pre.eth1_data,
eth1_data_votes=pre.eth1_data_votes,
eth1_deposit_index=pre.eth1_deposit_index,
# Registry
validators=pre.validators,
balances=pre.balances,
# Randomness
randao_mixes=pre.randao_mixes,
# Slashings
slashings=pre.slashings,
2021-03-02 01:19:12 +00:00
# Participation
2021-03-09 22:16:26 +00:00
previous_epoch_participation=[ParticipationFlags(0b0000_0000) for _ in range(len(pre.validators))],
current_epoch_participation=[ParticipationFlags(0b0000_0000) for _ in range(len(pre.validators))],
2020-12-15 05:18:20 +00:00
# Finality
justification_bits=pre.justification_bits,
previous_justified_checkpoint=pre.previous_justified_checkpoint,
current_justified_checkpoint=pre.current_justified_checkpoint,
finalized_checkpoint=pre.finalized_checkpoint,
2021-03-09 22:16:26 +00:00
# Leak
leak_scores=[0 for _ in range(len(pre.validators))],
2020-12-15 05:18:20 +00:00
)
2020-12-17 00:12:51 +00:00
# Fill in sync committees
post.current_sync_committee = get_sync_committee(post, get_current_epoch(post))
post.next_sync_committee = get_sync_committee(post, get_current_epoch(post) + EPOCHS_PER_SYNC_COMMITTEE_PERIOD)
2020-12-15 05:18:20 +00:00
return post
```