Skip to content

Commit

Permalink
v2.0: gossip: demote invalid duplicate proof errors to info (backport…
Browse files Browse the repository at this point in the history
… of #2754) (#2759)

gossip: demote invalid duplicate proof errors to info (#2754)

* gossip: demote invalid duplicate proof errors to info

* pr feedback: explicitly list every enum

(cherry picked from commit 7b6e6c1)

Co-authored-by: Ashwin Sekar <[email protected]>
  • Loading branch information
mergify[bot] and AshwinSekar authored Aug 28, 2024
1 parent 2088c58 commit 2f2d7ec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
27 changes: 27 additions & 0 deletions gossip/src/duplicate_shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,33 @@ pub enum Error {
UnknownSlotLeader(Slot),
}

impl Error {
/// Errors indicating that the initial node submitted an invalid duplicate proof case
pub(crate) fn is_non_critical(&self) -> bool {
match self {
Self::SlotMismatch
| Self::InvalidShredVersion(_)
| Self::InvalidSignature
| Self::ShredTypeMismatch
| Self::InvalidDuplicateShreds
| Self::InvalidLastIndexConflict
| Self::InvalidErasureMetaConflict => true,
Self::BlockstoreInsertFailed(_)
| Self::DataChunkMismatch
| Self::DuplicateSlotSenderFailure
| Self::InvalidChunkIndex { .. }
| Self::InvalidDuplicateSlotProof
| Self::InvalidSizeLimit
| Self::InvalidShred(_)
| Self::NumChunksMismatch
| Self::MissingDataChunk
| Self::SerializationError(_)
| Self::TryFromIntError(_)
| Self::UnknownSlotLeader(_) => false,
}
}
}

/// Check that `shred1` and `shred2` indicate a valid duplicate proof
/// - Must be for the same slot
/// - Must match the expected shred version
Expand Down
8 changes: 7 additions & 1 deletion gossip/src/duplicate_shred_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ impl DuplicateShredHandlerTrait for DuplicateShredHandler {
fn handle(&mut self, shred_data: DuplicateShred) {
self.cache_root_info();
self.maybe_prune_buffer();
let slot = shred_data.slot;
let pubkey = shred_data.from;
if let Err(error) = self.handle_shred_data(shred_data) {
error!("handle packet: {error:?}")
if error.is_non_critical() {
info!("Received invalid duplicate shred proof from {pubkey} for slot {slot}: {error:?}");
} else {
error!("Unable to process duplicate shred proof from {pubkey} for slot {slot}: {error:?}");
}
}
}
}
Expand Down

0 comments on commit 2f2d7ec

Please sign in to comment.