Skip to content

Commit 5471b47

Browse files
committed
Merge remote-tracking branch 'origin/develop' into ETCM-165-separate-rlp-sbt-project
2 parents bc4a749 + b368808 commit 5471b47

39 files changed

+1418
-108
lines changed

src/it/scala/io/iohk/ethereum/sync/util/CommonFakePeer.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import io.iohk.ethereum.network.{
3232
KnownNodesManager,
3333
PeerEventBusActor,
3434
PeerManagerActor,
35+
PeerStatisticsActor,
3536
ServerActor
3637
}
3738
import io.iohk.ethereum.nodebuilder.PruningConfigBuilder
@@ -140,15 +141,20 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
140141
override val connectMaxRetries: Int = 3
141142
override val connectRetryDelay: FiniteDuration = 1 second
142143
override val disconnectPoisonPillTimeout: FiniteDuration = 3 seconds
144+
override val minOutgoingPeers = 5
143145
override val maxOutgoingPeers = 10
144146
override val maxIncomingPeers = 5
145147
override val maxPendingPeers = 5
148+
override val pruneIncomingPeers = 0
149+
override val minPruneAge = 1.minute
146150
override val networkId: Int = 1
147151

148152
override val updateNodesInitialDelay: FiniteDuration = 5.seconds
149153
override val updateNodesInterval: FiniteDuration = 20.seconds
150154
override val shortBlacklistDuration: FiniteDuration = 1.minute
151155
override val longBlacklistDuration: FiniteDuration = 3.minutes
156+
override val statSlotDuration: FiniteDuration = 1.minute
157+
override val statSlotCount: Int = 30
152158
}
153159

154160
lazy val peerEventBus = system.actorOf(PeerEventBusActor.props, "peer-event-bus")
@@ -167,12 +173,16 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
167173

168174
lazy val authHandshaker: AuthHandshaker = AuthHandshaker(nodeKey, secureRandom)
169175

176+
lazy val peerStatistics =
177+
system.actorOf(PeerStatisticsActor.props(peerEventBus, slotDuration = 1.minute, slotCount = 30))
178+
170179
lazy val peerManager: ActorRef = system.actorOf(
171180
PeerManagerActor.props(
172181
peerDiscoveryManager,
173182
Config.Network.peer,
174183
peerEventBus,
175184
knownNodesManager,
185+
peerStatistics,
176186
handshaker,
177187
authHandshaker,
178188
EthereumMessageDecoder,

src/it/scala/io/iohk/ethereum/txExecTest/util/DumpChainApp.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import io.iohk.ethereum.ledger.{InMemoryWorldStateProxy, InMemoryWorldStateProxy
1818
import io.iohk.ethereum.mpt.MptNode
1919
import io.iohk.ethereum.network.EtcPeerManagerActor.PeerInfo
2020
import io.iohk.ethereum.network.PeerManagerActor.PeerConfiguration
21+
import io.iohk.ethereum.network.PeerStatisticsActor
2122
import io.iohk.ethereum.network.discovery.DiscoveryConfig
2223
import io.iohk.ethereum.network.handshaker.{EtcHandshaker, EtcHandshakerConfiguration, Handshaker}
2324
import io.iohk.ethereum.network.p2p.EthereumMessageDecoder
@@ -52,14 +53,19 @@ object DumpChainApp extends App with NodeKeyBuilder with SecureRandomBuilder wit
5253
override val waitForChainCheckTimeout: FiniteDuration = Config.Network.peer.waitForChainCheckTimeout
5354
override val fastSyncHostConfiguration: PeerManagerActor.FastSyncHostConfiguration =
5455
Config.Network.peer.fastSyncHostConfiguration
56+
override val minOutgoingPeers: Int = Config.Network.peer.minOutgoingPeers
5557
override val maxOutgoingPeers: Int = Config.Network.peer.maxOutgoingPeers
5658
override val maxIncomingPeers: Int = Config.Network.peer.maxIncomingPeers
5759
override val maxPendingPeers: Int = Config.Network.peer.maxPendingPeers
60+
override val pruneIncomingPeers: Int = Config.Network.peer.pruneIncomingPeers
61+
override val minPruneAge: FiniteDuration = Config.Network.peer.minPruneAge
5862
override val networkId: Int = privateNetworkId
5963
override val updateNodesInitialDelay: FiniteDuration = 5.seconds
6064
override val updateNodesInterval: FiniteDuration = 20.seconds
6165
override val shortBlacklistDuration: FiniteDuration = 1.minute
6266
override val longBlacklistDuration: FiniteDuration = 3.minutes
67+
override val statSlotDuration: FiniteDuration = 1.minute
68+
override val statSlotCount: Int = 30
6369
}
6470

6571
val actorSystem = ActorSystem("mantis_system")
@@ -91,17 +97,20 @@ object DumpChainApp extends App with NodeKeyBuilder with SecureRandomBuilder wit
9197

9298
val peerMessageBus = actorSystem.actorOf(PeerEventBusActor.props)
9399

100+
val peerStatistics = actorSystem.actorOf(PeerStatisticsActor.props(peerMessageBus, 1.minute, 30))
101+
94102
val peerManager = actorSystem.actorOf(
95103
PeerManagerActor.props(
96104
peerDiscoveryManager = actorSystem.deadLetters, // TODO: fixme
97105
peerConfiguration = peerConfig,
98106
peerMessageBus = peerMessageBus,
107+
peerStatistics = peerStatistics,
99108
knownNodesManager = actorSystem.deadLetters, // TODO: fixme
100109
handshaker = handshaker,
101110
authHandshaker = authHandshaker,
102111
messageDecoder = EthereumMessageDecoder,
103-
discoveryConfig,
104-
Config.Network.protocolVersion
112+
discoveryConfig = discoveryConfig,
113+
bestProtocolVersion = Config.Network.protocolVersion
105114
),
106115
"peer-manager"
107116
)

src/main/resources/application.conf

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ mantis {
22
# Optionally augment the client ID sent in Hello messages.
33
client-identity = null
44

5-
# Version string (reported by an RPC method)
6-
client-version = "mantis/v2.0"
7-
85
# Base directory where all the data used by the node is stored, including blockchain data and private keys
96
datadir = ${user.home}"/.mantis/"${mantis.blockchains.network}
107

@@ -142,11 +139,22 @@ mantis {
142139
# Maximum MPT components in a single response message (as a blockchain host)
143140
max-mpt-components-per-message = 200
144141

145-
# Maximum number of peers this node can connect to
142+
# Minimum number of peers this node tries to connect to at all times
143+
min-outgoing-peers = 20
144+
145+
# Maximum number of peers this node can connect to at any time.
146+
# It's a bit higher than max-incoming-peers so that the node can quickly churn through incompatible peers after startup.
146147
max-outgoing-peers = 50
147148

148-
# Maximum number of peers that can connect to this node
149-
max-incoming-peers = 50
149+
# Maximum number of peers that can connect to this node.
150+
# Should be at least as much as `min-outgoing-peers` so on a network level `total(max-in) >= total(min-out)`
151+
max-incoming-peers = 30
152+
153+
# Number of incoming peers to prune if we hit the maximum, to free up slots for new connections.
154+
prune-incoming-peers = 10
155+
156+
# Minimum age of peers before they can be selected for pruning, and the minimum time to pass between pruning attempts.
157+
min-prune-age = 30.minutes
150158

151159
# Maximum number of peers that can be connecting to this node
152160
max-pending-peers = 20
@@ -163,6 +171,13 @@ mantis {
163171
# Peer which disconnect during tcp connection becouse of other reasons will not be retried for this long duration
164172
# other reasons include: timeout during connection, wrong protocol, incompatible network
165173
long-blacklist-duration = 30.minutes
174+
175+
# Resolution of moving window of peer statistics.
176+
# Will be multiplied by `stat-slot-count` to give the overall length of peer statistics availability.
177+
stat-slot-duration = 10.minutes
178+
179+
# How many slots of peer statistics to keep in the moving window, e.g. 60 * 1.minute to keep stats for the last hour with 1 minute resolution.
180+
stat-slot-count = 72
166181
}
167182

168183
rpc {
@@ -605,7 +620,8 @@ mantis {
605620

606621
akka {
607622
loggers = ["akka.event.slf4j.Slf4jLogger"]
608-
loglevel = "DEBUG"
623+
# Not using ${logging.logs-level} because it might be set to TRACE, which our version of Akka doesn't have.
624+
loglevel = "INFO"
609625
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
610626
logger-startup-timeout = 30s
611627
log-dead-letters = off
@@ -659,4 +675,7 @@ logging {
659675

660676
# Logs filename
661677
logs-file = "mantis"
678+
679+
# Logs level
680+
logs-level = "INFO"
662681
}

src/main/resources/logback.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<load key="logging.json-output" as="ASJSON"/>
99
<load key="logging.logs-dir" as="LOGSDIR"/>
1010
<load key="logging.logs-file" as="LOGSFILENAME"/>
11+
<load key="logging.logs-level" as="LOGSLEVEL"/>
1112

1213
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
1314
<encoder>
@@ -43,7 +44,7 @@
4344

4445
<appender name="METRICS" class="io.prometheus.client.logback.InstrumentedAppender" />
4546

46-
<root level="DEBUG">
47+
<root level="${LOGSLEVEL}">
4748
<if condition='p("ASJSON").contains("true")'>
4849
<then>
4950
<appender-ref ref="STASH" />
@@ -58,9 +59,9 @@
5859

5960
<logger name="io.netty" level="WARN"/>
6061
<logger name="io.iohk.scalanet" level="INFO" />
61-
<logger name="io.iohk.ethereum.network.rlpx.RLPxConnectionHandler" level="DEBUG" />
6262
<logger name="io.iohk.ethereum.blockchain.sync.SyncController" level="INFO" />
63-
<logger name="io.iohk.ethereum.network.PeerActor" level="DEBUG" />
63+
<logger name="io.iohk.ethereum.network.PeerActor" level="${LOGSLEVEL}" />
64+
<logger name="io.iohk.ethereum.network.rlpx.RLPxConnectionHandler" level="${LOGSLEVEL}" />
6465
<logger name="io.iohk.ethereum.vm.VM" level="OFF" />
6566

6667
</configuration>

src/main/scala/io/iohk/ethereum/domain/BlockBody.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ case class BlockBody(transactionList: Seq[SignedTransaction], uncleNodesList: Se
77
override def toString: String =
88
s"BlockBody{ transactionList: $transactionList, uncleNodesList: $uncleNodesList }"
99

10+
def toShortString: String =
11+
s"BlockBody { transactionsList: ${transactionList.map(_.hashAsHexString)}, uncleNodesList: ${uncleNodesList.map(_.hashAsHexString)} }"
12+
1013
lazy val numberOfTxs: Int = transactionList.size
1114

1215
lazy val numberOfUncles: Int = uncleNodesList.size

src/main/scala/io/iohk/ethereum/domain/TransactionOutcome.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package io.iohk.ethereum.domain
22

33
import akka.util.ByteString
44

5-
trait TransactionOutcome
5+
sealed trait TransactionOutcome
66

77
case class HashOutcome(stateHash: ByteString) extends TransactionOutcome
88

src/main/scala/io/iohk/ethereum/faucet/FaucetConfig.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ case class FaucetConfig(
3434
txValue: BigInt,
3535
rpcClient: RpcClientConfig,
3636
keyStoreDir: String,
37-
minRequestInterval: FiniteDuration,
3837
handlerTimeout: FiniteDuration,
3938
actorCommunicationMargin: FiniteDuration,
4039
supervisor: SupervisorConfig,
@@ -52,7 +51,6 @@ object FaucetConfig {
5251
txValue = faucetConfig.getLong("tx-value"),
5352
rpcClient = RpcClientConfig(faucetConfig.getConfig("rpc-client")),
5453
keyStoreDir = faucetConfig.getString("keystore-dir"),
55-
minRequestInterval = faucetConfig.getDuration("min-request-interval").toMillis.millis,
5654
handlerTimeout = faucetConfig.getDuration("handler-timeout").toMillis.millis,
5755
actorCommunicationMargin = faucetConfig.getDuration("actor-communication-margin").toMillis.millis,
5856
supervisor = SupervisorConfig(faucetConfig),

src/main/scala/io/iohk/ethereum/jsonrpc/EthService.scala

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import io.iohk.ethereum.consensus.blocks.PendingBlockAndState
1111
import io.iohk.ethereum.consensus.ethash.EthashUtils
1212
import io.iohk.ethereum.crypto._
1313
import io.iohk.ethereum.db.storage.TransactionMappingStorage.TransactionLocation
14-
import io.iohk.ethereum.domain.{BlockHeader, SignedTransaction, UInt256, _}
14+
import io.iohk.ethereum.domain.{BlockHeader, SignedTransaction, _}
1515
import io.iohk.ethereum.jsonrpc.AkkaTaskOps._
16-
import io.iohk.ethereum.jsonrpc.FilterManager.{FilterChanges, FilterLogs, LogFilterLogs, TxLog}
16+
import io.iohk.ethereum.jsonrpc.FilterManager.{FilterChanges, FilterLogs, LogFilterLogs}
1717
import io.iohk.ethereum.jsonrpc.server.controllers.JsonRpcBaseController.JsonRpcConfig
1818
import io.iohk.ethereum.jsonrpc.{FilterManager => FM}
1919
import io.iohk.ethereum.keystore.KeyStore
@@ -24,7 +24,6 @@ import io.iohk.ethereum.rlp
2424
import io.iohk.ethereum.rlp.RLPImplicitConversions._
2525
import io.iohk.ethereum.rlp.RLPImplicits._
2626
import io.iohk.ethereum.rlp.RLPList
27-
import io.iohk.ethereum.rlp.UInt256RLPImplicits._
2827
import io.iohk.ethereum.transactions.PendingTransactionsManager
2928
import io.iohk.ethereum.transactions.PendingTransactionsManager.{PendingTransaction, PendingTransactionsResponse}
3029
import io.iohk.ethereum.utils._
@@ -346,39 +345,22 @@ class EthService(
346345
stx <- body.transactionList.lift(txIndex)
347346
receipts <- blockchain.getReceiptsByHash(blockHash)
348347
receipt: Receipt <- receipts.lift(txIndex)
348+
// another possibility would be to throw an exception and fail hard, as if we cannot calculate sender for transaction
349+
// included in blockchain it means that something is terribly wrong
350+
sender <- SignedTransaction.getSender(stx)
349351
} yield {
350-
// safe to call get as we are geting saved transaction with receipt (sender was proper formed)
351-
val sender = SignedTransaction.getSender(stx)
352-
val contractAddress = if (stx.tx.isContractInit && sender.isDefined) {
353-
//do not subtract 1 from nonce because in transaction we have nonce of account before transaction execution
354-
val hash = kec256(rlp.encode(RLPList(sender.get.bytes, UInt256(stx.tx.nonce).toRLPEncodable)))
355-
Some(Address(hash))
356-
} else {
357-
None
358-
}
352+
353+
val gasUsed =
354+
if (txIndex == 0) receipt.cumulativeGasUsed
355+
else receipt.cumulativeGasUsed - receipts(txIndex - 1).cumulativeGasUsed
359356

360357
TransactionReceiptResponse(
361-
transactionHash = stx.hash,
358+
receipt = receipt,
359+
stx = stx,
360+
signedTransactionSender = sender,
362361
transactionIndex = txIndex,
363-
blockNumber = header.number,
364-
blockHash = header.hash,
365-
cumulativeGasUsed = receipt.cumulativeGasUsed,
366-
gasUsed =
367-
if (txIndex == 0) receipt.cumulativeGasUsed
368-
else receipt.cumulativeGasUsed - receipts(txIndex - 1).cumulativeGasUsed,
369-
contractAddress = contractAddress,
370-
logs = receipt.logs.zipWithIndex.map { case (txLog, index) =>
371-
TxLog(
372-
logIndex = index,
373-
transactionIndex = txIndex,
374-
transactionHash = stx.hash,
375-
blockHash = header.hash,
376-
blockNumber = header.number,
377-
address = txLog.loggerAddress,
378-
data = txLog.data,
379-
topics = txLog.logTopics
380-
)
381-
}
362+
blockHeader = header,
363+
gasUsedByTransaction = gasUsed
382364
)
383365
}
384366

0 commit comments

Comments
 (0)