Skip to content

Commit e51ad47

Browse files
author
Jaap van der Plas
committed
Merge branch 'feature/ETCM-697-retesteth-endpoints' into feature/ETCM-680-retesteth-ci
2 parents 88b1e79 + 78e2edc commit e51ad47

File tree

67 files changed

+1319
-303
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1319
-303
lines changed

.buildkite/pipeline.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,15 @@ in
161161
nix-shell --run '$SBT benchmark:compile dist'
162162
'';
163163
};
164+
165+
publish = commonAttrs // {
166+
dependsOn = [ test-crypto test-rlp test-unit ];
167+
label = "Publishing libraries to Maven";
168+
command = ''
169+
nix-env -iA nixpkgs.gnupg && nix-shell --run '.buildkite/publish.sh'
170+
'';
171+
branches = "master develop";
172+
timeoutInMinutes = 30;
173+
};
164174
};
165175
}

.buildkite/publish.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env bash
2+
3+
set -euv
4+
5+
# The build agents have gpg 2.0.22, which doesn't have the `--pinentry-mode` option, but
6+
# the sbt-pgp plugin assumes that 2.x has it, and generates an invalid command.
7+
# We can either create a wrapper script that removes that option, or update gpg
8+
# somewhere in pipeline.nix
9+
10+
# Force a restart of the agent becuase it may be out of sync with what Nix installed.
11+
gpgconf --kill all
12+
13+
gpg --version
14+
15+
16+
# The build agent might have this key from before.
17+
GPG_EXISTS=$(gpg --list-keys "$GPG_KEY_ID" >&2 && echo "yes" || echo "no")
18+
19+
if [[ "$GPG_EXISTS" == "no" ]]; then
20+
echo "$GPG_KEY" | base64 --decode | gpg --batch --import
21+
# Local testing showed that without this the SBT plugin got "Bad passphrase".
22+
gpg --passphrase $GPG_PASSPHRASE --batch --yes -a -b LICENSE
23+
fi
24+
25+
# https://github.com/olafurpg/sbt-ci-release#secrets
26+
export PGP_SECRET="$GPG_KEY"
27+
export PGP_PASSPHRASE="$GPG_PASSPHRASE"
28+
export SONATYPE_USERNAME="$OSS_USERNAME"
29+
export SONATYPE_PASSWORD="$OSS_PASSWORD"
30+
31+
set +u
32+
33+
#https://github.com/sbt/sbt/issues/3570
34+
export JAVA_OPTS="$JAVA_OPTS -Dsbt.gigahorse=false"
35+
36+
# ci-release cannot be called on individual modules, but it looks like
37+
# with `publish / skip := true` in build.sbt for the default project,
38+
# without any aggregation, by default it would publish nothing, so
39+
# let's tell it here by using `sbt-ci-release` env vars.
40+
# NOTE: +rlp/publishSigned with the `+` would cross publish,
41+
# but it doesn't work because of scapegoat (see below).
42+
export CI_SNAPSHOT_RELEASE="; bytes/publishSigned; rlp/publishSigned; crypto/publishSigned"
43+
export CI_RELEASE=$CI_SNAPSHOT_RELEASE
44+
export CI_SONATYPE_RELEASE=$"; bytes/sonatypeBundleRelease; rlp/sonatypeBundleRelease; crypto/sonatypeBundleRelease"
45+
46+
# Scala 2.12 has up to scapegoat 1.4.5, while Scala 2.13 starts with 1.4.7.
47+
# I couldn't make build.sbt vary the scapegoat version by the current cross build,
48+
# so as a workaround the combos are called here explicitly.
49+
function release {
50+
SCALA_VERSION=$1
51+
export SCAPEGOAT_VERSION=$2
52+
53+
sbt "++ $SCALA_VERSION ; ci-release"
54+
}
55+
56+
function releaseAll {
57+
release 2.12.10 1.4.5
58+
release 2.13.4 1.4.7
59+
}
60+
61+
if [[ "$BUILDKITE_BRANCH" == "develop" ]]; then
62+
63+
# Publish the -SNAPSHOT version.
64+
releaseAll
65+
66+
elif [[ "$BUILDKITE_BRANCH" == "master" ]]; then
67+
68+
# Remove the -SNAPSHOT from the version file, then publish and release.
69+
sed -i 's/-SNAPSHOT//' version.sbt
70+
71+
# Whether ci-release does a release or a snapshot depends on whether it thinks the build is tagged; setting a dummy value.
72+
# Check https://github.com/olafurpg/sbt-ci-release/blob/main/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala for the rules.
73+
export CI_COMMIT_TAG=$(sbt -Dsbt.supershell=false -error "print version")
74+
75+
releaseAll
76+
77+
else
78+
79+
echo "Skipping the publish step."
80+
81+
fi

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Possible networks: `etc`, `eth`, `mordor`, `testnet-internal`
3232
### Command Line Interface
3333

