Commit Graph

194 Commits

Author SHA1 Message Date
Moritz Kiefer
dee2460849
Support listKnownParties in DAML Script over JSON API (#8109)
fixes #6374

changelog_begin

- [DAML Script] listKnownParties is now also supported when running
  over the JSON API.

changelog_end
2020-11-30 15:02:54 +00:00
Moritz Kiefer
a3f8caae28
Cleanup DAML Script over JSON API (#8105)
* Cleanup DAML Script over JSON API

changelog_begin
changelog_end

* Update daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/LedgerInteraction.scala

Co-authored-by: Stephen Compall <stephen.compall@daml.com>

* Update daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/LedgerInteraction.scala

Co-authored-by: Stephen Compall <stephen.compall@daml.com>

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2020-11-30 13:36:50 +01:00
Samir Talwar
9976b4cd50
Bazel: Factor out logic around Protobuf JARs. [KVL-714] (#8084)
* kvutils: Use ScalaPB to generate a Scala JAR for daml_kvutils.proto.

* Bazel: Delete the unused `da_java_binary` rule, and inline `_wrap_rule`.

* Bazel: Factor out Java/Scala protobuf class generation into a helper.

CHANGELOG_BEGIN
CHANGELOG_END

* daml-lf/archive: Use `proto_jars`.

* Bazel: Remove the visibility modifier from `proto_jars`.

It's too confusing. Just make everything public.

* daml-lf/archive: Push protobuf source tarballs into `proto_jars`.

* Bazel: Add comments to the various parts of `proto_jars`.

* daml-assistant: Do unpleasant things with `location` in Bazel.
2020-11-27 08:34:53 +00:00
Robin Krom
5bfff4e9ba
sandbox: fail on already existing port-file. (#7929)
Fixes #7806. This aligns the port file behaviour of the sandbox with the
HTTP JSON API.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-17 11:08:37 +01:00
Sofia Faro
f7e096afc3
Make GHC recognise our ($) operator. (#7969)
* Make GHC recognise our ($) operator.

Fixes #4555 by moving ($) to GHC.Base and giving it a levity polymorphic
signature, as GHC expects. Added a regression test.

changelog_begin
changelog_end

* Update line numbers for debug...

* Fix `daml test-script` tests

changelog_begin
changelog_end

* fmt for the format gods

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-11-16 15:10:14 +00:00
Moritz Kiefer
1dcfca11d7
Include listKnownParties in DAML Script docs (#7955)
* Include listKnownParties in DAML Script docs

Ratko pointed out that this can often be useful in demo scenarios so
we might as well include it while documenting the caveats. I’ve also
added some subheadings since this got a bit out of hand.

changelog_begin
changelog_end

* Fix tests

changelog_begin
changelog_end
2020-11-13 07:43:56 +00:00
Moritz Kiefer
05b4f95967
Avoid verbose mode in DAML Script and DAML triggers (#7870)
We only expose the DAML values to users which don’t depend on this, so
we might as well avoid the unnecessary costs associated with verbose
mode especially since those are expected to increase in the
foreseeable future.

changelog_begin
changelog_end
2020-11-03 18:37:13 +01:00
Remy
21c1c951f1
LF: remove control of input/output value/transaction versions. (#7858)
This is made obsolete by #7788.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-02 20:02:53 +01:00
Jussi Mäki
fa9bc4a984
Cache computation of top-level values at definition level (#7818)
* Cache computation of top-level values at definition level

Earlier the computation of a top-level value was only cached at the
use-site in SEVal. This introduces SDefinition which contains the same
mechanism as SEVal to cache the computation.

As expected this does not impact performance much:

before: CollectAuthority.bench  //daml-lf/scenario-interpreter/CollectAuthority.dar  CollectAuthority:test  avgt   40  44.267 ± 0.728  ms/op
after: CollectAuthority.bench  //daml-lf/scenario-interpreter/CollectAuthority.dar  CollectAuthority:test  avgt   40  43.693 ± 0.702  ms/op

What this does have a significant impact is on reducing the number of distinct
SValues for things like type class dictionaries etc, so that now we have one
SValue per dictionary rather than one per SEVal.

CHANGELOG_BEGIN
CHANGELOG_END

* Address code review

* Fix speedy tests
2020-10-28 13:39:20 +00:00
Samir Talwar
7f679b9896
resources: Customizable contexts. (#7678)
* resources: Move builders into //ledger/ledger-resources.

Keep the actual constructors in a trait, but instantiate it when working
with ledger code.

This allows us to later introduce an extra "context" type parameter to
ResourceOwner.

* resources-akka: Move the builders in to //ledger/ledger-resources.

* resources: Introduce an abstract `Context` parameter for owners.

This replaces the concrete `ExecutionContext`. While it _can_ be an
execution context, it really doesn't matter as long as we can get at one
somehow.

This is being introduced so we can wrap the context in a container,
either for type tagging or to include extra information.

Because our current context _is_ `ExecutionContext`, and an implicit is
provided to extract it, we can end up with two ways to get the same
value. We use shadowing to prevent this. This problem should go away in
the near future when a new context type is added.

CHANGELOG_BEGIN
- [Integration Kit] The `ResourceOwner` type is now parameterized by a
  `Context`, which is filled in by the corresponding `Context` class in
  the _ledger-resources_ dependency. This allows us to pass extra
  information through resource acquisition.
CHANGELOG_END

* ledger-resources: Move `ResourceOwner` here from `resources`.

* ledger-resources: Remove dependencies from outside //ledger.

* ledger-resource: Wrap the acquisition execution context in `Context`.

So we can add a logging context to it.

* resources: Pass the Context, not the ExecutionContext, to Resource.

* Avoid importing `HasExecutionContext`.

* ledger-resources: Publish to Maven Central.

* resources: Make the small changes suggested by @stefanobaghino-da.

Co-Authored-By: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

* ledger-resources: Pull out a trait for test resource contexts.

Saves a few lines of code.

* Restore some imports that were accidentally wildcarded.

* resources: Replace an `implicit def` with a couple of imports.

* participant-integration-api: Simplify the JdbcLedgerDaoBackend tests.

Try and use the right execution context where possible.

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2020-10-20 09:26:28 +00:00
Moritz Kiefer
9c339f3c1c
Address review feedback from #7682 (#7691)
changelog_begin
changelog_end
2020-10-15 16:35:27 +02:00
Moritz Kiefer
598698abb7
Support multi-party queries in daml script (#7682)
Small comment: This is technically not completely backwards compatible
since it messes with type inference. But to hit that you are doing
something sufficiently advanced that you should be able to add the
type annotation that is required

fixes #7635

changelog_begin

- [DAML Script] `query`, `queryContractId` and `queryContractKey` now
  accepts multiple parties using the `IsParties` abstraction used by
  `signatory`, `observer` and other fields. They will return all
  contracts for which any of the given parties is a stakeholder. Since
  `Party` is an instance of `IsParties`, this is fully backwards
  compatible.

changelog_end
2020-10-14 16:03:48 +02:00
Moritz Kiefer
cd4f085e92
Support multiple parties in scenario’s ParticipantView (#7666)
As part of multi-party read/write on command submissions we also need
to be able to support multi-party queries in DAML Script. Since the
queries in DAML Studio go via ParticipantView, this PR extends this as
a prerequisite to making use of this in DAML Script.

This does not yet relax any restrictions on command submissions. Those
still require a single committer.

For consistency with the surrounding code, I went for a simple Set
rather than a non-empty Set.

changelog_begin
changelog_end
2020-10-14 12:51:02 +02:00
Remy
dc34d4f637
LF: add PackageInterface a lightweigh Package (#7577)
CHANGELOG_BEGIN
CHANGELOG_END
2020-10-13 12:41:22 +02:00
Remy
ea2a637a11
LF: decouple template from record in the Scala Ast. (#7631)
CHANGELOG_BEGIN
CHANGELOG_END
2020-10-12 11:28:30 +02:00
Robert Autenrieth
8f57b9bf85
Add ability to start only indexer or only ledger API server [KVL-584] (#7574)
* Add ability to start only indexer or lapi server

CHANGELOG_BEGIN
CHANGELOG_END

* Change command line arguments

* Use Resource.unit

* Fix MultiParticipantFixture

* Add a new conformance test

* Improve retrying connecting to the database

* Improve naming

* Introduce shardName

and use it to create unique metric names

* Fix a merge error

* Remove unused comment

* Fix test

* Run conformance-test-split-participant in batch mode

Co-authored-by: tudor-da <tudor.voicu@digitalasset.com>
2020-10-12 09:46:20 +02:00
Remy
a69d10766d
DAML-Script: use idomatic way to convert Option to Either. (#7627)
CHANGELOG_BEGIN
CHANGELOG_END
2020-10-09 14:33:17 +00:00
Moritz Kiefer
e09c31899d
Connectify user-facing output (#7624)
Together with #7615, this overs all items in #7612.

changelog_begin
changelog_end
2020-10-09 15:45:02 +02:00
Gerolf Seitz
e2da5ba010
Bump hardcoded timeout for party alloc/package upload (#7593)
Make the hardcoded timeout for party allocaction/package upload configurable
This is a short term fix to remediate issues with uploading packages
that take a considerable amount of time to decode and validate and
therefore exhausting the 30 seconds.

Adding a maximum record parameter to the ledger API like we already have
for the config management service is not as straight forward for the
package upload, because one has to account for the time in transit as
well. This topic needs further analysis, but in the meantime making the
timeout configurable and setting the default to 2 minutes should provide
enough headroom to alleviate existing issues with package upload timing.

Contributes to #6880

CHANGELOG_BEGIN
[Integration Kit]: The hardcoded timeout for party
allocation and package uploads in the Ledger API Server can be configured via ParticipantConfig and
the default value is now set to 2 minutes. See
`issue #6880 <https://github.com/digital-asset/daml/issues/6880>`__.
CHANGELOG_END
2020-10-07 18:59:01 +02:00
Stephen Compall
2368aa7719
make Script's free runner more declarative with new utilities (#7563)
* make Script's free runner more declarative with new utilities

- use JavaList patterns instead of j.u.List#get

- use nested patterns instead of extra for-Future steps

- use unrollFree instead of matching on Free and SVariant

- use a custom variant of match2, deleting most failure fallbacks (and making some
  mismatched error messages *very* obvious)

- patterns and function were added in #7456; this builds on that

* fix now-clearly wrong error messages

* missed SetTime interpretation case

* fallback no longer used; handled by unrollFree instead

* fallback no longer used; handled by unrollFree instead

* stray whitespace in an error message

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END
2020-10-05 06:59:43 +00:00
Stephen Compall
0e71a2d3d2
interpret allowed updates and other actions in a free Trigger monad, like Script (#7456)
* conservatively move daml-script, trigger SValue interpreters to common library

* introduce expect and JavaList pattern for converters

* clean up trigger Converter Command interpretation

* add Church Free monad

* add an action language for trigger updates

* add expectE to remove some of the joins

* convert more of the converters to expect

* tool for unrolling Free/Roll

* split handleStepResult up and clean up its pattern

* handleStepFreeResult to interpret TriggerF

* replace Free Church with Pure/Roll free from Script

* newtype for ActionTrigger

* replace update in low-level Trigger with Free TriggerF

* submit one Commands at a time

* boolean blindness strikes again

* log missed TriggerF steps

* comment actual Submit contents

* match #7501 fromPureSExpr sig change in 00b80b8ea3

* avoid using forwardPort in runTrigger

* push State back into DAML, so it can be excluded from the action list

* push Message back into DAML, unifying the action language for initialState and update

* bringing TriggerF into initial state

* really add TriggerF into initial state, with all ports, tested

* add ActionTrigger class, express initialState in its terms

* add all TriggerF actions to existing TriggerA

* Trigger.rule will no longer have Time argument

* rename getS, setS to get, put, matching C.M.T.State from transformers

* make high-level Rule evaluate to the underlying TriggerF sequence

* Assert's testRule doesn't have a transform yet

* move DamlTuple2 to common converter library

- suggested by @cocreature; thanks

* combine the two Frees, provide from Script

* remove time argument from integration tests

CHANGELOG_BEGIN
- [Triggers] The ``Time`` argument was removed from the trigger rule function; instead, it
  can be fetched within the ``TriggerA`` ``do`` block by ``getTime``, as with ``Update``
  and ``Scenario``.  The ``LowLevel`` trigger interface has been redesigned; such triggers
  need to be rewritten or ported to high-level triggers.
  See `issue #7456 <https://github.com/digital-asset/daml/pull/7456>`_.
CHANGELOG_END

* add trigger rule simulator to support Assert module

* missed new Free module

- left in script per @cocreature

* remove retract as we ended up using foldFree for that purpose instead

- suggested by @cocreature; thanks

* throw ConverterException instead of RuntimeException

- suggested by @cocreature; thanks

* remove Time argument from coin-upgrade-trigger

* port trigger service tests

* port trigger scenario test

* put TriggerSetup and TriggerRule into LowLevel.Trigger instead of unboxed Free

- suggested by @cocreature; thanks

* remove Time argument from trigger compatibility test

* submit commands as soon as each `emitCommands` is sequenced

- we still collect a list, but only for tracking commandsInFlight

* filter out compatibility tests for triggers before now

* remove commented imports, libraries from new shared converter

* make the TriggerF interpreter tail-recursive

* remove unused compatibility trait

* add back new state logging

* remove refactoring comment

* rewrite some LowLevel initialStates in do

* hide Daml.Script.Free from docs

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* remove forwardPortInitialState

- suggested by @cocreature; thanks

* manually port low-level updates

- suggested by @cocreature; thanks

* remove forwardPort

- suggested by @cocreature; thanks

* fail faster on unrecognized TriggerF

- suggested by @cocreature; thanks

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-10-02 14:18:13 -04:00
Moritz Kiefer
00b80b8ea3
Separate off-ledger ond on-ledger speedy (#7501)
* Separate off-ledger ond on-ledger speedy

changelog_begin
changelog_end

* Add OnLedgerBuiltin abstract class

changelog_begin
changelog_end

* fix typo

changelog_begin
changelog_end

* Fix borked rebase

changelog_begin
changelog_end

* Remove unscoped withOnLedger

changelog_begin
changelog_end
2020-09-29 10:05:45 +00:00
Bernhard Elsner
3ef1b21747
Add queryFilter to the export list (#7503)
CHANGELOG_BEGIN
CHANGELOG_END
2020-09-29 08:15:45 +00:00
Bernhard Elsner
331ee44978
Documentation of our support and compatibility framework (#7458)
* Documentation of our support and compatibility framework

CHANGELOG_BEGIN
CHANGELOG_END

* Update docs/source/daml-integration-kit/index.rst

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Update docs/source/support/component-statuses.rst

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Address feedback

* Update docs/source/support/compatibility.rst

Co-authored-by: Gerolf Seitz <gerolf.seitz@daml.com>

* Add Deprecations and address feedback

* Fix short title underline

* Apply suggestions from code review

Co-authored-by: Gerolf Seitz <gerolf.seitz@daml.com>

* Improve sentence on Integration Kit

* Imprive SemVer TLDR

* Uncapitalize release candidate

* Fix release timeline image

* Make the DAML Language Server CLI a Labs feature

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
Co-authored-by: Gerolf Seitz <gerolf.seitz@daml.com>
2020-09-24 14:40:57 +00:00
Moritz Kiefer
cd4a06db95
Move script tests to scalatest (#7445)
There isn’t really any good reason to insist on client_server_test
here so this PR replaces all of that by scalatest and a few test
fixtures which gives us better assertion failures, allows us to run
individual tests, ….

fixes #7356

changelog_begin
changelog_end
2020-09-22 16:59:12 +02:00
Remy
a899e5e4e6
Speedy: Check language version as part of Speedy compilation. (#7440)
Additionnally
+ move allowedLanguageVersion inside compiler config
+ add missing catch error insde
  ConcurrentCompiledPackages#addPackageInternal
+ implement EngineConfig method to easily produce a Compiler.Config

CHANGELOG_BEGIN
CHANGELOG_END
2020-09-22 12:43:48 +02:00
Remy
76ef4c861a
Speedy: group compiler parameters into a Config case class. (#7438)
* Speedy: group compiler parameters into a Config case class.

Speedy compiler is parametrized by several option flags.  Those flags
are passed through different calls (in particular in the instance of
`CompiledPackages`.

This PR group all this configuration parameters into a case class to
pass the option in a cleaner way.

CHANGELOG_BEGIN
CHANGELOG_END
2020-09-18 19:32:26 +02:00
Bernhard Elsner
1af817aba6
Add a queryFilter function to Daml.Script (#7367)
* Add a queryFor function to Daml.Script

`queryFor` combines `query` and filter. A very common pattern.

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-script/daml/Daml/Script.daml

CHANGELOG_BEGIN
CHANGELOG_END
2020-09-15 09:40:46 +00:00
Moritz Kiefer
f28c877584
Expose Script in data-dependencies (#7391)
Previously, it was filtered out by accident since damlc considered it
to be an old-style typeclass. This PR fixes this by adding a dummy
field.

This is primarily useful in DAML REPL since all DARs there are
importad as data-dependencies atm. It’s not actually all that useful
across SDK versions since you end up with multiple daml-script
libraries but at least within an SDK you can use it and don’t have to
think about whether your project is a dependency or data-dependency.

changelog_begin
changelog_end
2020-09-14 15:29:09 +02:00
Remy
23d5552807
DAML-script: drop ScriptLedgerClient.Command (#7378)
in favor of standard lf.command.Command.

This PR tries to decuple a bit more DAML-script to speedy.

CHANGELOG_BEGIN
CHANGELOG_END
2020-09-14 14:46:49 +02:00
Remy
c94f81db0f
DAML-script: fix complexity of script.Converter#toCommands (#7377)
imporve complexity from quadratic to linear

CHANGELOG_BEGIN
CHANGELOG_END
2020-09-14 09:34:44 +02:00
Remy
c9c5bcbfe0
DAML-script: limit usage of SParty (#7376)
This PR tries to decuple DAML-script to speedy.

CHANGELOG_BEGIN
CHANGELOG_END
2020-09-14 09:33:38 +02:00
Moritz Kiefer
84fe505a58
Add queryContractKey to DAML Script (#7354)
* Add queryContractKey to DAML Script

This matches the behavior and the implementation of
`queryContractId`. We only return contracts for stakeholders and we
return an `Optional` so you can handle lookup failures. On the JSON
API and in DAML Studio this is fairly efficient, over the gRPC API it
degrades to a linear search.

changelog_begin

- [DAML Script] Add `queryContractKey` to the DAML Script API.

changelog_end

* Update daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/LedgerInteraction.scala

Co-authored-by: Stephen Compall <stephen.compall@daml.com>

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2020-09-10 19:39:23 +02:00
Moritz Kiefer
c0b6851abe
Generate hoogle docs for daml script/triggers (#7371)
* Generate hoogle docs for daml script/triggers

This PR switches over the documentation generation for daml script and
daml triggers to the multi-page format we already use for the standard
library and extends it to also generate hoogle documentation.

All 3 hoogle files are combined in a single hoogle_db.tar.gz archive.

Since the location in the multi-page format is different, I’ve added
redirects.

I verified locally, that I can generate the hoogle database and that
the links point to the right places.

changelog_begin
changelog_end

* Fix baseurl for daml-stdlib

changelog_begin
changelog_end
2020-09-10 15:58:15 +02:00
Moritz Kiefer
5bee5a08df
Document ApplicativeDo restrictions (#7359)
fixes #7343

changelog_begin
changelog_end
2020-09-09 17:56:33 +02:00
Moritz Kiefer
d086738ac0
Migrate DAML Intro to DAML Script (#7264)
changelog_begin
changelog_end
2020-09-08 14:28:30 +02:00
Remy
fbeae8ae5e
LF: Use the new Struct data structure for SStruct (#7319)
This PR uses the new data structure introduced in #7220.

Additionally this fixes `svalue.Equality` and
`svalue.Ordering` which were considering <a: x, b: y>
different from <b:y, a:x>.

CHANGELOG_BEGIN
CHANGELOG_END
2020-09-04 22:04:07 +02:00
Samir Talwar
2b3cf1b3c0
ledger-api-client: Rename maxInboundMessageSize to maxInboundMetadataSize. (#7290)
* ledger-api-client: `maxInboundMessageSize` -> `maxInboundMetadataSize`.

CHANGELOG_BEGIN
- [Scala Bindings] Rename a field in the ``LedgerClientConfiguration``
  to ``maxInboundMetadataSize``, to match the builder Netty channel
  builder. It was incorrectly named ``maxInboundMessageSize``, which is
  a different channel property that configures the maximum message size,
  not the header size.
CHANGELOG_END

* ledger-api-client: Introduce a `maxInboundMessageSize` config property.

We use this a lot; easier if it's in the configuration.

CHANGELOG_BEGIN
- [Scala Bindings] Replace the
  ``LedgerClientConfiguration.maxInboundMessageSize`` property with a
  new one that represents the maximum size of the response body.
CHANGELOG_END
2020-09-02 08:41:34 +00:00
Moritz Kiefer
4460cb5e08
Fix trace statement handling in DAML Script service (#7292)
* Fix trace statement handling in DAML Script service

This PR makes sure that we get both trace statements coming from the
ledger client as well as from the ledger server. In the script service
those are two different Speedy machines so we need to interleave
them. This is a bit messy so let me explain the steps (apologies for
not splitting it up but I think it’s easier to understand the
motivation when it is a single PR):

1. Abstract over the tracelog interface. The ringbuffer doesn’t makes
   sense for our purposes and is annoying to clear.

2. Pass in the respective fields of `Machine` to `Conversions` instead
   of the whole machine. This is both a simpler design (passing around
   mutable objects scares me) and it allows us to assemble the fields
   from different machines.

3. Initialize the ledger machine with a simple ArrayBuffer tracelog.

4. After `submit` and `submitMustFail` copy the tracelog from the
   ledger to the client.

fixes #7280

changelog_begin
changelog_end

* Address review feedback

changelog_begin
changelog_end
2020-09-01 17:15:48 +00:00
Moritz Kiefer
09a1b445df
Only include stakeholder contracts in result of query (#7291)
* Only include stakeholder contracts in result of query

This fixes a bug in the script service. We need to filter out divulged
contracts since this should behave exactly like the ACS endpoint on
the ledger API.

changelog_begin
changelog_end

* Update daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/scenario/ScenarioLedger.scala

Co-authored-by: Remy <remy.haemmerle@daml.com>

* Update daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/LedgerInteraction.scala

Co-authored-by: Remy <remy.haemmerle@daml.com>

* fmt

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2020-09-01 10:34:11 +00:00
Moritz Kiefer
f8a82ad25f
Add queryContractId to DAML Script (#7289)
* Add queryContractId to DAML Script

I’ve switched between a few different naming options and in the end
settled on this one:

- `lookupContract`, not too bad but misses the connection to `query`
- `queryCid`, we don’t abbreviate this in other places in our API so I
  don’t think we should here.
- `queryContractId`, makes the connection clear and no
  abbreviation. We could also add `queryContractKey` later

changelog_begin

- [DAML Script] Add a `queryContractId` function for querying for a
  contract with the given identifier.

changelog_end

* Fix test

changelog_begin
changelog_end
2020-09-01 10:31:34 +00:00
Remy
fdb69455d4
DAML-SCRIPT: minor cleanup of Struct usage in Converter (#7287)
* DAML-SCRIPT: minor cleanup of Struct usage in Converter

CHANGELOG_BEGIN
CHANGELOG_END
2020-09-01 11:57:40 +02:00
Moritz Kiefer
1eefb4b27d
Fix partial tx and commit locs in the script service (#7281)
It turns out we were too aggressive in resetting the state. We only
want to reset in `submit` on successful commit and in `submitMustFail`
on failed commits. I’ve also split the reset in two parts, one that is
done at the beginning every time and one at the end. I don’t think it
really makes a difference but it matches what the scenario runner does
which at least makes me stop wondering if the difference matters.

fixes #7275 fixes #7276

changelog_begin
changelog_end
2020-08-31 18:00:20 +02:00
Moritz Kiefer
b1530bed7a
Add passTime to DAML Script (#7269)
I’ve also removed the restriction to only support going forward since
scenarios don’t have that restriction and it seems potentially useful
for tests.

factored out from #7264

changelog_begin

- [DAML Script] Add `passTime` helper to advance the time by the
  given interval.

- [DAML Script] In DAML Studio, you can now set the time to the
  past. This is not supported when running against a ledger.

changelog_end
2020-08-31 13:25:09 +02:00
Moritz Kiefer
11a477244a
Add a script helper to DAML Script (#7272)
Factored out from #7264

We have enough cases of scenarios that don’t actually do ledger
operations and need some hint for type inference. While adding type
annotations works, this is a bit easier at least for the migration and
some people might prefer it.

No test, since this seems a bit excessive here :)

changelog_begin

- [DAML Script] Add a `script` function to aid type inference. This
  is the equivalent of `scenario`.

changelog_end
2020-08-31 13:24:58 +02:00
Moritz Kiefer
6743bf5b9b
Add archiveCmd to DAML Script (#7268)
Factored out from #7264 and added a test. Just makes the migration a
tiny bit easier.

changelog_begin

- [DAML Script] Add `archiveCmd cid` as a convenience wrapper around
`exerciseCmd cid Archive`.

changelog_end
2020-08-31 13:24:48 +02:00
Andreas Herrmann
d937a5ebad
Track source locations on Daml.Script.submit (#7252)
* Track source locations on Daml.Script.submit

Adds a `HasCallStack` constraint on `HasSubmit.submit` and
`HasSubmit.submitMustfail`.

We need to move the definition of `HasCallStack` to `GHC.Stack.Types` to
avoid a cyclic dependency between `DA.Stack` and `DA.Internal.LF`.
Alternatively, we could inline `HasCallStack` in `DA.Internal.LF` but it
seems preferable to use the alias on the signature of
`submit(MustFail)`.

We need to adapt the type of the builtins for scenario `submit` and
`submitMustfail`.

changelog_begin
changelog_end

* Test-case for scenario/script source locations

* Test second commit with intermediate definition

Addressing review comment
https://github.com/digital-asset/daml/pull/7252/files#r478518834

* Store the full callstack on submit

For forwards compatibility.

Addressing review comment
https://github.com/digital-asset/daml/pull/7252/files#r478520268

* Document unused location definition

Addressing review commit
https://github.com/digital-asset/daml/pull/7252/files#r478522373

* Make user facing `SrcLoc` zero based

Following LSP precedent rather than GHC

Addressing review comment
https://github.com/digital-asset/daml/pull/7252/files#r478529138

* Add comment for backwards compatibility code

Addressing review comment
https://github.com/digital-asset/daml/pull/7252/files#r478529138

* fmt

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-08-28 12:22:15 +00:00
Leonid Shlyapnikov
1452076eee
Deprecating noop '--application-id' command-line option in JSON API (#7232)
* Deprecate noop `--application-id`

changelog_begin

[JSON API]
Hiding and deprecating `--application-id` command-line option. JSON API never used it.
It is required to instantiate LedgerClientConfiguration and was not used for any command submission.
JSON API uses Application ID specified in the JWT. See #7162

changelog_end

* removing further usage of noop applicationId

* a bit of explanation what this is for
2020-08-26 20:05:00 +00:00
Remy
4e265f0c1c
Speedy: Make the fields 'fields' from SStruct immutable. (#7227)
Change the type of SStruct.fields from Array to ImmArray.

CHANGELOG_BEGIN
CHANGELOG_END
2020-08-25 18:03:33 +02:00
Remy
89770cf1c1
Speedy: make the field names from SRecord immutable. (#7225)
CHANGELOG_BEGIN
CHANGELOG_END
2020-08-25 17:02:27 +02:00