From dc98ffb09bf17345732fd8947e8d42c17affda96 Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Mon, 1 Jul 2019 10:23:50 +0200 Subject: [PATCH] update Validator to 0.8.0; update/refactor deposit contract/etc to constants category; mark process_rewards_and_penalties(...) as 0.8.0 --- beacon_chain/spec/datatypes.nim | 31 +++++++++----------- beacon_chain/spec/presets/mainnet.nim | 13 +++----- beacon_chain/spec/presets/minimal.nim | 6 ++-- beacon_chain/spec/state_transition_epoch.nim | 4 +-- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/beacon_chain/spec/datatypes.nim b/beacon_chain/spec/datatypes.nim index b9f0d5bb7..fcd043d43 100644 --- a/beacon_chain/spec/datatypes.nim +++ b/beacon_chain/spec/datatypes.nim @@ -280,31 +280,28 @@ type eth1_data_votes*: seq[Eth1Data] deposit_index*: uint64 - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#validator + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#validator Validator* = object - pubkey*: ValidatorPubKey ##\ - ## BLS public key + pubkey*: ValidatorPubKey withdrawal_credentials*: Eth2Digest ##\ - ## Withdrawal credentials + ## Commitment to pubkey for withdrawals and transfers - activation_eligibility_epoch*: Epoch ##\ - ## Epoch when validator activated - - activation_epoch*: Epoch ##\ - ## Epoch when validator activated - - exit_epoch*: Epoch ##\ - ## Epoch when validator exited - - withdrawable_epoch*: Epoch ##\ - ## Epoch when validator is eligible to withdraw + effective_balance*: uint64 ##\ + ## Balance at stake slashed*: bool ##\ ## Was the validator slashed - effective_balance*: uint64 ##\ - ## Effective balance + # Status epochs + activation_eligibility_epoch*: Epoch ##\ + ## When criteria for activation were met + + activation_epoch*: Epoch + exit_epoch*: Epoch + + withdrawable_epoch*: Epoch ##\ + ## When validator can withdraw or transfer funds # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#crosslink Crosslink* = object diff --git a/beacon_chain/spec/presets/mainnet.nim b/beacon_chain/spec/presets/mainnet.nim index a1b67fed2..cba3f0733 100644 --- a/beacon_chain/spec/presets/mainnet.nim +++ b/beacon_chain/spec/presets/mainnet.nim @@ -26,7 +26,7 @@ type const # Misc # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#misc + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#misc SHARD_COUNT* {.intdefine.} = 1024 ##\ ## Number of shards supported by the network - validators will jump around @@ -51,16 +51,11 @@ const CHURN_LIMIT_QUOTIENT* = 2^16 - BASE_REWARDS_PER_EPOCH* = 5 - SHUFFLE_ROUND_COUNT* = 90 - # Deposit contract - # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/configs/constant_presets/mainnet.yaml#L24 - - DEPOSIT_CONTRACT_ADDRESS = "0x1234567890123456789012345678901234567890" - # TODO + # Constants (TODO: not actually configurable) + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#constants + BASE_REWARDS_PER_EPOCH* = 5 DEPOSIT_CONTRACT_TREE_DEPTH* = 32 diff --git a/beacon_chain/spec/presets/minimal.nim b/beacon_chain/spec/presets/minimal.nim index dd8e0f354..4364d9773 100644 --- a/beacon_chain/spec/presets/minimal.nim +++ b/beacon_chain/spec/presets/minimal.nim @@ -41,10 +41,10 @@ const # Changed SHUFFLE_ROUND_COUNT* = 10 - # Deposit contract + # Constants # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#deposit-contract - + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#constants + # TODO "The following values are (non-configurable) constants" ... # Unchanged DEPOSIT_CONTRACT_TREE_DEPTH* = 32 diff --git a/beacon_chain/spec/state_transition_epoch.nim b/beacon_chain/spec/state_transition_epoch.nim index 692a209ec..cc3de5d44 100644 --- a/beacon_chain/spec/state_transition_epoch.nim +++ b/beacon_chain/spec/state_transition_epoch.nim @@ -346,7 +346,7 @@ func get_crosslink_deltas(state: BeaconState, cache: var StateCache): (rewards, penalties) -# https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#rewards-and-penalties-1 +# https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#rewards-and-penalties-1 func process_rewards_and_penalties( state: var BeaconState, cache: var StateCache) = if get_current_epoch(state) == GENESIS_EPOCH: @@ -447,7 +447,7 @@ func processEpoch*(state: var BeaconState) = # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#rewards-and-penalties-1 process_rewards_and_penalties(state, per_epoch_cache) - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#registry-updates + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#registry-updates # Don't rely on caching here. process_registry_updates(state)