2019-08-28 12:07:00 +00:00
|
|
|
# beacon_chain
|
2021-06-11 17:51:46 +00:00
|
|
|
# Copyright (c) 2018-2021 Status Research & Development GmbH
|
2019-08-28 12:07:00 +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-08-28 12:07:00 +00:00
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
|
|
|
# Mocking helpers for BeaconState
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
|
|
|
import
|
|
|
|
# Specs
|
2021-08-10 20:46:35 +00:00
|
|
|
../../beacon_chain/spec/[forks, presets, state_transition],
|
2021-06-21 08:35:24 +00:00
|
|
|
../../beacon_chain/spec/datatypes/base
|
2019-08-28 12:07:00 +00:00
|
|
|
|
2021-06-11 17:51:46 +00:00
|
|
|
proc nextEpoch*(state: var ForkedHashedBeaconState) =
|
2019-08-28 12:07:00 +00:00
|
|
|
## Transition to the start of the next epoch
|
2021-05-07 11:36:21 +00:00
|
|
|
var
|
|
|
|
cache = StateCache()
|
2021-10-13 14:24:36 +00:00
|
|
|
info = ForkedEpochInfo()
|
2020-04-30 06:44:19 +00:00
|
|
|
let slot =
|
2021-06-11 17:51:46 +00:00
|
|
|
getStateField(state, slot) + SLOTS_PER_EPOCH -
|
|
|
|
(getStateField(state, slot) mod SLOTS_PER_EPOCH)
|
2021-10-13 14:24:36 +00:00
|
|
|
doAssert process_slots(defaultRuntimeConfig, state, slot, cache, info, {})
|
2019-08-28 12:07:00 +00:00
|
|
|
|
2021-06-11 17:51:46 +00:00
|
|
|
proc nextSlot*(state: var ForkedHashedBeaconState) =
|
2019-08-28 12:07:00 +00:00
|
|
|
## Transition to the next slot
|
2021-05-07 11:36:21 +00:00
|
|
|
var
|
|
|
|
cache = StateCache()
|
2021-10-13 14:24:36 +00:00
|
|
|
info = ForkedEpochInfo()
|
2021-05-07 11:36:21 +00:00
|
|
|
|
2021-06-11 17:51:46 +00:00
|
|
|
doAssert process_slots(
|
2021-10-13 14:24:36 +00:00
|
|
|
defaultRuntimeConfig, state, getStateField(state, slot) + 1, cache, info, {})
|