Commit Graph

4881 Commits

Author SHA1 Message Date
Moritz Kiefer
c6ce05e3a2
Upgrade jpeg-js to address security vulnerabilities (#6949)
Tested locally that Navigator still works.

changelog_begin
changelog_end
2020-08-03 15:51:05 +02:00
Remy
5cae5b43ce
DAML-LF: fix minor typos in LF spec (#6963)
CHANGELOG_BEGIN
CHANGELOG_END
2020-08-03 15:07:57 +02:00
Samir Talwar
6bb034c053
daml-on-sql: Extend the README with information about architecture and system dependencies. (#6961)
* daml-on-sql: Fix references to the JAR file in the README.

* daml-on-sql: Add README info about architecture, OS, and dependencies.

* daml-on-sql: Make README headings consistent in style.

* daml-on-sql: Explain the `--ledgerid` flag in the README.

* daml-on-sql: Everything is important.

* daml-on-sql: Document parameters used to tune performance.

CHANGELOG_BEGIN
- [DAML on SQL] Document the architecture and OS we test against, native
  system dependencies on Linux, and parameters for performance tuning.
CHANGELOG_END

* daml-on-sql: Document architecture requirements.
2020-08-03 12:59:54 +00:00
Sofia Faro
262220a501
Add 'unknown contract' cases in LF spec. (#6955)
* Add 'unknown contract' cases in LF spec.

changelog_begin
changelog_end

* Fix duplicate Err t

* remove indices
2020-08-03 12:54:57 +01:00
Martin Huschenbett
de3f593399
FrontStack: Ensure that claimed invariant is maintained (#6960)
* FrontStack: Ensure that claimed invariant is maintained

The documentation of `FrontStack` claims that the head of the
`FQPrepend` is never empty but there's a way to violate this claimed
invariant.

This PR makes sure the invariant is maintained and then uses the
invariant to remove a redundant `else`-branch.

CHANGELOG_BEGIN
CHANGELOG_END

* Remove initials from NOTE

CHANGELOG_BEGIN
CHANGELOG_END
2020-08-03 11:39:04 +00:00
Martin Huschenbett
6a678c5733
Add evaluation order tests for foldl and foldr (#6958)
* Add evaluation order tests for foldl and foldr

I'd like to have a play with the implementation of `foldl` and `foldr`
in Speedy in order to improve their performance. Doing so without any
tests for the evaluation order of those builtins, is too scary for me.
Thus, let's kick off the effort by adding some tests.

Except for the usual case where we need to test that we're running over
the list in the right order, we also need to test for the case where
the step function only consumes one argument and the case where the
accumulator is a function. In the latter case we need to make sure we
don't evaluate the argument applied to the final accumulator too early.

We're also very short on the semantics of `foldl` and `foldr` in the
DAML-LF spec but I leave that for another PR.

CHANGELOG_BEGIN
CHANGELOG_END

* Fix copy/paste error

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

* Minor fixes

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2020-08-03 11:13:50 +00:00
Gary Verhaegen
e4482767af
fix release job (#6959)
This failed on [the master build for the latest release][0] (trigger commit
08d4bb0a21), fortunately after everything
was done so the only consequence is a red tick in the commit list.

[0]: https://dev.azure.com/digitalasset/daml/_build/results?buildId=50840&view=logs&jobId=8d802004-fbbb-5f17-b73e-f23de0c1dec8&j=8d802004-fbbb-5f17-b73e-f23de0c1dec8&t=3f4756f8-86d7-526f-1a17-d1c7745ae68d

CHANGELOG_BEGIN
CHANGELOG_END
2020-08-03 12:35:51 +02:00
Gary Verhaegen
314064d5bf
fix docs typo (#6957)
CHANGELOG_BEGIN
CHANGELOG_END
2020-08-03 10:06:43 +00:00
Martin Huschenbett
d95b867a0f
DAML Engine: Speed up updates of multiple fields in a record (#6937)
* DAML Engine: Speed up updates of multiple fields in a record

Currently, updating multiple fields of a single record is not very
efficient. If you update, say, `n` fields, as in
```haskell
  r with f_1 = ...; ...; f_n = ...
```
`n-1` intermediate records are created and almost immediately
discarded. Each creation of an intermediate record involves shallowly
cloning an array of size `m`, where `m` is the number of fields of the
record type. This does not only cost computation time but also a lot of
avoidable memory allocations. Overall, the cost of such an update is
`O(m*n)` in terms of time and memory.

This PR changes the DAML-LF interpreter such that multiple updates of
the same record are batched together. This avoids the creating of any
intermediate records but only creates the final record resulting from
the updates. This reduces the time complexity to `O(m+n)` and the
memory complexity to `O(m)`.

The code path for updating a single record field remains unchanged
(for now) and hence won't suffer from the additional complexity that
is required for the batching described above.

I've benchmarked this change by creating a single record with `m`
fields and updating all `m` fields in one single update expression,
for `m = 10` and `m = 20`. In both cases, the benchmarks showed a
speedup of ca. 2.5x.

This is part of #5766.

CHANGELOG_BEGIN
- [DAML Engine] Record update expressions of the form
  `R with f_1 = E_1; ...; f_n = E_n` are now run as batch updates
  in order to improve runtime performance and avoid unneccesary
  memory allocations.
CHANGELOG_END

* Apply suggestions from code review

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2020-08-03 09:00:24 +00:00
Moritz Kiefer
5ceeb476c8
Remove duplicated tls config parsing from DAML Script/Triggers (#6947)
This was not only unnecessarily duplicated, it also had a bug where
`--crt` behaved like `--pem` instead of setting the cert chain.

I didn’t add new tests since it seems like the wrong place to test
config parsing of a library. We do have tests for TLS in general for
both DAML Script and DAML Triggers.

changelog_begin
changelog_end
2020-07-31 18:25:18 +02:00
Stephen Compall
3a0a3228ec
fix null pointer in PortLock#lock (#6941)
java.lang.NullPointerException:
  at com.daml.ports.PortLock$Locked.unlock(PortLock.scala:55)
  at com.daml.ports.PortLock$.lock(PortLock.scala:41)
  at com.daml.ports.LockedFreePort$.find(LockedFreePort.scala:15)
  at com.daml.lf.engine.trigger.TriggerServiceFixture$.$anonfun$withTriggerService$1(TriggerServiceFixture.scala:65)

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-31 10:59:39 -04:00
Stefano Baghino
e972872128
Properly use LoggingContext in Participant Server (#6924)
* Properly use LoggingContext in Participant Server

Fixes #6837

Spreads usage of LoggingContext and ContextualizedLogger throughout the participant server.

changelog_begin
[Sandbox/Integration Kit] We have enriched the contextual information
exposed by the Ledger API server. You should note richer logging information,
which can be read either via unstructured or structured logging frameworks.
A paragraph on how to configure structured logging has been added to the docs.
For more on the issue, see https://github.com/digital-asset/daml/issues/6837.
changelog_end

* Make everything compile

* Leave only actual commands on trace level on submission

* Shorter log messages on submission

* Don't add values down the call stack

* Document good practices regarding the logging context

* Add context to write service implementations

* Add logging context to tests

* Document logging for DAML on SQL

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463503013

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463508117

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463515665

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463513157

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463516359

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463516895

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463518813

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463520210

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463521501

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463521593

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463525453

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463525560

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463525672

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463525742

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463526837

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463527054

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463527523

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463527814

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463527958

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463527900

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463527997

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463528050

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463542877

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463543051

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463543614

* Address https://github.com/digital-asset/daml/pull/6924#discussion_r463543692
2020-07-31 12:40:13 +00:00
Rohan Jacob-Rao
e6cf6d0d51
Trigger service tests: sequence toxiproxy setup before starting sandbox (#6939)
This should avoid potential contention for ports.

changelog_begin
changelog_end
2020-07-30 15:32:46 -04:00
Leonid Shlyapnikov
05d49b37c3
Introduce //libs-scala/scala-utils (#6935)
* Moving `Statements.discard` from //ledger-server/http-json into //libs-scala/scala-utils

changelog_begin
changelog_end

* Add new module to the published artifacts

* `com.daml.scalautil` instead of `com.daml.scala.util`

@S11001001: That's because if this is in classpath and you import com.daml._,
you have a different scala in scope than the one you expect.
2020-07-30 13:51:07 -04:00
Moritz Kiefer
83031f3edf
Mark contract lookups as private[lf] (#6938)
DAML Script is in lf so that is good enough and nothing else should
access this.

changelog_begin
changelog_end
2020-07-30 17:28:23 +00:00
Moritz Kiefer
13add95a5e
Expose lookupContract and lookupKey methods from ScenarioRunner (#6931)
This is a spinoff from IDE support for DAML Script #6929. There I need
cannot quite use `run` from ScenarioRunner since I need to handle
results differently but I don’t want to replicate all the visibility
and authorization logic from `lookupContract` and `lookupKey`.

changelog_begin
changelog_end
2020-07-30 18:15:48 +02:00
Andreas Herrmann
8e706a9bde
Remove vendored pkg_tar (#6934)
* Use Bazel builtin pkg_tar rule

* Use @rules_pkg//:pkg.bzl%pkg_tar

The pkg_tar rule builtin to Bazel has been deprecated.
See https://docs.bazel.build/versions/master/be/pkg.html

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-07-30 15:53:16 +00:00
Martin Huschenbett
3c1e8c7748
daml-lf/parser: Add the ability to parse location annotations (#6932)
* daml-lf/parser: Add the ability to parse location annotations

Currently, the DAML-LF parser we use for testing in Scala land does not
understand location information and has in particular no way to produce
`ELocation` AST nodes. Having these nodes will be important in a test
for a feature I'm currently working on in order to demonstrate that my
Speedy AST transformation can actually look through location
information properly.

This PR adds a rule to the parser to allow for parsing location
information and producing `ELocation` nodes.

CHANGELOG_BEGIN
CHANGELOG_END

* Address Nick's feedback

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-30 15:29:00 +00:00
Sofia Faro
3b08440fe7
Strip ELocation nodes in simplifier rules. (#6930)
* Strip ELocation nodes in simplifier rules.

Uses stripLoc in the patterns used by the simplifier. This change
reduces the size of the generated code by 1.5% for a very large project,
meaning we had rules (like `let x = e in x`) that weren't trigerring
because of the `ELocation` nodes that weren't being properly ignored.

changelog_begin
changelog_end

* More stripLoc
2020-07-30 14:37:35 +00:00
Rohan Jacob-Rao
91b174da91
Trigger service tests: Remove auth service process in trigger service fixture (#6928)
This code has a few problems: the auth service test mode is not enabled, the
admin ledger should be separate from main ledger if auth is enabled, and the
retry strategy not executed.

The auth service is not used in these tests yet and we have an example
of how to do it correctly in the auth service fixture (and auth service
client tests). We can try to reuse that fixture instead or copy the
code over when necessary.

changelog_begin
changelog_end
2020-07-29 23:29:04 +00:00
Rohan Jacob-Rao
4c76cf98ee
Trigger service tests: Make sure toxiproxy server is running before connecting the client (#6927)
* Trigger service tests: Make sure toxiproxy server is running before connecting client

changelog_begin
changelog_end

* Undo infuriatingly wrong camel case
2020-07-29 23:00:43 +00:00
Stephen Compall
39b6e47a7e
use row ID arithmetic for transaction stream pagination (#6658)
* event_sequential_id arithmetic

* add minPageSize fetch size to fallbacks

* use row_id arithmetic for single-party and multi-party tree queries, wildcard templates

  - as a fallback, try to grab 10 or (pageSize / 10) rows with LIMIT,
    whichever is larger

* add sequences of arnorm queries with parsed results

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END

* remove an extra LIMIT

* reformat SQL statements

* add newlines to other tx tree queries

* group by does nothing with this order by setting

* reformat all queries in EventsTableFlatEventsRangeQueries

* group by doesn't matter when you have order by and no aggregate exprs

* factor out the "faster read, then safer read" pattern from tree events

* make flat events all return SqlSequence with embedded parser

- with a path for EventsRange.readPage

* make flat transactions singleWildcardParty use arithmetic and fallback

* rename Fast to ByArith, Slow to ByLimit, because speed may vary

* missed Fast/Slow

* replace the other flat transaction queries with limited versions

replace

(?s)^      SQL"""(.*?)(\$\{range.endInclusive\})(.*?) limit \$pageSize"""

with

      FrqK.ByArith(\n        fasterRead = guessedPageEnd => SQL"""\n            $1\$guessedPageEnd$3""",\n        saferRead = minPageSize => SQL"""\n            $1$2$3 limit \$minPageSize"""\n      )

which is obviously better than being able to factor common parts of SQL
queries, so naturally I agree with anorm lacking a doobie-like append.

* remove readUpperBound, stray merge conflict inclusion

- thanks @leo-da for pointing it out

* rename SqlSequence.Elt to SqlSequence.Element

- suggested by @stefanobaghino-da; thanks

* rename FrqK to QueryParts

- suggested by @stefanobaghino-da; thanks

* reformat flatMap chain

* don't rescan first page; eliminate duplicate SQL exprs

- overload 'range' to mean "first page" then "search space after first page"
- page sizes are always safe to interpolate directly into SQL, as ints

(?s)^        fasterRead = guessedPageEnd => (.*?)\$guessedPageEnd(.*?)""",\n        saferRead = minPageSize => SQL""".*?"""

        read = (range, limitExpr) => $1\${range.endInclusive}$2 #\$limitExpr"""

* FilterRelation is used in a private[dao] context

- you won't get a warning for this because aliases are expanded before
  this is checked, so the method can still be called, you simply can't
  use the same type name used in the written signature

* generated sequences of transactions with different matching frequencies

- different occurrences of the matched transactions cause different SQL
  queries to be used, so we try to exercise all of them

* generalize storeSync's traverse to let multiple tests run in order

- thanks to @leo-da for the inspiration

* a way for singleCreates to be slightly different

* test that matched transaction count and the specific offsets match

* test more code paths for flat events
2020-07-29 15:06:06 +00:00
Moritz Kiefer
e42b16dcfd
Fix example in the trigger docs. (#6919)
The docs talked about `emitCommands` while the code talked about
`dedupExercise`. I’m increasingly leaning towards recommending
`emitCommands` for everything so I’ve switched the code instead of the
docs.

changelog_begin
changelog_end
2020-07-29 15:02:57 +00:00
Samir Talwar
99463577af
triggers + ports: Lock free ports before binding. (#6911)
* triggers: Use `FreePort.find()`.

* ports: Move `LockedFreePort` from postgresql-testing for reuse.

* triggers: Use `LockedFreePort` to avoid race conditions.

* ports + triggers: Move common port testing into the ports library.

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-29 14:29:55 +00:00
Martin Huschenbett
4b26a62ad9
Remove some debugging left-overs from damlc tests (#6917)
CHANGELOG_BEGIN
CHANGELOG_END
2020-07-29 13:49:16 +00:00
Moritz Kiefer
9ed9970493
Avoid dev-env for posting to slack (#6914)
This is running on Azure’s agents and we just call curl so there is
really no need for dev-env (as evidenced by the fact that the message
got sent despite dev-env failing).

changelog_begin
changelog_end
2020-07-29 15:22:23 +02:00
Martin Huschenbett
76e5df6369
Add a test for the conversion of (nested) record updates to DAML-LF (#6915)
* Add a test for the conversion of (nested) record updates to DAML-LF

The new tests check that we generate the DAML-LF we intend to generate,
namely code using `ERecUpd` AST nodes rather than calls to the
`setField` function.

CHANGELOG_BEGIN
CHANGELOG_END

* Use get_value_name instead of get_dotted_name

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-29 13:13:17 +00:00
Martin Huschenbett
f1a83448d5
Mark the damlc integration tests as flaky (#6912)
See https://github.com/digital-asset/daml/issues/6910 for an
explanation of the issue causing the flakiness.

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-29 13:10:51 +02:00
Stefano Baghino
08d4bb0a21
Release new snapshot (#6909)
changelog_begin
changelog_end
2020-07-29 09:48:55 +00:00
Sofia Faro
0f06d63570
Evaluation order specification and tests for exercise and other updates. (#6867)
* Evaluation order for exercise & other updates.

This adds more DAML tests and error cases for, finishing off the update
interpretation for now. I believe this is roughly the limit of what we
can test directly in DAML, and the rest is up to DAML-LF testing.

For example, there's no way to test that the contract inactivity check
in EvUpdExercInactive happens before the evaluation of the controller
expression, since there is no way to generate an 'exercise' with actors
from DAML, as far as I could tell, and 'exercise_without_actor' always
evaluates the controller before passing it off to 'exercise'.

For the same reason, the EvUpdExercBadActor check seems impossible to
trigger from DAML itself. The closest is an authorization test that
happens during submit (which I added a test for, because it is kinda
relevant to evaluation order of scenarios, even though scenario
interpretation isn't really important to the spec).

So at the very least we should add LF tests for those two cases.

changelog_begin
changelog_end

* Apply Moritz\'s suggestions

* Add test with fetch of consumed contract
2020-07-29 09:59:46 +01:00
Miklos
224ab3621c
Ledger writer supporting pre-execution and normal flow (#6904)
* Added ledger writer that chooses between instances based on estimate interpretation cost.
CHANGELOG_BEGIN
CHANGELOG_END

* Code tidying.

* Delegate to pre-executing writer in case thershold is set to 0.

* Added ability to change metrics.

* Added metrics.

* Code tidying.

* Update ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/InterpretationCostBasedLedgerWriterChooser.scala

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
2020-07-29 08:48:30 +00:00
Moritz Kiefer
aec5cacba5
Add Moritz as a codeowner for more things (#6908)
I like keeping track of what happens in the areas I’m responsible
for. I’ve also removed Shayne since it doesn’t make sense to keep him.

changelog_begin
changelog_end
2020-07-29 09:49:34 +02:00
Stephen Compall
fd07a26510
check for scaladoc comments that are not actually used (#6802)
* add -Xlint:doc-detached

- reverts 1feae964e3 from #6798

* attach several scaladocs where they'll actually be included

* no changelog

* attach several more scaladocs where they'll actually be included

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-28 20:32:30 +00:00
Moritz Kiefer
a0e7e8f5dd
Fix flakiness in build-and-lint tests (again) (#6905)
This fixes 3 issues:

1. Switch the order in which we assign to `$proc` and
   `waitOn`. Without this the cleanup will not do anthing if `beforeAll`
   fails since the variable has not been assigned. This results in jest
   hanging forever until we hit the Bazel timeout.

2. Increase the timeout on `beforeAll` since we occasionally hit this
   on CI.

3. Allocate 2 CPUs to reflect the number of resources required by this test.

changelog_begin
changelog_end
2020-07-28 21:15:14 +02:00
Stefano Baghino
c16f17a721
Remove mentions of fidelity levels from the Ledger API test tool (#6893)
* Remove mentions of fidelity levels from the Ledger API test tool

Fixes #6868

changelog_begin
[Integration Kit] The performance test names have been changed.
To learn more about the available tests, consult the documentation
for the Ledger API Test Tool and run it with --list.
Docs: https://docs.daml.com/tools/ledger-api-test-tool/index.html
changelog_end

* Update performance envelope tests

* Address https://github.com/digital-asset/daml/pull/6893#discussion_r461655325
2020-07-28 18:24:46 +00:00
Samir Talwar
914c4513d3
ts/codegen: Mark the tests as flaky. (#6903)
They seem to break a lot.

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-28 18:45:04 +02:00
Martin Huschenbett
6c61ec272e
Add a semantic test for updating a record field twice (#6901)
rhe new test ensures that we don't omit the first update in a record
update that updates the same field twice.

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-28 16:14:50 +00:00
Robert Autenrieth
2ac7d28ca2
Support participant node failover (#6875)
* Change error code for invalid offsets for transaction stream and completion stream requests
* Expanded application architecture docs on how to build application with ledger api failover capabilities.

Fixes #6842.

CHANGELOG_BEGIN
- [Ledger API] The error code for requesting a transaction stream
  with an offset beyond the ledger end changed from INVALID_ARGUMENT
  to OUT_OF_RANGE. This makes it easier to handle scenarios where
  an application fails over to a backup participant which hasn't
  caught up with the ledger yet.
- [Ledger API] The command completion service now validates the offset and
  returns the OUT_OF_RANGE error if the request offset is beyond the ledger end.
- [Documentation] Added a section on how to write DAML applications
  that can fail over between multiple eventually consistent Ledger API endpoints
  where command deduplication works across these Ledger API endpoints, which
  can be useful for addressing HA and/or DR scenarios.
CHANGELOG_END
2020-07-28 17:03:55 +02:00
Sofia Faro
944ccf9fc5
Expose type synonyms in data-dependencies. (#6894)
* Expose type synonyms in data-dependencies.

This PR converts (non-unit) type synonyms during LF conversion, and then
exposes them via data-dependencies. This is possible only when using an
LF version that supports type synonyms (LF version >= 1.7), the
type synonym isn't of unit type (because it clashes with empty
typeclasses, and the (fully applied) type synonym has kind *
(e.g. you can't define a * -> * synonym in LF).

This fixes issue #6306

changelog_begin

- [DAML Compiler] The DAML compiler will now compile type synonyms
  (``type X = Y``) into the DAR, whenever possible, and will expose
  these synonyms via data-dependencies.

changelog_end

* Add more tests

* Fix formatting
2020-07-28 15:11:17 +01:00
Martin Huschenbett
3991c8a357
daml2js: Add decoder test for recursive records (#6899)
This is a follow-up on #6898.

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-28 14:10:41 +00:00
Martin Huschenbett
960d7ba628
daml2js: Use jtv.lazy as the only loop break (#6898)
We currently use two different mechanisms for breaking loops in the
`Serializable` companion objects generated for each type:

1. Explicit thunks of the form `() => Decoder<A>`, e.g., in the
   definition of the `Serializable` interface itself.
2. the `lazyMemo` combinator, e.g. in enum types, `Optional`s and lists.

This is inconsistent and leads to the introduction of more loop
breakers than actually needed.

This PR changes the situation to use the `lazyMemo` combinator as the
only loop breaker. To this end, we change the definition of the
`Serializable` interface and related similar interfaces to use `Decoder`
directly rather than the thunked up version. This is a *breaking change*
of the affected interfaces. However, the libraries `@daml/ledger` and
`@daml/react` are updated accordingly and hence nothing breaks when
using `daml2js` in combination with these libraries. Furthermore, the
exact definition of the decoder types is considered an implementation
detail since we don't want to tie ourselves long-term to the use of the
`json-type-validation` library, which is mostly unmaintained.

Using `lazy` as the only loop breaker effectively pushes all loop
breakers to the top-level and allows for removing those nested more
deeply in types.

This change should not negatively impact the performance of the
decoding process since it only replaces thunks by memoized thunks and
removes a few calls to `lazyMemo` completely. In fact, we should gain
performance since the decoders in the companion objects are now
memoized.

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-28 15:35:35 +02:00
Martin Huschenbett
11c4fe0727
daml2js: Memoize lazily constructed decoders (#6892)
Currently, if you have a record type `T` with a field of type, say,
`Optional S` and you're decoding a list of type `[T]`, then the decoder
for `S` has to be reconstructed for each element of the list. This is
because the `lazy` combinator from the `json-type-validation` does not
memoize the decoder it receives as a thunk.

This PR adds a new combinator `lazyMemo` which behaves like `lazy` but
also memoizes the decoder on its first invocation. All use sites of the
old `lazy` combinator are then replaced with `lazyMemo`.

We could consider upstreaming `lazyMemo` but I'm not sure how much
effort this is given that `json-type-validation` seems to be in
maintenance mode rather than active development.

CHANGELOG_BEGIN
CHANGELOG_END
2020-07-28 11:44:29 +00:00
Moritz Kiefer
a9fcf965ba
Document required nodejs version (#6891)
We’ve had a few confused users run into issues because of
this. `fsevents` (which is basically impossible to avoid as a
dependency) requires NodeJS 8.16 but for some reason Ubuntu 18.04
sticks to the unsupported 8.10.

changelog_begin
changelog_end
2020-07-28 11:27:55 +02:00
Moritz Kiefer
6581bba285
Upgrade rules_scala (#6883)
changelog_begin
changelog_end
2020-07-28 08:53:12 +00:00
Andreas Herrmann
5481a080d7
DAML REPL :show imports (#6885)
* DAML REPL :show imports

changelog_begin
- [DAML REPL] You can now list the currently imported modules using
  the REPL command ``:show imports``.
changelog_end

* Accept \r\n on Windows.

* REPL functests use text mode file for stdin/out

So that `\r\n` will be mapped to `\n` automatically on Windows.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-07-28 10:51:48 +02:00
Miklos
899fedcc2e
Added time update log entry type. (#6886)
CHANGELOG_BEGIN
CHANGELOG_END
2020-07-28 10:49:47 +02:00
Samir Talwar
4b703e19e7
daml-on-sql: Build a Docker image. (#6887)
* daml-on-sql + sandbox: Remove unused Bazel `load` declarations.

* daml-on-sql: Build a Docker image.

* daml-on-sql: Move the example Kubernetes file over from Sandbox.

* Add a changelog entry that was dropped.

CHANGELOG_BEGIN
* [DAML on SQL] DAML on SQL is now available with every release,
  from the GitHub Releases page.
CHANGELOG_END

* Upgrade the Java Docker base image to the latest version.
2020-07-28 08:07:49 +00:00
Moritz Kiefer
12c9612566
Remove redundant clean --expunge (#6890)
After the node resets this should hopefully not be necessary
anymore (we still had an issue this morning but I believe all nodes
that hit the issue also got the fix and if not, I’ll schedule a
targetted clean --expunge). I’ve also added node_modules to
.bazelignore to match the other node_modules directories.

changelog_begin
changelog_end
2020-07-28 09:49:36 +02:00
Moritz Kiefer
f588eac0c4
Fix version of @bazel/typescript (#6889)
Not quite sure why this didn’t fail on the PR but now it complains
that the version of @bazel/typescript and rules_nodejs are
incompatible.

changelog_begin
changelog_end
2020-07-28 06:40:32 +00:00
Robert Autenrieth
46b87c392d
Log all authorization errors (#6857)
* Log all authorization errors

CHANGELOG_BEGIN
- [Ledger API Server] The ledger API server now prints detailed log messages
  whenever a request was rejected due to a failed
  authorization.
CHANGELOG_END
2020-07-28 06:39:39 +02:00