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

Doc standardization #1039

Merged
merged 80 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
8267c01
Update README.md
JSON May 3, 2019
7fbba42
Update 0_beacon-chain.md
JSON May 3, 2019
c221a19
Update 0_deposit-contract.md
JSON May 3, 2019
c94d2cf
Update 0_fork-choice.md
JSON May 3, 2019
209e6c7
Update 1_custody-game.md
JSON May 3, 2019
e67517c
Update 1_shard-data-chains.md
JSON May 3, 2019
278f245
Update 0_beacon-chain-validator.md
JSON May 3, 2019
c7ba69d
Update simple-serialize.md
JSON May 3, 2019
109799b
Update bls_signature.md
JSON May 3, 2019
79a7703
Update README.md
JSON May 3, 2019
4460dc8
Update merkle_proofs.md
JSON May 3, 2019
95addd0
Update sync_protocol.md
JSON May 3, 2019
d5c0a05
Update messaging.md
JSON May 3, 2019
b30da4e
Update node-identification.md
JSON May 3, 2019
7eeb61f
Update rpc-interface.md
JSON May 3, 2019
70a1f33
Update README.md
JSON May 3, 2019
d7381dd
Update README.md
JSON May 3, 2019
6958d80
Update README.md
JSON May 3, 2019
e8effc9
Update README.md
JSON May 3, 2019
d4d03ed
Update README.md
JSON May 3, 2019
b24b613
Update README.md
JSON May 3, 2019
989a47a
Update README.md
JSON May 3, 2019
5017662
Update README.md
JSON May 3, 2019
b47db35
Update core.md
JSON May 3, 2019
750ac7c
Update README.md
JSON May 3, 2019
26d4f01
Update README.md
JSON May 3, 2019
d060f3a
Update README.md
JSON May 3, 2019
1f66969
Update bls_signature.md
JSON May 3, 2019
e5de2a5
Update 0_beacon-chain.md
JSON May 3, 2019
d6fdf50
Update 0_deposit-contract.md
JSON May 3, 2019
175658f
Update 0_fork-choice.md
JSON May 3, 2019
88f6f7d
Update 0_fork-choice.md
JSON May 3, 2019
d747137
Update 1_custody-game.md
JSON May 3, 2019
9b63bba
Update merkle_proofs.md
JSON May 3, 2019
130289d
Update sync_protocol.md
JSON May 3, 2019
72a6ac6
Update rpc-interface.md
JSON May 3, 2019
5f691b5
Update simple-serialize.md
JSON May 3, 2019
9a333ab
Update README.md
JSON May 3, 2019
39c68da
Update README.md
JSON May 3, 2019
851ddc1
Update core.md
JSON May 3, 2019
12b8dc9
Update 0_beacon-chain-validator.md
JSON May 3, 2019
b218798
Update README.md
JSON May 3, 2019
29edd80
Update README.md
JSON May 3, 2019
9e56396
Update 1_shard-data-chains.md
JSON May 3, 2019
e38c04e
Update 0_beacon-chain.md
JSON May 3, 2019
54381ac
Update 0_beacon-chain.md
JSON May 3, 2019
b34ecb4
Update rpc-interface.md
JSON May 3, 2019
e62725f
Update README.md
JSON May 3, 2019
be1440d
Update 1_custody-game.md
JSON May 3, 2019
77bc139
Update simple-serialize.md
JSON May 3, 2019
1197dac
Update simple-serialize.md
JSON May 3, 2019
7f29295
Update merkle_proofs.md
JSON May 3, 2019
29a4f27
Update 1_custody-game.md
JSON May 3, 2019
95bf2be
Update rpc-interface.md
JSON May 3, 2019
6c8665c
Update 0_beacon-chain.md
JSON May 3, 2019
7ce653c
Update 1_custody-game.md
JSON May 3, 2019
f17a80a
Update README.md
JSON May 3, 2019
b498aeb
Update messaging.md
JSON May 3, 2019
c484a44
Update node-identification.md
JSON May 3, 2019
6fbaeba
Update rpc-interface.md
JSON May 3, 2019
0a39ef3
Update 0_beacon-chain.md
JSON May 3, 2019
0dcdbba
Update 0_deposit-contract.md
JSON May 3, 2019
3196cf0
Update 1_custody-game.md
JSON May 3, 2019
214943b
Update 1_shard-data-chains.md
JSON May 3, 2019
b8cce7f
Update 0_fork-choice.md
JSON May 3, 2019
33134d4
Update 0_beacon-chain-validator.md
JSON May 3, 2019
182cc31
Update simple-serialize.md
JSON May 3, 2019
4f7139f
Update bls_signature.md
JSON May 3, 2019
b9024d1
Update README.md
JSON May 3, 2019
5f55735
Update merkle_proofs.md
JSON May 3, 2019
a850bbe
Update sync_protocol.md
JSON May 3, 2019
bcf98c5
Update README.md
JSON May 3, 2019
854363f
Update README.md
JSON May 3, 2019
a29dc5e
Update 0_beacon-chain.md
JSON May 3, 2019
54243ec
Update rpc-interface.md
JSON May 4, 2019
db6bd38
Update 0_beacon-chain.md
JSON May 5, 2019
2fb9700
Update 1_custody-game.md
JSON May 5, 2019
8342343
Update core.md
JSON May 5, 2019
c8e4db4
Update README.md
JSON May 5, 2019
63657f7
Update 1_shard-data-chains.md
JSON May 5, 2019
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

