forked from ethereum/consensus-specs
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable light client patch: beacon-chain.md (ethereum#2141)
* Bump remerkleable to 0.1.18 * Disable `sync-protocol.md` for now. Make linter pass * Enable lightclient tests * Use *new* `optional_fast_aggregate_verify` * Fix ToC and codespell * Do not run phase1 tests with Lightclient patch * Fix the Eth1Data casting bug. Add a workaround. * Fix `run_on_attestation` testing helper * Revert * Rename `optional_fast_aggregate_verify` to `eth2_fast_aggregate_verify` * Apply Proto's suggestion * Apply Danny's suggestion * Fixing tests * Fix after rebasing * Rename `LIGHTCLIENT` -> `LIGHTCLIENT_PATCH` * New doctoc * Add lightclient patch configs * fix gitignore light client patch generator output * Upgrade state for light client patch * Add `lightclient-fork.md` to deal the fork boundary and fix `process_block_header` * Misc cleanups 1) Add a summary note for every function that is changed. 2) Avoid changing `process_block` (instead only change `process_block_header`). 3) Rename `G2_INFINITY_POINT_SIG` to `G2_POINT_AT_INFINITY` to avoid `SIG` contraction. 4) Misc cleanups * Update block.py * Update beacon-chain.md * Fix typo "minimal" -> "mainnet" Co-authored-by: Marin Petrunić <[email protected]> * Use the new `BeaconBlockHeader` instead of phase 0 version * Update config files * Move `sync_committee_bits` and `sync_committee_signature` back to `BeaconBlockBody` Co-authored-by: protolambda <[email protected]> Co-authored-by: Justin <[email protected]> Co-authored-by: Marin Petrunić <[email protected]>
- Loading branch information
1 parent
1a30ea9
commit acfe49e
Showing
27 changed files
with
340 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Mainnet preset - lightclient patch | ||
|
||
CONFIG_NAME: "mainnet" | ||
|
||
# Misc | ||
# --------------------------------------------------------------- | ||
# 2**10 (=1,024) | ||
SYNC_COMMITTEE_SIZE: 1024 | ||
# 2**6 (=64) | ||
SYNC_COMMITTEE_PUBKEY_AGGREGATES_SIZE: 64 | ||
|
||
|
||
# Time parameters | ||
# --------------------------------------------------------------- | ||
# 2**8 (= 256) | ||
EPOCHS_PER_SYNC_COMMITTEE_PERIOD: 256 | ||
|
||
|
||
# Signature domains | ||
# --------------------------------------------------------------- | ||
DOMAIN_SYNC_COMMITTEE: 0x07000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Minimal preset - lightclient patch | ||
|
||
CONFIG_NAME: "minimal" | ||
|
||
# Misc | ||
# --------------------------------------------------------------- | ||
# [customized] | ||
SYNC_COMMITTEE_SIZE: 64 | ||
# [customized] | ||
SYNC_COMMITTEE_PUBKEY_AGGREGATES_SIZE: 16 | ||
|
||
|
||
# Time parameters | ||
# --------------------------------------------------------------- | ||
# 2**8 (= 256) | ||
EPOCHS_PER_SYNC_COMMITTEE_PERIOD: 256 | ||
|
||
|
||
# Signature domains | ||
# --------------------------------------------------------------- | ||
DOMAIN_SYNC_COMMITTEE: 0x07000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Ethereum 2.0 Light Client Support -- From Phase 0 to Light Client Patch | ||
|
||
**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 | ||
|
||
This document describes the process of moving from Phase 0 to Phase 1 of Ethereum 2.0. | ||
|
||
## Configuration | ||
|
||
Warning: this configuration is not definitive. | ||
|
||
| Name | Value | | ||
| - | - | | ||
| `LIGHTCLIENT_PATCH_FORK_VERSION` | `Version('0x01000000')` | | ||
| `LIGHTCLIENT_PATCH_FORK_SLOT` | `Slot(0)` **TBD** | | ||
|
||
## Fork to Light-client patch | ||
|
||
### 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 `LIGHTCLIENT_PATCH_FORK_SLOT`, where `LIGHTCLIENT_PATCH_FORK_SLOT % SLOTS_PER_EPOCH == 0`. | ||
|
||
### Upgrading the state | ||
|
||
After `process_slots` of Phase 0 finishes, if `state.slot == LIGHTCLIENT_PATCH_FORK_SLOT`, an irregular state change is made to upgrade to light-client patch. | ||
|
||
```python | ||
def upgrade_to_lightclient_patch(pre: phase0.BeaconState) -> BeaconState: | ||
epoch = get_current_epoch(pre) | ||
post = BeaconState( | ||
genesis_time=pre.genesis_time, | ||
slot=pre.slot, | ||
fork=Fork( | ||
previous_version=pre.fork.current_version, | ||
current_version=LIGHTCLIENT_PATCH_FORK_VERSION, | ||
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, | ||
# Attestations | ||
# previous_epoch_attestations is cleared on upgrade. | ||
previous_epoch_attestations=List[PendingAttestation, MAX_ATTESTATIONS * SLOTS_PER_EPOCH](), | ||
# empty in pre state, since the upgrade is performed just after an epoch boundary. | ||
current_epoch_attestations=List[PendingAttestation, MAX_ATTESTATIONS * SLOTS_PER_EPOCH](), | ||
# 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, | ||
# Light-client | ||
current_sync_committee=SyncCommittee(), | ||
next_sync_committee=SyncCommittee(), | ||
) | ||
return post | ||
``` |
Oops, something went wrong.