Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Candidate for 6.0.0 release #2152

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ab65271
with-sigma-v5.0.13-RC: updated to sigma with DefaultHeader == ZeroHeader
aslesarenko Oct 4, 2023
5e9d8d0
5.0.22 version set, checkpoint updated to 1,231,454
kushti Mar 29, 2024
2a3f14f
6.0.0 version set, protocol version = 4 set, Header.Interpreter60Version
kushti Apr 24, 2024
20370df
merging w. master
kushti Aug 16, 2024
513cc96
sigma version update
kushti Aug 19, 2024
e03ee77
merging w. with-5.0.13 branch
kushti Aug 19, 2024
6510686
custom launch parameters support & devnet params
kushti Aug 20, 2024
90a11cb
sigma dep update to 6.0
kushti Aug 23, 2024
4e0e923
devnet settings
kushti Aug 23, 2024
66e269d
6.0 activation fixed, VersionedBlockchainStateContext
kushti Aug 26, 2024
5282922
gitlab based repo for leveldbjni-all dependency
kushti Aug 29, 2024
3660516
Merge branch 'jni-dep' of github.com:ergoplatform/ergo into v6.0.0
kushti Aug 29, 2024
7e62038
updated sigma dep, 1007 rule replaced
kushti Sep 24, 2024
22e3ffb
sigma de updated to alpha2
kushti Oct 10, 2024
42f2979
6.0 test for script reducing to false
kushti Oct 14, 2024
d6d5b5d
more tests: execution of 6.0 Ergoscript, 6.0 execution of unparsed Er…
kushti Oct 15, 2024
bdf0cff
215 rule disabled, new tests in VotingSpecification
kushti Oct 16, 2024
1933061
subBlocksPerBlock added to parameters
kushti Oct 17, 2024
c702de9
injecting init value for sub-blocks per blocks on block version v4
kushti Oct 17, 2024
bb588e9
checking multiple scripts in execution of 6.0 Ergoscript test
kushti Oct 18, 2024
99c2553
externalizing scripts
kushti Oct 20, 2024
34696cf
Merge branch 'v6.0.0-parameters' of github.com:ergoplatform/ergo into…
kushti Nov 18, 2024
95492ed
updating sigma dependency, replacing rules
kushti Nov 18, 2024
52a070a
6.0 test for ErgoState.execTransactions()
kushti Nov 24, 2024
cea99f0
highlighting serializing issues
kushti Dec 3, 2024
8db6851
sigma dep updated to RC2
kushti Dec 5, 2024
16cb98f
sigma dependency updated, VersionContext.withVersions => VersionConte…
kushti Dec 9, 2024
8be97e1
versioning in unconfirmed transaction and block serialization
kushti Dec 9, 2024
4eb53f5
updating sigma dep
kushti Dec 20, 2024
3782a05
improved versioning in serializers
kushti Dec 23, 2024
c5812e0
improved comments
kushti Dec 23, 2024
c8aacff
sigma dep updated, parseExtension test updated
kushti Dec 26, 2024
44d61d9
public testnet voting height
kushti Dec 26, 2024
b7e4132
unsigned big int serialization in register - initial test
kushti Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ lazy val commonSettings = Seq(
// without the tag version resolves to [branch name]-[git commit hash]-SNAPSHOT
// don't set the version manually
resolvers ++= Seq("Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/",
"Bintray" at "https://jcenter.bintray.com/", //for org.ethereum % leveldbjni-all
"SonaType" at "https://oss.sonatype.org/content/groups/public",
"Repo for leveldbjni-all" at "https://gitlab.com/api/v4/projects/61211221/packages/maven",
"Typesafe maven releases" at "https://dl.bintray.com/typesafe/maven-releases/",
"Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"),
homepage := Some(url("http://ergoplatform.org/")),
Expand All @@ -33,11 +33,13 @@ lazy val commonSettings = Seq(
),
)

publishArtifact in (Compile, packageDoc) := false

val circeVersion = "0.13.0"
val akkaVersion = "2.6.10"
val akkaHttpVersion = "10.2.4"

