Skip to content

Commit

Permalink
Merge pull request #634 from ScorexFoundation/develop
Browse files Browse the repository at this point in the history
Release v3.2.0
  • Loading branch information
kushti committed Jan 19, 2020
2 parents 910ef28 + abab425 commit 291997a
Show file tree
Hide file tree
Showing 86 changed files with 610 additions and 438 deletions.
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@ jdk:
- oraclejdk8
stages:
- test
# - coverage
- name: release
if: tag =~ ^v
- name: snapshot
if: "(NOT tag IS present) AND (type = push)"
jobs:
include:
- stage: test
script: sbt -jvm-opts .travis.jvmopts +test
# enable scoverage after SpamSpecification timeout issue is resolved
# script: sbt -jvm-opts .travis.jvmopts coverage test
# - stage: coverage
# script: sbt coverageReport coveralls
script: sbt -jvm-opts .travis.jvmopts +coverage +test && sbt +coverageReport coverageAggregate coveralls
- stage: release
# decrypt the private key (exported via https://docs.scala-lang.org/overviews/contributors/index.html#export-your-pgp-key-pair )
script: openssl aes-256-cbc -K $encrypted_98cf3af00429_key -iv $encrypted_98cf3af00429_iv -in ci/secring.asc.enc -out ci/secring.asc -d && gpg --import ci/secring.asc && sbt -jvm-opts .travis.jvmopts +publishSigned sonatypeBundleRelease
- stage: snapshot
script: sbt -jvm-opts .travis.jvmopts +publish
Expand All @@ -37,4 +33,3 @@ env:
- secure: IGwd+lY2TfkAeX1SfzaYBwyhiiPaFrTxoF0e+4R1bkGxiGCce1hBYjn15z1HRfK+k3hgEZh/FBG7dv8LQfNWQ6AJY5PQ2zwckd4ArYMhTVpiY4eRzUMqO1/gjTCCbbTjfFKOMsR2pAw+TGeglqoX4eyziIaS8nR901dZcFvHuC1Fr5EdKFZ0x+WHnX8vaSQoDE4u1MoBnyo5cRVumXG+xvs1Q0nZXm/hd/Flfx5u3L7veKAkGtvbHmdsJoSSySTbc1MGYQtofQjbjd9AVvUhgfP32J63UCC2SqgWWKVvIjW+dUn414BV3lelnWR3FdzhC7AUJqYWVfSILh1aj3STnizRnjtCScm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ECm8r+kgB+o2G3i4tEIYcIC5Jbdcbjf4bk6uNZW/X3dna0irl/Mdswt7rTLzLan1rPz3k8Bylgs8ehETFBGr8HyNitEa8ODyaEXa84MPQaucXUmpHS+sUEhQn0Z70T70d1H9ZubUhGv9VLltNoSWkPGW5CPZlpQTHl63ZShfmylfQuQVTbVMdL8LLUHn2x2edlDKMGD8YPH5d+of0AKc3IKnlnMM36WjgYVsf1yehfLi0NH/b2Dzk7wLjetu/bw8Cu9Ne6/u0Lu83Hbh4DyS2iPQivDUGB+JXlHDFI4uji3GurnvpFDku1gbc4HVoFqhgOWyXQAiRllj2BXmq2vwp6797TUG4HrD2EVzIJV7eIZdWNN/QttZtNxNdSbBq8QQc92G2SU4q7PcogMSr0LpX05SfyL1sMgX2WeGzFzyMIu/+rAJhG0lPt7krBxEfQrRtTLdJ9eyeFjFQlxM6G/9gk68j+Nida6KunLwe9QEl2T+t1YbE4i9pndoCMJFxAOjirhw5OM3PfSWfb/mU7zXd4PSNK7RQIdOaPJff5C6UEM7h/iQ6riRZp1Pn7d/rxppTXsvUbtvwUYnkoOeUZyMvQNQsPI6Slns8jWl0zp5XiTmzSRVOuH3ME=
# decrypt the private key (exported via https://docs.scala-lang.org/overviews/contributors/index.html#export-your-pgp-key-pair )
9 changes: 5 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ name := "sigma-state"

lazy val scala212 = "2.12.10"
lazy val scala211 = "2.11.12"
crossScalaVersions := Seq(scala212, scala211)
scalaVersion := scala212

javacOptions ++=
"-source" :: "1.7" ::
Expand All @@ -20,6 +18,8 @@ lazy val allConfigDependency = "compile->compile;test->test"

