-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.sc
223 lines (181 loc) · 7.58 KB
/
build.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
import mill._
import mill.modules._
import scalalib._
import ammonite.ops._
import coursier.maven.MavenRepository
import mill.scalalib.{PublishModule, ScalaModule}
import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl}
import $ivy.`com.lihaoyi::mill-contrib-versionfile:$MILL_VERSION`
import mill.contrib.versionfile.VersionFileModule
object versionFile extends VersionFileModule
object VersionOf {
val cats = "2.3.1"
val config = "1.4.1"
val logback = "1.2.3"
val monix = "3.3.0"
val prometheus = "0.10.0"
val rocksdb = "6.15.2"
val scalacheck = "1.15.2"
val scalalogging = "3.9.2"
val scalatest = "3.2.5"
val scalanet = "0.7.0"
}
object metronome extends Cross[MetronomeModule]("2.12.10", "2.13.4")
class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
// Get rid of the `metronome-2.12.10-` part from the artifact name. The JAR name suffix will shows the Scala version.
// Check with `mill show metronome[2.12.10].__.artifactName` or `mill __.publishLocal`.
private def removeCrossVersion(artifactName: String): String =
"metronome-" + artifactName.split("-").drop(2).mkString("-")
// In objects inheriting this trait, use `override def moduleDeps: Seq[PublishModule]`
// to point at other modules that also get published. In other cases such as tests
// it can be `override def moduleDeps: Seq[JavaModule]`, i.e. point at any module.
trait Publishing extends PublishModule {
def description: String
// Make sure there's no newline in the file.
override def publishVersion = versionFile.currentVersion().toString
override def pomSettings = PomSettings(
description = description,
organization = "io.iohk",
url = "https://github.com/input-output-hk/metronome",
licenses = Seq(License.`Apache-2.0`),
versionControl = VersionControl.github("input-output-hk", "metronome"),
// Add yourself if you make a PR!
developers = Seq(
Developer("aakoshh", "Akosh Farkash", "https://github.com/aakoshh"),
Developer("lemastero", "Piotr Paradzinski", "https://github.com/lemastero")
)
)
}
/** Common properties for all Scala modules. */
trait SubModule extends ScalaModule {
override def scalaVersion = crossScalaVersion
override def artifactName = removeCrossVersion(super.artifactName())
override def ivyDeps = Agg(
ivy"org.typelevel::cats-core:${VersionOf.cats}",
ivy"org.typelevel::cats-effect:${VersionOf.cats}"
)
// `extends Tests` uses the context of the module in which it's defined
trait TestModule extends Tests {
override def artifactName =
removeCrossVersion(super.artifactName())
override def testFrameworks =
Seq("org.scalatest.tools.Framework")
// It may be useful to see logs in tests.
override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ Seq(logging)
override def ivyDeps = Agg(
ivy"org.scalatest::scalatest:${VersionOf.scalatest}",
ivy"org.scalacheck::scalacheck:${VersionOf.scalacheck}",
ivy"ch.qos.logback:logback-classic:${VersionOf.logback}"
)
def single(args: String*) = T.command {
super.runMain("org.scalatest.run", args: _*)
}
}
}
/** Storage abstractions, e.g. a generic key-value store. */
object storage extends SubModule
/** Emit trace events, abstracting away logs and metrics.
*
* Based on https://github.com/input-output-hk/iohk-monitoring-framework/tree/master/contra-tracer
*/
object tracing extends SubModule with Publishing {
override def description: String =
"Abstractions for contravariant tracing."
def scalacPluginIvyDeps = Agg(ivy"org.typelevel:::kind-projector:0.11.3")
}
/** Additional crypto utilities such as threshold signature. */
object crypto extends SubModule with Publishing {
override def description: String =
"Cryptographic primitives to support HotStuff and BFT proof verification."
// TODO: Use crypto library from Mantis.
object test extends TestModule
}
/** Generic HotStuff BFT library. */
object hotstuff extends SubModule {
/** Pure consensus models. */
object consensus extends SubModule {
object test extends TestModule
}
/** Expose forensics events via tracing. */
object forensics extends SubModule
/** Implements peer-to-peer communication, state and block synchronisation.
*
* Includes the remote communication protocol messages and networking.
*/
object service extends SubModule {
override def moduleDeps: Seq[JavaModule] =
Seq(storage, tracing, crypto, hotstuff.consensus, hotstuff.forensics)
override def ivyDeps = super.ivyDeps() ++ Agg(
ivy"io.iohk::scalanet:${VersionOf.scalanet}"
)
object test extends TestModule
}
}
/** Components realising the checkpointing functionality using HotStuff. */
object checkpointing extends SubModule {
/** Library to be included on the PoW side to talk to the checkpointing service.
*
* Includes the certificate models, the local communication protocol messages and networking.
*/
object interpreter extends SubModule with Publishing {
override def description: String =
"Components to implement a PoW side checkpointing interpreter."
override def ivyDeps = Agg(
ivy"io.iohk::scalanet:${VersionOf.scalanet}"
)
override def moduleDeps: Seq[PublishModule] =
Seq(tracing, crypto)
}
/** Implements the checkpointing functionality and the ledger rules.
*
* If it was published, it could be directly included in the checkpoint assisted blockchain application,
* so the service and the interpreter can share data in memory.
*/
object service extends SubModule {
override def moduleDeps: Seq[JavaModule] =
Seq(tracing, hotstuff.service, checkpointing.interpreter)
object test extends TestModule
}
/** Executable application for running HotStuff and checkpointing as a stand-alone process,
* communicating with the interpreter over TCP.
*/
object app extends SubModule {
override def moduleDeps: Seq[JavaModule] =
Seq(hotstuff.service, checkpointing.service, rocksdb, logging, metrics)
override def ivyDeps = super.ivyDeps() ++ Agg(
ivy"com.typesafe:config:${VersionOf.config}",
ivy"ch.qos.logback:logback-classic:${VersionOf.logback}",
ivy"io.iohk::scalanet-discovery:${VersionOf.scalanet}",
ivy"io.monix::monix:${VersionOf.monix}"
)
object test extends TestModule
}
}
/** Implements tracing abstractions to do structured logging. */
object logging extends SubModule {
override def moduleDeps: Seq[JavaModule] =
Seq(tracing)
override def ivyDeps = super.ivyDeps() ++ Agg(
ivy"com.typesafe.scala-logging::scala-logging:${VersionOf.scalalogging}"
)
}
/** Implements tracing abstractions to expose metrics to Prometheus. */
object metrics extends SubModule {
override def moduleDeps: Seq[JavaModule] =
Seq(tracing)
override def ivyDeps = super.ivyDeps() ++ Agg(
ivy"io.prometheus:simpleclient:${VersionOf.prometheus}",
ivy"io.prometheus:simpleclient_httpserver:${VersionOf.prometheus}"
)
}
/** Implements the storage abstractions using RocksDB. */
object rocksdb extends SubModule {
override def moduleDeps: Seq[JavaModule] =
Seq(storage)
override def ivyDeps = super.ivyDeps() ++ Agg(
ivy"org.rocksdb:rocksdbjni:${VersionOf.rocksdb}"
)
object test extends TestModule
}
}