This commit is contained in:
Hsiao-Wei Wang 2018-12-01 13:29:19 +08:00
parent f6a14e68e9
commit 11d4473863
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
1 changed files with 80 additions and 61 deletions

View File

@ -3,63 +3,82 @@
**NOTICE**: This document is a work-in-progress for researchers and implementers. It reflects recent spec changes and takes precedence over the Python proof-of-concept implementation [[python-poc]](#ref-python-poc). **NOTICE**: This document is a work-in-progress for researchers and implementers. It reflects recent spec changes and takes precedence over the Python proof-of-concept implementation [[python-poc]](#ref-python-poc).
## Table of contents ## Table of contents
* [Ethereum 2.0 Phase 0 -- The Beacon Chain](#ethereum-20-phase-0----the-beacon-chain) <!-- TOC -->
* [Table of contents](#table-of-contents)
* [Introduction](#introduction) - [Ethereum 2.0 Phase 0 -- The Beacon Chain](#ethereum-20-phase-0----the-beacon-chain)
* [Notation](#notation) - [Table of contents](#table-of-contents)
* [Terminology](#terminology) - [Introduction](#introduction)
* [Constants](#constants) - [Notation](#notation)
* [Ethereum 1.0 deposit contract](#ethereum-10-chain-deposit-contract) - [Terminology](#terminology)
* [Contract code in Vyper](#contract-code-in-vyper) - [Constants](#constants)
* [Data structures](#data-structures) - [Ethereum 1.0 chain deposit contract](#ethereum-10-chain-deposit-contract)
* [Beacon chain blocks](#beacon-chain-blocks) - [Contract code in Vyper](#contract-code-in-vyper)
* [Beacon chain state](#beacon-chain-state) - [Data structures](#data-structures)
* [Beacon chain processing](#beacon-chain-processing) - [Deposits](#deposits)
* [Beacon chain fork choice rule](#beacon-chain-fork-choice-rule) - [`DepositParametersRecord`](#depositparametersrecord)
* [Beacon chain state transition function](#beacon-chain-state-transition-function) - [Beacon chain blocks](#beacon-chain-blocks)
* [Helper functions](#helper-functions) - [`BeaconBlock`](#beaconblock)
* [`get_active_validator_indices`](#get_active_validator_indices) - [`AttestationRecord`](#attestationrecord)
* [`shuffle`](#shuffle) - [`AttestationData`](#attestationdata)
* [`split`](#split) - [`ProposalSignedData`](#proposalsigneddata)
* [`clamp`](#clamp) - [`SpecialRecord`](#specialrecord)
* [`get_new_shuffling`](#get_new_shuffling) - [Beacon chain state](#beacon-chain-state)
* [`get_shard_and_committees_for_slot`](#get_shard_and_committees_for_slot) - [`BeaconState`](#beaconstate)
* [`get_block_hash`](#get_block_hash) - [`ValidatorRecord`](#validatorrecord)
* [`get_beacon_proposer_index`](#get_beacon_proposer_index) - [`CrosslinkRecord`](#crosslinkrecord)
* [`get_attestation_participants`](#get_attestation_participants) - [`ShardAndCommittee`](#shardandcommittee)
* [`bytes1`, `bytes2`, ...](#bytes1-bytes2-) - [`ShardReassignmentRecord`](#shardreassignmentrecord)
* [`get_effective_balance`](#get_effective_balance) - [`CandidatePoWReceiptRootRecord`](#candidatepowreceiptrootrecord)
* [`get_new_validator_registry_delta_chain_tip`](#get_new_validator_registry_delta_chain_tip) - [`PendingAttestationRecord`](#pendingattestationrecord)
* [`integer_squareroot`](#integer_squareroot) - [`ForkData`](#forkdata)
* [On startup](#on-startup) - [Beacon chain processing](#beacon-chain-processing)
* [Routine for adding a validator](#routine-for-adding-a-validator) - [Beacon chain fork choice rule](#beacon-chain-fork-choice-rule)
* [Routine for removing a validator](#routine-for-removing-a-validator) - [Beacon chain state transition function](#beacon-chain-state-transition-function)
* [Per-block processing](#per-block-processing) - [Helper functions](#helper-functions)
* [Verify attestations](#verify-attestations) - [`get_active_validator_indices`](#get_active_validator_indices)
* [Verify proposer signature](#verify-proposer-signature) - [`shuffle`](#shuffle)
* [Verify and process RANDAO reveal](#verify-and-process-randao-reveal) - [`split`](#split)
* [Process PoW receipt root](#process-pow-receipt-root) - [`clamp`](#clamp)
* [Process special objects](#process-special-objects) - [`get_new_shuffling`](#get_new_shuffling)
* [`VOLUNTARY_EXIT`](#voluntary_exit) - [`get_shard_and_committees_for_slot`](#get_shard_and_committees_for_slot)
* [`CASPER_SLASHING`](#casper_slashing) - [`get_block_hash`](#get_block_hash)
* [`PROPOSER_SLASHING`](#proposer_slashing) - [`get_beacon_proposer_index`](#get_beacon_proposer_index)
* [`DEPOSIT_PROOF`](#deposit_proof) - [`get_attestation_participants`](#get_attestation_participants)
* [Epoch boundary processing](#epoch-boundary-processing) - [`bytes1`, `bytes2`, ...](#bytes1-bytes2-)
* [Precomputation](#precomputation) - [`get_effective_balance`](#get_effective_balance)
* [Adjust justified slots and crosslink status](#adjust-justified-slots-and-crosslink-status) - [`get_new_validator_registry_delta_chain_tip`](#get_new_validator_registry_delta_chain_tip)
* [Balance recalculations related to FFG rewards](#balance-recalculations-related-to-ffg-rewards) - [`integer_squareroot`](#integer_squareroot)
* [Balance recalculations related to crosslink rewards](#balance-recalculations-related-to-crosslink-rewards) - [On startup](#on-startup)
* [Ethereum 1.0 chain related rules](#ethereum-10-chain-related-rules) - [Routine for adding a validator](#routine-for-adding-a-validator)
* [Validator registry change](#validator-registry-change) - [Routine for removing a validator](#routine-for-removing-a-validator)
* [If a validator registry change does NOT happen](#if-a-validator-registry-change-does-not-happen) - [Per-block processing](#per-block-processing)
* [Proposer reshuffling](#proposer-reshuffling) - [Verify attestations](#verify-attestations)
* [Finally...](#finally) - [Verify proposer signature](#verify-proposer-signature)
* [Appendix](#appendix) - [Verify and process the RANDAO reveal](#verify-and-process-the-randao-reveal)
* [Appendix A - Hash function](#appendix-a---hash-function) - [Process PoW receipt root](#process-pow-receipt-root)
* [References](#references) - [Process special objects](#process-special-objects)
* [Normative](#normative) - [`VOLUNTARY_EXIT`](#voluntary_exit)
* [Informative](#informative) - [`CASPER_SLASHING`](#casper_slashing)
* [Copyright](#copyright) - [`PROPOSER_SLASHING`](#proposer_slashing)
- [`DEPOSIT_PROOF`](#deposit_proof)
- [Epoch boundary processing](#epoch-boundary-processing)
- [Precomputation](#precomputation)
- [Adjust justified slots and crosslink status](#adjust-justified-slots-and-crosslink-status)
- [Balance recalculations related to FFG rewards](#balance-recalculations-related-to-ffg-rewards)
- [Balance recalculations related to crosslink rewards](#balance-recalculations-related-to-crosslink-rewards)
- [Ethereum 1.0 chain related rules](#ethereum-10-chain-related-rules)
- [Validator registry change](#validator-registry-change)
- [If a validator registry change does NOT happen](#if-a-validator-registry-change-does-not-happen)
- [Proposer reshuffling](#proposer-reshuffling)
- [Finally...](#finally)
- [Appendix](#appendix)
- [Appendix A - Hash function](#appendix-a---hash-function)
- [References](#references)
- [Normative](#normative)
- [Informative](#informative)
- [Copyright](#copyright)
<!-- /TOC -->
## Introduction ## Introduction
@ -329,7 +348,7 @@ When the contract publishes a `ChainStart` log, this initializes the chain, call
} }
``` ```
A `SpecialRecord` object has the following fields: #### `SpecialRecord`
```python ```python
{ {
@ -416,7 +435,7 @@ A `SpecialRecord` object has the following fields:
} }
``` ```
A `ShardAndCommittee` object has the following fields: #### `ShardAndCommittee`
```python ```python
{ {
@ -429,7 +448,7 @@ A `ShardAndCommittee` object has the following fields:
} }
``` ```
A `ShardReassignmentRecord` object has the following fields: #### `ShardReassignmentRecord`
```python ```python
{ {
@ -748,7 +767,7 @@ def get_attestation_participants(state: State,
#### `get_effective_balance` #### `get_effective_balance`
```python ```python
def get_effective_balance(validator: ValidatorRecord) -> int: def get_effective_balance(validator: ValidatorRecord) -> int:
""" """
Returns the effective balance (also known as "balance at stake") for the ``validator``. Returns the effective balance (also known as "balance at stake") for the ``validator``.