From 0b4c03c8ca68ea656c072271c1910532a1f4be83 Mon Sep 17 00:00:00 2001 From: Stefan Pingel <16143240+pinges@users.noreply.github.com> Date: Fri, 26 Nov 2021 11:24:47 +1000 Subject: [PATCH] add more logging for get blocks form peers task (#3047) * add more logging for get blocks form peers task Signed-off-by: Stefan Pingel --- .../task/AbstractGetHeadersFromPeerTask.java | 9 ++++++--- .../eth/manager/task/GetBlockFromPeerTask.java | 14 ++++++++++---- .../eth/manager/task/GetBodiesFromPeerTask.java | 3 +++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractGetHeadersFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractGetHeadersFromPeerTask.java index 6bcdb176e5..1a6104e5dc 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractGetHeadersFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractGetHeadersFromPeerTask.java @@ -74,16 +74,19 @@ public abstract class AbstractGetHeadersFromPeerTask final List headers = headersMessage.getHeaders(protocolSchedule); if (headers.isEmpty()) { // Message contains no data - nothing to do + LOG.debug("headers.isEmpty. Peer: {}", peer); return Optional.empty(); } if (headers.size() > count) { // Too many headers - this isn't our response + LOG.debug("headers.size()>count. Peer: {}", peer); return Optional.empty(); } final BlockHeader firstHeader = headers.get(0); if (!matchesFirstHeader(firstHeader)) { // This isn't our message - nothing to do + LOG.debug("!matchesFirstHeader. Peer: {}", peer); return Optional.empty(); } @@ -95,6 +98,7 @@ public abstract class AbstractGetHeadersFromPeerTask final BlockHeader header = headers.get(i); if (header.getNumber() != prevBlockHeader.getNumber() + expectedDelta) { // Skip doesn't match, this isn't our data + LOG.debug("header not matching the expected number. Peer: {}", peer); return Optional.empty(); } // if headers are supposed to be sequential check if a chain is formed @@ -103,8 +107,7 @@ public abstract class AbstractGetHeadersFromPeerTask final BlockHeader child = reverse ? prevBlockHeader : header; if (!parent.getHash().equals(child.getParentHash())) { LOG.debug( - "Sequential headers must form a chain through hashes, disconnecting peer: {}", - peer.toString()); + "Sequential headers must form a chain through hashes, disconnecting peer: {}", peer); peer.disconnect(DisconnectMessage.DisconnectReason.BREACH_OF_PROTOCOL); return Optional.empty(); } @@ -113,7 +116,7 @@ public abstract class AbstractGetHeadersFromPeerTask headersList.add(header); } - LOG.debug("Received {} of {} headers requested from peer.", headersList.size(), count); + LOG.debug("Received {} of {} headers requested from peer {}", headersList.size(), count, peer); return Optional.of(headersList); } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeerTask.java index eb11e6afd0..1680539f87 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeerTask.java @@ -74,13 +74,18 @@ public class GetBlockFromPeerTask extends AbstractPeerTask { .whenComplete( (r, t) -> { if (t != null) { - LOG.info( - "Failed to download block {} from peer {}.", + LOG.debug( + "Failed to download block {} from peer {} with message '{}' and cause '{}'", blockIdentifier, - assignedPeer.map(EthPeer::toString).orElse("")); + assignedPeer.map(EthPeer::toString).orElse(""), + t.getMessage(), + t.getCause()); result.completeExceptionally(t); } else if (r.getResult().isEmpty()) { - LOG.info("Failed to download block {} from peer {}.", blockIdentifier, r.getPeer()); + LOG.debug( + "Failed to download block {} from peer {} with empty result.", + blockIdentifier, + r.getPeer()); result.completeExceptionally(new IncompleteResultsException()); } else { LOG.debug( @@ -111,6 +116,7 @@ public class GetBlockFromPeerTask extends AbstractPeerTask { private CompletableFuture>> completeBlock( final PeerTaskResult> headerResult) { if (headerResult.getResult().isEmpty()) { + LOG.debug("header result is empty."); return CompletableFuture.failedFuture(new IncompleteResultsException()); } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java index 2b8c02c627..d0cf46408e 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java @@ -106,9 +106,11 @@ public class GetBodiesFromPeerTask extends AbstractPeerRequestTask> final List bodies = bodiesMessage.bodies(protocolSchedule); if (bodies.size() == 0) { // Message contains no data - nothing to do + LOG.debug("Message contains no data. Peer: {}", peer); return Optional.empty(); } else if (bodies.size() > headers.size()) { // Message doesn't match our request - nothing to do + LOG.debug("Message doesn't match our request. Peer: {}", peer); return Optional.empty(); } @@ -117,6 +119,7 @@ public class GetBodiesFromPeerTask extends AbstractPeerRequestTask> final List headers = bodyToHeaders.get(new BodyIdentifier(body)); if (headers == null) { // This message contains unrelated bodies - exit + LOG.debug("This message contains unrelated bodies. Peer: {}", peer); return Optional.empty(); } headers.forEach(h -> blocks.add(new Block(h, body)));