diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala index 5813ff99e7..babd0435be 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala @@ -10,7 +10,8 @@ import sigmastate.crypto.DLogProtocol.{ProveDlog, ProveDlogProp} import sigmastate.exceptions.SigmaException import sigmastate.serialization._ import sigmastate.utxo.{DeserializeContext, Slice} -import sigma.Coll +import sigma.{Coll, VersionContext} +import sigmastate.Values.ErgoTree.{ZeroHeader, setVersionBits} import scala.util.Try @@ -163,7 +164,11 @@ class Pay2SHAddress(val scriptHash: Array[Byte])(implicit val encoder: ErgoAddre ByteArrayConstant(scriptHash) ) val scriptIsCorrect = DeserializeContext(scriptId, SSigmaProp) - ErgoTree.withoutSegregation(SigmaAnd(hashEquals.toSigmaProp, scriptIsCorrect)) + // Get script version either from the default context or from a context provided by an application + // This is never part of the consensus and can be controlled by applications + val treeVersion = VersionContext.current.ergoTreeVersion + val header = setVersionBits(ZeroHeader, treeVersion) + ErgoTree.withoutSegregation(header, SigmaAnd(hashEquals.toSigmaProp, scriptIsCorrect)) } override def equals(obj: Any): Boolean = obj match { diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoTreePredef.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoTreePredef.scala index 9650da7a1f..c02bca7a20 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoTreePredef.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoTreePredef.scala @@ -5,7 +5,7 @@ import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.crypto.CryptoConstants import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.SCollection.SByteArray -import sigmastate.Values.ErgoTree.HeaderType +import sigmastate.Values.ErgoTree.{HeaderType, ZeroHeader} import sigmastate.Values.{ErgoTree, FalseSigmaProp, IntArrayConstant, IntConstant, LongConstant, SigmaPropConstant, SigmaPropValue, TrueSigmaProp, Value} import sigmastate.utxo._ import sigmastate._ @@ -50,10 +50,10 @@ object ErgoTreePredef { * Required script of the box, that collects mining rewards */ def rewardOutputScript(delta: Int, minerPk: ProveDlog): ErgoTree = { - SigmaAnd( + ErgoTree.withSegregation(ZeroHeader, SigmaAnd( GE(Height, Plus(boxCreationHeight(Self), IntConstant(delta))).toSigmaProp, SigmaPropConstant(minerPk) - ).treeWithSegregation + )) } /** @@ -62,11 +62,11 @@ object ErgoTreePredef { */ def feeProposition(delta: Int = 720): ErgoTree = { val out = ByIndex(Outputs, IntConstant(0)) - AND( + ErgoTree.withSegregation(ZeroHeader, AND( EQ(Height, boxCreationHeight(out)), EQ(ExtractScriptBytes(out), expectedMinerOutScriptBytesVal(delta, MinerPubkey)), EQ(SizeOf(Outputs), 1) - ).toSigmaProp.treeWithSegregation + ).toSigmaProp) } /** @@ -92,11 +92,13 @@ object ErgoTreePredef { EQ(ExtractScriptBytes(minerOut), expectedMinerOutScriptBytesVal(s.minerRewardDelay, MinerPubkey)), EQ(Height, boxCreationHeight(minerOut)) ) - AND( - heightIncreased, - correctMinerOutput, - OR(AND(outputsNum, sameScriptRule, correctCoinsConsumed, heightCorrect), lastCoins) - ).toSigmaProp.treeWithSegregation + ErgoTree.withSegregation(ZeroHeader, + AND( + heightIncreased, + correctMinerOutput, + OR(AND(outputsNum, sameScriptRule, correctCoinsConsumed, heightCorrect), lastCoins) + ).toSigmaProp + ) } /** @@ -153,7 +155,7 @@ object ErgoTreePredef { // check, that additional rules defined by foundation members are satisfied val customProposition = DeserializeRegister(ErgoBox.R4, SSigmaProp) // combine 3 conditions above with AND conjunction - SigmaAnd(amountCorrect.toSigmaProp, sameScriptRule.toSigmaProp, customProposition).treeWithSegregation + ErgoTree.withSegregation(ZeroHeader, SigmaAnd(amountCorrect.toSigmaProp, sameScriptRule.toSigmaProp, customProposition)) } /** diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index 8f95a4689c..2d39f1874d 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -1353,7 +1353,7 @@ object Values { val ZeroHeader: HeaderType = HeaderType @@ 0.toByte /** Default value of ErgoTree.header byte */ - val DefaultHeader: HeaderType = HeaderType @@ (0/*VersionFlag | SizeFlag*/).toByte + val DefaultHeader: HeaderType = HeaderType @@ (VersionFlag | SizeFlag).toByte /** Default header with constant segregation enabled. */ val ConstantSegregationHeader: HeaderType = HeaderType @@ (DefaultHeader | ConstantSegregationFlag).toByte diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index 870cbbb5bf..5e22bf1a03 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -129,7 +129,7 @@ case class CSigmaProp(sigmaTree: SigmaBoolean) extends SigmaProp with WrapperOf[ // the same serialization method is used in both cases // TODO v6.0: add `pk.propBytes(version)` (see https://github.com/ScorexFoundation/sigmastate-interpreter/issues/903) val root = sigmaTree.toSigmaProp - val ergoTree = new ErgoTree(ErgoTree.DefaultHeader, EmptyConstants, Right(root), 0, null, None) + val ergoTree = new ErgoTree(ErgoTree.ZeroHeader, EmptyConstants, Right(root), 0, null, None) val bytes = DefaultSerializer.serializeErgoTree(ergoTree) Colls.fromArray(bytes) } diff --git a/interpreter/shared/src/test/scala/sigmastate/CrossVersionProps.scala b/interpreter/shared/src/test/scala/sigmastate/CrossVersionProps.scala index 0c4056dcee..67f54e151d 100644 --- a/interpreter/shared/src/test/scala/sigmastate/CrossVersionProps.scala +++ b/interpreter/shared/src/test/scala/sigmastate/CrossVersionProps.scala @@ -2,10 +2,12 @@ package sigmastate import debox.cfor import org.scalactic.source.Position + import scala.util.DynamicVariable import org.scalatest.Tag import sigmastate.eval.Profiler import org.scalatest.propspec.AnyPropSpecLike +import sigma.VersionContext trait CrossVersionProps extends AnyPropSpecLike with TestsBase { /** Number of times each test property is warmed up (i.e. executed before final execution). */ @@ -29,7 +31,9 @@ trait CrossVersionProps extends AnyPropSpecLike with TestsBase { System.gc() } forEachScriptAndErgoTreeVersion(activatedVersions, ergoTreeVersions) { - testFun_Run(testName, testFun) + VersionContext.withVersions(activatedVersionInTests, ergoTreeVersionInTests) { + testFun_Run(testName, testFun) + } } } } diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala index ef38c97a6d..56c5aae4be 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala @@ -286,16 +286,17 @@ class ErgoAddressSpecification extends SigmaDslTesting // when everything is ok testPay2SHAddress(addr, script = scriptVarId -> ByteArrayConstant(scriptBytes)) + val expectedCost = if (ergoTreeVersionInTests == 0) 88 else 90 // account for size serialized for version > 0 + // when limit is low { val deliberatelySmallLimit = 24 - assertExceptionThrown( testPay2SHAddress(addr, script = scriptVarId -> ByteArrayConstant(scriptBytes), costLimit = deliberatelySmallLimit), rootCauseLike[CostLimitException]( - s"Estimated execution cost 88 exceeds the limit $deliberatelySmallLimit") + s"Estimated execution cost $expectedCost exceeds the limit $deliberatelySmallLimit") ) } @@ -311,7 +312,7 @@ class ErgoAddressSpecification extends SigmaDslTesting costLimit = deliberatelySmallLimit) }, rootCauseLike[CostLimitException]( - s"Estimated execution cost 88 exceeds the limit $deliberatelySmallLimit") + s"Estimated execution cost $expectedCost exceeds the limit $deliberatelySmallLimit") ) } diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala index b8579ddedf..4865b2b8e2 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala @@ -25,7 +25,7 @@ class ErgoLikeTransactionSpec extends SigmaDslTesting { val token2 = "a3ff007f00057600808001ff8f8000019000ffdb806fff7cc0b6015eb37fa600" val b1 = new ErgoBoxCandidate( 10L, - ErgoTree(ErgoTree.DefaultHeader, Vector(), TrueSigmaProp), + ErgoTree(ErgoTree.ZeroHeader, Vector(), TrueSigmaProp), 100, Coll( (Digest32Coll @@@ (ErgoAlgos.decodeUnsafe(token1).toColl)) -> 10000000L, @@ -34,7 +34,7 @@ class ErgoLikeTransactionSpec extends SigmaDslTesting { ) val b1_clone = new ErgoBoxCandidate( 10L, - ErgoTree(ErgoTree.DefaultHeader, Vector(), TrueSigmaProp), + ErgoTree(ErgoTree.ZeroHeader, Vector(), TrueSigmaProp), 100, Coll( Digest32Coll @@ (ErgoAlgos.decodeUnsafe(token1).toColl) -> 10000000L, diff --git a/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala index d25cc0ff58..78d67b0f9d 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala @@ -14,22 +14,23 @@ import org.ergoplatform.{ErgoBox, ErgoLikeContext} import org.ergoplatform.dsl.ContractSyntax.{ErgoScript, Proposition, Token} import sigmastate.{AvlTreeData, SType} import sigmastate.Values.{ErgoTree, EvaluatedValue} -import sigmastate.eval.{CSigmaProp, Evaluation, IRContext, CAnyValue} -import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter, CompilerTestingCommons} +import sigmastate.eval.{CAnyValue, CSigmaProp, Evaluation, IRContext} +import sigmastate.helpers.{CompilerTestingCommons, ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.lang.Terms.ValueOps import sigma.{AnyValue, SigmaProp} +import sigmastate.Values.ErgoTree.ZeroHeader case class TestContractSpec(testSuite: CompilerTestingCommons)(implicit val IR: IRContext) extends ContractSpec { case class TestPropositionSpec(name: String, dslSpec: Proposition, scriptSpec: ErgoScript) extends PropositionSpec { lazy val ergoTree: ErgoTree = { val value = testSuite.compile(scriptSpec.env, scriptSpec.code) - val headerFlags = scriptSpec.scriptVersion match { - case Some(version) => ErgoTree.defaultHeaderWithVersion(version) + val header = scriptSpec.scriptVersion match { + case Some(version) => ErgoTree.headerWithVersion(ZeroHeader, version) case None => testSuite.ergoTreeHeaderInTests } - val tree: ErgoTree = ErgoTree.fromProposition(headerFlags, value.asSigmaProp) + val tree: ErgoTree = ErgoTree.fromProposition(header, value.asSigmaProp) tree } } diff --git a/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala b/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala index a045db45f0..e2869fb84a 100644 --- a/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala +++ b/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala @@ -1,50 +1,41 @@ package special.sigma -import java.math.BigInteger +import org.ergoplatform.ErgoBox.AdditionalRegisters import org.ergoplatform._ import org.ergoplatform.settings.ErgoAlgos +import org.scalacheck.Arbitrary._ import org.scalacheck.{Arbitrary, Gen} -import sigma.data.{ExactIntegral, ExactNumeric, ExactOrdering, RType} +import org.scalatest.BeforeAndAfterAll import scorex.crypto.authds.avltree.batch._ import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} +import scorex.util.ModifierId +import sigma.Extensions._ +import sigma.{VersionContext, _} +import sigma.data.RType._ +import sigma.data.{ExactIntegral, ExactNumeric, ExactOrdering, RType} import sigma.util.Extensions._ -import sigmastate.utils.Extensions._ import sigmastate.SCollection._ -import sigmastate.Values.IntConstant +import sigmastate.Values.ErgoTree.{HeaderType, ZeroHeader} +import sigmastate.Values.{IntConstant, _} import sigmastate._ import sigmastate.crypto.DLogProtocol._ -import sigmastate.Values._ -import sigmastate.lang.Terms.Apply +import sigmastate.crypto.ProveDHTuple import sigmastate.eval.Extensions._ +import sigmastate.eval.OrderingOps._ import sigmastate.eval._ -import sigmastate.lang.Terms.{MethodCall, PropertyCall} -import sigmastate.utxo._ -import sigma._ -import sigma.Extensions._ +import sigmastate.helpers.TestingHelpers._ +import sigmastate.interpreter._ +import sigmastate.lang.Terms.{Apply, MethodCall, PropertyCall} import sigmastate.serialization.OpCodes.OpCode +import sigmastate.utils.Extensions._ import sigmastate.utils.Helpers import sigmastate.utils.Helpers._ -import sigmastate.helpers.TestingHelpers._ - -import scala.util.{Failure, Success, Try} -import OrderingOps._ -import org.ergoplatform.ErgoBox.AdditionalRegisters -import org.scalacheck.Arbitrary._ -import org.scalacheck.Gen.frequency -import org.scalatest.{BeforeAndAfterAll, Tag} -import sigma.data.RType._ -import scorex.util.ModifierId -import sigmastate.crypto.ProveDHTuple -import sigmastate.interpreter._ -import org.scalactic.source.Position -import sigma.VersionContext -import sigmastate.Values.ErgoTree.HeaderType -import sigmastate.helpers.SigmaPPrint -import sigmastate.exceptions.GraphBuildingException -import supertagged.classic.@@ +import sigmastate.utxo._ +import java.math.BigInteger import scala.collection.compat.immutable.ArraySeq +import scala.util.{Failure, Success} /** This suite tests every method of every SigmaDsl type to be equivalent to * the evaluation of the corresponding ErgoScript operation. @@ -9656,14 +9647,14 @@ class SigmaDslSpecification extends SigmaDslTesting property("substConstants equivalence") { // tree without constant segregation - val t1 = ErgoTree(ErgoTree.DefaultHeader, Vector(), TrueSigmaProp) + val t1 = ErgoTree(ErgoTree.ZeroHeader, Vector(), TrueSigmaProp) // tree with constant segregation, but without constants - val t2 = ErgoTree(ErgoTree.ConstantSegregationHeader, Vector(), TrueSigmaProp) + val t2 = ErgoTree(ErgoTree.setConstantSegregation(ZeroHeader), Vector(), TrueSigmaProp) // tree with one segregated constant - val t3 = ErgoTree(ErgoTree.ConstantSegregationHeader, Vector(TrueSigmaProp), ConstantPlaceholder(0, SSigmaProp)) + val t3 = ErgoTree(ErgoTree.setConstantSegregation(ZeroHeader), Vector(TrueSigmaProp), ConstantPlaceholder(0, SSigmaProp)) // tree with one segregated constant of different type val t4 = ErgoTree( - ErgoTree.ConstantSegregationHeader, + ErgoTree.setConstantSegregation(ZeroHeader), Vector(IntConstant(10)), BoolToSigmaProp(EQ(ConstantPlaceholder(0, SInt), IntConstant(20)))) def costDetails(i: Int) = TracedCost( diff --git a/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala index 4c3010ac7a..8299c5420d 100644 --- a/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala @@ -19,6 +19,7 @@ import sigma.util.CollectionUtil._ import sigma.util.Extensions._ import sigma.util.StringUtil.StringUtilExtensions import sigmastate.SType.AnyOps +import sigmastate.Values.ErgoTree.ZeroHeader import sigmastate.Values.{ByteArrayConstant, Constant, ConstantNode, ErgoTree, IntConstant, SValue} import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} import sigmastate.crypto.SigmaProtocolPrivateInput @@ -325,7 +326,7 @@ class SigmaDslTesting extends AnyPropSpec pkAlice, DeserializeRegister(ErgoBox.R5, SSigmaProp), // deserialize pkBob DeserializeContext(2, SSigmaProp))) // deserialize pkCarol - val header = ErgoTree.defaultHeaderWithVersion(ergoTreeVersionInTests) + val header = ErgoTree.headerWithVersion(ZeroHeader, ergoTreeVersionInTests) ErgoTree.withSegregation(header, sigmastate.SigmaOr(prop, multisig)) } diff --git a/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala b/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala index 69e7234f57..52e7667cae 100644 --- a/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala @@ -39,7 +39,7 @@ class SoftForkabilitySpecification extends SigmaTestingData // cast Boolean typed prop to SigmaProp (which is invalid) // ErgoTree v0 lazy val invalidPropV1: ErgoTree = ErgoTree.fromProposition( - ErgoTree.defaultHeaderWithVersion(0), + ErgoTree.headerWithVersion(ZeroHeader, 0), booleanPropV1.asSigmaProp) lazy val invalidTxV1 = createTransaction(createBox(boxAmt, invalidPropV1, 1)) @@ -48,7 +48,7 @@ class SoftForkabilitySpecification extends SigmaTestingData lazy val propV1 = booleanPropV1.toSigmaProp lazy val txV1 = createTransaction( createBox(boxAmt, - ErgoTree.fromProposition(ErgoTree.defaultHeaderWithVersion(0), propV1), // ErgoTree v0 + ErgoTree.fromProposition(ErgoTree.headerWithVersion(ZeroHeader, 0), propV1), // ErgoTree v0 1)) lazy val txV1bytes = txV1.messageToSign @@ -163,7 +163,7 @@ class SoftForkabilitySpecification extends SigmaTestingData // prepare bytes using default serialization and then replacing version in the header val v2tree_withoutSize_bytes = runOnV2Node { val tree = ErgoTree.fromProposition( - ErgoTree.defaultHeaderWithVersion(0), propV2) // ErgoTree v0 + ErgoTree.headerWithVersion(ZeroHeader, 0), propV2) // ErgoTree v0 val bytes = tree.bytes // set version to v2 while not setting the size bit, // we cannot do this using ErgoTree constructor (due to require() check) diff --git a/sc/shared/src/test/scala/sigmastate/utxo/DistributedSigSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/DistributedSigSpecification.scala index 9276413e1e..99fecd0aa1 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/DistributedSigSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/DistributedSigSpecification.scala @@ -1,7 +1,9 @@ package sigmastate.utxo +import sigmastate.Values.ErgoTree +import sigmastate.Values.ErgoTree.ZeroHeader import sigmastate._ -import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeTestProvingInterpreter, CompilerTestingCommons} +import sigmastate.helpers.{CompilerTestingCommons, ContextEnrichingTestProvingInterpreter, ErgoLikeTestProvingInterpreter} import sigmastate.interpreter._ import sigmastate.lang.Terms._ @@ -518,7 +520,10 @@ class DistributedSigSpecification extends CompilerTestingCommons val sigAlice = proverA.signMessage(sigmaTree, msg, bagA).get - val bagB = proverB.bagForMultisig(ctx, sigmaTree, sigAlice, Seq(pubkeyAlice)) + val bagB = proverB.bagForMultisig(ctx, + ErgoTree.fromSigmaBoolean(ergoTreeHeaderInTests, sigmaTree), + proof = sigAlice, + realSecretsToExtract = Seq(pubkeyAlice)) .addHint(hintsFromBob.ownCommitments.head) val sigBob = proverB.signMessage(sigmaTree, msg, bagB).get diff --git a/sc/shared/src/test/scala/sigmastate/utxo/blockchain/BlockchainSimulationTestingCommons.scala b/sc/shared/src/test/scala/sigmastate/utxo/blockchain/BlockchainSimulationTestingCommons.scala index 77c4054ebd..5353c906bd 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/blockchain/BlockchainSimulationTestingCommons.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/blockchain/BlockchainSimulationTestingCommons.scala @@ -16,6 +16,7 @@ import scala.collection.mutable import scala.util.{Random, Try} import scorex.util._ import sigma.Colls +import sigmastate.Values.ErgoTree.ZeroHeader import sigmastate.interpreter.ContextExtension import sigmastate.interpreter.Interpreter.{ScriptNameProp, emptyEnv} import sigmastate.utxo.blockchain.BlockchainSimulationTestingCommons.{FullBlock, ValidationState} @@ -155,7 +156,7 @@ object BlockchainSimulationTestingCommons extends CompilerTestingCommons { val boxes = (1 to 50).map(_ => testBox(10, ErgoTree.fromProposition( - ErgoTree.defaultHeaderWithVersion(scriptVersion), + ErgoTree.headerWithVersion(ZeroHeader, scriptVersion), Values.TrueLeaf.toSigmaProp), i, Seq(), Map(), txId)) createTransaction(boxes) diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/CoopExampleSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/CoopExampleSpecification.scala index 231ddb9220..a293e6b61a 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/CoopExampleSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/CoopExampleSpecification.scala @@ -1,12 +1,13 @@ package sigmastate.utxo.examples -import org.ergoplatform.{ErgoLikeContext, ErgoLikeTransaction, ErgoBox} +import org.ergoplatform.{ErgoBox, ErgoLikeContext, ErgoLikeTransaction} import org.scalatest.Assertion import org.scalatest.TryValues._ -import sigmastate.crypto.DLogProtocol.{ProveDlog, DLogProverInput} +import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} import scorex.crypto.hash.Blake2b256 -import sigmastate.Values.{ByteArrayConstant, ErgoTree, BooleanConstant} -import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, CompilerTestingCommons, ErgoLikeTestInterpreter} +import sigmastate.Values.ErgoTree.ZeroHeader +import sigmastate.Values.{BooleanConstant, ByteArrayConstant, ErgoTree} +import sigmastate.helpers.{CompilerTestingCommons, ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.lang.Terms._ import sigmastate.{AvlTreeData, CompilerCrossVersionProps} @@ -65,7 +66,7 @@ class CoopExampleSpecification extends CompilerTestingCommons def pkWithTree(in: DLogProverInput): (ProveDlog, ErgoTree) = { val pk = in.publicImage - val tree = ErgoTree.fromSigmaBoolean(ErgoTree.defaultHeaderWithVersion(0), pk) + val tree = ErgoTree.fromSigmaBoolean(ErgoTree.headerWithVersion(ZeroHeader, 0), pk) (pk, tree) } diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala index 8566ce437e..93f46ce2c7 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala @@ -265,8 +265,10 @@ class OracleExamplesSpecification extends CompilerTestingCommons spendingTransaction, self = sOracle, activatedVersionInTests) - val prA = alice.prove(emptyEnv + (ScriptNameProp -> "alice_prove"), prop, ctx, fakeMessage).get - verifier.verify(emptyEnv + (ScriptNameProp -> "verify"), prop, ctx, prA, fakeMessage).get._1 shouldBe true + val prA = alice.prove(emptyEnv + (ScriptNameProp -> "alice_prove"), + mkTestErgoTree(prop), ctx, fakeMessage).get + verifier.verify(emptyEnv + (ScriptNameProp -> "verify"), + mkTestErgoTree(prop), ctx, prA, fakeMessage).get._1 shouldBe true } case class OracleContract[Spec <: ContractSpec]