diff --git a/compiler/damlc/tests/daml-test-files/ContractKeyNotEffective.daml b/compiler/damlc/tests/daml-test-files/ContractKeyNotEffective.daml index 791b10a3868..380152a95e6 100644 --- a/compiler/damlc/tests/daml-test-files/ContractKeyNotEffective.daml +++ b/compiler/damlc/tests/daml-test-files/ContractKeyNotEffective.daml @@ -1,4 +1,4 @@ --- @ERROR range=14:1-14:19; contract 0055b33c9fd9928bdf0c2c611194865917b9aaf8b4b94a44abc25ddfea6d866cd1 not effective, but we found its key! +-- @ERROR range=14:1-14:19; contract 0053db8d12a2aebf02e9d3c2dc653c7b8f61914eeef91b2d6e08b5b066925592a4 not effective, but we found its key! module ContractKeyNotEffective where import DA.Time diff --git a/compiler/scenario-service/server/src/main/scala/com/digitalasset/daml/lf/scenario/Context.scala b/compiler/scenario-service/server/src/main/scala/com/digitalasset/daml/lf/scenario/Context.scala index b0ddc1e3e01..3cb7fe5b53b 100644 --- a/compiler/scenario-service/server/src/main/scala/com/digitalasset/daml/lf/scenario/Context.scala +++ b/compiler/scenario-service/server/src/main/scala/com/digitalasset/daml/lf/scenario/Context.scala @@ -156,7 +156,7 @@ class Context(val contextId: Context.ContextId, languageVersion: LanguageVersion buildMachine( Identifier(PackageId.assertFromString(pkgId), QualifiedName.assertFromString(name)) ).map { machine => - ScenarioRunner(machine, txSeeding).run() + new ScenarioRunner(machine, txSeeding).run() } } diff --git a/daml-lf/repl/src/main/scala/com/digitalasset/daml/lf/repl/testing/Main.scala b/daml-lf/repl/src/main/scala/com/digitalasset/daml/lf/repl/testing/Main.scala index cf2b591ba2c..e4752c57471 100644 --- a/daml-lf/repl/src/main/scala/com/digitalasset/daml/lf/repl/testing/Main.scala +++ b/daml-lf/repl/src/main/scala/com/digitalasset/daml/lf/repl/testing/Main.scala @@ -206,7 +206,7 @@ object Repl { compiledPackages, expr, ) - (machine, ScenarioRunner(machine, seed).run()) + (machine, new ScenarioRunner(machine, seed).run()) } } diff --git a/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala b/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala index b494aecb14d..eaf7c8ad704 100644 --- a/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala +++ b/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala @@ -30,14 +30,14 @@ import scala.util.{Failure, Success, Try} * same result each time given the same argument. Should return values compatible * with [[com.daml.lf.data.Ref.Party]]. */ -final case class ScenarioRunner( +final class ScenarioRunner( machine: Speedy.Machine, initialSeed: crypto.Hash, partyNameMangler: (String => String) = identity, ) { import ScenarioRunner._ - var seed = initialSeed + private[this] val nextSeed: () => crypto.Hash = crypto.Hash.secureRandom(initialSeed) var ledger: ScenarioLedger = ScenarioLedger.initialLedger(Time.Timestamp.Epoch) var currentSubmission: Option[CurrentSubmission] = None @@ -90,7 +90,7 @@ final case class ScenarioRunner( Set.empty, SExpr.SEValue(commands), location, - seed, + nextSeed(), machine.traceLog, machine.warningLog, ) @@ -99,14 +99,7 @@ final case class ScenarioRunner( case Commit(result, _, ptx) => currentSubmission = Some(CurrentSubmission(location, ptx.finishIncomplete)) throw scenario.Error.MustFailSucceeded(result.richTransaction.transaction) - case err: SubmissionError => - currentSubmission = None - // TODO (MK) This is gross, we need to unwind the transaction to - // get the right root context to derived the seed for the next transaction. - val rootCtx = err.ptx.unwind().context - seed = nextSeed( - rootCtx.nextActionChildSeed - ) + case _: SubmissionError => ledger = ledger.insertAssertMustFail(committers, Set.empty, location) callback(SValue.SUnit) } @@ -114,9 +107,6 @@ final case class ScenarioRunner( submitResult match { case Commit(result, value, _) => currentSubmission = None - seed = nextSeed( - crypto.Hash.deriveNodeSeed(seed, result.richTransaction.transaction.roots.length) - ) ledger = result.newLedger callback(value) case SubmissionError(err, ptx) => @@ -171,7 +161,7 @@ object ScenarioRunner { engine.compiledPackages(), scenarioExpr, ) - ScenarioRunner(speedyMachine, transactionSeed).run() match { + new ScenarioRunner(speedyMachine, transactionSeed).run() match { case err: ScenarioError => throw new RuntimeException(s"error running scenario $scenarioRef in scenario ${err.error}") case success: ScenarioSuccess => success.ledger diff --git a/daml-lf/scenario-interpreter/src/test/scala/com/digitalasset/daml/lf/ScenarioRunnerTest.scala b/daml-lf/scenario-interpreter/src/test/scala/com/digitalasset/daml/lf/ScenarioRunnerTest.scala index 3fde47d0405..db7737305d6 100644 --- a/daml-lf/scenario-interpreter/src/test/scala/com/digitalasset/daml/lf/ScenarioRunnerTest.scala +++ b/daml-lf/scenario-interpreter/src/test/scala/com/digitalasset/daml/lf/ScenarioRunnerTest.scala @@ -19,7 +19,7 @@ class ScenarioRunnerTest extends AsyncWordSpec with Matchers with ScalaFutures { val e = Ast.EScenario(Ast.ScenarioGetParty(Ast.EPrimLit(Ast.PLText("foo-bar")))) val txSeed = crypto.Hash.hashPrivateKey("ScenarioRunnerTest") val m = speedy.Speedy.Machine.fromScenarioExpr(PureCompiledPackages.Empty, e) - val sr = ScenarioRunner(m, txSeed, _ + "-XXX") + val sr = new ScenarioRunner(m, txSeed, _ + "-XXX") sr.run() match { case success: ScenarioRunner.ScenarioSuccess => success.resultValue shouldBe SValue.SParty(Ref.Party.assertFromString("foo-bar-XXX")) diff --git a/daml-lf/tests/scenario/actualize.sh b/daml-lf/tests/scenario/actualize.sh index 43ad8a4f8e9..df245dc9605 100755 --- a/daml-lf/tests/scenario/actualize.sh +++ b/daml-lf/tests/scenario/actualize.sh @@ -24,5 +24,5 @@ bazel build //compiler/damlc:damlc ../../../bazel-bin/compiler/damlc/damlc package --debug $TESTMAIN main -o $TESTDAR bazel build //daml-lf/repl:repl -../../../bazel-bin/daml-lf/repl/repl test Test:run $TESTDAR | sed '1d' | sed -E "$REGEX_HIDE_HASHES" | tee ${TESTDIR}/EXPECTED.ledger.new +../../../bazel-bin/daml-lf/repl/repl --dev test Test:run $TESTDAR | sed -E "$REGEX_HIDE_HASHES" | tee ${TESTDIR}/EXPECTED.ledger.new diff --git a/daml-lf/tests/scenario/dev/exception-auth/EXPECTED.ledger b/daml-lf/tests/scenario/dev/exception-auth/EXPECTED.ledger index e76662dbbe3..758e123c9be 100644 --- a/daml-lf/tests/scenario/dev/exception-auth/EXPECTED.ledger +++ b/daml-lf/tests/scenario/dev/exception-auth/EXPECTED.ledger @@ -9,7 +9,7 @@ TX #0 1970-01-01T00:00:00Z [Test:42] version: dev TX #1 1970-01-01T00:00:00Z [Test:44] version: dev #1:0 version: dev │ known to (since): a (#1), b (#1) -└─> b exercises CreateInTry:Test:Tester@XXXXXXXX on 009877e9c7e647b905ba9185add7af1b24e664508899260672b7e21c59ad9168d1 +└─> b exercises CreateInTry:Test:Tester@XXXXXXXX on 003596dec622807ab002c4bd5534e2f12fb2936da75d44b282df6cdf58a007fe1a with { } children: #1:1 no-version @@ -23,7 +23,7 @@ TX #1 1970-01-01T00:00:00Z [Test:44] version: dev TX #2 1970-01-01T00:00:00Z [Test:47] version: dev #2:0 version: dev │ known to (since): a (#2), b (#2) -└─> b exercises CreateInNestedTry:Test:Tester@XXXXXXXX on 009877e9c7e647b905ba9185add7af1b24e664508899260672b7e21c59ad9168d1 +└─> b exercises CreateInNestedTry:Test:Tester@XXXXXXXX on 003596dec622807ab002c4bd5534e2f12fb2936da75d44b282df6cdf58a007fe1a with { } children: #2:1 no-version @@ -35,4 +35,4 @@ TX #2 1970-01-01T00:00:00Z [Test:47] version: dev with: { ps = ['a', 'b'] } active contracts: - 009877e9c7e647b905ba9185add7af1b24e664508899260672b7e21c59ad9168d1 + 003596dec622807ab002c4bd5534e2f12fb2936da75d44b282df6cdf58a007fe1a diff --git a/daml-lf/tests/scenario/stable/big-numeric/EXPECTED.ledger b/daml-lf/tests/scenario/stable/big-numeric/EXPECTED.ledger index 92550c54d8c..33f02dc1278 100644 --- a/daml-lf/tests/scenario/stable/big-numeric/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/big-numeric/EXPECTED.ledger @@ -6,4 +6,4 @@ TX #0 1970-01-01T00:00:00Z [Test:21] version: 14 with: { party = 'Alice', values = [1.0000000000, -0.5000000000, 0.2500000000, 1.0000000000, 0.0000000000, 1.0000000000, 0.0000000000] } active contracts: - 0019f204ef6ba77f8003a1c679c3ca245028d8e82c713ebb267ea3cc3d802d6df3 + 00fc4114f9e0408a3b8587e01e9bc7daaceffd8f1a42e7e17f0ccbd44d5427b8c5 diff --git a/daml-lf/tests/scenario/stable/contract-key-through-exercises/EXPECTED.ledger b/daml-lf/tests/scenario/stable/contract-key-through-exercises/EXPECTED.ledger index e60791bb03c..87a7bcc5534 100644 --- a/daml-lf/tests/scenario/stable/contract-key-through-exercises/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/contract-key-through-exercises/EXPECTED.ledger @@ -10,7 +10,7 @@ TX #0 1970-01-01T00:00:00Z [Test:48] version: 14 TX #1 1970-01-01T00:00:00Z [Test:49] version: 14 #1:0 version: 14 │ known to (since): Alice (#1), Bob (#1) -└─> Bob exercises Accept:Test:KeyOps@XXXXXXXX on 0066d7eab72b04d1ab3c24f2f3cb2a2d9266c2c2dc769c8b4699b6db3a4f56ec46 +└─> Bob exercises Accept:Test:KeyOps@XXXXXXXX on 00662af883a5ac96f706d6af9627078daf1d4f833adcb5c33d75426182437c7418 with { } children: #1:1 version: 14 @@ -22,7 +22,7 @@ TX #1 1970-01-01T00:00:00Z [Test:49] version: 14 TX #2 1970-01-01T00:00:00Z [Test:51] version: 14 #2:0 version: 14 │ known to (since): Alice (#2), Bob (#2) -└─> Alice exercises LookupGivenKey:Test:KeyOps@XXXXXXXX on 00541236708d6615d0586a50793ccd77d0bc2b7c51025df96ce743c2469c8d3c95 +└─> Alice exercises LookupGivenKey:Test:KeyOps@XXXXXXXX on 00420cfea44e4d7f536caf95c9a45394bdc0994e38cbff3b02c444d39bd3ba3d9a with { actor = 'Alice', keyMaintainers = DA.Next.Set:Set@XXXXXXXX{ textMap = TextMap(Alice -> ) } } children: #2:1 version: 14 @@ -34,7 +34,7 @@ TX #2 1970-01-01T00:00:00Z [Test:51] version: 14 TX #3 1970-01-01T00:00:00Z [Test:54] version: 14 #3:0 version: 14 │ known to (since): Alice (#3), Bob (#3) -└─> Bob exercises LookupGivenKey:Test:KeyOps@XXXXXXXX on 00541236708d6615d0586a50793ccd77d0bc2b7c51025df96ce743c2469c8d3c95 +└─> Bob exercises LookupGivenKey:Test:KeyOps@XXXXXXXX on 00420cfea44e4d7f536caf95c9a45394bdc0994e38cbff3b02c444d39bd3ba3d9a with { actor = 'Bob', keyMaintainers = DA.Next.Set:Set@XXXXXXXX{ textMap = TextMap(Alice -> ) } } children: #3:1 version: 14 @@ -54,16 +54,16 @@ key { textMap = TextMap(Alice -> ) } TX #5 1970-01-01T00:00:00Z [Test:59] version: 14 #5:0 version: 14 │ known to (since): Alice (#5), Bob (#5) -└─> Alice exercises LookupGivenKey:Test:KeyOps@XXXXXXXX on 00541236708d6615d0586a50793ccd77d0bc2b7c51025df96ce743c2469c8d3c95 +└─> Alice exercises LookupGivenKey:Test:KeyOps@XXXXXXXX on 00420cfea44e4d7f536caf95c9a45394bdc0994e38cbff3b02c444d39bd3ba3d9a with { actor = 'Alice', keyMaintainers = DA.Next.Set:Set@XXXXXXXX{ textMap = TextMap(Alice -> ) } } children: #5:1 version: 14 │ known to (since): Alice (#5), Bob (#5) └─> lookup by key Test:BasicKey@XXXXXXXX key { textMap = TextMap(Alice -> ) } - found 001562b1ff4a33485e45d6e392d6eea26e518c878dae2b8f1d2a6c7d8face9d0f7 + found 003cb3efc384096d3804f43242d5a20876071b307e08fb06787cf6a3786ee833b2 mustFailAt actAs: {'Bob'} readAs: {} [Test:62] active contracts: - 001562b1ff4a33485e45d6e392d6eea26e518c878dae2b8f1d2a6c7d8face9d0f7, 00541236708d6615d0586a50793ccd77d0bc2b7c51025df96ce743c2469c8d3c95 + 003cb3efc384096d3804f43242d5a20876071b307e08fb06787cf6a3786ee833b2, 00420cfea44e4d7f536caf95c9a45394bdc0994e38cbff3b02c444d39bd3ba3d9a diff --git a/daml-lf/tests/scenario/stable/contract-keys/EXPECTED.ledger b/daml-lf/tests/scenario/stable/contract-keys/EXPECTED.ledger index 6b72a89f50b..587d86d044d 100644 --- a/daml-lf/tests/scenario/stable/contract-keys/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/contract-keys/EXPECTED.ledger @@ -19,12 +19,12 @@ TX #4 1970-01-01T00:00:00Z [Test:93] version: 14 │ known to (since): Alice (#4) └─> lookup by key Test:TextKey@XXXXXXXX key { _1 = 'Alice', _2 = "some-key" } -found 0066d7eab72b04d1ab3c24f2f3cb2a2d9266c2c2dc769c8b4699b6db3a4f56ec46 +found 00662af883a5ac96f706d6af9627078daf1d4f833adcb5c33d75426182437c7418 TX #5 1970-01-01T00:00:00Z [Test:97] version: 14 #5:0 version: 14 │ known to (since): Alice (#5) -└─> ensure active 0066d7eab72b04d1ab3c24f2f3cb2a2d9266c2c2dc769c8b4699b6db3a4f56ec46 +└─> ensure active 00662af883a5ac96f706d6af9627078daf1d4f833adcb5c33d75426182437c7418 TX #6 1970-01-01T00:00:00Z [Test:101] version: 14 #6:0 version: 14 @@ -43,7 +43,7 @@ not found TX #8 1970-01-01T00:00:00Z [Test:109] version: 14 #8:0 version: 14 │ known to (since): Alice (#8), Bob (#8) -└─> Alice exercises TextKeyChoice:Test:TextKey@XXXXXXXX on 0066d7eab72b04d1ab3c24f2f3cb2a2d9266c2c2dc769c8b4699b6db3a4f56ec46 +└─> Alice exercises TextKeyChoice:Test:TextKey@XXXXXXXX on 00662af883a5ac96f706d6af9627078daf1d4f833adcb5c33d75426182437c7418 with { } @@ -66,7 +66,7 @@ key { _1 = 'Alice', _2 = "some-key-2" } TX #11 1970-01-01T00:00:00Z [Test:123] version: 14 #11:0 version: 14 │ known to (since): Alice (#11), Bob (#11) -└─> Alice exercises TextKeyChoice:Test:TextKey@XXXXXXXX on 004f56105c00ca4026b905ed27b104471dffcaf2de15832139b93ef46b87000232 +└─> Alice exercises TextKeyChoice:Test:TextKey@XXXXXXXX on 00017991efcb9a29bf248cfe47c1ed66f6df6da90ee467c72045ad2d664d976194 with { } @@ -88,7 +88,7 @@ key { _1 = 'Alice', _2 = "same-submit-key" } │ known to (since): Alice (#12) └─> lookup by key Test:TextKey@XXXXXXXX key { _1 = 'Alice', _2 = "same-submit-key" } -found 00a95ea3bb21422ab003f15dc95de204110b3f7f2682b407a2ba75d36b0be9053b +found 00bd46775c336a07f7c6d244b55b35aba17c74eb29f07685840ccc3f8705df86da TX #13 1970-01-01T00:00:00Z [Test:137] version: 14 #13:0 version: 14 @@ -100,7 +100,7 @@ TX #13 1970-01-01T00:00:00Z [Test:137] version: 14 TX #14 1970-01-01T00:00:00Z [Test:141] version: 14 #14:0 version: 14 │ known to (since): Alice (#14) -└─> Alice exercises Good:Test:CreateAndLookup@XXXXXXXX on 00528ef7ca096fcc1cfb640394394117e237d21236faef81c544770ec5962c462c +└─> Alice exercises Good:Test:CreateAndLookup@XXXXXXXX on 006004656e352547624a77a9af18090cb61e5485c93ba7043651c766e06c60b9ca with { } children: #14:1 version: 14 @@ -113,10 +113,10 @@ TX #14 1970-01-01T00:00:00Z [Test:141] version: 14 │ known to (since): Alice (#14) └─> lookup by key Test:TextKey@XXXXXXXX key { _1 = 'Alice', _2 = "same-choice-key" } - found 00ce68df68a7e42ecadca4ff1e4d35ffff75f009d1f01ae130d36116e1332ff773 + found 00c81bd2d424f0b4a6e7d5a58e4661f971e2fbab837b9718d6a787700340c1db04 #14:3 version: 14 │ known to (since): Alice (#14) - └─> ensure active 00ce68df68a7e42ecadca4ff1e4d35ffff75f009d1f01ae130d36116e1332ff773 + └─> ensure active 00c81bd2d424f0b4a6e7d5a58e4661f971e2fbab837b9718d6a787700340c1db04 mustFailAt actAs: {'Alice'} readAs: {} [Test:144] @@ -130,7 +130,7 @@ key { _1 = 'Alice', _2 = "non-consuming-choice" } #16:1 version: 14 │ known to (since): Alice (#16) -└─> Alice exercises TextKeyNonconsumingChoice:Test:TextKey@XXXXXXXX on 00bcf23c0f4133f226e7051a79ab289277e1a3941dcf08c545ff477593c9b22651 +└─> Alice exercises TextKeyNonconsumingChoice:Test:TextKey@XXXXXXXX on 0088ba74115a8c7a32610295f6693cfba76bd320771819cac47e6bce34e28f66d6 with { } @@ -138,9 +138,9 @@ key { _1 = 'Alice', _2 = "non-consuming-choice" } │ known to (since): Alice (#16) └─> lookup by key Test:TextKey@XXXXXXXX key { _1 = 'Alice', _2 = "non-consuming-choice" } -found 00bcf23c0f4133f226e7051a79ab289277e1a3941dcf08c545ff477593c9b22651 +found 0088ba74115a8c7a32610295f6693cfba76bd320771819cac47e6bce34e28f66d6 mustFailAt actAs: {'Alice'} readAs: {} [Test:158] active contracts: - 00528ef7ca096fcc1cfb640394394117e237d21236faef81c544770ec5962c462c, 00a95ea3bb21422ab003f15dc95de204110b3f7f2682b407a2ba75d36b0be9053b, 00bcf23c0f4133f226e7051a79ab289277e1a3941dcf08c545ff477593c9b22651, 00ce68df68a7e42ecadca4ff1e4d35ffff75f009d1f01ae130d36116e1332ff773 + 006004656e352547624a77a9af18090cb61e5485c93ba7043651c766e06c60b9ca, 0088ba74115a8c7a32610295f6693cfba76bd320771819cac47e6bce34e28f66d6, 00bd46775c336a07f7c6d244b55b35aba17c74eb29f07685840ccc3f8705df86da, 00c81bd2d424f0b4a6e7d5a58e4661f971e2fbab837b9718d6a787700340c1db04 diff --git a/daml-lf/tests/scenario/stable/divulge-iou/EXPECTED.ledger b/daml-lf/tests/scenario/stable/divulge-iou/EXPECTED.ledger index a5ff229e677..790906d6ecb 100644 --- a/daml-lf/tests/scenario/stable/divulge-iou/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/divulge-iou/EXPECTED.ledger @@ -16,12 +16,12 @@ TX #1 1970-01-01T00:00:00Z [Test:17] version: 14 TX #2 1970-01-01T00:00:00Z [Test:20] version: 14 #2:0 version: 14 │ known to (since): AlicesBank (#2), Bob (#2) -└─> AlicesBank exercises Divulge:Test:DivulgeIouByExercise@XXXXXXXX on 00999d35e67dc49f91772eaffd08179f431661a382cd68edc7d25ee2c2508fb6a3 - with { ref = 00a21310a64aec150c16589881ebebc4780fc8e476489ef939a1ebfbfeb1aa3835 } +└─> AlicesBank exercises Divulge:Test:DivulgeIouByExercise@XXXXXXXX on 00df288b1eefaa504409b5b6ab8918fa53f308cba0e9be76b16c2dd61e432048aa + with { ref = 008d786470605293774dad75f6bc0df268eb612271f1547003669c7b8517d2d5ac } children: #2:1 version: 14 │ known to (since): AlicesBank (#2), Bob (#2) - └─> ensure active 00a21310a64aec150c16589881ebebc4780fc8e476489ef939a1ebfbfeb1aa3835 + └─> ensure active 008d786470605293774dad75f6bc0df268eb612271f1547003669c7b8517d2d5ac active contracts: - 00999d35e67dc49f91772eaffd08179f431661a382cd68edc7d25ee2c2508fb6a3, 00a21310a64aec150c16589881ebebc4780fc8e476489ef939a1ebfbfeb1aa3835 + 008d786470605293774dad75f6bc0df268eb612271f1547003669c7b8517d2d5ac, 00df288b1eefaa504409b5b6ab8918fa53f308cba0e9be76b16c2dd61e432048aa diff --git a/daml-lf/tests/scenario/stable/gen-map/EXPECTED.ledger b/daml-lf/tests/scenario/stable/gen-map/EXPECTED.ledger index b70411dd1d2..91629b5fcac 100644 --- a/daml-lf/tests/scenario/stable/gen-map/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/gen-map/EXPECTED.ledger @@ -6,4 +6,4 @@ TX #0 1970-01-01T00:00:00Z [Test:18] version: 14 with: { party = 'Alice', value = GenMap(1 -> "c", 2 -> "a", 5 -> "b") } active contracts: - 0019f204ef6ba77f8003a1c679c3ca245028d8e82c713ebb267ea3cc3d802d6df3 + 00fc4114f9e0408a3b8587e01e9bc7daaceffd8f1a42e7e17f0ccbd44d5427b8c5 diff --git a/daml-lf/tests/scenario/stable/many-fields/EXPECTED.ledger b/daml-lf/tests/scenario/stable/many-fields/EXPECTED.ledger index dd1e354e14d..6eed076b208 100644 --- a/daml-lf/tests/scenario/stable/many-fields/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/many-fields/EXPECTED.ledger @@ -6,4 +6,4 @@ TX #0 1970-01-01T00:00:00Z [Test:42] version: 14 with: { p = 'Alice', x000 = 0, x001 = 1, x002 = 2, x003 = 3, x004 = 4, x005 = 5, x006 = 6, x007 = 7, x008 = 8, x009 = 9, x010 = 10, x011 = 11, x012 = 12, x013 = 13, x014 = 14, x015 = 15, x016 = 16, x017 = 17, x018 = 18, x019 = 19, x020 = 20, x021 = 21, x022 = 22, x023 = 23, x024 = 24, x025 = 25, x026 = 26, x027 = 27, x028 = 28, x029 = 29, x030 = 30, x031 = 31, x032 = 32, x033 = 33, x034 = 34, x035 = 35, x036 = 36, x037 = 37, x038 = 38, x039 = 39, x040 = 40, x041 = 41, x042 = 42, x043 = 43, x044 = 44, x045 = 45, x046 = 46, x047 = 47, x048 = 48, x049 = 49, x050 = 50, x051 = 51, x052 = 52, x053 = 53, x054 = 54, x055 = 55, x056 = 56, x057 = 57, x058 = 58, x059 = 59, x060 = 60, x061 = 61, x062 = 62, x063 = 63, x064 = 64, x065 = 65, x066 = 66, x067 = 67, x068 = 68, x069 = 69, x070 = 70, x071 = 71, x072 = 72, x073 = 73, x074 = 74, x075 = 75, x076 = 76, x077 = 77, x078 = 78, x079 = 79, x080 = 80, x081 = 81, x082 = 82, x083 = 83, x084 = 84, x085 = 85, x086 = 86, x087 = 87, x088 = 88, x089 = 89, x090 = 90, x091 = 91, x092 = 92, x093 = 93, x094 = 94, x095 = 95, x096 = 96, x097 = 97, x098 = 98, x099 = 99, x100 = 100, x101 = 101, x102 = 102, x103 = 103, x104 = 104, x105 = 105, x106 = 106, x107 = 107, x108 = 108, x109 = 109, x110 = 110, x111 = 111, x112 = 112, x113 = 113, x114 = 114, x115 = 115, x116 = 116, x117 = 117, x118 = 118, x119 = 119, x120 = 120, x121 = 121, x122 = 122, x123 = 123, x124 = 124, x125 = 125, x126 = 126, x127 = 127, x128 = 128, x129 = 129 } active contracts: - 0019f204ef6ba77f8003a1c679c3ca245028d8e82c713ebb267ea3cc3d802d6df3 + 00fc4114f9e0408a3b8587e01e9bc7daaceffd8f1a42e7e17f0ccbd44d5427b8c5 diff --git a/daml-lf/tests/scenario/stable/mustfailcommit/EXPECTED.ledger b/daml-lf/tests/scenario/stable/mustfailcommit/EXPECTED.ledger index 27b66705f5b..4ef9c0b2431 100644 --- a/daml-lf/tests/scenario/stable/mustfailcommit/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/mustfailcommit/EXPECTED.ledger @@ -16,4 +16,4 @@ TX #2 1970-01-01T00:00:00Z [Test:36] version: 14 key { _1 = 'p', _2 = 1 } active contracts: - 006f0d7d4e37edf8575fabd93290dfe66025ad31a78aeab64dbbf912d6b593266c, 00a34815a1df96eb9da0475ea1bbbd7d1fd946b287f610cc344317adcd86cbf76b + 00ae3d4ece7463b10b5390500e3e8d59d186019a0ed3c5f52e4b79909b399e9872, 00b0ca211e2619fdabef342c95526476410189567991f0f09f87cac7106c04b77c diff --git a/daml-lf/tests/scenario/stable/mustfailinterpretation/EXPECTED.ledger b/daml-lf/tests/scenario/stable/mustfailinterpretation/EXPECTED.ledger index a952f3ed66a..97028178cdf 100644 --- a/daml-lf/tests/scenario/stable/mustfailinterpretation/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/mustfailinterpretation/EXPECTED.ledger @@ -16,4 +16,4 @@ TX #2 1970-01-01T00:00:00Z [Test:37] version: 14 key { _1 = 'p', _2 = 1 } active contracts: - 006f0d7d4e37edf8575fabd93290dfe66025ad31a78aeab64dbbf912d6b593266c, 00a34815a1df96eb9da0475ea1bbbd7d1fd946b287f610cc344317adcd86cbf76b + 00ae3d4ece7463b10b5390500e3e8d59d186019a0ed3c5f52e4b79909b399e9872, 00b0ca211e2619fdabef342c95526476410189567991f0f09f87cac7106c04b77c diff --git a/daml-lf/tests/scenario/stable/mustfails/EXPECTED.ledger b/daml-lf/tests/scenario/stable/mustfails/EXPECTED.ledger index 36e7f7dee2e..e41c28e2aa4 100644 --- a/daml-lf/tests/scenario/stable/mustfails/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/mustfails/EXPECTED.ledger @@ -38,7 +38,7 @@ TX #10 1969-12-31T23:58:20Z [Test:131] version: 14 TX #11 1969-12-31T23:58:20Z [Test:132] version: 14 #11:0 version: 14 │ known to (since): Alice (#11), Bob (#11) -└─> Bob exercises Convert:Test:ToTwoParties@XXXXXXXX on 00059653cdb8e866d69fac4d5bd0f62bbdaba4c36b01c438b86351fbdbf2cab8b0 +└─> Bob exercises Convert:Test:ToTwoParties@XXXXXXXX on 00605e684f517a8cd13fc2b33bfe8bb102dbf902811a7e686b146fa0057fe4df0f with { } children: #11:1 version: 14 @@ -85,4 +85,4 @@ TX #21 1969-12-31T23:58:20Z [Test:351] version: 14 mustFailAt actAs: {'Alice'} readAs: {} [Test:352] active contracts: - 00049c3d61768cf931aa2b97a7ac28002d7673c3f8b996798d87227106e178286e, 00067f889bdf49aa670596cab1a5907d75596d971df3477087c88ca86f281cee85, 00154fe9827fdb40afae4ba484f3f51159d99a27c1463928ec761043c28353b76c, 007e5c9342585588fff0855b297c6e06bfb6a3d62578a28da860af02a98048bd68, 00945c0656f04cdd9f6a85cb466acb0edcd75ea0f618362e83b92164c4cee523e9, 00bf46b75494167be56ef270a63cbc740370b75c98fb517457d9859d55796f7fbf, 00e52b332d66bbf5ac835144e35bf339a7ab319e505e005d1ddd9aed313764dd51 + 003b83213883e440651c50000fdd62ec935c485f92ad3ecfcfe5d6340ffbf6a54e, 00521a241477a6653321c1dfe113bea2b872d5932ae3f9e82fcb3a2b4fd92faa52, 0069683bfe5182f35398a53da7ce5c1e333486adabe913f808bd7974e54f16f5ed, 007310cf4ff7d8ca41760271bbe38518b726f4342c9ed33e545792e1df53664a0a, 009e8d7f3c6ca9cb97ca65c063871e3d2448763e2464e272e27521e28c2faf2fb3, 00bd46775c336a07f7c6d244b55b35aba17c74eb29f07685840ccc3f8705df86da, 00cabce9342394b2471049c0650815c77835ec2a7bd857c1342e7ee8a21040186d diff --git a/daml-lf/tests/scenario/stable/no-contract-ids-in-keys/EXPECTED.ledger b/daml-lf/tests/scenario/stable/no-contract-ids-in-keys/EXPECTED.ledger index f37ffd7fd5c..2faef10f835 100644 --- a/daml-lf/tests/scenario/stable/no-contract-ids-in-keys/EXPECTED.ledger +++ b/daml-lf/tests/scenario/stable/no-contract-ids-in-keys/EXPECTED.ledger @@ -1 +1 @@ -Error: Contract IDs are not supported in contract keys: ContractId(007be5e2626fcafa36cdf73e6ad638f3026f866d665764c7bc0ece5e945d71bbfb) +Error: Contract IDs are not supported in contract keys: ContractId(00fa6dbc32b678ec8a97ed0de226e397a4e2d521097b879d0146979556e7cd3e58) diff --git a/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala b/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala index a899c8f581a..f8b39b07ff9 100644 --- a/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala +++ b/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala @@ -40,7 +40,10 @@ class IdeLedgerClient( traceLog: TraceLog, warningLog: WarningLog, ) extends ScriptLedgerClient { - private var seed = crypto.Hash.hashPrivateKey(s"script-service") + private val nextSeed: () => crypto.Hash = + // We seeds to secureRandom with a fix seed to get deterministic sequences of seeds + // across different runs of IdeLedgerClient. + crypto.Hash.secureRandom(crypto.Hash.hashPrivateKey(s"script-service")) private var _currentSubmission: Option[ScenarioRunner.CurrentSubmission] = None @@ -146,7 +149,7 @@ class IdeLedgerClient( readAs, translated, optLocation, - seed, + nextSeed(), traceLog, warningLog, ) @@ -166,9 +169,6 @@ class IdeLedgerClient( case ScenarioRunner.Commit(result, _, _) => _currentSubmission = None _ledger = result.newLedger - seed = ScenarioRunner.nextSeed( - crypto.Hash.deriveNodeSeed(seed, result.richTransaction.transaction.roots.length) - ) val transaction = result.richTransaction.transaction def convRootEvent(id: NodeId): ScriptLedgerClient.CommandResult = { val node = transaction.nodes.getOrElse( @@ -206,12 +206,9 @@ class IdeLedgerClient( _currentSubmission = Some(ScenarioRunner.CurrentSubmission(optLocation, commit.ptx.finishIncomplete)) Left(()) - case error: ScenarioRunner.SubmissionError => + case _: ScenarioRunner.SubmissionError => _currentSubmission = None _ledger = ledger.insertAssertMustFail(actAs.toSet, readAs, optLocation) - seed = ScenarioRunner.nextSeed( - error.ptx.unwind().context.nextActionChildSeed - ) Right(()) }) } @@ -229,9 +226,6 @@ class IdeLedgerClient( case ScenarioRunner.Commit(result, _, _) => _currentSubmission = None _ledger = result.newLedger - seed = ScenarioRunner.nextSeed( - crypto.Hash.deriveNodeSeed(seed, result.richTransaction.transaction.roots.length) - ) val transaction = result.richTransaction.transaction def convEvent(id: NodeId): Option[ScriptLedgerClient.TreeEvent] = transaction.nodes(id) match {