Skip to content

Commit

Permalink
more message tweaks
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Harris <[email protected]>
  • Loading branch information
rolfyone committed Oct 18, 2024
1 parent f0e7ad4 commit 4985d4d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
}
}

0 comments on commit 4985d4d

Please sign in to comment.