Fix Off By One Attestation Bug (#1619)

This commit is contained in:
terence tsao 2019-02-17 06:45:56 -08:00 committed by GitHub
parent 4ee40706e0
commit 26961d4686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -343,8 +343,8 @@ func isSurroundVote(data1 *pb.AttestationData, data2 *pb.AttestationData) bool {
// For each attestation in block.body.attestations:
// Verify that attestation.data.slot <= state.slot - MIN_ATTESTATION_INCLUSION_DELAY <
// attestation.data.slot + EPOCH_LENGTH.
// Verify that attestation.data.justified_epoch is equal to state.justified_epoch
// if attestation.data.slot >= get_epoch_start_slot(get_current_epoch(state)) else state.previous_justified_epoch.
// Verify that `attestation.data.justified_epoch` is equal to `state.justified_epoch
// if slot_to_epoch(attestation.data.slot + 1) >= get_current_epoch(state) else state.previous_justified_epoch`.
// Verify that attestation.data.justified_block_root is equal to
// get_block_root(state, get_epoch_start_slot(attestation.data.justified_epoch)).
// Verify that either attestation.data.latest_crosslink_root or
@ -400,10 +400,10 @@ func verifyAttestation(beaconState *pb.BeaconState, att *pb.Attestation, verifyS
beaconState.Slot,
)
}
// Verify that attestation.data.justified_epoch is equal to state.justified_epoch
// if attestation.data.slot >= get_epoch_start_slot(get_current_epoch(state))
// else state.previous_justified_epoch.
if att.Data.Slot >= helpers.StartSlot(helpers.SlotToEpoch(beaconState.Slot)) {
// Verify that `attestation.data.justified_epoch` is equal to `state.justified_epoch
// if slot_to_epoch(attestation.data.slot + 1) >= get_current_epoch(state)
// else state.previous_justified_epoch`.
if helpers.SlotToEpoch(att.Data.Slot+1) >= helpers.CurrentEpoch(beaconState) {
if att.Data.JustifiedEpoch != beaconState.JustifiedEpoch {
return fmt.Errorf(
"expected attestation.JustifiedEpoch == state.JustifiedEpoch, received %d == %d",