Add clippy suggestions
This commit is contained in:
parent
51ffbc07d2
commit
9a6ecc4665
@ -2,7 +2,7 @@ mod beacon_node_attestation;
|
||||
mod grpc;
|
||||
|
||||
use std::sync::Arc;
|
||||
use types::{BeaconBlock, ChainSpec, Domain, Fork, Slot};
|
||||
use types::{ChainSpec, Domain, Fork};
|
||||
//TODO: Move these higher up in the crate
|
||||
use super::block_producer::{BeaconNodeError, PublishOutcome, ValidatorEvent};
|
||||
use crate::signer::Signer;
|
||||
@ -50,19 +50,16 @@ impl<'a, B: BeaconNodeAttestation, S: Signer> AttestationProducer<'a, B, S> {
|
||||
}
|
||||
Err(e) => error!(log, "Attestation production error"; "Error" => format!("{:?}", e)),
|
||||
Ok(ValidatorEvent::SignerRejection(_slot)) => {
|
||||
error!(log, "Attestation production error"; "Error" => format!("Signer could not sign the attestation"))
|
||||
error!(log, "Attestation production error"; "Error" => "Signer could not sign the attestation".to_string())
|
||||
}
|
||||
Ok(ValidatorEvent::SlashableAttestationNotProduced(_slot)) => {
|
||||
error!(log, "Attestation production error"; "Error" => format!("Rejected the attestation as it could have been slashed"))
|
||||
}
|
||||
Ok(ValidatorEvent::BeaconNodeUnableToProduceAttestation(_slot)) => {
|
||||
error!(log, "Attestation production error"; "Error" => format!("Beacon node was unable to produce an attestation"))
|
||||
error!(log, "Attestation production error"; "Error" => "Rejected the attestation as it could have been slashed".to_string())
|
||||
}
|
||||
Ok(ValidatorEvent::PublishAttestationFailed) => {
|
||||
error!(log, "Attestation production error"; "Error" => format!("Beacon node was unable to publish an attestation"))
|
||||
error!(log, "Attestation production error"; "Error" => "Beacon node was unable to publish an attestation".to_string())
|
||||
}
|
||||
Ok(ValidatorEvent::InvalidAttestation) => {
|
||||
error!(log, "Attestation production error"; "Error" => format!("The signed attestation was invalid"))
|
||||
error!(log, "Attestation production error"; "Error" => "The signed attestation was invalid".to_string())
|
||||
}
|
||||
Ok(v) => {
|
||||
warn!(log, "Unknown result for attestation production"; "Error" => format!("{:?}",v))
|
||||
|
@ -27,8 +27,6 @@ pub enum ValidatorEvent {
|
||||
SlashableAttestationNotProduced(Slot),
|
||||
/// The Beacon Node was unable to produce a block at that slot.
|
||||
BeaconNodeUnableToProduceBlock(Slot),
|
||||
/// The Beacon Node was unable to produce an attestation at that slot.
|
||||
BeaconNodeUnableToProduceAttestation(Slot),
|
||||
/// The signer failed to sign the message.
|
||||
SignerRejection(Slot),
|
||||
/// Publishing an attestation failed.
|
||||
@ -61,13 +59,13 @@ impl<'a, B: BeaconNodeBlock, S: Signer> BlockProducer<'a, B, S> {
|
||||
}
|
||||
Err(e) => error!(log, "Block production error"; "Error" => format!("{:?}", e)),
|
||||
Ok(ValidatorEvent::SignerRejection(_slot)) => {
|
||||
error!(log, "Block production error"; "Error" => format!("Signer Could not sign the block"))
|
||||
error!(log, "Block production error"; "Error" => "Signer Could not sign the block".to_string())
|
||||
}
|
||||
Ok(ValidatorEvent::SlashableBlockNotProduced(_slot)) => {
|
||||
error!(log, "Block production error"; "Error" => format!("Rejected the block as it could have been slashed"))
|
||||
error!(log, "Block production error"; "Error" => "Rejected the block as it could have been slashed".to_string())
|
||||
}
|
||||
Ok(ValidatorEvent::BeaconNodeUnableToProduceBlock(_slot)) => {
|
||||
error!(log, "Block production error"; "Error" => format!("Beacon node was unable to produce a block"))
|
||||
error!(log, "Block production error"; "Error" => "Beacon node was unable to produce a block".to_string())
|
||||
}
|
||||
Ok(v) => {
|
||||
warn!(log, "Unknown result for block production"; "Error" => format!("{:?}",v))
|
||||
@ -88,7 +86,6 @@ impl<'a, B: BeaconNodeBlock, S: Signer> BlockProducer<'a, B, S> {
|
||||
pub fn produce_block(&mut self) -> Result<ValidatorEvent, Error> {
|
||||
let epoch = self.slot.epoch(self.spec.slots_per_epoch);
|
||||
|
||||
let randao_reveal = {
|
||||
let message = epoch.hash_tree_root();
|
||||
let randao_reveal = match self.signer.sign_message(
|
||||
&message,
|
||||
@ -97,8 +94,6 @@ impl<'a, B: BeaconNodeBlock, S: Signer> BlockProducer<'a, B, S> {
|
||||
None => return Ok(ValidatorEvent::SignerRejection(self.slot)),
|
||||
Some(signature) => signature,
|
||||
};
|
||||
randao_reveal
|
||||
};
|
||||
|
||||
if let Some(block) = self
|
||||
.beacon_node
|
||||
|
@ -1,11 +1,12 @@
|
||||
use super::beacon_node_duties::{BeaconNodeDuties, BeaconNodeDutiesError};
|
||||
use super::epoch_duties::{EpochDuties, EpochDuty};
|
||||
use grpcio::CallOption;
|
||||
// to use if we manually specify a timeout
|
||||
//use grpcio::CallOption;
|
||||
use protos::services::{GetDutiesRequest, Validators};
|
||||
use protos::services_grpc::ValidatorServiceClient;
|
||||
use ssz::ssz_encode;
|
||||
use std::collections::HashMap;
|
||||
use std::time::Duration;
|
||||
// use std::time::Duration;
|
||||
use types::{AttestationDuty, Epoch, PublicKey, Slot};
|
||||
|
||||
impl BeaconNodeDuties for ValidatorServiceClient {
|
||||
|
@ -69,7 +69,7 @@ impl<U: BeaconNodeDuties, S: Signer + Display> DutiesManager<U, S> {
|
||||
// duties have changed
|
||||
//TODO: Duties could be large here. Remove from display and avoid the clone.
|
||||
self.duties_map.write()?.insert(epoch, duties.clone());
|
||||
return Ok(UpdateOutcome::DutiesChanged(epoch, duties));
|
||||
Ok(UpdateOutcome::DutiesChanged(epoch, duties))
|
||||
}
|
||||
|
||||
/// A future wrapping around `update()`. This will perform logic based upon the update
|
||||
|
@ -157,7 +157,7 @@ impl<B: BeaconNodeDuties + 'static, S: Signer + 'static> Service<B, S> {
|
||||
|
||||
let current_slot = slot_clock
|
||||
.present_slot()
|
||||
.map_err(|e| ErrorKind::SlotClockError(e))?
|
||||
.map_err(ErrorKind::SlotClockError)?
|
||||
.expect("Genesis must be in the future");
|
||||
|
||||
/* Generate the duties manager */
|
||||
@ -289,8 +289,7 @@ impl<B: BeaconNodeDuties + 'static, S: Signer + 'static> Service<B, S> {
|
||||
std::thread::spawn(move || {
|
||||
// the return value is a future which returns ready.
|
||||
// built to be compatible with the tokio runtime.
|
||||
let _empty = cloned_manager.run_update(current_epoch.clone(), cloned_log.clone());
|
||||
dbg!("Duties Thread Ended");
|
||||
let _empty = cloned_manager.run_update(current_epoch, cloned_log.clone());
|
||||
});
|
||||
}
|
||||
|
||||
@ -303,7 +302,7 @@ impl<B: BeaconNodeDuties + 'static, S: Signer + 'static> Service<B, S> {
|
||||
// spawns a thread to produce a beacon block
|
||||
let signers = self.duties_manager.signers.clone(); // this is an arc
|
||||
let fork = self.fork.clone();
|
||||
let slot = self.current_slot.clone();
|
||||
let slot = self.current_slot;
|
||||
let spec = self.spec.clone();
|
||||
let beacon_node = self.beacon_block_client.clone();
|
||||
let log = self.log.clone();
|
||||
@ -318,7 +317,6 @@ impl<B: BeaconNodeDuties + 'static, S: Signer + 'static> Service<B, S> {
|
||||
signer,
|
||||
};
|
||||
block_producer.handle_produce_block(log);
|
||||
dbg!("Block produce Thread Ended");
|
||||
});
|
||||
}
|
||||
if work_type.attestation_duty.is_some() {
|
||||
@ -340,7 +338,6 @@ impl<B: BeaconNodeDuties + 'static, S: Signer + 'static> Service<B, S> {
|
||||
signer,
|
||||
};
|
||||
attestation_producer.handle_produce_attestation(log);
|
||||
dbg!("Attestation Thread Ended");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user