diff --git a/validator_client/src/block_producer/mod.rs b/validator_client/src/block_producer/mod.rs index 8297469baf..77b7196667 100644 --- a/validator_client/src/block_producer/mod.rs +++ b/validator_client/src/block_producer/mod.rs @@ -10,11 +10,6 @@ use types::{BeaconBlock, ChainSpec, Domain, Fork, Slot}; #[derive(Debug, PartialEq)] pub enum Error { - SlotClockError, - SlotUnknowable, - EpochMapPoisoned, - SlotClockPoisoned, - EpochLengthIsZero, BeaconBlockNodeError(BeaconBlockNodeError), } @@ -34,7 +29,7 @@ pub enum ValidatorEvent { /// This struct contains the logic for requesting and signing beacon blocks for a validator. The /// validator can abstractly sign via the Signer trait object. -pub struct BlockProducer { +pub struct BlockProducer<'a, B: BeaconBlockNode, S: Signer> { /// The current fork. pub fork: Fork, /// The current slot to produce a block for. @@ -44,10 +39,10 @@ pub struct BlockProducer { /// The beacon node to connect to. pub beacon_node: Arc, /// The signer to sign the block. - pub signer: Arc, + pub signer: &'a S, } -impl BlockProducer { +impl<'a, B: BeaconBlockNode, S: Signer> BlockProducer<'a, B, S> { /// Produce a block at some slot. /// /// Assumes that a block is required at this slot (does not check the duties). diff --git a/validator_client/src/service.rs b/validator_client/src/service.rs index d6c0e6638b..4c01d89671 100644 --- a/validator_client/src/service.rs +++ b/validator_client/src/service.rs @@ -299,17 +299,23 @@ impl Service { /// If there are any duties to process, spawn a separate thread and perform required actions. fn process_duties(&mut self) { if let Some(work) = self.duties_manager.get_current_work(self.current_slot) { - for (_public_key, work_type) in work { + for (signer_index, work_type) in work { if work_type.produce_block { // spawns a thread to produce a beacon block + let signers = self.duties_manager.signers.clone(); + let fork = self.fork.clone(); + let slot = self.current_slot.clone(); + let spec = self.spec.clone(); + let beacon_node = self.beacon_block_client.clone(); std::thread::spawn(move || { - /* + let signer = &signers[signer_index]; let block_producer = BlockProducer { - fork: self.fork, - slot: self.current_slot, - spec: self.spec.clone(), + fork, + slot, + spec, + beacon_node, + signer, }; - */ }); // TODO: Produce a beacon block in a new thread diff --git a/validator_client/src/signer.rs b/validator_client/src/signer.rs index 49dedbb33f..4bbada08ee 100644 --- a/validator_client/src/signer.rs +++ b/validator_client/src/signer.rs @@ -2,7 +2,7 @@ use std::fmt::Display; use types::{Keypair, PublicKey, Signature}; /// Signs message using an internally-maintained private key. -pub trait Signer: Display + Send + Sync { +pub trait Signer: Display + Send + Sync + Clone { fn sign_block_proposal(&self, message: &[u8], domain: u64) -> Option; fn sign_randao_reveal(&self, message: &[u8], domain: u64) -> Option; /// Returns a public key for the signer object.