Skip to content

Commit

Permalink
sigma dep update to 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Aug 23, 2024
1 parent 6510686 commit 90a11cb
Show file tree
Hide file tree
Showing 129 changed files with 452 additions and 447 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ val circeVersion = "0.13.0"
val akkaVersion = "2.6.10"
val akkaHttpVersion = "10.2.4"

val sigmaStateVersion = "5.0.14-244-fc056d8f-SNAPSHOT"
val sigmaStateVersion = "5.0.14-246-a8f1d666-SNAPSHOT"
val ficusVersion = "1.4.7"

// for testing current sigmastate build (see sigmastate-ergo-it jenkins job)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.ergoplatform.http.api

import cats.syntax.either._
import sigmastate.utils.Helpers._

import io.circe._
import io.circe.syntax._
import org.bouncycastle.util.BigIntegers
Expand All @@ -14,24 +16,22 @@ import org.ergoplatform.sdk.wallet.secrets.{DhtSecretKey, DlogSecretKey}
import org.ergoplatform.settings.{Algos, ErgoAlgos}
import org.ergoplatform.wallet.Constants.ScanId
import org.ergoplatform.wallet.boxes.TrackedBox
import org.ergoplatform.wallet.interface4j.SecretString
import org.ergoplatform.wallet.interpreter.TransactionHintsBag
import org.ergoplatform.validation.ValidationResult
import scorex.crypto.authds.merkle.MerkleProof
import scorex.crypto.authds.{LeafData, Side}
import scorex.crypto.hash.Digest
import scorex.util.encode.Base16
import sigmastate.Values.SigmaBoolean
import sigmastate._
import sigmastate.crypto.CryptoConstants.EcPointType
import sigmastate.crypto.DLogProtocol.{DLogProverInput, FirstDLogProverMessage, ProveDlog}
import sigmastate.crypto.DLogProtocol.{DLogProverInput, FirstDLogProverMessage}
import sigmastate.crypto.VerifierMessage.Challenge
import sigmastate.crypto._
import sigmastate.interpreter._
import sigmastate.serialization.OpCodes
import org.ergoplatform.sdk.JsonCodecs
import sigmastate.eval.Extensions.ArrayOps
import sigmastate.utils.Helpers._
import org.ergoplatform.sdk.{JsonCodecs, SecretString}
import sigma.crypto.EcPointType
import sigma.data._
import sigma.serialization.{OpCodes, SigSerializer}
import sigma.Extensions.ArrayOps

import java.math.BigInteger
import scala.annotation.nowarn
Expand Down Expand Up @@ -129,7 +129,7 @@ trait ApiCodecs extends JsonCodecs {
})

implicit val secretBigIntEncoder: Encoder[BigInteger] = Encoder.instance { w =>
ErgoAlgos.encode(BigIntegers.asUnsignedByteArray(CryptoConstants.groupSize, w)).asJson
ErgoAlgos.encode(BigIntegers.asUnsignedByteArray(sigma.crypto.groupSize, w)).asJson
}

