From c5f03f7d56556aad2b4145c1bc2d1181ff5b821a Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Wed, 23 Dec 2020 07:53:38 +0000 Subject: [PATCH] Tidy slasher logs for known slashings (#2108) ## Proposed Changes This quiets the slasher logs when ingesting slashings that are already known. Previously we would log an `ERRO` when a slashing was rediscovered locally but had already been submitted on-chain. This is to be expected from time to time, as different users' slashers will run at different times, and it's likely that slashings will make it on-chain before all users have detected them locally. --- .../src/per_block_processing/errors.rs | 2 - slasher/service/src/service.rs | 53 ++++++++++++++----- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/consensus/state_processing/src/per_block_processing/errors.rs b/consensus/state_processing/src/per_block_processing/errors.rs index 2046631841..81f06a5262 100644 --- a/consensus/state_processing/src/per_block_processing/errors.rs +++ b/consensus/state_processing/src/per_block_processing/errors.rs @@ -223,8 +223,6 @@ pub enum AttesterSlashingInvalid { IndexedAttestation2Invalid(BlockOperationError), /// The validator index is unknown. One cannot slash one who does not exist. UnknownValidator(u64), - /// The specified validator has already been withdrawn. - ValidatorAlreadyWithdrawn(u64), /// There were no indices able to be slashed. NoSlashableIndices, } diff --git a/slasher/service/src/service.rs b/slasher/service/src/service.rs index 5608eac5fa..18ca063ecf 100644 --- a/slasher/service/src/service.rs +++ b/slasher/service/src/service.rs @@ -10,7 +10,12 @@ use slasher::{ }; use slog::{debug, error, info, trace, warn, Logger}; use slot_clock::SlotClock; -use state_processing::VerifyOperation; +use state_processing::{ + per_block_processing::errors::{ + AttesterSlashingInvalid, BlockOperationError, ProposerSlashingInvalid, + }, + VerifyOperation, +}; use std::sync::mpsc::{sync_channel, Receiver, SyncSender, TrySendError}; use std::sync::Arc; use task_executor::TaskExecutor; @@ -175,12 +180,22 @@ impl SlasherService { ) }) { Ok(verified) => verified, + Err(BeaconChainError::AttesterSlashingValidationError( + BlockOperationError::Invalid(AttesterSlashingInvalid::NoSlashableIndices), + )) => { + debug!( + log, + "Skipping attester slashing for slashed validators"; + "slashing" => ?slashing, + ); + continue; + } Err(e) => { warn!( log, "Attester slashing produced is invalid"; - "error" => format!("{:?}", e), - "slashing" => format!("{:?}", slashing), + "error" => ?e, + "slashing" => ?slashing, ); continue; } @@ -191,8 +206,8 @@ impl SlasherService { error!( log, "Beacon chain refused attester slashing"; - "error" => format!("{:?}", e), - "slashing" => format!("{:?}", slashing), + "error" => ?e, + "slashing" => ?slashing, ); } @@ -204,7 +219,7 @@ impl SlasherService { debug!( log, "Unable to publish attester slashing"; - "error" => format!("{:?}", e), + "error" => e, ); } } @@ -221,19 +236,29 @@ impl SlasherService { for slashing in proposer_slashings { let verified_slashing = match beacon_chain.with_head(|head| { - Ok::<_, BeaconChainError>( - slashing - .clone() - .validate(&head.beacon_state, &beacon_chain.spec)?, - ) + Ok(slashing + .clone() + .validate(&head.beacon_state, &beacon_chain.spec)?) }) { Ok(verified) => verified, + Err(BeaconChainError::ProposerSlashingValidationError( + BlockOperationError::Invalid(ProposerSlashingInvalid::ProposerNotSlashable( + index, + )), + )) => { + debug!( + log, + "Skipping proposer slashing for slashed validator"; + "validator_index" => index, + ); + continue; + } Err(e) => { error!( log, "Proposer slashing produced is invalid"; - "error" => format!("{:?}", e), - "slashing" => format!("{:?}", slashing), + "error" => ?e, + "slashing" => ?slashing, ); continue; } @@ -247,7 +272,7 @@ impl SlasherService { debug!( log, "Unable to publish proposer slashing"; - "error" => format!("{:?}", e), + "error" => e, ); } }