From c2e9354126f122951bd7db75fd34084c589c2124 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 14 Mar 2022 06:16:49 +0000 Subject: [PATCH] Gracefully handle missing sync committee duties (#3086) ## Issue Addressed Closes https://github.com/sigp/lighthouse/issues/3085 Closes https://github.com/sigp/lighthouse/issues/2953 ## Proposed Changes Downgrade some of the warnings logged by the VC which were useful during development of the sync committee service but are creating trouble now that we avoid populating the `sync_duties` map with 0 active validators. --- validator_client/src/duties_service/sync.rs | 2 +- .../src/sync_committee_service.rs | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/validator_client/src/duties_service/sync.rs b/validator_client/src/duties_service/sync.rs index 02f45ebc45..9857561c48 100644 --- a/validator_client/src/duties_service/sync.rs +++ b/validator_client/src/duties_service/sync.rs @@ -403,7 +403,7 @@ pub async fn poll_sync_committee_duties_for_period sync_committee_period, ); return Ok(()); diff --git a/validator_client/src/sync_committee_service.rs b/validator_client/src/sync_committee_service.rs index a349cb75f5..105bf7d27f 100644 --- a/validator_client/src/sync_committee_service.rs +++ b/validator_client/src/sync_committee_service.rs @@ -4,7 +4,7 @@ use environment::RuntimeContext; use eth2::types::BlockId; use futures::future::join_all; use futures::future::FutureExt; -use slog::{crit, debug, error, info, trace, warn}; +use slog::{crit, debug, error, info, trace}; use slot_clock::SlotClock; use std::collections::HashMap; use std::ops::Deref; @@ -154,11 +154,16 @@ impl SyncCommitteeService { .checked_sub(slot_duration / 3) .unwrap_or_else(|| Duration::from_secs(0)); - let slot_duties = self + let slot_duties = if let Some(duties) = self .duties_service .sync_duties .get_duties_for_slot::(slot, &self.duties_service.spec) - .ok_or_else(|| format!("Error fetching duties for slot {}", slot))?; + { + duties + } else { + debug!(log, "No duties known for slot {}", slot); + return Ok(()); + }; if slot_duties.duties.is_empty() { debug!( @@ -490,9 +495,9 @@ impl SyncCommitteeService { spec, )), None => { - warn!( + debug!( log, - "Missing duties for subscription"; + "No duties for subscription"; "slot" => duty_slot, ); all_succeeded = false; @@ -500,6 +505,15 @@ impl SyncCommitteeService { } } + if subscriptions.is_empty() { + debug!( + log, + "No sync subscriptions to send"; + "slot" => slot, + ); + return Ok(()); + } + // Post subscriptions to BN. debug!( log,