Fix bug with fork choice, tidy

This commit is contained in:
Paul Hauner
2019-08-09 11:54:35 +10:00
parent 284166c7f8
commit 76bb671084
6 changed files with 70 additions and 49 deletions

View File

@@ -136,6 +136,9 @@ pub enum AttestationInvalid {
delay: u64,
attestation: Slot,
},
/// The attestation is attesting to a state that is later than itself. (Viz., attesting to the
/// future).
AttestsToFutureState { state: Slot, attestation: Slot },
/// Attestation slot is too far in the past to be included in a block.
IncludedTooLate { state: Slot, attestation: Slot },
/// Attestation target epoch does not match the current or previous epoch.

View File

@@ -62,6 +62,17 @@ pub fn verify_attestation_for_state<T: EthSpec>(
Invalid::BadShard
);
let attestation_slot = state.get_attestation_data_slot(&data)?;
// An attestation cannot attest to a state that is later than itself.
verify!(
attestation_slot <= state.slot,
Invalid::AttestsToFutureState {
state: state.slot,
attestation: attestation_slot
}
);
// Verify the Casper FFG vote and crosslink data.
let parent_crosslink = verify_casper_ffg_vote(attestation, state)?;