Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build system cleanup #3901

Merged
merged 15 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
path: ~/.cache/coursier
key: coursier-cache
- name: Check PR
run: sbt --mem 6144 --batch checkPR
run: sbt --mem 6144 --batch ";checkPR;completeQaseRun"
env:
QASE_ENABLE: true
QASE_RUN_NAME: checkPR
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/publish-docker-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ jobs:
type=ref,event=tag
type=raw,value=latest,enable=${{ github.event.release.prerelease == false }}

- name: Extract Docker RIDE runner metadata
id: meta-ride-runner
uses: docker/metadata-action@v4
with:
images: wavesplatform/ride-runner
flavor: |
latest=false
tags: |
type=match,pattern=v(.*),group=1
type=raw,value=latest,enable=${{ github.event.release.prerelease == false }}

- name: Build and push Docker public image
id: build-and-push-public
uses: docker/build-push-action@v3
Expand All @@ -83,3 +94,12 @@ jobs:
tags: ${{ steps.meta-private.outputs.tags }}
build-args: |
NODE_TAG=${{ steps.meta-public.outputs.version }}

- name: Build and push Docker RIDE runner image
id: build-and-push-ride-runner
uses: docker/build-push-action@v3
with:
context: ./ride-runner/docker
push: true
pull: true
tags: ${{ steps.meta-ride-runner.outputs.tags }}
70 changes: 55 additions & 15 deletions benchmark/src/test/scala/com/wavesplatform/lang/v1/DataFuncs.scala
Original file line number Diff line number Diff line change
@@ -1,31 +1,69 @@
package com.wavesplatform.lang.v1

import java.util.concurrent.TimeUnit

import com.wavesplatform.common.utils._
import com.wavesplatform.lang.v1.DataFuncs._
import com.esaulpaugh.headlong.util.FastHex
import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin
import com.wavesplatform.common.utils.*
import com.wavesplatform.lang.v1.DataFuncs.*
import com.wavesplatform.lang.v1.EnvironmentFunctionsBenchmark.randomBytes
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.annotations.*
import org.openjdk.jmh.infra.Blackhole

import java.util.concurrent.TimeUnit

