be explicit about use of genesis epoch for previous epoch in fork choice on_block

This commit is contained in:
Danny Ryan 2019-11-06 17:26:06 -07:00
parent e1d2823810
commit a28c027943
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 4 additions and 2 deletions

View File

@ -235,7 +235,9 @@ def on_attestation(store: Store, attestation: Attestation) -> None:
# 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