Commit Graph

5697 Commits

Author SHA1 Message Date
Oliver Seeliger
7a2a2700cf
Introduce optional ledger-api-test-tool tests with ParticipantPruningIT (#8041)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-23 19:09:39 +01:00
Oliver Seeliger
83f11aa784
Participant pruning ledger api server support ported from Canton (#7988)
* Participant pruning ledger api server support ported from Canton

CHANGELOG_BEGIN
- [Ledger API]: The preview of `ParticipantPruningService` enables ledger participants to prune the "front" of ledger state at the participant including the ledger api server index.
CHANGELOG_END

* Review feedback from Stefano

* Add pruning tests plus missed command completions change

* Review feedback from Robert

* Improved test readability by having populate helper return offsets

* Review feedback

* Ledger api changes to pruning api and disable canton pruning test

- Change return result to PruneResponse
- Change type of PruneRequest.prune_up_to to string

* Review feedback: Use ApiOffsetSConverter for logged offsets
2020-11-23 15:28:04 +01:00
Robin Krom
936a0862fb
daml codegen: Add deprecation warning for scala. (#8033)
This fixes #8022. This adds a deprecation warning for the scala codegen.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-23 13:27:49 +01:00
tudor-da
f7c2ca808a
Allow async commits only within JdbcIndexer (#8004)
* Allow async commits within JdbcIndexer (#8004)

CHANGELOG_BEGIN
CHANGELOG_END

* Test in SqlLedgerSpec asserting no async commits in JdbcLedgerDao
2020-11-23 11:13:23 +01:00
Miklos
d5de65a234
Support serializing a single state update [KVL-669] (#8031) 2020-11-20 18:04:25 +01:00
Samir Talwar
bd037475eb
kvutils/tools: Fix the integrity checker so it compares state updates. (#8030)
* kvutils/tools: Fix the integrity checker so it compares state updates.

Previously, it would always take the list of updates _before_ processing
the import, leading to this useless check:

    Comparing expected and actual state updates.
    Successfully compared 0 state updates.

This makes the snapshotting lazy (by using a function instead of a
value), ensuring we actually perform the assertion.

CHANGELOG_BEGIN
CHANGELOG_END

* kvutils/tools: Add a test for the state updates regression.
2020-11-20 15:46:42 +00:00
Moritz Kiefer
65f355f327
Wait for live event in build-and-lint JS tests (#8001)
The stream from the JSON API is split into two sections:

1. The unordered section of ACS events.
2. The ordered transaction stream after the live event.

Our assertions assume that we only get 2 but currently we don’t wait
before sending commands so depending on timing, some of the events can
be delivered as part of the ACS section in a different order causing
very confusing assertion failures.

This test fixes this by waiting for the live event indicating the end
of section 1 and thereby forcing everything to come via the ordered
transaction stream.

Verified that this fixes the flakiness with --runs_per_test=50 which
reproduced it fairly reliable before (on CI, never managed to hit it
locally).

changelog_begin
changelog_end
2020-11-20 14:38:49 +01:00
Martin Huschenbett
da551ea142
DAML-LF spec: Explain how to use LaTeX input (#8018)
Add a description of how to enable LaTeX input mode when editing the
DAML-LF spec in VS Code. Also add some additional symbols.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-20 13:41:10 +01:00
fabiotudone-da
13851ca5e9
[KV] Read and prefer pre-computed blinding info when decoding KV transaction log entries [KVL-736] (#8012)
* Test and fix Conversions#encodeBlindingInfo

* Fix rebase

* Read and prefer pre-computed blinding info when decoding KV transaction log entries

CHANGELOG_BEGIN
CHANGELOG_END

* Fix rebase

* Tidy up

* Tidy up
2020-11-20 10:41:58 +01:00
Richard Kapolnai
34d7429147
fix section link in docs (#7850)
changelog_begin
changelog_end
2020-11-20 08:42:24 +00:00
fabiotudone-da
4f21453c5a
[KV] Fill DamlTransactionEntry#bindingInfo during TransactionCommitter#blind [KVL-736] (#8009)
* Fill DamlTransactionEntry#bindingInfo during TransactionCommitter#blind

CHANGELOG_BEGIN
CHANGELOG_END

* Test and fix Conversions#encodeBlindingInfo

* Fix rebase

* Fix non-determinism

* Reduce visibility

* Tidy up
2020-11-20 08:43:08 +01:00
Matthias Schmalz
82eaef5402
Updated documentation of CommandClient.trackCommands(Unbounded) (#7998)
* Do not backpressure from the command tracker output to the submission flow.
This is required to meet the contract of CommandClient.trackCommandsUnbounded, which allows for submitting an unbounded number of commands.
This is in turn required to use CommandClient.trackCommandsUnbounded as part of a flow that retries (some of the) failed command submissions.

CHANGELOG_BEGIN
CHANGELOG_END

* Revert "Do not backpressure from the command tracker output to the submission flow. This is required to meet the contract of CommandClient.trackCommandsUnbounded, which allows for submitting an unbounded number of commands. This is in turn required to use CommandClient.trackCommandsUnbounded as part of a flow that retries (some of the) failed command submissions."

This reverts commit 20c0b8e3

* Adding a disclaimer to the CommandClient so that users are not totally surprised about unexpected backpressure.
2020-11-19 16:55:10 +00:00
fabiotudone-da
2ff4d923a9
[KV] proto: add optional DamlTransactionBlindingInfo to DamlTransactionEntry [KVL-736] (#8005)
* KV proto: add optional DamlTransactionBlindingInfo to DamlTransactionEntry

CHANGELOG_BEGIN
CHANGELOG_END

* Wording

* Wording

* Rename party -> <action>_to for consistency

* Treat contract IDs as opaque strings (and for consistency)

* Address review comments
2020-11-19 15:09:23 +01:00
Richard Kapolnai
db08959811
Topology documentation: refine "serving the API" (#7971)
* concretize item on "serving the API"
CHANGELOG_BEGIN
CHANGELOG_END

* Revert "concretize item on "serving the API""

This reverts commit 83e35114c4.

* change authentication to authorization

* remove "etc." to make item clearer
2020-11-19 14:49:02 +01:00
Sofia Faro
4ac8d7cdf1
Make featureCppFlag field optional. (#8014)
Some features, in particular daml-lf encoding features, don't make any sense to have an associated CPP flag. I made the CPP flag optional and removed these unnecessary feature flags (based mostly on whether the flags were used in the standard library).

changelog_begin
changelog_end
2020-11-19 12:40:41 +00:00
Sofia Faro
ddf1378273
Use a NonEmpty list in makeLocalValBinds. (#8013)
Rewrite makeLocalValBinds to make the non-emptiness of the `binds`
argument explicit.

changelog_begin
changelog_end
2020-11-19 11:29:19 +00:00
Moritz Kiefer
9a6c33a7e3
Pass application_id through auth middleware (#8011)
fixes #7978

There is no new test in the trigger service since the existing test
for the custom application id already hits this. The difference is
that now the test authorization server will produce a token with the
application id set to what we request rather than the wildcard token
we used before.

changelog_begin
changelog_end
2020-11-19 12:00:54 +01:00
Shaul Kfir
2b9bc2b8bf
Minor improvements to getting started doc (#7854)
* Minor improvements to getting started doc

* add empty changelog

changelog_begin
changelog_end

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-11-19 09:42:22 +00:00
azure-pipelines[bot]
6a7cdc1831
update compat versions for 1.8.0-snapshot.20201117.5661.0.76fae40c (#8000)
CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Azure Pipelines DAML Build <support@digitalasset.com>
2020-11-19 10:18:40 +01:00
Martin Huschenbett
cfb8681b1c
DAML-LF spec: Fix some bad markup for links (#8010)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-19 09:06:34 +00:00
Moritz Kiefer
21aaf8b173
Use futures for database interaction in trigger service (#7999)
akka-http gets a bit unhappy if you block within requests and we also
use the unsafeToFuture in the JSON API so it seems sensible to do the
same in both.

I’ve moved out the initDb option out of the Server actor both because
it seemed cleaner than calling sys.exit in the actor and because it
was annoying to fit it in.

changelog_begin
changelog_end
2020-11-19 09:13:05 +01:00
nickchapman-da
6a745ed1fa
Support choice observers in 1.dev (#7922)
* Adapt to new desugaring for choice observers.

update hash of ghc patch.

changelog_begin
changelog_end

update ghc patch to final version

update stack-snapshot hashes for ghc-lib(-parser)

update stackage_snapshot.json, following `bazel run @stackage-unpinned//:pin`

expose Optional constructors for desugared code to use

adapt LFConversion to expect a 4-tuple for a desugared choice def/sig

update LFConversion for choice-observers

first example using new choice observer syntax.

fix scala type checker to have correct scoping rules for choice-observers

remove comment from example which says it is broken

improve variable names

improve tests for choice-observer clause

only test choice-observers SINCE 1.dev

add jq queries for choice observeres

make positive statement in jq test which checks choice obserers are present

test behaviour of choice observers

squash me

typo

* test more choice-observer divulgence

* Update documention for choice observers.

changelog_begin
Support choice observers in 1.dev
changelog_end

* fix docs build

* fix daml docs choice-observers example

* address comments: rewording text

* annotate choices observers as early-access in documention

* split out documentation code-snippets which require --target=1.dev

* final tweaks to documentation text
2020-11-18 19:51:15 +00:00
Sofia Faro
6c7e37a330
Rewrite multiple binding lets sequentially. (#8006)
* Rewrite multiple binding lets sequentially.

This PR enforces a sequential evaluation and dependency on
multiple-binding lets, by rewriting,

  let x1 = e1
      x2 = e2
      ...
      xn = en
  in b

Into a chain of single-binding let expressions,

  let x1 = e1 in
    let x2 = e2 in
      ...
        let xn = en in
          b

And likewise, rewriting multi-binding let statements in a "do" block,

  do
      ...
      let x1 = e1
          x2 = e2
          ...
          xn = en
      ...

Into single-binding let statements,

  do
      ...
      let x1 = e1
      let x2 = e2
      ...
      let xn = en
      ...

This PR fixes #6788 and adds a bunch of tests.

This is a bugfix, but it may break existing code that relies on
out-of-order let bindings. The suggested fix is to simply reorder
the let bindings, placing them in order of their dependency.

CHANGELOG_BEGIN

- [DAML Compiler] The DAML compiler now enforces sequential
  ordering for ``let`` expressions with multiple bindings.
  This fixes a bug where ``let`` expressions would be evaluated
  in the wrong order.

CHANGELOG_END

* Update compiler/damlc/daml-preprocessor/src/DA/Daml/Preprocessor.hs

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

* adjust last binding behavior

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-11-18 19:32:08 +00:00
Gary Verhaegen
e69cb45c51
ts/daml-ledger: createAndExercise (#7990)
ts/daml-ledger: createAndExercise

Fixes #7966.

CHANGELOG_BEGIN

JavaScript Client Libraries: The Ledger object (defined in daml-ledger,
returned by useLedger in daml-react) now sports an additional method
`createAndExercise`, which lets JS users create a contract and exercise
a choice on it in the same transaction.

CHANGELOG_END
2020-11-18 18:06:42 +01:00
Gary Verhaegen
6b31b2d4fd
release instructions: minor tweaks (#8008)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-18 17:37:19 +01:00
Samir Talwar
4ca87206ed
sandbox-common: Use a single sandbox for all the reset service tests. (#8007)
This makes the test a lot faster, not just because we don't restart the
Sandbox, but because we don't restart PostgreSQL either.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-18 16:02:48 +00:00
azure-pipelines[bot]
dc236dc600
rotate release duty after 1.8.0-snapshot.20201117.5661.0.76fae40c (#7995)
@garyverhaegen-da is taking care of 1.8.0-snapshot.20201117.5661.0.76fae40c (#7994), so they get pushed back to the end of the line.

Please do not merge this before #7994.

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Azure Pipelines DAML Build <support@digitalasset.com>
2020-11-18 16:53:20 +01:00
Samir Talwar
7bea34955e
extractor: Use pattern matching to get better error messages. (#8002)
* extractor: Use pattern matching to get better error messages.

If the gRPC exception status is not the one we expect, this will ensure
that we log the entire exception and not just the status.

CHANGELOG_BEGIN
CHANGELOG_END

* extractor: Make VeryLargeArchiveSpec an async spec.
2020-11-18 12:31:58 +00:00
Andreas Herrmann
59f40cb54e
Hide docs of Daml.Trigger.Internal (#7992)
changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-11-18 12:26:06 +00:00
Martin Huschenbett
f0e5bed36f
DAML-LF: Add interning for type to DAML-LF 1.dev (#7893)
* DAML-LF: Add interning for type to DAML-LF 1.dev

We add two new features to DAML-LF 1.dev:

* a per package list (or table) of `Type` messages, and
* a new case in the `Type` message which is an index into this table.

In combination, these two features can be used to allow DAML-LF
encoders to perform hash-consing of `Type` messages. We also change the
Haskell implementation of our DAML-LF encoder to do exactly that when
targetting DAML-LF 1.dev.

Doing this has a few benefits:

1. The DALFs produced by `damlc` get smaller: I've seen a case where
   the size dropped from 69MB to 45MB.
2. DAML-LF decoders need to decode less data.
3. Decoded packages use less memory because identical structures are
   now shared. This is particularly helpful in situations where we need
   to keep the interface (or signature) of a package in memory for a
   long time.

This PR mostly takes care of the Haskell implementation. However, we
need to make the Scala implementation of the decoder aware of the new
features as well since we have tests that load DAML-LF 1.dev into the
engine. A decoder and _targeted_ tests on the Scala side will follow
in a separate PR.

CHANGELOG_BEGIN
CHANGELOG_END

* Make jq tests aware of type interning

CHANGELOG_BEGIN
CHANGELOG_END

* Improve jq test

CHANGELOG_BEGIN
CHANGELOG_END

* Apply Remy's suggestions

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

* Improve the imperative bits

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Remy <remy.haemmerle@daml.com>
2020-11-18 11:14:30 +00:00
Samir Talwar
1ac3160a46
test-common: Make FiniteStreamObserver more lenient. (#7996)
* test-common: Make FiniteStreamObserver more lenient.

We can't protect against all possible race conditions; we just have to
accept that sometimes `onNext` will be called after `onCompleted`, or
`onCompleted` will be called twice, or…

CHANGELOG_BEGIN
CHANGELOG_END

* test-common: Avoid calling `onCompleted` twice in `TimeBoundObserver`.
2020-11-18 10:45:40 +00:00
fabiotudone-da
43b1f9c96f
Let indexer updates support and prefer (optional) pre-computed blinding info [KVL-724] (#7989)
* Add to indexer updates and prefer optional blinding info

CHANGELOG_BEGIN
CHANGELOG_END

* Formatting

* Relax adherence to Scala naming convention for better readability
2020-11-18 11:42:12 +01:00
Samir Talwar
87eee303e3
resources: Release sequenced resources in parallel. (#7991)
* resources: Release sequenced resources in parallel.

This isn't used much, but has been bothering me for a while. While we
acquire the resources in parallel, we used to release them sequentially.
This reimplements `sequence` so they're released all at once.

CHANGELOG_BEGIN
CHANGELOG_END

* resources: Drop an unnecessary `.map`.

* resources: Fix the Scaladoc for `sequence`.
2020-11-18 09:33:44 +00:00
Samir Talwar
51101151ca
sandbox-classic: Make ScenarioLoadingIT tests async. (#7997)
This speeds things up, and makes the tests less brittle.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-18 08:52:44 +00:00
tudor-da
e3816ec557
Disabled synchronous commit when indexing TransactionAccepted (#7980) (#7980)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-18 09:42:55 +01:00
azure-pipelines[bot]
80662eceb2
release 1.8.0-snapshot.20201117.5661.0.76fae40c (#7994)
This PR has been created by a script, which is not very smart and does not have all the context. Please do double-check that the version prefix is correct before merging.

@garyverhaegen-da is in charge of this release.

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Azure Pipelines DAML Build <support@digitalasset.com>
2020-11-18 09:08:52 +01:00
Samir Talwar
76fae40c19
test-common: Remove duplicate logic between test observers. (#7984)
This uses the decorator pattern to avoid doing the same thing in every
class.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-17 16:43:37 +00:00
Moritz Kiefer
221dd5189f
Fix missing trace statements on failed submits (#7987)
changelog_begin

- [DAML Script] Fix a bug where trace statements from a failing
  transaction where not displayed in DAML Studio.

changelog_end
2020-11-17 17:09:24 +01:00
Matthias Schmalz
9f44de6cc3
Await termination of the CommandTrackerFlow when closing. (#7986)
This fixes the following bug:
1. The command tracker is closed as part of the command service.
2. The dispatcher is closed.
3. The command tracker accesses the dispatcher, resulting in an exception ("Dispatcher is closed").

CHANGELOG_BEGIN
Avoid error message "Dispatcher is closed" on shutdown.
CHANGELOG_END
2020-11-17 16:49:52 +01:00
Richard Kapolnai
831ed8bdfc
doc: rename user to party (#7985)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-17 14:47:21 +00:00
Stephen Compall
ac8cffd98f
document name mangling from DAML to DAML-LF (#7976)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-17 09:20:14 -05:00
Samir Talwar
7013c1619f
sandbox: When testing the reset service, wait for the ledger config. (#7975)
* Suppress debug and trace logging for Sandbox tests.

* participant-integration-api: Don't submit config after shutting down.

* sandbox: When testing the reset service, wait for the ledger config.

If we don't wait for the ledger configuration, we could potentially ask
for completions before the server is fully ready.

* sandbox-common: Reduce the number of reset attempts in testing.

Now we're also checking for ledger configuration, the time for a reset
to be "accepted" is longer, so 5 tries in 30 seconds is a bit flaky.
Reducing to 4 seems reasonable.

* sandbox: Stop marking the reset service tests as flaky.

I don't have conclusive proof that they're no longer flaky, but I'm
fairly confident. We can revert this commit if they turn out to still
need some attention.

CHANGELOG_BEGIN
CHANGELOG_END

* sandbox-common: Check the configuration shows up in reset service tests.

* sandbox-common: Factor out logback-test.xml.
2020-11-17 13:28:44 +00:00
Andreas Herrmann
14f71ed20c
Split trigger service tests into a test suite (#7983)
This is to reduce the likelyhood of these tests timint out. Bazel will
generate a dedicated test target per `.scala` file. Meaning the tests
can run in parallel and each test target should have a shorter overall
runtime.

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-11-17 13:14:24 +00:00
Andreas Herrmann
90dc3a5669
Implement token refresh in auth middleware (#7981)
* Obtain refresh token from Auth0

Auth0 requires the `offline_access` scope to be set to return a refresh
token.

See https://auth0.com/docs/tokens/refresh-tokens/get-refresh-tokens

Additionally, the `audience` claim needs to be set to obtain a JWT
access token and a refresh token.

See https://auth0.com/docs/tokens/refresh-tokens

changelog_begin
changelog_end

* Implement refresh endpoint on auth middleware

Following the refresh spec [1] and Auth0 documentation [2].

[1]: https://tools.ietf.org/html/rfc6749#section-6
[2]: https://auth0.com/docs/tokens/refresh-tokens/use-refresh-tokens

* Adapt Auth0 example configuration

Ignore any requests outside the ledger-api audience.

Don't throw on missing query fields. Otherwise the unhandled exception
would prevent unrelated requests from succeeding. E.g. token refresh
requests would always fail.

* Forward unauthorized/forbidden response on refresh

* re-use precomputed token payload

* Implement token refresh in auth test server

Reuses the association between authorization code and token payload to
associate refresh tokens and token payload.

Adds an expiry to the generated token to make tokens distinguishable
across refresh.

* obtain refresh token in test client

* Test auth server refresh token

* auth test server clock configurable

The clock used to define token expiry is configurable

* Override default clock in test fixture

* implement an adjustable clock

* Test token refresh with adjustable clock

* Test token expiry on /auth backend

* Test case for auth middleware /refresh endpoint

* handle malformed code/refresh token in auth server

* Forward client errors on middleware refresh

* Test middleware refresh failure

* Clarify meaning of offline accesss

* Remove redundant testing only comment

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-11-17 12:06:42 +00:00
fabiotudone-da
983a937cf5
[KV integrity check] Fix: use the configured jdbc URL when indexing (#7982)
* Use configured jdbc URL when indexing

CHANGELOG_BEGIN
CHANGELOG_END

* Wording

* Tidy up
2020-11-17 12:38:10 +01: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
nickchapman-da
9bf4ef9ba6
update instructions for working with ghc-lib (#7958)
changelog_begin
changelog_end

typos

undo change to old instructions

test & fix new instructions

remove old instructions

rename new instructions

copyright at top

remove update date from text

tee when running example

instruct to make initial build
2020-11-17 10:02:19 +00:00
Moritz Kiefer
10792ed6fd
Make application ID configurable in trigger service (#7974)
* Make application ID configurable in trigger service

fixes #7671

changelog_begin

- [Trigger Service] The application id used by a trigger can now be
  configured by an optional `applicationId` in the start request.

changelog_end

* Update triggers/service/src/main/scala/com/digitalasset/daml/lf/engine/trigger/Server.scala

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

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2020-11-17 10:25:30 +01:00
fabiotudone-da
fdddb56b72
[KV integrity checker] Remove extra stateUpdates.compare() (#7977)
* Remove extra stateUpdates.compare()

CHANGELOG_BEGIN
CHANGELOG_END

* Add test
2020-11-17 10:23:54 +01:00
Moritz Kiefer
45ba167aac
Dedup parties in JwtPayload (#7973)
Previously we didn’t build up the `OneAnd[Set, Party]` properly and
included the one party in the set as well. This was an issue if you
have the same party multiple times, most likely in readAs and
actAs (but not limited to that). This then lead to SQL queries failing
since we tried to insert twice for a given party. This PR fixes that
by properly deduplicating the parties and adding a test for this.

changelog_begin

- [JSON API] Fix a regression introduced in SDK 1.7.0, where using a
  party multiple times in the same JWT token (e.g., readAs and actAs)
  broke database queries for that party. Note that there is never a
  reason to include a party multiple times since actAs implies readAs.

changelog_end
2020-11-16 19:28:11 +01:00