Skip to content

Commit c615718

Browse files
committed
[CHORE] Update akka (v2.6.9), akka http (v10.2.0)
1 parent 07393db commit c615718

File tree

16 files changed

+38
-60
lines changed

16 files changed

+38
-60
lines changed

build.sbt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ val commonSettings = Seq(
1111
resolvers += "rocksDb" at "https://dl.bintray.com/ethereum/maven/"
1212

1313
val dep = {
14-
val akkaVersion = "2.5.31"
15-
val akkaHttpVersion = "10.1.12"
14+
val akkaVersion = "2.6.9"
15+
val akkaHttpVersion = "10.2.0"
1616
val circeVersion = "0.9.3"
1717
val rocksDb = "5.9.2"
1818

@@ -22,9 +22,9 @@ val dep = {
2222
"com.typesafe.akka" %% "akka-testkit" % akkaVersion,
2323
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
2424
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
25-
"ch.megard" %% "akka-http-cors" % "1.0.0",
25+
"ch.megard" %% "akka-http-cors" % "1.1.0",
2626
"org.json4s" %% "json4s-native" % "3.5.4",
27-
"de.heikoseeberger" %% "akka-http-json4s" % "1.21.0",
27+
"de.heikoseeberger" %% "akka-http-json4s" % "1.34.0",
2828
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % "it,test",
2929
"io.suzaku" %% "boopickle" % "1.3.0",
3030
"org.ethereum" % "rocksdbjni" % rocksDb,
@@ -38,7 +38,7 @@ val dep = {
3838
"io.circe" %% "circe-generic" % circeVersion,
3939
"io.circe" %% "circe-parser" % circeVersion,
4040
"io.circe" %% "circe-generic-extras" % circeVersion,
41-
"com.miguno.akka" %% "akka-mock-scheduler" % "0.5.1" % "it,test",
41+
"com.miguno.akka" %% "akka-mock-scheduler" % "0.5.5" % "it,test",
4242
"commons-io" % "commons-io" % "2.6",
4343
"org.scala-sbt.ipcsocket" % "ipcsocket" % "1.0.0",
4444
"org.bouncycastle" % "bcprov-jdk15on" % "1.59",
@@ -50,7 +50,6 @@ val dep = {
5050
// mallet deps
5151
"org.jline" % "jline" % "3.1.2",
5252
"net.java.dev.jna" % "jna" % "4.5.1",
53-
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.5",
5453
"com.github.scopt" %% "scopt" % "3.7.0",
5554

5655
// Metrics (https://github.com/DataDog/java-dogstatsd-client)

src/main/scala/io/iohk/ethereum/blockchain/sync/FastSync.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ class FastSync(
117117

118118
//Delay before starting to persist snapshot. It should be 0, as the presence of it marks that fast sync was started
119119
private val persistStateSnapshotDelay: FiniteDuration = 0.seconds
120-
private val syncStatePersistCancellable = scheduler.schedule(persistStateSnapshotDelay, persistStateSnapshotInterval, self, PersistSyncState)
121-
private val printStatusCancellable = scheduler.schedule(printStatusInterval, printStatusInterval, self, PrintStatus)
122-
private val heartBeat = scheduler.schedule(syncRetryInterval, syncRetryInterval * 2, self, ProcessSyncing)
120+
private val syncStatePersistCancellable = scheduler.scheduleWithFixedDelay(persistStateSnapshotDelay, persistStateSnapshotInterval, self, PersistSyncState)
121+
private val printStatusCancellable = scheduler.scheduleWithFixedDelay(printStatusInterval, printStatusInterval, self, PrintStatus)
122+
private val heartBeat = scheduler.scheduleWithFixedDelay(syncRetryInterval, syncRetryInterval * 2, self, ProcessSyncing)
123123

124124
def receive: Receive = handleCommonMessages orElse {
125125
case UpdateTargetBlock(state) => updateTargetBlock(state)

src/main/scala/io/iohk/ethereum/blockchain/sync/PeerListSupport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ trait PeerListSupport {
2222

2323
var handshakedPeers: PeersMap = Map.empty
2424

25-
scheduler.schedule(0.seconds, syncConfig.peersScanInterval, etcPeerManager, EtcPeerManagerActor.GetHandshakedPeers)(global, context.self)
25+
scheduler.scheduleWithFixedDelay(0.seconds, syncConfig.peersScanInterval, etcPeerManager, EtcPeerManagerActor.GetHandshakedPeers)(global, context.self)
2626

2727
def removePeer(peerId: PeerId): Unit = {
2828
peerEventBus ! Unsubscribe(PeerDisconnectedClassifier(PeerSelector.WithId(peerId)))

src/main/scala/io/iohk/ethereum/blockchain/sync/PeersClient.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class PeersClient(
2525
implicit val ec: ExecutionContext = context.dispatcher
2626

2727
val statusSchedule: Cancellable =
28-
scheduler.schedule(syncConfig.printStatusInterval, syncConfig.printStatusInterval, self, PrintStatus)
28+
scheduler.scheduleWithFixedDelay(syncConfig.printStatusInterval, syncConfig.printStatusInterval, self, PrintStatus)
2929

3030
def receive: Receive = running(Map())
3131

src/main/scala/io/iohk/ethereum/blockchain/sync/regular/OldRegularSync.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class OldRegularSync(
4343
import OldRegularSync._
4444
import syncConfig._
4545

46-
scheduler.schedule(printStatusInterval, printStatusInterval, self, PrintStatus)(global)
46+
scheduler.scheduleWithFixedDelay(printStatusInterval, printStatusInterval, self, PrintStatus)(global)
4747

4848
peerEventBus ! Subscribe(MessageClassifier(Set(NewBlock.code, NewBlockHashes.code), PeerSelector.AllPeers))
4949

src/main/scala/io/iohk/ethereum/blockchain/sync/regular/RegularSync.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class RegularSync(
3131
"block-importer")
3232

3333
val printFetcherSchedule: Cancellable =
34-
scheduler.schedule(syncConfig.printStatusInterval, syncConfig.printStatusInterval, fetcher, BlockFetcher.PrintStatus)(context.dispatcher)
34+
scheduler.scheduleWithFixedDelay(syncConfig.printStatusInterval, syncConfig.printStatusInterval, fetcher, BlockFetcher.PrintStatus)(context.dispatcher)
3535
val printImporterSchedule: Cancellable =
36-
scheduler.schedule(syncConfig.printStatusInterval, syncConfig.printStatusInterval, importer, BlockImporter.PrintStatus)(context.dispatcher)
36+
scheduler.scheduleWithFixedDelay(syncConfig.printStatusInterval, syncConfig.printStatusInterval, importer, BlockImporter.PrintStatus)(context.dispatcher)
3737

3838
override def receive: Receive = {
3939
case Start =>

src/main/scala/io/iohk/ethereum/extvm/ExtVMInterface.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
package io.iohk.ethereum.extvm
22

3-
import java.nio.ByteOrder
4-
53
import akka.actor.ActorSystem
6-
import akka.stream.{ActorMaterializer, OverflowStrategy}
4+
import akka.stream.OverflowStrategy
75
import akka.stream.scaladsl.{Framing, Keep, Sink, SinkQueueWithCancel, Source, SourceQueueWithComplete, Tcp}
86
import akka.util.ByteString
97
import io.iohk.ethereum.ledger.{InMemoryWorldStateProxy, InMemoryWorldStateProxyStorage}
108
import io.iohk.ethereum.utils.{BlockchainConfig, VmConfig}
119
import io.iohk.ethereum.vm._
12-
10+
import java.nio.ByteOrder
1311
import scala.annotation.tailrec
1412
import scala.util.{Failure, Success, Try}
1513

1614
class ExtVMInterface(externaVmConfig: VmConfig.ExternalConfig, blockchainConfig: BlockchainConfig, testMode: Boolean)(implicit system: ActorSystem)
1715
extends VM[InMemoryWorldStateProxy, InMemoryWorldStateProxyStorage]{
1816

19-
private implicit val materializer = ActorMaterializer()
20-
2117
private var out: Option[SourceQueueWithComplete[ByteString]] = None
2218

2319
private var in: Option[SinkQueueWithCancel[ByteString]] = None

src/main/scala/io/iohk/ethereum/extvm/VMServer.scala

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
package io.iohk.ethereum.extvm
22

3-
import java.nio.ByteOrder
4-
53
import akka.NotUsed
64
import akka.actor.ActorSystem
5+
import akka.stream.OverflowStrategy
76
import akka.stream.scaladsl.{Flow, Framing, Keep, Sink, Source, Tcp}
8-
import akka.stream.{ActorMaterializer, OverflowStrategy}
97
import akka.util.ByteString
108
import com.google.protobuf.{ByteString => GByteString}
119
import com.typesafe.config.ConfigFactory
1210
import io.iohk.ethereum.domain.{Address, BlockHeader}
1311
import io.iohk.ethereum.extvm.Implicits._
1412
import io.iohk.ethereum.utils._
15-
import io.iohk.ethereum.vm._
16-
import io.iohk.ethereum.vm.BlockchainConfigForEvm
17-
import io.iohk.ethereum.vm.ProgramResult
18-
13+
import io.iohk.ethereum.vm.{BlockchainConfigForEvm, ProgramResult, _}
14+
import java.nio.ByteOrder
1915
import scala.annotation.tailrec
2016
import scala.util.{Failure, Success, Try}
2117

2218
object VmServerApp extends Logger {
2319

2420
implicit val system = ActorSystem("EVM_System")
25-
implicit val materializer = ActorMaterializer()
2621

2722
def main(args: Array[String]): Unit = {
2823
val config = ConfigFactory.load()

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import java.security.SecureRandom
44

55
import akka.actor.ActorSystem
66
import akka.http.scaladsl.Http
7-
import akka.stream.ActorMaterializer
87
import com.typesafe.config.ConfigFactory
98
import io.iohk.ethereum.keystore.KeyStoreImpl
109
import io.iohk.ethereum.mallet.service.RpcClient
@@ -19,13 +18,12 @@ object Faucet extends Logger {
1918
val config = FaucetConfig(ConfigFactory.load())
2019

2120
implicit val system = ActorSystem("Faucet-system")
22-
implicit val materializer = ActorMaterializer()
2321

2422
val keyStore = new KeyStoreImpl(KeyStoreConfig.customKeyStoreConfig(config.keyStoreDir), new SecureRandom())
2523
val rpcClient = new RpcClient(config.rpcAddress)
2624
val api = new FaucetApi(rpcClient, keyStore, config)
2725

28-
val bindingResultF = Http().bindAndHandle(api.route, config.listenInterface, config.listenPort)
26+
val bindingResultF = Http().newServerAt(config.listenInterface, config.listenPort).bind(api.route)
2927

3028
bindingResultF onComplete {
3129
case Success(serverBinding) => log.info(s"Faucet HTTP server listening on ${serverBinding.localAddress}")

src/main/scala/io/iohk/ethereum/jsonrpc/server/http/BasicJsonRpcHttpServer.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package io.iohk.ethereum.jsonrpc.server.http
22

33
import akka.actor.ActorSystem
44
import akka.http.scaladsl.Http
5-
import akka.stream.ActorMaterializer
65
import ch.megard.akka.http.cors.scaladsl.model.HttpOriginMatcher
76
import io.iohk.ethereum.jsonrpc._
87
import io.iohk.ethereum.jsonrpc.server.http.JsonRpcHttpServer.JsonRpcHttpServerConfig
@@ -15,9 +14,7 @@ class BasicJsonRpcHttpServer(val jsonRpcController: JsonRpcController, config: J
1514
extends JsonRpcHttpServer with Logger {
1615

1716
def run(): Unit = {
18-
implicit val materializer = ActorMaterializer()
19-
20-
val bindingResultF = Http(actorSystem).bindAndHandle(route, config.interface, config.port)
17+
val bindingResultF = Http(actorSystem).newServerAt(config.interface, config.port).bind(route)
2118

2219
bindingResultF onComplete {
2320
case Success(serverBinding) => log.info(s"JSON RPC HTTP server listening on ${serverBinding.localAddress}")

src/main/scala/io/iohk/ethereum/jsonrpc/server/http/JsonRpcHttpsServer.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package io.iohk.ethereum.jsonrpc.server.http
22

33
import akka.actor.ActorSystem
44
import akka.http.scaladsl.{ConnectionContext, Http}
5-
import akka.stream.ActorMaterializer
65
import ch.megard.akka.http.cors.scaladsl.model.HttpOriginMatcher
76
import io.iohk.ethereum.jsonrpc.JsonRpcController
87
import io.iohk.ethereum.jsonrpc.server.http.JsonRpcHttpServer.JsonRpcHttpServerConfig
@@ -20,8 +19,6 @@ class JsonRpcHttpsServer(val jsonRpcController: JsonRpcController, config: JsonR
2019
extends JsonRpcHttpServer with Logger {
2120

2221
def run(): Unit = {
23-
implicit val materializer = ActorMaterializer()
24-
2522
val maybeSslContext = validateCertificateFiles(config.certificateKeyStorePath, config.certificateKeyStoreType, config.certificatePasswordFile).flatMap{
2623
case (keystorePath, keystoreType, passwordFile) =>
2724
val passwordReader = Source.fromFile(passwordFile)
@@ -33,12 +30,11 @@ class JsonRpcHttpsServer(val jsonRpcController: JsonRpcController, config: JsonR
3330
}
3431
}
3532

36-
val maybeHttpsContext = maybeSslContext.map(sslContext => ConnectionContext.https(sslContext))
33+
val maybeHttpsContext = maybeSslContext.map(sslContext => ConnectionContext.httpsServer(sslContext))
3734

3835
maybeHttpsContext match {
3936
case Right(httpsContext) =>
40-
Http().setDefaultServerHttpContext(httpsContext)
41-
val bindingResultF = Http().bindAndHandle(route, config.interface, config.port, connectionContext = httpsContext)
37+
val bindingResultF = Http().newServerAt(config.interface, config.port).enableHttps(httpsContext).bind(route)
4238

4339
bindingResultF onComplete {
4440
case Success(serverBinding) => log.info(s"JSON RPC HTTPS server listening on ${serverBinding.localAddress}")

src/main/scala/io/iohk/ethereum/mallet/service/RpcClient.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import java.util.UUID
66
import akka.actor.ActorSystem
77
import akka.http.scaladsl.Http
88
import akka.http.scaladsl.model._
9-
import akka.stream.ActorMaterializer
109
import akka.util.ByteString
1110
import com.typesafe.config.ConfigFactory
1211
import io.circe.generic.auto._
@@ -32,7 +31,6 @@ object RpcClient {
3231
val akkaConfig = ConfigFactory.load("mallet")
3332

3433
implicit val system = ActorSystem("mallet_rpc", akkaConfig)
35-
implicit val mat = ActorMaterializer()
3634
implicit val ec = scala.concurrent.ExecutionContext.Implicits.global
3735

3836
new RpcClient(node)
@@ -43,7 +41,7 @@ object RpcClient {
4341
* Talks to a node over HTTP(S) JSON-RPC
4442
* Note: the URI schema determines whether HTTP or HTTPS is used
4543
*/
46-
class RpcClient(node: Uri)(implicit system: ActorSystem, mat: ActorMaterializer, ec: ExecutionContext) {
44+
class RpcClient(node: Uri)(implicit system: ActorSystem, ec: ExecutionContext) {
4745
import CommonJsonCodecs._
4846

4947
//TODO: CL option

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class KnownNodesManager(
2525

2626
var toRemove: Set[URI] = Set.empty
2727

28-
scheduler.schedule(config.persistInterval, config.persistInterval, self, PersistChanges)
28+
scheduler.scheduleWithFixedDelay(config.persistInterval, config.persistInterval, self, PersistChanges)
2929

3030
override def receive: Receive = {
3131
case AddKnownNode(uri) =>

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ class PeerManagerActor(
5959
}
6060

6161
private def scheduleNodesUpdate(): Unit = {
62-
scheduler.schedule(peerConfiguration.updateNodesInitialDelay, peerConfiguration.updateNodesInterval){
63-
peerDiscoveryManager ! PeerDiscoveryManager.GetDiscoveredNodesInfo
64-
}
62+
scheduler.scheduleWithFixedDelay(
63+
peerConfiguration.updateNodesInitialDelay,
64+
peerConfiguration.updateNodesInterval,
65+
peerDiscoveryManager,
66+
PeerDiscoveryManager.GetDiscoveredNodesInfo
67+
)
6568
}
6669

6770
def listen(pendingPeers: PeerMap, peers: PeerMap): Receive = {

src/main/scala/io/iohk/ethereum/network/discovery/PeerDiscoveryManager.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PeerDiscoveryManager(
3838

3939
if (discoveryConfig.discoveryEnabled) {
4040
discoveryListener ! DiscoveryListener.Subscribe
41-
context.system.scheduler.schedule(discoveryConfig.scanInitialDelay, discoveryConfig.scanInterval, self, Scan)
41+
context.system.scheduler.scheduleWithFixedDelay(discoveryConfig.scanInitialDelay, discoveryConfig.scanInterval, self, Scan)
4242
}
4343

4444
def scan(): Unit = {

src/test/scala/io/iohk/ethereum/extvm/MessageHandlerSpec.scala

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
package io.iohk.ethereum.extvm
22

3-
import java.math.BigInteger
4-
53
import akka.actor.ActorSystem
4+
import akka.stream.OverflowStrategy
65
import akka.stream.scaladsl.{Keep, Sink, SinkQueueWithCancel, Source, SourceQueueWithComplete}
7-
import akka.util.ByteString
8-
import org.scalamock.scalatest.MockFactory
9-
import org.scalatest.{FlatSpec, Matchers}
10-
import akka.stream.{ActorMaterializer, OverflowStrategy}
116
import akka.testkit.TestProbe
7+
import akka.util.ByteString
128
import com.trueaccord.scalapb.GeneratedMessage
139
import io.iohk.ethereum.vm.Generators
14-
import org.scalatest.prop.PropertyChecks
10+
import java.math.BigInteger
1511
import org.bouncycastle.util.BigIntegers
16-
12+
import org.scalamock.scalatest.MockFactory
13+
import org.scalatest.prop.PropertyChecks
14+
import org.scalatest.{FlatSpec, Matchers}
1715
import scala.concurrent.ExecutionContext.Implicits.global
1816

1917
class MessageHandlerSpec extends FlatSpec with Matchers with MockFactory with PropertyChecks {
2018

19+
import Implicits._
2120
import akka.pattern.pipe
2221
import scala.concurrent.duration._
23-
import Implicits._
2422

2523
"MessageHandler" should "send arbitrary messages" in {
2624
implicit val system = ActorSystem("MessageHandlerSpec_System")
27-
implicit val materializer = ActorMaterializer()
2825

2926
val bytesGen = Generators.getByteStringGen(1, 1024 * 128)
3027

@@ -49,7 +46,6 @@ class MessageHandlerSpec extends FlatSpec with Matchers with MockFactory with Pr
4946

5047
it should "receive arbitrary code messages" in {
5148
implicit val system = ActorSystem("MessageHandlerSpec_System")
52-
implicit val materializer = ActorMaterializer()
5349

5450
val bytesGen = Generators.getByteStringGen(1, 8)
5551

0 commit comments

Comments
 (0)