mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-03 10:13:35 +00:00
63e621c27d
* 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
133 lines
4.1 KiB
Nim
133 lines
4.1 KiB
Nim
# 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
|
|
math
|
|
|
|
type
|
|
Slot* = distinct uint64
|
|
Epoch* = distinct uint64
|
|
|
|
{.experimental: "codeReordering".} # SLOTS_PER_EPOCH is use before being defined in spec
|
|
|
|
const
|
|
# Misc
|
|
# ---------------------------------------------------------------
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.3/configs/minimal.yaml#L4
|
|
|
|
# Changed
|
|
SHARD_COUNT* {.intdefine.} = 8
|
|
TARGET_COMMITTEE_SIZE* = 4
|
|
|
|
# Unchanged
|
|
MAX_VALIDATORS_PER_COMMITTEE* = 4096
|
|
MIN_PER_EPOCH_CHURN_LIMIT* = 4
|
|
CHURN_LIMIT_QUOTIENT* = 2^16
|
|
BASE_REWARDS_PER_EPOCH* = 5
|
|
|
|
# Changed
|
|
SHUFFLE_ROUND_COUNT* = 10
|
|
MIN_GENESIS_ACTIVE_VALIDATOR_COUNT* {.intdefine.} = 99
|
|
MIN_GENESIS_TIME* {.intdefine.} = 0
|
|
|
|
# Constants
|
|
# ---------------------------------------------------------------
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.0/specs/core/0_beacon-chain.md#constants
|
|
# TODO "The following values are (non-configurable) constants" ...
|
|
# Unchanged
|
|
DEPOSIT_CONTRACT_TREE_DEPTH* = 32
|
|
|
|
# Gwei values
|
|
# ---------------------------------------------------------------
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.0/configs/minimal.yaml#L32
|
|
|
|
# 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
|
|
# ---------------------------------------------------------------
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.3/configs/minimal.yaml#L44
|
|
|
|
# Unchanged
|
|
GENESIS_SLOT* = 0.Slot
|
|
BLS_WITHDRAWAL_PREFIX* = 0'u8
|
|
|
|
# Time parameters
|
|
# ---------------------------------------------------------------
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.0/configs/minimal.yaml#L51
|
|
# Unchanged
|
|
SECONDS_PER_SLOT*{.intdefine.} = 6'u64
|
|
|
|
# Unchanged
|
|
MIN_ATTESTATION_INCLUSION_DELAY* = 1
|
|
|
|
# Changed
|
|
SLOTS_PER_EPOCH* {.intdefine.} = 8
|
|
|
|
# Unchanged
|
|
MIN_SEED_LOOKAHEAD* = 1
|
|
MAX_SEED_LOOKAHEAD* = 4
|
|
|
|
# Changed
|
|
SLOTS_PER_ETH1_VOTING_PERIOD* = 16
|
|
SLOTS_PER_HISTORICAL_ROOT* = 64
|
|
|
|
# Unchanged
|
|
MIN_VALIDATOR_WITHDRAWABILITY_DELAY* = 2'u64^8
|
|
PERSISTENT_COMMITTEE_PERIOD* = 2'u64^11
|
|
MAX_EPOCHS_PER_CROSSLINK* = 4
|
|
MIN_EPOCHS_TO_INACTIVITY_PENALTY* = 2'u64^2
|
|
|
|
# State vector lengths
|
|
# ---------------------------------------------------------------
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.3/configs/minimal.yaml#L79
|
|
|
|
# Changed
|
|
EPOCHS_PER_HISTORICAL_VECTOR* = 64
|
|
EPOCHS_PER_SLASHINGS_VECTOR* = 64
|
|
HISTORICAL_ROOTS_LIMIT* = 16777216
|
|
VALIDATOR_REGISTRY_LIMIT* = 1099511627776
|
|
|
|
# Reward and penalty quotients
|
|
# ---------------------------------------------------------------
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.4/specs/core/0_beacon-chain.md#rewards-and-penalties
|
|
|
|
# Unchanged
|
|
BASE_REWARD_FACTOR* = 2'u64^6
|
|
WHISTLEBLOWER_REWARD_QUOTIENT* = 2'u64^9
|
|
PROPOSER_REWARD_QUOTIENT* = 2'u64^3
|
|
INACTIVITY_PENALTY_QUOTIENT* = 2'u64^25
|
|
MIN_SLASHING_PENALTY_QUOTIENT* = 32 # 2^5
|
|
|
|
# Max operations per block
|
|
# ---------------------------------------------------------------
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.0/configs/minimal.yaml#L109
|
|
|
|
MAX_PROPOSER_SLASHINGS* = 2^4
|
|
MAX_ATTESTER_SLASHINGS* = 2^0
|
|
MAX_ATTESTATIONS* = 2^7
|
|
MAX_DEPOSITS* = 2^4
|
|
MAX_VOLUNTARY_EXITS* = 2^4
|
|
|
|
|
|
type
|
|
# Domains
|
|
# ---------------------------------------------------------------
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.0/specs/core/0_beacon-chain.md#domain-types
|
|
DomainType* {.pure.} = enum
|
|
DOMAIN_BEACON_PROPOSER = 0
|
|
DOMAIN_BEACON_ATTESTER = 1
|
|
DOMAIN_RANDAO = 2
|
|
DOMAIN_DEPOSIT = 3
|
|
DOMAIN_VOLUNTARY_EXIT = 4
|