Commit Graph

647 Commits

Author SHA1 Message Date
azure-pipelines[bot]
9ae125eeae
bump canton to 20220505 (#13805)
CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Azure Pipelines Daml Build <support@digitalasset.com>
2022-05-06 12:52:22 +02:00
Remy
615d2e6206
Daml-script: marking MultiParticipantIT as falky in windows (#13739)
The problem is tracked by #13737.

CHANGELOG_BEGIN
CHANGELOG_END
2022-04-28 16:09:23 +00:00
Nicu Reut
a792de39a5
Update scalafmt to 3.5.1. (#13584)
CHANGELOG_BEGIN
CHANGELOG_END
2022-04-28 09:57:04 +00:00
Remy
7dfbf58147
Daml-script: Use curly braces notation for records in ledger export (#13634)
instead of `with` notation

fixes #13620

CHANGELOG_BEGIN
- [Daml-script] fix a bug in daml-script export formatting
  See https://github.com/digital-asset/daml/issues/13620
CHANGELOG_END
2022-04-26 16:36:18 +02:00
Remy
0be64a8dd0
LF: Structure stable packages (#13682)
CHANGELOG_BEGIN
CHANGELOG_END
2022-04-26 12:47:06 +00:00
Moisés Ackerman
482fb040a4
Ensure MultiTest.waitForCid actually waits (#13698)
changelog_begin
changelog_end
2022-04-26 12:17:44 +00:00
Hubert Slojewski
35b68962e8
Remove remaining kvutils dependencies [KVL-1245] (#13695)
CHANGELOG_BEGIN
CHANGELOG_END
2022-04-26 13:42:18 +02:00
Remy
79af226966
LF: Add a convenient companion object for ArrayList (#13684)
CHANGELOG_BEGIN
CHANGELOG_END
2022-04-26 12:36:36 +02:00
Remy
2894038b04
Daml-Script: fix MultiTestIT test (#13692)
CHANGELOG_BEGIN
CHANGELOG_END
2022-04-26 08:05:26 +00:00
Moisés Ackerman
c61326884e
daml-script/runner: leave application id blank when an access token is provided but an application id isn't (#13654)
changelog_begin
changelog_end
2022-04-21 17:51:35 +02:00
Gary Verhaegen
e085a4932e
bump canton (#13574)
I'm considering automating this, but thought I'd do it manually once
first.

CHANGELOG_BEGIN
CHANGELOG_END
2022-04-12 15:23:11 +00:00
Remy
e94dc3eae8
Allow LF dev for daml script tests (#13455)
CHANGELOG_BEGIN
CHANGELOG_END
2022-03-30 10:15:17 +02:00
Rafael Guglielmetti
f24a39d2df
Use Canton 2.1.0-SNAPSHOT (20220328) for conformance tests (#13446)
CHANGELOG_BEGIN
CHANGELOG_END
2022-03-29 17:55:21 +02:00
Remy
f7d1901a5c
LF: split Command into ApiCommand and ReplayCommand (#13323)
CHANGELOG_BEGIN
CHANGELOG_END
2022-03-21 14:07:41 +01:00
Moritz Kiefer
1a66bb998b
Bump port retries in Canton fixture (#13235)
changelog_begin
changelog_end
2022-03-09 19:18:10 +00:00
Stefano Baghino
b8fd1747e8
Remove mentions of Daml connect (#13230)
Daml Connect is no longer a thing. I replaced usages with
either Daml or Daml SDK.

changelog_begin
changelog_end
2022-03-09 18:18:51 +00:00
Moritz Kiefer
d36123bf03
Bump Canton startup timeout to 2min (#13222)
It looks like 1min is too small under load.

changelog_begin
changelog_end
2022-03-09 13:42:15 +00:00
Gary Verhaegen
dfa648f585
hunt down DAML better (#13195)
Process:

- `git ls-files -z | xargs -0 -n 100 sed -i --follow-symlinks 's/DAML/Daml/g'`
- `git add -p`
- `git restore -p`
- Check there is no unstaged change left.

To review:

- Check for false positives by carefully reviewing the diff in this PR.
- Check for false negatives with `git grep DAML`.
- Quicker check for fals positives:

```
git grep DAML | grep -v migration | grep -v DAML_
```

Fixes #13190

Note: This is the "second half" of #13191, which failed to cover all the
remaining DAMLs because of:

```
$ git ls-files | grep "'"
compiler/damlc/tests/daml-test-files/MangledScenario'.daml
```

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-08 17:04:58 +01:00
Moritz Kiefer
e44b6ef61f
Switch daml script multi-participant tests to Canton (#13171)
* Switch daml script multi-participant tests to Canton

ledger-on-memory is moving repos together with kvutils so this doesn’t
work anymore. Sandbox on X does not (yet) have multi-participant
support so this is our only option.

At a later point, we may want to switch back to sandbox on x once it
supports multiple participants.

changelog_begin
changelog_end

* more startup attempts

changelog_begin
changelog_end
2022-03-07 20:34:17 +01:00
Moisés Ackerman
2dbd91aab9
Interface methods can use plain function declaration syntax (#13102)
* Update 'implements' blocks to use new syntax

* Add InterfaceSyntax test case

* Add InterfaceMultipleMethodDeclsError test case

* Add InterfaceDifferentNumArgsError test case

changelog_begin
changelog_end
2022-03-02 15:59:01 +00:00
Remy
e834a7b85c
Triggers: Connect Logging context from Triggers to the Speedy. (#13009)
Follow up of #12976.
fixes #12208

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-22 18:28:49 +01:00
Remy
ac3d9a4647
LF: Add LoggingContext to Speedy Machine (#12976)
This advances the state of #12208

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-21 13:34:46 +01:00
Moritz Kiefer
756b8bc406
Raise akka log-lveel for CoordinatedShutdown in daml-script (#12919)
Trying to work around https://github.com/akka/akka/pull/30944/files
having introduced rather confusing log messages in Daml script.

There are probably some other tools where we might want to do this but
I think daml script is the main one as the other ones are long-running
services where you don’t expect to shutdown the actor system during
regular operatino.

changelog_begin
changelog_end
2022-02-15 09:07:13 +01:00
tudor-da
307931d5b4
Extracted kvutils Config to //leger/ledger-runner-common [DPP-865] (#12889)
* Extracted kvutils Config to //leger/ledger-runner-config

changelog_begin
changelog_end

* Sandbox-on-X logback.xml does not depend on the kvutils/app one

* Remove unused dependencies

* Add copyright header back

* Remove dependency of SoX on kvutils
2022-02-14 13:52:06 +00:00
Moritz Kiefer
d6e6c568fe
Fold daml test-script under daml script --all (#12895)
I tried to keep the changes somewhat minimal and reuse what is already
there. I think there is a fair amount of cleanup we can do afterwards
but hopefully this way it’s easier to review.

fixes #12837

changelog_begin

- [Daml Script] `daml test-script` has been replaced by `daml script
  --all`. The option to spin up a ledger automatically has been
  removed and you always have to specify one.

changelog_end
2022-02-14 14:23:21 +01:00
Moritz Kiefer
0fb0bf2f52
Disable implicit party allocation in Daml Studio (#12839)
* Disable implicit party allocation in Daml Studio

fixes #12058

This matches what sandbox does in 2.0 so it reduces a source of
inconsistency and potential confusion.

changelog_begin
changelog_end

* Update compiler/scenario-service/protos/scenario_service.proto

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2022-02-09 17:47:40 +00:00
Moritz Kiefer
857dff9cd6
Remove option to spin up ledger in-process in daml test-script (#12842)
* Remove option to spin up ledger in-process in daml test-script

This drops the dependency on the kv sandbox which we need to kill for
2.0.

part of #12837

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2022-02-09 16:18:40 +01:00
nickchapman-da
b60a7ef657
belt and braces to ensure no infinite loop (#12770)
* belt and braces

changelog_begin
changelog_end

* comment explaining loop termination for GrpcLedgerClient.listAllUsers

* fix loop termination condition + comment

* update comment
2022-02-08 11:53:10 +00:00
tudor-da
14a0459f0a
SandboxNextFixture replaced by SOX-based SandboxFixture (#12654)
* SandboxNextFixture replaced by Sandbox-on-X based SandboxFixture

changelog_begin
changelog_end

* Some fixed tests

* No direct dependencies on //ledger/sandbox:sandbox and //ledger/sandbox:sandbox-scala-tests-lib

* Fix after rebase

* Rename SandboxFixture and add a missing dep

* Generate valid party names if hint is empty

* Smaller maxInboundMessageSize

* Added test for empty display name

* SandboxServer is a ResourceOwner
* Uses execution context passed as an input for resource management
* Fixes flaky FlywayMigrations issue with null Thread.currentThread.currentClassLoader
* SandboxServer simplification returns Port instead of ApiServer

* Dedicated PMAllocateWithoutDisplayName for non-Canton ledgers
* Created since Canton does not return empty display names
2022-02-07 09:25:22 +01:00
nickchapman-da
56140569f8
Adapt daml-script to paginated listUsers. (#12710)
* Adapt daml-script to paginated listUsers.

changelog_begin
changelog_end

* adapt testUserListPagination to rename listUsers -> listAllUsers
2022-02-04 11:05:48 +00:00
pbatko-da
7137b46543
[User management] Use pagination for listing users [DPP-840] (#12610)
CHANGELOG_BEGIN
Ledger API Specification: UserManagementService.ListUsers is now using pagination
CHANGELOG_END
2022-02-03 20:32:50 +01:00
nickchapman-da
cd16eb740e
Rename: listUsers --> listAllUsers (within daml-script) (#12734)
* Rename: listUsers --> listAllUsers (within daml-script)

changelog_begin
changelog_end

* fix/rename in newly add def: clearUsers

* improve comment doc
2022-02-03 13:07:09 +00:00
Victor Peter Rouven Müller
aa45f48798
Upgrade to Scala 2.13.8 (#12506)
* Upgrade to Scala 2.13.8

changelog_begin
changelog_end

* Update hash for scala in nixpkgs

* update more hashes for scala upgrade

* Fix most warnings etc.

* Fix remaining errors etc.

* Fix formatting

* Resolve last errors hopefully

* Fix ledger api common build file

* Combine imports & revert accidental change that broke the CI run

* Rename exporting vals to scriptExport & minimize diff

* Remove more wrong changes

* moved warning around
2022-02-03 09:05:31 +00:00
Moritz Kiefer
7a5172c025
Make daml-script docs work with a Canton sandbox (#12695)
* Make daml-script docs work with a Canton sandbox

This addresses a few issues:

1. The `--wallclock-time` option does not work.
2. Display names are garbage so dropped the "solution" for
`listKnownParties`.
3. We cannot allocate fixed parties even with
`allocatePartyWithHint`. Switched to `--output-file` and user mgmt.

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* debug windows

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* debug scriptexample

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* Update docs/source/daml-script/index.rst
2022-02-02 21:01:44 +00:00
Moritz Kiefer
0494731928
Adjust response type for script JSON API user mgmt requests (#12683)
This broke due to concurrent merges of #12646 and #12578

changelog_begin
changelog_end
2022-01-31 19:17:00 +00:00
nickchapman-da
54c427f849
Expose documentation for user-management functions in daml-script. (#12674)
changelog_begin
changelog_end
2022-01-31 17:01:22 +00:00
nickchapman-da
3d3d84fa6f
User management in daml-script over json API (#12646)
* WIP

changelog_begin
changelog_end

* small cleanup

* use symbolic names for status codes instead of 404/409

* improve recover methods to have them wrap the success case with Some
2022-01-31 15:28:10 +00:00
nickchapman-da
4a6729eb70
Fix a bug in user management caching (#12605)
* provoke bug using daml-script

* fix bug in user management caching

changelog_begin
changelog_end

* add test case (#12606)

Co-authored-by: pbatko-da <pawel.batko@digitalasset.com>
2022-01-26 20:15:21 +00:00
Stefano Baghino
f1cd4b1c7c
Remove dependencies on compatibility libraries (#12548)
Continues the work started in https://github.com/digital-asset/daml/pull/12543

These libraries were only needed to transition from Scala 2.12 to 2.13
and are no longer useful as all the necessary items are now available
in Scala 2.13.

changelog_begin
changelog_end
2022-01-24 18:04:07 +00:00
Stefano Baghino
aec3390904
Replace silencer plugin with built-in warning configuration (#12543)
Since Scala 2.13.2, Scala introduced built-in support to
manage warnings in a more granular fashion, thus making
the silencer plugin we are currently using no longer
strictly useful. Removing compiler plugins also removes
friction from migrating to Scala 3 in the future. As a
cherry on top, the built-in warning configuration also
allows to check whether a `@nowarn` actually does
anything, allowing us to proactively remove unused
warnings should the need arise.

[Here][1] is s a blog post by the Scala team about it.

Warnings have been either solved or preserved if useful,
trying to minimize the scope (keeping it at the single
expression scope if possible). In particular, all
remaining usages of the Scala Collection API compatibility
module have been removed.

Using the silencer plugin also apparently hid a few
remaining usages of compatibility libraries that were used
as part of the transition from Scala 2.12 to Scala 2.13
that are no longer needed. Removing those warnings
highlighted those.

changelog_begin
changelog_end

[1]: https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html
2022-01-24 15:01:35 +00:00
Moritz Kiefer
688f1e1e0b
Drop v0 contract ids (#12464)
* Drop v0 contract ids

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2022-01-20 15:28:27 +00:00
nickchapman-da
ebd3827c4a
Make UserId properly opaque by defining it as a variant (#12476)
* Make UserId properly opaque by defining it as a variant instead of as a record.

changelog_begin
changelog_end

* hand coded Show instance for UserId

* rename: userName --> userIdToText
2022-01-19 17:53:44 +00:00
nickchapman-da
6fbaac467f
Remove user-management error cases from scenario-service proto. (#12460)
* Remove user-management error cases from scenario-service proto.

changelog_begin
changelog_end

* remove Error.UserManagement

* remove UserManagememtError

* simp

* meh... done over by scala's poor excuse for a type system
2022-01-19 10:44:04 +00:00
nickchapman-da
0c13a4f1fd
Error handling for User Management exposed via daml-script (#12416)
* Error handling for User Management exposed via daml-script

changelog_begin
changelog_end

adapt ScriptTest.daml to new user-management interface

adapt create-daml-app Setup.daml to new user-management interface

* Add deriving Ord for UserId

* change example of invalid user-id char to "%" from "." (which is no longer illegal)

* recover/reify ALREADY_EXISTS from GrpcLedgerClient.createuser

* fix testcase expected order of users from daml-script listUsers

* adapt create-saml-app Setup.daml to changed interface of user-management

* reinstate sort lost in merge

* sort user in ScriptService user-management test

* improve comment for error foobar hack

* improve doc comment for validateUserId

* use upper case as test example for invalid user-id
2022-01-18 12:58:51 +00:00
Stefano Baghino
4af48bbccc
Split channel configuration from LedgerClientConfiguration (#12433)
* Split channel configuration from LedgerClientConfiguration

Fixes #12391

The channel configuration now has to be provided separately from the
configuration specific to the ledger client. In this way we avoid
situations where the builder is provided with some configuration
that gets overridden.

changelog_begin
[Scala bindings] The channel configuration has been split from the
LedgerClientConfiguration class. Provide the gRPC channel specific
configuration separately or use a builder. The channel configuration
no longer overrides the builder.
changelog_end

* Fix compilation issues in //ledger-service/...
2022-01-18 10:03:33 +00:00
Moritz Kiefer
b996e5e3fa
Support user tokens in Daml Script over JSON API (#12368)
fixes #12349

changelog_begin
changelog_end
2022-01-17 18:45:31 +01:00
Moritz Kiefer
b21c960232
Make Daml Script user mgmt tests order independent (#12409)
no specific order guaranteed so let’s not assume one.

changelog_begin
changelog_end
2022-01-13 17:51:12 +00:00
Simon Meier
82bdfa5222
ledger-api-auth: remove SupportedJWTPayload (#12343)
* ledger-api-auth: make AuthServiceJWTPayload parse both user and custom daml access tokens

changelog_begin
changelog_end
2022-01-13 16:12:13 +00:00
Moritz Kiefer
bb8f455e2d
Add test coverage for validateTokenParties (#12370)
This is pure refactoring & adding some tests in preparation
for #12368

changelog_begin
changelog_end
2022-01-13 14:40:09 +01:00
Samir Talwar
9c77a3c94b
kvutils: Remove the DAR upload parameters from the runner. (#12366)
* kvutils: Remove the DAR upload parameters from the runner.

No production ledger needs to upload DARs on participant startup; this
feature is primarily for users of Sandbox. The feature never worked in
the case of multiple participants and was only ever used in testing.

This also removes the associated functionality from Sandbox-on-X as they
share a configuration object. Hopefully this won't be an issue.

Some tests were using this feature, so I have updated them to upload the
DARs through the PackageManagementService instead.

CHANGELOG_BEGIN
CHANGELOG_END

* kvutils: Remove the `writePackagesService` factory constructor.

We no longer use it.

* daml-lf/engine: Revert an unnecessary change.

* daml-script/test: Shut down the channel after uploading the DAR.
2022-01-12 12:57:02 +01:00
Moritz Kiefer
8bc5ff06a7
Clarify unhandled exception error message (#12353)
* Clarify unhandled exception error message

The previous error doesn’t make it clear that this is an exception in
user code rather than a Scala exception in our code.

Daml-lf exception would technically be more correct but I don’t think
it’s helpful here so I went with Daml exception.

changelog_begin
changelog_end

* adjust ledger api test tool

changelog_begin
changelog_end

* Update test assertions

changelog_begin
changelog_end

* fix another assertion

changelog_begin
changelog_end
2022-01-11 17:57:07 +00:00
Simon Meier
6dd0eb774e
ledger api server: support auth0 usernames (#12308)
* ledger api: support Auth0 user names in user management

See the `IdString.UserId` and `IdString.ApplicationId` comments wrt the
character classes being introduced.

Many thanks to @cocreature for helping with deciding on the exact
restrictions of user-ids.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-10 12:58:43 +00:00
Gary Verhaegen
ea55ea2d14
Further copyright updates (#12249)
Somewhat error-prone, so please review carefully.

Reasons we need this:

- Some file types are not properly handled by the script.
- The only exclusion mechanism we currently have (`NO_AUTO_COPYRIGHT`)
  is overly coarse.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-04 16:32:17 +01:00
Moritz Kiefer
7c011cfb38
Fix tracking of party references (#12253)
We missed keys of generic maps.

Don’t be scared of the diff, I just added some unit tests since there
didn’t seem to be any.

fixes #12234

changelog_begin
changelog_end
2022-01-04 12:11:05 +00:00
Gary Verhaegen
d2e2c21684
update copyright headers (#12240)
New year, new copyright, new expected unknown issues with various files
that won't be covered by the script and/or will be but shouldn't change.

I'll do the details on Jan 1, but would appreciate this being
preapproved so I can actually get it merged by then.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-03 16:36:51 +00:00
Moritz Kiefer
01364f2863
Enable Daml Script user management tests (#12130)
With #12063 merged, these tests now pass \o/

changelog_begin
changelog_end
2021-12-14 11:57:41 +00:00
Moritz Kiefer
f146bc814b
Escape daml-lf tracelog messages (#12116)
* Escape daml-lf tracelog messages

Currently veracode complains because this allows for clrf
injection (injecting newlines to make user input look like separate
log statements).

With this change
```
debug "abc"
debug "eaiu\neaiu"
debug "def"
debugRaw "abc
```

is logged as

```
[DA.Internal.Prelude:555]: \"abc\"
[DA.Internal.Prelude:555]: \"eaiu\neaiu\"
[DA.Internal.Prelude:555]: \"def\"
[DA.Internal.Prelude:555]: abc
```

You can debate whether we should escape the quotes are necessary but
90% of the reason why people add them is because they call `debug` on
strings when they should be using `debugRaw` so this seems fine to me.

changelog_begin
changelog_end

* fix tests

changelog_begin
changelog_end
2021-12-14 11:20:33 +01:00
Simon Meier
f223528bfb
Implement PoC of user management for Ledger API server (fix #12014) (#12063)
CHANGELOG_BEGIN
- [User Management]: add support for managing participant node users and authenticating
  requests as these users using standard JWT tokens.
CHANGELOG_END

Co-authored-by: Marton Nagy <marton.nagy@digitalasset.com>
Co-authored-by: Adriaan Moors <90182053+adriaanm-da@users.noreply.github.com>
2021-12-13 17:58:30 +01:00
Moritz Kiefer
8011d602c8
Support multiple participant in daml script’s user management (#12091)
part of #11997

No tests for now since we don’t have a multi-participant ledger that
supports this in `main`. The logic for selecting the client for the
participant is the same as for party management and other stuff anyway
so tests don’t add that much.

changelog_begin
changelog_end
2021-12-10 15:08:28 +01:00
Moritz Kiefer
f59760efd8
Wire up Daml Script user management to gRPC API (#12069)
* Wire up Daml Script user management to gRPC API

part of #11997

The tests are disabled for now until #12063 is merged. I did test it
manually against that branch though and they pass happily.

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end
2021-12-09 10:18:22 +00:00
Moritz Kiefer
f3acd8d852
Wire up user management to ScriptLedgerClient (#11889)
part of #11997

changelog_begin
changelog_end
2021-12-09 08:52:48 +01:00
Moritz Kiefer
e036e2c00a
Implement user management in Daml script service (#12050)
* Implement user management in Daml script service

changelog_begin
changelog_end

* Update compiler/scenario-service/server/src/main/scala/com/digitalasset/daml/lf/scenario/Conversions.scala

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

* move assertion into replaceInfo

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-12-08 16:11:09 +00:00
Moritz Kiefer
6c7112cc08
Add the Daml API for exposing user management in Daml Script (#12029)
Spun out from #11899 for ease of review, part of #11997

This PR exposes the user management service from
https://github.com/digital-asset/daml/blob/main/ledger-api/grpc-definitions/com/daml/ledger/api/v1/admin/user_management_service.proto
in the Daml Script Daml API.

It obviously doesn’t actually work without also handling that in the
Daml Script runner. For ease of review I’ll handle that in a separate PR.

changelog_begin
changelog_end
2021-12-08 14:32:45 +01:00
Moritz Kiefer
42a8ccdbef
Extend ScriptLedgerClient trait with user management (#12031)
* Extend ScriptLedgerClient trait with user management

Spun out from #11899, part of #11977

This PR extends the ScriptLedgerClient trait with the methods we need
for user management. All implementations currently fail, I’ll fill
those in separately. I’ve chosen to make them fail in each instance
rather than in the trait since eventually they should all be filled in.

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end
2021-12-08 08:54:55 +01:00
Moisés Ackerman
8df9a42f29
Interface desugaring cont. (#11964)
* Move toInterfaceContractId and fromInterfaceContractId out of Implements class

* Split Implements class into single-method classes

* Define toInterface outside its class to swap type arguments

This allows users to call 'toInterface @Interface', since the type of the template can usually be inferred

* Move interface classes and functions to DA.Internal.Interface

changelog_begin
changelog_end
2021-12-07 13:56:57 +01:00
Moritz Kiefer
8179c73763
Drop support for Daml-LF party literals from the Scala side (#11922)
* Drop support for Daml-LF party literals from the Scala side

This PR enforces that forbidPartyLiterals is always `true` and drops
the corresponding literals from the AST. Haskell side is in #11930

fixes #11581

changelog_begin
changelog_end

* Update daml-lf/interpreter/src/test/scala/com/digitalasset/daml/lf/speedy/ComparisonSBuiltinTest.scala

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

* Revert "Update daml-lf/interpreter/src/test/scala/com/digitalasset/daml/lf/speedy/ComparisonSBuiltinTest.scala"

This reverts commit 55e542ce4e3a7fd15544ee703de3277ffc309b17.

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-12-01 10:37:42 +00:00
Moritz Kiefer
16135e6f7c
Limit supported input versions in damlc to >= LF 1.8 (#11905)
* Limit supported input versions in damlc to >= LF 1.8

1.8 was the version that introduced type synonyms, we really don’t
gain much by dropping more since data-dependencies mainly depends on
that. and this provides for a very natural upgrade path for users
where pretty much everyone should be able to upgrade directly to SDK
2.0 without having to go through intermediate versions.

changelog_begin

- [Daml Compiler] The supported input LF versions for
  data-dependencies are now limited to LF 1.8 and newer.

changelog_end

* fix some tests

changelog_begin
changelog_end

* Drop export 1.6 tests

changelog_begin
changelog_end

* Drop daml2js support for LF < 1.8

changelog_begin

- [Daml2js] DARs with LF version < 1.8 are no longer supported.

changelog_end

* .

changelog_begin
changelog_end

* bash is bad, stop using it

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-11-30 17:24:08 +01:00
Moritz Kiefer
31cc540cf9
Turn package name & version warnings into an error (#11859)
* Turn package name & version warnings into an error

fixes #11321

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-11-26 18:46:33 +00:00
Remy
58e69ade1a
LF: replace "dev" LF version by "1.dev" in bazel files (#11894)
the more consistent, as asked by Moritz in review of #11820

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-26 12:23:17 +00:00
Moritz Kiefer
9ff64f7faa
Change daml script’s sleep to sleep for a minimum amount of time (#11886)
* Change daml script’s sleep to sleep for a minimum amount of time

We’ve seen a few flaky test failures where we slept for less than the
expected amount of time which isn’t what we want. We definitely cannot
guarantee an exact sleep time but at least a minimum.

changelog_begin
changelog_end

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

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-11-26 11:12:08 +00:00
Moritz Kiefer
5785bbfcfd
Drop LF < 1.14 from supported damlc output versions (#11701)
* Drop LF < 1.14 from supported damlc output versions

fixes #11319

We keep test coverage by depending on the most recent snapshot which
still has 1.14 support.

changelog_begin

- [Daml Compiler] Damlc can only produce Daml-LF 1.14 or
  newer. Passing aynthing older to `--target` is an error. If you
  need to produce older versions, use an older SDK.

changelog_end

* Switch around legacy_compiler_lf_versions

changelog_begin
changelog_end

* drop since-lf

changelog_begin
changelog_end
2021-11-22 16:20:17 +00:00
Sofia Faro
f8933d1f4b
Make lookupTemplateChoice return only choices in the template. (#11808)
This fixes a bug in the typechecker (#11558) and the command
preprocessor, since those were written with this behavior of
lookupTemplateChoice in mind. Enables the engine test that
caught this.

changelog_begin
changelog_end
2021-11-22 13:27:48 +00:00
tudor-da
8e31e8e6a8
[Self-service error codes] Enabled by default [DPP-691] (#11685)
* [Self-service error codes] Enabled by default
* Flag changed to `use-pre-1.18-error-codes` (disabled by default)

CHANGELOG_BEGIN
[Ledger API Specification] The Ledger API returns enriched error codes (see https://docs.daml.com/error-codes/self-service/index.html)
For backwards-compatibility, a new API flag `--use-pre-1.18-error-codes` is introduced for preserving the legacy behavior for
clients that want to migrate incrementally to the changed gRPC status code responses and error details format.
CHANGELOG_END

* Adapted HttpServiceIntegrationTest

* Renamed `Feature Flag` to `Configuration` in docs

* Fix Daml Script tests

changelog_begin
changelog_end

* Fix Repl functests

changelog_begin
changelog_end

* Fix haskell binding tests

changelog_begin
changelog_end

* Fix CommandClientIT test

* Fixed Sandbox and CommandServiceBackpressureIT tests
 Please enter the commit message for your changes. Lines starting

* Adapt //compiler/damlc/tests:repl-functests again

* Fix more tests and address Miklos' comments
* Flag name changed to `grpc-status-codes-compatibility-mode`

* Remove useless flags sandbox-classic

* Sandbox-classic tests fix for ContractKeysIT and ExceptionsIT
* Created 2 deprecated test suites that have the more generic assertions as returned
by the deprecated in-memory backend

* More fixes for CommandServiceIT
* Fixes compilation issue with the deprecated exceptionsIT class for Sandbox-classic in-memory

* Compatibility mode for old test tools

* Change flag name to `use-pre-1.18-error-codes`

* Apply suggestions from code review

Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>
2021-11-22 12:26:48 +00:00
Moisés Ackerman
d23d113667
Restructure interface desugaring (#11555)
* Update ghc patch

* Replace Implements proxy datatype with a class

* Expose 'Implements' class in Prelude

* Add DA.Internal.Desugar.HasMethod class

This allows us to get the type of a method of an interface through the functional dependency

* Convert interfaces from new desugaring

* Update Interface daml-test-file to use Interface class functions

* Update InterfaceDesugared daml-test-file

* Replace remaining uses of Is<Interface> methods with Implements

* Document HasMethod, Method and mkMethod

* Ignore _method_ bindings in convertBind

* Ignore interface desugaring types/classes/instances/functions in LF conversion

* update snapshot after pin on windows

changelog_begin
changelog_end
2021-11-19 10:06:49 +01:00
Moritz Kiefer
fa7663148a
Drop 2.12 versioned_scala_deps (#11748)
I’ve kept the infrastructure for versioned_scala_deps around because
I’m optimistic and hope that eventually we’ll do another Scala upgrade.

changelog_begin
changelog_end
2021-11-17 22:13:08 +00:00
Moritz Kiefer
2d5b54828b
Use explicit party specifications in Daml Script over JSON API (#11678)
* Use explicit party specifications in Daml Script over JSON API

This uses the new party set arguments from #11454 to allow Daml Script
over the JSON API to `submit p` even if we have a token with more
claims.

changelog_begin

- [Daml Script] When run over the JSON API, Daml Script can now use a
  subset of the claims in the token. E.g., `submit p` works even if you
  have a token with `actAs = [p, p2]`.

changelog_end

* Apply suggestions from code review

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

* Drop opt prefix

changelog_begin
changelog_end

* switch around error & success cases

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-11-16 12:17:32 +00:00
Remy
7eb22ddf4f
LF: drop forgotten deprecate Node aliases. (#11673)
Because a bug in the scala compiler deprecated pattern matching are
not detected (See https://github.com/scala/bug/issues/12493).
Hence some deprecated usage of Node aliases have been forgotten in

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-12 15:07:22 +00:00
Moritz Kiefer
b0463aaab2
Move script auth tests to postgresql (#11670)
changelog_begin
changelog_end
2021-11-12 13:55:25 +01:00
Moritz Kiefer
d3bb036591
Fix sandbox database config in script & trigger tests (#11655)
* Fix sandbox database config in script & trigger tests

Setting jdbcUrl does absolutely nothing because it later gets
overwritten again.

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-11-12 06:18:12 +00:00
nickchapman-da
2dd5289a35
different types for different speedy phases (#11605)
* Refactor speedy to distinuish SExpr types before/after ANF compilation phase

CHANGELOG_BEGIN
CHANGELOG_END

* remove commment/marker left in error

* make SExpr0 private to speedy

* reinstate (non-pp) print of original expression in AnfTest faiure

* avoid use of s./t. prefixes for expressions in SBuiltin; add 3 TODO markers

* inline "runtime" apply methods of SDefinitionRef into sole caller: SBCallInterface

* avoid use of t. prefix in SExpr0

* change s./t. prefix to source./target.

* add comment to summarize differences between SExpr0 and SExpr
2021-11-11 08:21:12 +00:00
Remy
92181161cc
LF: Abstract VersionedValue and VersionedContractInstance (#11533)
* LF: Abstract VersionedValue and VersionedContractInstance

CHANGELOG_BEGIN
CHANGELOG_END

* formatting
2021-11-09 23:22:38 +00:00
Remy
3b61a1b748
LF: allow exercise command by template for inherited choice. (#11584)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-09 13:10:06 +00:00
Moritz Kiefer
ac19c8cff5
Synchronize in multi-participant script tests (#11594)
* Synchronize in multi-participant script tests

This hopefully fixes the flakiness where the party allocation is not
yet propagated to the other participant.

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-11-09 09:27:54 +00:00
Moisés Ackerman
7d68e05f7f
Remove virtual choices (#11482)
* Remove virtual choices

* Remove choices without a body in 'interface' definition
* Remove choices in 'template ... implements' section

part of #11372

changelog_begin
changelog_end

* Remove virtual choices cont.

Switch uses of virtual choices to fixed choice with method implementation

* update snapshot after pin on windows

* Disable failing interface tests with TODO #10810
2021-11-08 17:05:23 +01:00
Moritz Kiefer
a3d04cafaf
Migrate matches-docs tests to sandbox on postgres (#11573)
* Migrate matches-docs tests to sandbox on postgres

We’ve seen timeouts on party allocation which are likely caused by the
h2 issues that keep popping up. Switching to postgres should hopefully
solve that.

We need to wrap postgres to set LOCALE_ARCHIVE for this to work in
builds. We already pass it through in tests which is why it works fine there.

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* Update nix/bazel.nix

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

* disable on Windows

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2021-11-08 13:39:02 +00:00
Moritz Kiefer
6a0b84e3d0
Run Script export tests against BR (#11574)
More h2 garbage

changelog_begin
changelog_end
2021-11-08 10:41:09 +00:00
Stefano Baghino
b84a9142d1
Extractor: replace sandbox-classic-based fixtures with sandbox-based ones (#11489)
* Replace `sandbox-classic`-based fixtures with `sandbox`-based ones

changelog_begin
changelog_end

* Replace Scenarios with Script for BasicPrimitiveTypes

* Adapt ListsSpec

* Adapt TextMapsSpec

* Adapt OptionalSpec

* Adapt more tests

* More tests passing

- removed workflow_id testing (Daml Script doesn't set one)
- reduced failure threshold for VeryLargeArchiveSpec
- solved issu in TransactionSingleTableSpec (wrong parties were used)

* Port EnumMod and make EnumSpec pass

* Port GenMapMod and make GenMapSpec pass

* Shaking things around to make Windows happy -- maybe
2021-11-04 13:08:51 +00:00
Moritz Kiefer
c098d75621
Add a --log-level flag to damlc (#11514)
This also allows us to quite down our builds a bit which is nice.

changelog_begin
changelog_end
2021-11-03 14:22:57 +01:00
Moritz Kiefer
bb37eef156
Switch script & trigger tests to postgres-backed Sadbonx (#11525)
DPP-695 is gift that keeps on giving and seems to also result in
timeouts here. Just marking all of our tests that depend on Sadbonx as
flaky doesn’t seem all that helpful so switch to a postgres-backed
sandbox instead.

changelog_begin
changelog_end
2021-11-03 08:39:46 +00:00
Moritz Kiefer
257d5365c2
Switch from sandbox to sandbox-classic in daml test-script (#11476)
* Switch from sandbox to sandbox-classic in daml test-script

changelog_begin
changelog_end

* apparently sadbonx next also has ce and ee

changelog_begin
changelog_end
2021-11-01 10:42:46 +00:00
Moritz Kiefer
8ffd835f24
Migrate daml script tests to Sandbox next (#11472)
* Migrate daml script tests to Sandbox next

This does not yet drop all dependencies from daml script. In
particular `daml test-script` still depends on Sandbox classic. Will
tackle that in a separate PR.

changelog_begin
changelog_end

* Speedup maxInboundMessageSize tests

changelog_begin
changelog_end
2021-11-01 09:08:32 +00:00
Moritz Kiefer
73718a22fa
Mark script export tests as flaky (#11449)
Not much we can do here until the underlying bug in the indexer is
fixed so marking flaky for now.

changelog_begin
changelog_end
2021-10-28 15:03:45 +02:00
Moritz Kiefer
fcc7e581cf
Make stable packages dependent on supported LF versions (#11382)
* Make stable packages dependent on supported LF versions

Note that this just introduces an API dependency, we are not yet
filtering the list of packages. For that, I’d really like to
autogenerate StablePackages.scala since I don’t want to make that
manually maintained list even more complex. But review seems easier if
we first change the usage sites and then switch to autogenerating than
trying to do both in one go.

changelog_begin
changelog_end

* Fix script export tests

changelog_begin
changelog_end
2021-10-28 11:20:42 +00:00
Moritz Kiefer
8d17882951
Allocate parties sequentially in script export tests (#11389)
* Allocate parties sequentially in script export tests

We’ve seen a few timeouts so this seems at least worth a try.

changelog_begin
changelog_end

* Extend logging to ease debugging

changelog_begin
changelog_end
2021-10-26 08:21:40 +00:00
Robert Autenrieth
1309c2f819
DPP-587 Use Timestamp instead of Instant (#11183)
* Use Timestamp instead of Instant

Time has microsecond resolution in Daml

changelog_begin
changelog_end

* Revert accidental newline changes

* Remove unused conversion modes

* Apply review comments
2021-10-26 08:54:47 +02:00
Remy
5365d68a38
LF: Remove PartialTransaction out from ScenarioRunner/IdeLedgerClient (#11368)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-25 13:07:23 +02:00
Remy
8d5cab5f16
LF: Simplify seeds generation in scenario runnner (#11353)
We just need the new seeds to be:
- fresh during a run,
- deterministic across two runs.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-25 08:54:42 +02:00
Robert Autenrieth
355352f2d1
DPP-650 Remove the mutating schema (#11211)
* Remove the mutating schema

changelog_begin
- [Participant] All participants now use the new append-only schema. Existing databases will
  automatically upgrade to the new schema the first time a participant/ledger is started.
changelog_end

* Fix post-commit validation test

* Remove append-only flags from CI

* Don't crash when using deprecated flag

* Increase timeout for reset service tests

* Fix typos in parameter names

* Restore removed test

* Restore removed CLI check

* Improve CLI parameter description
2021-10-21 14:40:35 +02:00
Stephen Compall
f4df1cc4d0
converting server errors to proper client errors (#11184)
* a model for trapping client errors in Scala bindings shim and reporting correctly

* clean up some nesting with an alias

* filter out client-side command service errors

* fix flattening error propagation of CommandService errors in endpoints

* remove todo

* Daml evaluation triggers INVALID_ARGUMENT; handle this for creates/exercises

* clean up lookupResult

* remove stripLeft utility; it is unused

* proper error propagation for /parties endpoint

* map grpc status codes to HTTP error codes

* add a case to pass-through gRPC errors in Endpoints errors

* handle gRPC status in all explicit top-level catches

* pass through gRPC errors in CommandService as well

* treat a gRPC status anywhere in the causal chain as indicating participant-server error

* propagate ContractsService errors without assuming they will always be ServerErrors

* filter ServerErrors' contents when rendering errorful streams

* log errors from websocket output instead of rendering full messages

* hide message in ServerError case

* remove Aborted

* transfer with bad contract ID now returns 409

* mention new error codes

* add changelog

CHANGELOG_BEGIN
- [JSON API] Several kinds of gRPC server errors are now reported with
  associated HTTP statuses; for example, a Daml-LF interpreter error now
  returns a 400 instead of a 500, and an exercise on an archived contract
  returns a 409 Conflict instead of a 500.  Errors internal to JSON API
  (e.g. internal assertion failures) are no longer detailed in the HTTP
  response; their details are only logged.
  See `issue #11184 <https://github.com/digital-asset/daml/pull/11184>`__.
CHANGELOG_END

* remove unused Show and liftErr utility

* adapt daml-script to new error codes

* adapt typescript tests to new error codes

* adapt json-api failure tests to new error codes
2021-10-19 13:54:29 -04:00
tudor-da
2fc7490df2
[Self-service error codes] Adapt error factories [DPP-656] (#11270)
* Moved ErrorCodesVersionSwitcher to //ledger/error

CHANGELOG_BEGIN
CHANGELOG_END

* Rename ErrorCodeLoggingContext to ContextualizedErrorLogger

* Refactored ErrorFactories
* All error factories use ContextualizedErrorLogger for being able to dispatch self-service error codes.
* The ContextualizedErrorLogger is passed down from the dispatching Ledger API services.
* ErrorFactoriesSpec asserts both legacy (V1) and self-service error codes (V2).

* Adapted ApiSubmissionService

* Addressed Marcin's review comments
2021-10-18 16:46:20 +02:00
Remy
a1d94e10ba
LF: Create special case class for VersionedContractInstance (#11127)
To replace usage of ContractInstance[VersionedValue]

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-14 08:53:26 +02:00
Moritz Kiefer
83d1e3cc0e
Fix daml test-script ordering (#11210)
The issue is that onComplete is not sequenced here. It’s close to
impossible to hit this by default but I added random delays which
triggered it reliably and confirmed that this fixes the issue.

changelog_begin
changelog_end
2021-10-12 13:57:42 +00:00
Robin Krom
3115d104aa
daml script interfaces (#11124)
* interfaces: introduce TemplateOrInterface class in stdlib

The template typeclass is to strong for many applications. The new
constraint `TemplateOrInterface` only contains the methods to convert
contract IDs and choices.

CHANGELOG_BEGIN
CHANGELOG_END

* ghc-lib update, interface script tests

* pinned stackage on unix

* added missing implementation in preprocessor

* added test

* fixing tests

* remove Iface type

* pinned stackage windows

* make sure createAndExercise is not called on interfaces
2021-10-11 18:22:40 +02:00
Hubert Slojewski
b9e8eb81e8
daml-script: Switch integration-tests to the append-only-schema (#11149)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-07 10:18:29 +02:00
Andreas Herrmann
51873ff344
Support empty party display name in scenario service (#11131)
* Add regression test for #11099

https://github.com/digital-asset/daml/issues/11099

* Support empty party display name in scenario service

changelog_begin
- [Daml Studio] Scripts no longer fail when allocating a party with an
  empty display name. See https://github.com/digital-asset/daml/issues/11099.
changelog_end

* fmt

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-10-06 10:28:11 +00:00
John Sullivan
7a4963b43d
add --max-inbound-message-size flag to daml ledger export (#11087)
Add support for `--max-inbound-message-size` flag to the [Ledger Export](https://docs.daml.com/tools/export/index.html) tool.

CHANGELOG_BEGIN

- [Daml Assistant] Add support for `--max-inbound-message-size` flag to the Ledger Export tool.

CHANGELOG_END
2021-09-30 12:17:53 +02:00
Moritz Kiefer
26d10b267d
Drop NodeId type parameter (#10921)
changelog_begin
changelog_end
2021-09-30 09:13:54 +00:00
Remy
5dc15c6911
LF: rename language Interface to PackageInterface (#10938)
To avoid confusion with the new Daml concept of Interface.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-20 19:04:14 +00:00
Moritz Kiefer
8e22bb6b2d
Drop ContractId typeparameter from Value (#10827)
99% of our usecases use Value[ContractId] so this PR just fixes it.

The few other usescases are:

1. Value[Nothing] which we use for keys. This is technically more
precise but we benefit very little from it.
2. Value[String] mostly because in a few places we are lazy.

We don’t have any code which benefits from being polymorphic in the
contract id type.

changelog_begin
changelog_end
2021-09-16 08:46:57 +00:00
pbatko-da
6dcdaa411c
[DPP-589] Add CLI flag to select minimum enabled TLS version (#10854)
- Add support for specifying either 1.2 or 1.3 as minimum TLS versions for ledger api server.
- Log enabled protocols (~TLS versions) and cipher suites at server and client startup.
- Add integration tests against Sandbox-classic and Sandbox

CHANGELOG_BEGIN
Sandbox: Add CLI flag to select minimum enabled TLS version for ledger API server.
CHANGELOG_END
2021-09-14 12:37:38 +02:00
Hubert Slojewski
b50bb8e437
Populate definite_answer in ApiException [KVL-1004] (#10832)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-13 16:28:39 +00:00
Remy
1e1c452b36
LF: drop ad-hoc FrontStack builders (#10839)
Following #10763, we drop the ad-hoc builders for `FrontStack`.

* Building a `Fronstack` from individuals elements should be done with
  standard scala buidler.

* Building a `Fronstack` from a `TraversableOne` should be done with
  the scala 2.13 `.to(FrontStack)` methd

* Building a `Fronstack` from a `ImmArray` should be done with the
  `toImmArray` method.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-13 17:49:09 +02:00
Remy
c4e0a755d4
LF: drop ad-hoc ImmArray builders (#10763)
Since we switch to scala 2.13, ImmArray companion object extends
`Factory`. Hence:

- the `apply` methods of `ImmArray` override the one from `Factory`

- we can use the notation `.to(ImmArray)` to convert an `Iterable` to
  `ImmArray`

This PR drops those `apply` ImmArray. Conversion from Iterable to
`ImmArray` should use the `.to(ImmArray)`.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-04 16:10:07 +02:00
Victor Peter Rouven Müller
5595d55c79
[JSON-API] Use the token from incoming requests to update the package list (#10602)
* Use the token from incoming requests to update the package list

changelog_begin
changelog_end

* Lazily initialize the ledger client

* Fix ee integration tests

* Fix package reloading behaviour by using a semaphore to check for ongoing updates

* Refactor out the semaphore code into a concurrency utility class

* Use correct locking for the updateTask so every thread always uses an up to date task

* Remove unused imports in utils.Concurrent & remove packages from the tests

* Hide & mark the token file cli option deprecated because we dont need it anymore and only keep it so client deployment code doesn't break

* Fix scala 2.12 build by adding more type annotations

* Update ledger-service/http-json-cli/src/main/scala/com/daml/http/OptionParser.scala

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

* Update ledger-service/http-json/src/main/scala/com/digitalasset/http/PackageService.scala

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

* Readd pgkManagementClient after it was removed accidentally (but now it's lazy)

* Remove concurrent object & use atomic boolean instead of a mutex because it makes more sense

* Replace semaphore with countdownlatch

* Refactor the caching into a separate class

* Use Instant instead of LocalDateTime

* Remove that ** of bad synchonization and do stupid simple synchronization because it JUST WORKS, besides adapt when we want to reload

* Remove await in tests because it can result in buggy tests

* remove unused code in WebSocketService.scala

* Unhide the access-token-file option as per request of Stefano

* Less implicit jwts per request of Stefano

* Try making some code more readable as by request of Akshay

* Use more shark because it expresses better than flatMaps if I don't need the arg

* Move defs in predicate in WebsocketService.scala around

* Try to minimize diff further in WebsocketService.scala

* Fix build and minimize diff in WebSocketService.scala further

* Minimize diff of function getTransactionSourceForParty in WebSocketService.scala

* Share the ec in WebSocketService.scala to minimize the diff

* Minimize in function predicate in WebSocketService.scala

* Further minimize in function predicate in WebSocketService.scala

* Change some case classes to be normal classes but with apply method

* Update ledger-service/http-json/src/main/scala/com/digitalasset/http/PackageService.scala

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

* Update ledger-service/http-json/src/main/scala/com/digitalasset/http/Endpoints.scala

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

* Get rid of implicit jwt tokens, the world is already confusing and full of implicits enough

* Improve readability

* Integrate the new LedgerClient which does not depend on a leder id

* Fix tests

* Apply suggestions from code review

thanks to @S11001001

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

* Apply further review comments

* Remove outcommented code

* Deprecate access token file option in the description too

changelog_begin

- [JSON API] The cli option `--access-token-file` is now deprecated. It
    is not needed anymore and you can safely remove it. Reason is that
    the operations which prior required a token at startup are now done
    on demand using the token of the incoming request.

changelog_end

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-09-03 10:12:01 +00:00
Remy
97bda3ca36
LF: V1 Contract ID check in Preprocessor (#10687)
This PR makes possible to reject V0 contract IDs during preprocessing.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-30 20:14:55 +02:00
nickchapman-da
387c68b9eb
Normalize transaction values within the engine (#10648)
Create normalized TXs when a partial TX is finalised.

Except in limited cases! (i.e for scenario-runner, sandbox)

CHANGELOG_BEGIN
CHANGELOG_END

normalize values in the engine as they are converted from speedy-values

fix 2.12 build

backout redundant change

ensure byKey field is correctly normalized when constructed by engine

rename flag: valueNormalization -> transactionNormalization

improve comment

delete commented-out code

rename: toValueNorm --> toNormalizedValue

rename: (SValue.) toValue --> toUnNormalizedValue

revert changes to ptx so that the interface to insertCreate() etc is Value-based (not SValue-based)

improve comments

respell: toUnNormalizedValue --> toUnnormalizedValue

fix build
2021-08-25 09:53:26 +01:00
Remy
b22de6893b
LF: Contract ID suffix check in Preprocessor (#10642)
This PR makes possible to check for contract IDs suffix during
preprocessing.

This is the first part of the task 3 described in #10504.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-24 18:45:33 +02:00
Remy
3598e0928c
LF: Drop contract ID Freshness check (#10620)
As stated in #10504 the contract ID freshness check cannot be
implemented correctly in general.

This PR drops the support for this (buggy) check.

This corresponds to the fist task of #10504.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-19 18:07:29 +02:00
Samir Talwar
8dd136fc7d
bazel-tools: Replace runner with either runner_with_port_check or runner_with_port_file. (#10615)
* Use `extra` in the port file runner, rather than `temporary`.

* ledger-api-test-tool-on-canton: Use the port check runner.

Much simpler than the port file runner for our purposes.

* Replace `runner` with `runner_with_port_file`.

Rather than expecting a particular set of command-line-arguments, we use
templating.

CHANGELOG_BEGIN
CHANGELOG_END

* Rename the `runner_with_port_check` target to the default.
2021-08-18 15:23:45 +00:00
Andreas Herrmann
d92440471c
daml ledger export: export all parties (#10588)
* Add test-case to ConfigSpec for output type

changelog_begin
changelog_end

* Add an --all-parties flag to ledger export

changelog_begin
* [Daml export] You can now set the ``--all-parties`` option to generate
  a ledger export as seen by all known parties.
changelog_end

* Update docs

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-17 14:12:28 +02:00
Andreas Herrmann
244262dfac
Handle imports for builtin types correctly in Daml export (#10575)
* Move isTupleId

* Don't depend on DA.Types for tuple values

changelog_begin
changelog_end

* Date|Timestamp requires import DA.Date|Time

changelog_begin
changelog_end

date

* Use DA.TextMap consistently in encoding

changelog_begin
changelog_end

* TextMap requires DA.TextMap

changelog_begin
changelog_end

* Use DA.Map in encoding

* GenMap requires DA.Map

changelog_begin
changelog_end

* Add unit tests for module and package refs

changelog_begin
changelog_end

* Update daml-script/export/src/main/scala/com/daml/script/export/TreeUtils.scala

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

* Update daml-script/export/src/main/scala/com/daml/script/export/TreeUtils.scala

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

* Consistently use Set +

* Format scaladoc comment

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-08-16 11:20:10 +00:00
Samir Talwar
4b8b67a1b5
Upgrade Scalatest to v3.2.9. (#10576)
* Upgrade Scalatest to v3.2.9.

Because of some coupling we also have to upgrade Scalaz to the latest
v7.2 point release, v7.2.33.

The Scalatest changes are quite involved because the JAR has been broken
up into several smaller JARs. Because Bazel expects us to specify all
dependencies and doesn't allow transitive dependencies to be used
directly, this means that we need to specify the explicit Scalatest
components that we use.

As you can imagine, this results in quite a big set of changes. They
are, however, constrained to dependency management; all the code remains
the same.

CHANGELOG_BEGIN
CHANGELOG_END

* http-json-oracle: Fix a Scalatest dependency.

* ledger-api-client: Fix a Scalatest dependency.
2021-08-12 23:19:35 +00:00
Moritz Kiefer
f1a55aa4bf
Fix sdk version in script export tests (#10559)
changelog_begin
changelog_end
2021-08-11 17:04:08 +00:00
Andreas Herrmann
5cc78f5254
Handle missing template instances in Daml ledger export (#10526)
* LF 1.6 ledger export integration test

Test that Daml ledger export script handles DALF packages in LF version
1.6. These packages don't contain metadata, meanint `--package` flags
have to use the hash rather than the package name, and they contain no
type class instances, meaning the export script needs to contain newly
defined instances for type classes required to issue ledger commands in
Daml script.

changelog_begin
changelog_end

* Expose unconstrained Daml script commands

This will be used in Daml ledger exports of contracts defined in Daml LF
versions before 1.8. These versions did not include typeclass instances,
meaning that instances such as HasTemplateTypeRep need to be recreated
in the export Script. Not all instances required in the `Template t`
constraint can be recreated at the use-site. E.g. `HasSignatory`. By
avoiding these kinds of constraints it is possible to handle these cases
in Daml ledger exports anyway.

changelog_begin
changelog_end

* Identify all templates with missing instances

changelog_begin
changelog_end

* Use internal*Cmd on templates missing instances

changelog_begin
- [Daml export] Daml ledger export now handles templates in packages
  using LF versions 1.7 or older. These package versions don't include
  type class instances and Daml ledger export needs to generate
  replacement instances in the generated script. The generated script
  uses less type-safe versions of Daml script ledger commands.
changelog_end

* Add encodeType to encode Ast.Type in ledger export

This will be required to encode HasContractKey instances.

changelog_begin
changelog_end

* Simplify newline handling in encodeExport

* Encode missing template type class instances

* ZIP entries must use forward slash as path separator

* Throw error on encode of Any

Addressing
https://github.com/digital-asset/daml/pull/10526#discussion_r685807454

* Qualify choice using argument type

Addresses review comment
https://github.com/digital-asset/daml/pull/10526#discussion_r685817745

* Use lf.language.Util

Addresses
https://github.com/digital-asset/daml/pull/10526#discussion_r685827150

* Factor out header comment in tests

Addressing review comment
https://github.com/digital-asset/daml/pull/10526#discussion_r685830832

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-10 16:44:11 +00:00
Andreas Herrmann
35f1592098
Split the Daml ledger export integration tests (#10506)
changelog_begin
changelog_end

This test suite performs the same test with different parameters three
times. These tests each setup some state on the ledger, then create a
Daml ledger export script, compile it, run it, and compare the new
ledger state to the previous state.

Running all this three times in the same target get exceed the default
timeout of 300s in some case. This splits these tests into three
separate targets to reduce the risk of timeouts.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-09 13:58:11 +02:00
Andreas Herrmann
55ed83c7ea
Factor out Daml export integration tests (#10492)
* Move Daml export scala integration-tests

changelog_begin
changelog_end

* Move Daml export example test

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-09 10:04:01 +02:00
Samir Talwar
df78f9cb1e
Replace LedgerConfiguration with InitialLedgerConfiguration or the load timeout. [KVL-1058] (#10487)
* participant-integration-api: Encapsulate the initial configuration.

* participant-integration-api: Reduce usage of `LedgerConfiguration`.

* Inline `LedgerConfiguration` wherever it's used.

Most things don't need all its constituent parts; this reduces the
amount of unused properties.

CHANGELOG_BEGIN
- [Integration Kit] The ``LedgerConfiguration`` class has been
  removed in favor of ``InitialLedgerConfiguration``. Its usage
  has been changed accordingly, with the ``configurationLoadTimeout``
  property becoming part of ``ApiServerConfig`` instead.

  The default options provided by ``LedgerConfiguration`` have been
  removed; you are now encouraged to come up with sensible values for
  your own ledger. The ``Configuration.reasonableInitialConfiguration``
  value may help.
CHANGELOG_END

* Correct the initial configuration submission delay for KV ledgers.

* kvutils: Mark supertype unused parameters as unused.

* kvutils: Extract out common configuration submission delays.

These values are specific to kvutils; other drivers should come up with
their own.

* configuration: Delete `NoGeneration`, as it's unused.
2021-08-05 16:31:45 +00:00
Andreas Herrmann
8f1cde3e7d
Handle exerciseByKey after exercise command (#10490)
* Add regression test for exerciseByKey after exercise

changelog_begin
changelog_end

The discovery of exerciseByKey commands currently doesn't handle the
case where the contract or contract key is modified during the same
transaction. Issuing a regular exercise command in this case is an error
as it is not possible to reference a contract id that is generated
during the same transaction.

* Track contract-keys from exercise events

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-05 13:36:58 +00:00
Andreas Herrmann
a8a39f7540
Handle tuple values in Daml ledger export (#10483)
* encodeValue handle tuple

* Cover tuples in encodeValue unit-test

changelog_begin
changelog_end

* Check DA.Types package-id in tuple check

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-05 12:19:11 +00:00
Andreas Herrmann
7c6d3c5bc7
Handle package dependencies without metadata in Daml export (#10481)
* Expose set of stable-packages package-ids

Needed in Daml ledger export to decide whether to depend on a package
without metadata or not.

changelog_begin
changelog_end

* Handle package dependencies without metadata in Daml export

This addresses the immediate issue reported in
https://github.com/digital-asset/daml/issues/10435.

DALF before LF version 1.8 don't contain metadata such as the package
name and version. However, Daml ledger export assumed that metadata was
available to generate `--package` flags for data-dependencies.

This change generates `--package=<hash>` flags for such dependencies on
packages that don't have metadata available.

This change requires additional care when checking if a package is a
stable-package. As the package name is not available without metadata we
cannot just check against names such as `daml-stdlib`. Instead this
change uses the list of stable-package package-ids exposed by
`com.daml.lf.language.StablePackages.Ids`, which was introduced in
0da814d250 (diff-208c6948c7c7f2b582faa8e4792bfe78b231188881947ad0cdd5046e0b9a40e7)

Note that this does not fully resolve #10435. Building a generated Daml
ledger export script will fail on missing instances of standard classes
such as `HasTemplate` because packages prior to LF version 1.8 don't
contain type-class instances. This will be addressed in a separate PR.

changelog_begin
changelog_end

* Fix Scala 2.12

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-04 18:11:17 +02:00
Andreas Herrmann
87c9c5186e
Use at least LF version 1.7 for Daml ledger export (#10480)
That is the earliest LF version at which Daml Script is available,
according to 50c7b79f83/daml-lf/language/daml-lf.bzl (L71).

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-04 13:12:06 +00:00
Remy
c243f82525
LF: Clean up of Errors (#10052)
part of #9974

 - rename `msg` field to `message`
 - drop `engine.Error.Validation.Generic`
 - rename argument `where` to `location`
 - Builtin set the `dependsOnTime` before throwing the callback `SResultNeedTime`

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-03 18:35:34 +02:00
Remy
41009f79cc
Compiler: Make LF 1.14 the default output (#10394)
CHANGELOG_BEGIN

- [Compiler] Default compiler output LF version is now 1.14

CHANGELOG_END
2021-07-28 12:14:56 +02:00
akshayshirahatti-da
4b55f1ab6a
Connection pool for Contract Dao (#10359)
* Switch ContractDao to use a HikariCP connection pool
CHANGELOG_BEGIN
CHANGELOG_END

* missed conn pool changes for PostgresTest and ContractDaoBenchmark

* shutdown db access await threadpool and fix formatting

* custom pool sizes for Prod and Integration similar to DbTriggerDao

* cleanup contract dao connection pool

* simplify Dao shutdown

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

* remove redundant config setting

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

* fix code formatting issue, NonUnitStatments warning
2021-07-27 09:15:39 +01:00
Andreas Herrmann
7df9758c2f
Daml export: make paths relative to daml.yaml (#10388)
Previously data-dependencies in the generated daml.yaml file had a path
including the output-dir path itself. E.g.

```
data-dependencies:
- /some/out/path/deps/some.dalf
```

This worked fine so long as the output path was absolute. However, if
the output path is a relative path, then it might lead to "no such file"
errors during daml build.

This change always makes the generated data-dependencies paths relative
to the daml.yaml file.

changelog_begin
- [Daml export] The generated paths to data-dependencies DALFs are now
  relative to the generated daml.yaml. Fixes
  https://github.com/digital-asset/daml/issues/10378.
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-07-23 09:53:35 +00:00
Victor Peter Rouven Müller
8148137259
[JSON-API] Include the logging context in the ledger client for consistent logging (#10332)
changelog_begin

- [JSON-API] Connection tries from the json api to the ledger now include the logging context, more specifically the instance_uuid is included in each logging statement.

changelog_end
2021-07-21 10:05:45 +02:00
Remy
159728d716
LF: use Either by default in all archive reader API (#10295)
This is a follow up of #10277.
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-19 19:48:37 +02:00
nickchapman-da
0e09f3ba08
Remove optLocation field from transaction nodes. (#10301)
* Remove Optional[Location] field from transaction nodes.

xoptLocation

working but very messy!

cleanup PartialTransaction code

pass locationInfo in CompleteTransaction

dont pass locationInfo in SumittedTransaction

pass optLocation to CheckAuthorization

temp reinstate xoptLocation in ExerciseContextInfo

cleanup Conversions.scala

remove Optional[Location] field from transaction nodes.

CHANGELOG_BEGIN
CHANGELOG_END

* fix bad merge

* fix build after merge

* rename

* doc comment, and question
2021-07-19 13:03:30 +00:00
Samir Talwar
bd12170af2
participant-state: Remove the ParticipantId, PackageId, and Party aliases. [KVL-1002] (#10308)
* participant-state: Remove the `ParticipantId` alias.

This alias adds nothing. By using `Ref.ParticipantId` directly, many
packages can remove their dependency on the _participant-state_ package.

CHANGELOG_BEGIN
CHANGELOG_END

* participant-state: Remove the `PackageId` and `Party` aliases.

They don't add anything. Let's just use `Ref`.

* kvutils: Restore missing compat imports.
2021-07-19 12:31:25 +00:00
Miklos
0eba812109
Remove trace_context field from Ledger API [KVL-1021] (#10256)
CHANGELOG_BEGIN
* [Integration Kit] Removed trace_context field from Ledger API and its bindings as we now have trace context propagation support via gRPC metadata. If you are constructing or consuming Ledger API requests or responses directly, you may need to update your code.
CHANGELOG_END
2021-07-15 19:06:25 +02:00
Remy
a8f190214c
LF: change type from Try to Either in archive module (#10277)
* LF: change type from Try to Either in archive module

This is the first part of restructuring errors in archive module.
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END

* Apply suggestions from code review

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

* remove type alias

* apply stephen suggestion

* fix after rebase

* fix test

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-07-14 19:24:31 +00:00
Remy
caf85a2270
LF: rationalize archive Parser/Reader/Decoder (#10239)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-14 11:05:17 +02:00
Sofia Faro
b8e2198873
Separate traces from warnings in engine. (#10253)
* Separate traces from warnings in engine.

I decided to separate the engine warnings from the tracelog after all,
because I think it will make testing and maintenance easier in the
long run.

Part of #9947, follow up from #10179

changelog_begin
changelog_end

* scalafmt

* Apply suggestions from code review

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

* dont use case class for WarningLog

* revert TraceLog changes from last PR

* Scala 2.12 doesnt have ArrayBuffer.addOne :(

* remove isWarnEnabled check

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-07-13 14:24:27 +00:00
Remy
f19f5b0821
LF: Simplify DarReader (#10217)
This PR simplifies a bit DarReader and UniversalDarReader

This is a follow up of #10208.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-08 17:03:45 +02:00
Remy
41b8448b17
LF: Simplify archive reader. (#10208)
* LF: Simplify archive reader.

- decouple Reader and Decoder
- introduce case class to handle hash, proto payload, and version

CHANGELOG_BEGIN
CHANGELOG_END

* Address Moritz' review

* cosmetic
2021-07-07 19:56:40 +00:00
Samir Talwar
e7e8a5705b
daml-lf/data: Optionally truncate party names in structured logs. [KVL-996] (#10163)
* daml-lf/data: Truncate party names in log output, on request.

The party name can grow quite long, so we offer ledger implementors the
opportunity to truncate it in structured log output.

Unfortunately, because we use Logback through the global
`LoggerFactory`, there is no place to inject logging configuration. This
means we also need to use global, mutable state to configure logging
output. I have added a `LoggingConfiguration` class+object in Daml-LF
Data, which may not be the best place, but I can't think of a better
one right now. I suggest we leave it there until it has reason to grow,
at which point we may want to move it.

CHANGELOG_BEGIN
CHANGELOG_END

* logging-entries: Make `ToLoggingValue` mixin-able.

* participant-integration-api: Truncate parties in filters when logging.

* participant-integration-api: Cast to `Party` for logging.

Invalid input should not break the request at this point. No assertions.

* daml-lf/data: Move `Party to LoggingValue` to a new package.

This avoids the transitive dependency issue most of the time.

* daml-lf-data: Move the `Identifier` logging to another package.

Again, reduces the need for transitively depending on _logging-entries_.
2021-07-01 16:50:49 +00:00
Samir Talwar
eda1245311
daml-lf/data: Add a conversion from Ref.Identifier to LoggingValue. (#10157)
I am getting quite tired of (Bazel + Scala)'s attitude to transitive
dependencies.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-30 20:05:06 +00:00
Samir Talwar
888f02aa4d
ledger-api-common: There's only one way to order absolute offsets. (#10153)
Let's not mess around with injectable orderings.

This has the pleasant side effect of removing dependencies.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-30 14:17:59 +00:00
Samir Talwar
c929a14486
logging-entries: Split from contextualized-logging. [KVL-996] (#10149)
* logging-entries: Split from contextualized-logging.

This allows us to introduce it to Daml-LF without bringing in the
Logback, Logstash, and gRPC dependencies.

CHANGELOG_BEGIN
CHANGELOG_END

* logging-entries: Fix dependencies for 2.12.

* logging-entries: Missed one more Scala 2.12 dependency.

* release: Publish logging-entries.
2021-06-30 12:08:33 +00:00
Samir Talwar
c764fbe573
contextualized-logging: Introduce different logging types for more structure. [KVL-996] (#10134)
* contextualized-logging: Automatically convert logging values to strings.

For now, this has almost the same behavior, but it allows us to
customize the output in the future.

The main change is that the log format has gone from:

    context: {a=b, x=1, foo=bar}

to:

    context: {a: "b", x: "1", foo: "bar"}

* contextualized-logging: Move `writeTo` inside `LoggingValue`.

* contextualized-logging: Allow for more than just strings.

`null`, numbers, and sequences are now correctly logged.

The log format has gone from:

    context: {a: "b", x: "1", foo: "bar", parties: "[alice, bob]"}

to:

    context: {a: "b", x: 1, foo: "bar", parties: ["alice", "bob"]}

CHANGELOG_BEGIN
- The log output of Daml components has changed so that the structured
  part is closer to JSON. This allows us to distinguish and parse
  numbers and lists. If you are parsing this log output, you may need to
  change your parser.

  The log output has changed from:

  .. code-block::

     context: {a=b, x=1, foo=bar, parties=[alice, bob]}

  to:

  .. code-block::

     context: {a: "b", x: 1, foo: "bar", parties: ["alice", "bob"]}

CHANGELOG_END

* contextualized-logging: Extract the string serializer.

* Use non-string logging where possible.

* contextualized-logging: Split logging values from serialization.

So that callers don't have to know about Jackson.

* contextualized-logging: `SeqView` is `Iterable`. Don't need both.

* contextualized-logging: Make `ToStringToLoggingValue` a `val`.

Co-Authored-By: Stephen Compall <stephen.compall@daml.com>

* contextualized-logging: Add a transient dependency for 2.12 only.

This required more infrastructure than I thought it would.

* kvutils: Make it explicit that we're logging the hashes of archives.

The implicit was found to be a little confusing.

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-06-29 09:16:26 +00:00
Remy
3df2566305
Scenario: move Scenario Error Throwable to scenario package (#10075)
com.daml.lf.speedy.SErrorScenario => com.daml.lf.scenario.Error

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-28 12:04:57 +00:00
Remy
398300b76f
LF: Move Speedy Interpretation Error to transaction package (#10091)
to be accessible from any package

part of #9974

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-25 20:50:15 +02:00
Moritz Kiefer
d4150ac078
Refactor error reporting in Daml Repl (#10118)
* Refactor error reporting in Daml Repl

fixes #10098

As mentioned in that issue, the current behavior is a mess which
silently drops errors in certain cases. This PR switches things around
so that errors are reported to the client and we print them there
making sure that no error should ever get lost.

changelog_begin
changelog_end

* Bump timeout

changelog_begin
changelog_end
2021-06-25 14:08:44 +00:00
Moritz Kiefer
e4c1c58317
Run scenarios in off-ledger machine (#10070)
* Run scenarios in off-ledger machine

This PR builds on the previous PR that split scenario execution in two
different speedy machines and now actually makes the machine that runs
scenarios run in off-ledger mode just like we handle Daml Script.

This required a bunch of refactoring to make it nice so apologies for
the slightly large PR. Hopefully it’s still relatively easy to follow
and luckily it deletes more code than it adds.

changelog_begin
changelog_end

* Apply suggestions from code review

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

* review comments

changelog_begin
changelog_end

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2021-06-22 12:11:00 +02:00
Moritz Kiefer
febca5d62d
Use ScenarioRunner.submit in Daml Script (#10053)
* Use ScenarioRunner.submit in Daml Script

changelog_begin
changelog_end

* privatize ledger variable

changelog_begin
changelog_end

* drop space

changelog_begin
changelog_end
2021-06-17 17:12:45 +00:00
Moritz Kiefer
2b915e93da
Split scenario & ledger execution (#10039)
* Split scenario & ledger execution

This PR by no means aims to solve everything we can do here. It is
rather the minimal change that I could get to work that provides us
with one Speedy machine for scenario execution (which is still an
on-ledger machine to avoid having to change the callsites to much in
this PR) and one speedy machine per submission.

There is tons of cleanup we can do afterwards but this should
hopefully set the right foundations.

changelog_begin
changelog_end
2021-06-17 12:45:35 +02:00
nickchapman-da
5f0f5756bf
Define IncompleteTransaction for use by scenario-service (#9952)
* Define IncompleteTransaction for use by scenario-service

changelog_begin
changelog_end

* improve names as per review comments
2021-06-10 15:06:58 +00:00
Rafael Guglielmetti
1dc8472017
Fix variable name (#9927)
Fix typos

CHANGELOG_BEGIN
Small fixes to the doc
CHANGELOG_END
2021-06-08 19:15:07 +02:00
Victor Peter Rouven Müller
4037b1cd9e
Add metrics to the http json service (#9923)
* Introduce metrics in the http-json service

changelog_begin

[HTTP/JSON API]
- metrics reporting can now be chosen via the command line option --metrics-reporter (currently hidden), valid options are console, csv://, graphite:// and prometheus://
- metrics reporting interval can also now be chosen via a command line option --metrics-reporting-interval (currently hidden)

changelog_end

* Move MetricsReporter and it's dependencies into //ledger/metrics

* Restore non-ugly formatting for that one section in Endpoints.scala

* Update ledger/sandbox-common/src/test/lib/scala/platform/sandbox/cli/CommonCliSpecBase.scala

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

* Hide metrics option for http-json

* Propagate context exception for the parseUri function in MetricsReporter.scala

* Move cliHint value above parseUri function to have a better structure (it's used once before it's defined and once after it's defined, which is weird to me)

* Use better value name than optMr & optFd in cliopts Metrics.scala

* Remove import order changes & whitespace changes

* Revert usage of Nanoseconds for conversion from scala duration to java duration to usage of Seconds

* Shorten hideIfRequested function

* Fix another rearranged import

* Fix another whitespace removal

* Readd metrics cli option to sandbox after refactoring

* Add missing return type annotation for invalidRead in MetricsReporter

* Readd newline in https OptionParser.scala

* Remove unecessary import

* Update ledger/sandbox-common/src/main/scala/platform/sandbox/cli/CommonCliBase.scala

Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>

* Align setter & config name for metricsReportingInterval setting too in CommonCliBase.scala

* Rename http_json_api in Metrics.scala of metrics project to HttpJsonApi

* Reformat CommonCliBase.scala of sandbox-common project

* Fix CommonCliSpecBase test of sandbox

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>
2021-06-08 15:54:01 +00:00
Remy
7bc925e4d2
LF: Factorize the logic for AST lookup (#9871)
Factorize the logic for AST lookup in
 - compiler 
 - type checker 
 - preprocessor
 - script triggers 
 - some tests

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-03 13:32:56 +02:00
mziolekda
8fc45432d1
Uniform configuration of the command service across all ledgers (#9839)
* Uniform configuration of the command service across all ledgers

* CHANGELOG_BEGIN
Modify command line options of the ledgers based on the kvutils/app library:
- Remove max-commands-in-flight sub-option from the participant group.
- Add command service configuration options in line with sandbox and daml-on-sql: max-commands-in-flight, max-parallel-submissions, input-buffer-size
CHANGELOG_END
2021-05-31 16:22:00 +00:00
Remy
0c12259c04
Speedy: Use SAny instead of SAnyException to reperesent AnyExcpetion (#9819)
This PR simplifies the internal of Speedy by factorizing SAny and
SAnyException. By side effect we also get the comparison of LF
AnyException values that was not implemented before.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-27 23:43:26 +00:00
Andreas Herrmann
aedb9a823b
Daml ledger export test - normalize SDK version (#9800)
changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-05-26 10:08:37 +00:00
Andreas Herrmann
fa0815bc11
Example export (#9756)
* Pretty print daml.yaml in Daml ledger export

changelog_begin
changelog_end

* Use dynamic port in example-export generation

* Add daml.yaml to Daml ledger export golden test

* Sort data-dependencies for reproducibility

* Replace hashes in data-dependencies with a placeholder

To avoid test failure when any of these change.

* normalize data-dependencies path in scala client

So that the bazel build action is more reproducible itself.

* Fix Scala 2.12 build

* Factor out deleteRecursively

changelog_begin
changelog_end

* Generate ledger export in temp-dir

Build actions are not sandboxed in Windows. The ledger export will also
created a directory `deps` to store all the DALFs in. On Windows this
directory may persist across Bazel builds and may cause errors due to
attempts to overwrite an existing directory.

To avoid these issues the ledger export is generated into a temporary
directory and only the wanted files are moved to the expected output
locations in the bazel execroot afterwards.

* Close source

* Use replace instead of replaceFirst

The latter matches regex pattern instead of just substring matching
which fails with Windows paths due to `\` being interpreted as an escape
character.

* Normalize Windows \ to Unix /

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-05-21 09:36:25 +02:00
Victor Peter Rouven Müller
beb2d138f2
Add cli option & system property to enable json only logging for http json service (#9725)
changelog_begin
- [Ledger HTTP Json Service] Logging output can now be in JSON either via providing the cli option `--log-encoder json` or via setting the env var `LOG_FORMAT_JSON=true`
changelog_end
2021-05-20 13:28:34 +00:00
Sofia Faro
2ba5ca7ca2
Make DA.Assert throw AssertionFailed instead of GeneralError (#9747)
* Make DA.Assert throw AssertionFailed instead of GeneralError

changelog_begin

- [Daml Standard Library] `assert`, `(===)`, and other assertion functions (see DA.Assert) now use a new `CanAssert` typeclass constraint instead of `CanAbort`, in preparation for exceptions support.

changelog_end

* Add CanAssert instances for Script and Trigger.

* buildifier-fix

* update script test runner output

* Fix flag and add tests.

* update script test runner again
2021-05-20 12:01:50 +00:00
Andreas Herrmann
10177d239e
Add golden test for example Daml ledger export (#9732)
* client_server_build - user defined outputs

Let the user define a list of output files on client_server_build.

changelog_begin
changelog_end

* daml-script runner expose main(config)

changelog_begin
changelog_end

* Add an example Daml ledger export to the docs

* Build Daml ledger export

changelog_begin
changelog_end

* sh_inline_test

Support toolchain arguments to sh_inline_test. Usefuly for make variable
expansion, e.g. for the POSIX toolchain.

* Add a golden test for Daml ledger export

* Test args files as well

* Use sed from POSIX toolchain

* Add normalization comment to top-level comment

* Ignore trailing CR on Windows

The JSON formatting of the args file uses Windows line endings on
Windows. Therefore, the args.json output technically differs from the
expected output. We're happy to ignore the difference in CRLF here.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-05-19 12:02:14 +00:00
Miklos
cd9933328a
runtime: Damlification of Scala files (#9668)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-17 10:28:50 +02:00
Moritz Kiefer
142767c421
Split daml test-script code into a separate library (#9674)
Currently we have the following dependency chain:

1. The compiler depends on the scenario service for daml test
2. The scenario service depends on Daml Script
3. Daml Script depends on the Sandbox code only for daml test-script

The last one can easily be split. The scenario service does not care
about this code.

This means that now if we change ledger code, at least not all
compiler tests are going to rerun.

Verified that this actually breaks the dependency fully via

```
bazel query 'somepath(//compiler/damlc/tests:packaging, //ledger/participant-integration-api/...)'
```

changelog_begin
changelog_end
2021-05-13 12:58:31 +02:00
Victor Peter Rouven Müller
625592e7b5
Rename CorrelationID to InstanceUUID as it has been used wrongly. (#9672)
This ensures that we follow our internal guidance on logging correctly.

changelog_begin
changelog_end
2021-05-12 16:46:14 +00:00
Stephen Compall
ca9e89b3da
check whether collection.compat is unused when compiling for Scala 2.12 (#9604)
* check whether collection.compat is unused when compiling for Scala 2.12

- Instead of always suppressing warnings for collection.compat._,
  we should only do it for Scala 2.13

- We can also reduce boilerplate by automatically adding this
  option when both silencer_plugin and collection-compat are
  present

CHANGELOG_BEGIN
CHANGELOG_END

* remove unused import

* remove another unused import

* remove even more unused imports

* missed compat dependency

* more missed compat dependencies

* missed compat dependency

* use scala_deps in scaladoc_jar

- #8423 inlined the major version expansion, but this seems to
  have been prior to proper support by scaladoc_jar

* restore custom handling of participant-integration-api

- fixing scaladoc_jar isn't worth it for a single case, as with
  deps vs scala_deps
2021-05-11 21:54:14 +00:00
Victor Peter Rouven Müller
4f0ceff7a2
Fix #7170 (#9618)
CHANGELOG_BEGIN

http-json:
- add contextual id as logging context to distinguish different application runs in logs
- add request id as logging context to distinguish different http requests within an application run
- add for non-static endpoints trace logs which show how long processing it took in ns

CHANGELOG_END
2021-05-11 14:15:17 +00:00
Andreas Herrmann
f7b33d93fb
Authorization for daml script exports (#9629)
* Add token parameter to daml export

changelog_begin
changelog_end

* Add test case for --access-token-flag

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-05-11 09:44:52 +02:00
Remy
0d1f3db8a4
LF: refactor builtin exceptions in Speedy (#9605)
follow up #9595.

part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-11 09:18:27 +02:00
Andreas Herrmann
26a8011ba5
TLS for Daml Script exports (#9626)
* Daml ledger export add TLS command-line flags

changelog_begin
changelog_end

* Add ConfgSpec test for TLS options

* Fix path comparison on Windows. (`/` vs `\`)

* Fix Scala 2.13

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-05-10 13:29:07 +00:00
Remy
871279f3a6
LF: extends LF command with Fetch and Lookup (#9587)
This PR includes  :

- Adding ApiCommand to distinguish between generic command (that are
  accepted by the engine) and command that are accepted by the ledger
  API.

- Reimplement Canton's reinterpret method using commands instead of
  node.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-07 19:19:25 +02:00
Andreas Herrmann
f51145cb88
Support mapping from old to new party ids in daml exports (#9591)
* Factor out all encoding components

* Provide TextMap party mapping instead of record

This allows users to customize the mapping from old party names to new
party names.

* Emit bindings for parties at beginning of export

For better readability, to avoid `getParty "Alice" parties` all over the
place.

* getParty --> lookupParty to avoid conflict with Prelude

* Use DA.Traversable.mapA over TextMap

* Update integration test

* Update args.json

* Update the daml export docs

changelog_begin
* [Daml export] Users can now define a mapping from parties in the
  original ledger state to parties to be used when recontructing the
  ledger state. The ``parties`` component of the argument to the
  generated export script now takes a mapping from old party name to new
  party name.
changelog_end

* getContract --> lookupContract for consistency with lookupParty

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-05-07 15:44:40 +02:00
Victor Müller
26a53d8469
Add logging command line option to ledger http service (#9581)
CHANGELOG_BEGIN

- [Ledger HTTP Json service] Logging can now be configured via the `--log-level` cli argument. Valid values are `error`, `warn`, `info` (default), `debug`, `trace`

CHANGELOG_END

Co-authored-by: victor.mueller@digitalasset.com <mueller.vpr@gmail.com>
2021-05-05 17:36:22 +00:00
Moritz Kiefer
a27b2c56bc
Address more exception todos (#9582)
* Address more exception todos

A bit of a kitchen sink PR to address a bunch of the trivial todos
that didn’t seem worth splitting out into separate PRs.

changelog_begin
changelog_end

* Revert changes to TransactionSpec

changelog_begin
changelog_end
2021-05-05 16:00:08 +02:00
Andreas Herrmann
121ded3565
Accept a comma-separated list of parties for daml ledger export (#9568)
* Add test suite for CLI parser and fix --end

changelog_begin
changelog_end

* Accept a comma separated list on --party

changelog_begin
changelog_end

* Use scalaopts list parsing support

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-05-04 14:45:54 +00:00
Andreas Herrmann
e8d25b255e
Handle references to missing contracts (#9553)
* Take user defined mappings for unknown contracts

* Remove unused `allocateParties` helper

These are now provided in `args.json`.

* No longer fail on missing contract ids

* Generate a default args.json

* Configure daml start to run the export

Configures init-script and script-options such that `daml start` will
execute the export script with the default `args.json` input.

Configures navigator to display the default parties.

* Update daml export integration test

Input format has changed.

* Update documentation for daml ledger export

changelog_begin
* [Daml export] Daml ledger export now handles references to missing
  contracts. The generated export script takes a mapping from unknown
  contract ids to replacement contract ids as a parameter. Users can
  prepopulate the ledger with replacements of missing contracts and
  configure the export script to reference these replacements.
  The generated export script no longer exposes ``testExport`` as an
  entry point, instead Daml export generates a default input file
  ``args.json`` that can be used to execute the ``export`` function from
  ``daml script`` or ``daml start``.
changelog_end

* Reinstante testExport & allocateParties

Convenient for testing in Daml IDE or on ledgers that don't have
automatic party allocation.

* Add docstrings to the generated Daml export script

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-05-03 15:52:40 +00:00
Moritz Kiefer
ca012c3b54
Improve script errors when the endpoint is not the JSON API (#9550)
fixes #9532

changelog_begin
changelog_end
2021-05-03 09:13:49 +00:00
Andreas Herrmann
8678791653
Separate Daml export creation from encoding (#9542)
* Merge ACS encoding with transactions

Both can be first converted to Actions and only then encoded.

* Check for unknown contract id references in ACS and tree

* Separate construction and encoding of export

* Factor out export actions encoding

* inline encodeTransactionTreeStream

* Add test-cases for cid references in export

* Don't crash on unknown contract reference in ACS

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-05-03 10:43:32 +02:00
Moritz Kiefer
4aca199bbd
Upgrade to Scala 2.13.5 (#9528)
changelog_begin
changelog_end
2021-04-29 13:05:57 +00:00
Samir Talwar
e1af564bcc
Switch from @silent to @nowarn. (#9498)
* Switch from `@silent` to `@nowarn`.

This annotation is native to Scala 2.12.13+ and 2.13.2+. It replaces
most usages of `@silent`.

I had to get creative about a couple of use cases that didn't work.
Specifically:

  1.  Suppressing deprecation warnings works, but Scala 2.12 erroneously
      complains that the `@nowarn` is unnecessary.  I had to suppress
      this warning too with `-Ywarn-unused:-nowarn`.
  2.  I can't seem to suppress the warning, "The outer reference in this
      type test cannot be checked at run time." Instead, I have
      refactored the code to remove the warning.

We still need to use the silencer plugin to suppress some warnings about
unused imports (because of compatibility between Scala 2.12 and 2.13),
but this means we no longer need the library, and therefore it is not a
transitive dependency that downstream consumers need to worry about.

CHANGELOG_BEGIN
CHANGELOG_END

* Add some comments around `@nowarn` support.

* language-support/scala: Fix a warning suppression.

* Revert to the default warnings.

Compatibility was complaining.
2021-04-26 19:46:14 +00:00
Moritz Kiefer
176b17ae47
Move localContracts to PartialTransaction (#9475)
This makes it easier to do a bunch of other checks around contract
keys in PartialTransaction.

changelog_begin
changelog_end
2021-04-22 22:11:50 +02:00
Moritz Kiefer
4e1c5fedb3
Check visibility for by-key operation of local contracts (#9470)
* Check visibility for by-key operation of local contracts

fixes #9454

I tried out two approaches for this:

1. The one here where we add a new callback. This has the advantage
   that the engine remains oblivious to visibility checks. They are all
   done outside and the engine doesn’t even know about the reading
   parties.
2. Make the engine aware of the reading parties. A start of that is in
   #9458.

Both work in principle but I ended up going for 1 in the end. Doing
half of the visibility checks outside the engine and half inside just
seems worse than the current state.

changelog_begin

- [Daml Engine] Fix a bug where it was possible to
  fetch/lookup/exercise a local contract by key even if the reading parties
  are not stakeholders. See #9454 for details.

changelog_end

* Disable new test on Canton

changelog_begin
changelog_end

* Exclude from compat tests

changelog_begin
changelog_end

* s/LocalLookup/LocalFetch/

changelog_begin
changelog_end

* Address review

changelog_begin
changelog_end
2021-04-22 21:39:12 +02:00
Andreas Herrmann
e525382dc2
Optionally emit setTime actions in daml export (#9469)
* Add setTime flag

changelog_begin
* [Daml export] Enable the ``--set-time`` flag on
  ``daml ledger export script`` to replicate transaction time stamps.
  This only works on ledgers operating in static time mode.
changelog_end

* Dump.scala --> Export.scala

So that the file name and class name match.

This was forgotten in 5e652bb2f8.

* Implement optional setTime actions

* Define Action type encompassing SetTime and Submit

Factor out construction of submit actions interleaved with setTime
actions.

This makes it easier to test the corresponding functionality in
isolation.

* EncodeSetTimeSpec

* ActionsFromTreesSpec

* update docs on daml ledger export

* Enable --set-time in integration test

To ensure that the generated code actually compiles

* Fix date/time encoding

Requires additional imports for DA.Time and DA.Date.
Requires qualified references to DA.Time.time, DA.Date.date, and
DA.Date.MONTH.

* Fix Scala 2.13

* Move setTime parameter to Action.fromTrees

* Move export transaction time docs out of caveats

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-04-22 12:10:05 +00:00
Andreas Herrmann
5e652bb2f8
Add daml export script command to Daml assistant (#9414)
* rename "dump" to "export"

* Add Daml export command to assistant

* Make daml export script a subcommand of daml export

* daml-assistant IT for daml export script

* Expose export as daml ledger command (hidden for now)

Add Haskell side parser for ledger export flags

changelog_begin
* [Daml export] New feature: Use ``daml ledger export script`` to
  generate a Daml script that will reconstruct a given ledger state.
  This is an early access feature.
changelog_end

* Update integration test

* Remove daml export - it's daml ledger export now

* integration-test set ledger port

The integration tests don't configure the port in the project config,
but on the command-line, and they don't use the default value.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-04-16 10:53:49 +00:00
Robert Autenrieth
301dcd9e40
DPP-316: Enable the use of the append only index database (#9368)
* Enable append-only schema in index

changelog_begin
changelog_end

* Enable append-only schema in indexer

* Add CLI flags to configure append-only indexer

* Fix CLI flag name

* Remove unused parameter

* Change CLI flag description

... it's independent of Postgres

* Refactor how indexer config is specified in CLI

* Upper case constants
2021-04-12 21:11:03 +00:00
Moritz Kiefer
867e62520d
Add exception handling to Daml Script (#9324)
* Add exception handling to Daml Script

changelog_begin
changelog_end

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

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

* Add more test cases

changelog_begin
changelog_end

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-04-07 18:48:24 +02:00
Andreas Herrmann
4edefbc2d9
Generate DALFs for data-dependencies in Daml script dump (#9265)
* Don't mark dalfs in data-dependencies as main dalfs

This causes the LF version consistency check to fail on DALF data
dependencies that were generated with a different LF version and also
occur in dalfsFromDependencies. E.g. a dalf like `daml-prim-DA-Types`
triggers this issue.

changelog_begin
- [DAML Compiler] DALFs in data-dependencies that are imported directly
  now require corresponding `--package` flags to make them visible. The
  reason for this is that DALFs that are data-dependencies are no longer
  treated as main DALFs.
changelog_end

* Daml script dump write DALFs instead of DARs

Produces DALFs for dependencies and adds them to the data-dependencies.
Package flags for main DALFs are added to the build options.

* Update test-cases

* address review

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-31 10:14:56 +02:00
Moritz Kiefer
eb91dcf853
Only walk list once in splitAt (#9275)
* Only walk list once in splitAt

No idea if that makes a significant difference anywhere but walking
the list twice is definitely not faster.

changelog_begin
changelog_end

* Avoid hardcoded locations in tests

changelog_begin
changelog_end
2021-03-30 19:26:59 +02:00
Stefano Baghino
3fa05804bf
Make non-repudiation integration exclusive to enterprise edition (#9219)
* Make non-repudiation integration exclusive to enterprise edition

Closes #9182

changelog_begin
changelog_end

* Address https://github.com/digital-asset/daml/pull/9219#discussion_r599578614

* Address https://github.com/digital-asset/daml/pull/9219#pullrequestreview-618605511

* Add aliases for CE test targets, thanks to @S11001001 for the feedback

* Uh, turns out you need a main...

* Address https://github.com/digital-asset/daml/pull/9219#discussion_r599717526

* Add missing dependency for Oracle
2021-03-24 20:25:47 +01:00
Andreas Herrmann
eb80e7b32e
Improve syntax for selecting contract ids from a transaction tree (#9216)
* Daml.Script fromTree, created(N), exercised(N)

Implements more readable transaction tree accessors. E.g.

```
let contract_1_0 = fromTree tree $
      exercised @Module.Template "Choice" $
      created @Module.Template
```

instead of

```
let contract_1_0 = createdCid @Module.Template [0, 0]
```

changelog_begin
changelog_end

* Use fromTree in daml script dump

changelog_begin
changelog_end

* Update tests

* Remove now unused createdCid

* Avoid zip of layer selectors and events

Addresses https://github.com/digital-asset/daml/pull/9216#discussion_r600243370

The zip approach would be misaligned if an event has `Kind.Empty`. This
circumvents the issue by only iterating over non-empty events.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-24 12:30:27 +00:00
Moritz Kiefer
b7aedb477b
Remove contract arguments from localContracts (#9207)
We already store them in cachedContracts, no reason to store them
twice. This should also be slightly more efficient since we only do
one lookup in cachedContracts in the common case and only look at
localContracts if there’s a wrongly typed contract. I doubt it’s
measurable but at least it’s not worse.

changelog_begin
changelog_end
2021-03-23 09:49:53 +00:00
nickchapman-da
c1cf2756a8
add rollback node to transactions (#9178)
* New transaction node: NodeRollback. Fixup every match with a crash + TODO.

changelog_begin
changelog_end

* remove 3 methods from NodeRollback which are not needed to fulfill its interface

* add override to remaining 4 methods implemented in body of NodeRollback

* remove unrequired 2nd type parameter (Cid) from NodeRollback

* add missing 8020 marker
2021-03-23 08:49:25 +00:00
Moritz Kiefer
7a41ee6ce0
Cache contract fetches in speedy (#9192)
* Cache contract fetches in speedy

This PR adds a cache to speedy to cache contract fetches and
information only derived from the contract argument, namely,
signatories, observers and keys.

The cache is engine-internal so on the first fetch of a global
contract in a transaction, we recompute that information.

This does not change observable semantics:

Ledgers must be consistent within a transaction so caching is safe. We
still recompute signatories, observers & keys the first time so if
they fail, we still blow u.

We also never compute more than before. While `SBUFetch` itself did
not compute that information, it was immediately folowed by either
`SBUBeginExercise` or `SBUInsertFetchNode` which compute that
information.

We also keep the optimization that we do not have to compute key and
maintainers on by-key operations

On the collect authority benchmark, this is around a ~1.48x
improvement which is pretty decent.

changelog_begin
changelog_end

* Remove dead code

changelog_begin
changelog_end

* Less stupid error handling

changelog_begin
changelog_end

* Add a test for wrongly typed contract ids

changelog_begin
changelog_end

* Check type of cached contracts

changelog_begin
changelog_end

* Update daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/SBuiltin.scala

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

* Add tests for wrongly-typed contract ids to EngineTest

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-03-22 13:39:02 +01:00
Andreas Herrmann
587a9c95d0
Recognize (some) exerciseByKey commands in Daml script dumps (#9185)
* Take nested consuming choices into account

When determining whether a command is considered a simple command.

changelog_begin
changelog_end

* Add test-case for nested consuming simple createAndExerciseCommand

* Define exerciseByKeyCmd type

changelog_begin
changelog_end

* Recognize exerciseByKeyCmd

changelog_begin
changelog_end

* Test case to identify exercise by key

* test-cases for simple exerciseByKeyCommand

* test encoding of exerciseByKeyCmd

* Refactor ExerciseCommand encoding

* Drop unnecessary lazy

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-19 08:44:17 +00:00
Stefano Baghino
f0c8b1240d
Integrate non-repudiation into HTTP JSON API (#9180)
* Integrate non-repudiation into HTTP JSON API

changelog_begin
changelog_end

Closes #9094

* Address https://github.com/digital-asset/daml/pull/9180#discussion_r596400828

* Address https://github.com/digital-asset/daml/pull/9180#discussion_r596408663

* Address https://github.com/digital-asset/daml/pull/9180#discussion_r596402533

* Address https://github.com/digital-asset/daml/pull/9180#discussion_r596624708

* Address https://github.com/digital-asset/daml/pull/9180#discussion_r596624174

* Solve compilation error in daml-script

* Address https://github.com/digital-asset/daml/pull/9180#issuecomment-801875959

changelog_begin
- [JSON API] The JAR for the HTTP JSON API is no longer published on
Maven, use the fat JAR as indicated in the documentation.
changelog_end
2021-03-18 15:15:52 +00:00
Andreas Herrmann
dbd8806848
Distinguish all four types of submits (#9179)
changelog_begin
changelog_end

Adds case classes for the four cases
- `submit`
- `submitMulti`
- `submitTree`
- `submitTreeMulti`

Also groups them by single/multi submitter and simple/tree commands
using additional traits.

The logic to classify submits is called earlier to avoid identifying
commands twice, as we did before to correctly identify referenced
contract ids taking `createAndExerciseCmd` into account.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-18 12:54:19 +01:00
Andreas Herrmann
d5ca22815d
Recognize simple createAndExercise commands (#9154)
* Identify simple createAndExercise command

changelog_begin
changelog_end

* Test simple createAndExercise command

* Don't count created and then consumed contracts

* Test nested createAndExercise

* Expand comment about consuming choice

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-18 09:58:34 +00:00
Andreas Herrmann
370f290d3d
Handle createAndExecuteCmd (#9150)
* Identify CreateAndExerciseCommand

changelog_begin
changelog_end

* Add test case for Command.fromTree

* Fix test hierarchy

* SimpleEvent --> SimpleCommand

* encodeSubmitSimpleCommands

* Use encodeCmd in encodeTree

* Use encodeSubmitSimpleCommands for ACS

* Remove unused code

* encodeTree createAndExerciseCmd test case

* treeReferencedCids --> cmdReferencedCids

* Test cmdReferencedCids on createAndExercise

* Handle cid references from createAndExercise correctly

* Rename test suite

* fix indentation

* CreateAndExercise: Only adjacent create & exercise events

Addresses https://github.com/digital-asset/daml/pull/9150#discussion_r595366589

* Add test case for non-adjacent create&exercise

* Scala 2.13

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-17 10:36:53 +00:00
Andreas Herrmann
7430590c1d
Only track cids referenced in root events (#9131)
* Only cids referenced in root events count

changelog_begin
changelog_end

* Add regression test for inner event cid references

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-12 17:55:34 +01:00
Andreas Herrmann
2be1a964f8
Avoid submitTree on simple exercise commands (#9080)
* Factor out traverseEventInTree

* Generalize encodeSubmitCreated to simple exercise

Where simple exercise events are those that cause one contract creation
and return its contract id.

* Use submit on simple exercise commands

* Define type to track simple events

changelog_begin
changelog_end

* encode SimpleEvent

* SimpleEvents from tree

* Test SimpleEvent.fromTree

* Test encodeSubmitSimpleEvents

* Match Kind.Empty explicitly

* Use ListBuffer

* Factor out treeEventCreatedCids

* foldMap

* Scala 2.12 vs 2.13

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-11 11:41:04 +00:00
Moritz Kiefer
e04bd91eda
Move Daml Profiler to EE version of sandbox/sandbox-classic (#9054)
* Move Daml Profiler to EE version of sandbox/sandbox-classic

This splits Sandbox targets into EE/CE targets and exposes the option
in the EE version. The option still exists in the CE option for now
until we have released EE artifacts to not break users that might know
about it without an alternative.

There is also a small test that makes sure that this actually works
since classpaths are dumb and it didn’t work at first.

changelog_begin
changelog_end

* Fix publish target

changelog_begin
changelog_end

* Publish transitive dep

changelog_begin
changelog_end

* I hate bash

changelog_begin
changelog_end
2021-03-09 19:35:14 +01:00
Gary Verhaegen
7859bc13e1
inline help: scripts JSON API clarification (#9057)
* inline help: scripts JSON API clarification

While writing a forum response and trying to use `daml script` against
the JSON API, I was a bit confused by the existing help texts.

CHANGELOG_BEGIN
CHANGELOG_END

* thanks, scalafmt, that's very useful feedback
2021-03-09 16:01:22 +00:00
Moritz Kiefer
5d88c08832
Bump ghcide (#9041)
* Bump ghcide

Includes https://github.com/digital-asset/daml-ghcide/pull/13 meaning
we can now remove the hacks for missing signatures

changelog_begin

- [Daml Compiler] Fix a bug where passing `--ghc-option=-Werror` also
  produced errors for warnings produced by `-Wmissing-signatures` even
  if the user did not explicitly enable this.

changelog_end

* Bump to merged commit

changelog_begin
changelog_end
2021-03-05 18:17:28 +01:00
Moritz Kiefer
0281b442b8
-Werror all the things (#9027)
We used to do this for some packages but it broke cpp. I don’t
actually know why it doesn’t do that anymore but I’ll gladly accept
that fact and turn it on everywhere.

changelog_begin
changelog_end
2021-03-04 19:08:59 +01:00
Moritz Kiefer
2c08586d33
Expose Daml stacktraces for Daml Script errors (#9025)
* Expose Daml stacktraces for Daml Script errors

This finally plugs together the pieces from the previous PRs to
provide stacktraces on any ScriptF command (and thereby anything
involving an interaction with the ledger).

fixes #8754

changelog_begin

- [Daml Script] When running Daml Script on the command line you will
  now see a Daml stacktrace on failures to interact with the ledger
  which makes it significantly easier to track down which of the calls
  fails. By default, you will only get the callsite of functions like
  `submit`. To extend the stack trace, add `HasCallStack` constraints
  to functions and those will also be included.

changelog_end

* Fix non-determinism in tests

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end
2021-03-04 16:13:50 +01:00
Moritz Kiefer
65fbcfe8e9
Move execution of commands out of Runner (#9009)
This PR extracts the implementation of the individual commands out of
Runner and into the commands. Turns out, object oriented programming
is good actually.

This is another prerequisite for including stack traces. With this PR
landed, it should be quite easy to adapt Runner to rethrow failed
futures including the daml stacktrace.

changelog_begin
changelog_end
2021-03-04 10:07:36 +01:00
Moritz Kiefer
32dc8b007b
Include stack traces for all ScriptF commands (#8999)
This PR adds stack traces to all ScriptF commands and handles those in
the converter. Those stack traces are not yet used. To ease review,
I’ve left that for a separate PR. The plan is to use this to tackle
https://github.com/digital-asset/daml/issues/8754.

changelog_begin
changelog_end
2021-03-03 15:07:09 +01:00
Andreas Herrmann
926949e503
Use single party submit/submitTree where appropriate (#8995)
* Move [] into submit

* Use submit instead of submitMulti for single party

changelog_begin
changelog_end

* Test multi-party submission

* Factor out construction of submit command

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-03 14:16:48 +01:00
Moritz Kiefer
a40b4a978e
Factor out "parsing" of ScriptF constructors (#8984)
I was trying to add stacktraces and this giant pattern match got
really annoying so this PR tries to improve the situation somewhat by
factoring out the parsing into a separate module. There is more stuff
we can do here but this is at least a start.

changelog_begin
changelog_end
2021-03-03 11:05:51 +01:00
Andreas Herrmann
65101e37d0
Batch creation of ACS (#8978)
* Implement batching of ACS submits

* Configure ACS batch size

changelog_begin
changelog_end

* Add tests for ACS batching

* Avoid empty lines in dump

* Stream --> LazyList

* use grouped

* Bump default ACS batch size to 10

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-02 14:00:03 +01:00
Moritz Kiefer
ec36066986
Split LedgerInteraction into different files (#8975)
Pure shuffling around there is no logic change in here. I keep getting
lost in the 1.4k LedgerInteraction file so this client splits it up
into a 4 different files to make it a bit easier to navigate.

changelog_begin
changelog_end
2021-03-01 16:27:34 +01:00
Andreas Herrmann
ddf8e13705
Helpers to create test ACS and TransactionTree (#8961)
* Helpers to create test ACS and TransactionTree

changelog_begin
changelog_end

* use mutable count

c62fff7921 (r583743837)

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-02-26 16:41:36 +00:00
Andreas Herrmann
4fcd2b833f
Avoid submitTree for a sequence of creates (#8952)
* use scalaz.std.iterable

* Use submitMulti for sequence of creates

Instead of submitMultiTree, which is not necessary in such cases.
Avoids redundant binds, i.e. when we only bind one result and it is from
the last action.

changelog_begin
changelog_end

* Extend EncodeTreeSpec

* Factor out encoding created events

* Factor out encodeSubmitCreatedEvents

* Remove redundant encodeSubmitCreatedEvent

* Test encoding multiple creates

* Drop redundant case

* Fix duplicate created event

* Avoid .last

* Use traverse

* Avoid silently discarded return values

* mkCreate helper in EncodeTreeSpec

* mkExercised helper in EncodeTreeSpec

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-02-26 11:29:45 +00:00
Andreas Herrmann
d0e8d696a0
Use ContractId and Party types instead of plain String (#8914)
* Use com.daml.ledger.api.refinements.ApiTypes.ContractId

https://github.com/digital-asset/daml/pull/8898#discussion_r579148842

changelog_begin
changelog_end

* Use com.daml.ledger.api.refinements.ApiTypes.Party

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-02-22 17:25:09 +00:00
Andreas Herrmann
240f7957a3
Factor out utilities from com.daml.script.dump.Main (#8912)
* Factor out getACS and getTransactionTrees

https://github.com/digital-asset/daml/pull/8898#discussion_r579146541

changelog_begin
changelog_end

* Factor out contracts and tx-trees pkg-references

changelog_begin
changelog_end

* Factor out writeDump

changelog_begin
changelog_end

* Move references helpers to TreeUtils

https://github.com/digital-asset/daml/pull/8912#discussion_r580396852

Also, use `scalaz.std.iterable._` in `TreeUtils`.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-02-22 17:07:31 +00:00
Andreas Herrmann
68dfcc1d57
Support starting script dumps from a given offset (#8898)
* Start Daml Script Dump after an offset

changelog_begin
changelog_end

Before this offset we reproduce the ACS with simple `createCmd` command
submissions.

This current approach does not support contracts in the ACS that
reference other contracts outside the ACS, e.g. archived contracts.

* Unit test for encodeCreatedEvent

* Factor out operations from Daml Script IT test

* IT fresh tmpDir for each test case and sandbox around all

* Test Iou dump at different offsets

* Use "begin" for LEDGER_BEGIN

https://github.com/digital-asset/daml/pull/8898/files#r579144131

* unknownCidRefs

* Avoid unnecessary getTransactionTrees

* view.mapValues

* topoSortAcs fixes

* foldMap

* fmt

* warning: Unused import `import scala.collection.compat._`

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-02-19 18:10:54 +01:00
Moritz Kiefer
efe0f4a096
Include --target flags in daml script dumps (#8872)
As evidenced by #8856, daml script dumps currently fail to compile if
we generate a dump including templates which are newer than the
default LF version in the compiler. This PR addresses this by
including a --target flag in the generated daml.yaml.

changelog_begin
changelog_end
2021-02-17 12:07:23 +01:00
Moritz Kiefer
2c469c067f
Move conversion out of unsafeSubmit (#8864)
Spun out of #8863. This seems cleaner, more consistent with how we
handle the conversion in submitTree and it has the nice side effect
that it means that conversion now only happens after comitting which
is crucial for #8863.

changelog_begin
changelog_end
2021-02-17 10:25:38 +01:00
Andreas Herrmann
c8a053c16d
Only bind contract ids that are used (#8838)
* treeCids --> treeCreatedCids

* Only bind referenced contract ids

Adds an additional traversal of the tree to determine all referenced
contract ids.

Filters out contract ids that are never referenced before creating
bindings for them.

changelog_begin
changelog_end

* Add treeReferencedCids unit tests

* Add encodeTree unit tests for contract id bindings

* Collect cids in created arguments as well

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-02-12 17:32:12 +00:00
Moritz Kiefer
2558843bc5
Port //daml-script/... to Scala 2.13 (#8831)
* Port //daml-script/... to Scala 2.13

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end
2021-02-12 13:01:58 +00:00
Moritz Kiefer
51ca3eb1ab
Improve daml script dump testing infrastructure (#8829)
This PR adds a generic function to compare to transaction trees (or
rather sequences thereof) modulo alpha equivalence wtr to contract ids
and party ids.

This allows us to abstract away the concrete integration test for Daml
Script dump we had before and turn it into a generic process:

1. Run some setup code to generate transactions.
2. Query and store transaction stream.
3. Create the dump, build it and run it for a different set of
parties.
4. Query and store transaction stream for new parties.
5. Diff transaction streams.

This PR does not change tests or add new ones. I think it might be
nice to use Daml Scripts for 1 as well but I’ll leave that for a
separate PR. The infrastructure here already supports this.

fixes #8772

changelog_begin
changelog_end
2021-02-12 13:31:21 +01:00
Gerolf Seitz
ad161d7f78
Make database connection pool size configurable (#8816)
[ledger-api-server] Make database connection pool size configurable

CHANGELOG_BEGIN
[Daml Driver for PostgreSQL]: Added CLI option --database-connection-pool-size
to configure the size of the database connection pool
[Integration Kit]: Added the CLI options api-server-connection-pool-size and
indexer-server-connection-pool-size to configure the database connection pool size
for the Ledger API Server and the indexer respectively.
CHANGELOG_END
2021-02-12 12:05:47 +01:00
Moritz Kiefer
8747b056a3
Factor out shared DAR encoder (#8794)
* Factor out shared DAR encoder

changelog_begin
changelog_end

* Update daml-lf/archive/encoder/BUILD.bazel

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

* Add a version of encode that takes a Path and document stream closing

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2021-02-09 13:53:46 +00:00
Moritz Kiefer
61feb5bf2b
Fix Daml Script dump integration tests (#8779)
Hardcoded 0.0.0 breaks on the release build :(

changelog_begin
changelog_end
2021-02-08 16:54:46 +01:00
Moritz Kiefer
cf3d0876af
Add a prototype for DAML Script dumps (#7934)
* Add a prototype for DAML Script dumps

This is still fairly rough unfortunately but it does at least have
some tests and it doesn’t interact with anything else, so hopefully we
can land this and then parallelize the work from there on.

changelog_begin
changelog_end

* Update daml-script/dump/src/main/scala/com/daml/script/dump/Encode.scala

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

* view all the things

changelog_begin
changelog_end

* Update daml-script/dump/src/main/scala/com/daml/script/dump/Dependencies.scala

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

* Fixup the switch to exists

changelog_begin
changelog_end

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2021-02-05 13:19:20 +01:00
Samir Talwar
9c477ffdf5
ledger-on-memory: Only support pre-execution. [KVL-821] (#8757)
* ledger-on-memory: Rename `PreExecutingOwner` to just `Owner`.

* ledger-on-memory: Push the committer execution context up a little.

* ledger-on-memory: Use pre-execution in tests, not batching.

* ledger-on-memory: Remove support for batching submissions.

Pre-execution is pretty much always faster; let's use it.

CHANGELOG_BEGIN
CHANGELOG_END

* ledger-on-memory: Simplify construction.

Now we only support pre-execution, we can be less general.
2021-02-05 08:56:55 +00:00
Moritz Kiefer
4b33da2420
Expose transaction trees in DAML Script (#8750)
This is spun off from #7934 for ease of review.

For now, all of this is hidden (and for extra caution also marked as
early access). I expect we’ll tweak the API in a bunch of ways before
marking it stable but this at least is sufficient for the prototype.

At this point, we cannot support this over the JSON API. Not too
worried about that at least for now.

fixes #7847

changelog_begin
changelog_end
2021-02-04 15:21:30 +01:00
Moritz Kiefer
81dc6b9473
Relax party validation in DAML Script over JSON API (#8674)
* Relax party validation in DAML Script over JSON API

Since the JSON API infers parties from the token instead of accepting
them explicitly, we have to ensure that the parties in the token match
the parties passed to `submit`/`submitMulti` exactly. However, we were
a bit too strict and required a party to be in `readAs` even if it is
already in `actAs`. This caused issues on DamlHub because they issue
tokens with the party in both `actAs` and `readAs` so regular `submit`
doesn’t work.

changelog_begin

- [DAML Script] When running DAML Script over the JSON API, the check
  that the parties in the DAML Script match the parties in the token
  has been relaxed and now allows for duplicate parties as well as
  parties that are only in actAs in the DAML Script but in both actAs
  and readAs in the token.

changelog_end

* fmt

changelog_begin
changelog_end
2021-01-28 20:22:07 +01:00
Richard Kapolnai
ce5d3bed1e
Add note about loglevel to trace and debug api doc (#4756)
* Add note about loglevel to trace and debug api doc

CHANGELOG_BEGIN
CHANGELOG_END

* Explain log level in comment of debug

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

* fix typo

* propagate explanation to trace, traceId and debug

* Fix DA.Internal.Prelude location

changelog_begin
changelog_end

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-01-26 14:56:11 +00:00
Remy
de14275528
triggers: do not use the type information from SRecord (#8623)
This type information is there for debugging purpose, one should not
use it.  We use type from SAny instead.

CHANGELOG_BEGIN
CHANGELOG_END
2021-01-26 12:08:53 +01:00
Stefano Baghino
fc69db02b4
Add a library that defines Resource factory methods for gRPC servers and channels (#8604)
* Add a library that defines Resource factory methods for gRPC servers and channels

This is the first of four PRs in which 6ea70c4b45
has been broken up to facilitate review.

The endgame is to have the non-repudiation prototype merged. These
factory methods have been used to make resource management easier,
specifically as part of testing.

changelog_begin
changelog_end

* Let warning log output in tests

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

* Address https://github.com/digital-asset/daml/pull/8604#discussion_r562634032

* Address https://github.com/digital-asset/daml/pull/8604#discussion_r562634865

* Address https://github.com/digital-asset/daml/pull/8604#discussion_r562635148

* Address https://github.com/digital-asset/daml/pull/8604#discussion_r562635684

* Add resources-grpc to release/artifacts.yaml

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-01-25 10:32:36 +01:00
Gary Verhaegen
ce8c38bac1
copyright updates (#8610)
CHANGELOG_BEGIN
CHANGELOG_END
2021-01-22 15:03:36 +00:00
Moritz Kiefer
427ea0fb7d
Remove redundant list of LF versions (#8490)
* Remove redundant list of LF versions

After #8472, I realized that there must be a list used for daml-stdlib
and daml-prim already and it turns out there is. I’ve removed that one
in favor of the one added in #8472 since I like having all in one
place and the one from #8472 is created by filtering an existing list
instead of creating a completely separate list like we do here.

changelog_begin
changelog_end

* Introduce SCRIPT_LF_VERSIONS

changelog_begin
changelog_end
2021-01-13 13:21:39 +00:00
Moritz Kiefer
b32177cb0b
Build DAML Script library for all LF versions (#8472)
The hardcoded list is obviously garbage and didn’t include 1.11 so
this PR changes it to use the one we already have so they are always
in sync.

changelog_begin
changelog_end
2021-01-12 11:23:41 +00:00
Moritz Kiefer
22ce940954
Upgrade scalafmt and enable trailing commas (#8437)
This PR updates scalafmt and enables trailingCommas =
multiple. Unfortunately, scalafmt broke the version field which means
we cannot fully preserve the rest of the config. I’ve made some
attempts to stay reasonably close to the original config but couldn’t
find an exact equivalent in a lot of cases. I don’t feel strongly
about any of the settings so happy to change them to something else.

As announced, this will be merged on Saturday to avoid too many conflicts.

changelog_begin
changelog_end
2021-01-09 11:37:37 +01:00
Bernhard Elsner
cda93db944
Daml case and logo (#8433)
* Replace many occurrences of DAML with Daml

* Update docs logo

* A few more CLI occurrences

CHANGELOG_BEGIN
- Change DAML capitalization and docs logo
CHANGELOG_END

* Fix some over-eager replacements

* A few mor occurrences in md files

* Address comments in *.proto files

* Change case in comments and strings in .ts files

* Revert changes to frozen proto files

* Also revert LF 1.11

* Update get-daml.sh

* Update windows installer

* Include .py files

* Include comments in .daml files

* More instances in the assistant CLI

* some more help texts
2021-01-08 12:50:15 +00:00
Moritz Kiefer
424faa923a
Port damlc dependencies to Scala 2.13 (#8423)
* Port damlc dependencies to Scala 2.13

I got a bit fed up by the fact that going directory by directory
didn’t really work since there are two many interdependencies in
tests (e.g., client tests depend on sandbox, sandbox tests depend on
clients, engine tests depend on DARs which depend on damlc, …).

So before attempting to continue with the per-directory process, this
is a bruteforce approach to break a lot of those cycles by porting all
dependencies of damlc which includes client bindings (for DAML Script)
and Sandbox Classic (also for DAML Script).

If this is too annoying to review let me know and I’ll try to split it
up into a few chunks.

changelog_begin
changelog_end

* Update daml-lf/data/src/main/2.13/com/daml/lf/data/LawlessTraversals.scala

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

* fixup lawlesstraversal

changelog_begin
changelog_end

* less iterator more view

changelog_begin
changelog_end

* document safety of unsafeWrapArray

changelog_begin
changelog_end

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-01-08 07:22:38 +01:00
Moritz Kiefer
4ca890fab9
Fix queryContractKey for complex keys over gRPC (#8368)
* Fix queryContractKey for complex keys over gRPC

Unfortunately the Equal instance of Value only performs structural
equality which includes optional field names and constructor
names. While we could try to ensure that they are always present or
always absent, the more reliable solution seems to be to not rely on
this at all and instead use the equality on SValues which is
explicitly designed for this.

changelog_begin

- [DAML Script] Fix a bug where queryContractKey incorrectly returned
  None despite their being an active contract with the given key. This
  only affected DAML Script over gRPC.

changelog_end

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

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-01-04 15:38:43 +00:00
Gary Verhaegen
a925f0174c
update copyright notices for 2021 (#8257)
* update copyright notices for 2021

To be merged on 2021-01-01.

CHANGELOG_BEGIN
CHANGELOG_END

* patch-bazel-windows & da-ghc-lib
2021-01-01 19:49:51 +01:00
Moritz Kiefer
df98ee0107
Support multi-party submissions in DAML Script over JSON API (#8339)
* Support multi-party submissions in DAML Script over JSON API

changelog_begin

- [DAML Script] Multi-party submissions are now also supported over
  the JSON API.

changelog_end

* Fix outdated comment

changelog_begin
changelog_end
2020-12-18 12:45:34 +01:00
Moritz Kiefer
433a4e0e29
Test multi-party submissions in DAML Script over gRPC (#8331)
changelog_begin

- [DAML Script] Multi-party submissions are also supported over gRPC.

changelog_end
2020-12-18 09:57:25 +01:00
Remy
a8c4f1661b
LF: Add exceptions to Scala DAML-LF AST (#8312)
This advances states of #8020.

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-17 17:45:32 +01:00
Remy
7d31135645
LF: retire VersionTimeline (#8273)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-14 16:56:47 +01:00
Remy
44c5b8a777
LF: remove version from value nested in GenNode. (#8217)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-11 17:12:14 +01:00
Moritz Kiefer
5c077a4550
Add multi-party submissions to DAML Script (#8240)
* Add multi-party submissions to DAML Script

changelog_begin

- [DAMl Script] Add early-access submitMulti and submitMultiMustFail
  for multi-party submissions. This is only supported in DAML Studio at
  the moment.

changelog_end

* Fix daml-lf prettyprinter

changelog_begin
changelog_end

* Cleanup visibleIn

changelog_begin
changelog_end

* Fix JsonApiIt

changelog_begin
changelog_end

* s/Set()/Set.empty

changelog_begin
changelog_end

* Cleanup token check

changelog_begin
changelog_end

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

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

* Document ParticipantView

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2020-12-11 12:45:32 +01:00