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 10 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
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
24 changes: 9 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ lazy val `waves-node` = (project in file("."))

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 @@ -194,8 +194,7 @@ buildTarballsForDocker := {
}

lazy val checkPRRaw = taskKey[Unit]("Build a project and run unit tests")
checkPRRaw := Def.taskDyn {
val res = Def
checkPRRaw := Def
.sequential(
`waves-node` / clean,
Def.task {
Expand All @@ -209,19 +208,9 @@ checkPRRaw := Def.taskDyn {
(`node-it` / Test / compile).value
(benchmark / Test / compile).value
(`node-generator` / Compile / compile).value
(`ride-runner` / Test / 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
}
}
}.value
).value

def checkPR: Command = Command.command("checkPR") { state =>
val newState = Project
Expand All @@ -234,6 +223,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
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.wavesplatform.lang.v1.compiler

import java.nio.charset.StandardCharsets

import cats.Eval
import cats.instances.list.*
import cats.syntax.traverse.*
import com.wavesplatform.common.state.ByteStr
import com.wavesplatform.lang.{ExecutionError, CommonError}
import com.wavesplatform.lang.{CommonError, ExecutionError}
import com.wavesplatform.lang.v1.ContractLimits.*
import com.wavesplatform.lang.v1.FunctionHeader
import com.wavesplatform.lang.v1.compiler.Types.*
import com.wavesplatform.lang.v1.evaluator.ctx.impl.PureContext.MaxListLengthV4
import monix.eval.Coeval

import scala.annotation.nowarn

object Terms {
val DataTxMaxBytes: Int = 150 * 1024 // should be the same as DataTransaction.MaxBytes
val DataTxMaxProtoBytes: Int = 165947 // depends from DataTransaction.MaxProtoBytes
Expand Down Expand Up @@ -242,6 +243,7 @@ object Terms {
lazy val TRUE: CONST_BOOLEAN = CONST_BOOLEAN(true)
lazy val FALSE: CONST_BOOLEAN = CONST_BOOLEAN(false)

@nowarn // do not warn about private constructor
case class CaseObj private (caseType: CASETYPEREF, fields: Map[String, EVALUATED]) extends EVALUATED {
// must be with fixArrIndentation = false, because of makeString behavior before RideV6 (NODE-2370)
override def toString: String = TermPrinter().string(this)
Expand Down
Loading