From 08b3810663d39f5f7eead2b33416dfde5dcbe5fa Mon Sep 17 00:00:00 2001 From: Jozef Koval Date: Mon, 7 Feb 2022 21:29:03 +0100 Subject: [PATCH 1/7] v5.0-test-nested-loops: --- .../scala/sigmastate/eval/CostingRules.scala | 1 + .../sigmastate/eval/RuntimeCosting.scala | 9 +++- .../scala/sigmastate/utxo/CostTable.scala | 2 + .../special/sigma/SigmaDslSpecification.scala | 49 +++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/sigmastate/src/main/scala/sigmastate/eval/CostingRules.scala b/sigmastate/src/main/scala/sigmastate/eval/CostingRules.scala index 1b6b016627..813686db1a 100644 --- a/sigmastate/src/main/scala/sigmastate/eval/CostingRules.scala +++ b/sigmastate/src/main/scala/sigmastate/eval/CostingRules.scala @@ -58,6 +58,7 @@ trait CostingRules extends SigmaLibrary { IR: IRContext => val costerClass = coster.getClass val parameterTypes = Array.fill(costedArgs.length + args.length)(classOf[Sym]) val costerMethod = costerClass.getMethod(method.name, parameterTypes:_*) + println(s"invoking $costerMethod with coster $coster and args: ${costedArgs ++ args}") val res = costerMethod.invoke(coster, costedArgs ++ args:_*) res.asInstanceOf[RCosted[_]] } diff --git a/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala b/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala index 67bfa87b8f..d06337a954 100644 --- a/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala +++ b/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala @@ -1146,7 +1146,7 @@ trait RuntimeCosting extends CostingRules { IR: IRContext => val t = System.nanoTime() ruleStack = new CostingRuleStat(node, t, 0, t) :: ruleStack } - + println(s"going to eval node $node") val res: Ref[Any] = node match { case c @ Constant(v, tpe) => v match { case p: SSigmaProp => @@ -1853,9 +1853,16 @@ trait RuntimeCosting extends CostingRules { IR: IRContext => } method.objType.coster.get(IR)(objC, method, argsC, elems) + case BitOp(left, right, code) => + val x = asRep[Costed[Coll[Byte]]](evalNode(ctx, env, left)) + val y = asRep[Costed[Coll[Byte]]](evalNode(ctx, env, right)) + val value = sigmaDslBuilder.xor(x.value, y.value) + withConstantSize(value, opCost(value, Array(x.cost, y.cost), costOf(node))) + case _ => error(s"Don't know how to evalNode($node)", node.sourceContext.toOption) } + println(s"after eval node $node") if (okMeasureOperationTime) { val t = System.nanoTime() diff --git a/sigmastate/src/main/scala/sigmastate/utxo/CostTable.scala b/sigmastate/src/main/scala/sigmastate/utxo/CostTable.scala index 4a55887f8d..fd3eba0cfd 100644 --- a/sigmastate/src/main/scala/sigmastate/utxo/CostTable.scala +++ b/sigmastate/src/main/scala/sigmastate/utxo/CostTable.scala @@ -174,6 +174,8 @@ object CostTable { ("Xor_per_kb", "(Coll[Byte],Coll[Byte]) => Coll[Byte]", hashPerKb / 2), ("XorOf_per_item", "(Coll[Boolean]) => Boolean", logicCost), ("LogicalNot", "(Boolean) => Boolean", logicCost), + // uncommenting evaluate cost for BitwiseXor, but fails to invoke zip method. + //("BitOp", "(Byte, Byte)", logicCost), ("GT", "(T,T) => Boolean", comparisonCost), ("GE", "(T,T) => Boolean", comparisonCost), diff --git a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala index 92af9b3ce8..c028994930 100644 --- a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -7680,6 +7680,55 @@ class SigmaDslSpecification extends SigmaDslTesting } } + property("nested loops") { + val (keysArr, valuesArr, _, avlProver) = sampleAvlProver + val keys = Colls.fromArray(keysArr.slice(0, 20)) + val proof = avlProver.generateProof().toColl + + verifyCases( + Seq( + // using exception as v4 doesn't support the test + (keys, proof) -> Expected(Failure(new NoSuchElementException("None.get")), cost = 35905) + // Expected( + // Failure(new NoSuchElementException("None.get")), + // cost = 35905, + // newDetails = CostDetails.ZeroCost, + // newCost = 1796, + // newVersionedResults = Seq( + // 0 -> (ExpectedResult(Success(true), Some(1796)) -> None), + // 1 -> (ExpectedResult(Success(true), Some(1796)) -> None), + // 2 -> (ExpectedResult(Success(true), Some(1796)) -> None) + // ) + // ) + ), + changedFeature( + { (x: (Coll[Coll[Byte]], Coll[Byte])) => + // val foo = x._1.foldLeft(x._2, { (a: (Coll[Byte], Coll[Byte])) => + // a._1.zip(a._2).map({ (c: (Byte, Byte)) => (c._1 ^ c._2).toByte }) + // }) + Option.empty[Int].get + true + }, + { (x: (Coll[Coll[Byte]], Coll[Byte])) => + val foo = x._1.foldLeft(x._2, { (a: (Coll[Byte], Coll[Byte])) => + a._1.zip(a._2).map({ (c: (Byte, Byte)) => (c._1 ^ c._2).toByte }) + }) + true + }, + """{ + | (x: (Coll[Coll[Byte]], Coll[Byte])) => + | val foo = x._1.fold(x._2, {(a: Coll[Byte], b: Coll[Byte]) => + | a.zip(b).map({ (c: (Byte, Byte)) => (c._1 ^ c._2).toByte }) + | }) + | true + |}""".stripMargin, + null, + allowDifferentErrors = true, + allowNewToSucceed = true, + ) + ) + } + override protected def afterAll(): Unit = { println(ErgoTreeEvaluator.DefaultProfiler.generateReport) println("==========================================================") From 9bae653e80b9d87d9498fdf60f796ad6189bcf6a Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Fri, 1 Apr 2022 16:31:48 +0200 Subject: [PATCH 2/7] v5.0-test-nested-loops: fix property("nested loops: map inside fold") --- .../scala/sigmastate/eval/CostingRules.scala | 1 - .../sigmastate/eval/RuntimeCosting.scala | 2 - .../special/sigma/SigmaDslSpecification.scala | 115 +++++++++++------- 3 files changed, 69 insertions(+), 49 deletions(-) diff --git a/sigmastate/src/main/scala/sigmastate/eval/CostingRules.scala b/sigmastate/src/main/scala/sigmastate/eval/CostingRules.scala index 813686db1a..1b6b016627 100644 --- a/sigmastate/src/main/scala/sigmastate/eval/CostingRules.scala +++ b/sigmastate/src/main/scala/sigmastate/eval/CostingRules.scala @@ -58,7 +58,6 @@ trait CostingRules extends SigmaLibrary { IR: IRContext => val costerClass = coster.getClass val parameterTypes = Array.fill(costedArgs.length + args.length)(classOf[Sym]) val costerMethod = costerClass.getMethod(method.name, parameterTypes:_*) - println(s"invoking $costerMethod with coster $coster and args: ${costedArgs ++ args}") val res = costerMethod.invoke(coster, costedArgs ++ args:_*) res.asInstanceOf[RCosted[_]] } diff --git a/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala b/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala index d06337a954..90f0c93bfc 100644 --- a/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala +++ b/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala @@ -1146,7 +1146,6 @@ trait RuntimeCosting extends CostingRules { IR: IRContext => val t = System.nanoTime() ruleStack = new CostingRuleStat(node, t, 0, t) :: ruleStack } - println(s"going to eval node $node") val res: Ref[Any] = node match { case c @ Constant(v, tpe) => v match { case p: SSigmaProp => @@ -1862,7 +1861,6 @@ trait RuntimeCosting extends CostingRules { IR: IRContext => case _ => error(s"Don't know how to evalNode($node)", node.sourceContext.toOption) } - println(s"after eval node $node") if (okMeasureOperationTime) { val t = System.nanoTime() diff --git a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala index c028994930..58c8e6b8d8 100644 --- a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -7680,53 +7680,76 @@ class SigmaDslSpecification extends SigmaDslTesting } } - property("nested loops") { - val (keysArr, valuesArr, _, avlProver) = sampleAvlProver - val keys = Colls.fromArray(keysArr.slice(0, 20)) - val proof = avlProver.generateProof().toColl - - verifyCases( - Seq( - // using exception as v4 doesn't support the test - (keys, proof) -> Expected(Failure(new NoSuchElementException("None.get")), cost = 35905) - // Expected( - // Failure(new NoSuchElementException("None.get")), - // cost = 35905, - // newDetails = CostDetails.ZeroCost, - // newCost = 1796, - // newVersionedResults = Seq( - // 0 -> (ExpectedResult(Success(true), Some(1796)) -> None), - // 1 -> (ExpectedResult(Success(true), Some(1796)) -> None), - // 2 -> (ExpectedResult(Success(true), Some(1796)) -> None) - // ) - // ) - ), - changedFeature( - { (x: (Coll[Coll[Byte]], Coll[Byte])) => - // val foo = x._1.foldLeft(x._2, { (a: (Coll[Byte], Coll[Byte])) => - // a._1.zip(a._2).map({ (c: (Byte, Byte)) => (c._1 ^ c._2).toByte }) - // }) - Option.empty[Int].get - true - }, - { (x: (Coll[Coll[Byte]], Coll[Byte])) => - val foo = x._1.foldLeft(x._2, { (a: (Coll[Byte], Coll[Byte])) => - a._1.zip(a._2).map({ (c: (Byte, Byte)) => (c._1 ^ c._2).toByte }) - }) - true - }, - """{ - | (x: (Coll[Coll[Byte]], Coll[Byte])) => - | val foo = x._1.fold(x._2, {(a: Coll[Byte], b: Coll[Byte]) => - | a.zip(b).map({ (c: (Byte, Byte)) => (c._1 ^ c._2).toByte }) - | }) - | true - |}""".stripMargin, - null, - allowDifferentErrors = true, - allowNewToSucceed = true, + // related issue https://github.com/ScorexFoundation/sigmastate-interpreter/issues/464 + property("nested loops: map inside fold") { + val keys = Colls.fromArray(Array(Coll[Byte](1, 2, 3, 4, 5))) + val initial = Coll[Byte](0, 0, 0, 0, 0) + if (lowerMethodCallsInTests) { + verifyCases( + Seq( + // using exception as v4 doesn't support the test + (keys, initial) -> Expected(Success(Coll[Byte](1, 2, 3, 4, 5)), cost = 46522, expectedDetails = CostDetails.ZeroCost, 1821) + ), + existingFeature( + { (x: (Coll[Coll[Byte]], Coll[Byte])) => + val foo = x._1.foldLeft(x._2, { (a: (Coll[Byte], Coll[Byte])) => + a._1.zip(a._2).map({ (c: (Byte, Byte)) => (c._1 + c._2).toByte }) + }) + foo + }, + """{ + | (x: (Coll[Coll[Byte]], Coll[Byte])) => + | val foo = x._1.fold(x._2, { (a: Coll[Byte], b: Coll[Byte]) => + | a.zip(b).map({ (c: (Byte, Byte)) => (c._1 + c._2).toByte }) + | }) + | foo + |}""".stripMargin, + FuncValue( + Array((1, SPair(SByteArray2, SByteArray))), + Fold( + SelectField.typed[Value[SCollection[SCollection[SByte.type]]]]( + ValUse(1, SPair(SByteArray2, SByteArray)), + 1.toByte + ), + SelectField.typed[Value[SCollection[SByte.type]]]( + ValUse(1, SPair(SByteArray2, SByteArray)), + 2.toByte + ), + FuncValue( + Array((3, SPair(SByteArray, SByteArray))), + MapCollection( + MethodCall.typed[Value[SCollection[STuple]]]( + SelectField.typed[Value[SCollection[SByte.type]]]( + ValUse(3, SPair(SByteArray, SByteArray)), + 1.toByte + ), + SCollection.getMethodByName("zip").withConcreteTypes( + Map(STypeVar("IV") -> SByte, STypeVar("OV") -> SByte) + ), + Vector( + SelectField.typed[Value[SCollection[SByte.type]]]( + ValUse(3, SPair(SByteArray, SByteArray)), + 2.toByte + ) + ), + Map() + ), + FuncValue( + Array((5, SPair(SByte, SByte))), + ArithOp( + SelectField.typed[Value[SByte.type]](ValUse(5, SPair(SByte, SByte)), 1.toByte), + SelectField.typed[Value[SByte.type]](ValUse(5, SPair(SByte, SByte)), 2.toByte), + OpCode @@ (-102.toByte) + ) + ) + ) + ) + ) + ) + ), + preGeneratedSamples = Some(Seq.empty) ) - ) + } } override protected def afterAll(): Unit = { From ee22a64218e4046845a44f7a3a5a1d7a71898001 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Fri, 1 Apr 2022 16:40:43 +0200 Subject: [PATCH 3/7] v5.0-test-nested-loops: check exception when !lowerMethodCallsInTests in property("nested loops: map inside fold") --- .../special/sigma/SigmaDslSpecification.scala | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala index 58c8e6b8d8..8c0d6d400a 100644 --- a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -7684,26 +7684,26 @@ class SigmaDslSpecification extends SigmaDslTesting property("nested loops: map inside fold") { val keys = Colls.fromArray(Array(Coll[Byte](1, 2, 3, 4, 5))) val initial = Coll[Byte](0, 0, 0, 0, 0) + val cases = Seq( + (keys, initial) -> Expected(Success(Coll[Byte](1, 2, 3, 4, 5)), cost = 46522, expectedDetails = CostDetails.ZeroCost, 1821) + ) + val scalaFunc = { (x: (Coll[Coll[Byte]], Coll[Byte])) => + val foo = x._1.foldLeft(x._2, { (a: (Coll[Byte], Coll[Byte])) => + a._1.zip(a._2).map({ (c: (Byte, Byte)) => (c._1 + c._2).toByte }) + }) + foo + } + val script = + """{ + | (x: (Coll[Coll[Byte]], Coll[Byte])) => + | val foo = x._1.fold(x._2, { (a: Coll[Byte], b: Coll[Byte]) => + | a.zip(b).map({ (c: (Byte, Byte)) => (c._1 + c._2).toByte }) + | }) + | foo + |}""".stripMargin if (lowerMethodCallsInTests) { - verifyCases( - Seq( - // using exception as v4 doesn't support the test - (keys, initial) -> Expected(Success(Coll[Byte](1, 2, 3, 4, 5)), cost = 46522, expectedDetails = CostDetails.ZeroCost, 1821) - ), - existingFeature( - { (x: (Coll[Coll[Byte]], Coll[Byte])) => - val foo = x._1.foldLeft(x._2, { (a: (Coll[Byte], Coll[Byte])) => - a._1.zip(a._2).map({ (c: (Byte, Byte)) => (c._1 + c._2).toByte }) - }) - foo - }, - """{ - | (x: (Coll[Coll[Byte]], Coll[Byte])) => - | val foo = x._1.fold(x._2, { (a: Coll[Byte], b: Coll[Byte]) => - | a.zip(b).map({ (c: (Byte, Byte)) => (c._1 + c._2).toByte }) - | }) - | foo - |}""".stripMargin, + verifyCases(cases, + existingFeature(scalaFunc, script, FuncValue( Array((1, SPair(SByteArray2, SByteArray))), Fold( @@ -7749,6 +7749,13 @@ class SigmaDslSpecification extends SigmaDslTesting ), preGeneratedSamples = Some(Seq.empty) ) + } else { + assertExceptionThrown( + verifyCases(cases, + existingFeature(scalaFunc, script) + ), + rootCauseLike[CosterException]("Don't know how to evalNode(Lambda(List(),Vector((a,Coll[SByte$]), ") + ) } } From 48aba6972687dcc6ed013beb439f4271adeb0876 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Fri, 1 Apr 2022 16:48:33 +0200 Subject: [PATCH 4/7] v5.0-test-nested-loops: roll back BitOp case --- .../src/main/scala/sigmastate/eval/RuntimeCosting.scala | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala b/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala index 90f0c93bfc..30fe8a25e5 100644 --- a/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala +++ b/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala @@ -1852,12 +1852,6 @@ trait RuntimeCosting extends CostingRules { IR: IRContext => } method.objType.coster.get(IR)(objC, method, argsC, elems) - case BitOp(left, right, code) => - val x = asRep[Costed[Coll[Byte]]](evalNode(ctx, env, left)) - val y = asRep[Costed[Coll[Byte]]](evalNode(ctx, env, right)) - val value = sigmaDslBuilder.xor(x.value, y.value) - withConstantSize(value, opCost(value, Array(x.cost, y.cost), costOf(node))) - case _ => error(s"Don't know how to evalNode($node)", node.sourceContext.toOption) } From 53ea2a4a26774fbd8f653ee48fca30466309359d Mon Sep 17 00:00:00 2001 From: Jozef Koval Date: Sat, 2 Apr 2022 18:21:13 +0200 Subject: [PATCH 5/7] v5.0-test-nested-loops: remove unnecessary code. --- .../src/main/scala/sigmastate/eval/RuntimeCosting.scala | 1 + sigmastate/src/main/scala/sigmastate/utxo/CostTable.scala | 2 -- .../test/scala/special/sigma/SigmaDslSpecification.scala | 6 ++---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala b/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala index 30fe8a25e5..67bfa87b8f 100644 --- a/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala +++ b/sigmastate/src/main/scala/sigmastate/eval/RuntimeCosting.scala @@ -1146,6 +1146,7 @@ trait RuntimeCosting extends CostingRules { IR: IRContext => val t = System.nanoTime() ruleStack = new CostingRuleStat(node, t, 0, t) :: ruleStack } + val res: Ref[Any] = node match { case c @ Constant(v, tpe) => v match { case p: SSigmaProp => diff --git a/sigmastate/src/main/scala/sigmastate/utxo/CostTable.scala b/sigmastate/src/main/scala/sigmastate/utxo/CostTable.scala index fd3eba0cfd..4a55887f8d 100644 --- a/sigmastate/src/main/scala/sigmastate/utxo/CostTable.scala +++ b/sigmastate/src/main/scala/sigmastate/utxo/CostTable.scala @@ -174,8 +174,6 @@ object CostTable { ("Xor_per_kb", "(Coll[Byte],Coll[Byte]) => Coll[Byte]", hashPerKb / 2), ("XorOf_per_item", "(Coll[Boolean]) => Boolean", logicCost), ("LogicalNot", "(Boolean) => Boolean", logicCost), - // uncommenting evaluate cost for BitwiseXor, but fails to invoke zip method. - //("BitOp", "(Byte, Byte)", logicCost), ("GT", "(T,T) => Boolean", comparisonCost), ("GE", "(T,T) => Boolean", comparisonCost), diff --git a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala index 8c0d6d400a..2a161923ee 100644 --- a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -7688,18 +7688,16 @@ class SigmaDslSpecification extends SigmaDslTesting (keys, initial) -> Expected(Success(Coll[Byte](1, 2, 3, 4, 5)), cost = 46522, expectedDetails = CostDetails.ZeroCost, 1821) ) val scalaFunc = { (x: (Coll[Coll[Byte]], Coll[Byte])) => - val foo = x._1.foldLeft(x._2, { (a: (Coll[Byte], Coll[Byte])) => + x._1.foldLeft(x._2, { (a: (Coll[Byte], Coll[Byte])) => a._1.zip(a._2).map({ (c: (Byte, Byte)) => (c._1 + c._2).toByte }) }) - foo } val script = """{ | (x: (Coll[Coll[Byte]], Coll[Byte])) => - | val foo = x._1.fold(x._2, { (a: Coll[Byte], b: Coll[Byte]) => + | x._1.fold(x._2, { (a: Coll[Byte], b: Coll[Byte]) => | a.zip(b).map({ (c: (Byte, Byte)) => (c._1 + c._2).toByte }) | }) - | foo |}""".stripMargin if (lowerMethodCallsInTests) { verifyCases(cases, From c84aa3595e5946c83050884083e404e4e79a0ced Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Mon, 4 Apr 2022 17:28:22 +0200 Subject: [PATCH 6/7] v5.0-fix-flatmap: remove checkValidFlatmap from flatMap_eval (which is used by v5.0 interpreter) --- sigmastate/src/main/scala/sigmastate/types.scala | 3 --- .../src/test/scala/special/sigma/SigmaDslSpecification.scala | 3 --- 2 files changed, 6 deletions(-) diff --git a/sigmastate/src/main/scala/sigmastate/types.scala b/sigmastate/src/main/scala/sigmastate/types.scala index dcfdadf5fc..d173d4d4ff 100644 --- a/sigmastate/src/main/scala/sigmastate/types.scala +++ b/sigmastate/src/main/scala/sigmastate/types.scala @@ -1688,9 +1688,6 @@ object SCollection extends STypeCompanion with MethodByNameUnapply { */ def flatMap_eval[A, B](mc: MethodCall, xs: Coll[A], f: A => Coll[B]) (implicit E: ErgoTreeEvaluator): Coll[B] = { - if (!VersionContext.current.isJitActivated) { - checkValidFlatmap(mc) - } val m = mc.method var res: Coll[B] = null E.addSeqCost(m.costKind.asInstanceOf[PerItemCost], m.opDesc) { () => diff --git a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala index 2a161923ee..946a4a64f7 100644 --- a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -6005,10 +6005,7 @@ class SigmaDslSpecification extends SigmaDslTesting val f = changedFeature( { (x: Coll[GroupElement]) => SCollection.throwInvalidFlatmap(null) }, { (x: Coll[GroupElement]) => - if (VersionContext.current.isJitActivated) x.flatMap({ (b: GroupElement) => b.getEncoded.indices }) - else - SCollection.throwInvalidFlatmap(null) }, "", // NOTE, the script for this test case cannot be compiled FuncValue( From bee7396ead3d9cd3113b5e984c30d178cbfbbe39 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Mon, 4 Apr 2022 17:35:16 +0200 Subject: [PATCH 7/7] v5.0-fix-flatmap: comment test code --- .../test/scala/special/sigma/SigmaDslSpecification.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala index 946a4a64f7..663955540a 100644 --- a/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -6003,9 +6003,10 @@ class SigmaDslSpecification extends SigmaDslTesting )) ) val f = changedFeature( - { (x: Coll[GroupElement]) => SCollection.throwInvalidFlatmap(null) }, - { (x: Coll[GroupElement]) => - x.flatMap({ (b: GroupElement) => b.getEncoded.indices }) + scalaFunc = { (x: Coll[GroupElement]) => SCollection.throwInvalidFlatmap(null) }, + scalaFuncNew = { (x: Coll[GroupElement]) => + // NOTE, v5.0 interpreter accepts any lambda in flatMap + x.flatMap({ (b: GroupElement) => b.getEncoded.indices }) }, "", // NOTE, the script for this test case cannot be compiled FuncValue(