spec v0.6.1: verify proposer slashing

This commit is contained in:
Michael Sproul 2019-05-20 15:04:55 +10:00
parent 366f0ffd87
commit 58481c7119
No known key found for this signature in database
GPG Key ID: 77B1309D2E54E914
2 changed files with 7 additions and 11 deletions

View File

@ -281,10 +281,8 @@ pub enum ProposerSlashingInvalid {
ProposalEpochMismatch(Slot, Slot),
/// The proposals are identical and therefore not slashable.
ProposalsIdentical,
/// The specified proposer has already been slashed.
ProposerAlreadySlashed,
/// The specified proposer has already been withdrawn.
ProposerAlreadyWithdrawn(u64),
/// The specified proposer cannot be slashed because they are already slashed, or not active.
ProposerNotSlashable(u64),
/// The first proposal signature was invalid.
BadProposal1Signature,
/// The second proposal signature was invalid.

View File

@ -7,7 +7,7 @@ use types::*;
///
/// Returns `Ok(())` if the `ProposerSlashing` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.5.1
/// Spec v0.6.1
pub fn verify_proposer_slashing<T: EthSpec>(
proposer_slashing: &ProposerSlashing,
state: &BeaconState<T>,
@ -34,11 +34,9 @@ pub fn verify_proposer_slashing<T: EthSpec>(
Invalid::ProposalsIdentical
);
verify!(!proposer.slashed, Invalid::ProposerAlreadySlashed);
verify!(
proposer.withdrawable_epoch > state.slot.epoch(spec.slots_per_epoch),
Invalid::ProposerAlreadyWithdrawn(proposer_slashing.proposer_index)
proposer.is_slashable_at(state.current_epoch()),
Invalid::ProposerNotSlashable(proposer_slashing.proposer_index)
);
verify!(
@ -67,7 +65,7 @@ pub fn verify_proposer_slashing<T: EthSpec>(
///
/// Returns `true` if the signature is valid.
///
/// Spec v0.5.1
/// Spec v0.6.1
fn verify_header_signature(
header: &BeaconBlockHeader,
pubkey: &PublicKey,
@ -77,7 +75,7 @@ fn verify_header_signature(
let message = header.signed_root();
let domain = spec.get_domain(
header.slot.epoch(spec.slots_per_epoch),
Domain::BeaconBlock,
Domain::BeaconProposer,
fork,
);
header.signature.verify(&message[..], domain, pubkey)