spec: check ProposalSlashing epochs, not slots

As per v0.5.{0,1} of the spec, we only need to check that the epochs of two proposal slashings are
equal, not their slots.
This commit is contained in:
Michael Sproul 2019-04-02 10:22:19 +11:00
parent 10a5d2657c
commit 8da8730dca
No known key found for this signature in database
GPG Key ID: 77B1309D2E54E914
2 changed files with 5 additions and 4 deletions

View File

@ -271,10 +271,10 @@ pub enum ProposerSlashingValidationError {
pub enum ProposerSlashingInvalid {
/// The proposer index is not a known validator.
ProposerUnknown(u64),
/// The two proposal have different slots.
/// The two proposal have different epochs.
///
/// (proposal_1_slot, proposal_2_slot)
ProposalSlotMismatch(Slot, Slot),
ProposalEpochMismatch(Slot, Slot),
/// The proposals are identical and therefore not slashable.
ProposalsIdentical,
/// The specified proposer has already been slashed.

View File

@ -21,8 +21,9 @@ pub fn verify_proposer_slashing(
})?;
verify!(
proposer_slashing.header_1.slot == proposer_slashing.header_2.slot,
Invalid::ProposalSlotMismatch(
proposer_slashing.header_1.slot.epoch(spec.slots_per_epoch)
== proposer_slashing.header_2.slot.epoch(spec.slots_per_epoch),
Invalid::ProposalEpochMismatch(
proposer_slashing.header_1.slot,
proposer_slashing.header_2.slot
)