spec v0.6.1: verify proposer slashing
This commit is contained in:
parent
366f0ffd87
commit
58481c7119
@ -281,10 +281,8 @@ pub enum ProposerSlashingInvalid {
|
|||||||
ProposalEpochMismatch(Slot, Slot),
|
ProposalEpochMismatch(Slot, Slot),
|
||||||
/// The proposals are identical and therefore not slashable.
|
/// The proposals are identical and therefore not slashable.
|
||||||
ProposalsIdentical,
|
ProposalsIdentical,
|
||||||
/// The specified proposer has already been slashed.
|
/// The specified proposer cannot be slashed because they are already slashed, or not active.
|
||||||
ProposerAlreadySlashed,
|
ProposerNotSlashable(u64),
|
||||||
/// The specified proposer has already been withdrawn.
|
|
||||||
ProposerAlreadyWithdrawn(u64),
|
|
||||||
/// The first proposal signature was invalid.
|
/// The first proposal signature was invalid.
|
||||||
BadProposal1Signature,
|
BadProposal1Signature,
|
||||||
/// The second proposal signature was invalid.
|
/// The second proposal signature was invalid.
|
||||||
|
@ -7,7 +7,7 @@ use types::*;
|
|||||||
///
|
///
|
||||||
/// Returns `Ok(())` if the `ProposerSlashing` is valid, otherwise indicates the reason for invalidity.
|
/// 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>(
|
pub fn verify_proposer_slashing<T: EthSpec>(
|
||||||
proposer_slashing: &ProposerSlashing,
|
proposer_slashing: &ProposerSlashing,
|
||||||
state: &BeaconState<T>,
|
state: &BeaconState<T>,
|
||||||
@ -34,11 +34,9 @@ pub fn verify_proposer_slashing<T: EthSpec>(
|
|||||||
Invalid::ProposalsIdentical
|
Invalid::ProposalsIdentical
|
||||||
);
|
);
|
||||||
|
|
||||||
verify!(!proposer.slashed, Invalid::ProposerAlreadySlashed);
|
|
||||||
|
|
||||||
verify!(
|
verify!(
|
||||||
proposer.withdrawable_epoch > state.slot.epoch(spec.slots_per_epoch),
|
proposer.is_slashable_at(state.current_epoch()),
|
||||||
Invalid::ProposerAlreadyWithdrawn(proposer_slashing.proposer_index)
|
Invalid::ProposerNotSlashable(proposer_slashing.proposer_index)
|
||||||
);
|
);
|
||||||
|
|
||||||
verify!(
|
verify!(
|
||||||
@ -67,7 +65,7 @@ pub fn verify_proposer_slashing<T: EthSpec>(
|
|||||||
///
|
///
|
||||||
/// Returns `true` if the signature is valid.
|
/// Returns `true` if the signature is valid.
|
||||||
///
|
///
|
||||||
/// Spec v0.5.1
|
/// Spec v0.6.1
|
||||||
fn verify_header_signature(
|
fn verify_header_signature(
|
||||||
header: &BeaconBlockHeader,
|
header: &BeaconBlockHeader,
|
||||||
pubkey: &PublicKey,
|
pubkey: &PublicKey,
|
||||||
@ -77,7 +75,7 @@ fn verify_header_signature(
|
|||||||
let message = header.signed_root();
|
let message = header.signed_root();
|
||||||
let domain = spec.get_domain(
|
let domain = spec.get_domain(
|
||||||
header.slot.epoch(spec.slots_per_epoch),
|
header.slot.epoch(spec.slots_per_epoch),
|
||||||
Domain::BeaconBlock,
|
Domain::BeaconProposer,
|
||||||
fork,
|
fork,
|
||||||
);
|
);
|
||||||
header.signature.verify(&message[..], domain, pubkey)
|
header.signature.verify(&message[..], domain, pubkey)
|
||||||
|
Loading…
Reference in New Issue
Block a user