diff --git a/eth2/attester/src/lib.rs b/eth2/attester/src/lib.rs index 5bffd0c503..8838f022d9 100644 --- a/eth2/attester/src/lib.rs +++ b/eth2/attester/src/lib.rs @@ -2,8 +2,9 @@ pub mod test_utils; mod traits; use slot_clock::SlotClock; +use ssz::TreeHash; use std::sync::Arc; -use types::{AttestationData, FreeAttestation, Signature, Slot}; +use types::{AttestationData, AttestationDataAndCustodyBit, FreeAttestation, Signature, Slot}; pub use self::traits::{ BeaconNode, BeaconNodeError, DutiesReader, DutiesReaderError, PublishOutcome, Signer, @@ -137,10 +138,14 @@ impl Attester Option { self.store_produce(attestation_data); - self.signer.sign_attestation_message( - &attestation_data.signable_message(PHASE_0_CUSTODY_BIT)[..], - DOMAIN_ATTESTATION, - ) + let message = AttestationDataAndCustodyBit { + data: attestation_data.clone(), + custody_bit: PHASE_0_CUSTODY_BIT, + } + .hash_tree_root(); + + self.signer + .sign_attestation_message(&message[..], DOMAIN_ATTESTATION) } /// Returns `true` if signing some attestation_data is safe (non-slashable). diff --git a/eth2/block_proposer/src/lib.rs b/eth2/block_proposer/src/lib.rs index cea8556272..55461d986a 100644 --- a/eth2/block_proposer/src/lib.rs +++ b/eth2/block_proposer/src/lib.rs @@ -3,13 +3,17 @@ mod traits; use int_to_bytes::int_to_bytes32; use slot_clock::SlotClock; +use ssz::SignedRoot; use std::sync::Arc; -use types::{BeaconBlock, ChainSpec, Slot}; +use types::{BeaconBlock, ChainSpec, Hash256, Proposal, Slot}; pub use self::traits::{ BeaconNode, BeaconNodeError, DutiesReader, DutiesReaderError, PublishOutcome, Signer, }; +//TODO: obtain the correct domain using a `Fork`. +pub const TEMPORARY_DOMAIN_VALUE: u64 = 0; + #[derive(Debug, PartialEq)] pub enum PollOutcome { /// A new block was produced. @@ -136,7 +140,7 @@ impl BlockProducer return Ok(PollOutcome::SignerRejection(slot)), Some(signature) => signature, @@ -169,10 +173,17 @@ impl BlockProducer Option { self.store_produce(&block); - match self.signer.sign_block_proposal( - &block.proposal_root(&self.spec)[..], - self.spec.domain_proposal, - ) { + let proposal = Proposal { + slot: block.slot, + shard: self.spec.beacon_chain_shard_number, + block_root: Hash256::from_slice(&block.signed_root()[..]), + signature: block.signature.clone(), + }; + + match self + .signer + .sign_block_proposal(&proposal.signed_root()[..], TEMPORARY_DOMAIN_VALUE) + { None => None, Some(signature) => { block.signature = signature;