2019-05-27 12:48:13 +00:00
|
|
|
# beacon_chain
|
2020-01-27 11:36:17 +00:00
|
|
|
# Copyright (c) 2018-2020 Status Research & Development GmbH
|
2019-05-27 12:48:13 +00:00
|
|
|
# Licensed and distributed under either of
|
2019-11-25 15:30:02 +00:00
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
2019-05-27 12:48:13 +00:00
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
|
|
|
# This file contains constants that are part of the spec and thus subject to
|
|
|
|
# serialization and spec updates.
|
|
|
|
|
|
|
|
import
|
2019-10-25 10:59:56 +00:00
|
|
|
math
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
{.experimental: "codeReordering".} # SLOTS_PER_EPOCH is use before being defined in spec
|
|
|
|
|
|
|
|
const
|
|
|
|
# Misc
|
|
|
|
# ---------------------------------------------------------------
|
2020-07-30 09:47:57 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/configs/mainnet/phase0.yaml#L6
|
2019-05-27 12:48:13 +00:00
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MAX_COMMITTEES_PER_SLOT* {.intdefine.}: uint64 = 64
|
2019-05-27 12:48:13 +00:00
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
TARGET_COMMITTEE_SIZE*: uint64 = 128 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## Number of validators in the committee attesting to one shard
|
|
|
|
## Per spec:
|
|
|
|
## 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 at least `TARGET_COMMITTEE_SIZE`. (Unbiasable randomness
|
|
|
|
## with a Verifiable Delay Function (VDF) will improve committee robustness
|
|
|
|
## and lower the safe minimum committee size.)
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MAX_VALIDATORS_PER_COMMITTEE*: uint64 = 2048 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## votes
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MIN_PER_EPOCH_CHURN_LIMIT*: uint64 = 4
|
|
|
|
CHURN_LIMIT_QUOTIENT*: uint64 = 2'u64 ^ 16
|
|
|
|
SHUFFLE_ROUND_COUNT*: uint64 = 90
|
2019-05-27 12:48:13 +00:00
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
HYSTERESIS_QUOTIENT*: uint64 = 4
|
|
|
|
HYSTERESIS_DOWNWARD_MULTIPLIER*: uint64 = 1
|
|
|
|
HYSTERESIS_UPWARD_MULTIPLIER*: uint64 = 5
|
2020-03-14 21:54:45 +00:00
|
|
|
|
2019-05-27 12:48:13 +00:00
|
|
|
# Gwei values
|
|
|
|
# ---------------------------------------------------------------
|
2020-07-29 12:47:03 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/configs/mainnet/phase0.yaml#L61
|
2019-05-27 12:48:13 +00:00
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MIN_DEPOSIT_AMOUNT*: uint64 = 2'u64^0 * 10'u64^9 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## Minimum amounth of ETH that can be deposited in one call - deposits can
|
|
|
|
## be used either to top up an existing validator or commit to a new one
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MAX_EFFECTIVE_BALANCE*: uint64 = 2'u64^5 * 10'u64^9 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## Maximum amounth of ETH that can be deposited in one call
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
EJECTION_BALANCE*: uint64 = 2'u64^4 * 10'u64^9 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## Once the balance of a validator drops below this, it will be ejected from
|
|
|
|
## the validator pool
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
EFFECTIVE_BALANCE_INCREMENT*: uint64 = 2'u64^0 * 10'u64^9
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Initial values
|
|
|
|
# ---------------------------------------------------------------
|
2020-07-28 14:55:46 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/configs/mainnet/phase0.yaml#L73
|
2020-07-13 14:44:58 +00:00
|
|
|
BLS_WITHDRAWAL_PREFIX*: byte = 0
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Time parameters
|
|
|
|
# ---------------------------------------------------------------
|
2020-07-30 09:47:57 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/configs/mainnet/phase0.yaml#L80
|
2020-07-13 14:44:58 +00:00
|
|
|
SECONDS_PER_SLOT* {.intdefine.}: uint64 = 12'u64 # Compile with -d:SECONDS_PER_SLOT=1 for 12x faster slots
|
2019-05-27 12:48:13 +00:00
|
|
|
## TODO consistent time unit across projects, similar to C++ chrono?
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MIN_ATTESTATION_INCLUSION_DELAY*: uint64 = 1 ##\
|
initial 0.9.0 spec sync (#509)
* rename compute_epoch_of_slot(...) to compute_epoch_at_slot(...)
* remove some unnecessary imports; remove some crosslink-related code and tests; complete renaming of compute_epoch_of_slot(...) to compute_epoch_at_slot(...)
* rm more transfer-related code and tests; rm more unnecessary strutils imports
* rm remaining unused imports
* remove useless get_empty_per_epoch_cache(...)/compute_start_slot_of_epoch(...) calls
* rename compute_start_slot_of_epoch(...) to compute_start_slot_at_epoch(...)
* rename ACTIVATION_EXIT_DELAY to MAX_SEED_LOOKAHEAD
* update domain types to 0.9.0
* mark AttesterSlashing, IndexedAttestation, AttestationDataAndCustodyBit, DepositData, BeaconBlockHeader, Fork, integer_squareroot(...), and process_voluntary_exit(...) as 0.9.0
* mark increase_balance(...), decrease_balance(...), get_block_root(...), CheckPoint, Deposit, PendingAttestation, HistoricalBatch, is_active_validator(...), and is_slashable_attestation_data(...) as 0.9.0
* mark compute_activation_exit_epoch(...), bls_verify(...), Validator, get_active_validator_indices(...), get_current_epoch(...), get_total_active_balance(...), and get_previous_epoch(...) as 0.9.0
* mark get_block_root_at_slot(...), ProposerSlashing, get_domain(...), VoluntaryExit, mainnet preset Gwei values, minimal preset max operations, process_block_header(...), and is_slashable_validator(...) as 0.9.0
* mark makeWithdrawalCredentials(...), get_validator_churn_limit(...), get_total_balance(...), is_valid_indexed_attestation(...), bls_aggregate_pubkeys(...), initial genesis value/constants, Attestation, get_randao_mix(...), mainnet preset max operations per block constants, minimal preset Gwei values and time parameters, process_eth1_data(...), get_shuffled_seq(...), compute_committee(...), and process_slots(...) as 0.9.0; partially update get_indexed_attestation(...) to 0.9.0 by removing crosslink refs and associated tests
* mark initiate_validator_exit(...), process_registry_updates(...), BeaconBlock, Eth1Data, compute_domain(...), process_randao(...), process_attester_slashing(...), get_base_reward(...), and process_slot(...) as 0.9.0
2019-10-30 19:41:19 +00:00
|
|
|
## (12 seconds)
|
2019-05-27 12:48:13 +00:00
|
|
|
## Number of slots that attestations stay in the attestation
|
|
|
|
## pool before being added to a block.
|
|
|
|
## The attestation delay exists so that there is time for attestations to
|
|
|
|
## propagate before the block is created.
|
|
|
|
## When creating an attestation, the validator will look at the best
|
|
|
|
## information known to at that time, and may not revise it during the same
|
|
|
|
## slot (see `is_double_vote`) - the delay gives the validator a chance to
|
|
|
|
## wait towards the end of the slot and still have time to publish the
|
|
|
|
## attestation.
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
SLOTS_PER_EPOCH* {.intdefine.}: uint64 = 32 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## (~6.4 minutes)
|
|
|
|
## slots that make up an epoch, at the end of which more heavy
|
|
|
|
## processing is done
|
|
|
|
## Compile with -d:SLOTS_PER_EPOCH=4 for shorter epochs
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MIN_SEED_LOOKAHEAD*: uint64 = 1 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## epochs (~6.4 minutes)
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MAX_SEED_LOOKAHEAD*: uint64 = 4 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## epochs (~25.6 minutes)
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
EPOCHS_PER_ETH1_VOTING_PERIOD*: uint64 = 32 ##\
|
2020-03-14 21:54:45 +00:00
|
|
|
## epochs (~3.4 hours)
|
2019-05-27 12:48:13 +00:00
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
SLOTS_PER_HISTORICAL_ROOT*: uint64 = 8192 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## slots (13 hours)
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MIN_VALIDATOR_WITHDRAWABILITY_DELAY*: uint64 = 2'u64^8 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## epochs (~27 hours)
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
SHARD_COMMITTEE_PERIOD*: uint64 = 256 # epochs (~27 hours)
|
2020-07-08 20:36:26 +00:00
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MAX_EPOCHS_PER_CROSSLINK*: uint64 = 2'u64^6 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## epochs (~7 hours)
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
MIN_EPOCHS_TO_INACTIVITY_PENALTY*: uint64 = 2'u64^2 ##\
|
2019-05-27 12:48:13 +00:00
|
|
|
## epochs (25.6 minutes)
|
|
|
|
|
2019-09-05 19:52:34 +00:00
|
|
|
# State vector lengths
|
2019-05-27 12:48:13 +00:00
|
|
|
# ---------------------------------------------------------------
|
2020-07-28 14:55:46 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/configs/mainnet/phase0.yaml#L108
|
2020-04-01 11:41:39 +00:00
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
EPOCHS_PER_HISTORICAL_VECTOR*: uint64 = 65536 ##\
|
2020-04-01 11:41:39 +00:00
|
|
|
## epochs (~0.8 years)
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
EPOCHS_PER_SLASHINGS_VECTOR*: uint64 = 8192 ##\
|
2020-04-01 11:41:39 +00:00
|
|
|
## epochs (~36 days)
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
HISTORICAL_ROOTS_LIMIT*: uint64 = 16777216 ##\
|
2020-04-01 11:41:39 +00:00
|
|
|
## epochs (~26,131 years)
|
|
|
|
|
2020-07-13 14:44:58 +00:00
|
|
|
VALIDATOR_REGISTRY_LIMIT*: uint64 = 1099511627776'u64
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Reward and penalty quotients
|
|
|
|
# ---------------------------------------------------------------
|
2020-07-28 14:55:46 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/configs/mainnet/phase0.yaml#L120
|
2020-07-13 14:44:58 +00:00
|
|
|
BASE_REWARD_FACTOR*: uint64 = 2'u64^6
|
|
|
|
WHISTLEBLOWER_REWARD_QUOTIENT*: uint64 = 2'u64^9
|
|
|
|
PROPOSER_REWARD_QUOTIENT*: uint64 = 2'u64^3
|
|
|
|
INACTIVITY_PENALTY_QUOTIENT*: uint64 = 2'u64^24
|
|
|
|
MIN_SLASHING_PENALTY_QUOTIENT*: uint64 = 32 # 2^5
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Max operations per block
|
|
|
|
# ---------------------------------------------------------------
|
2020-07-30 09:47:57 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/configs/mainnet/phase0.yaml#L134
|
2020-07-13 14:44:58 +00:00
|
|
|
MAX_PROPOSER_SLASHINGS*: uint64 = 2'u64 ^ 4
|
|
|
|
MAX_ATTESTER_SLASHINGS*: uint64 = 2'u64 ^ 1
|
|
|
|
MAX_ATTESTATIONS*: uint64 = 2'u64 ^ 7
|
|
|
|
MAX_DEPOSITS*: uint64 = 2'u64 ^ 4
|
|
|
|
MAX_VOLUNTARY_EXITS*: uint64 = 2'u64 ^ 4
|
2019-05-27 12:48:13 +00:00
|
|
|
|
2019-11-22 19:56:39 +00:00
|
|
|
# Fork choice
|
|
|
|
# ---------------------------------------------------------------
|
2020-07-31 09:59:14 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/configs/mainnet/phase0.yaml#L32
|
2020-07-13 14:44:58 +00:00
|
|
|
SAFE_SLOTS_TO_UPDATE_JUSTIFIED*: uint64 = 8 # 96 seconds
|
2019-11-22 19:56:39 +00:00
|
|
|
|
|
|
|
# Validators
|
|
|
|
# ---------------------------------------------------------------
|
2020-08-06 11:00:31 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/configs/mainnet/phase0.yaml#L38
|
|
|
|
ETH1_FOLLOW_DISTANCE* {.intdefine.}: uint64 = 1024 # blocks ~ 4 hours
|
2020-07-13 14:44:58 +00:00
|
|
|
TARGET_AGGREGATORS_PER_COMMITTEE*: uint64 = 16 # validators
|
|
|
|
RANDOM_SUBNETS_PER_VALIDATOR*: uint64 = 1 # subnet
|
|
|
|
EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION*: uint64 = 256 # epochs ~ 27 hours
|
|
|
|
SECONDS_PER_ETH1_BLOCK* {.intdefine.}: uint64 = 14 # (estimate from Eth1 mainnet)
|
2019-11-22 19:56:39 +00:00
|
|
|
|
2020-07-27 10:59:57 +00:00
|
|
|
# Deposit contract
|
2020-03-14 21:54:45 +00:00
|
|
|
# ---------------------------------------------------------------
|
2020-07-27 10:59:57 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/configs/mainnet/phase0.yaml#L52
|
2020-03-14 21:54:45 +00:00
|
|
|
|
2020-07-27 10:59:57 +00:00
|
|
|
# Ethereum PoW Mainnet
|
2020-08-04 14:55:37 +00:00
|
|
|
# TODO These violate the spec (this is a temporary change to allow `make medalla` to work)
|
|
|
|
DEPOSIT_CHAIN_ID* = 5
|
|
|
|
DEPOSIT_NETWORK_ID* = 5
|