Skip to content

Commit d788290

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fix/fix-block-fetcher-bug
2 parents facbaec + 63283cc commit d788290

30 files changed

+2641
-773
lines changed

Diff for: .scalafmt.conf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version = "2.3.0"
2+
align = none
3+
maxColumn = 120

Diff for: build.sbt

+34-24
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ val commonSettings = Seq(
44
name := "mantis",
55
version := "3.0",
66
scalaVersion := "2.12.12",
7-
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-l", "EthashMinerSpec") // miner tests disabled by default
7+
testOptions in Test += Tests
8+
.Argument(TestFrameworks.ScalaTest, "-l", "EthashMinerSpec") // miner tests disabled by default
89
)
910

1011
// Resolver for rocksDb
@@ -15,7 +16,7 @@ val dep = {
1516
val akkaHttpVersion = "10.2.0"
1617
val circeVersion = "0.9.3"
1718
val rocksDb = "5.9.2"
18-
19+
1920
Seq(
2021
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
2122
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion,
@@ -43,15 +44,20 @@ val dep = {
4344
"org.scala-sbt.ipcsocket" % "ipcsocket" % "1.0.0",
4445
"org.bouncycastle" % "bcprov-jdk15on" % "1.59",
4546
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.0",
46-
"org.typelevel" %% "mouse" % "0.18",
47+
"org.typelevel" %% "mouse" % "0.23",
48+
"org.typelevel" %% "cats-core" % "2.0.0",
49+
"org.typelevel" %% "cats-effect" % "2.0.0",
4750
"com.twitter" %% "util-collection" % "18.5.0",
4851
"com.google.guava" % "guava" % "28.0-jre",
49-
52+
"io.monix" %% "monix" % "3.1.0",
53+
"com.beachape" %% "enumeratum" % "1.5.13",
54+
"com.beachape" %% "enumeratum-cats" % "1.5.15",
55+
"com.beachape" %% "enumeratum-scalacheck" % "1.5.16" % Test,
5056
// mallet deps
5157
"org.jline" % "jline" % "3.1.2",
5258
"net.java.dev.jna" % "jna" % "4.5.1",
59+
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.5",
5360
"com.github.scopt" %% "scopt" % "3.7.0",
54-
5561
// Metrics (https://github.com/DataDog/java-dogstatsd-client)
5662
"com.datadoghq" % "java-dogstatsd-client" % "2.5",
5763
"org.xerial.snappy" % "snappy-java" % "1.1.7.2",
@@ -71,19 +77,20 @@ val Snappy = config("snappy") extend Test
7177

7278
val Rpc = config("rpcTest") extend Test
7379

74-
val root = project.in(file("."))
75-
.configs(Integration, Benchmark, Evm, Ets, Snappy, Rpc)
76-
.settings(commonSettings: _*)
77-
.settings(
78-
libraryDependencies ++= dep,
79-
executableScriptName := name.value
80-
)
81-
.settings(inConfig(Integration)(Defaults.testSettings) : _*)
82-
.settings(inConfig(Benchmark)(Defaults.testSettings) : _*)
83-
.settings(inConfig(Evm)(Defaults.testSettings) : _*)
84-
.settings(inConfig(Ets)(Defaults.testSettings) : _*)
85-
.settings(inConfig(Snappy)(Defaults.testSettings) : _*)
86-
.settings(inConfig(Rpc)(Defaults.testSettings) : _*)
80+
val root = project
81+
.in(file("."))
82+
.configs(Integration, Benchmark, Evm, Ets, Snappy, Rpc)
83+
.settings(commonSettings: _*)
84+
.settings(
85+
libraryDependencies ++= dep,
86+
executableScriptName := name.value
87+
)
88+
.settings(inConfig(Integration)(Defaults.testSettings): _*)
89+
.settings(inConfig(Benchmark)(Defaults.testSettings): _*)
90+
.settings(inConfig(Evm)(Defaults.testSettings): _*)
91+
.settings(inConfig(Ets)(Defaults.testSettings): _*)
92+
.settings(inConfig(Snappy)(Defaults.testSettings): _*)
93+
.settings(inConfig(Rpc)(Defaults.testSettings): _*)
8794

8895
scalacOptions := Seq(
8996
"-unchecked",
@@ -93,13 +100,16 @@ scalacOptions := Seq(
93100
"-Xlint:unsound-match",
94101
"-Ywarn-inaccessible",
95102
"-Ywarn-unused-import",
96-
"-encoding", "utf-8"
103+
"-encoding",
104+
"utf-8"
97105
)
98106

99-
scalacOptions in (Compile, console) ~= (_.filterNot(Set(
100-
"-Ywarn-unused-import",
101-
"-Xfatal-warnings"
102-
)))
107+
scalacOptions in (Compile, console) ~= (_.filterNot(
108+
Set(
109+
"-Ywarn-unused-import",
110+
"-Xfatal-warnings"
111+
)
112+
))
103113

104114
parallelExecution in Test := false
105115

@@ -117,7 +127,7 @@ unmanagedResourceDirectories in Compile += baseDirectory.value / "src" / "main"
117127
(sourceDirectory in Evm) := baseDirectory.value / "src" / "evmTest"
118128

119129
(scalastyleConfig in Test) := baseDirectory.value / "scalastyle-test-config.xml"
120-
scalastyleSources in Test ++= {(unmanagedSourceDirectories in Integration).value}
130+
scalastyleSources in Test ++= { (unmanagedSourceDirectories in Integration).value }
121131

122132
mainClass in Compile := Some("io.iohk.ethereum.App")
123133

Diff for: insomnia_workspace.json

+107-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,105 @@
11
{
22
"_type": "export",
33
"__export_format": 4,
4-
"__export_date": "2020-09-11T12:07:41.513Z",
5-
"__export_source": "insomnia.desktop.app:v2020.2.1",
4+
"__export_date": "2020-09-16T09:48:00.794Z",
5+
"__export_source": "insomnia.desktop.app:v2020.3.3",
66
"resources": [
7+
{
8+
"_id": "req_cd0078ce4a034ebdbdf7dc9e20e78a29",
9+
"authentication": {},
10+
"body": {
11+
"mimeType": "application/json",
12+
"text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"qa_mineBlocks\", \n \"params\": [1, true],\n \"id\": 1\n}"
13+
},
14+
"created": 1600249397450,
15+
"description": "",
16+
"headers": [
17+
{
18+
"id": "pair_9f4d6a9dde554cd384487e04fa3b21aa",
19+
"name": "Content-Type",
20+
"value": "application/json"
21+
},
22+
{
23+
"id": "pair_088edc31f5e04f20a16b465a673871bb",
24+
"name": "Cache-Control",
25+
"value": "no-cache"
26+
}
27+
],
28+
"isPrivate": false,
29+
"metaSortKey": -1552939150156.9297,
30+
"method": "POST",
31+
"modified": 1600249644998,
32+
"name": "qa_mineBlocks",
33+
"parameters": [],
34+
"parentId": "fld_2b54cbb84e244284b3ef752c5f805376",
35+
"settingDisableRenderRequestBody": false,
36+
"settingEncodeUrl": true,
37+
"settingFollowRedirects": "global",
38+
"settingRebuildPath": true,
39+
"settingSendCookies": true,
40+
"settingStoreCookies": true,
41+
"url": "{{ node_url }}",
42+
"_type": "request"
43+
},
44+
{
45+
"_id": "fld_2b54cbb84e244284b3ef752c5f805376",
46+
"created": 1600249374160,
47+
"description": "",
48+
"environment": {},
49+
"environmentPropertyOrder": null,
50+
"metaSortKey": -1600249374160,
51+
"modified": 1600249374160,
52+
"name": "QA",
53+
"parentId": "wrk_097d43914a4d4aea8b6f73f647921182",
54+
"_type": "request_group"
55+
},
56+
{
57+
"_id": "wrk_097d43914a4d4aea8b6f73f647921182",
58+
"created": 1552662762769,
59+
"description": "",
60+
"modified": 1599825617921,
61+
"name": "Mantis",
62+
"parentId": null,
63+
"scope": null,
64+
"_type": "workspace"
65+
},
66+
{
67+
"_id": "req_6197fefa1e1448a89f30712ec12295f8",
68+
"authentication": {},
69+
"body": {
70+
"mimeType": "application/json",
71+
"text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"qa_getPendingTransactions\", \n \"params\": [],\n \"id\": 1\n}"
72+
},
73+
"created": 1600249491560,
74+
"description": "",
75+
"headers": [
76+
{
77+
"id": "pair_9f4d6a9dde554cd384487e04fa3b21aa",
78+
"name": "Content-Type",
79+
"value": "application/json"
80+
},
81+
{
82+
"id": "pair_088edc31f5e04f20a16b465a673871bb",
83+
"name": "Cache-Control",
84+
"value": "no-cache"
85+
}
86+
],
87+
"isPrivate": false,
88+
"metaSortKey": -1552939150156.832,
89+
"method": "POST",
90+
"modified": 1600249571669,
91+
"name": "qa_getPendingTransactions",
92+
"parameters": [],
93+
"parentId": "fld_2b54cbb84e244284b3ef752c5f805376",
94+
"settingDisableRenderRequestBody": false,
95+
"settingEncodeUrl": true,
96+
"settingFollowRedirects": "global",
97+
"settingRebuildPath": true,
98+
"settingSendCookies": true,
99+
"settingStoreCookies": true,
100+
"url": "{{ node_url }}",
101+
"_type": "request"
102+
},
7103
{
8104
"_id": "req_dd6e5c718f974407bb79fe3c953b7106",
9105
"authentication": {},
@@ -53,16 +149,6 @@
53149
"parentId": "wrk_097d43914a4d4aea8b6f73f647921182",
54150
"_type": "request_group"
55151
},
56-
{
57-
"_id": "wrk_097d43914a4d4aea8b6f73f647921182",
58-
"created": 1552662762769,
59-
"description": "",
60-
"modified": 1599825617921,
61-
"name": "Mantis",
62-
"parentId": null,
63-
"scope": null,
64-
"_type": "workspace"
65-
},
66152
{
67153
"_id": "req_105cb28c6f774eadbf099a28617a6d1f",
68154
"authentication": {},
@@ -695,8 +781,14 @@
695781
"_id": "env_2e1a8d7b5f3649308cb3c524e84a3f33",
696782
"color": null,
697783
"created": 1552663140073,
698-
"data": { "node_url": "http://127.0.0.1:8546" },
699-
"dataPropertyOrder": { "&": ["node_url"] },
784+
"data": {
785+
"node_url": "http://127.0.0.1:8546"
786+
},
787+
"dataPropertyOrder": {
788+
"&": [
789+
"node_url"
790+
]
791+
},
700792
"isPrivate": false,
701793
"metaSortKey": 1552663140073,
702794
"modified": 1599825641645,
@@ -705,4 +797,4 @@
705797
"_type": "environment"
706798
}
707799
]
708-
}
800+
}

Diff for: src/main/resources/application.conf

+21-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ mantis {
185185
}
186186

187187
# Enabled JSON-RPC APIs over the JSON-RPC endpoint
188-
# Available choices are: eth, web3, net, personal, test, daedalus, iele
189-
apis = "eth,web3,net,personal,daedalus,debug"
188+
# Available choices are: eth, web3, net, personal, test, daedalus, iele, qa
189+
apis = "eth,web3,net,personal,daedalus,debug,qa"
190190

191191
# Maximum number of blocks for daedalus_getAccountTransactions
192192
account-transactions-max-blocks = 50000
@@ -534,6 +534,25 @@ mantis {
534534
# Iff true, any errors during metrics client operations will be logged.
535535
log-errors = true
536536
}
537+
538+
async {
539+
dispatchers {
540+
block-forger {
541+
type = Dispatcher
542+
executor = "fork-join-executor"
543+
544+
fork-join-executor {
545+
parallelism-min = 2
546+
parallelism-factor = 2.0
547+
parallelism-max = 8
548+
549+
task-peeking-mode = "FIFO"
550+
}
551+
552+
throughput = 5
553+
}
554+
}
555+
}
537556
}
538557

539558
akka {

Diff for: src/main/scala/io/iohk/ethereum/consensus/Consensus.scala

+7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package io.iohk.ethereum.consensus
22

33
import io.iohk.ethereum.consensus.blocks.{BlockGenerator, TestBlockGenerator}
4+
import io.iohk.ethereum.consensus.ethash.{MinerProtocol, MinerResponse}
45
import io.iohk.ethereum.consensus.validators.Validators
56
import io.iohk.ethereum.ledger.BlockPreparator
67
import io.iohk.ethereum.ledger.Ledger.VMImpl
78
import io.iohk.ethereum.nodebuilder.Node
9+
import scala.concurrent.Future
810

911
/**
1012
* Abstraction for a consensus protocol implementation.
@@ -53,6 +55,11 @@ trait Consensus {
5355
* This is called internally when the node terminates.
5456
*/
5557
def stopProtocol(): Unit
58+
59+
/**
60+
* Sends msg to the internal miner
61+
*/
62+
def sendMiner(msg: MinerProtocol): Future[MinerResponse]
5663
}
5764

5865
/**

Diff for: src/main/scala/io/iohk/ethereum/consensus/ConsensusBuilder.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ trait StdConsensusBuilder extends ConsensusBuilder {
3838

3939
val consensus =
4040
config.protocol match {
41-
case Protocol.Ethash buildEthashConsensus()
41+
case Protocol.Ethash | Protocol.MockedPow buildEthashConsensus()
4242
}
4343
log.info(s"Using '${protocol.name}' consensus [${consensus.getClass.getName}]")
4444

Diff for: src/main/scala/io/iohk/ethereum/consensus/Protocol.scala

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,22 @@ object Protocol {
1717
object Names {
1818
// This is the standard Ethereum PoW consensus protocol.
1919
final val Ethash = "ethash"
20+
21+
final val MockedPow = "mocked"
2022
}
2123

2224
sealed abstract class ProtocolImpl(val name: String) extends Protocol
2325

2426
/** The standard Ethereum PoW consensus protocol. */
2527
case object Ethash extends ProtocolImpl(Names.Ethash)
2628

29+
/** Mocked pow consensus algorithm used for tests etc. */
30+
case object MockedPow extends ProtocolImpl(Names.MockedPow)
31+
2732

2833
/** All the known protocols. If a protocol is not put here, then it cannot be used to run Mantis. */
2934
final val KnownProtocols = Set(
30-
Ethash
35+
Ethash, MockedPow
3136
)
3237

3338
final val KnownProtocolNames = KnownProtocols.map(_.name)

0 commit comments

Comments
 (0)