val sigmaStateVersion = "5.0.13"
val sigmaStateVersion = "5.0.14-479-aab382e8-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 @@ -18,6 +18,7 @@ import scorex.crypto.hash.Digest32
import scorex.util.serialization.{Reader, Writer}
import scorex.util.{ModifierId, bytesToId, idToBytes}
import scorex.util.Extensions._
import sigma.VersionContext

import scala.annotation.nowarn
import scala.collection.mutable
Expand Down Expand Up @@ -145,7 +146,9 @@ object BlockTransactionsSerializer extends ErgoSerializer[BlockTransactions] {
}
w.putUInt(bt.txs.size.toLong)
bt.txs.foreach { tx =>
ErgoTransactionSerializer.serialize(tx, w)
VersionContext.withVersions(VersionContext.V6SoftForkVersion, VersionContext.V6SoftForkVersion) {
ErgoTransactionSerializer.serialize(tx, w)
}
}
}

Expand All @@ -170,8 +173,13 @@ object BlockTransactionsSerializer extends ErgoSerializer[BlockTransactions] {
txCount = r.getUInt().toIntExact
}

val txs = (1 to txCount).map { _ =>
ErgoTransactionSerializer.parse(r)
val txs: IndexedSeq[ErgoTransaction] = {
val version = VersionContext.fromBlockVersion(blockVersion)
VersionContext.withVersions(version.activatedVersion, version.ergoTreeVersion) {
(1 to txCount).map { _ =>
ErgoTransactionSerializer.parse(r)
}
}
}
BlockTransactions(headerId, blockVersion, txs, Some(r.position - startPos))
}
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 @@ -138,14 +139,31 @@ object Header extends ApiCodecs {
*/
val Interpreter50Version: Byte = 3

/**
* Block version after the 6.0 soft-fork
* 6.0 interpreter (EIP-50)
*/
val Interpreter60Version: Byte = 4

// todo: pass NetworkType, not String
// todo: comments
def interpreter60VersionActivationHeight(networkTypeName: String): Int = {
if(networkTypeName == "mainnet") {
??? // todo: set
} else if(networkTypeName == "testnet") {
1548800 // todo: set
} else {
//devnet
??? // todo: set
}
}

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 @@ -155,7 +173,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,7 @@ 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
import org.ergoplatform.modifiers.history.header.Header
Expand All @@ -27,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 @@ -490,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 @@ -9,19 +9,20 @@ import org.ergoplatform.modifiers.history.header.{Header, HeaderSerializer}
import org.ergoplatform.modifiers.history.popow.NipopowAlgos
import org.ergoplatform.nodeView.history.ErgoHistoryUtils
import org.ergoplatform.nodeView.history.storage.modifierprocessors.ExtensionValidator
import org.ergoplatform.sdk.wallet.protocol.context.BlockchainStateContext
import org.ergoplatform.settings.ValidationRules._
import org.ergoplatform.settings._
import org.ergoplatform.utils.ScorexEncoding
import org.ergoplatform.serialization.ErgoSerializer
import org.ergoplatform.validation.{InvalidModifier, ModifierValidator, ValidationState}
import org.ergoplatform.wallet.interpreter.VersionedBlockchainStateContext
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 sigma.validation.SigmaValidationSettings

import scala.collection.compat.immutable.ArraySeq
import scala.util.{Failure, Success, Try}
Expand Down Expand Up @@ -68,7 +69,7 @@ class ErgoStateContext(val lastHeaders: Seq[Header],
val validationSettings: ErgoValidationSettings,
val votingData: VotingData)
(implicit val chainSettings: ChainSettings)
extends BlockchainStateContext
extends VersionedBlockchainStateContext
with BytesSerializable
with ScorexEncoding
with ScorexLogging {
Expand All @@ -78,6 +79,8 @@ class ErgoStateContext(val lastHeaders: Seq[Header],
private val votingSettings = chainSettings.voting
private val popowAlgos = new NipopowAlgos(chainSettings)

override val sigmaValidationSettings: SigmaValidationSettings = validationSettings.sigmaSettings

override def sigmaPreHeader: sigma.PreHeader =
PreHeader.toSigma(lastHeaders.headOption.getOrElse(PreHeader.fake))

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 = Values.TrueLeaf.toSigmaProp
def FalseLeaf: ErgoTree = 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
Loading