[![Join the chat at https://gitter.im/ethereum/sharding](https://badges.gitter.im/ethereum/sharding.svg)](https://gitter.im/ethereum/sharding?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

To learn more about sharding and eth2.0/Serenity, see the [sharding FAQ](https://github.com/ethereum/wiki/wiki/Sharding-FAQ) and the [research compendium](https://notes.ethereum.org/s/H1PGqDhpm).
To learn more about sharding and Ethereum 2.0 (Serenity), see the [sharding FAQ](https://github.com/ethereum/wiki/wiki/Sharding-FAQ) and the [research compendium](https://notes.ethereum.org/s/H1PGqDhpm).

This repo hosts the current eth2.0 specifications. Discussions about design rationale and proposed changes can be brought up and discussed as issues. Solidified, agreed upon changes to spec can be made through pull requests.
This repository hosts the current Eth 2.0 specifications. Discussions about design rationale and proposed changes can be brought up and discussed as issues. Solidified, agreed-upon changes to the spec can be made through pull requests.


## Specs

Core specifications for eth2.0 client validation can be found in [specs/core](specs/core). These are divided into phases. Each subsequent phase depends upon the prior. The current phases specified are:
Core specifications for Eth 2.0 client validation can be found in [specs/core](specs/core). These are divided into phases. Each subsequent phase depends upon the prior. The current phases specified are:

### Phase 0
* [The Beacon Chain](specs/core/0_beacon-chain.md)
Expand All @@ -30,7 +30,7 @@ Core specifications for eth2.0 client validation can be found in [specs/core](sp
* [Light client syncing protocol](specs/light_client/sync_protocol.md)


### Design goals
## Design goals

The following are the broad design goals for Ethereum 2.0:
* to minimize complexity, even at the cost of some losses in efficiency
Expand Down
6 changes: 3 additions & 3 deletions configs/constant_presets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Later-fork constants can be ignored, e.g. ignore phase1 constants as a client th
Each preset is a key-value mapping.

**Key**: an `UPPER_SNAKE_CASE` (a.k.a. "macro case") formatted string, name of the constant.
**Value**: can be any of:

**Value** can be either:
- an unsigned integer number, can be up to 64 bits (incl.)
- a hexadecimal string, prefixed with `0x`

Presets may contain comments to describe the values.

See `mainnet.yaml` for a complete example.

See [`mainnet.yaml`](./mainnet.yaml) for a complete example.
7 changes: 4 additions & 3 deletions configs/fork_timelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
This directory contains a set of fork timelines used for testing, testnets, and mainnet.

A timeline file contains all the forks known for its target.
Later forks can be ignored, e.g. ignore fork `phase1` as a client that only supports phase 0 currently.
Later forks can be ignored, e.g. ignore fork `phase1` as a client that only supports Phase 0 currently.

## Format

Each preset is a key-value mapping.

**Key**: an `lower_snake_case` (a.k.a. "python case") formatted string, name of the fork.
**Value**: an unsigned integer number, epoch number of activation of the fork

**Value**: an unsigned integer number, epoch number of activation of the fork.

Timelines may contain comments to describe the values.

See `mainnet.yaml` for a complete example.
See [`mainnet.yaml`](./mainnet.yaml) for a complete example.

2 changes: 1 addition & 1 deletion specs/bls_signature.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Let `bls_aggregate_signatures(signatures: List[Bytes96]) -> Bytes96` return `sig

## Signature verification

In the following `e` is the pairing function and `g` is the G1 generator with the following coordinates (see [here](https://github.com/zkcrypto/pairing/tree/master/src/bls12_381#g1)):
In the following, `e` is the pairing function and `g` is the G1 generator with the following coordinates (see [here](https://github.com/zkcrypto/pairing/tree/master/src/bls12_381#g1)):

```python
g_x = 3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507
Expand Down
52 changes: 26 additions & 26 deletions specs/core/0_beacon-chain.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ethereum 2.0 Phase 0 -- The Beacon Chain

**NOTICE**: This document is a work in progress for researchers and implementers.
**Notice**: This document is a work-in-progress for researchers and implementers.

## Table of contents
<!-- TOC -->
Expand Down Expand Up @@ -45,7 +45,7 @@
- [`BeaconBlock`](#beaconblock)
- [Beacon state](#beacon-state)
- [`BeaconState`](#beaconstate)
- [Custom Types](#custom-types)
- [Custom types](#custom-types)
- [Helper functions](#helper-functions)
- [`xor`](#xor)
- [`hash`](#hash)
Expand Down Expand Up @@ -134,25 +134,25 @@ Code snippets appearing in `this style` are to be interpreted as Python code.

## Terminology

* **Validator** <a id="dfn-validator"></a> - a registered participant in the beacon chain. You can become one by sending ether into the Ethereum 1.0 deposit contract.
* **Active validator** <a id="dfn-active-validator"></a> - an active participant in the Ethereum 2.0 consensus invited to, among other things, propose and attest to blocks and vote for crosslinks.
* **Committee** - a (pseudo-) randomly sampled subset of [active validators](#dfn-active-validator). When a committee is referred to collectively, as in "this committee attests to X", this is assumed to mean "some subset of that committee that contains enough [validators](#dfn-validator) that the protocol recognizes it as representing the committee".
* **Proposer** - the [validator](#dfn-validator) that creates a beacon chain block.
* **Attester** - a [validator](#dfn-validator) that is part of a committee that needs to sign off on a beacon chain block while simultaneously creating a link (crosslink) to a recent shard block on a particular shard chain.
* **Beacon chain** - the central PoS chain that is the base of the sharding system.
* **Shard chain** - one of the chains on which user transactions take place and account data is stored.
* **Block root** - a 32-byte Merkle root of a beacon chain block or shard chain block. Previously called "block hash".
* **Crosslink** - a set of signatures from a committee attesting to a block in a shard chain that can be included into the beacon chain. Crosslinks are the main means by which the beacon chain "learns about" the updated state of shard chains.
* **Slot** - a period during which one proposer has the ability to create a beacon chain block and some attesters have the ability to make attestations.
* **Epoch** - an aligned span of slots during which all [validators](#dfn-validator) get exactly one chance to make an attestation.
* **Finalized**, **justified** - see the [Casper FFG paper](https://arxiv.org/abs/1710.09437).
* **Withdrawal period** - the number of slots between a [validator](#dfn-validator) exit and the [validator](#dfn-validator) balance being withdrawable.
* **Genesis time** - the Unix time of the genesis beacon chain block at slot 0.
* **Validator**<a id="dfn-validator"></a>a registered participant in the beacon chain. You can become one by sending ether into the Ethereum 1.0 deposit contract.
* **Active validator**<a id="dfn-active-validator"></a>an active participant in the Ethereum 2.0 consensus invited to, among other things, propose and attest to blocks and vote for crosslinks.
* **Committee**a (pseudo-) randomly sampled subset of [active validators](#dfn-active-validator). When a committee is referred to collectively, as in "this committee attests to X", this is assumed to mean "some subset of that committee that contains enough [validators](#dfn-validator) that the protocol recognizes it as representing the committee".
* **Proposer**the [validator](#dfn-validator) that creates a beacon chain block.
* **Attester**a [validator](#dfn-validator) that is part of a committee that needs to sign off on a beacon chain block while simultaneously creating a link (crosslink) to a recent shard block on a particular shard chain.
* **Beacon chain**the central PoS chain that is the base of the sharding system.
* **Shard chain**one of the chains on which user transactions take place and account data is stored.
* **Block root**a 32-byte Merkle root of a beacon chain block or shard chain block. Previously called "block hash".
* **Crosslink**a set of signatures from a committee attesting to a block in a shard chain that can be included into the beacon chain. Crosslinks are the main means by which the beacon chain "learns about" the updated state of shard chains.
* **Slot**a period during which one proposer has the ability to create a beacon chain block and some attesters have the ability to make attestations.
* **Epoch**an aligned span of slots during which all [validators](#dfn-validator) get exactly one chance to make an attestation.
* **Finalized**, **justified**see the [Casper FFG paper](https://arxiv.org/abs/1710.09437).
* **Withdrawal period**the number of slots between a [validator](#dfn-validator) exit and the [validator](#dfn-validator) balance being withdrawable.
* **Genesis time**the Unix time of the genesis beacon chain block at slot 0.

## Constants

Note: the default mainnet values for the constants are included here for spec-design purposes.
The different configurations for mainnet, testnets, and yaml-based testing can be found in the `configs/constant_presets/` directory.
*Note*: The default mainnet values for the constants are included here for spec-design purposes.
The different configurations for mainnet, testnets, and YAML-based testing can be found in the `configs/constant_presets/` directory.
These configurations are updated for releases, but may be out of sync during `dev` changes.

### Misc
Expand All @@ -165,7 +165,7 @@ These configurations are updated for releases, but may be out of sync during `de
| `MIN_PER_EPOCH_CHURN_LIMIT` | `2**2` (= 4) |
| `CHURN_LIMIT_QUOTIENT` | `2**16` (= 65,536) |
| `BASE_REWARDS_PER_EPOCH` | `5` |
| `SHUFFLE_ROUND_COUNT` | 90 |
| `SHUFFLE_ROUND_COUNT` | `90` |

* For the safety of crosslinks `TARGET_COMMITTEE_SIZE` exceeds [the recommended minimum committee size of 111](https://vitalik.ca/files/Ithaca201807_Sharding.pdf); with sufficient active validators (at least `SLOTS_PER_EPOCH * TARGET_COMMITTEE_SIZE`), the shuffling algorithm ensures committee sizes of at least `TARGET_COMMITTEE_SIZE`. (Unbiasable randomness with a Verifiable Delay Function (VDF) will improve committee robustness and lower the safe minimum committee size.)

Expand Down Expand Up @@ -229,7 +229,7 @@ These configurations are updated for releases, but may be out of sync during `de
| `INACTIVITY_PENALTY_QUOTIENT` | `2**25` (= 33,554,432) |
| `MIN_SLASHING_PENALTY_QUOTIENT` | `2**5` (= 32) |

* **The `BASE_REWARD_QUOTIENT` is NOT final. Once all other protocol details are finalized it will be adjusted, to target a theoretical maximum total issuance of `2**21` ETH per year if `2**27` ETH is validating (and therefore `2**20` per year if `2**25` ETH is validating, etc etc)**
* **The `BASE_REWARD_QUOTIENT` is NOT final. Once all other protocol details are finalized, it will be adjusted to target a theoretical maximum total issuance of `2**21` ETH per year if `2**27` ETH is validating (and therefore `2**20` per year if `2**25` ETH is validating, etc.)**
* The `INACTIVITY_PENALTY_QUOTIENT` equals `INVERSE_SQRT_E_DROP_TIME**2` where `INVERSE_SQRT_E_DROP_TIME := 2**12 epochs` (~18 days) is the time it takes the inactivity penalty to reduce the balance of non-participating [validators](#dfn-validator) to about `1/sqrt(e) ~= 60.6%`. Indeed, the balance retained by offline [validators](#dfn-validator) after `n` epochs is about `(1 - 1/INACTIVITY_PENALTY_QUOTIENT)**(n**2/2)` so after `INVERSE_SQRT_E_DROP_TIME` epochs it is roughly `(1 - 1/INACTIVITY_PENALTY_QUOTIENT)**(INACTIVITY_PENALTY_QUOTIENT/2) ~= 1/sqrt(e)`.

### Max operations per block
Expand Down Expand Up @@ -587,7 +587,7 @@ The types are defined topologically to aid in facilitating an executable version
}
```

## Custom Types
## Custom types

We define the following Python custom types for type hinting and readability:

Expand All @@ -604,7 +604,7 @@ We define the following Python custom types for type hinting and readability:

## Helper functions

Note: The definitions below are for specification purposes and are not necessarily optimal implementations.
*Note*: The definitions below are for specification purposes and are not necessarily optimal implementations.

### `xor`

Expand All @@ -617,7 +617,7 @@ def xor(bytes1: Bytes32, bytes2: Bytes32) -> Bytes32:

The `hash` function is SHA256.

Note: We aim to migrate to a S[T/N]ARK-friendly hash function in a future Ethereum 2.0 deployment phase.
*Note*: We aim to migrate to a S[T/N]ARK-friendly hash function in a future Ethereum 2.0 deployment phase.

### `hash_tree_root`

Expand Down Expand Up @@ -1120,7 +1120,7 @@ def get_churn_limit(state: BeaconState) -> int:

### Routines for updating validator status

Note: All functions in this section mutate `state`.
*Note*: All functions in this section mutate `state`.

#### `initiate_validator_exit`

Expand Down Expand Up @@ -1226,7 +1226,7 @@ Transition section notes:

Beacon blocks that trigger unhandled Python exceptions (e.g. out-of-range list accesses) and failed `assert`s during the state transition are considered invalid.

Note: If there are skipped slots between a block and its parent block, run the steps in the [state-root](#state-caching), [per-epoch](#per-epoch-processing), and [per-slot](#per-slot-processing) sections once for each skipped slot and then once for the slot containing the new block.
*Note*: If there are skipped slots between a block and its parent block, run the steps in the [state-root](#state-caching), [per-epoch](#per-epoch-processing), and [per-slot](#per-slot-processing) sections once for each skipped slot and then once for the slot containing the new block.

### State caching

Expand Down Expand Up @@ -1632,7 +1632,7 @@ def process_eth1_data(state: BeaconState, block: BeaconBlock) -> None:

#### Operations

Note: All functions in this section mutate `state`.
*Note*: All functions in this section mutate `state`.

##### Proposer slashings

Expand Down
14 changes: 7 additions & 7 deletions specs/core/0_deposit-contract.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ethereum 2.0 Phase 0 -- Deposit Contract

**NOTICE**: This document is a work in progress for researchers and implementers.
**Notice**: This document is a work-in-progress for researchers and implementers.

## Table of contents
<!-- TOC -->
Expand All @@ -24,7 +24,7 @@

## Introduction

This document represents is the specification for the beacon chain deposit contract, part of Ethereum 2.0 phase 0.
This document represents the specification for the beacon chain deposit contract, part of Ethereum 2.0 Phase 0.

## Constants

Expand All @@ -40,19 +40,19 @@ This document represents is the specification for the beacon chain deposit contr
| - | - |
| `DEPOSIT_CONTRACT_ADDRESS` | **TBD** |
| `DEPOSIT_CONTRACT_TREE_DEPTH` | `2**5` (= 32) |
| `CHAIN_START_FULL_DEPOSIT_THRESHOLD` | `2**16` (=65,536) |
| `CHAIN_START_FULL_DEPOSIT_THRESHOLD` | `2**16` (= 65,536) |

## Ethereum 1.0 deposit contract

The initial deployment phases of Ethereum 2.0 are implemented without consensus changes to Ethereum 1.0. A deposit contract at address `DEPOSIT_CONTRACT_ADDRESS` is added to Ethereum 1.0 for deposits of ETH to the beacon chain. Validator balances will be withdrawable to the shards in phase 2, i.e. when the EVM2.0 is deployed and the shards have state.
The initial deployment phases of Ethereum 2.0 are implemented without consensus changes to Ethereum 1.0. A deposit contract at address `DEPOSIT_CONTRACT_ADDRESS` is added to Ethereum 1.0 for deposits of ETH to the beacon chain. Validator balances will be withdrawable to the shards in Phase 2 (i.e. when the EVM 2.0 is deployed and the shards have state).

### Arguments

The deposit contract has a `deposit` function which takes the amount in Ethereum 1.0 transaction, and arguments `pubkey: bytes[48], withdrawal_credentials: bytes[32], signature: bytes[96]` corresponding to `DepositData`.

#### Withdrawal credentials

One of the `DepositData` fields is `withdrawal_credentials`. It is a commitment to credentials for withdrawals to shards. The first byte of `withdrawal_credentials` is a version number. As of now the only expected format is as follows:
One of the `DepositData` fields is `withdrawal_credentials`. It is a commitment to credentials for withdrawals to shards. The first byte of `withdrawal_credentials` is a version number. As of now, the only expected format is as follows:

* `withdrawal_credentials[:1] == BLS_WITHDRAWAL_PREFIX_BYTE`
* `withdrawal_credentials[1:] == hash(withdrawal_pubkey)[1:]` where `withdrawal_pubkey` is a BLS pubkey
Expand Down Expand Up @@ -84,10 +84,10 @@ When `CHAIN_START_FULL_DEPOSIT_THRESHOLD` of full deposits have been made, the d

The source for the Vyper contract lives in a [separate repository](https://github.com/ethereum/deposit_contract) at [https://github.com/ethereum/deposit_contract/blob/master/deposit_contract/contracts/validator_registration.v.py](https://github.com/ethereum/deposit_contract/blob/master/deposit_contract/contracts/validator_registration.v.py).

Note: to save ~10x on gas this contract uses a somewhat unintuitive progressive Merkle root calculation algo that requires only O(log(n)) storage. See https://github.com/ethereum/research/blob/master/beacon_chain_impl/progressive_merkle_tree.py for an implementation of the same algo in python tested for correctness.
*Note*: To save ~10x on gas, this contract uses a somewhat unintuitive progressive Merkle root calculation algo that requires only O(log(n)) storage. See https://github.com/ethereum/research/blob/master/beacon_chain_impl/progressive_merkle_tree.py for an implementation of the same algo in Python tested for correctness.

For convenience, we provide the interface to the contract here:

* `__init__()`: initializes the contract
* `get_deposit_root() -> bytes32`: returns the current root of the deposit tree
* `deposit(pubkey: bytes[48], withdrawal_credentials: bytes[32], signature: bytes[96])`: adds a deposit instance to the deposit tree, incorporating the input arguments and the value transferred in the given call. Note: the amount of value transferred *must* be at least `MIN_DEPOSIT_AMOUNT`. Each of these constants are specified in units of Gwei.
* `deposit(pubkey: bytes[48], withdrawal_credentials: bytes[32], signature: bytes[96])`: adds a deposit instance to the deposit tree, incorporating the input arguments and the value transferred in the given call. *Note*: The amount of value transferred *must* be at least `MIN_DEPOSIT_AMOUNT`. Each of these constants are specified in units of Gwei.
Loading