Commit Graph

57 Commits

Author SHA1 Message Date
Moritz Kiefer
c34f56ab2e
Add template id filtering to triggers (#3577)
* Add template id filtering to triggers

CHANGELOG_BEGIN
- [Daml Triggers - Experimental] DAML triggers now allow you to specify which templates you want to listen for which can improve performance.
CHANGELOG_END

* Address review comments

* Fix list-triggers test
2019-11-21 16:50:40 +01:00
Moritz Kiefer
c3438a58af
Refactor trigger runner in preparation for template id filtering (#3570)
This is a prepatory PR before introducing template id filtering in
DAML triggers. It does not change or introduce any new functionality.
2019-11-21 14:08:11 +01:00
Moritz Kiefer
6d2ed90f29 Remove target flags in DAML triggers and DAML script (#3545)
1.7 is now the default so we no longer need those.
2019-11-20 10:54:16 +00:00
Moritz Kiefer
1bc4bb76a4 Make AnyChoice and AnyContractKey take template type into account (#3541)
* Make AnyChoice and AnyContractKey take template type into account

fixes #3540

* Update template desugaring

* Switch to proper ghc-lib release
2019-11-20 10:40:14 +00:00
Moritz Kiefer
5458053ea9 Add pending set to DAML triggers (#3502)
fixes #3360
2019-11-18 14:25:40 +00:00
Andreas Herrmann
712bc456ba Map CommandIds in MTransaction (#3501)
* Regression test for #3485

* Respect CommandId mapping for transactions

* triggers: Fix ExerciseByKey

Make choice nonconsuming, so that no second `T` is created later.
Only execute `dedupExerciseByKey` if `T_` doesn't exist, yet.

* Update list-triggers test

* triggers: Empty commandId on foreign TransactionM

95ccc59b45 (r347287514)
2019-11-18 14:34:48 +01:00
Moritz Kiefer
4eb72d496e
Fix conversion from Ledger API to Speedy in DAML triggers (#3458)
Previously, we use SValue.fromValue for the conversion. However, this
breaks in cases like Numeric where the scale information is lost. By
using the ValueTranslator instead, we avoid this issue.

There is a similar problem in DAML script but I’ll fix that in a
separate PR.

Since the ValueTranslator is package private, this PR moves the
triggers in the engine package.
2019-11-14 09:26:36 +01:00
Moritz Kiefer
3fdc9f280c Clean trigger tracelog after each step (#3445)
Previously, we ended up accumulating trace messages which obviously is
not what you want. This PR changes this to replace the tracelog by a
new, empty TraceLog (if there actually was something to trace) and
thereby fixes this issue.

I don’t really want to start adding tests for logging output so for
now this doesn’t have a manual test but if this starts becoming a
problem again, we probably want to add a separate output source to the
trigger runner instead of going via the logger so we can test this easily.
2019-11-13 10:13:41 +00:00
Moritz Kiefer
45d2b7048c
[daml-triggers] Rename getTemplates to getContracts (#3430)
Given that this returns the contracts of a given template rather than
returning templates, this name makes a lot more sense.
2019-11-12 14:48:24 +01:00
Moritz Kiefer
11044f3683 Add exerciseByKey to DAML triggers (#3413)
fixes #3317
2019-11-11 18:12:25 +00:00
Moritz Kiefer
7db11ca427 Add toAnyContractKey and fromAnyContractKey (#3408)
* Add toAnyContractKey and fromAnyContractKey

This is necessary to add exerciseByKey to DAML triggers.

* Switch to proper ghc-lib release

* Remove unnecessary filter

* Bump timeout because macos is terrible

* bazel fmt
2019-11-11 17:35:53 +00:00
Moritz Kiefer
c57a31d630
Compile DAML trigger library with --target 1.7 (#3372) 2019-11-07 12:08:44 +01:00
Jussi Mäki
ca7bbacd6c Build rules for producing and verifying ledger dumps (#3290)
* Add client_server_build and integrity_test rules

And use them to implement ledger dump of the reference
server and to check it.

* Only build and test ledger dump on Linux. Only run tests relevant to dump.

* Make client_server_build quiet in happy path

* Reformat

* Remove unnecessary runfiles for client_server_build
2019-11-07 09:41:54 +00:00
Andreas Herrmann
6bbc6157d5 trigger.Converter avoid exceptions (#3341)
* trigger.Converter avoid exceptions

Refactor `com.daml.trigger.Converter` to consistently use
`Either[String, _]` instead of throwing exceptions to handle conversion
errors.

* Throw ConverterError on conversion error
2019-11-06 10:52:27 +00:00
Moritz Kiefer
90679c93f8
Use regular ContractIds in DAML triggers (#3337)
The only reason for having AbsoluteContractId was that we could get
some more instances in particular `Ord` and `MapKey` but given that
`ContractId` will be a valid key type for the new DAML-LF maps, we can
just use slower implementations for now and switch to Map-based
implementations once that has landed.

fixes #3336
2019-11-05 15:15:07 +01:00
Remy
7c427119e1 DAML-LF add Type Representation value (#3326)
* daml-lf: update spec with type-rep

* daml-lf: update proto with type-rep

* daml-lf: update scala side with TypeRep

* daml-lf: update compiler side with TypeRep

* Get triggers to compile

* Add featureTypeRep to allFeatures

* Apply suggestions from code review

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* daml-lf: add builtin for TypeRep equality

* Address Andrea's comments

* formatting

* Fix triggers

* Fix template typerep tests
2019-11-04 17:00:55 +00:00
Moritz Kiefer
e7280f96b3 Add dedupCreate/dedupExercise helpers to the DAML trigger API (#3280)
Given how common this is, it seems worthwile to add helpers for this.
2019-10-29 18:06:43 +00:00
Moritz Kiefer
e70bb007be Add a command to list the triggers in a DAR (#3268)
For now, this uses a somewhat adhoc format with one trigger identifier
per line but given that I expect that it won’t be particularly common
to want to do this mechanically this should be sufficient and it’s
trivial to parse.
2019-10-28 22:34:19 +00:00
Moritz Kiefer
3cd5cfc1d7 Include daml-docs for daml-trigger in the documentation (#3263)
* Include daml-docs for daml-trigger in the documentation

* Fix link to trigger docs
2019-10-28 19:30:23 +00:00
Moritz Kiefer
d2e209aeb9 Cleanup internals of high-level trigger API (#3265)
This is in preparation for adding helpers for command
deduplication. There are no public API changes in this PR.
2019-10-28 19:20:35 +00:00
Moritz Kiefer
380c2cc494 Warn on trigger package id mismatch (#3258)
This is fairly easy to run into so it makes sense to warn about
this. Given that I expect the trigger library will be reasonably
stable in the near future, this is only a warning rather than an
error.

fixes #3244
2019-10-28 15:14:54 +00:00
Andreas Herrmann
2bd1db490a
Replace bazel-deps by rules_jvm_external (#3253)
* Update bazel-common to fix javadoc issues

Specifically, to fix the following error

```
ERROR: /home/aj/tweag.io/da/da-bazel-1.1/ledger-api/rs-grpc-bridge/BUILD.bazel:7:1: in javadoc_library rule //ledger-api/rs-grpc-bridge:rs-grpc-bridge_javadoc:
Traceback (most recent call last):
        File "/home/aj/tweag.io/da/da-bazel-1.1/ledger-api/rs-grpc-bridge/BUILD.bazel", line 7
                javadoc_library(name = 'rs-grpc-bridge_javadoc')
        File "/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/com_github_google_bazel_common/tools/javadoc/javadoc.bzl", line 27, in _javadoc_library
                dep.java.transitive_deps
object of type 'JavaSkylarkApiProvider' has no field 'transitive_deps'
```

* Define Maven deps using rules_jvm_external

* Pin artifacts

* Remove bazel-deps generated targets

* Remove bazel-deps

* Switch to rules_jvm_external targets

* update bazel documentation

* pom_file: There are no more bazel-deps targets

* BAZEL-JVM.md `maven_install` typo
2019-10-28 13:53:14 +01:00
Andreas Herrmann
dc2f10ebe6 Use TemplateTypeRep in DAML Trigger API (#3245)
* Add TemplateTypeRep to AnyContractId

* Define Trigger.ContractId t

* Use Trigger.ContractId t

* Implement fromCreated and fromArchived

* instance MapKey TemplateTypeRep

* More efficient ACS access using Map TemplateTypeRep

* ./fmt.sh

* toString and fromString for Identifier

* Replace Identifier by TemplateTypeRep

* TheContractId --> AbsoluteContractId

https://github.com/digital-asset/daml/pull/3245#discussion_r338033546
2019-10-23 13:56:59 +00:00
Moritz Kiefer
6c36777a8e
Release DAML trigger runner to Bintray (#3243)
This should make it a bit easier to use in a managed environment and
has been requested by some users.
2019-10-21 18:14:46 -04:00
Andreas Herrmann
b0bd8328ea
Detect high level trigger (#3239)
* capture high-level module in converter

* Factor out trigger discovery

* Support running high-level triggers directly

* Don't convert to low-level trigger in Retry

* ./fmt.sh

* Update CopyTrigger, docs, and changelog
2019-10-21 14:22:08 +02:00
Moritz Kiefer
f2618ec85b Run DAML trigger rule on failed completions (#3226)
fixes #3214
2019-10-18 13:04:31 +00:00
Moritz Kiefer
e31526c35c Use the same CopyTrigger in the docs and the tests (#3213)
* Use the same CopyTrigger in the docs and the tests

That way, we actually test what we use in our docs which seem like a
much better idea than duplicating the code.

* Add debugging output on failures
2019-10-17 12:52:15 +00:00
Moritz Kiefer
6d3ae219d1 Improve logging and debugging of DAML triggers (#3210)
- We now display `trace` messages so they can be used for debugging.
- I’ve removed the log message from the low-level API since it is
  confusing as it is not exposed via the high-level API and somewhat
  redundant since you can use `trace` for debugging. If there is a
  demand for proper logging support we might want to add it back at
  some point.
- We now display errors from speedy properly. This is mainly important
  for calls to `error` since we previously lost the error message.
- Logging messages go through a proper logging library now and the
  internal debugging stuff is only displayed at debug level so not by default.
- We log failed completions at warning level to ease debugging.
2019-10-17 10:21:56 +00:00
Moritz Kiefer
155b2ea5d1
Disable debug logging messages from netty in the trigger runner (#3202)
This makes the output significantly less noisy.
2019-10-16 17:31:10 +02:00
Moritz Kiefer
87427ba334
Fix a race condition in the DAML trigger tests (#3199)
Previously, it could happen that the command flow used in the test was
started before the trigger queried the ACS on startup.

Now we wait for the ACS to be queried before starting the commands
flow which fixes this issue.
2019-10-16 16:51:06 +02:00
Moritz Kiefer
155302a247 [daml-triggers] Support wallclock time and make TTL configurable (#3186)
* [daml-triggers] Support wallclock time and make TTL configurable

fixes #3184

* Remove duplicate wall clock option
2019-10-15 15:43:55 +00:00
Moritz Kiefer
dbddead461
Add a first draft of documentation for DAML triggers (#3181)
* Add a first draft of documentation for DAML triggers

The API will still change in a bunch of ways but I’d rather get some
docs in place now and update them as we change things than not have
any docs at all.

* Fix path to daml.yaml

* s/bot/trigger/

* fix source code markers

* Fix tests

* Update docs/source/triggers/index.rst

Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2019-10-15 16:50:43 +02:00
Remy
e45b585307 daml-lf: repackage daml-lf archive proto (daml_lf -> daml_lf_dev) (#3169) 2019-10-15 09:36:11 +00:00
Remy
d64df4b5f7 daml-lf: clean achive bazel build (#3175)
* clean the mess in daml-lf achive bazel build

* add release note

* Address Moritz's comments

* more release notes
2019-10-15 08:36:46 +00:00
Remy
fc1a000090 daml-lf: rename daml_lf_archive_scala target to daml_lf_archive_reader (#3168)
* daml-lf: rename daml_lf_archive_scala target to daml_lf_archive_reader

* fix release
2019-10-14 14:53:50 +00:00
Moritz Kiefer
1da742ec60 Use UUIDs for command ids emitted from DAML triggers (#3170)
fixes #3130
2019-10-14 14:49:01 +00:00
Moritz Kiefer
b6e9e5ccea
Replace LedgerValue by AnyChoice in DAML triggers (#3162)
This means that we no longer rely on the fact that Speedy
accepts type errors which makes me very sad :(
2019-10-11 18:30:51 +02:00
Moritz Kiefer
48eb360a4f Add AnyChoice type to DAML (#3152)
* Add AnyChoice type to DAML

fixes #3131

* Fix ProposalDesugared

* Fix trigger tests

* Use the proper ghc-lib urls
2019-10-10 16:46:55 +00:00
Moritz Kiefer
dcdcf7f0c0
Generalize AnyTemplate type to Any in DAML-LF (#3141)
* Generalize AnyTemplate type to Any in DAML-LF

See #3131 for the motivation for this. The tl;dr is that we need
something like AnyTemplate for choice types as well.

Since the protobuf was already more general in anticipation of such a
change, this change only changes the internal AST on the Haskell and
Scala side.

Since AnyTemplate change has never made it out of 1.dev, I updated the
changelog in the LF spec instead of adding a new entry.

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>

* windows debugging

* more windows debugging

* clean expunge

* don’t cat the config file

* remove comment on type equality

* windows …

* gnah

* foobar

* foobar

* does anything ever work?

* reenable caching

* Do not build daml-lf-ast separately
2019-10-10 08:51:52 +02:00
Moritz Kiefer
3b1d8dfe33 Remove custom State monad from daml-trigger (#3136) 2019-10-09 07:42:48 +00:00
Moritz Kiefer
d500d9967a
Allow emitting commands on trigger initialization (#3132)
fixes #3128

Also includes a small bug fix to reenable some tests that I
accidentally disabled in #3127 and fixes deserialization of command
ids in completions which I accidentaly broke when making fromCommandId
return an Optional since that’s what we need for transactions.
2019-10-09 09:24:34 +02:00
Moritz Kiefer
bf04fe1be9
First draft of a high-level API for DAML triggers (#3127)
This PR adds a first draft of a high-level API for DAML
triggers. There is definitely more work to be done and the design is
absolutely not final. However it already allows expressing the copy
bot fairly cleanly so I would like to merge this in its current
state (or at least without bikeshedding the design too much) and then
iterate upon it.
2019-10-08 15:34:14 +02:00
Moritz Kiefer
e51e27fe27
Make the DAML trigger tests more generic (#3096)
This is a first step towards making our tests more generic so we can
add more easily tests different triggers.
2019-10-04 10:59:02 +02:00
Moritz Kiefer
a7eec73f38
Split trigger runner into multiple files (#3088)
Having everything in a single file has gotten a bit unwieldly so this
PR splits it up. There is no change in the actual code, this is just a reshuffling.
2019-10-02 18:26:13 +02:00
Moritz Kiefer
8743dbbda7
Use newtypes for id types in DAML triggers (#3082)
This makes the API a bit safer and nicer to use. Since this is a
low-level API the constructors are exposed, for the high-level API we
probably want to hide them.
2019-10-02 16:57:20 +02:00
Moritz Kiefer
a96f219f47 Share akka logic between DAML trigger main and tests (#3084) 2019-10-02 13:29:33 +00:00
Moritz Kiefer
7e7f35216f
Remove flaky=True from trigger tests (#3079)
I’ve run them a 100 times locally and haven’t been able to get them to
fail so it looks like the issue has been fixed since.

fixes #2881
2019-10-01 17:21:16 +02:00
Moritz Kiefer
a7fbad153c
Expose completions in daml triggers (#3077) 2019-10-01 15:28:59 +02:00
Andreas Herrmann
98bb580aa2 Bundle packages with SDK releases (#3056)
* Enable SDK daml-lib package dependencies

* integration-test: SDK daml-libs dependency

* trigger --> daml-trigger

Rename the trigger library package to match other builtin packages.

* Bundle daml-trigger.dar in SDK release tarball

* Describe SDK bundled packages in changelog

* Push case match inside expand

Addressing review comment
8208277747 (r329428240)
2019-09-30 09:15:11 +00:00
Moritz Kiefer
11c686b255
Support emitting multiple transations from DAML triggers (#3049)
fixes #3047
2019-09-30 08:46:08 +02:00