* 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>
* 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.
* 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
* 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>
* 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>
* 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
* 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>
* 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
* 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>
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
* 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
* 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>
* 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>
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>
* 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>
* 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>
* 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>
* 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>
* 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
* 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
* 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
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
* 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
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
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
* 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>
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
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
* 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>
* 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>
* 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>
* 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>
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
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
* 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>
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
[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
* 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>
* 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>
* 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.