From 36a6c1bf1f56266c763ab5a20922c46cfebd5013 Mon Sep 17 00:00:00 2001 From: Justin Date: Sun, 9 Jun 2019 21:30:42 +0100 Subject: [PATCH 1/4] Set MIN_ATTESTATION_INCLUSION_DELAY to 1 See item 7 of #1054. We should consider increasing the slot duration as well. --- 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 a6d9d23c5..6f273de4b 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -199,7 +199,7 @@ These configurations are updated for releases, but may be out of sync during `de | Name | Value | Unit | Duration | | - | - | :-: | :-: | -| `MIN_ATTESTATION_INCLUSION_DELAY` | `2**2` (= 4) | slots | 24 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 | | `ACTIVATION_EXIT_DELAY` | `2**2` (= 4) | epochs | 25.6 minutes | From 05a35c7228f0ae12c44e46cb1d202c6989af434e Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 10 Jun 2019 15:14:32 +0100 Subject: [PATCH 2/4] Tweak inclusion delay rewards and set BASE_REWARD_FACTOR Substantive changes: 1) Split the inclusion delay reward between attester and proposer to add up to at most one base reward. This is analogous to the reward logic in `slash_validator`, and makes the `BASE_REWARDS_PER_EPOCH` constant include proposer rewards. 2) Double `BASE_REWARD_FACTOR` to 2^6 (addressing item 4 in #1054). When the total effective balance is 2^17 ETH then maximum annual issuance is a bit below 2^21 ETH. Maximum annual issuance happens when a) all validators make perfect attestations (matching source, target, head, as well as consistent crosslink data), b) all attestations are included as fast as possible (in particular, no skip blocks), and c) there are no slashings. ```python BASE_REWARD_FACTOR = 2**6 SLOTS_PER_EPOCH = 2**6 SECONDS_PER_SLOT = 6 BASE_REWARDS_PER_EPOCH = 5 GWEI_PER_ETH = 10**9 MAX_TOTAL_EFFECTIVE_BALANCE = 2**27 * GWEI_PER_ETH TARGET_MAX_ISSUANCE = 2**21 * GWEI_PER_ETH def integer_squareroot(n: int) -> int: """ The largest integer ``x`` such that ``x**2`` is less than or equal to ``n``. """ assert n >= 0 x = n y = (x + 1) // 2 while y < x: x = y y = (x + n // x) // 2 return x MAX_REWARDS_PER_EPOCH = MAX_TOTAL_EFFECTIVE_BALANCE * BASE_REWARD_FACTOR // integer_squareroot(MAX_TOTAL_EFFECTIVE_BALANCE) // BASE_REWARDS_PER_EPOCH EPOCHS_PER_YEAR = 365.25*24*60*60 / (SECONDS_PER_SLOT * SLOTS_PER_EPOCH) MAX_REWARDS_PER_YEAR = EPOCHS_PER_YEAR * MAX_REWARDS_PER_EPOCH * BASE_REWARDS_PER_EPOCH print(MAX_REWARDS_PER_YEAR / TARGET_MAX_ISSUANCE) ``` --- specs/core/0_beacon-chain.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index a6d9d23c5..8a60b6f34 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -224,14 +224,13 @@ These configurations are updated for releases, but may be out of sync during `de | Name | Value | | - | - | -| `BASE_REWARD_FACTOR` | `2**5` (= 32) | +| `BASE_REWARD_FACTOR` | `2**6` (= 64) | | `WHISTLEBLOWING_REWARD_QUOTIENT` | `2**9` (= 512) | | `PROPOSER_REWARD_QUOTIENT` | `2**3` (= 8) | | `INACTIVITY_PENALTY_QUOTIENT` | `2**25` (= 33,554,432) | | `MIN_SLASHING_PENALTY_QUOTIENT` | `2**5` (= 32) | -* **The `BASE_REWARD_FACTOR` 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)`. +* The `INACTIVITY_PENALTY_QUOTIENT` equals `INVERSE_SQRT_E_DROP_TIME**2` where `INVERSE_SQRT_E_DROP_TIME := 2**12 epochs` (about 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 @@ -1425,8 +1424,10 @@ def get_attestation_deltas(state: BeaconState) -> Tuple[List[Gwei], List[Gwei]]: a for a in matching_source_attestations if index in get_attesting_indices(state, a.data, a.aggregation_bitfield) ], key=lambda a: a.inclusion_delay) - rewards[attestation.proposer_index] += get_base_reward(state, index) // PROPOSER_REWARD_QUOTIENT - rewards[index] += get_base_reward(state, index) * MIN_ATTESTATION_INCLUSION_DELAY // attestation.inclusion_delay + proposer_reward = get_base_reward(state, index) // PROPOSER_REWARD_QUOTIENT + rewards[attestation.proposer_index] += proposer_reward + max_attester_reward = get_base_reward(state, index) - proposer_reward + rewards[index] += max_attester_reward * MIN_ATTESTATION_INCLUSION_DELAY // attestation.inclusion_delay # Inactivity penalty finality_delay = previous_epoch - state.finalized_epoch From 207eb808a0cad10d0ec20b5fd0ae23004fd59705 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 17 Jun 2019 15:19:44 -0600 Subject: [PATCH 3/4] split constants vs configuration --- configs/constant_presets/mainnet.yaml | 4 ---- configs/constant_presets/minimal.yaml | 4 ---- specs/core/0_beacon-chain.md | 21 ++++++++++++--------- specs/core/0_fork-choice.md | 4 ++-- specs/core/1_shard-data-chains.md | 9 +++++++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/configs/constant_presets/mainnet.yaml b/configs/constant_presets/mainnet.yaml index c0b7c6e9c..892111ce0 100644 --- a/configs/constant_presets/mainnet.yaml +++ b/configs/constant_presets/mainnet.yaml @@ -25,8 +25,6 @@ SHUFFLE_ROUND_COUNT: 90 # --------------------------------------------------------------- # **TBD** DEPOSIT_CONTRACT_ADDRESS: 0x1234567890123456789012345678901234567890 -# 2**5 (= 32) -DEPOSIT_CONTRACT_TREE_DEPTH: 32 # Gwei values @@ -46,8 +44,6 @@ EFFECTIVE_BALANCE_INCREMENT: 1000000000 GENESIS_FORK_VERSION: 0x00000000 # 0, GENESIS_EPOCH is derived from this constant GENESIS_SLOT: 0 -# 2**64 - 1 -FAR_FUTURE_EPOCH: 18446744073709551615 BLS_WITHDRAWAL_PREFIX: 0 diff --git a/configs/constant_presets/minimal.yaml b/configs/constant_presets/minimal.yaml index cdd919927..5f4087d89 100644 --- a/configs/constant_presets/minimal.yaml +++ b/configs/constant_presets/minimal.yaml @@ -24,8 +24,6 @@ SHUFFLE_ROUND_COUNT: 10 # --------------------------------------------------------------- # **TBD** DEPOSIT_CONTRACT_ADDRESS: 0x1234567890123456789012345678901234567890 -# 2**5 (= 32) -DEPOSIT_CONTRACT_TREE_DEPTH: 32 # Gwei values @@ -45,8 +43,6 @@ EFFECTIVE_BALANCE_INCREMENT: 1000000000 GENESIS_FORK_VERSION: 0x00000000 # 0, GENESIS_EPOCH is derived from this constant GENESIS_SLOT: 0 -# 2**64 - 1 -FAR_FUTURE_EPOCH: 18446744073709551615 BLS_WITHDRAWAL_PREFIX: 0 diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 968098895..6f6b6e74e 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -11,6 +11,7 @@ - [Notation](#notation) - [Terminology](#terminology) - [Constants](#constants) + - [Configuration](#configuration) - [Misc](#misc) - [Deposit contract](#deposit-contract) - [Gwei values](#gwei-values) @@ -152,7 +153,17 @@ Code snippets appearing in `this style` are to be interpreted as Python code. ## Constants -*Note*: The default mainnet values for the constants are included here for spec-design purposes. +The following values are (non-configurable) constants used throughout the specification. + +| Name | Value | +| - | - | +| `FAR_FUTURE_EPOCH` | `2**64 - 1` | +| `ZERO_HASH` | `b'\x00' * 32` | +| `DEPOSIT_CONTRACT_TREE_DEPTH` | `2**5` (= 32) | + +## Configuration + +*Note*: The default mainnet configuration values 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. @@ -170,12 +181,6 @@ These configurations are updated for releases, but may be out of sync during `de * 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.) -### Deposit contract - -| Name | Value | -| - | - | -| `DEPOSIT_CONTRACT_TREE_DEPTH` | `2**5` (= 32) | - ### Gwei values | Name | Value | Unit | @@ -191,8 +196,6 @@ These configurations are updated for releases, but may be out of sync during `de | - | - | | `GENESIS_SLOT` | `0` | | `GENESIS_EPOCH` | `0` | -| `FAR_FUTURE_EPOCH` | `2**64 - 1` | -| `ZERO_HASH` | `b'\x00' * 32` | | `BLS_WITHDRAWAL_PREFIX` | `0` | ### Time parameters diff --git a/specs/core/0_fork-choice.md b/specs/core/0_fork-choice.md index 8103bbeb2..1910b6d04 100644 --- a/specs/core/0_fork-choice.md +++ b/specs/core/0_fork-choice.md @@ -9,7 +9,7 @@ - [Table of contents](#table-of-contents) - [Introduction](#introduction) - [Prerequisites](#prerequisites) - - [Constants](#constants) + - [Configuration](#configuration) - [Time parameters](#time-parameters) - [Beacon chain processing](#beacon-chain-processing) - [Beacon chain fork choice rule](#beacon-chain-fork-choice-rule) @@ -26,7 +26,7 @@ This document represents the specification for the beacon chain fork choice rule All terminology, constants, functions, and protocol mechanics defined in the [Phase 0 -- The Beacon Chain](./0_beacon-chain.md) doc are requisite for this document and used throughout. Please see the Phase 0 doc before continuing and use as a reference throughout. -## Constants +## Configuration ### Time parameters diff --git a/specs/core/1_shard-data-chains.md b/specs/core/1_shard-data-chains.md index a895b3c38..1b2b2b2da 100644 --- a/specs/core/1_shard-data-chains.md +++ b/specs/core/1_shard-data-chains.md @@ -9,8 +9,9 @@ - [Ethereum 2.0 Phase 1 -- Shard Data Chains](#ethereum-20-phase-1----shard-data-chains) - [Table of contents](#table-of-contents) - [Introduction](#introduction) - - [Constants](#constants) + - [Configuration](#configuration) - [Misc](#misc) + - [Initial values](#initial-values) - [Time parameters](#time-parameters) - [Signature domains](#signature-domains) - [Data structures](#data-structures) @@ -38,7 +39,7 @@ This document describes the shard data layer and the shard fork choice rule in Phase 1 of Ethereum 2.0. -## Constants +## Configuration ### Misc @@ -46,6 +47,10 @@ This document describes the shard data layer and the shard fork choice rule in P | - | - | | `BYTES_PER_SHARD_BLOCK_BODY` | `2**14` (= 16,384) | | `MAX_SHARD_ATTESTIONS` | `2**4` (= 16) | + +### Initial values + +| Name | Value | | `PHASE_1_FORK_EPOCH` | **TBD** | | `PHASE_1_FORK_SLOT` | **TBD** | | `GENESIS_SHARD_SLOT` | 0 | From 89d9d80b1c54fef13bf3135aa7fbcb534ce5e700 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 17 Jun 2019 16:12:47 -0600 Subject: [PATCH 4/4] move BASE_REWARDS_PER_EPOCH to constants --- configs/constant_presets/mainnet.yaml | 2 -- configs/constant_presets/minimal.yaml | 2 -- specs/core/0_beacon-chain.md | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/configs/constant_presets/mainnet.yaml b/configs/constant_presets/mainnet.yaml index 892111ce0..ed839fc7d 100644 --- a/configs/constant_presets/mainnet.yaml +++ b/configs/constant_presets/mainnet.yaml @@ -15,8 +15,6 @@ MAX_INDICES_PER_ATTESTATION: 4096 MIN_PER_EPOCH_CHURN_LIMIT: 4 # 2**16 (= 65,536) CHURN_LIMIT_QUOTIENT: 65536 -# Normalizes base rewards -BASE_REWARDS_PER_EPOCH: 5 # See issue 563 SHUFFLE_ROUND_COUNT: 90 diff --git a/configs/constant_presets/minimal.yaml b/configs/constant_presets/minimal.yaml index 5f4087d89..d631300e2 100644 --- a/configs/constant_presets/minimal.yaml +++ b/configs/constant_presets/minimal.yaml @@ -14,8 +14,6 @@ MAX_INDICES_PER_ATTESTATION: 4096 MIN_PER_EPOCH_CHURN_LIMIT: 4 # 2**16 (= 65,536) CHURN_LIMIT_QUOTIENT: 65536 -# Normalizes base rewards -BASE_REWARDS_PER_EPOCH: 5 # [customized] Faster, but unsecure. SHUFFLE_ROUND_COUNT: 10 diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 6f6b6e74e..4a8e316ea 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -159,6 +159,7 @@ The following values are (non-configurable) constants used throughout the specif | - | - | | `FAR_FUTURE_EPOCH` | `2**64 - 1` | | `ZERO_HASH` | `b'\x00' * 32` | +| `BASE_REWARDS_PER_EPOCH` | `5` | | `DEPOSIT_CONTRACT_TREE_DEPTH` | `2**5` (= 32) | ## Configuration @@ -176,7 +177,6 @@ These configurations are updated for releases, but may be out of sync during `de | `MAX_INDICES_PER_ATTESTATION` | `2**12` (= 4,096) | | `MIN_PER_EPOCH_CHURN_LIMIT` | `2**2` (= 4) | | `CHURN_LIMIT_QUOTIENT` | `2**16` (= 65,536) | -| `BASE_REWARDS_PER_EPOCH` | `5` | | `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.)