Skip to content

Commit

Permalink
Better handling of some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
povi committed Feb 14, 2025
1 parent 0b5d7d3 commit 67c7bc7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
7 changes: 5 additions & 2 deletions liveness_tracker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ impl<P: Preset, W: Wait> LivenessTracker<P, W> {
}
}
ValidatorToLiveness::ValidAttestation(attestation) => {
let state = self.controller.preprocessed_state_at_current_slot()?;
let result = self
.controller
.preprocessed_state_at_current_slot()
.map(|state| self.process_attestation(&attestation, &state));

if let Err(error) = self.process_attestation(&attestation, &state) {
if let Err(error) = result {
warn!("Error while tracking liveness from attestation: {error:?}");
}
}
Expand Down
10 changes: 9 additions & 1 deletion metrics/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,15 @@ impl<P: Preset> MetricsService<P> {
// Take state at last slot in epoch
let slot = misc::compute_start_slot_at_epoch::<P>(epoch).saturating_sub(1);

if let Some(state) = self.controller.state_at_slot(slot)? {
let state_opt = match self.controller.state_at_slot(slot) {
Ok(state_opt) => state_opt,
Err(error) => {
warn!("unable to update epoch metrics: {error:?}");
continue;
}
};

if let Some(state) = state_opt {
match self.update_epoch_metrics(&state.value) {
Ok(()) => epoch_with_metrics = Some(epoch),
Err(error) => warn!("unable to update epoch metrics: {error:?}"),
Expand Down
11 changes: 10 additions & 1 deletion operation_pools/src/attestation_agg_pool/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use eth1_api::ApiController;
use features::Feature::DebugAttestationPacker;
use fork_choice_control::Wait;
use helper_functions::accessors;
use log::warn;
use prometheus_metrics::Metrics;
use ssz::ContiguousList;
use std_ext::ArcExt as _;
Expand Down Expand Up @@ -283,7 +284,15 @@ impl<P: Preset, W: Wait> PoolTask for SetRegisteredValidatorsTask<P, W> {
prepared_proposer_indices,
} = self;

let beacon_state = controller.preprocessed_state_at_current_slot()?;
let beacon_state = match controller.preprocessed_state_at_current_slot() {
Ok(state) => state,
Err(error) => {
warn!(
"failed get preprocessed state at current slot needed for validating registered validator pubkeys: {error}",
);
return Ok(());
}
};

let validator_indices = pubkeys
.into_iter()
Expand Down
30 changes: 24 additions & 6 deletions validator/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,16 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {

gossip_message = self.p2p_to_validator_rx.select_next_some() => match gossip_message {
P2pToValidator::AttesterSlashing(slashing, gossip_id) => {
let outcome = self
let outcome = match self
.block_producer
.handle_external_attester_slashing(*slashing.clone())
.await?;
.await {
Ok(outcome) => outcome,
Err(error) => {
warn!("failed to handle attester slashing: {error}");
continue;
}
};

if matches!(outcome, PoolAdditionOutcome::Accept) {
self.event_channels.send_attester_slashing_event(&slashing);
Expand All @@ -351,10 +357,16 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
self.handle_pool_addition_outcome_for_p2p(outcome, gossip_id);
}
P2pToValidator::ProposerSlashing(slashing, gossip_id) => {
let outcome = self
let outcome = match self
.block_producer
.handle_external_proposer_slashing(*slashing)
.await?;
.await {
Ok(outcome) => outcome,
Err(error) => {
warn!("failed to handle proposer slashing: {error}");
continue;
}
};

if matches!(outcome, PoolAdditionOutcome::Accept) {
self.event_channels.send_proposer_slashing_event(&slashing);
Expand All @@ -363,10 +375,16 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
self.handle_pool_addition_outcome_for_p2p(outcome, gossip_id);
}
P2pToValidator::VoluntaryExit(voluntary_exit, gossip_id) => {
let outcome = self
let outcome = match self
.block_producer
.handle_external_voluntary_exit(*voluntary_exit)
.await?;
.await {
Ok(outcome) => outcome,
Err(error) => {
warn!("failed to handle voluntary exit: {error}");
continue;
}
};

if matches!(outcome, PoolAdditionOutcome::Accept) {
self.event_channels.send_voluntary_exit_event(&voluntary_exit);
Expand Down

0 comments on commit 67c7bc7

Please sign in to comment.