From b3d65368a1e5747155fe6cdcd557ba3efc023737 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 4 Jul 2019 20:38:18 +0800 Subject: [PATCH 1/4] `PERSISTENT_COMMITTEE_PERIOD` has been defined in phase 0 --- specs/core/1_shard-data-chains.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/specs/core/1_shard-data-chains.md b/specs/core/1_shard-data-chains.md index 613b4c4c2..330840598 100644 --- a/specs/core/1_shard-data-chains.md +++ b/specs/core/1_shard-data-chains.md @@ -13,7 +13,7 @@ - [Misc](#misc) - [Initial values](#initial-values) - [Time parameters](#time-parameters) - - [Signature domains](#signature-domains) + - [Signature domain types](#signature-domain-types) - [TODO PLACEHOLDER](#todo-placeholder) - [Data structures](#data-structures) - [`ShardBlockBody`](#shardblockbody) @@ -61,7 +61,6 @@ This document describes the shard data layer and the shard fork choice rule in P | Name | Value | Unit | Duration | | - | - | :-: | :-: | | `CROSSLINK_LOOKBACK` | `2**0` (= 1) | epochs | 6.2 minutes | -| `PERSISTENT_COMMITTEE_PERIOD` | `2**11` (= 2,048) | epochs | ~9 days | ### Signature domain types From bc39f39d5dd502ff8e317c85d9e8fbcfabf5b14b Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 4 Jul 2019 20:41:00 +0800 Subject: [PATCH 2/4] Move `SECONDS_PER_SLOT` back to 0_beacon_chain spec so that the "duration" notes make more sense --- specs/core/0_beacon-chain.md | 1 + specs/core/0_fork-choice.md | 10 ---------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 975874d51..c0d52463a 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -207,6 +207,7 @@ The following values are (non-configurable) constants used throughout the specif | Name | Value | Unit | Duration | | - | - | :-: | :-: | +| `SECONDS_PER_SLOT` | `6` | seconds | 6 seconds | | `MIN_ATTESTATION_INCLUSION_DELAY` | `2**0` (= 1) | slots | 6 seconds | | `SLOTS_PER_EPOCH` | `2**6` (= 64) | slots | 6.4 minutes | | `MIN_SEED_LOOKAHEAD` | `2**0` (= 1) | epochs | 6.4 minutes | diff --git a/specs/core/0_fork-choice.md b/specs/core/0_fork-choice.md index 9fd8ab53e..fed5457d7 100644 --- a/specs/core/0_fork-choice.md +++ b/specs/core/0_fork-choice.md @@ -8,8 +8,6 @@ - [Ethereum 2.0 Phase 0 -- Beacon Chain Fork Choice](#ethereum-20-phase-0----beacon-chain-fork-choice) - [Table of contents](#table-of-contents) - [Introduction](#introduction) - - [Configuration](#configuration) - - [Time parameters](#time-parameters) - [Fork choice](#fork-choice) - [Helpers](#helpers) - [`LatestMessage`](#latestmessage) @@ -29,14 +27,6 @@ This document is the beacon chain fork choice spec, part of Ethereum 2.0 Phase 0. It assumes the [beacon chain state transition function spec](./0_beacon-chain.md). -## Configuration - -### Time parameters - -| Name | Value | Unit | Duration | -| - | - | :-: | :-: | -| `SECONDS_PER_SLOT` | `6` | seconds | 6 seconds | - ## Fork choice The head block root associated with a `store` is defined as `get_head(store)`. At genesis, let `store = get_genesis_store(genesis_state)` and update `store` by running: From ff96eea3ac7042a36bbc91ae73799f859b77e9c9 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 4 Jul 2019 20:46:47 +0800 Subject: [PATCH 3/4] Add phase 1 domain to constant_presets files --- configs/constant_presets/mainnet.yaml | 3 +++ configs/constant_presets/minimal.yaml | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configs/constant_presets/mainnet.yaml b/configs/constant_presets/mainnet.yaml index 10ab26a00..d4e69dab5 100644 --- a/configs/constant_presets/mainnet.yaml +++ b/configs/constant_presets/mainnet.yaml @@ -128,3 +128,6 @@ DOMAIN_ATTESTATION: 0x02000000 DOMAIN_DEPOSIT: 0x03000000 DOMAIN_VOLUNTARY_EXIT: 0x04000000 DOMAIN_TRANSFER: 0x05000000 +DOMAIN_CUSTODY_BIT_CHALLENGE: 0x06000000 +DOMAIN_SHARD_PROPOSER: 0x80000000 +DOMAIN_SHARD_ATTESTER: 0x81000000 diff --git a/configs/constant_presets/minimal.yaml b/configs/constant_presets/minimal.yaml index b030333ff..34419a223 100644 --- a/configs/constant_presets/minimal.yaml +++ b/configs/constant_presets/minimal.yaml @@ -125,4 +125,7 @@ DOMAIN_RANDAO: 0x01000000 DOMAIN_ATTESTATION: 0x02000000 DOMAIN_DEPOSIT: 0x03000000 DOMAIN_VOLUNTARY_EXIT: 0x04000000 -DOMAIN_TRANSFER: 0x05000000 \ No newline at end of file +DOMAIN_TRANSFER: 0x05000000 +DOMAIN_CUSTODY_BIT_CHALLENGE: 0x06000000 +DOMAIN_SHARD_PROPOSER: 0x80000000 +DOMAIN_SHARD_ATTESTER: 0x81000000 From 733653f1695a01e23c6266205c8d05dcc698bb9a Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 4 Jul 2019 20:52:58 +0800 Subject: [PATCH 4/4] Update some missing type hinting of phase 1 --- specs/core/1_custody-game.md | 16 ++++++++-------- specs/core/1_shard-data-chains.md | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/specs/core/1_custody-game.md b/specs/core/1_custody-game.md index 48100e7ba..f79977442 100644 --- a/specs/core/1_custody-game.md +++ b/specs/core/1_custody-game.md @@ -15,7 +15,7 @@ - [Time parameters](#time-parameters) - [Max operations per block](#max-operations-per-block) - [Reward and penalty quotients](#reward-and-penalty-quotients) - - [Signature domains](#signature-domains) + - [Signature domain types](#signature-domain-types) - [TODO PLACEHOLDER](#todo-placeholder) - [Data structures](#data-structures) - [Custody objects](#custody-objects) @@ -156,7 +156,7 @@ class CustodyChunkChallengeRecord(Container): challenger_index: ValidatorIndex responder_index: ValidatorIndex inclusion_epoch: Epoch - data_root: Bytes32 + data_root: Hash depth: uint64 chunk_index: uint64 ``` @@ -169,9 +169,9 @@ class CustodyBitChallengeRecord(Container): challenger_index: ValidatorIndex responder_index: ValidatorIndex inclusion_epoch: Epoch - data_root: Bytes32 + data_root: Hash chunk_count: uint64 - chunk_bits_merkle_root: Bytes32 + chunk_bits_merkle_root: Hash responder_key: BLSSignature ``` @@ -182,9 +182,9 @@ class CustodyResponse(Container): challenge_index: uint64 chunk_index: uint64 chunk: Vector[Bytes[PLACEHOLDER], BYTES_PER_CUSTODY_CHUNK] - data_branch: List[Bytes32, PLACEHOLDER] - chunk_bits_branch: List[Bytes32, PLACEHOLDER] - chunk_bits_leaf: Bytes32 + data_branch: List[Hash, PLACEHOLDER] + chunk_bits_branch: List[Hash, PLACEHOLDER] + chunk_bits_leaf: Hash ``` ### New beacon operations @@ -296,7 +296,7 @@ def get_custody_chunk_bit(key: BLSSignature, chunk: bytes) -> bool: ### `get_chunk_bits_root` ```python -def get_chunk_bits_root(chunk_bits: bytes) -> Bytes32: +def get_chunk_bits_root(chunk_bits: bytes) -> Hash: aggregated_bits = bytearray([0] * 32) for i in range(0, len(chunk_bits), 32): for j in range(32): diff --git a/specs/core/1_shard-data-chains.md b/specs/core/1_shard-data-chains.md index 330840598..fb4f353ef 100644 --- a/specs/core/1_shard-data-chains.md +++ b/specs/core/1_shard-data-chains.md @@ -93,7 +93,7 @@ class ShardAttestation(Container): class data(Container): slot: Slot shard: Shard - shard_block_root: Bytes32 + shard_block_root: Hash aggregation_bits: Bitlist[PLACEHOLDER] aggregate_signature: BLSSignature ``` @@ -104,10 +104,10 @@ class ShardAttestation(Container): class ShardBlock(Container): slot: Slot shard: Shard - beacon_chain_root: Bytes32 - parent_root: Bytes32 + beacon_chain_root: Hash + parent_root: Hash data: ShardBlockBody - state_root: Bytes32 + state_root: Hash attestations: List[ShardAttestation, PLACEHOLDER] signature: BLSSignature ``` @@ -118,10 +118,10 @@ class ShardBlock(Container): class ShardBlockHeader(Container): slot: Slot shard: Shard - beacon_chain_root: Bytes32 - parent_root: Bytes32 - body_root: Bytes32 - state_root: Bytes32 + beacon_chain_root: Hash + parent_root: Hash + body_root: Hash + state_root: Hash attestations: List[ShardAttestation, PLACEHOLDER] signature: BLSSignature ``` @@ -249,7 +249,7 @@ def verify_shard_attestation_signature(state: BeaconState, ### `compute_crosslink_data_root` ```python -def compute_crosslink_data_root(blocks: Sequence[ShardBlock]) -> Bytes32: +def compute_crosslink_data_root(blocks: Sequence[ShardBlock]) -> Hash: def is_power_of_two(value: uint64) -> bool: return (value > 0) and (value & (value - 1) == 0) @@ -258,7 +258,7 @@ def compute_crosslink_data_root(blocks: Sequence[ShardBlock]) -> Bytes32: values.append(b'\x00' * BYTES_PER_SHARD_BLOCK_BODY) return values - def hash_tree_root_of_bytes(data: bytes) -> bytes: + def hash_tree_root_of_bytes(data: bytes) -> Hash: return hash_tree_root([data[i:i + 32] for i in range(0, len(data), 32)]) def zpad(data: bytes, length: uint64) -> bytes: