Clean Up P2P Debug Logging (#2093)

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
pull/2099/head
Ratan (Rai) Sur 4 years ago committed by GitHub
parent 3d4a2974ff
commit 901b0a1e00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeer.java
  2. 29
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java
  3. 2
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnection.java
  4. 4
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/AbstractHandshakeHandler.java
  5. 4
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/ApiHandler.java
  6. 2
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramer.java

@ -416,7 +416,7 @@ public class EthPeer {
@Override @Override
public String toString() { public String toString() {
return nodeId().toString().substring(0, 20) + "..."; return String.format("Peer %s...", nodeId().toString().substring(0, 20));
} }
@FunctionalInterface @FunctionalInterface

@ -302,36 +302,31 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
final DisconnectReason reason, final DisconnectReason reason,
final boolean initiatedByPeer) { final boolean initiatedByPeer) {
ethPeers.registerDisconnect(connection); ethPeers.registerDisconnect(connection);
if (initiatedByPeer) { LOG.debug(
LOG.debug( "Disconnect - {} - {} - {} - {} peers left",
"Peer requested to be disconnected ({}), {} peers left: {}", initiatedByPeer ? "Inbound" : "Outbound",
reason, reason,
ethPeers.peerCount(), connection.getPeerInfo(),
ethPeers); ethPeers.peerCount());
} else {
LOG.debug(
"Disconnecting from peer ({}), {} peers left: {}",
reason,
ethPeers.peerCount(),
ethPeers);
}
} }
private void handleStatusMessage(final EthPeer peer, final MessageData data) { private void handleStatusMessage(final EthPeer peer, final MessageData data) {
final StatusMessage status = StatusMessage.readFrom(data); final StatusMessage status = StatusMessage.readFrom(data);
try { try {
if (!status.networkId().equals(networkId)) { if (!status.networkId().equals(networkId)) {
LOG.debug("Disconnecting from peer with mismatched network id: {}", status.networkId()); LOG.debug("{} has mismatched network id: {}", peer, status.networkId());
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);
} else if (!forkIdManager.peerCheck(status.forkId()) && status.protocolVersion() > 63) { } else if (!forkIdManager.peerCheck(status.forkId()) && status.protocolVersion() > 63) {
LOG.debug( LOG.debug(
"Disconnecting from peer with matching network id ({}), but non-matching fork id: {}", "{} has matching network id ({}), but non-matching fork id: {}",
peer,
networkId, networkId,
status.forkId()); status.forkId());
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);
} else if (forkIdManager.peerCheck(status.genesisHash())) { } else if (forkIdManager.peerCheck(status.genesisHash())) {
LOG.debug( LOG.debug(
"Disconnecting from peer with matching network id ({}), but non-matching genesis hash: {}", "{} has matching network id ({}), but non-matching genesis hash: {}",
peer,
networkId, networkId,
status.genesisHash()); status.genesisHash());
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);
@ -341,7 +336,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
status.bestHash(), status.totalDifficulty(), status.protocolVersion()); status.bestHash(), status.totalDifficulty(), status.protocolVersion());
} }
} catch (final RLPException e) { } catch (final RLPException e) {
LOG.debug("Unable to parse status message, disconnecting from peer.", e); LOG.debug("Unable to parse status message.", 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);

@ -142,7 +142,6 @@ public abstract class AbstractPeerConnection implements PeerConnection {
@Override @Override
public void terminateConnection(final DisconnectReason reason, final boolean peerInitiated) { public void terminateConnection(final DisconnectReason reason, final boolean peerInitiated) {
if (disconnected.compareAndSet(false, true)) { if (disconnected.compareAndSet(false, true)) {
LOG.debug("Disconnected ({}) from {}", reason, peerInfo);
connectionEventDispatcher.dispatchDisconnect(this, reason, peerInitiated); connectionEventDispatcher.dispatchDisconnect(this, reason, peerInitiated);
} }
// Always ensure the context gets closed immediately even if we previously sent a disconnect // Always ensure the context gets closed immediately even if we previously sent a disconnect
@ -157,7 +156,6 @@ public abstract class AbstractPeerConnection implements PeerConnection {
@Override @Override
public void disconnect(final DisconnectReason reason) { public void disconnect(final DisconnectReason reason) {
if (disconnected.compareAndSet(false, true)) { if (disconnected.compareAndSet(false, true)) {
LOG.debug("Disconnecting ({}) from {}", reason, peerInfo);
connectionEventDispatcher.dispatchDisconnect(this, reason, false); connectionEventDispatcher.dispatchDisconnect(this, reason, false);
doSend(null, DisconnectMessage.create(reason)); doSend(null, DisconnectMessage.create(reason));
closeConnection(); closeConnection();

@ -97,7 +97,7 @@ abstract class AbstractHandshakeHandler extends SimpleChannelInboundHandler<Byte
return; return;
} }
LOG.debug("Sending framed hello"); LOG.trace("Sending framed hello");
// Exchange keys done // Exchange keys done
final Framer framer = new Framer(handshaker.secrets()); final Framer framer = new Framer(handshaker.secrets());
@ -121,7 +121,7 @@ abstract class AbstractHandshakeHandler extends SimpleChannelInboundHandler<Byte
.addListener( .addListener(
ff -> { ff -> {
if (ff.isSuccess()) { if (ff.isSuccess()) {
LOG.debug("Successfully wrote hello message"); LOG.trace("Successfully wrote hello message");
} }
}); });
msg.retain(); msg.retain();

@ -79,12 +79,12 @@ final class ApiHandler extends SimpleChannelInboundHandler<MessageData> {
DisconnectMessage.DisconnectReason reason = DisconnectMessage.DisconnectReason.UNKNOWN; DisconnectMessage.DisconnectReason reason = DisconnectMessage.DisconnectReason.UNKNOWN;
try { try {
reason = disconnect.getReason(); reason = disconnect.getReason();
LOG.debug( LOG.trace(
"Received Wire DISCONNECT ({}) from peer: {}", "Received Wire DISCONNECT ({}) from peer: {}",
reason.name(), reason.name(),
connection.getPeerInfo()); connection.getPeerInfo());
} catch (final RLPException e) { } catch (final RLPException e) {
LOG.debug( LOG.trace(
"Received Wire DISCONNECT with invalid RLP. Peer: {}", connection.getPeerInfo()); "Received Wire DISCONNECT with invalid RLP. Peer: {}", connection.getPeerInfo());
} catch (final Exception e) { } catch (final Exception e) {
LOG.error( LOG.error(

@ -116,7 +116,7 @@ final class DeFramer extends ByteToMessageDecoder {
} }
LOG.debug("Received HELLO message: {}", peerInfo); LOG.debug("Received HELLO message: {}", peerInfo);
if (peerInfo.getVersion() >= 5) { if (peerInfo.getVersion() >= 5) {
LOG.debug("Enable compression for p2pVersion: {}", peerInfo.getVersion()); LOG.trace("Enable compression for p2pVersion: {}", peerInfo.getVersion());
framer.enableCompression(); framer.enableCompression();
} }

Loading…
Cancel
Save