This commit is contained in:
Dustin Brody 2019-01-28 20:49:20 -08:00
parent 5d0e1c026d
commit 8dadbd3257
3 changed files with 4 additions and 4 deletions

View File

@ -89,7 +89,7 @@ proc sync*(node: BeaconNode): Future[bool] {.async.} =
node.beaconState = await obtainTrustedStateSnapshot(node.db)
else:
node.beaconState = persistedState[]
var targetSlot = (toSlot timeSinceGenesis(node.beaconState))
var targetSlot = toSlot timeSinceGenesis(node.beaconState)
let t = now()
if t < node.beaconState.genesisTime * 1000:

View File

@ -208,7 +208,7 @@ func get_randao_mix*(state: BeaconState,
func get_active_index_root(state: BeaconState, epoch: EpochNumber): Eth2Digest =
# Returns the index root at a recent ``epoch``.
assert get_current_epoch(state) - LATEST_INDEX_ROOTS_LENGTH < epoch
assert epoch <= get_current_epoch(state)
assert epoch <= get_current_epoch(state) + 1
state.latest_index_roots[epoch mod LATEST_INDEX_ROOTS_LENGTH]
func generate_seed*(state: BeaconState, epoch: EpochNumber): Eth2Digest =

View File

@ -730,15 +730,15 @@ func processEpoch(state: var BeaconState) =
state.latest_crosslinks[(state.current_epoch_start_shard + it.uint64) mod SHARD_COUNT].epoch > state.validator_registry_update_epoch):
update_validator_registry(state)
state.current_calculation_epoch = next_epoch
state.current_epoch_start_shard = (state.current_epoch_start_shard + get_current_epoch_committee_count(state) * EPOCH_LENGTH) mod SHARD_COUNT
state.current_epoch_seed = generate_seed(state, state.current_calculation_epoch)
state.current_calculation_epoch = next_epoch
else:
# If a validator registry change does NOT happen
let epochs_since_last_registry_change = current_epoch - state.validator_registry_update_epoch
if is_power_of_2(epochs_since_last_registry_change):
state.current_epoch_seed = generate_seed(state, state.current_calculation_epoch)
state.current_calculation_epoch = next_epoch
state.current_epoch_seed = generate_seed(state, state.current_calculation_epoch)
# /Note/ that state.current_epoch_start_shard is left unchanged
# TODO run process_penalties_and_exits