Fix attester and proposer compile issues
- Updated to use new signed roots (`SignedRoot`, `TreeHash`) - Added a temporary domain value Note: these changes are not a fully v0.4.0 upgrade.
This commit is contained in:
parent
93ce7b59e7
commit
dad140a338
@ -2,8 +2,9 @@ pub mod test_utils;
|
|||||||
mod traits;
|
mod traits;
|
||||||
|
|
||||||
use slot_clock::SlotClock;
|
use slot_clock::SlotClock;
|
||||||
|
use ssz::TreeHash;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use types::{AttestationData, FreeAttestation, Signature, Slot};
|
use types::{AttestationData, AttestationDataAndCustodyBit, FreeAttestation, Signature, Slot};
|
||||||
|
|
||||||
pub use self::traits::{
|
pub use self::traits::{
|
||||||
BeaconNode, BeaconNodeError, DutiesReader, DutiesReaderError, PublishOutcome, Signer,
|
BeaconNode, BeaconNodeError, DutiesReader, DutiesReaderError, PublishOutcome, Signer,
|
||||||
@ -137,10 +138,14 @@ impl<T: SlotClock, U: BeaconNode, V: DutiesReader, W: Signer> Attester<T, U, V,
|
|||||||
fn sign_attestation_data(&mut self, attestation_data: &AttestationData) -> Option<Signature> {
|
fn sign_attestation_data(&mut self, attestation_data: &AttestationData) -> Option<Signature> {
|
||||||
self.store_produce(attestation_data);
|
self.store_produce(attestation_data);
|
||||||
|
|
||||||
self.signer.sign_attestation_message(
|
let message = AttestationDataAndCustodyBit {
|
||||||
&attestation_data.signable_message(PHASE_0_CUSTODY_BIT)[..],
|
data: attestation_data.clone(),
|
||||||
DOMAIN_ATTESTATION,
|
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).
|
/// Returns `true` if signing some attestation_data is safe (non-slashable).
|
||||||
|
@ -3,13 +3,17 @@ mod traits;
|
|||||||
|
|
||||||
use int_to_bytes::int_to_bytes32;
|
use int_to_bytes::int_to_bytes32;
|
||||||
use slot_clock::SlotClock;
|
use slot_clock::SlotClock;
|
||||||
|
use ssz::SignedRoot;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use types::{BeaconBlock, ChainSpec, Slot};
|
use types::{BeaconBlock, ChainSpec, Hash256, Proposal, Slot};
|
||||||
|
|
||||||
pub use self::traits::{
|
pub use self::traits::{
|
||||||
BeaconNode, BeaconNodeError, DutiesReader, DutiesReaderError, PublishOutcome, Signer,
|
BeaconNode, BeaconNodeError, DutiesReader, DutiesReaderError, PublishOutcome, Signer,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//TODO: obtain the correct domain using a `Fork`.
|
||||||
|
pub const TEMPORARY_DOMAIN_VALUE: u64 = 0;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum PollOutcome {
|
pub enum PollOutcome {
|
||||||
/// A new block was produced.
|
/// A new block was produced.
|
||||||
@ -136,7 +140,7 @@ impl<T: SlotClock, U: BeaconNode, V: DutiesReader, W: Signer> BlockProducer<T, U
|
|||||||
|
|
||||||
match self
|
match self
|
||||||
.signer
|
.signer
|
||||||
.sign_randao_reveal(&message, self.spec.domain_randao)
|
.sign_randao_reveal(&message, TEMPORARY_DOMAIN_VALUE)
|
||||||
{
|
{
|
||||||
None => return Ok(PollOutcome::SignerRejection(slot)),
|
None => return Ok(PollOutcome::SignerRejection(slot)),
|
||||||
Some(signature) => signature,
|
Some(signature) => signature,
|
||||||
@ -169,10 +173,17 @@ impl<T: SlotClock, U: BeaconNode, V: DutiesReader, W: Signer> BlockProducer<T, U
|
|||||||
fn sign_block(&mut self, mut block: BeaconBlock) -> Option<BeaconBlock> {
|
fn sign_block(&mut self, mut block: BeaconBlock) -> Option<BeaconBlock> {
|
||||||
self.store_produce(&block);
|
self.store_produce(&block);
|
||||||
|
|
||||||
match self.signer.sign_block_proposal(
|
let proposal = Proposal {
|
||||||
&block.proposal_root(&self.spec)[..],
|
slot: block.slot,
|
||||||
self.spec.domain_proposal,
|
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,
|
None => None,
|
||||||
Some(signature) => {
|
Some(signature) => {
|
||||||
block.signature = signature;
|
block.signature = signature;
|
||||||
|
Loading…
Reference in New Issue
Block a user