Skip to content

Commit

Permalink
Merge pull request #575 from ScorexFoundation/i573-ergolikectx-json
Browse files Browse the repository at this point in the history
Json representation for ErgoLikeContext
  • Loading branch information
aslesarenko authored Aug 23, 2019
2 parents dd1b323 + db1895e commit 4135eed
Show file tree
Hide file tree
Showing 74 changed files with 1,520 additions and 653 deletions.
11 changes: 9 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ libraryDependencies ++= Seq(
"org.spire-math" %% "debox" % "0.8.0"
) ++ testingDependencies

val circeVersion = "0.10.0"

libraryDependencies ++= Seq(
"io.circe" %% "circe-core",
"io.circe" %% "circe-generic",
"io.circe" %% "circe-parser"
).map(_ % circeVersion)

scalacOptions ++= Seq("-feature", "-deprecation")

Expand Down Expand Up @@ -201,7 +208,7 @@ lazy val sigma = (project in file("."))
.settings(commonSettings: _*)

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

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

def runSpamTestTask(task: String, sigmastateVersion: String, log: Logger): Unit = {
val spamBranch = "master"
val spamBranch = "i4-add-input-hash"
val envVars = Seq("SIGMASTATE_VERSION" -> sigmastateVersion,
"SPECIAL_VERSION" -> specialVersion,
// SSH_SPAM_REPO_KEY should be set (see Jenkins Credentials Binding Plugin)
Expand Down
13 changes: 9 additions & 4 deletions sigma-impl/src/main/scala/special/sigma/Extensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ class DslSyntaxExtensions(dsl: SigmaDslBuilder) {

object Extensions {

def showECPoint(p: ECPoint) = {
val rawX = p.getRawXCoord.toString.substring(0, 6)
val rawY = p.getRawYCoord.toString.substring(0, 6)
s"ECPoint($rawX,$rawY,...)"
def showECPoint(p: ECPoint): String = {
if (p.isInfinity) {
"INF"
}
else {
val rawX = p.getRawXCoord.toString.substring(0, 6)
val rawY = p.getRawYCoord.toString.substring(0, 6)
s"ECPoint($rawX,$rawY,...)"
}
}

implicit class GroupElementOps(val source: GroupElement) extends AnyVal {
Expand Down
25 changes: 12 additions & 13 deletions src/main/scala/org/ergoplatform/ErgoBox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package org.ergoplatform

import com.google.common.primitives.Shorts
import org.ergoplatform.ErgoBox.{NonMandatoryRegisterId, TokenId}
import org.ergoplatform.settings.ErgoAlgos
import scorex.crypto.authds.ADKey
import scorex.util.encode.Base16
import scorex.crypto.hash.{Digest32, Blake2b256}
import scorex.crypto.hash.{Blake2b256, Digest32}
import scorex.util._
import sigmastate.Values._
import sigmastate.SCollection.SByteArray
import sigmastate.SType.AnyOps
import sigmastate.Values._
import sigmastate._
import sigmastate.eval.Extensions._
import sigmastate.eval._
import sigmastate.serialization.SigmaSerializer
import sigmastate.SCollection.SByteArray
import sigmastate.utils.{SigmaByteReader, SigmaByteWriter, Helpers}
import sigmastate.utils.{Helpers, SigmaByteReader, SigmaByteWriter}
import sigmastate.utxo.ExtractCreationInfo
import special.collection._
import sigmastate.eval._
import sigmastate.eval.Extensions._

import scala.runtime.ScalaRunTime

Expand Down Expand Up @@ -84,8 +84,8 @@ class ErgoBox(
def toCandidate: ErgoBoxCandidate =
new ErgoBoxCandidate(value, ergoTree, creationHeight, additionalTokens, additionalRegisters)

override def toString: Idn = s"ErgoBox(${Base16.encode(id)},$value,$ergoTree," +
s"tokens: (${additionalTokens.map(t => Base16.encode(t._1) + ":" + t._2)}), $transactionId, " +
override def toString: String = s"ErgoBox(${ErgoAlgos.encode(id)},$value,$ergoTree," +
s"tokens: (${additionalTokens.map(t => ErgoAlgos.encode(t._1) + ":" + t._2)}), $transactionId, " +
s"$index, $additionalRegisters, $creationHeight)"
}

Expand All @@ -100,7 +100,7 @@ object ErgoBox {
val size: Short = 32
}

val MaxBoxSize: Int = ErgoConstants.MaxBoxSize.value
val MaxBoxSize: Int = SigmaConstants.MaxBoxSize.value

val STokenType = STuple(SByteArray, SLong)
val STokensRegType = SCollection(STokenType)
Expand Down Expand Up @@ -134,9 +134,9 @@ object ErgoBox {
val TokensRegId: MandatoryRegisterId = R2
val ReferenceRegId: MandatoryRegisterId = R3

val MaxTokens: Int = ErgoConstants.MaxTokens.value
val MaxTokens: Int = SigmaConstants.MaxTokens.value

val maxRegisters: Int = ErgoConstants.MaxRegisters.value
val maxRegisters: Int = SigmaConstants.MaxRegisters.value

/** @hotspot don't beautify the code in this companion */
private val _mandatoryRegisters: Array[MandatoryRegisterId] = Array(R0, R1, R2, R3)
Expand Down Expand Up @@ -197,5 +197,4 @@ object ErgoBox {
ergoBoxCandidate.toBox(transactionId, index.toShort)
}
}

}
4 changes: 2 additions & 2 deletions src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package org.ergoplatform
import java.util

import org.ergoplatform.ErgoBox._
import org.ergoplatform.settings.ErgoAlgos
import scorex.crypto.hash.Digest32
import scorex.util.encode.Base16
import scorex.util.ModifierId
import sigmastate.Values._
import sigmastate._
Expand Down Expand Up @@ -75,7 +75,7 @@ class ErgoBoxCandidate(val value: Long,
ScalaRunTime._hashCode((value, ergoTree, additionalTokens, additionalRegisters, creationHeight))

override def toString: Idn = s"ErgoBoxCandidate($value, $ergoTree," +
s"tokens: (${additionalTokens.map(t => Base16.encode(t._1) + ":" + t._2).toArray.mkString(", ")}), " +
s"tokens: (${additionalTokens.map(t => ErgoAlgos.encode(t._1) + ":" + t._2).toArray.mkString(", ")}), " +
s"$additionalRegisters, creationHeight: $creationHeight)"
}

Expand Down
Loading

0 comments on commit 4135eed

Please sign in to comment.