Skip to content

Commit

Permalink
Merge branch 'version-1.4.x' into node-2348-api-liquid-balances
Browse files Browse the repository at this point in the history
  • Loading branch information
xrtm000 committed Nov 21, 2022
2 parents 557636f + 32e1a9b commit 32a6967
Show file tree
Hide file tree
Showing 98 changed files with 3,190 additions and 3,611 deletions.
119 changes: 0 additions & 119 deletions Jenkinsfile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import com.google.protobuf.ByteString
import com.wavesplatform.account.{Address, AddressScheme, KeyPair}
import com.wavesplatform.block.Block
import com.wavesplatform.common.state.ByteStr
import com.wavesplatform.common.utils._
import com.wavesplatform.database.{openDB, LevelDBWriter}
import com.wavesplatform.common.utils.*
import com.wavesplatform.database.{LevelDBWriter, openDB}
import com.wavesplatform.protobuf.transaction.PBRecipients
import com.wavesplatform.state.{Diff, Portfolio}
import com.wavesplatform.transaction.{GenesisTransaction, Proofs}
import com.wavesplatform.transaction.{GenesisTransaction, Proofs, TxDecimals, TxPositiveAmount}
import com.wavesplatform.transaction.Asset.IssuedAsset
import com.wavesplatform.transaction.assets.IssueTransaction
import com.wavesplatform.utils.{NTP, ScorexLogging}
Expand Down Expand Up @@ -40,11 +40,11 @@ object RollbackBenchmark extends ScorexLogging {
issuer.publicKey,
ByteString.copyFromUtf8("asset-" + i),
ByteString.EMPTY,
100000e2.toLong,
2.toByte,
TxPositiveAmount.unsafeFrom(100000e2.toLong),
TxDecimals.unsafeFrom(2.toByte),
false,
None,
1e8.toLong,
TxPositiveAmount.unsafeFrom(1e8.toLong),
time.getTimestamp(),
Proofs(ByteStr(new Array[Byte](64))),
AddressScheme.current.chainId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AddressFromPublicKeyBenchmark {
@State(Scope.Benchmark)
class PkSt extends EthHelpers {
val ds = DirectiveSet(V6, Account, Expression).fold(null, identity)
val ctx = lazyContexts(ds).value().evaluationContext(EnvironmentFunctionsBenchmark.environment)
val ctx = lazyContexts((ds, true)).value().evaluationContext(EnvironmentFunctionsBenchmark.environment)

val wavesPk = ByteStr(curve25519.generateKeypair._2)
val exprWaves = TestCompiler(V6).compileExpression(s"addressFromPublicKey(base58'$wavesPk')").expr.asInstanceOf[EXPR]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BigIntToStringBenchmark {
@State(Scope.Benchmark)
class BigIntToStringSt {
val ds = DirectiveSet(V5, Account, Expression).fold(null, identity)
val ctx = lazyContexts(ds).value().evaluationContext(Common.emptyBlockchainEnvironment())
val ctx = lazyContexts((ds, true)).value().evaluationContext(Common.emptyBlockchainEnvironment())

val expr = FUNCTION_CALL(
Native(BIGINT_TO_STRING),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.nio.charset.StandardCharsets
import java.util.concurrent.{ThreadLocalRandom, TimeUnit}

import cats.Id
import cats.syntax.bifunctor._
import cats.syntax.bifunctor.*
import com.wavesplatform.account
import com.wavesplatform.account.PublicKey
import com.wavesplatform.common.state.ByteStr
Expand All @@ -13,18 +13,19 @@ import com.wavesplatform.crypto.Curve25519
import com.wavesplatform.lang.directives.DirectiveSet
import com.wavesplatform.lang.directives.values.{Account, DApp, V4}
import com.wavesplatform.lang.script.Script
import com.wavesplatform.lang.v1.EnvironmentFunctionsBenchmark._
import com.wavesplatform.lang.v1.EnvironmentFunctionsBenchmark.*
import com.wavesplatform.lang.v1.compiler.Terms.{CONST_STRING, EVALUATED, EXPR, FUNCTION_CALL}
import com.wavesplatform.lang.v1.evaluator.Log
import com.wavesplatform.lang.v1.evaluator.ctx.EvaluationContext
import com.wavesplatform.lang.v1.evaluator.ctx.impl.EnvironmentFunctions
import com.wavesplatform.lang.v1.evaluator.ctx.impl.waves.{Functions, WavesContext}
import com.wavesplatform.lang.v1.traits._
import com.wavesplatform.lang.v1.traits.*
import com.wavesplatform.lang.v1.traits.domain.Recipient.Address
import com.wavesplatform.lang.v1.traits.domain.{BlockInfo, Recipient, ScriptAssetInfo, Tx}
import com.wavesplatform.lang.{Common, Global, ValidationError}
import com.wavesplatform.wallet.Wallet
import monix.eval.Coeval
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.annotations.*
import org.openjdk.jmh.infra.Blackhole

import scala.util.Random
Expand Down Expand Up @@ -88,7 +89,7 @@ class EnvironmentFunctionsBenchmark {
@Benchmark
def addressFromString(st: AddressFromString, bh: Blackhole): Unit = {
val i = Random.nextInt(100)
bh.consume(eval(st.ctx, st.expr(i), V4, true))
bh.consume(eval(st.ctx, st.expr(i), V4))
}
}

Expand Down Expand Up @@ -130,14 +131,15 @@ object EnvironmentFunctionsBenchmark {
Right(Address(ByteStr(PublicKey(publicKey).toAddress.bytes)))

override def accountScript(addressOrAlias: Recipient): Option[Script] = ???
override def callScript(

def callScript(
dApp: Address,
func: String,
args: List[EVALUATED],
payments: Seq[(Option[Array[Byte]], Long)],
availableComplexity: Int,
reentrant: Boolean
): Coeval[(Either[ValidationError, EVALUATED], Int)] = ???
): Coeval[Id[(Either[ValidationError, (EVALUATED, Log[Id])], Int)]] = ???
}

val environmentFunctions = new EnvironmentFunctions(environment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ import java.util.concurrent.TimeUnit
import cats.Id
import com.wavesplatform.lang.Common
import com.wavesplatform.lang.directives.values.{V1, V3}
import com.wavesplatform.lang.v1.EvaluatorV2Benchmark._
import com.wavesplatform.lang.v1.EvaluatorV2Benchmark.*
import com.wavesplatform.lang.v1.compiler.Terms.{EXPR, IF, TRUE}
import com.wavesplatform.lang.v1.compiler.TestCompiler
import com.wavesplatform.lang.v1.evaluator.ctx.EvaluationContext
import com.wavesplatform.lang.v1.evaluator.EvaluatorV2
import com.wavesplatform.lang.v1.evaluator.ctx.{EvaluationContext, LoggedEvaluationContext}
import com.wavesplatform.lang.v1.evaluator.ctx.impl.PureContext
import com.wavesplatform.lang.v1.traits.Environment
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.annotations.*
import org.openjdk.jmh.infra.Blackhole

import scala.annotation.tailrec

object EvaluatorV2Benchmark {
val pureContext: CTX[Environment] = PureContext.build(V1, useNewPowPrecision = true, useNewPowPrecision = true).withEnvironment[Environment]
val pureContext: CTX[Environment] = PureContext.build(V1, useNewPowPrecision = true).withEnvironment[Environment]
val pureEvalContext: EvaluationContext[Environment, Id] = pureContext.evaluationContext(Common.emptyBlockchainEnvironment())
val evaluatorV2: EvaluatorV2 = new EvaluatorV2(LoggedEvaluationContext(_ => _ => (), pureEvalContext), V1, true)
val evaluatorV2: EvaluatorV2 = new EvaluatorV2(LoggedEvaluationContext(_ => _ => (), pureEvalContext), V1, true, true)
}

@OutputTimeUnit(TimeUnit.MILLISECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FoldBenchmark {
@State(Scope.Benchmark)
class FoldSt {
val ds = DirectiveSet(V5, Account, Expression).fold(null, identity)
val ctx = lazyContexts(ds).value().evaluationContext(Common.emptyBlockchainEnvironment())
val ctx = lazyContexts((ds, true)).value().evaluationContext(Common.emptyBlockchainEnvironment())

val function = "func f(acc: Boolean, elem: ByteVector) = acc && sigVerify(elem, base58'', base58'')"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.wavesplatform.lang.v1.FunctionHeader.Native
import com.wavesplatform.lang.v1.compiler.Terms.{CONST_BIGINT, FUNCTION_CALL}
import com.wavesplatform.lang.v1.evaluator.FunctionIds.{FRACTION_BIGINT, FRACTION_BIGINT_ROUNDS}
import com.wavesplatform.lang.v1.evaluator.ctx.impl.{PureContext, Rounding}
import org.openjdk.jmh.annotations.{State, _}
import org.openjdk.jmh.annotations.*
import org.openjdk.jmh.infra.Blackhole

@OutputTimeUnit(TimeUnit.MICROSECONDS)
Expand Down Expand Up @@ -42,7 +42,7 @@ class FractionBigIntBenchmark {
@State(Scope.Benchmark)
class FractionBigIntSt {
val ds = DirectiveSet(V5, Account, Expression).fold(null, identity)
val ctx = lazyContexts(ds).value().evaluationContext(Common.emptyBlockchainEnvironment())
val ctx = lazyContexts(ds -> true).value().evaluationContext(Common.emptyBlockchainEnvironment())

val max = CONST_BIGINT(PureContext.BigIntMax)
val halfMax = CONST_BIGINT(PureContext.BigIntMax / 2)
Expand All @@ -62,7 +62,7 @@ class FractionBigIntSt {

val expr3 = FUNCTION_CALL(
Native(FRACTION_BIGINT),
List(maxSqrt, maxSqrt, maxSqrt)
List(maxSqrt, maxSqrt, three)
)

val expr1Round = FUNCTION_CALL(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import java.util.concurrent.TimeUnit

import com.wavesplatform.lang.Common
import com.wavesplatform.lang.directives.DirectiveSet
import com.wavesplatform.lang.directives.values.{Account, Expression, V6}
import com.wavesplatform.lang.directives.values.{Account, Expression, V5, V6}
import com.wavesplatform.lang.utils.lazyContexts
import com.wavesplatform.lang.v1.compiler.Terms.EXPR
import com.wavesplatform.lang.v1.compiler.TestCompiler
import org.openjdk.jmh.annotations.{State, _}
import com.wavesplatform.lang.v1.evaluator.ContractEvaluator.LogExtraInfo
import com.wavesplatform.lang.v1.evaluator.EvaluatorV2
import org.openjdk.jmh.annotations.*
import org.openjdk.jmh.infra.Blackhole

@OutputTimeUnit(TimeUnit.MICROSECONDS)
Expand All @@ -19,22 +20,22 @@ import org.openjdk.jmh.infra.Blackhole
@Measurement(iterations = 10, time = 1)
class FractionIntBenchmark {
@Benchmark
def fraction1(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr1, V5, true))
def fraction1(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr1, LogExtraInfo(), V5, true, true))

@Benchmark
def fraction2(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr2, V5, true))
def fraction2(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr2, LogExtraInfo(), V5, true, true))

@Benchmark
def fraction3(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr3, V5, true))
def fraction3(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr3, LogExtraInfo(), V5, true, true))

@Benchmark
def fraction1Round(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr1Round, V5, true))
def fraction1Round(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr1Round, LogExtraInfo(), V5, true, true))

@Benchmark
def fraction2Round(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr2Round, V5, true))
def fraction2Round(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr2Round, LogExtraInfo(), V5, true, true))

@Benchmark
def fraction3Round(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr3Round, V5, true))
def fraction3Round(bh: Blackhole, s: St): Unit = bh.consume(EvaluatorV2.applyCompleted(s.ctx, s.expr3Round, LogExtraInfo(), V5, true, true))
}

@State(Scope.Benchmark)
Expand All @@ -45,11 +46,11 @@ class St {
val max = Long.MaxValue
val maxSqrt = 3037000499L

val expr1 = TestCompiler(V6).compileExpression(s"fraction($max / 2, 3, 3)").expr.asInstanceOf[EXPR]
val expr2 = TestCompiler(V6).compileExpression(s"fraction($max, -$max, -$max)").expr.asInstanceOf[EXPR]
val expr3 = TestCompiler(V6).compileExpression(s"fraction($maxSqrt, $maxSqrt, $maxSqrt)").expr.asInstanceOf[EXPR]
val expr1 = TestCompiler(V6).compileExpression(s"fraction($max / 2, 3, 3)").expr
val expr2 = TestCompiler(V6).compileExpression(s"fraction($max, -$max, -$max)").expr
val expr3 = TestCompiler(V6).compileExpression(s"fraction($maxSqrt, $maxSqrt, $maxSqrt)").expr

val expr1Round = TestCompiler(V6).compileExpression(s"fraction($max / 2, 3, 3, HALFEVEN)").expr.asInstanceOf[EXPR]
val expr2Round = TestCompiler(V6).compileExpression(s"fraction($max, -$max, -$max, HALFEVEN)").expr.asInstanceOf[EXPR]
val expr3Round = TestCompiler(V6).compileExpression(s"fraction($maxSqrt, $maxSqrt, $maxSqrt, HALFEVEN)").expr.asInstanceOf[EXPR]
val expr1Round = TestCompiler(V6).compileExpression(s"fraction($max / 2, 3, 3, HALFEVEN)").expr
val expr2Round = TestCompiler(V6).compileExpression(s"fraction($max, -$max, -$max, HALFEVEN)").expr
val expr3Round = TestCompiler(V6).compileExpression(s"fraction($maxSqrt, $maxSqrt, $maxSqrt, HALFEVEN)").expr
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.wavesplatform.common.utils.EitherExt2
import com.wavesplatform.lang.v1.ListIndexOfBenchmark.ListIndexOfSt
import com.wavesplatform.lang.v1.compiler.Terms.{CONST_STRING, EVALUATED}
import com.wavesplatform.lang.v1.evaluator.ctx.impl.PureContext
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.annotations.*
import org.openjdk.jmh.infra.Blackhole

@OutputTimeUnit(TimeUnit.MICROSECONDS)
Expand Down Expand Up @@ -41,10 +41,10 @@ object ListIndexOfBenchmark {
val listWithMaxCmpWeightElements = IndexedSeq.fill(1000)(CONST_STRING("a" * (ContractLimits.MaxCmpWeight.toInt - 1) + "b").explicitGet())
val listWithMaxSizeElements = IndexedSeq.fill(1000)(CONST_STRING(("a" * (150 * 1024 - 1)) + "b").explicitGet())

def indexOf(list: Seq[EVALUATED], element: EVALUATED): Either[String, EVALUATED] =
def indexOf(list: Seq[EVALUATED], element: EVALUATED) =
PureContext.genericListIndexOf(element, list.indexOf, list.indexWhere)

def lastIndexOf(list: Seq[EVALUATED], element: EVALUATED): Either[String, EVALUATED] =
def lastIndexOf(list: Seq[EVALUATED], element: EVALUATED) =
PureContext.genericListIndexOf(element, list.lastIndexOf(_), list.lastIndexWhere)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PowBigIntBenchmark {
@State(Scope.Benchmark)
class PowBigIntSt {
val ds = DirectiveSet(V5, Account, Expression).fold(null, identity)
val ctx = lazyContexts(ds).value().evaluationContext(Common.emptyBlockchainEnvironment())
val ctx = lazyContexts(ds -> true).value().evaluationContext(Common.emptyBlockchainEnvironment())

val max = PureContext.BigIntMax
val min = PureContext.BigIntMin
Expand Down
Loading

0 comments on commit 32a6967

Please sign in to comment.