diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/GossipFailureLogger.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/GossipFailureLogger.java index 488288e7bc0..5da65069875 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/GossipFailureLogger.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/GossipFailureLogger.java @@ -42,28 +42,31 @@ public synchronized void logWithSuppression(final Throwable error, final UInt64 lastErroredSlot = slot; lastRootCause = rootCause; - switch (lastRootCause) { - case MessageAlreadySeenException messageAlreadySeenException -> LOG.debug( - "Failed to publish {}(s) for slot {} because the message has already been seen", - messageType, - lastErroredSlot); - case NoPeersForOutboundMessageException noPeersForOutboundMessageException -> LOG.log( - Level.DEBUG, - "Failed to publish {}(s) for slot {}; {}", - messageType, - lastErroredSlot, - rootCause.getMessage()); - case SemiDuplexNoOutboundStreamException semiDuplexNoOutboundStreamException -> LOG.log( - suppress ? Level.DEBUG : Level.WARN, - "Failed to publish {}(s) for slot {} because no peers were available on the required gossip topic", - messageType, - lastErroredSlot); - default -> LOG.log( - suppress ? Level.DEBUG : Level.ERROR, - "Failed to publish {}(s) for slot {}", - messageType, - lastErroredSlot, - error); - } + if (lastRootCause instanceof MessageAlreadySeenException) { + LOG.debug( + "Failed to publish {}(s) for slot {} because the message has already been seen", + messageType, + lastErroredSlot); + } else if (lastRootCause instanceof NoPeersForOutboundMessageException) { + LOG.log( + suppress ? Level.DEBUG : Level.WARN, + "Failed to publish {}(s) for slot {}; {}", + messageType, + lastErroredSlot, + rootCause.getMessage()); + } else if (lastRootCause instanceof SemiDuplexNoOutboundStreamException) { + LOG.log( + suppress ? Level.DEBUG : Level.WARN, + "Failed to publish {}(s) for slot {} because no peers were available on the required gossip topic", + messageType, + lastErroredSlot); + } else { + LOG.log( + suppress ? Level.DEBUG : Level.ERROR, + "Failed to publish {}(s) for slot {}", + messageType, + lastErroredSlot, + error); + } } } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/AttestationSubnetSubscriptions.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/AttestationSubnetSubscriptions.java index 7c1d2a39485..24bd96c5da0 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/AttestationSubnetSubscriptions.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/AttestationSubnetSubscriptions.java @@ -76,7 +76,7 @@ public SafeFuture gossip(final Attestation attestation) { + " because the state was not available"); } LOG.trace( - "send attestation {} slot {} on subnet {}", + "Send attestation {} slot {} on subnet {}", attestation.hashTreeRoot(), attestation.getData().getSlot(), subnetId.get()); diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/SyncCommitteeSubnetSubscriptions.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/SyncCommitteeSubnetSubscriptions.java index 4bc8f627554..3e928b8c37b 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/SyncCommitteeSubnetSubscriptions.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/SyncCommitteeSubnetSubscriptions.java @@ -64,7 +64,7 @@ public SyncCommitteeSubnetSubscriptions( public SafeFuture gossip(final SyncCommitteeMessage message, final int subnetId) { LOG.trace( - "send sync committee message {} validator {}, subnet {} on slot slot {} ", + "Send sync committee message {} validator {}, subnet {} on slot slot {} ", message.hashTreeRoot(), message.getValidatorIndex(), subnetId, diff --git a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/libp2p/gossip/GossipHandler.java b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/libp2p/gossip/GossipHandler.java index 50ad98475cb..c06b5f9d22f 100644 --- a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/libp2p/gossip/GossipHandler.java +++ b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/libp2p/gossip/GossipHandler.java @@ -13,6 +13,7 @@ package tech.pegasys.teku.networking.p2p.libp2p.gossip; +import com.google.common.base.Throwables; import io.libp2p.core.pubsub.MessageApi; import io.libp2p.core.pubsub.PubsubPublisherApi; import io.libp2p.core.pubsub.Topic; @@ -87,6 +88,10 @@ public void gossip(final Bytes bytes) { SafeFuture.of(publisher.publish(Unpooled.wrappedBuffer(bytes.toArrayUnsafe()), topic)) .finish( () -> LOG.trace("Successfully gossiped message on {}", topic), - err -> LOG.debug("Failed to gossip message on {}, {}", topic, err.getMessage())); + err -> + LOG.debug( + "Failed to gossip message on {}, {}", + topic, + Throwables.getRootCause(err).getMessage())); } }