implicit val secretBigIntDecoder: Decoder[BigInteger] = arrayBytesDecoder.map { bytes =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import org.ergoplatform.nodeView.mempool.TransactionMembershipProof
import scorex.crypto.authds.{ADDigest, SerializedAdProof}
import scorex.crypto.hash.{Blake2b256, Digest32}
import scorex.util.{ModifierId, ScorexLogging}
import sigmastate.crypto.DLogProtocol.ProveDlog
import sigmastate.crypto.CryptoFacade
import sigma.crypto.CryptoFacade
import sigma.data.ProveDlog

import scala.annotation.tailrec
import scala.util.Try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.ergoplatform.mining

import cats.syntax.either._
import sigmastate.utils.Helpers._

import io.circe.syntax._
import io.circe.{Decoder, Encoder, HCursor}
import org.bouncycastle.util.BigIntegers
Expand All @@ -10,8 +11,7 @@ import org.ergoplatform.modifiers.history.header.Header.Version
import org.ergoplatform.settings.Algos
import org.ergoplatform.serialization.ErgoSerializer
import scorex.util.serialization.{Reader, Writer}
import sigmastate.crypto.CryptoConstants
import sigmastate.crypto.CryptoConstants.EcPointType
import sigma.crypto.{CryptoConstants, EcPointType}

/**
* Solution for an Autolykos PoW puzzle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.ergoplatform.mining
import org.ergoplatform.modifiers.history.header.Header
import scorex.crypto.authds.ADDigest
import scorex.crypto.hash.Digest32
import sigmastate.crypto.CryptoConstants.EcPointType
import sigma.crypto.EcPointType

import scala.util.{Random, Success, Try}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.ergoplatform.mining

import cats.syntax.either._
import sigmastate.utils.Helpers._

import io.circe.{Encoder, Json}
import org.ergoplatform.modifiers.history.BlockTransactions
import org.ergoplatform.nodeView.mempool.TransactionMembershipProof
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import io.circe.syntax._
import io.circe.{Encoder, Json}
import org.ergoplatform.http.api.ApiCodecs
import org.ergoplatform.nodeView.history.ErgoHistoryUtils.Height
import sigmastate.crypto.DLogProtocol.ProveDlog
import sigma.data.ProveDlog


/**
Expand Down
5 changes: 2 additions & 3 deletions ergo-core/src/main/scala/org/ergoplatform/mining/mining.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package org.ergoplatform

import org.bouncycastle.util.BigIntegers
import scorex.crypto.hash.Blake2b256
import sigmastate.crypto.CryptoConstants.EcPointType
import sigmastate.crypto.{BcDlogGroup, CryptoConstants}
import sigma.crypto.{BcDlogGroup, CryptoConstants, EcPointType}
import sigma.serialization.{GroupElementSerializer, SigmaSerializer}
import sigmastate.crypto.DLogProtocol.DLogProverInput
import sigmastate.serialization.{GroupElementSerializer, SigmaSerializer}

package object mining {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.ergoplatform.modifiers

import cats.syntax.either._
import sigmastate.utils.Helpers._

import io.circe.syntax._
import io.circe.{Decoder, Encoder, HCursor, Json}
import org.ergoplatform.http.api.ApiCodecs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.ergoplatform.modifiers.history

import cats.syntax.either._
import sigmastate.utils.Helpers._

import io.circe.syntax._
import io.circe.{Decoder, Encoder, HCursor}
import org.ergoplatform.http.api.ApiCodecs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import org.ergoplatform.modifiers.history.header.Header._
import org.ergoplatform.nodeView.history.ErgoHistoryUtils._
import org.ergoplatform.settings.Constants
import scorex.util._
import sigmastate.crypto.CryptoConstants.EcPointType
import sigmastate.eval.CGroupElement
import sigmastate.eval.Extensions._
import sigma.crypto.EcPointType
import sigma.data.CGroupElement
import sigma.Extensions._

/**
* Only header fields that can be predicted by a miner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.ergoplatform.modifiers.history.extension

import cats.syntax.either._
import sigmastate.utils.Helpers._

import com.google.common.primitives.Bytes
import io.circe.syntax._
import io.circe.{Decoder, Encoder, HCursor}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import org.ergoplatform.serialization.ErgoSerializer
import scorex.crypto.authds.ADDigest
import scorex.crypto.hash.Digest32
import scorex.util._
import sigmastate.crypto.CryptoConstants.EcPointType
import sigmastate.eval.Extensions._
import sigmastate.eval.{CAvlTree, CBigInt, CGroupElement, CHeader}
import sigma.Colls
import sigma.Extensions._
import sigma.crypto.EcPointType
import sigma.data.{CAvlTree, CBigInt, CGroupElement, CHeader}

import scala.annotation.nowarn
import scala.concurrent.duration.FiniteDuration
Expand Down Expand Up @@ -146,11 +147,10 @@ object Header extends ApiCodecs {

def toSigma(header: Header): sigma.Header =
CHeader(
id = header.id.toBytes.toColl,
version = header.version,
parentId = header.parentId.toBytes.toColl,
ADProofsRoot = header.ADProofsRoot.asInstanceOf[Array[Byte]].toColl,
stateRoot = CAvlTree(ErgoInterpreter.avlTreeFromDigest(header.stateRoot.toColl)),
stateRootDigest = header.stateRoot.toColl,
transactionsRoot = header.transactionsRoot.asInstanceOf[Array[Byte]].toColl,
timestamp = header.timestamp,
nBits = header.nBits,
Expand All @@ -160,7 +160,8 @@ object Header extends ApiCodecs {
powOnetimePk = CGroupElement(header.powSolution.w),
powNonce = header.powSolution.n.toColl,
powDistance = CBigInt(header.powSolution.d.bigInteger),
votes = header.votes.toColl
votes = header.votes.toColl,
unparsedBytes = Colls.emptyColl[Byte] // todo: fix after merging w. 5.0.23
)

val modifierTypeId: NetworkObjectTypeId.Value = HeaderTypeId.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.ergoplatform.modifiers.history.popow

import cats.syntax.either._
import sigmastate.utils.Helpers._

import cats.Traverse
import cats.implicits.{catsStdInstancesForEither, catsStdInstancesForList}
import io.circe.{Decoder, Encoder, Json}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.ergoplatform.modifiers.mempool
import io.circe.syntax._
import org.ergoplatform.{DataInput, ErgoBox, ErgoBoxCandidate, ErgoLikeTransaction, ErgoLikeTransactionSerializer, Input}
import org.ergoplatform.ErgoBox.BoxId
import org.ergoplatform.SigmaConstants.{MaxBoxSize, MaxPropositionBytes}
import org.ergoplatform._
import org.ergoplatform.http.api.ApiCodecs
import org.ergoplatform.mining.emission.EmissionRules
Expand All @@ -28,8 +27,8 @@ import org.ergoplatform.validation.{InvalidModifier, ModifierValidator, Validati
import scorex.db.ByteArrayUtils
import scorex.util.serialization.{Reader, Writer}
import scorex.util.{ModifierId, ScorexLogging, bytesToId}
import sigmastate.serialization.ConstantStore
import sigmastate.utils.{SigmaByteReader, SigmaByteWriter}
import sigma.data.SigmaConstants.{MaxBoxSize, MaxPropositionBytes}
import sigma.serialization.{ConstantStore, SigmaByteReader, SigmaByteWriter}

import java.util
import scala.annotation.nowarn
Expand Down Expand Up @@ -491,7 +490,7 @@ object ErgoTransactionSerializer extends ErgoSerializer[ErgoTransaction] {

override def serialize(tx: ErgoTransaction, w: Writer): Unit = {
val elt = new ErgoLikeTransaction(tx.inputs, tx.dataInputs, tx.outputCandidates)
ErgoLikeTransactionSerializer.serialize(elt, new SigmaByteWriter(w, None))
ErgoLikeTransactionSerializer.serialize(elt, new SigmaByteWriter(w, None, None, None))
}

override def parse(r: Reader): ErgoTransaction = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import org.ergoplatform.validation.{InvalidModifier, ModifierValidator, Validati
import scorex.crypto.authds.ADDigest
import scorex.util.ScorexLogging
import scorex.util.serialization.{Reader, Writer}
import sigmastate.crypto.CryptoConstants.EcPointType
import sigmastate.eval.Extensions.ArrayOps
import sigmastate.eval.SigmaDsl
import sigma.Coll
import sigma.eval.SigmaDsl
import sigma.Extensions.ArrayOps
import sigma.crypto.EcPointType

import scala.collection.compat.immutable.ArraySeq
import scala.util.{Failure, Success, Try}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package org.ergoplatform.settings
import org.ergoplatform.mining.difficulty.DifficultySerializer
import org.ergoplatform.nodeView.history.ErgoHistoryUtils.Difficulty
import scorex.crypto.authds.avltree.batch.AvlTreeParameters
import sigmastate.Values
import sigmastate.Values.ErgoTree
import sigma.ast.{ErgoTree, FalseLeaf, TrueLeaf}
import sigma.ast.ErgoTree.{HeaderType, ZeroHeader}
import sigma.ast.syntax.{FalseSigmaProp, TrueSigmaProp}

object Constants {
/**
Expand Down Expand Up @@ -42,9 +43,6 @@ object Constants {

val SoftForkEpochs = 32 //about 45.5 days

def TrueLeaf: ErgoTree = ErgoTree.fromProposition(Values.TrueLeaf.toSigmaProp)
def FalseLeaf: ErgoTree = ErgoTree.fromProposition(Values.FalseLeaf.toSigmaProp)

val StringEncoding = "UTF-8"

// Maximum extension size
Expand All @@ -59,4 +57,8 @@ object Constants {
*/
object StateTreeParameters extends AvlTreeParameters(keySize = HashLength, valueSize = None, labelSize = HashLength)

def FalseTree: ErgoTree = ErgoTree.fromProposition(FalseLeaf.toSigmaProp)

def TrueTree: ErgoTree = ErgoTree.fromProposition(TrueLeaf.toSigmaProp)

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import org.ergoplatform.core.BytesSerializable
import org.ergoplatform.http.api.ApiCodecs
import org.ergoplatform.modifiers.history.extension.{Extension, ExtensionCandidate}
import org.ergoplatform.utils
import org.ergoplatform.validation.SigmaValidationSettings
import org.ergoplatform.serialization.ErgoSerializer
import org.ergoplatform.validation.{InvalidModifier, ModifierValidator, ValidationResult, ValidationSettings}
import scorex.util.serialization.{Reader, Writer}
import sigma.validation.SigmaValidationSettings

import scala.util.Try

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package org.ergoplatform.settings
import org.ergoplatform.validation.RuleStatusSerializer
import org.ergoplatform.serialization.ErgoSerializer
import scorex.util.serialization.{Reader, Writer}
import sigmastate.serialization.ConstantStore
import sigmastate.utils.{SigmaByteReader, SigmaByteWriter}
import sigma.serialization.{ConstantStore, SigmaByteReader, SigmaByteWriter}

case class ErgoValidationSettingsUpdate(rulesToDisable: Seq[Short],
statusUpdates: Seq[(Short, org.ergoplatform.validation.RuleStatus)]) {
statusUpdates: Seq[(Short, sigma.validation.RuleStatus)]) {

def ++(that: ErgoValidationSettingsUpdate): ErgoValidationSettingsUpdate = {
val newRules = (rulesToDisable ++ that.rulesToDisable).distinct.sorted
Expand All @@ -23,10 +22,10 @@ object ErgoValidationSettingsUpdate {

object ErgoValidationSettingsUpdateSerializer extends ErgoSerializer[ErgoValidationSettingsUpdate] {

private val FirstRule = org.ergoplatform.validation.ValidationRules.FirstRuleId
private val FirstRule = sigma.validation.ValidationRules.FirstRuleId

override def serialize(obj: ErgoValidationSettingsUpdate, w: Writer): Unit = {
val sigmaWriter = new SigmaByteWriter(w, None)
val sigmaWriter = new SigmaByteWriter(w, None, None, None)
w.putUInt(obj.rulesToDisable.length.toLong)
obj.rulesToDisable.foreach { r =>
w.putUShort(r.toInt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,10 @@ class Parameters(val height: Height,
activatedUpdate = proposedUpdate
}

// Forced version update to version 2 at height provided in settings
if (height == votingSettings.version2ActivationHeight) {
// Forced update should happen, but some soft-fork update happened before.
// Node should fail at this point, as the situation is unclear
require(table(BlockVersion) == 1, "Protocol version is not 1 on the hard-fork")
table = table.updated(BlockVersion, table(BlockVersion) + 1)
// Forced version update to version 2 at height provided in settings.
// Needed as it was non-voted hard-fork in the mainnet.
if (height == votingSettings.version2ActivationHeight && table(BlockVersion) == 1) {
table = table.updated(BlockVersion, 2)
}
(table, activatedUpdate)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.ergoplatform.settings

import org.ergoplatform.SigmaConstants.{MaxBoxSize, MaxPropositionBytes}
import org.ergoplatform.modifiers.{ErgoFullBlock, NetworkObjectTypeId}
import org.ergoplatform.modifiers.history.extension.Extension
import org.ergoplatform.modifiers.history.header.Header
Expand All @@ -11,6 +10,7 @@ import org.ergoplatform.wallet.boxes.ErgoBoxAssetExtractor
import org.ergoplatform.validation.{InvalidModifier, ModifierValidator}
import org.ergoplatform.validation.ValidationResult.Invalid
import scorex.util.ModifierId
import sigma.data.SigmaConstants.{MaxBoxSize, MaxPropositionBytes}

object ValidationRules {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import org.ergoplatform.ErgoBox.{AdditionalRegisters, TokenId}
import org.ergoplatform.settings.{Algos, Parameters}
import org.ergoplatform.{ErgoBox, ErgoBoxCandidate}
import scorex.util.ModifierId
import sigma.ast.ErgoTree
import sigma.{Coll, Colls}
import sigmastate.Values.ErgoTree
import sigmastate.eval._

object BoxUtils {
Expand Down
Loading

0 comments on commit 90a11cb

Please sign in to comment.