mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
fix
This commit is contained in:
@@ -483,7 +483,7 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
|
||||
}
|
||||
};
|
||||
|
||||
let sync_selection_proof_config = if config.distributed {
|
||||
let _sync_selection_proof_config = if config.distributed {
|
||||
SelectionProofConfig {
|
||||
lookahead_slot: AGGREGATION_PRE_COMPUTE_SLOTS_DISTRIBUTED,
|
||||
computation_offset: Duration::default(),
|
||||
@@ -499,21 +499,20 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
|
||||
}
|
||||
};
|
||||
|
||||
let duties_context = context.service_context("duties".into());
|
||||
let duties_service = Arc::new(DutiesService {
|
||||
attesters: <_>::default(),
|
||||
proposers: <_>::default(),
|
||||
sync_duties: SyncDutiesMap::new(sync_selection_proof_config),
|
||||
slot_clock: slot_clock.clone(),
|
||||
beacon_nodes: beacon_nodes.clone(),
|
||||
validator_store: validator_store.clone(),
|
||||
unknown_validator_next_poll_slots: <_>::default(),
|
||||
spec: context.eth2_config.spec.clone(),
|
||||
context: duties_context,
|
||||
enable_high_validator_count_metrics: config.enable_high_validator_count_metrics,
|
||||
selection_proof_config: attestation_selection_proof_config,
|
||||
disable_attesting: config.disable_attesting,
|
||||
});
|
||||
let duties_service: Arc<
|
||||
DutiesService<LighthouseValidatorStore<SystemTimeSlotClock, E>, SystemTimeSlotClock>,
|
||||
> = Arc::new(
|
||||
DutiesServiceBuilder::new()
|
||||
.slot_clock(slot_clock.clone())
|
||||
.beacon_nodes(beacon_nodes.clone())
|
||||
.validator_store(validator_store.clone())
|
||||
.spec(context.eth2_config.spec.clone())
|
||||
.executor(context.executor.clone())
|
||||
.enable_high_validator_count_metrics(config.enable_high_validator_count_metrics)
|
||||
.selection_proof_config(attestation_selection_proof_config)
|
||||
.disable_attesting(config.disable_attesting)
|
||||
.build()?,
|
||||
);
|
||||
|
||||
// Update the metrics server.
|
||||
if let Some(ctx) = &validator_metrics_ctx {
|
||||
|
||||
@@ -114,6 +114,7 @@ pub struct SubscriptionSlots {
|
||||
duty_slot: Slot,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct SelectionProofConfig {
|
||||
pub lookahead_slot: u64,
|
||||
pub computation_offset: Duration, // The seconds to compute the selection proof before a slot
|
||||
@@ -121,16 +122,27 @@ pub struct SelectionProofConfig {
|
||||
pub parallel_sign: bool,
|
||||
}
|
||||
|
||||
impl SelectionProofConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
lookahead_slot: 0,
|
||||
computation_offset: Duration::default(),
|
||||
selections_endpoint: false,
|
||||
parallel_sign: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a selection proof for `duty`.
|
||||
///
|
||||
/// Return `Ok(None)` if the attesting validator is not an aggregator.
|
||||
async fn make_selection_proof<S: ValidatorStore + 'static>(
|
||||
async fn make_selection_proof<S: ValidatorStore + 'static, T: SlotClock + 'static>(
|
||||
duty: &AttesterData,
|
||||
validator_store: &S,
|
||||
spec: &ChainSpec,
|
||||
beacon_nodes: &Arc<BeaconNodeFallback<T, E>>,
|
||||
beacon_nodes: &Arc<BeaconNodeFallback<T>>,
|
||||
config: &SelectionProofConfig,
|
||||
) -> Result<Option<SelectionProof>, Error> {
|
||||
) -> Result<Option<SelectionProof>, Error<S::Error>> {
|
||||
let selection_proof = if config.selections_endpoint {
|
||||
let beacon_committee_selection = BeaconCommitteeSelection {
|
||||
validator_index: duty.validator_index,
|
||||
@@ -266,7 +278,7 @@ pub struct DutiesServiceBuilder<S, T> {
|
||||
//// Whether we permit large validator counts in the metrics.
|
||||
enable_high_validator_count_metrics: bool,
|
||||
/// If this validator is running in distributed mode.
|
||||
distributed: bool,
|
||||
selection_proof_config: SelectionProofConfig,
|
||||
disable_attesting: bool,
|
||||
}
|
||||
|
||||
@@ -285,7 +297,7 @@ impl<S, T> DutiesServiceBuilder<S, T> {
|
||||
executor: None,
|
||||
spec: None,
|
||||
enable_high_validator_count_metrics: false,
|
||||
distributed: false,
|
||||
selection_proof_config: SelectionProofConfig::default(),
|
||||
disable_attesting: false,
|
||||
}
|
||||
}
|
||||
@@ -323,8 +335,8 @@ impl<S, T> DutiesServiceBuilder<S, T> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn distributed(mut self, distributed: bool) -> Self {
|
||||
self.distributed = distributed;
|
||||
pub fn selection_proof_config(mut self, selection_proof_config: SelectionProofConfig) -> Self {
|
||||
self.selection_proof_config = selection_proof_config;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -337,7 +349,7 @@ impl<S, T> DutiesServiceBuilder<S, T> {
|
||||
Ok(DutiesService {
|
||||
attesters: Default::default(),
|
||||
proposers: Default::default(),
|
||||
sync_duties: SyncDutiesMap::new(self.distributed),
|
||||
sync_duties: SyncDutiesMap::new(self.selection_proof_config),
|
||||
validator_store: self
|
||||
.validator_store
|
||||
.ok_or("Cannot build DutiesService without validator_store")?,
|
||||
@@ -353,7 +365,7 @@ impl<S, T> DutiesServiceBuilder<S, T> {
|
||||
.ok_or("Cannot build DutiesService without executor")?,
|
||||
spec: self.spec.ok_or("Cannot build DutiesService without spec")?,
|
||||
enable_high_validator_count_metrics: self.enable_high_validator_count_metrics,
|
||||
distributed: self.distributed,
|
||||
selection_proof_config: self.selection_proof_config,
|
||||
disable_attesting: self.disable_attesting,
|
||||
})
|
||||
}
|
||||
@@ -1168,9 +1180,9 @@ async fn post_validator_duties_attester<S: ValidatorStore, T: SlotClock + 'stati
|
||||
}
|
||||
|
||||
// Create a helper function here to reduce code duplication for normal and distributed mode
|
||||
fn process_duty_and_proof<E: EthSpec>(
|
||||
fn process_duty_and_proof<S: ValidatorStore>(
|
||||
attesters: &mut RwLockWriteGuard<AttesterMap>,
|
||||
result: Result<(AttesterData, Option<SelectionProof>), Error>,
|
||||
result: Result<(AttesterData, Option<SelectionProof>), Error<S::Error>>,
|
||||
dependent_root: Hash256,
|
||||
current_slot: Slot,
|
||||
) -> bool {
|
||||
@@ -1198,7 +1210,7 @@ fn process_duty_and_proof<E: EthSpec>(
|
||||
};
|
||||
|
||||
let attester_map = attesters.entry(duty.pubkey).or_default();
|
||||
let epoch = duty.slot.epoch(E::slots_per_epoch());
|
||||
let epoch = duty.slot.epoch(S::E::slots_per_epoch());
|
||||
match attester_map.entry(epoch) {
|
||||
hash_map::Entry::Occupied(mut entry) => {
|
||||
// No need to update duties for which no proof was computed.
|
||||
@@ -1304,7 +1316,7 @@ async fn fill_in_selection_proofs<S: ValidatorStore + 'static, T: SlotClock + 's
|
||||
.map(|duty| async {
|
||||
let opt_selection_proof = make_selection_proof(
|
||||
&duty,
|
||||
&duties_service.validator_store,
|
||||
duties_service.validator_store.as_ref(),
|
||||
&duties_service.spec,
|
||||
&duties_service.beacon_nodes,
|
||||
&duties_service.selection_proof_config,
|
||||
@@ -1317,7 +1329,7 @@ async fn fill_in_selection_proofs<S: ValidatorStore + 'static, T: SlotClock + 's
|
||||
while let Some(result) = duty_and_proof_results.next().await {
|
||||
let mut attesters = duties_service.attesters.write();
|
||||
// if process_duty_and_proof returns false, exit the loop
|
||||
if !process_duty_and_proof::<E>(
|
||||
if !process_duty_and_proof::<S>(
|
||||
&mut attesters,
|
||||
result,
|
||||
dependent_root,
|
||||
@@ -1332,7 +1344,7 @@ async fn fill_in_selection_proofs<S: ValidatorStore + 'static, T: SlotClock + 's
|
||||
.then(|duty| async {
|
||||
let opt_selection_proof = make_selection_proof(
|
||||
&duty,
|
||||
&duties_service.validator_store,
|
||||
duties_service.validator_store.as_ref(),
|
||||
&duties_service.spec,
|
||||
&duties_service.beacon_nodes,
|
||||
&duties_service.selection_proof_config,
|
||||
@@ -1346,7 +1358,7 @@ async fn fill_in_selection_proofs<S: ValidatorStore + 'static, T: SlotClock + 's
|
||||
// Add to attesters store.
|
||||
let mut attesters = duties_service.attesters.write();
|
||||
for result in duty_and_proof_results {
|
||||
if !process_duty_and_proof::<E>(
|
||||
if !process_duty_and_proof::<S>(
|
||||
&mut attesters,
|
||||
result,
|
||||
dependent_root,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use crate::duties_service::{DutiesService, Error, SelectionProofConfig};
|
||||
// use beacon_node_fallback::BeaconNodeFallback;
|
||||
use doppelganger_service::DoppelgangerStatus;
|
||||
use eth2::types::{Signature, SyncCommitteeSelection};
|
||||
use futures::future::join_all;
|
||||
use futures::stream::{FuturesUnordered, StreamExt};
|
||||
@@ -489,8 +487,8 @@ pub async fn poll_sync_committee_duties_for_period<S: ValidatorStore, T: SlotClo
|
||||
}
|
||||
|
||||
// Create a helper function here to reduce code duplication for normal and distributed mode
|
||||
pub async fn make_sync_selection_proof<T: SlotClock + 'static, E: EthSpec>(
|
||||
duties_service: &Arc<DutiesService<T, E>>,
|
||||
pub async fn make_sync_selection_proof<S: ValidatorStore, T: SlotClock + 'static>(
|
||||
duties_service: &Arc<DutiesService<S, T>>,
|
||||
duty: &SyncDuty,
|
||||
proof_slot: Slot,
|
||||
subnet_id: SyncSubnetId,
|
||||
@@ -608,7 +606,7 @@ pub async fn fill_in_aggregation_proofs<S: ValidatorStore, T: SlotClock + 'stati
|
||||
let mut futures_unordered = FuturesUnordered::new();
|
||||
|
||||
for (_, duty) in pre_compute_duties {
|
||||
let subnet_ids = match duty.subnet_ids::<E>() {
|
||||
let subnet_ids = match duty.subnet_ids::<S::E>() {
|
||||
Ok(subnet_ids) => subnet_ids,
|
||||
Err(e) => {
|
||||
crit!(
|
||||
@@ -646,7 +644,7 @@ pub async fn fill_in_aggregation_proofs<S: ValidatorStore, T: SlotClock + 'stati
|
||||
let validators = committee_duties.validators.read();
|
||||
|
||||
// Check if the validator is an aggregator
|
||||
match proof.is_aggregator::<E>() {
|
||||
match proof.is_aggregator::<S::E>() {
|
||||
Ok(true) => {
|
||||
if let Some(Some(duty)) = validators.get(&validator_index) {
|
||||
debug!(
|
||||
@@ -703,7 +701,7 @@ pub async fn fill_in_aggregation_proofs<S: ValidatorStore, T: SlotClock + 'stati
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Create futures to produce proofs.
|
||||
let duties_service_ref = &duties_service;
|
||||
let futures = subnet_ids.iter().map(|subnet_id| async move {
|
||||
|
||||
@@ -20,7 +20,6 @@ pub enum Error<T> {
|
||||
GreaterThanCurrentEpoch { epoch: Epoch, current_epoch: Epoch },
|
||||
UnableToSignAttestation(AttestationError),
|
||||
SpecificError(T),
|
||||
UnableToSign(SigningError),
|
||||
Middleware(String),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user