mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-26 13:15:16 +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)
|
node.beaconState = await obtainTrustedStateSnapshot(node.db)
|
||||||
else:
|
else:
|
||||||
node.beaconState = persistedState[]
|
node.beaconState = persistedState[]
|
||||||
var targetSlot = (toSlot timeSinceGenesis(node.beaconState))
|
var targetSlot = toSlot timeSinceGenesis(node.beaconState)
|
||||||
|
|
||||||
let t = now()
|
let t = now()
|
||||||
if t < node.beaconState.genesisTime * 1000:
|
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 =
|
func get_active_index_root(state: BeaconState, epoch: EpochNumber): Eth2Digest =
|
||||||
# Returns the index root at a recent ``epoch``.
|
# Returns the index root at a recent ``epoch``.
|
||||||
assert get_current_epoch(state) - LATEST_INDEX_ROOTS_LENGTH < 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]
|
state.latest_index_roots[epoch mod LATEST_INDEX_ROOTS_LENGTH]
|
||||||
|
|
||||||
func generate_seed*(state: BeaconState, epoch: EpochNumber): Eth2Digest =
|
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):
|
state.latest_crosslinks[(state.current_epoch_start_shard + it.uint64) mod SHARD_COUNT].epoch > state.validator_registry_update_epoch):
|
||||||
update_validator_registry(state)
|
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_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_epoch_seed = generate_seed(state, state.current_calculation_epoch)
|
||||||
state.current_calculation_epoch = next_epoch
|
|
||||||
else:
|
else:
|
||||||
# If a validator registry change does NOT happen
|
# If a validator registry change does NOT happen
|
||||||
let epochs_since_last_registry_change = current_epoch - state.validator_registry_update_epoch
|
let epochs_since_last_registry_change = current_epoch - state.validator_registry_update_epoch
|
||||||
if is_power_of_2(epochs_since_last_registry_change):
|
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_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
|
# /Note/ that state.current_epoch_start_shard is left unchanged
|
||||||
# TODO run process_penalties_and_exits
|
# TODO run process_penalties_and_exits
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user