From 6c1264cc085bf18ec973e8c0b015157ae5f29ac5 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Wed, 13 Jul 2022 15:15:37 +0300 Subject: [PATCH 1/5] remove incorrect comment in tx serialization; --- .../src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala | 3 --- 1 file changed, 3 deletions(-) diff --git a/sigmastate/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala b/sigmastate/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala index d67a71fa83..43481b39c1 100644 --- a/sigmastate/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala +++ b/sigmastate/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala @@ -121,9 +121,6 @@ object ErgoLikeTransactionSerializer extends SigmaSerializer[ErgoLikeTransaction w.putBytes(input.boxId) } // Serialize distinct ids of tokens in transaction outputs. - // This optimization is crucial to allow up to MaxTokens (== 255) in a box. - // Without it total size of all token ids 255 * 32 = 8160, - // way beyond MaxBoxSize (== 4K) val tokenIds = tx.outputCandidates.toColl .flatMap(box => box.additionalTokens.map(t => t._1)) From acb9544adf46dd380dde5e8dd1b81fc8b98ebc12 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Mon, 15 Aug 2022 13:08:02 +0300 Subject: [PATCH 2/5] Update README.md: added Acknowledgments --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index afda393b92..2fa7ba7a75 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,17 @@ libraryDependencies += "org.scorexfoundation" %% "sigma-state" % "4.0.3" | sigma-library | Implementation of graph IR nodes for Sigma types | | sigmastate | Implementation ErgoTree, Interpreter and cost estimation | +## Acknowledgments + +We thank JetBrains for [supporting](https://www.jetbrains.com/buy/opensource/) this project since 2021 by providing All Products Pack subscription. + + + +We thank YourKit for support of open source projects with its full-featured Java Profiler. +YourKit, LLC is the creator of YourKit Java Profiler +and YourKit .NET Profiler, +innovative and intelligent tools for profiling Java and .NET applications. + ## References - [Ergo Site](https://ergoplatform.org/en/) From 7f12a934079962a65c0a7a8fef480e772f7a6ae0 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Tue, 27 Sep 2022 21:46:17 +0300 Subject: [PATCH 3/5] Update CONTRIBUTING.md --- CONTRIBUTING.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ff928680e4..e6ab243abc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,13 @@ +## Building + +Clone the repository and then run tests. + +```shell +git clone git@github.com:ScorexFoundation/sigmastate-interpreter.git +cd sigmastate-interpreter +sbt test +``` + ## Releasing To publish release version to Sonatype, do the following: - make a tag with version number `vX.Y.Z` (used by `sbt-dynver` to set `version` in `build.sbt`); From e5e6554581975b23d35667e082d5c5a3d288eafb Mon Sep 17 00:00:00 2001 From: Benjamin Schulte Date: Thu, 3 Nov 2022 10:12:53 +0100 Subject: [PATCH 4/5] Fix ErgoBoxCandidate.tokens does not account for same token multiple times in array, closes #838 --- .../org/ergoplatform/ErgoBoxCandidate.scala | 21 ++++++++++++------- .../ErgoLikeTransactionSpec.scala | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/sigmastate/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala b/sigmastate/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala index bf13b8d9c8..003bfbe977 100644 --- a/sigmastate/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala +++ b/sigmastate/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala @@ -3,7 +3,7 @@ package org.ergoplatform import java.util import org.ergoplatform.ErgoBox._ import org.ergoplatform.settings.ErgoAlgos -import scorex.util.{bytesToId, ModifierId} +import scorex.util.{ModifierId, bytesToId} import sigmastate.Values._ import sigmastate._ import sigmastate.SType.AnyOps @@ -16,7 +16,7 @@ import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.util.safeNewArray import spire.syntax.all.cfor -import scala.collection.immutable +import scala.collection.{immutable, mutable} import scala.runtime.ScalaRunTime /** @@ -100,12 +100,17 @@ class ErgoBoxCandidate(val value: Long, s"tokens: (${additionalTokens.map(t => ErgoAlgos.encode(t._1) + ":" + t._2).toArray.mkString(", ")}), " + s"$additionalRegisters, creationHeight: $creationHeight)" - /** Additional tokens stored in the box. */ - lazy val tokens: Map[ModifierId, Long] = - additionalTokens - .toArray - .map(t => bytesToId(t._1) -> t._2) - .toMap + /** Additional tokens stored in the box, merged into a Map */ + lazy val tokens: Map[ModifierId, Long] = { + val merged = new mutable.HashMap[ModifierId, Long] + additionalTokens.foreach { + case (id, amount) => { + val mId = bytesToId(id) + merged.put(mId, java7.compat.Math.addExact(merged.getOrElse(mId, 0L), amount)) + } + } + merged.toMap + } } object ErgoBoxCandidate { diff --git a/sigmastate/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala b/sigmastate/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala index ab27179bec..5de774def8 100644 --- a/sigmastate/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala +++ b/sigmastate/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala @@ -46,6 +46,7 @@ class ErgoLikeTransactionSpec extends SigmaDslTesting { 100, Coll( Digest32 @@ (ErgoAlgos.decodeUnsafe(token1)) -> 10000000L, + Digest32 @@ (ErgoAlgos.decodeUnsafe(token1)) -> 500L, Digest32 @@ (ErgoAlgos.decodeUnsafe(token2)) -> 500L ) ) @@ -70,6 +71,7 @@ class ErgoLikeTransactionSpec extends SigmaDslTesting { b1.tokens shouldBe expectedTokens b1_clone.tokens shouldBe expectedTokens b3.tokens shouldBe expectedTokens + b2.tokens shouldBe Map[ModifierId, Long](ModifierId @@ token1 -> 10000500L, ModifierId @@ token2 -> 500L) assertResult(true)(b1.hashCode() == b1.hashCode()) assertResult(true)(b1 == b1) From 0c2ba58b3d30ac168418d1f5eeda4c898e003d9b Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Fri, 4 Nov 2022 09:52:47 +0100 Subject: [PATCH 5/5] fix-838: comments on consensus + formatting --- .../scala/org/ergoplatform/ErgoBoxCandidate.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sigmastate/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala b/sigmastate/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala index 003bfbe977..9fa6cafaf0 100644 --- a/sigmastate/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala +++ b/sigmastate/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala @@ -100,14 +100,14 @@ class ErgoBoxCandidate(val value: Long, s"tokens: (${additionalTokens.map(t => ErgoAlgos.encode(t._1) + ":" + t._2).toArray.mkString(", ")}), " + s"$additionalRegisters, creationHeight: $creationHeight)" - /** Additional tokens stored in the box, merged into a Map */ + /** Additional tokens stored in the box, merged into a Map. + * This method is not used in ErgoTree and serialization, not part of consensus. + */ lazy val tokens: Map[ModifierId, Long] = { val merged = new mutable.HashMap[ModifierId, Long] - additionalTokens.foreach { - case (id, amount) => { - val mId = bytesToId(id) - merged.put(mId, java7.compat.Math.addExact(merged.getOrElse(mId, 0L), amount)) - } + additionalTokens.foreach { case (id, amount) => + val mId = bytesToId(id) + merged.put(mId, java7.compat.Math.addExact(merged.getOrElse(mId, 0L), amount)) } merged.toMap }