2019-05-27 12:48:13 +00:00
|
|
|
# beacon_chain
|
|
|
|
# Copyright (c) 2018-2019 Status Research & Development GmbH
|
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# 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
|
|
|
|
# Standard library
|
|
|
|
math,
|
|
|
|
# Third-party
|
|
|
|
eth/common,
|
|
|
|
# Internals
|
|
|
|
../crypto, ../digest
|
|
|
|
|
|
|
|
type
|
|
|
|
Slot* = distinct uint64
|
|
|
|
Epoch* = distinct uint64
|
|
|
|
|
|
|
|
{.experimental: "codeReordering".} # SLOTS_PER_EPOCH is use before being defined in spec
|
|
|
|
|
2019-06-05 10:25:30 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/configs/constant_presets/minimal.yaml
|
2019-05-27 12:48:13 +00:00
|
|
|
const
|
|
|
|
# Misc
|
|
|
|
# ---------------------------------------------------------------
|
2019-06-12 07:48:49 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_beacon-chain.md#misc
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Changed
|
|
|
|
SHARD_COUNT* {.intdefine.} = 8
|
|
|
|
TARGET_COMMITTEE_SIZE* = 4
|
|
|
|
|
|
|
|
# Unchanged
|
|
|
|
MAX_INDICES_PER_ATTESTATION* = 4096
|
|
|
|
MIN_PER_EPOCH_CHURN_LIMIT* = 4
|
|
|
|
CHURN_LIMIT_QUOTIENT* = 2^16
|
|
|
|
BASE_REWARDS_PER_EPOCH* = 5
|
|
|
|
|
|
|
|
# Changed
|
|
|
|
SHUFFLE_ROUND_COUNT* = 10
|
|
|
|
|
|
|
|
# Deposit contract
|
|
|
|
# ---------------------------------------------------------------
|
2019-06-05 10:25:30 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_beacon-chain.md#deposit-contract
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Unchanged
|
|
|
|
DEPOSIT_CONTRACT_ADDRESS = "0x1234567890123456789012345678901234567890"
|
|
|
|
DEPOSIT_CONTRACT_TREE_DEPTH* = 32
|
|
|
|
|
|
|
|
# Gwei values
|
|
|
|
# ---------------------------------------------------------------
|
2019-06-05 10:25:30 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_beacon-chain.md#gwei-values
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Unchanged
|
|
|
|
MIN_DEPOSIT_AMOUNT* = 2'u64^0 * 10'u64^9
|
|
|
|
MAX_EFFECTIVE_BALANCE* = 2'u64^5 * 10'u64^9
|
|
|
|
EJECTION_BALANCE* = 2'u64^4 * 10'u64^9
|
|
|
|
EFFECTIVE_BALANCE_INCREMENT* = 2'u64^0 * 10'u64^9
|
|
|
|
|
|
|
|
# Initial values
|
|
|
|
# ---------------------------------------------------------------
|
2019-06-12 07:48:49 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/configs/constant_presets/minimal.yaml#L43
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Unchanged
|
|
|
|
GENESIS_FORK_VERSION* = [0'u8, 0'u8, 0'u8, 0'u8]
|
2019-06-12 07:48:49 +00:00
|
|
|
GENESIS_SLOT* = 0.Slot
|
2019-05-27 12:48:13 +00:00
|
|
|
FAR_FUTURE_EPOCH* = (not 0'u64).Epoch # 2^64 - 1 in spec
|
|
|
|
BLS_WITHDRAWAL_PREFIX_BYTE* = 0'u8
|
|
|
|
|
|
|
|
# Time parameters
|
|
|
|
# ---------------------------------------------------------------
|
2019-06-05 10:25:30 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_fork-choice.md#time-parameters
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Unchanged
|
|
|
|
SECONDS_PER_SLOT*{.intdefine.} = 6'u64
|
0.6.2 updates (#275)
* update process_justification_and_finalization to 0.6.2; mark AttesterSlashing as 0.6.2
* replace get_effective_balance(...) with state.validator_registry[idx].effective_balance; rm get_effective_balance, process_ejections, should_update_validator_registry, update_validator_registry, and update_registry_and_shuffling_data; update get_total_balance to 0.6.2; implement process_registry_updates
* rm exit_validator; implement is_slashable_attestation_data; partly update processAttesterSlashings
* mark HistoricalBatch and Eth1Data as 0.6.2; implement get_shard_delta(...); replace 0.5 finish_epoch_update with 0.6 process_final_updates
* mark increase_balance, decrease_balance, get_delayed_activation_exit_epoch, bls_aggregate_pubkeys, bls_verify_multiple, Attestation, Transfer, slot_to_epoch, Crosslink, get_current_epoch, int_to_bytes*, various constants, processEth1Data, processTransfers, and verifyStateRoot as 0.6.2; rm is_double_vote and is_surround_vote
* mark get_bitfield_bit, verify_bitfield, ProposerSlashing, DepositData, VoluntaryExit, PendingAttestation, Fork, integer_squareroot, get_epoch_start_slot, is_active_validator, generate_seed, some constants to 0.6.2; rename MIN_PENALTY_QUOTIENT to MIN_SLASHING_PENALTY_QUOTIENT
* rm get_previous_total_balance, get_current_epoch_boundary_attestations, get_previous_epoch_boundary_attestations, and get_previous_epoch_matching_head_attestations
* update BeaconState to 0.6.2; simplify legacy get_crosslink_committees_at_slot infrastructure a bit by noting that registry_change is always false; reimplment 0.5 get_crosslink_committees_at_slot in terms of 0.6 get_crosslink_committee
* mark process_deposit(...), get_block_root_at_slot(...), get_block_root(...), Deposit, BeaconBlockHeader, BeaconBlockBody, hash(...), get_active_index_root(...), various constants, get_shard_delta(...), get_epoch_start_shard(...), get_crosslink_committee(...), processRandao(...), processVoluntaryExits(...), cacheState(...) as 0.6.2
* rm removed-since-0.5 split(...), is_power_of_2(...), get_shuffling(...); rm 0.5 versions of get_active_validator_indices and get_epoch_committee_count; add a few tests for integer_squareroot
* mark bytes_to_int(...) and advanceState(...) as 0.6.2
* rm 0.5 get_attesting_indices; update get_attesting_balance to 0.6.2
* another tiny commit to poke AppVeyor to maybe not timeout at connecting to GitHub partway through CI: mark get_churn_limit(...), initiate_validator_exit(...), and Validator as 0.6.2
* mark get_attestation_slot(...), AttestationDataAndCustodyBit, and BeaconBlock as 0.6.2
2019-06-03 10:31:04 +00:00
|
|
|
|
2019-06-05 10:25:30 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_beacon-chain.md#time-parameters
|
0.6.2 updates (#275)
* update process_justification_and_finalization to 0.6.2; mark AttesterSlashing as 0.6.2
* replace get_effective_balance(...) with state.validator_registry[idx].effective_balance; rm get_effective_balance, process_ejections, should_update_validator_registry, update_validator_registry, and update_registry_and_shuffling_data; update get_total_balance to 0.6.2; implement process_registry_updates
* rm exit_validator; implement is_slashable_attestation_data; partly update processAttesterSlashings
* mark HistoricalBatch and Eth1Data as 0.6.2; implement get_shard_delta(...); replace 0.5 finish_epoch_update with 0.6 process_final_updates
* mark increase_balance, decrease_balance, get_delayed_activation_exit_epoch, bls_aggregate_pubkeys, bls_verify_multiple, Attestation, Transfer, slot_to_epoch, Crosslink, get_current_epoch, int_to_bytes*, various constants, processEth1Data, processTransfers, and verifyStateRoot as 0.6.2; rm is_double_vote and is_surround_vote
* mark get_bitfield_bit, verify_bitfield, ProposerSlashing, DepositData, VoluntaryExit, PendingAttestation, Fork, integer_squareroot, get_epoch_start_slot, is_active_validator, generate_seed, some constants to 0.6.2; rename MIN_PENALTY_QUOTIENT to MIN_SLASHING_PENALTY_QUOTIENT
* rm get_previous_total_balance, get_current_epoch_boundary_attestations, get_previous_epoch_boundary_attestations, and get_previous_epoch_matching_head_attestations
* update BeaconState to 0.6.2; simplify legacy get_crosslink_committees_at_slot infrastructure a bit by noting that registry_change is always false; reimplment 0.5 get_crosslink_committees_at_slot in terms of 0.6 get_crosslink_committee
* mark process_deposit(...), get_block_root_at_slot(...), get_block_root(...), Deposit, BeaconBlockHeader, BeaconBlockBody, hash(...), get_active_index_root(...), various constants, get_shard_delta(...), get_epoch_start_shard(...), get_crosslink_committee(...), processRandao(...), processVoluntaryExits(...), cacheState(...) as 0.6.2
* rm removed-since-0.5 split(...), is_power_of_2(...), get_shuffling(...); rm 0.5 versions of get_active_validator_indices and get_epoch_committee_count; add a few tests for integer_squareroot
* mark bytes_to_int(...) and advanceState(...) as 0.6.2
* rm 0.5 get_attesting_indices; update get_attesting_balance to 0.6.2
* another tiny commit to poke AppVeyor to maybe not timeout at connecting to GitHub partway through CI: mark get_churn_limit(...), initiate_validator_exit(...), and Validator as 0.6.2
* mark get_attestation_slot(...), AttestationDataAndCustodyBit, and BeaconBlock as 0.6.2
2019-06-03 10:31:04 +00:00
|
|
|
# Unchanged
|
2019-05-27 12:48:13 +00:00
|
|
|
MIN_ATTESTATION_INCLUSION_DELAY* = 2'u64^2
|
|
|
|
|
|
|
|
# Changed
|
|
|
|
SLOTS_PER_EPOCH* {.intdefine.} = 64
|
|
|
|
|
|
|
|
# Unchanged
|
|
|
|
MIN_SEED_LOOKAHEAD* = 1
|
|
|
|
ACTIVATION_EXIT_DELAY* = 4
|
|
|
|
|
|
|
|
# Changed
|
|
|
|
SLOTS_PER_ETH1_VOTING_PERIOD* = 16
|
2019-06-12 07:48:49 +00:00
|
|
|
SLOTS_PER_HISTORICAL_ROOT* = 128 # 64 doesn't work with GENESIS_SLOT == 0?
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Unchanged
|
|
|
|
MIN_VALIDATOR_WITHDRAWABILITY_DELAY* = 2'u64^8
|
|
|
|
PERSISTENT_COMMITTEE_PERIOD* = 2'u64^11
|
|
|
|
MAX_CROSSLINK_EPOCHS* = 2'u64^6
|
|
|
|
MIN_EPOCHS_TO_INACTIVITY_PENALTY* = 2'u64^2
|
|
|
|
|
|
|
|
# State list lengths
|
|
|
|
# ---------------------------------------------------------------
|
2019-06-05 10:25:30 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_beacon-chain.md#state-list-lengths
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Changed
|
|
|
|
LATEST_RANDAO_MIXES_LENGTH* = 64
|
|
|
|
LATEST_ACTIVE_INDEX_ROOTS_LENGTH* = 64
|
|
|
|
LATEST_SLASHED_EXIT_LENGTH* = 64
|
|
|
|
|
|
|
|
# Reward and penalty quotients
|
|
|
|
# ---------------------------------------------------------------
|
2019-06-05 10:25:30 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_beacon-chain.md#reward-and-penalty-quotients
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Unchanged
|
|
|
|
BASE_REWARD_QUOTIENT* = 2'u64^5
|
More 0.6.1 updates (#274)
* implement get_churn_limit from 0.6.1; update initiate_validator_exit and get_previous_epoch to 0.6.1; remove obsoleted/non-spec reduce_balance, replaced by decrease_balance; mark BeaconBlock as 0.6.1
* rename get_block_root to get_block_root_at_slot and introduce epoch-oriented get_block_root; implement get_attestation_slot, get_matching_source_attestations, get_matching_target_attestations, get_matching_head_attestations, 0.6.1 get_attesting_indices, get_unslashed_attesting_indices, get_attestation_deltas, process_rewards_and_penalties; rm get_inactivity_penalty
* update Validator and processVoluntaryExits to 0.6.1; rm obsolete inclusion_slots/inclusion_distances
* rm removed activate_validator; mark DepositData, misc values, Gwei values, Randao processing, state caching as 0.6.1; update GENESIS_SLOT to 64, since it doesn't quite yet work at 0
* mark BeaconBlockHeader as 0.6.1; update BeaconBlockBody to 0.6.1; rename WHISTLEBLOWER_REWARD_QUOTIENT to WHISTLEBLOWING_REWARD_QUOTIENT; update slash_validator to 0.6.1
* implement 0.6.2 is_slashable_validator; update processProposerSlashings to 0.6.2; mark state caching as 0.6.2
* mark get_total_active_balance and process_slashings as 0.6.2; update get_base_reward to 0.6.2
* rm prepare_validator_for_withdrawal, process_exit_queue; mark mainnet misc constants as 0.6.2; update process block header to 0.6.2
* address mratsim's code review comment
2019-05-29 10:08:56 +00:00
|
|
|
WHISTLEBLOWING_REWARD_QUOTIENT* = 2'u64^9
|
2019-05-27 12:48:13 +00:00
|
|
|
PROPOSER_REWARD_QUOTIENT* = 2'u64^3
|
|
|
|
INACTIVITY_PENALTY_QUOTIENT* = 2'u64^25
|
0.6.2 updates (#275)
* update process_justification_and_finalization to 0.6.2; mark AttesterSlashing as 0.6.2
* replace get_effective_balance(...) with state.validator_registry[idx].effective_balance; rm get_effective_balance, process_ejections, should_update_validator_registry, update_validator_registry, and update_registry_and_shuffling_data; update get_total_balance to 0.6.2; implement process_registry_updates
* rm exit_validator; implement is_slashable_attestation_data; partly update processAttesterSlashings
* mark HistoricalBatch and Eth1Data as 0.6.2; implement get_shard_delta(...); replace 0.5 finish_epoch_update with 0.6 process_final_updates
* mark increase_balance, decrease_balance, get_delayed_activation_exit_epoch, bls_aggregate_pubkeys, bls_verify_multiple, Attestation, Transfer, slot_to_epoch, Crosslink, get_current_epoch, int_to_bytes*, various constants, processEth1Data, processTransfers, and verifyStateRoot as 0.6.2; rm is_double_vote and is_surround_vote
* mark get_bitfield_bit, verify_bitfield, ProposerSlashing, DepositData, VoluntaryExit, PendingAttestation, Fork, integer_squareroot, get_epoch_start_slot, is_active_validator, generate_seed, some constants to 0.6.2; rename MIN_PENALTY_QUOTIENT to MIN_SLASHING_PENALTY_QUOTIENT
* rm get_previous_total_balance, get_current_epoch_boundary_attestations, get_previous_epoch_boundary_attestations, and get_previous_epoch_matching_head_attestations
* update BeaconState to 0.6.2; simplify legacy get_crosslink_committees_at_slot infrastructure a bit by noting that registry_change is always false; reimplment 0.5 get_crosslink_committees_at_slot in terms of 0.6 get_crosslink_committee
* mark process_deposit(...), get_block_root_at_slot(...), get_block_root(...), Deposit, BeaconBlockHeader, BeaconBlockBody, hash(...), get_active_index_root(...), various constants, get_shard_delta(...), get_epoch_start_shard(...), get_crosslink_committee(...), processRandao(...), processVoluntaryExits(...), cacheState(...) as 0.6.2
* rm removed-since-0.5 split(...), is_power_of_2(...), get_shuffling(...); rm 0.5 versions of get_active_validator_indices and get_epoch_committee_count; add a few tests for integer_squareroot
* mark bytes_to_int(...) and advanceState(...) as 0.6.2
* rm 0.5 get_attesting_indices; update get_attesting_balance to 0.6.2
* another tiny commit to poke AppVeyor to maybe not timeout at connecting to GitHub partway through CI: mark get_churn_limit(...), initiate_validator_exit(...), and Validator as 0.6.2
* mark get_attestation_slot(...), AttestationDataAndCustodyBit, and BeaconBlock as 0.6.2
2019-06-03 10:31:04 +00:00
|
|
|
MIN_SLASHING_PENALTY_QUOTIENT* = 32 # 2^5
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Max operations per block
|
|
|
|
# ---------------------------------------------------------------
|
2019-06-05 10:25:30 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_beacon-chain.md#max-operations-per-block
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
# Unchanged
|
|
|
|
MAX_PROPOSER_SLASHINGS* = 2^4
|
|
|
|
MAX_ATTESTER_SLASHINGS* = 2^0
|
|
|
|
MAX_ATTESTATIONS* = 2^7
|
|
|
|
MAX_DEPOSITS* = 2^4
|
|
|
|
MAX_VOLUNTARY_EXITS* = 2^4
|
|
|
|
MAX_TRANSFERS* = 0
|
|
|
|
|
|
|
|
type
|
|
|
|
# Signature domains
|
|
|
|
# ---------------------------------------------------------------
|
2019-06-05 10:25:30 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_beacon-chain.md#signature-domains
|
2019-05-27 12:48:13 +00:00
|
|
|
SignatureDomain* {.pure.} = enum
|
|
|
|
DOMAIN_BEACON_PROPOSER = 0
|
|
|
|
DOMAIN_RANDAO = 1
|
|
|
|
DOMAIN_ATTESTATION = 2
|
|
|
|
DOMAIN_DEPOSIT = 3
|
|
|
|
DOMAIN_VOLUNTARY_EXIT = 4
|
|
|
|
DOMAIN_TRANSFER = 5
|