From a28c02794319d3b7cf6a1c96f541f53b647b151b Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Wed, 6 Nov 2019 17:26:06 -0700 Subject: [PATCH] be explicit about use of genesis epoch for previous epoch in fork choice on_block --- specs/core/0_fork-choice.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/specs/core/0_fork-choice.md b/specs/core/0_fork-choice.md index 34948fbce..68e681fc7 100644 --- a/specs/core/0_fork-choice.md +++ b/specs/core/0_fork-choice.md @@ -233,9 +233,11 @@ def on_block(store: Store, block: BeaconBlock) -> None: def on_attestation(store: Store, attestation: Attestation) -> None: target = attestation.data.target - # Attestations must be from the current or previous epoch + # Attestations must be from the current or previous epoch current_epoch = compute_epoch_at_slot(get_current_slot(store)) - assert target.epoch in [current_epoch, current_epoch - 1 if current_epoch > GENESIS_EPOCH else GENESIS_EPOCH] + # Use GENESIS_EPOCH for previous when genesis to avoid underflow + previous_epoch = current_epoch - 1 if current_epoch > GENESIS_EPOCH else GENESIS_EPOCH + assert target.epoch in [current_epoch, previous_epoch] # Cannot calculate the current shuffling if have not seen the target assert target.root in store.blocks