From 58481c7119ff3e74932cfe9d3e5bde26919af18b Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 20 May 2019 15:04:55 +1000 Subject: [PATCH] spec v0.6.1: verify proposer slashing --- .../src/per_block_processing/errors.rs | 6 ++---- .../per_block_processing/verify_proposer_slashing.rs | 12 +++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/eth2/state_processing/src/per_block_processing/errors.rs b/eth2/state_processing/src/per_block_processing/errors.rs index 902d525027..a922b01518 100644 --- a/eth2/state_processing/src/per_block_processing/errors.rs +++ b/eth2/state_processing/src/per_block_processing/errors.rs @@ -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. diff --git a/eth2/state_processing/src/per_block_processing/verify_proposer_slashing.rs b/eth2/state_processing/src/per_block_processing/verify_proposer_slashing.rs index 0c66a9b15a..98a9a248cc 100644 --- a/eth2/state_processing/src/per_block_processing/verify_proposer_slashing.rs +++ b/eth2/state_processing/src/per_block_processing/verify_proposer_slashing.rs @@ -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( proposer_slashing: &ProposerSlashing, state: &BeaconState, @@ -34,11 +34,9 @@ pub fn verify_proposer_slashing( 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( /// /// 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)