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
public String toString() {
return nodeId().toString().substring(0, 20) + "...";
return String.format("Peer %s...", nodeId().toString().substring(0, 20));
}
@FunctionalInterface

@ -302,36 +302,31 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
final DisconnectReason reason,
final boolean initiatedByPeer) {
ethPeers.registerDisconnect(connection);
if (initiatedByPeer) {
LOG.debug(
"Peer requested to be disconnected ({}), {} peers left: {}",
reason,
ethPeers.peerCount(),
ethPeers);
} else {
LOG.debug(
"Disconnecting from peer ({}), {} peers left: {}",
reason,
ethPeers.peerCount(),
ethPeers);
}
LOG.debug(
"Disconnect - {} - {} - {} - {} peers left",
initiatedByPeer ? "Inbound" : "Outbound",
reason,
connection.getPeerInfo(),
ethPeers.peerCount());
}
private void handleStatusMessage(final EthPeer peer, final MessageData data) {
final StatusMessage status = StatusMessage.readFrom(data);
try {
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);
} else if (!forkIdManager.peerCheck(status.forkId()) && status.protocolVersion() > 63) {
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,
status.forkId());
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);
} else if (forkIdManager.peerCheck(status.genesisHash())) {
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,
status.genesisHash());
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);
@ -341,7 +336,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
status.bestHash(), status.totalDifficulty(), status.protocolVersion());
}
} 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,
// So just disconnect with "subprotocol" error rather than "breach of protocol".
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);

@ -142,7 +142,6 @@ public abstract class AbstractPeerConnection implements PeerConnection {
@Override
public void terminateConnection(final DisconnectReason reason, final boolean peerInitiated) {
if (disconnected.compareAndSet(false, true)) {
LOG.debug("Disconnected ({}) from {}", reason, peerInfo);
connectionEventDispatcher.dispatchDisconnect(this, reason, peerInitiated);
}
// 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
public void disconnect(final DisconnectReason reason) {
if (disconnected.compareAndSet(false, true)) {
LOG.debug("Disconnecting ({}) from {}", reason, peerInfo);
connectionEventDispatcher.dispatchDisconnect(this, reason, false);
doSend(null, DisconnectMessage.create(reason));
closeConnection();

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

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

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

Loading…
Cancel
Save