More progress towards getting the attester working.
This commit is contained in:
parent
16706d322f
commit
bda381a264
@ -99,6 +99,8 @@ impl<T: SlotClock, U: BeaconNode, V: DutiesReader, W: Signer> Attester<T, U, V,
|
|||||||
None => return Ok(PollOutcome::BeaconNodeUnableToProduceAttestation(slot)),
|
None => return Ok(PollOutcome::BeaconNodeUnableToProduceAttestation(slot)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dbg!(&attestation_data);
|
||||||
|
|
||||||
if !self.safe_to_produce(&attestation_data) {
|
if !self.safe_to_produce(&attestation_data) {
|
||||||
return Ok(PollOutcome::SlashableAttestationNotProduced(slot));
|
return Ok(PollOutcome::SlashableAttestationNotProduced(slot));
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,12 @@ use tokio::runtime::Builder;
|
|||||||
use tokio::timer::Interval;
|
use tokio::timer::Interval;
|
||||||
use tokio_timer::clock::Clock;
|
use tokio_timer::clock::Clock;
|
||||||
use types::{Epoch, Fork, Slot};
|
use types::{Epoch, Fork, Slot};
|
||||||
|
use std::thread;
|
||||||
|
|
||||||
//TODO: This service should be simplified in the future. Can be made more steamlined.
|
//TODO: This service should be simplified in the future. Can be made more steamlined.
|
||||||
|
|
||||||
|
const POLL_INTERVAL_MILLIS: u64 = 100;
|
||||||
|
|
||||||
/// The validator service. This is the main thread that executes and maintains validator
|
/// The validator service. This is the main thread that executes and maintains validator
|
||||||
/// duties.
|
/// duties.
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
@ -217,7 +220,10 @@ impl Service {
|
|||||||
|
|
||||||
// TODO: keypairs are randomly generated; they should be loaded from a file or generated.
|
// TODO: keypairs are randomly generated; they should be loaded from a file or generated.
|
||||||
// https://github.com/sigp/lighthouse/issues/160
|
// https://github.com/sigp/lighthouse/issues/160
|
||||||
let keypairs = Arc::new(vec![Keypair::random()]);
|
let keypairs = match config.fetch_keys(&log) {
|
||||||
|
Some(kps) => kps,
|
||||||
|
None => panic!("No key pairs found, cannot start validator client without. Try running ./account_manager generate first.")
|
||||||
|
};
|
||||||
|
|
||||||
// build requisite objects to pass to core thread.
|
// build requisite objects to pass to core thread.
|
||||||
let duties_map = Arc::new(EpochDutiesMap::new(config.spec.slots_per_epoch));
|
let duties_map = Arc::new(EpochDutiesMap::new(config.spec.slots_per_epoch));
|
||||||
@ -272,18 +278,13 @@ impl Service {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}))
|
}))
|
||||||
.map_err(|e| format!("Service thread failed: {:?}", e))?;
|
.map_err(|e| format!("Service thread failed: {:?}", e))?;
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
let duties_map = Arc::new(EpochDutiesMap::new(spec.slots_per_epoch));
|
|
||||||
let epoch_map_for_attester = Arc::new(EpochMap::new(spec.slots_per_epoch));
|
|
||||||
|
|
||||||
|
let mut threads = vec![];
|
||||||
|
|
||||||
for keypair in keypairs {
|
for keypair in keypairs {
|
||||||
info!(self.log, "Starting validator services"; "validator" => keypair.pk.concatenated_hex_id());
|
info!(log, "Starting validator services"; "validator" => keypair.pk.concatenated_hex_id());
|
||||||
|
|
||||||
|
/*
|
||||||
// Spawn a new thread to maintain the validator's `EpochDuties`.
|
// Spawn a new thread to maintain the validator's `EpochDuties`.
|
||||||
let duties_manager_thread = {
|
let duties_manager_thread = {
|
||||||
let spec = spec.clone();
|
let spec = spec.clone();
|
||||||
@ -330,16 +331,16 @@ impl Service {
|
|||||||
block_producer_service.run();
|
block_producer_service.run();
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
// Spawn a new thread for attestation for the validator.
|
// Spawn a new thread for attestation for the validator.
|
||||||
let attester_thread = {
|
let attester_thread = {
|
||||||
let signer = Arc::new(AttesterLocalSigner::new(keypair.clone()));
|
let signer = Arc::new(AttesterLocalSigner::new(keypair.clone()));
|
||||||
let epoch_map = epoch_map_for_attester.clone();
|
let slot_clock = service.slot_clock.clone();
|
||||||
let slot_clock = slot_clock.clone();
|
|
||||||
let log = log.clone();
|
let log = log.clone();
|
||||||
let client = Arc::new(AttestationGrpcClient::new(attester_grpc_client.clone()));
|
let attester_grpc_client = Arc::new(AttestationGrpcClient::new(attester_client.clone()));
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let attester = Attester::new(epoch_map, slot_clock, client, signer);
|
let attester = Attester::new(epoch_map_for_attester, slot_clock, attester_grpc_client, signer);
|
||||||
let mut attester_service = AttesterService {
|
let mut attester_service = AttesterService {
|
||||||
attester,
|
attester,
|
||||||
poll_interval_millis,
|
poll_interval_millis,
|
||||||
@ -350,9 +351,14 @@ impl Service {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
threads.push((duties_manager_thread, producer_thread, attester_thread));
|
//threads.push((duties_manager_thread, producer_thread, attester_thread));
|
||||||
|
threads.push((attester_thread));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
// Naively wait for all the threads to complete.
|
// Naively wait for all the threads to complete.
|
||||||
for tuple in threads {
|
for tuple in threads {
|
||||||
let (manager, producer, attester) = tuple;
|
let (manager, producer, attester) = tuple;
|
||||||
|
Loading…
Reference in New Issue
Block a user