From 8b64832a0235370ff7b3bebd729e9df4d31c6164 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Thu, 17 Jan 2019 12:07:41 -0600 Subject: [PATCH 1/6] ensure inclusion distance is for lower applicable attestation --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 0ba9b5bcc..81f2fc31d 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1641,7 +1641,7 @@ For every `slot in range(state.slot - 2 * EPOCH_LENGTH, state.slot)`, let `cross Define the following helpers to process attestation inclusion rewards and inclusion distance reward/penalty. For every attestation `a` in `previous_epoch_attestations`: -* Let `inclusion_slot(state, index) = a.slot_included` for the attestation `a` where `index` is in `get_attestation_participants(state, a.data, a.aggregation_bitfield)`. +* Let `inclusion_slot(state, index) = a.slot_included` for the attestation `a` where `index` is in `get_attestation_participants(state, a.data, a.aggregation_bitfield)`. If multiple attestations are applicable, the attestation with lowest `slot_included` is considered. * Let `inclusion_distance(state, index) = a.slot_included - a.data.slot` where `a` is the above attestation. ### Eth1 data From 11009af16ecab85f3d688000d46fe3c16b00fc39 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Fri, 18 Jan 2019 18:01:43 +0600 Subject: [PATCH 2/6] Adds a note about Python code exceptions --- specs/core/0_beacon-chain.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 002e53f97..2ecc76b94 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -135,7 +135,9 @@ The primary source of load on the beacon chain is "attestations". Attestations a ## Notation -Unless otherwise indicated, code appearing in `this style` is to be interpreted as an algorithm defined in Python. Implementations may implement such algorithms using any code and programming language desired as long as the behavior is identical to that of the algorithm provided. +Unless otherwise indicated, code appearing in `this style` is to be interpreted as an algorithm defined in Python. Hence, exceptional cases that are not explicitly handled by a logic in `this style` blocks are propagated to Python exception mechanism. In particular, out of range index access would turned into `IndexError: list index out of range` exception being thrown. + +Implementations may implement such algorithms using any code and programming language desired as long as the behavior is identical to that of the algorithm provided. ## Terminology From 70dfdace158d0c92d99aef04b1757c8c436d11da Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 18 Jan 2019 21:37:30 +0000 Subject: [PATCH 3/6] Update 0_beacon-chain.md --- specs/core/0_beacon-chain.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 2ecc76b94..429ff3a2c 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -131,11 +131,11 @@ This document represents the specification for Phase 0 of Ethereum 2.0 -- The Be At the core of Ethereum 2.0 is a system chain called the "beacon chain". The beacon chain stores and manages the registry of [validators](#dfn-validator). In the initial deployment phases of Ethereum 2.0 the only mechanism to become a [validator](#dfn-validator) is to make a one-way ETH transaction to a deposit contract on Ethereum 1.0. Activation as a [validator](#dfn-validator) happens when Ethereum 1.0 deposit receipts are processed by the beacon chain, the activation balance is reached, and after a queuing process. Exit is either voluntary or done forcibly as a penalty for misbehavior. -The primary source of load on the beacon chain is "attestations". Attestations are availability votes for a shard block, and simultaneously proof of stake votes for a beacon chain block. A sufficient number of attestations for the same shard block create a "crosslink", confirming the shard segment up to that shard block into the beacon chain. Crosslinks also serve as infrastructure for asynchronous cross-shard communication. +The primary source of load on the beacon chain is "attestations". Attestations are availability votes for a shard block, and simultaneously proof of stake votes for a beacon block. A sufficient number of attestations for the same shard block create a "crosslink", confirming the shard segment up to that shard block into the beacon chain. Crosslinks also serve as infrastructure for asynchronous cross-shard communication. ## Notation -Unless otherwise indicated, code appearing in `this style` is to be interpreted as an algorithm defined in Python. Hence, exceptional cases that are not explicitly handled by a logic in `this style` blocks are propagated to Python exception mechanism. In particular, out of range index access would turned into `IndexError: list index out of range` exception being thrown. +Code snippets appearing in `this style` are to be interpreted as Python code. Beacon blocks that trigger unhandled Python exceptions (e.g. out-of-range list accesses) are considered invalid. Implementations may implement such algorithms using any code and programming language desired as long as the behavior is identical to that of the algorithm provided. From 1c48544fee37ac2bbdf639991c8ef14eef224aa9 Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 18 Jan 2019 21:38:25 +0000 Subject: [PATCH 4/6] Update 0_beacon-chain.md --- specs/core/0_beacon-chain.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 429ff3a2c..cde7a1ba5 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -137,8 +137,6 @@ The primary source of load on the beacon chain is "attestations". Attestations a Code snippets appearing in `this style` are to be interpreted as Python code. Beacon blocks that trigger unhandled Python exceptions (e.g. out-of-range list accesses) are considered invalid. -Implementations may implement such algorithms using any code and programming language desired as long as the behavior is identical to that of the algorithm provided. - ## Terminology * **Validator** - a participant in the Casper/sharding consensus system. You can become one by depositing 32 ETH into the Casper mechanism. From c8d8dc94c09a85704f834c1191a267a14cacfb31 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Sat, 19 Jan 2019 17:16:07 +0800 Subject: [PATCH 5/6] Extract the first two lines of (non-)validator-registry-update --- specs/core/0_beacon-chain.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 0394761ad..899bac6da 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1735,6 +1735,11 @@ def process_ejections(state: BeaconState) -> None: ### Validator registry +First, update `previous_epoch_calculation_slot` and `previous_epoch_start_shard`: + +* Set `state.previous_epoch_calculation_slot = state.current_epoch_calculation_slot` +* Set `state.previous_epoch_start_shard = state.current_epoch_start_shard` + If the following are satisfied: * `state.finalized_slot > state.validator_registry_update_slot` @@ -1788,8 +1793,6 @@ def update_validator_registry(state: BeaconState) -> None: and perform the following updates: -* Set `state.previous_epoch_calculation_slot = state.current_epoch_calculation_slot` -* Set `state.previous_epoch_start_shard = state.current_epoch_start_shard` * Set `state.previous_epoch_randao_mix = state.current_epoch_randao_mix` * Set `state.current_epoch_calculation_slot = state.slot` * Set `state.current_epoch_start_shard = (state.current_epoch_start_shard + get_current_epoch_committee_count_per_slot(state) * EPOCH_LENGTH) % SHARD_COUNT` @@ -1797,8 +1800,6 @@ and perform the following updates: If a validator registry update does _not_ happen do the following: -* Set `state.previous_epoch_calculation_slot = state.current_epoch_calculation_slot` -* Set `state.previous_epoch_start_shard = state.current_epoch_start_shard` * Let `epochs_since_last_registry_change = (state.slot - state.validator_registry_update_slot) // EPOCH_LENGTH`. * If `epochs_since_last_registry_change` is an exact power of 2, set `state.current_epoch_calculation_slot = state.slot` and `state.current_epoch_randao_mix = state.latest_randao_mixes[(state.current_epoch_calculation_slot - SEED_LOOKAHEAD) % LATEST_RANDAO_MIXES_LENGTH]`. Note that `state.current_epoch_start_shard` is left unchanged. From 2e58d52aa6fb5c36f7af09b0bafa55a667f20590 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 21 Jan 2019 08:48:36 -0600 Subject: [PATCH 6/6] Update 0_beacon-chain.md --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index cde7a1ba5..c48abf538 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -135,7 +135,7 @@ The primary source of load on the beacon chain is "attestations". Attestations a ## Notation -Code snippets appearing in `this style` are to be interpreted as Python code. Beacon blocks that trigger unhandled Python exceptions (e.g. out-of-range list accesses) are considered invalid. +Code snippets appearing in `this style` are to be interpreted as Python code. Beacon blocks that trigger unhandled Python exceptions (e.g. out-of-range list accesses) and failed asserts are considered invalid. ## Terminology