[NC-1675] Apply more appropriate log levels (#133)

Reduce log level for a number of common situations to DEBUG and general tidy-up of output.
Adrian Sutton 6 years ago committed by GitHub
parent 78a002b53d
commit c9fbc9d3fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/AbstractRetryingPeerTask.java
  2. 7
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthProtocolManager.java
  3. 4
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/PeerReputation.java
  4. 12
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/Downloader.java
  5. 9
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/DetermineCommonAncestorTask.java
  6. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/GetHeadersFromPeerByNumberTask.java
  7. 5
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PipelinedImportChainSegmentTask.java
  8. 2
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/netty/AbstractHandshakeHandler.java
  9. 6
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/netty/ApiHandler.java
  10. 17
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/netty/DeFramer.java
  11. 9
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java

@ -84,7 +84,7 @@ public abstract class AbstractRetryingPeerTask<T> extends AbstractEthTask<T> {
return; return;
} }
LOG.info( LOG.debug(
"Retrying after recoverable failure from peer task {}: {}", "Retrying after recoverable failure from peer task {}: {}",
this.getClass().getSimpleName(), this.getClass().getSimpleName(),
cause.getMessage()); cause.getMessage());

@ -146,7 +146,8 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
LOG.trace("Process message {}, {}", cap, message.getData().getCode()); LOG.trace("Process message {}, {}", cap, message.getData().getCode());
final EthPeer peer = ethPeers.peer(message.getConnection()); final EthPeer peer = ethPeers.peer(message.getConnection());
if (peer == null) { if (peer == null) {
LOG.error("Message received from unknown peer connection: " + message.getConnection()); LOG.debug(
"Ignoring message received from unknown peer connection: " + message.getConnection());
return; return;
} }
@ -229,7 +230,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
LOG.debug("Disconnecting from peer with mismatched network id: {}", status.networkId()); LOG.debug("Disconnecting from peer with mismatched network id: {}", status.networkId());
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);
} else if (!status.genesisHash().equals(genesisHash)) { } else if (!status.genesisHash().equals(genesisHash)) {
LOG.warn( LOG.debug(
"Disconnecting from peer with matching network id ({}), but non-matching genesis hash: {}", "Disconnecting from peer with matching network id ({}), but non-matching genesis hash: {}",
networkId, networkId,
status.genesisHash()); status.genesisHash());
@ -239,7 +240,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
peer.registerStatusReceived(status.bestHash(), status.totalDifficulty()); peer.registerStatusReceived(status.bestHash(), status.totalDifficulty());
} }
} catch (final RLPException e) { } catch (final RLPException e) {
LOG.info("Unable to parse status message, disconnecting from peer."); LOG.debug("Unable to parse status message, disconnecting from peer.", e);
// Parsing errors can happen when clients broadcast network ids outside of the int range, // Parsing errors can happen when clients broadcast network ids outside of the int range,
// So just disconnect with "subprotocol" error rather than "breach of protocol". // So just disconnect with "subprotocol" error rather than "breach of protocol".
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);

