Fix overly restrictive check in fork choice.
This commit is contained in:
parent
76bb671084
commit
d191812d4b
@ -60,7 +60,15 @@ pub enum BlockProcessingOutcome {
|
|||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum AttestationProcessingOutcome {
|
pub enum AttestationProcessingOutcome {
|
||||||
Processed,
|
Processed,
|
||||||
UnknownHeadBlock { beacon_block_root: Hash256 },
|
UnknownHeadBlock {
|
||||||
|
beacon_block_root: Hash256,
|
||||||
|
},
|
||||||
|
/// The attestation is attesting to a state that is later than itself. (Viz., attesting to the
|
||||||
|
/// future).
|
||||||
|
AttestsToFutureState {
|
||||||
|
state: Slot,
|
||||||
|
attestation: Slot,
|
||||||
|
},
|
||||||
Invalid(AttestationValidationError),
|
Invalid(AttestationValidationError),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,11 +590,24 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
per_slot_processing(&mut state, &self.spec)?;
|
per_slot_processing(&mut state, &self.spec)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.process_attestation_for_state_and_block(
|
let attestation_slot = state.get_attestation_data_slot(&attestation.data)?;
|
||||||
attestation,
|
|
||||||
&state,
|
// Reject any attestation where the `state` loaded from `data.beacon_block_root`
|
||||||
&attestation_head_block,
|
// has a higher slot than the attestation.
|
||||||
)
|
//
|
||||||
|
// Permitting this would allow for attesters to vote on _future_ slots.
|
||||||
|
if attestation_slot > state.slot {
|
||||||
|
Ok(AttestationProcessingOutcome::AttestsToFutureState {
|
||||||
|
state: state.slot,
|
||||||
|
attestation: attestation_slot,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
self.process_attestation_for_state_and_block(
|
||||||
|
attestation,
|
||||||
|
&state,
|
||||||
|
&attestation_head_block,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Reject any block where we have not processed `attestation.data.beacon_block_root`.
|
// Reject any block where we have not processed `attestation.data.beacon_block_root`.
|
||||||
|
@ -136,9 +136,6 @@ pub enum AttestationInvalid {
|
|||||||
delay: u64,
|
delay: u64,
|
||||||
attestation: Slot,
|
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.
|
/// Attestation slot is too far in the past to be included in a block.
|
||||||
IncludedTooLate { state: Slot, attestation: Slot },
|
IncludedTooLate { state: Slot, attestation: Slot },
|
||||||
/// Attestation target epoch does not match the current or previous epoch.
|
/// Attestation target epoch does not match the current or previous epoch.
|
||||||
|
@ -62,17 +62,6 @@ pub fn verify_attestation_for_state<T: EthSpec>(
|
|||||||
Invalid::BadShard
|
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.
|
// Verify the Casper FFG vote and crosslink data.
|
||||||
let parent_crosslink = verify_casper_ffg_vote(attestation, state)?;
|
let parent_crosslink = verify_casper_ffg_vote(attestation, state)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user