update Validator to 0.8.0; update/refactor deposit contract/etc to constants category; mark process_rewards_and_penalties(...) as 0.8.0

This commit is contained in:
Dustin Brody 2019-07-01 10:23:50 +02:00 committed by zah
parent 607a7de5eb
commit dc98ffb09b
4 changed files with 23 additions and 31 deletions

View File

@ -280,31 +280,28 @@ type
eth1_data_votes*: seq[Eth1Data] eth1_data_votes*: seq[Eth1Data]
deposit_index*: uint64 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 Validator* = object
pubkey*: ValidatorPubKey ##\ pubkey*: ValidatorPubKey
## BLS public key
withdrawal_credentials*: Eth2Digest ##\ withdrawal_credentials*: Eth2Digest ##\
## Withdrawal credentials ## Commitment to pubkey for withdrawals and transfers
activation_eligibility_epoch*: Epoch ##\ effective_balance*: uint64 ##\
## Epoch when validator activated ## Balance at stake
activation_epoch*: Epoch ##\
## Epoch when validator activated
exit_epoch*: Epoch ##\
## Epoch when validator exited
withdrawable_epoch*: Epoch ##\
## Epoch when validator is eligible to withdraw
slashed*: bool ##\ slashed*: bool ##\
## Was the validator slashed ## Was the validator slashed
effective_balance*: uint64 ##\ # Status epochs
## Effective balance 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 # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#crosslink
Crosslink* = object Crosslink* = object

View File

@ -26,7 +26,7 @@ type
const const
# Misc # 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 ##\ SHARD_COUNT* {.intdefine.} = 1024 ##\
## Number of shards supported by the network - validators will jump around ## Number of shards supported by the network - validators will jump around
@ -51,16 +51,11 @@ const
CHURN_LIMIT_QUOTIENT* = 2^16 CHURN_LIMIT_QUOTIENT* = 2^16
BASE_REWARDS_PER_EPOCH* = 5
SHUFFLE_ROUND_COUNT* = 90 SHUFFLE_ROUND_COUNT* = 90
# Deposit contract # Constants (TODO: not actually configurable)
# --------------------------------------------------------------- # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#constants
# https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/configs/constant_presets/mainnet.yaml#L24 BASE_REWARDS_PER_EPOCH* = 5
DEPOSIT_CONTRACT_ADDRESS = "0x1234567890123456789012345678901234567890"
# TODO
DEPOSIT_CONTRACT_TREE_DEPTH* = 32 DEPOSIT_CONTRACT_TREE_DEPTH* = 32

View File

@ -41,10 +41,10 @@ const
# Changed # Changed
SHUFFLE_ROUND_COUNT* = 10 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 # Unchanged
DEPOSIT_CONTRACT_TREE_DEPTH* = 32 DEPOSIT_CONTRACT_TREE_DEPTH* = 32

View File

@ -346,7 +346,7 @@ func get_crosslink_deltas(state: BeaconState, cache: var StateCache):
(rewards, penalties) (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( func process_rewards_and_penalties(
state: var BeaconState, cache: var StateCache) = state: var BeaconState, cache: var StateCache) =
if get_current_epoch(state) == GENESIS_EPOCH: 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 # 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) 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. # Don't rely on caching here.
process_registry_updates(state) process_registry_updates(state)