Skip to content

Commit 62fc1ea

Browse files
committed
Downgrade routine peer-interaction logs from DEBUG to TRACE
Discovery v5 handlers log expected peer-interaction failures (bad packets, failed handshakes, policy-rejected peers, session timeouts) at DEBUG level, producing ~114 messages/minute on mainnet and making --logging=DEBUG output hard to read. Demote 16 such LOG.debug() calls across 9 files to LOG.trace(). The messages remain available at TRACE for protocol debugging; no LOG.warn/error/info calls are touched. Two additional debug calls in NodeSession#cancelAllRequests are intentionally left at DEBUG because they signal potential local-code issues (unexpected cleanup exception, possible race on requestIdStatuses) rather than routine peer behavior. Refs: besu-eth/besu#9691
1 parent 12c70f9 commit 62fc1ea

9 files changed

Lines changed: 15 additions & 15 deletions

src/main/java/org/ethereum/beacon/discovery/pipeline/handler/BadPacketHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void handle(Envelope envelope) {
2626
"Envelope %s in BadPacketHandler, requirements are satisfied!",
2727
envelope.getIdString()));
2828

29-
LOG.debug(
29+
LOG.trace(
3030
() ->
3131
String.format(
3232
"Bad packet: %s in envelope #%s: %s",

src/main/java/org/ethereum/beacon/discovery/pipeline/handler/HandshakeMessagePacketHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void handle(Envelope envelope) {
7070
try {
7171

7272
if (session.getWhoAreYouChallenge().isEmpty()) {
73-
LOG.debug(String.format("Outbound WhoAreYou challenge not found for session %s", session));
73+
LOG.trace(String.format("Outbound WhoAreYou challenge not found for session %s", session));
7474
markHandshakeAsFailed(envelope, session);
7575
return;
7676
}
@@ -90,7 +90,7 @@ public void handle(Envelope envelope) {
9090

9191
Optional<NodeRecord> enr = packet.getHeader().getAuthData().getNodeRecord(nodeRecordFactory);
9292
if (!enr.map(NodeRecord::isValid).orElse(true)) {
93-
LOG.debug(
93+
LOG.trace(
9494
String.format(
9595
"Node record not valid for message [%s] from node %s in status %s",
9696
packet, session.getNodeRecord(), session.getState()));
@@ -100,15 +100,15 @@ public void handle(Envelope envelope) {
100100
final Optional<NodeRecord> nodeRecordMaybe = session.getNodeRecord().or(() -> enr);
101101
// Check the node record matches the ID we expect
102102
if (!nodeRecordMaybe.map(r -> r.getNodeId().equals(session.getNodeId())).orElse(false)) {
103-
LOG.debug(
103+
LOG.trace(
104104
"Incorrect node ID for message [{}] from node {} in status {}",
105105
packet,
106106
session.getNodeRecord(),
107107
session.getState());
108108
markHandshakeAsFailed(envelope, session);
109109
return;
110110
} else if (!enr.map(addressAccessPolicy::allow).orElse(true)) {
111-
LOG.debug(
111+
LOG.trace(
112112
"Rejecting handshake from node {} because the ENR was disallowed: {}",
113113
session.getNodeRecord(),
114114
enr);
@@ -127,7 +127,7 @@ public void handle(Envelope envelope) {
127127
(Bytes) nodeRecord.get(EnrField.PKEY_SECP256K1));
128128

129129
if (!idNonceVerifyResult) {
130-
LOG.debug(
130+
LOG.trace(
131131
String.format(
132132
"ID signature not valid for message [%s] from node %s in status %s",
133133
packet, session.getNodeRecord(), session.getState()));
@@ -145,7 +145,7 @@ public void handle(Envelope envelope) {
145145
enr.ifPresent(session::onNodeRecordReceived);
146146
NextTaskHandler.tryToSendAwaitTaskIfAny(session, outgoingPipeline, scheduler);
147147
} catch (Exception ex) {
148-
LOG.debug(
148+
LOG.trace(
149149
String.format(
150150
"Failed to read message [%s] from node %s in status %s",
151151
packet, session.getNodeRecord(), session.getState()),

src/main/java/org/ethereum/beacon/discovery/pipeline/handler/MessagePacketHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void handle(Envelope envelope) {
6969
String.format(
7070
"Failed to read message [%s] from node %s in status %s",
7171
packet, session.getNodeRecord(), session.getState());
72-
LOG.debug(error, ex);
72+
LOG.trace(error, ex);
7373
envelope.remove(Field.PACKET_MESSAGE);
7474
envelope.put(Field.BAD_PACKET, packet);
7575
} catch (Throwable t) {

src/main/java/org/ethereum/beacon/discovery/pipeline/handler/OutgoingParcelHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void handle(Envelope envelope) {
4747
if (parcel.getPacket().getBytes().size() > IncomingDataPacker.MAX_PACKET_SIZE) {
4848
LOG.error("Outgoing packet is too large, dropping it: {}", parcel.getPacket());
4949
} else if (!addressAccessPolicy.allow(parcel.getDestination())) {
50-
LOG.debug(
50+
LOG.trace(
5151
"Dropping outgoing packet to disallowed destination: {}", parcel.getDestination());
5252
} else {
5353
outgoingSink.next(parcel);

src/main/java/org/ethereum/beacon/discovery/pipeline/handler/PacketSourceFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void handle(final Envelope envelope) {
3030
final InetSocketAddress sender = envelope.get(Field.REMOTE_SENDER);
3131
if (!addressAccessPolicy.allow(sender)) {
3232
envelope.remove(Field.INCOMING);
33-
LOG.debug("Ignoring message from disallowed source {}", sender);
33+
LOG.trace("Ignoring message from disallowed source {}", sender);
3434
}
3535
}
3636
}

src/main/java/org/ethereum/beacon/discovery/pipeline/handler/UnauthorizedMessagePacketHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void handle(Envelope envelope) {
6161
String.format(
6262
"Failed to read message [%s] from node %s in status %s",
6363
unknownPacket, session.getNodeRecord(), session.getState());
64-
LOG.debug(error, ex);
64+
LOG.trace(error, ex);
6565
envelope.put(Field.BAD_PACKET, unknownPacket);
6666
envelope.put(Field.BAD_EXCEPTION, ex);
6767
}

src/main/java/org/ethereum/beacon/discovery/pipeline/handler/WhoAreYouPacketHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void handle(final Envelope envelope) {
6868
boolean nonceMatches =
6969
session.getLastOutboundNonce().map(whoAreYouNonce::equals).orElse(false);
7070
if (!nonceMatches) {
71-
LOG.debug(
71+
LOG.trace(
7272
"Verification not passed for message [{}] from node {} in status {}",
7373
whoAreYouPacket,
7474
nodeRecord,

src/main/java/org/ethereum/beacon/discovery/pipeline/info/FindNodeResponseHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public synchronized List<NodeRecord> getFoundNodes() {
7373

7474
private boolean isValid(final NodeRecord record) {
7575
if (!record.isValid()) {
76-
LOG.debug("Rejecting invalid node record {}", record);
76+
LOG.trace("Rejecting invalid node record {}", record);
7777
return false;
7878
}
7979
return true;
@@ -82,7 +82,7 @@ private boolean isValid(final NodeRecord record) {
8282
private boolean hasCorrectDistance(final NodeSession session, final NodeRecord nodeRecordV5) {
8383
final int actualDistance = Functions.logDistance(nodeRecordV5.getNodeId(), session.getNodeId());
8484
if (!distances.contains(actualDistance)) {
85-
LOG.debug(
85+
LOG.trace(
8686
"Rejecting node record {} received from {} because distance was not in {}.",
8787
nodeRecordV5.getNodeId(),
8888
session.getNodeId(),

src/main/java/org/ethereum/beacon/discovery/schema/NodeSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private synchronized void resetHandshakeState() {
234234

235235
/** Updates request info. Thread-safe. */
236236
public synchronized void cancelAllRequests(final String message) {
237-
LOG.debug(() -> String.format("Cancelling all requests in session %s", this));
237+
LOG.trace(() -> String.format("Cancelling all requests in session %s", this));
238238
final Set<Bytes> requestIdsCopy = new HashSet<>(requestIdStatuses.keySet());
239239
requestIdsCopy.forEach(
240240
requestId -> {

0 commit comments

Comments
 (0)