@ -41,7 +41,7 @@ public class PeerReputation {
public Optional<DisconnectReason> recordRequestTimeout(final int requestCode) { public Optional<DisconnectReason> recordRequestTimeout(final int requestCode) {
final int newTimeoutCount = getOrCreateTimeoutCount(requestCode).incrementAndGet(); final int newTimeoutCount = getOrCreateTimeoutCount(requestCode).incrementAndGet();
if (newTimeoutCount >= TIMEOUT_THRESHOLD) { if (newTimeoutCount >= TIMEOUT_THRESHOLD) {
LOG.info("Disconnection triggered by repeated timeouts"); LOG.debug("Disconnection triggered by repeated timeouts");
return Optional.of(DisconnectReason.TIMEOUT); return Optional.of(DisconnectReason.TIMEOUT);
} else { } else {
return Optional.empty(); return Optional.empty();
@ -66,7 +66,7 @@ public class PeerReputation {
uselessResponseTimes.poll(); uselessResponseTimes.poll();
} }
if (uselessResponseTimes.size() >= USELESS_RESPONSE_THRESHOLD) { if (uselessResponseTimes.size() >= USELESS_RESPONSE_THRESHOLD) {
LOG.info("Disconnection triggered by exceeding useless response threshold"); LOG.debug("Disconnection triggered by exceeding useless response threshold");
return Optional.of(DisconnectReason.USELESS_PEER); return Optional.of(DisconnectReason.USELESS_PEER);
} else { } else {
return Optional.empty(); return Optional.empty();

@ -42,6 +42,7 @@ import java.util.Collections;
import java.util.Deque; import java.util.Deque;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
@ -103,7 +104,14 @@ public class Downloader<C> {
.whenComplete( .whenComplete(
(r, t) -> { (r, t) -> {
if (t != null) { if (t != null) {
final Throwable rootCause = ExceptionUtils.rootCause(t);
if (rootCause instanceof CancellationException) {
LOG.trace("Download cancelled", t);
} else if (rootCause instanceof InvalidBlockException) {
LOG.debug("Invalid block downloaded", t);
} else {
LOG.error("Error encountered while downloading", t); LOG.error("Error encountered while downloading", t);
}
// On error, wait a bit before retrying // On error, wait a bit before retrying
ethContext ethContext
.getScheduler() .getScheduler()
@ -160,8 +168,8 @@ public class Downloader<C> {
return waitForPeerAndThenSetSyncTarget(); return waitForPeerAndThenSetSyncTarget();
} }
final SyncTarget syncTarget = syncState.setSyncTarget(bestPeer, target); final SyncTarget syncTarget = syncState.setSyncTarget(bestPeer, target);
LOG.info("Found common ancestor with sync target at block {}", target.getNumber()); LOG.info(
LOG.info("Set sync target: {}.", syncTarget); "Found common ancestor with peer {} at block {}", bestPeer, target.getNumber());
syncTargetDisconnectListenerId = syncTargetDisconnectListenerId =
bestPeer.subscribeDisconnect(this::onSyncTargetPeerDisconnect); bestPeer.subscribeDisconnect(this::onSyncTargetPeerDisconnect);
return CompletableFuture.completedFuture(syncTarget); return CompletableFuture.completedFuture(syncTarget);

@ -26,8 +26,11 @@ import java.util.OptionalInt;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class DetermineCommonAncestorTask<C> extends AbstractEthTask<BlockHeader> { public class DetermineCommonAncestorTask<C> extends AbstractEthTask<BlockHeader> {
private static final Logger LOG = LogManager.getLogger();
private final EthContext ethContext; private final EthContext ethContext;
private final ProtocolSchedule<C> protocolSchedule; private final ProtocolSchedule<C> protocolSchedule;
private final ProtocolContext<C> protocolContext; private final ProtocolContext<C> protocolContext;
@ -97,7 +100,11 @@ public class DetermineCommonAncestorTask<C> extends AbstractEthTask<BlockHeader>
final int skipInterval = initialQuery ? 0 : calculateSkipInterval(range, headerRequestSize); final int skipInterval = initialQuery ? 0 : calculateSkipInterval(range, headerRequestSize);
final int count = final int count =
initialQuery ? headerRequestSize : calculateCount((double) range, skipInterval); initialQuery ? headerRequestSize : calculateCount((double) range, skipInterval);
LOG.debug(
"Searching for common ancestor with {} between {} and {}",
peer,
minimumPossibleCommonAncestorNumber,
maximumPossibleCommonAncestorNumber);
return executeSubTask( return executeSubTask(
() -> () ->
GetHeadersFromPeerByNumberTask.endingAtNumber( GetHeadersFromPeerByNumberTask.endingAtNumber(

@ -79,7 +79,7 @@ public class GetHeadersFromPeerByNumberTask extends AbstractGetHeadersFromPeerTa
@Override @Override
protected ResponseStream sendRequest(final EthPeer peer) throws PeerNotConnected { protected ResponseStream sendRequest(final EthPeer peer) throws PeerNotConnected {
LOG.info("Requesting {} headers from peer {}.", count, peer); LOG.debug("Requesting {} headers from peer {}.", count, peer);
return peer.getHeadersByNumber(blockNumber, count, reverse, skip); return peer.getHeadersByNumber(blockNumber, count, reverse, skip);
} }

@ -23,6 +23,7 @@ import tech.pegasys.pantheon.ethereum.mainnet.BlockHeaderValidator;
import tech.pegasys.pantheon.ethereum.mainnet.HeaderValidationMode; import tech.pegasys.pantheon.ethereum.mainnet.HeaderValidationMode;
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule; import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule;
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSpec; import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSpec;
import tech.pegasys.pantheon.util.ExceptionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -147,8 +148,8 @@ public class PipelinedImportChainSegmentTask<C> extends AbstractEthTask<List<Blo
LOG.warn( LOG.warn(
"Import of chain segment ({} to {}) failed: {}.", "Import of chain segment ({} to {}) failed: {}.",
firstHeader().getNumber(), firstHeader().getNumber(),
lastHeader().getNumber()); lastHeader().getNumber(),
LOG.error("Error", throwable); ExceptionUtils.rootCause(throwable).getMessage());
result.get().completeExceptionally(throwable); result.get().completeExceptionally(throwable);
} else { } else {
importedBlocks.addAll(blocks); importedBlocks.addAll(blocks);

@ -122,7 +122,7 @@ abstract class AbstractHandshakeHandler extends SimpleChannelInboundHandler<Byte
@Override @Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable throwable) { public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable throwable) {
LOG.warn("Handshake error:", throwable.getMessage()); LOG.debug("Handshake error:", throwable);
connectionFuture.completeExceptionally(throwable); connectionFuture.completeExceptionally(throwable);
ctx.close(); ctx.close();
} }

@ -82,10 +82,8 @@ final class ApiHandler extends SimpleChannelInboundHandler<MessageData> {
reason.name(), reason.name(),
connection.getPeer().getClientId()); connection.getPeer().getClientId());
} catch (final RLPException e) { } catch (final RLPException e) {
// It seems pretty common to get disconnect messages with no reason, which results in an LOG.debug(
// rlp parsing error "Received Wire DISCONNECT with invalid RLP. Peer: {}",
LOG.warn(
"Received Wire DISCONNECT, but unable to parse reason. Peer: {}",
connection.getPeer().getClientId()); connection.getPeer().getClientId());
} catch (final Exception e) { } catch (final Exception e) {
LOG.error( LOG.error(

@ -21,7 +21,9 @@ import tech.pegasys.pantheon.ethereum.p2p.wire.SubProtocol;
import tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage.DisconnectReason; import tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage.DisconnectReason;
import tech.pegasys.pantheon.ethereum.p2p.wire.messages.HelloMessage; import tech.pegasys.pantheon.ethereum.p2p.wire.messages.HelloMessage;
import tech.pegasys.pantheon.ethereum.p2p.wire.messages.WireMessageCodes; import tech.pegasys.pantheon.ethereum.p2p.wire.messages.WireMessageCodes;
import tech.pegasys.pantheon.ethereum.rlp.RLPException;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@ -67,7 +69,15 @@ final class DeFramer extends ByteToMessageDecoder {
if (!hellosExchanged && message.getCode() == WireMessageCodes.HELLO) { if (!hellosExchanged && message.getCode() == WireMessageCodes.HELLO) {
hellosExchanged = true; hellosExchanged = true;
// Decode first hello and use the payload to modify pipeline // Decode first hello and use the payload to modify pipeline
final PeerInfo peerInfo = parsePeerInfo(message); final PeerInfo peerInfo;
try {
peerInfo = parsePeerInfo(message);
} catch (final RLPException e) {
LOG.debug("Received invalid HELLO message", e);
connectFuture.completeExceptionally(e);
ctx.close();
return;
}
message.release(); message.release();
LOG.debug("Received HELLO message: {}", peerInfo); LOG.debug("Received HELLO message: {}", peerInfo);
if (peerInfo.getVersion() >= 5) { if (peerInfo.getVersion() >= 5) {
@ -115,7 +125,12 @@ final class DeFramer extends ByteToMessageDecoder {
@Override @Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable throwable) public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable throwable)
throws Exception { throws Exception {
if (throwable instanceof IOException) {
// IO failures are routine when communicating with random peers across the network.
LOG.debug("IO error while processing incoming message", throwable);
} else {
LOG.error("Exception while processing incoming message", throwable); LOG.error("Exception while processing incoming message", throwable);
}
if (connectFuture.isDone()) { if (connectFuture.isDone()) {
connectFuture.get().terminateConnection(DisconnectReason.TCP_SUBSYSTEM_ERROR, false); connectFuture.get().terminateConnection(DisconnectReason.TCP_SUBSYSTEM_ERROR, false);
} else { } else {

@ -21,9 +21,6 @@ import tech.pegasys.pantheon.util.bytes.BytesValues;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Objects; import java.util.Objects;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/** /**
* Represents a client capability. * Represents a client capability.
* *
@ -32,16 +29,10 @@ import org.apache.logging.log4j.Logger;
* format</a> * format</a>
*/ */
public class Capability { public class Capability {
private static final Logger LOG = LogManager.getLogger();
private final String name; private final String name;
private final int version; private final int version;
private Capability(final String name, final int version) { private Capability(final String name, final int version) {
// Quorum reports IBFT as "istanbul", breaking wire protocol conventions.
// As such, this check cannot prevent connection.
if (name.length() != 3) {
LOG.warn("Capability name '{}' is too long", name);
}
this.name = name; this.name = name;
this.version = version; this.version = version;
} }

Loading…
Cancel
Save