lazy val commonSettings = Seq(
organization := "org.scorexfoundation",
crossScalaVersions := Seq(scala212, scala211),
scalaVersion := scala212,
resolvers += Resolver.sonatypeRepo("public"),
licenses := Seq("CC0" -> url("https://creativecommons.org/publicdomain/zero/1.0/legalcode")),
homepage := Some(url("https://github.com/ScorexFoundation/sigmastate-interpreter")),
Expand Down Expand Up @@ -291,14 +291,15 @@ lazy val aggregateCompile = ScopeFilter(

lazy val rootSettings = Seq(
sources in Compile := sources.all(aggregateCompile).value.flatten,
sourceDirectories in Compile := sourceDirectories.all(aggregateCompile).value.flatten,
libraryDependencies := libraryDependencies.all(aggregateCompile).value.flatten,
mappings in (Compile, packageSrc) ++= (mappings in(Compile, packageSrc)).all(aggregateCompile).value.flatten,
mappings in (Test, packageBin) ++= (mappings in(Test, packageBin)).all(aggregateCompile).value.flatten,
mappings in(Test, packageSrc) ++= (mappings in(Test, packageSrc)).all(aggregateCompile).value.flatten
)

def runErgoTask(task: String, sigmastateVersion: String, log: Logger): Unit = {
val ergoBranch = "sigma-core-opt"
val ergoBranch = "master"
val sbtEnvVars = Seq("BUILD_ENV" -> "test", "SIGMASTATE_VERSION" -> sigmastateVersion)

log.info(s"Testing current build in Ergo (branch $ergoBranch):")
Expand Down Expand Up @@ -352,7 +353,7 @@ commands += Command.command("ergoItTest") { state =>
}

def runSpamTestTask(task: String, sigmastateVersion: String, log: Logger): Unit = {
val spamBranch = "master"
val spamBranch = "revert-23-revert-22-serialize-opt"
val envVars = Seq("SIGMASTATE_VERSION" -> sigmastateVersion,
"SPECIAL_VERSION" -> specialVersion,
// SSH_SPAM_REPO_KEY should be set (see Jenkins Credentials Binding Plugin)
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class P2PKAddress(val pubkey: ProveDlog,
override val script: ErgoTree = {
// NOTE: we don't segregate constants because the whole tree is single constant
// and we want different addreses of this type to have different `script` values
ErgoTree(ErgoTree.DefaultHeader, IndexedSeq.empty, SigmaPropConstant(pubkey))
ErgoTree(ErgoTree.DefaultHeader, ErgoTree.EmptyConstants, SigmaPropConstant(pubkey))
}

override def equals(obj: Any): Boolean = obj match {
Expand Down
15 changes: 12 additions & 3 deletions sigmastate/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class ErgoBoxCandidate(val value: Long,

object ErgoBoxCandidate {
val UndefinedBoxRef: Coll[Byte] = Array.fill(34)(0: Byte).toColl

/** @hotspot don't beautify the code */
object serializer extends SigmaSerializer[ErgoBoxCandidate, ErgoBoxCandidate] {

def serializeBodyWithIndexedDigests(obj: ErgoBoxCandidate,
Expand All @@ -90,7 +92,14 @@ object ErgoBoxCandidate {
w.putBytes(DefaultSerializer.serializeErgoTree(obj.ergoTree))
w.putUInt(obj.creationHeight)
w.putUByte(obj.additionalTokens.size)
obj.additionalTokens.foreach { case (id, amount) =>

val unzipped = Colls.unzip(obj.additionalTokens)
val ids = unzipped._1
val amounts = unzipped._2
val limit = ids.length
cfor(0)(_ < limit, _ + 1) { i =>
val id = ids(i)
val amount = amounts(i)
if (tokensInTx.isDefined) {
val tokenIndex = tokensInTx.get.indexWhere(v => util.Arrays.equals(v, id), 0)
if (tokenIndex == -1) sys.error(s"failed to find token id ($id) in tx's digest index")
Expand All @@ -100,6 +109,7 @@ object ErgoBoxCandidate {
}
w.putULong(amount)
}

val nRegs = obj.additionalRegisters.keys.size
if (nRegs + ErgoBox.startingNonMandatoryIndex > 255)
sys.error(s"The number of non-mandatory indexes $nRegs exceeds ${255 - ErgoBox.startingNonMandatoryIndex} limit.")
Expand All @@ -108,7 +118,7 @@ object ErgoBoxCandidate {
// this convention allows to save 1 bite for each register
val startReg = ErgoBox.startingNonMandatoryIndex
val endReg = ErgoBox.startingNonMandatoryIndex + nRegs - 1
for (regId <- startReg to endReg) {
cfor(startReg: Int)(_ <= endReg, _ + 1) { regId =>
val reg = ErgoBox.findRegisterByIndex(regId.toByte).get
obj.get(reg) match {
case Some(v) =>
Expand All @@ -124,7 +134,6 @@ object ErgoBoxCandidate {
serializeBodyWithIndexedDigests(obj, None, w)
}

/** @hotspot don't beautify the code */
def parseBodyWithIndexedDigests(digestsInTx: Option[Coll[TokenId]], r: SigmaByteReader): ErgoBoxCandidate = {
val previousPositionLimit = r.positionLimit
r.positionLimit = r.position + ErgoBox.MaxBoxSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object ErgoScriptPredef {
// first segregated constant is delta, so key is second constant
val positions = IntArrayConstant(Array[Int](1))
val minerPubkeySigmaProp = CreateProveDlog(DecodePoint(minerPkBytesVal))
val newVals = Values.ConcreteCollection(Vector[SigmaPropValue](minerPubkeySigmaProp), SSigmaProp)
val newVals = Values.ConcreteCollection(Array[SigmaPropValue](minerPubkeySigmaProp), SSigmaProp)
SubstConstants(genericMinerPropBytes, positions, newVals)
}

Expand Down
Loading

0 comments on commit 291997a

Please sign in to comment.