@OutputTimeUnit(TimeUnit.MICROSECONDS)
@BenchmarkMode(Array(Mode.AverageTime))
@Threads(1)
@Fork(1)
@Warmup(iterations = 30)
@Measurement(iterations = 30)
@Warmup(iterations = 10, time = 1)
@Measurement(iterations = 10, time = 1)
class DataFuncs {
@Benchmark
def decode64_35Kb(st: StrSt35K, bh: Blackhole): Unit =
bh.consume(Base64.decode(st.message))

@Benchmark
def decode16_32kb_bcprov(st: StrSt32K, bh: Blackhole): Unit =
bh.consume(org.bouncycastle.util.encoders.Hex.decode(st.message))

@Benchmark
def decode16_32kb_guava(st: StrSt32K, bh: Blackhole): Unit =
bh.consume(com.google.common.io.BaseEncoding.base16.decode(st.message))

@Benchmark
def decode16_32kb_commons_codec(st: StrSt32K, bh: Blackhole): Unit =
bh.consume(org.apache.commons.codec.binary.Hex.decodeHex(st.message))

@Benchmark
def decode16_32kb_web3j(st: StrSt32K, bh: Blackhole): Unit =
bh.consume(org.web3j.utils.Numeric.hexStringToByteArray(st.message))

@Benchmark
def decode16_32kb_headlong(st: StrSt32K, bh: Blackhole): Unit =
bh.consume(FastHex.decode(st.message))

@Benchmark
def decode16_32kb_jdk_hexbin(st: StrSt105K, bh: Blackhole): Unit =
bh.consume(HexBin.decode(st.message))

@Benchmark
def decode64_70Kb(st: StrSt70K, bh: Blackhole): Unit =
bh.consume(Base64.decode(st.message))

@Benchmark
def decode64_105Kb(st: StrSt105K, bh: Blackhole): Unit =
bh.consume(Base64.decode(st.message))
def decode64_105Kb_jdk(st: StrSt105K, bh: Blackhole): Unit =
bh.consume(java.util.Base64.getDecoder.decode(st.message))

@Benchmark
def decode64_105Kb_bcprov(st: StrSt105K, bh: Blackhole): Unit =
bh.consume(org.bouncycastle.util.encoders.Base64.decode(st.message))

@Benchmark
def decode64_105Kb_guava(st: StrSt105K, bh: Blackhole): Unit =
bh.consume(com.google.common.io.BaseEncoding.base64().decode(st.message))

@Benchmark
def decode64_105Kb_commons_codec(st: StrSt105K, bh: Blackhole): Unit =
bh.consume(org.apache.commons.codec.binary.Base64.decodeBase64(st.message))

@Benchmark
def decode64_140Kb(st: StrSt140K, bh: Blackhole): Unit =
Expand Down Expand Up @@ -95,7 +133,6 @@ class DataFuncs {
def concatr_175Kb(st: StrSt175K, bh: Blackhole): Unit =
bh.consume("q" ++ st.message)


@Benchmark
def decode58_16b(st: StrSt16b, bh: Blackhole): Unit =
bh.consume(Base58.decode(st.message))
Expand Down Expand Up @@ -144,23 +181,26 @@ class DataFuncs {
def encode58_896b(st: StrSt896b, bh: Blackhole): Unit =
bh.consume(Base58.encode(st.bmessage))


}

object DataFuncs {
@State(Scope.Benchmark)
class StrSt8K extends StrSt(8)
@State(Scope.Benchmark)
class StrSt35K extends StrSt(35)
@State(Scope.Benchmark)
class StrSt70K extends StrSt(70)
@State(Scope.Benchmark)
class StrSt105K extends StrSt(105)
@State(Scope.Benchmark)
class StrSt32K extends StrSt(32)
@State(Scope.Benchmark)
class StrSt140K extends StrSt(140)
@State(Scope.Benchmark)
class StrSt175K extends StrSt(175)

class StrSt(size: Int) {
val message = "B" * (size * 1024)
val message = "B" * (size * 1024)
}

@State(Scope.Benchmark)
Expand All @@ -177,8 +217,8 @@ object DataFuncs {
class StrSt896b extends StrStS(896)

class StrStS(size: Int) {
val message = "B" * size
val bmessage = randomBytes(size)
val message = "B" * size
val bmessage = randomBytes(size)
}

@State(Scope.Benchmark)
Expand All @@ -193,6 +233,6 @@ object DataFuncs {
class BinSt130K extends BinSt(130)

class BinSt(size: Int) {
val message = randomBytes(size * 1024)
val message = randomBytes(size * 1024)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import scala.util.Random
@BenchmarkMode(Array(Mode.AverageTime))
@Threads(1)
@Fork(1)
@Warmup(iterations = 10)
@Measurement(iterations = 10)
@Warmup(iterations = 10, time = 1)
@Measurement(iterations = 10, time = 1)
class EnvironmentFunctionsBenchmark {

@Benchmark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object ScriptEvaluatorBenchmark {
@BenchmarkMode(Array(Mode.AverageTime))
@Threads(1)
@Fork(1)
@Warmup(iterations = 10)
@Warmup(iterations = 10, time = 1)
@Measurement(iterations = 10)
class ScriptEvaluatorBenchmark {
@Benchmark
Expand Down
76 changes: 39 additions & 37 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
2. You've checked "Make project before run"
*/

import sbt.{Compile, Def}
import sbt.Keys.{concurrentRestrictions, _}

Global / onChangedBuildSource := ReloadOnSourceChanges

enablePlugins(GitVersioning)

git.uncommittedSignifier := Some("DIRTY")
git.useGitDescribe := true
ThisBuild / git.useGitDescribe := true

lazy val lang =
crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
Expand Down Expand Up @@ -119,12 +122,13 @@ lazy val `waves-node` = (project in file("."))
`node-generator`,
benchmark,
`repl-js`,
`repl-jvm`
`repl-jvm`,
`ride-runner`
)

inScope(Global)(
Seq(
scalaVersion := "2.13.11",
scalaVersion := "2.13.12",
organization := "com.wavesplatform",
organizationName := "Waves Platform",
organizationHomepage := Some(url("https://wavesplatform.com")),
Expand Down Expand Up @@ -172,9 +176,6 @@ inScope(Global)(
)
)

// ThisBuild options
git.uncommittedSignifier := Some("DIRTY")

lazy val packageAll = taskKey[Unit]("Package all artifacts")
packageAll := {
(node / assembly).value
Expand All @@ -185,43 +186,39 @@ packageAll := {

lazy val buildTarballsForDocker = taskKey[Unit]("Package node and grpc-server tarballs and copy them to docker/target")
buildTarballsForDocker := {
IO.copyFile((node / Universal / packageZipTarball).value, new File(baseDirectory.value, "docker/target/waves.tgz"))
IO.copyFile((`grpc-server` / Universal / packageZipTarball).value, new File(baseDirectory.value, "docker/target/waves-grpc-server.tgz"))
IO.copyFile(
(node / Universal / packageZipTarball).value,
baseDirectory.value / "docker" / "target" / "waves.tgz"
)
IO.copyFile(
(`grpc-server` / Universal / packageZipTarball).value,
baseDirectory.value / "docker" / "target" / "waves-grpc-server.tgz"
)
IO.copyFile(
(`ride-runner` / Universal / packageZipTarball).value,
(`ride-runner` / baseDirectory).value / "docker" / "target" / s"${(`ride-runner` / name).value}.tgz"
)
}

lazy val checkPRRaw = taskKey[Unit]("Build a project and run unit tests")
checkPRRaw := Def.taskDyn {
val res = Def
.sequential(
`waves-node` / clean,
Def.task {
(`lang-tests` / Test / test).value
(`repl-jvm` / Test / test).value
(`lang-js` / Compile / fastOptJS).value
(`lang-tests-js` / Test / test).value
(`grpc-server` / Test / test).value
(node / Test / test).value
(`repl-js` / Compile / fastOptJS).value
(`node-it` / Test / compile).value
(benchmark / Test / compile).value
(`node-generator` / Compile / compile).value
}
)
.result
.value

Def.task {
(`lang-testkit` / Test / runMain).toTask(" com.wavesplatform.report.QaseRunCompleter").value
res match {
case Inc(inc: Incomplete) => throw inc
case Value(v) => v
checkPRRaw := Def
.sequential(
`waves-node` / clean,
Def.task {
(`lang-tests` / Test / test).value
(`repl-jvm` / Test / test).value
(`lang-js` / Compile / fastOptJS).value
(`lang-tests-js` / Test / test).value
(`grpc-server` / Test / test).value
(node / Test / test).value
(`repl-js` / Compile / fastOptJS).value
(`node-it` / Test / compile).value
(benchmark / Test / compile).value
(`node-generator` / Compile / compile).value
(`ride-runner` / Test / compile).value
}
}
}.value
)
.value

def checkPR: Command = Command.command("checkPR") { state =>
val newState = Project
Expand All @@ -234,6 +231,11 @@ def checkPR: Command = Command.command("checkPR") { state =>
state
}

lazy val completeQaseRun = taskKey[Unit]("Complete Qase run")
completeQaseRun := Def.task {
(`lang-testkit` / Test / runMain).toTask(" com.wavesplatform.report.QaseRunCompleter").value
}.value

lazy val buildDebPackages = taskKey[Unit]("Build debian packages")
buildDebPackages := {
(`grpc-server` / Debian / packageBin).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.wavesplatform.transaction.TxHelpers
import com.wavesplatform.utils.DiffMatchers
import monix.execution.Scheduler.Implicits.global
import org.scalatest.{Assertion, BeforeAndAfterAll}

import com.wavesplatform.utils.byteStrOrdering
import scala.concurrent.Await
import scala.concurrent.duration.{DurationInt, FiniteDuration}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.wavesplatform.common.utils.*
import com.wavesplatform.db.InterferableDB
import com.wavesplatform.events.FakeObserver.*
import com.wavesplatform.events.StateUpdate.LeaseUpdate.LeaseStatus
import com.wavesplatform.utils.byteStrOrdering
import com.wavesplatform.events.StateUpdate.{
AssetInfo,
AssetStateUpdate,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.wavesplatform.common.state

import scala.util.Try

import com.wavesplatform.common._
import com.wavesplatform.common.utils.{Base58, Base64}

import scala.util.Try

case class ByteStr(arr: Array[Byte]) {
private[this] lazy val base58: String = Base58.encode(arr)
lazy val base64Raw: String = Base64.encode(arr)
Expand Down Expand Up @@ -86,6 +85,4 @@ object ByteStr {
def decodeBase64(s: String): Try[ByteStr] = Base64.tryDecode(s).map { bs =>
ByteStr(bs)
}

implicit val byteStrOrdering: Ordering[ByteStr] = (x, y) => ByteStrComparator.compare(x, y)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ sealed trait MetaVersion {

object V1 extends MetaVersion {
override type Self = V1.type
override val strategy = MetaMapperStrategyV1
override val strategy: MetaMapperStrategy[Self] = MetaMapperStrategyV1
override val number: Int = 1
}

object V2 extends MetaVersion {
override type Self = V2.type
override val strategy = MetaMapperStrategyV2
override val strategy: MetaMapperStrategy[Self] = MetaMapperStrategyV2
override val number: Int = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.wavesplatform.lang.script.v1
import cats.instances.either._
import cats.syntax.either._
import cats.syntax.flatMap._
import com.google.common.annotations.VisibleForTesting
import com.wavesplatform.common.state.ByteStr
import com.wavesplatform.lang.directives.values._
import com.wavesplatform.lang.script.Script
Expand All @@ -29,7 +28,6 @@ object ExprScript {
s"Script is too large: ${bs.length} bytes > $limit bytes"
)
}
@VisibleForTesting
def apply(x: EXPR): Either[String, Script] = apply(V1, x)

def apply(version: StdLibVersion, x: EXPR, isFreeCall: Boolean = false, checkSize: Boolean = true): Either[String, ExprScript] =
Expand Down
Loading