2019-08-28 12:07:00 +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.
|
|
|
|
|
|
|
|
# Mocking a genesis state
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
|
|
|
import
|
|
|
|
# Specs
|
2019-11-14 10:47:55 +00:00
|
|
|
../../beacon_chain/spec/[datatypes, beaconstate],
|
2019-08-28 12:07:00 +00:00
|
|
|
# Internals
|
2019-09-02 10:31:14 +00:00
|
|
|
../../beacon_chain/[extras, interop],
|
2019-08-28 12:07:00 +00:00
|
|
|
# Mocking procs
|
2019-11-14 10:47:55 +00:00
|
|
|
./mock_deposits
|
2019-08-28 12:07:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
proc initGenesisState*(num_validators: uint64, genesis_time: uint64 = 0): BeaconState =
|
|
|
|
let deposits = mockGenesisBalancedDeposits(
|
|
|
|
validatorCount = num_validators,
|
|
|
|
amountInEth = 32, # We create canonical validators with 32 Eth
|
|
|
|
flags = {skipValidation}
|
|
|
|
)
|
|
|
|
|
2019-09-02 10:31:14 +00:00
|
|
|
initialize_beacon_state_from_eth1(
|
|
|
|
eth1BlockHash, 0, deposits, {skipValidation})
|
2019-08-28 12:07:00 +00:00
|
|
|
|
|
|
|
when isMainModule:
|
|
|
|
# Smoke test
|
|
|
|
let state = initGenesisState(num_validators = SLOTS_PER_EPOCH)
|
|
|
|
doAssert state.validators.len == SLOTS_PER_EPOCH
|