From 1cbde6f3c807a092b1e768fb33b1e0065fc69766 Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 5 Oct 2018 11:34:38 +0100 Subject: [PATCH 1/4] Change balances to Gwei See discussion here https://github.com/ethereum/eth2.0-specs/issues/34 --- specs/beacon-chain.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/specs/beacon-chain.md b/specs/beacon-chain.md index 16be55464..ca17e206f 100644 --- a/specs/beacon-chain.md +++ b/specs/beacon-chain.md @@ -219,7 +219,7 @@ A `ValidatorRecord` has the following fields: # RANDAO commitment 'randao_commitment': 'hash32', # Balance - 'balance': 'int128', + 'balance': 'int64', # Status code 'status': 'int8', # Slot when validator exited (or 0) @@ -448,7 +448,7 @@ def add_validator(validators, pubkey, proof_of_possession, withdrawal_shard, withdrawal_shard=withdrawal_shard, withdrawal_address=withdrawal_address, randao_commitment=randao_commitment, - balance=DEPOSIT_SIZE, # in WEI + balance=DEPOSIT_SIZE * 10**9, # in Gwei status=PENDING_LOG_IN, exit_slot=0 ) @@ -585,9 +585,9 @@ def change_validators(validators): active_validators = get_active_validator_indices(validators, dynasty) # The total size of active deposits total_deposits = sum([v.balance for i, v in enumerate(validators) if i in active_validators]) - # The maximum total wei that can deposit+withdraw + # The maximum total Gwei that can be deposited and withdrawn max_allowable_change = max( - DEPOSIT_SIZE * 2, + 2 * DEPOSIT_SIZE * 10**9, total_deposits // MAX_VALIDATOR_CHURN_QUOTIENT ) # Go through the list start to end depositing+withdrawing as many as possible From e3c1eeb569e0f33779f799c8d41d0a7908c636be Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 5 Oct 2018 11:49:18 +0100 Subject: [PATCH 2/4] Update beacon-chain.md --- specs/beacon-chain.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/beacon-chain.md b/specs/beacon-chain.md index ca17e206f..8b427bde5 100644 --- a/specs/beacon-chain.md +++ b/specs/beacon-chain.md @@ -522,8 +522,8 @@ For all (`shard`, `shard_block_hash`) tuples, compute the total deposit size of Let `time_since_finality = block.slot - last_finalized_slot`, and let `B` be the balance of any given validator whose balance we are adjusting, not including any balance changes from this round of state recalculation. Let: -* `total_deposits = sum([v.balance for i, v in enumerate(validators) if i in get_active_validator_indices(validators, dynasty)])` and `total_deposits_in_ETH = total_deposits // 10**18` -* `reward_quotient = BASE_REWARD_QUOTIENT * int_sqrt(total_deposits_in_ETH)` (`1/reward_quotient` is the per-slot max interest rate) +* `total_deposits = sum([v.balance for i, v in enumerate(validators) if i in get_active_validator_indices(validators, dynasty)])` and `total_deposits_in_gwei = total_deposits // 10**9` +* `reward_quotient = BASE_REWARD_QUOTIENT * int_sqrt(total_deposits_in_gwei)` (`1/reward_quotient` is the per-slot max interest rate) * `quadratic_penalty_quotient = SQRT_E_DROP_TIME**2` (after `D` slots about `D*D/2/quadratic_penalty_quotient` is the portion lost by offline validators) For each slot `S` in the range `last_state_recalculation_slot - CYCLE_LENGTH ... last_state_recalculation_slot - 1`: From ef4b2c45425f481ec0f936c0b81f42814fcf91dd Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 5 Oct 2018 12:01:03 +0100 Subject: [PATCH 3/4] Update beacon-chain.md --- specs/beacon-chain.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/beacon-chain.md b/specs/beacon-chain.md index 8b427bde5..c8992f8ae 100644 --- a/specs/beacon-chain.md +++ b/specs/beacon-chain.md @@ -522,8 +522,8 @@ For all (`shard`, `shard_block_hash`) tuples, compute the total deposit size of Let `time_since_finality = block.slot - last_finalized_slot`, and let `B` be the balance of any given validator whose balance we are adjusting, not including any balance changes from this round of state recalculation. Let: -* `total_deposits = sum([v.balance for i, v in enumerate(validators) if i in get_active_validator_indices(validators, dynasty)])` and `total_deposits_in_gwei = total_deposits // 10**9` -* `reward_quotient = BASE_REWARD_QUOTIENT * int_sqrt(total_deposits_in_gwei)` (`1/reward_quotient` is the per-slot max interest rate) +* `total_deposits = sum([v.balance for i, v in enumerate(validators) if i in get_active_validator_indices(validators, dynasty)])` and `total_deposits_in_ETH = total_deposits // 10**9` +* `reward_quotient = BASE_REWARD_QUOTIENT * int_sqrt(total_deposits_in_ETH)` (`1/reward_quotient` is the per-slot max interest rate) * `quadratic_penalty_quotient = SQRT_E_DROP_TIME**2` (after `D` slots about `D*D/2/quadratic_penalty_quotient` is the portion lost by offline validators) For each slot `S` in the range `last_state_recalculation_slot - CYCLE_LENGTH ... last_state_recalculation_slot - 1`: From fedfe61d6ce571a73af67c280e427305e5261109 Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 6 Oct 2018 13:02:08 +0100 Subject: [PATCH 4/4] Update beacon-chain.md --- specs/beacon-chain.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/specs/beacon-chain.md b/specs/beacon-chain.md index c8992f8ae..978e91cbe 100644 --- a/specs/beacon-chain.md +++ b/specs/beacon-chain.md @@ -35,6 +35,7 @@ The primary source of load on the beacon chain are "attestations". Attestations | --- | --- | :---: | - | | `SHARD_COUNT` | 2**10 (= 1,024)| shards | | `DEPOSIT_SIZE` | 2**5 (= 32) | ETH | +| `GWEI_PER_ETH` | 10**9 | Gwei/ETH | | `MIN_COMMITTEE_SIZE` | 2**7 (= 128) | validators | | `GENESIS_TIME` | **TBD** | seconds | | `SLOT_DURATION` | 2**4 (= 16) | seconds | @@ -448,7 +449,7 @@ def add_validator(validators, pubkey, proof_of_possession, withdrawal_shard, withdrawal_shard=withdrawal_shard, withdrawal_address=withdrawal_address, randao_commitment=randao_commitment, - balance=DEPOSIT_SIZE * 10**9, # in Gwei + balance=DEPOSIT_SIZE * GWEI_PER_ETH, # in Gwei status=PENDING_LOG_IN, exit_slot=0 ) @@ -522,7 +523,7 @@ For all (`shard`, `shard_block_hash`) tuples, compute the total deposit size of Let `time_since_finality = block.slot - last_finalized_slot`, and let `B` be the balance of any given validator whose balance we are adjusting, not including any balance changes from this round of state recalculation. Let: -* `total_deposits = sum([v.balance for i, v in enumerate(validators) if i in get_active_validator_indices(validators, dynasty)])` and `total_deposits_in_ETH = total_deposits // 10**9` +* `total_deposits = sum([v.balance for i, v in enumerate(validators) if i in get_active_validator_indices(validators, dynasty)])` and `total_deposits_in_ETH = total_deposits // GWEI_PER_ETH` * `reward_quotient = BASE_REWARD_QUOTIENT * int_sqrt(total_deposits_in_ETH)` (`1/reward_quotient` is the per-slot max interest rate) * `quadratic_penalty_quotient = SQRT_E_DROP_TIME**2` (after `D` slots about `D*D/2/quadratic_penalty_quotient` is the portion lost by offline validators) @@ -587,7 +588,7 @@ def change_validators(validators): total_deposits = sum([v.balance for i, v in enumerate(validators) if i in active_validators]) # The maximum total Gwei that can be deposited and withdrawn max_allowable_change = max( - 2 * DEPOSIT_SIZE * 10**9, + 2 * DEPOSIT_SIZE * GWEI_PER_ETH, total_deposits // MAX_VALIDATOR_CHURN_QUOTIENT ) # Go through the list start to end depositing+withdrawing as many as possible