3434
`cli` is a tool that can be used to:
35-
35+
3636
- generate a new private key
3737
```
3838
./bin/mantis cli generate-private-key
@@ -124,10 +124,12 @@ will need to be updated so that it includes the new dependency state.
124124
To do so, please run:
125125
```
126126
./update-nix.sh
127-
git add ./nix/pkgs/mantis.nix
127+
git add ./nix/overlay.nix
128128
git commit -m "Update nix-sbt sha"
129129
```
130130

131+
For this command to work you'll need the [Flakes](https://nixos.wiki/wiki/Flakes) feature enabled in your `nix` environment.
132+
131133
*NOTE:* This should only be necessary when updating dependencies
132134
(For example, edits to build.sbt or project/plugins.sbt will likely need to be regenerated)
133135

@@ -159,9 +161,9 @@ If a new certificate is required, create a new keystore with a certificate by ru
159161
1. Configure the certificate and password file to be used at `mantis.network.rpc.http.certificate` key on the `application.conf` file:
160162

161163
keystore-path: path to the keystore storing the certificates (if generated through our script they are by default located in "./tls/mantisCA.p12")
162-
164+
163165
keystore-type: type of certificate keystore being used (if generated through our script use "pkcs12")
164-
166+
165167
password-file: path to the file with the password used for accessing the certificate keystore (if generated through our script they are by default located in "./tls/password")
166168
2. Enable TLS in specific config:
167169
- For JSON RPC: `mantis.network.rpc.http.mode=https`
@@ -171,9 +173,9 @@ If a new certificate is required, create a new keystore with a certificate by ru
171173
1. Configure the certificate and password file to be used at `mantis.network.rpc.http.certificate` key on the `faucet.conf` file:
172174

173175
keystore-path: path to the keystore storing the certificates (if generated through our script they are by default located in "./tls/mantisCA.p12")
174-
176+
175177
keystore-type: type of certificate keystore being used (if generated through our script use "pkcs12")
176-
178+
177179
password-file: path to the file with the password used for accessing the certificate keystore (if generated through our script they are by default located in "./tls/password")
178180
2. Enable TLS in specific config:
179181
- For JSON RPC: `mantis.network.rpc.http.mode=https`
@@ -200,7 +202,7 @@ volumes:
200202
- $HOME/.mantis:/home/demiourgos728/.mantis/
201203
command: -Dconfig.file=./conf/sagano.conf
202204
```
203-
205+
204206
2. Create a wallet address. Run the following curl command, replacing `<password>` by a password of your choice:
205207
```
206208
curl --request POST \
@@ -209,7 +211,7 @@ curl --request POST \
209211
--header 'Content-Type: application/json' \
210212
--data '{
211213
"jsonrpc": "2.0",
212-
"method": "personal_newAccount",
214+
"method": "personal_newAccount",
213215
"params": ["<password>"],
214216
"id": 1
215217
}'
@@ -244,7 +246,7 @@ curl --request POST \
244246
--header 'Content-Type: application/json' \
245247
--data '{
246248
"jsonrpc": "2.0",
247-
"method": "faucet_sendFunds",
249+
"method": "faucet_sendFunds",
248250
"params": ["<address>"],
249251
"id": 1
250252
}'

build.sbt

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,35 @@ val nixBuild = sys.props.isDefinedAt("nix")
1212
// Enable dev mode: disable certain flags, etc.
1313
val mantisDev = sys.props.get("mantisDev").contains("true") || sys.env.get("MANTIS_DEV").contains("true")
1414

15+
lazy val compilerOptimizationsForProd = Seq(
16+
"-opt:l:method", // method-local optimizations
17+
"-opt:l:inline", // inlining optimizations
18+
"-opt-inline-from:io.iohk.**" // inlining the project only
19+
)
20+
21+
// Releasing. https://github.com/olafurpg/sbt-ci-release
22+
inThisBuild(List(
23+
organization := "io.iohk",
24+
homepage := Some(url("https://github.com/input-output-hk/mantis")),
25+
scmInfo := Some(ScmInfo(url("https://github.com/input-output-hk/mantis"), "[email protected]:input-output-hk/mantis.git")),
26+
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
27+
developers := List()
28+
))
29+
30+
// https://github.com/sbt/sbt/issues/3570
31+
updateOptions := updateOptions.value.withGigahorse(false)
32+
33+
// artifact name will include scala version
34+
crossPaths := true
35+
36+
val `scala-2.12` = "2.12.10"
37+
val `scala-2.13` = "2.13.4"
38+
val supportedScalaVersions = List(`scala-2.12`, `scala-2.13`)
39+
1540
def commonSettings(projectName: String): Seq[sbt.Def.Setting[_]] = Seq(
1641
name := projectName,
1742
organization := "io.iohk",
18-
version := "3.2.1",
19-
scalaVersion := "2.13.4",
43+
scalaVersion := `scala-2.13`,
2044
// Scalanet snapshots are published to Sonatype after each build.
2145
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
2246
testOptions in Test += Tests
@@ -29,6 +53,7 @@ def commonSettings(projectName: String): Seq[sbt.Def.Setting[_]] = Seq(
2953
"-encoding",
3054
"utf-8"
3155
),
56+
scalacOptions ++= (if (mantisDev) Seq.empty else compilerOptimizationsForProd),
3257
scalacOptions in (Compile, console) ~= (_.filterNot(
3358
Set(
3459
"-Ywarn-unused-import",
@@ -38,7 +63,14 @@ def commonSettings(projectName: String): Seq[sbt.Def.Setting[_]] = Seq(
3863
scalacOptions ~= (options => if (mantisDev) options.filterNot(_ == "-Xfatal-warnings") else options),
3964
Test / parallelExecution := true,
4065
testOptions in Test += Tests.Argument("-oDG"),
41-
(scalastyleConfig in Test) := file("scalastyle-test-config.xml")
66+
(scalastyleConfig in Test) := file("scalastyle-test-config.xml"),
67+
// Only publish selected libraries.
68+
skip in publish := true
69+
)
70+
71+
val publishSettings = Seq(
72+
publish / skip := false,
73+
crossScalaVersions := supportedScalaVersions
4274
)
4375

4476
// Adding an "it" config because in `Dependencies.scala` some are declared with `% "it,test"`
@@ -50,6 +82,7 @@ lazy val bytes = {
5082
.in(file("bytes"))
5183
.configs(Integration)
5284
.settings(commonSettings("mantis-bytes"))
85+
.settings(publishSettings)
5386
.settings(
5487
libraryDependencies ++=
5588
Dependencies.akkaUtil ++
@@ -65,6 +98,7 @@ lazy val crypto = {
6598
.configs(Integration)
6699
.dependsOn(bytes)
67100
.settings(commonSettings("mantis-crypto"))
101+
.settings(publishSettings)
68102
.settings(
69103
libraryDependencies ++=
70104
Dependencies.akkaUtil ++
@@ -81,6 +115,7 @@ lazy val rlp = {
81115
.configs(Integration)
82116
.dependsOn(bytes)
83117
.settings(commonSettings("mantis-rlp"))
118+
.settings(publishSettings)
84119
.settings(
85120
libraryDependencies ++=
86121
Dependencies.akkaUtil ++
@@ -201,6 +236,9 @@ lazy val node = {
201236
batScriptExtraDefines += """call :add_java "-Dconfig.file=%APP_HOME%\conf\app.conf"""",
202237
batScriptExtraDefines += """call :add_java "-Dlogback.configurationFile=%APP_HOME%\conf\logback.xml""""
203238
)
239+
.settings(
240+
crossScalaVersions := List(`scala-2.13`)
241+
)
204242

205243
if (!nixBuild)
206244
node
@@ -252,5 +290,7 @@ addCommandAlias(
252290
|""".stripMargin
253291
)
254292

255-
scapegoatVersion in ThisBuild := "1.4.7"
293+
// Scala 2.12 only has up to 1.4.5, while 2.13 only from 1.4.7
294+
// In theory we should be able to switch on `scalaVersion.value` but it doesn't seem to work.
295+
scapegoatVersion in ThisBuild := (sys.env.getOrElse("SCAPEGOAT_VERSION", "1.4.7"))
256296
scapegoatReports := Seq("xml")

bytes/src/main/scala/io/iohk/ethereum/utils/ByteStringUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ object ByteStringUtils {
6161

6262
def concatByteStrings(elements: Iterator[ByteStringElement]): ByteString = {
6363
val builder = new mutable.ArrayBuilder.ofByte
64-
elements.foreach(el => builder.addAll(el.asByteArray))
64+
elements.foreach(el => builder ++= el.asByteArray)
6565
ByteString(builder.result())
6666
}
6767

bytes/src/main/scala/io/iohk/ethereum/utils/Hex.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ object Hex {
55
bytes.map("%02x".format(_)).mkString
66

77
def decode(hex: String): Array[Byte] =
8-
hex.toSeq.sliding(2, 2).toArray.map(s => Integer.parseInt(s.unwrap, 16).toByte)
8+
hex.toSeq.sliding(2, 2).toArray.map { s =>
9+
Integer.parseInt(s.mkString(""), 16).toByte
10+
}
911
}

0 commit comments

Comments
 (0)