update check_attestation/process_attestation() to 0.10.1 and fill in missing check

This commit is contained in:
Dustin Brody 2020-01-27 22:04:26 +01:00 committed by zah
parent 257771d9af
commit 60b1775879
1 changed files with 13 additions and 1 deletions

View File

@ -436,7 +436,7 @@ func get_indexed_attestation(state: BeaconState, attestation: Attestation,
signature: attestation.signature
)
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#attestations
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/beacon-chain.md#attestations
proc check_attestation*(
state: BeaconState, attestation: Attestation, flags: UpdateFlags,
stateCache: var StateCache): bool =
@ -453,11 +453,23 @@ proc check_attestation*(
trace "process_attestation: beginning",
attestation=attestation
if not (data.index < get_committee_count_at_slot(state, data.slot)):
warn("Data index exceeds committee count",
data_index = data.index,
committee_count = get_committee_count_at_slot(state, data.slot))
return
if not (data.target.epoch == get_previous_epoch(state) or
data.target.epoch == get_current_epoch(state)):
warn("Target epoch not current or previous epoch")
return
if not (data.target.epoch == compute_epoch_at_slot(data.slot)):
warn("Target epoch inconsistent with epoch of data slot",
target_epoch = data.target.epoch,
data_slot_epoch = compute_epoch_at_slot(data.slot))
return
if not (data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= stateSlot):
warn("Attestation too new",
attestation_slot = shortLog(data.slot),