Commit Graph

270 Commits

Author SHA1 Message Date
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