Crash before making attestation when replaying state pass genesis
This commit is contained in:
parent
d1f75cdfef
commit
e189c1d3cd
|
@ -281,6 +281,12 @@ proc makeAttestation(node: BeaconNode,
|
||||||
shard: uint64,
|
shard: uint64,
|
||||||
committeeLen: int,
|
committeeLen: int,
|
||||||
indexInCommittee: int) {.async.} =
|
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
|
let
|
||||||
attestationData =
|
attestationData =
|
||||||
makeAttestationData(node.state.data, shard, node.state.blck.root)
|
makeAttestationData(node.state.data, shard, node.state.blck.root)
|
||||||
|
|
|
@ -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
|
# 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 =
|
func get_previous_epoch*(state: BeaconState): Epoch =
|
||||||
## Return the previous epoch of the given ``state``.
|
## 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
|
# 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,
|
func get_crosslink_committees_at_slot*(state: BeaconState, slot: Slot|uint64,
|
||||||
|
|
Loading…
Reference in New Issue