Skip to content

Commit 42cfadb

Browse files
author
Nicolás Tallar
authored
[CHORE] Disable blacklisting on testnet internal; better logging of blacklist reasons (#696)
1 parent 8298cb2 commit 42cfadb

File tree

3 files changed

+33
-25
lines changed

3 files changed

+33
-25
lines changed

src/main/scala/io/iohk/ethereum/network/PeerManagerActor.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ class PeerManagerActor(
120120

121121
def connections(pendingPeers: PeerMap, peers: PeerMap): Receive = {
122122
case PeerClosedConnection(peerAddress, reason) =>
123-
blacklist(PeerAddress(peerAddress), getBlacklistDuration(reason), "error during tcp connection attempt")
123+
blacklist(
124+
PeerAddress(peerAddress),
125+
getBlacklistDuration(reason),
126+
s"peer disconnected due to: ${Disconnect.reasonToString(reason)}"
127+
)
124128

125129
case HandlePeerConnection(connection, remoteAddress) =>
126130
handleConnection(connection, remoteAddress, pendingPeers, peers)

src/main/scala/io/iohk/ethereum/network/p2p/messages/WireProtocol.scala

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package io.iohk.ethereum.network.p2p.messages
22

33
import akka.util.ByteString
44
import io.iohk.ethereum.network.p2p.{Message, MessageSerializableImplicit}
5-
import io.iohk.ethereum.network.p2p.messages.WireProtocol.Disconnect.Reasons
65
import io.iohk.ethereum.rlp.RLPImplicitConversions._
76
import io.iohk.ethereum.rlp.RLPImplicits._
87
import io.iohk.ethereum.rlp._
@@ -92,6 +91,23 @@ object WireProtocol {
9291
val Other = 0x10
9392
}
9493

94+
def reasonToString(reasonCode: Long): String =
95+
reasonCode match {
96+
case Reasons.DisconnectRequested => "Disconnect requested"
97+
case Reasons.TcpSubsystemError => "TCP sub-system error"
98+
case Reasons.UselessPeer => "Useless peer"
99+
case Reasons.TooManyPeers => "Too many peers"
100+
case Reasons.AlreadyConnected => "Already connected"
101+
case Reasons.IncompatibleP2pProtocolVersion => "Incompatible P2P protocol version"
102+
case Reasons.NullNodeIdentityReceived => "Null node identity received - this is automatically invalid"
103+
case Reasons.ClientQuitting => "Client quitting"
104+
case Reasons.UnexpectedIdentity => "Unexpected identity"
105+
case Reasons.IdentityTheSame => "Identity is the same as this node"
106+
case Reasons.TimeoutOnReceivingAMessage => "Timeout on receiving a message"
107+
case Reasons.Other => "Some other reason specific to a subprotocol"
108+
case other => s"unknown reason code: $other"
109+
}
110+
95111
val code = 0x01
96112

97113
implicit class DisconnectEnc(val underlyingMsg: Disconnect) extends MessageSerializableImplicit[Disconnect](underlyingMsg) with RLPSerializable {
@@ -111,26 +127,9 @@ object WireProtocol {
111127
case class Disconnect(reason: Long) extends Message {
112128
override val code: Int = Disconnect.code
113129

114-
override def toString: String = {
115-
116-
val message = reason match {
117-
case Reasons.DisconnectRequested => "Disconnect requested"
118-
case Reasons.TcpSubsystemError => "TCP sub-system error"
119-
case Reasons.UselessPeer => "Useless peer"
120-
case Reasons.TooManyPeers => "Too many peers"
121-
case Reasons.AlreadyConnected => "Already connected"
122-
case Reasons.IncompatibleP2pProtocolVersion => "Incompatible P2P protocol version"
123-
case Reasons.NullNodeIdentityReceived => "Null node identity received - this is automatically invalid"
124-
case Reasons.ClientQuitting => "Client quitting"
125-
case Reasons.UnexpectedIdentity => "Unexpected identity"
126-
case Reasons.IdentityTheSame => "Identity is the same as this node"
127-
case Reasons.TimeoutOnReceivingAMessage => "Timeout on receiving a message"
128-
case Reasons.Other => "Some other reason specific to a subprotocol"
129-
case other => s"unknown reason code: $other"
130-
}
130+
override def toString: String =
131+
s"Disconnect(${Disconnect.reasonToString(reason)}"
131132

132-
s"Disconnect($message)"
133-
}
134133
}
135134

136135
object Ping {

src/universal/conf/testnet-internal.conf

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ include "app.conf"
22

33
mantis {
44
sync {
5-
# Whether to enable fast-sync
5+
# Fast sync is disabled as it's an experimental feature for now
66
do-fast-sync = false
77

8-
# Duration for blacklisting a peer. Blacklisting reason include: invalid response from peer, response time-out, etc.
9-
# 0 value is a valid duration and it will disable blacklisting completely (which can be useful when all nodes are
10-
# are controlled by a single party, eg. private networks)
8+
# All testnet members are assumed to be honest so blacklisting is turned off
119
blacklist-duration = 0
1210
}
1311

1412
pruning {
13+
# Pruning is disabled as it's an experimental feature for now
1514
mode = "archive"
1615
}
1716

@@ -34,6 +33,12 @@ mantis {
3433

3534
}
3635

36+
peer {
37+
# All testnet members are assumed to be honest so blacklisting is turned off
38+
short-blacklist-duration = 0
39+
long-blacklist-duration = 0
40+
}
41+
3742
rpc {
3843
http {
3944
# Listening address of JSON-RPC HTTP/HTTPS endpoint

0 commit comments

Comments
 (0)