Crash before making attestation when replaying state pass genesis

This commit is contained in:
Mamy André-Ratsimbazafy 2019-03-26 11:41:33 +01:00 committed by zah
parent d1f75cdfef
commit e189c1d3cd
2 changed files with 11 additions and 1 deletions

View File

@ -281,6 +281,12 @@ proc makeAttestation(node: BeaconNode,
shard: uint64,
committeeLen: int,
indexInCommittee: int) {.async.} =
# TODO - move that to "updateState"
# Epoch underflow - https://github.com/status-im/nim-beacon-chain/issues/207
doAssert node.state.data.current_justified_epoch != GENESIS_EPOCH - 1,
"Underflow in justified epoch field before making attestation"
let
attestationData =
makeAttestationData(node.state.data, shard, node.state.blck.root)

View File

@ -125,7 +125,11 @@ func get_next_epoch_committee_count(state: BeaconState): uint64 =
# https://github.com/ethereum/eth2.0-specs/blob/v0.5.0/specs/core/0_beacon-chain.md#get_previous_epoch
func get_previous_epoch*(state: BeaconState): Epoch =
## Return the previous epoch of the given ``state``.
get_current_epoch(state) - 1
let epoch = get_current_epoch(state)
if epoch == GENESIS_EPOCH:
raise newException(OverflowError, "Underflow: trying to get the previous epoch of epoch 0 (genesis).")
epoch - 1
# https://github.com/ethereum/eth2.0-specs/blob/v0.5.0/specs/core/0_beacon-chain.md#get_crosslink_committees_at_slot
func get_crosslink_committees_at_slot*(state: BeaconState, slot: Slot|uint64,