mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-26 05:05:23 +00:00
fix spurious assertion per https://github.com/ethereum/eth2.0-specs/issues/515
This commit is contained in:
parent
5d0e1c026d
commit
8dadbd3257
@ -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:
|
||||
|
@ -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 =
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user