Commit Graph

158 Commits

Author SHA1 Message Date
Martin Huschenbett
caedc72551
Implement a simple profiler for DAML scenarios (#5957)
* Implement a simple profiler for DAML scenarios

The profiler runs a single scenario and records timing information when
each function (and some other closures) are entered and left. The
resulting information can be visualized as a flamegraph using
[speedscope](https://www.speedscope.app/).

The profiler works by instrumenting the CEK machine at the heart of
DAML Engine. Unfortunetaly, this causes a very small overhead on
non-profiling runs too. However, in my benchmarks I could not measure
any significant impact on the overall runtime at all. More precisely,
the overhead is as follows:

Every closure now has an additional field called `label`. In
non-profiling runs this field is always set to `null`. This field needs
to be allocated, copied whenever we copy a closure and scanned during
garbage collection. Additionally, whenever we enter a closure, we check
this field and whenever it is _not_ `null`, i.e. never during
non-profiling runs, we record an "open event" and set up a hook for the
corresponding "close event". Thus, the additional cost during
non-profiling runs are a single pointer comparison and a jump beyond
the "then branch".

Since this is still very much in active development, there are no
documentation, other than an entry in a README, and no tests yet. They
will come before we promote this. However, the UX will look very
different then since we already have plans to significantly change it.

CHANGELOG_BEGIN
CHANGELOG_END

* Run scalafmt

* Make profiling argument to PureCompiledPackges optional

* Fix a bunch of tests

CHANGELOG_BEGIN
CHANGELOG_END

* scalafmt is so annoying

CHANGELOG_BEGIN
CHANGELOG_END

* Apply simple suggestions

CHANGELOG_BEGIN
CHANGELOG_END
2020-05-18 17:20:44 +00:00
nickchapman-da
53b24793f4
Simplify and clarify the public interface to Speedy. (#5881)
* Simplify and clarify the public interface to Speedy.

- Remove `isFinal`. A client just uses `run()`.
- Remove `toSValue`. The value in available in `SResultFinalValue(v: SValue)`.
- A client never directly access the `.ctrl` (or `.returnValue`) components.
- A client may use `setExpressionToEvaluate(expr)` to evaluate a new expression on an existing machine.

changelog_begin
changelog_end

* remove while loop which executes just once

* avoid unnecessary mutation when running speedy
2020-05-07 08:55:16 +00:00
Remy
9fc1ceae10
Engine: revisit freshness of cid discrimator (#5361)
CHANGELOG_BEGIN
CHANGELOG_END
2020-04-30 16:44:34 +02:00
Remy
15354c3256
DAML-LF: remove submitter is in maintainer check (#5611)
CHANGELOG_BEGIN
CHANGELOG_END
2020-04-23 16:10:39 +02:00
Remy
d90b03633e
Scenario service: optimize for common usecases of context update (#5666)
CHANGELOG_BEGIN
CHANGELOG_END
2020-04-22 22:06:53 +02:00
Remy
7bdde70840
Speedy Compiler: clean up. (#5649)
CHANGELOG_BEGIN
CHANGELOG_END
2020-04-22 16:09:54 +02:00
Remy
101aceaeba
Scenario service: drop double validation (#5638)
CHANGELOG_BEGIN
CHANGELOG_END
2020-04-20 21:11:46 +02:00
Remy
969946c126
Scenario Service: drop support of submitter is in maintainers check (#5609)
CHANGELOG_BEGIN
CHANGELOG_END
2020-04-17 16:09:41 +02:00
Moritz Kiefer
5f7d6fd6cc
Properly mangle/unmangle names in the scenario service (#5595)
* Properly mangle/unmangle names in the scenario service

Previously, we just passed in whatever we had in DAML land which broke
the scenario service as soon as a name needed mangling. This PR fixes
mangling when passing identifiers to the scenario service and
unmangles them again when pretty printing.

fixes #5593

changelog_begin

- [DAML Studio] Fix a bug where scenarios with names that are mangled
  in DAML-LF resulted in a crash in the scenario service.

changelog_end

* Mangle module names in context updates
2020-04-17 12:26:40 +02:00
Remy
9704a39bae
Engine: refactor PartialTransaction context (#5578)
* Engine: refactor PartialTransaction context

CHANGELOG_BEGIN
CHANGELOG_END
2020-04-16 14:39:12 +02:00
Moritz Kiefer
18349be069
Fix conversion from contract to node ids in the scenario service (#5577)
* Fix conversion from contract to node ids in the scenario service

Previously we only included the mapping from the ledger. However, this
does not include any contracts which might have been created in a
partial transaction that failed. This caused a
`NoSuchElementException` when converting the error which is obviously
not what we want.

This PR extends the mapping to include any contracts created in the
current partial transaction.

changelog_begin

- [DAML Studio] Fix a bug where a failed transaction that included
  references to a transient contract returned a gRPC error instead of
  the expected error message.

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>

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

Co-Authored-By: Remy <remy.haemmerle@daml.com>

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

Co-Authored-By: Remy <remy.haemmerle@daml.com>

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

Co-Authored-By: Remy <remy.haemmerle@daml.com>

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

Co-Authored-By: Remy <remy.haemmerle@daml.com>

Co-authored-by: Remy <remy.haemmerle@daml.com>
2020-04-16 09:34:20 +00:00
Remy
32967f7294
Engine: redesign PartialTransaction context (#5519)
* Engine: redesign PartialTransaction context

* changelog

CHANGELOG_BEGIN
CHANGELOG_END
2020-04-15 17:35:01 +02:00
Moritz Kiefer
5dd196ac4a
Move GHC session to a Shake rule (#5517)
This is a spin off from the work for making module prefixing
work. There I wanted to be able to use the `GeneratePackageMap` rule
to get access to the modules in an LF package which requires to be in
an Action rather than in IO.

This resulted in a much larger refactoring than I expected, so here is
a list of changes to ease review:

1. I’ve split off Development/IDE/Core/RuleTypes/Daml.hs into its own
   Bazel targets to avoid cycles. This allows us to use a rule without
   depending on the implementation of that rule.

2. Development/IDE/Core/IdeState/Daml.hs has moved into its own Bazel
   target. There is a lot of stuff that needs `withDamlIdeState` now
   since the `ghcide` `initialise` function does not add our Shake rule
   for getting the GHC session and making all of that depend on
   damlc:lib creates a mess.

3. The actual logic of the initialization has stayed the same but
   moved into a rule in Development/IDE/Core/Rules/Daml.hs.

4. As mentioned above, a few things that could previously get away
   with only the rules provided by ghcide now need our own rules so
   they switched to `withDamlIdeState`. This mainly affects `damlc
   docs`.

5. Making daml-docs work with the ofInterestRule is a bit tricky.I did
   find the issue and included the fix but also disabled the
   ofInterestRule since it really does not make sense to generate Core
   in the background.

changelog_begin
changelog_end
2020-04-09 17:11:40 +02:00
Gerolf Seitz
a2d785e3ee
Use com.daml as root package (#5343)
Packages com.digitalasset.daml and com.daml have been unified under com.daml

Ledger API and DAML-LF DEV protos have also been moved from `com/digitalasset`
to `com/daml` on the file system.
Protos for already released DAML LF versions (1.6, 1.7, 1.8) stay in the
package `com.digitalasset`.

CHANGELOG_BEGIN
[SDK] All Java and Scala packages starting with
``com.digitalasset.daml`` and ``com.digitalasset`` are now consolidated
under ``com.daml``. Simply changing imports should be enough to
migrate your code.
CHANGELOG_END
2020-04-05 19:49:57 +02:00
Moritz Kiefer
2049f2ea93
Limit memory usage of scenario service in tests (#5373)
* Limit memory usage of scenario service in tests

Previously the scenario service used over 2GB of memory during
//compiler/damlc/tests:integration-dev for absolutely no reason.

This PR adds an option to pass JVM options when starting the scenario
service and sets them to 200MB for the Shake tests and the damlc
integration tests which seems to be more than sufficient.

These option can also be set in `daml.yaml`. I did not change the
defaults since this is shipped to users where I’d rather have high
memory usage than a crashing scenario service and on certain large
DAML codebases we might actually use a fair bit.

changelog_begin
changelog_end

* Update docs/source/tools/assistant.rst

Co-Authored-By: Samir Talwar <samir.talwar@digitalasset.com>

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
2020-04-02 14:42:33 +00:00
Remy
1d0c0df325
Scenario serice: use new contract ids (#5296)
CHANGELOG_BEGIN
CHANGELOG_END
2020-03-31 14:37:41 +02:00
Remy
1b37f6c482
DAML-LF: redesign absolute contract ids (#5207)
CHANGELOG_BEGIN
CHANGELOG_END
2020-03-27 19:07:42 +01:00
Gary Verhaegen
1872c668a5
replace DAML Authors with DA in copyright headers (#5228)
Change requested by Manoj.

CHANGELOG_BEGIN
CHANGELOG_END
2020-03-27 01:26:10 +01:00
Ognjen Maric
f7aa2a3db0
Add keys with maintainers to Fetch nodes (#5186)
Add keys with maintainers to Fetch nodes

The new field is populated by the interpreter whenever the fetched
contract has a key. Used for contract key reinterpretation in Canton.

CHANGELOG_BEGIN

- [DAML-LF] Add keys with maintainers to Fetch nodes in transactions.

CHANGELOG_END
2020-03-26 14:07:17 +01:00
Gary Verhaegen
75c7d48d5b
bind localhost for json-api and scenarios (#4576)
Both were previously binding 0.0.0.0, which is inherently insecure. More
importantly to me, that meant running `bazel test //...` essentially
rendered my computer unusable for however long it took (which is
_long_), as it kept popping up focus-stealing dialogs about whether or
not I wanted to trust "java" to open an incoming network connection.

The ScenarioService does not seem to have an existing setup for CLI args
and my Scala-fu is not good enough to add one, so I just changed the
hard-coded path.

The JSON API already had an option, just with the wrong default. This is
technically a breaking change, but I'm hoping to pass it under the
"experimental" flag we still have on the JSON API.

CHANGELOG_BEGIN
- [JSON API - Experimental] As a security improvement, the JSON API
server will now bind on ``127.0.0.1`` by default. Previous behaviour was
to bind on ``0.0.0.0``; you can get that behaviour back by passing in
the (existing) flag ``--address 0.0.0.0``.

- [DAML SDK] The Scenario Service will now bind on ``127.0.0.1``. Previous
behaviour was to bind on ``0.0.0.0``.

CHANGELOG_END
2020-03-05 17:10:49 +01:00
Remy
0321a1bb32
[Engine] push absolute contract ids inside the evaluation (#4652)
* [Engine] push absolute contract inside the evaluation
* Remove discriminator fom relative contract id

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-21 20:21:35 +01:00
Moritz Kiefer
c68dd19ade
Decode and validate package metadata in Scala (#4653)
This adds the code for decoding and validating package metadata
that is now emitted by damlc.

changelog_begin
changelog_end
2020-02-21 18:20:42 +00:00
Remy
3a8139d9c1
Engine: move partialTransaction to interpreter (#4617)
* Engine: move partialTransaction to interpreter

CHANGELOG_BEGIN
CHANGELOG_END

* formating

* fix
2020-02-20 16:48:47 +00:00
Jussi Mäki
61a65fe16f
Use the contract key hasher in kvutils (#4542)
* Use KeyHasher to serialize contract keys in kvutils

- Use Value instead of VersionedValue in GlobalKey as the versioning does not make sense here
  and may be misleading as the a value with a different version but same meaning would still
  be the same key.

- Relocate the KeyHasher to ledger-api-common so kvutils can use it (otherwise cyclic dependencies)

- Replace storing of the contract key as a VersionedValue with the hash produced by KeyHasher.
  This is backwards incompatible. A compatible option would require us to query the key with both
  the old way and the new way which is unattenable. We're making a calculated breaking change.

CHANGELOG_BEGIN
- [DAML Ledger Integration Kit] Serialize contract keys using a hash instead of the value in kvutils.
  This is a backwards incompatible change to kvutils.
CHANGELOG_END

* Use proper hasher for contract keys and not KeyHasher

- Use Hash.scala, not KeyHasher.scala.
- Add hash to GlobalKey as we want the hash to be computed from the inside.
  The use of KeyHasher will be later deprecated and replaced by this.

* Use "sealed abstract case class" trick instead of private ctor

and rebase fix

* Revert change to unsupported value version decode error

* Reformat code

* Add kvutils changelog entry and bump the version
2020-02-19 11:56:31 +00:00
Moritz Kiefer
4c7a864d3b
Make context updates in the scenario service thread safe (#4539)
I don’t have a great test case to demonstrate the problem but
`contexts = contexts + (ctxId -> ctx)` is definitely not an atomic
update which means that inserts can get lost.

changelog_begin
changelog_end
2020-02-17 12:35:51 +00:00
Moritz Kiefer
a0df5f91f9
Fix race condition in scenario service context updates (#4537)
If we get interrupted after updating our local view but before doing
the actual context update on the server side bad things happen. To fix
this, we first clone the context then update the clone which avoids
this and is a bit nicer than throwing an `uninterruptibleMask` around
updating the local view and sending the updateCtx gRPC request.

fixes #4525

changelog_begin
changelog_end
2020-02-17 11:57:45 +01:00
Jussi Mäki
f0c4f2820c
Add NodeInfo and informeesOfNode method. Fix witnesses of top-level fetches. (#4217)
This adds the NodeInfo trait to compute the informees of a node and the
required authorizers. This has been separated into its own trait as this
computation is also required (externally) for serialized transaction nodes
in a context where the full deserialization of the node would be prohibitively
expensive.

While doing this change and cleaning up transaction authorization it was
discovered that top-level fetches (which can only be created from scenarios)
did not include the submitter as a witnessing party.

CHANGELOG_BEGIN
[DAML SDK] Fix computation of witnesses of top-level fetch nodes in scenario results ("known to").
CHANGELOG_END
2020-02-05 14:17:32 +00:00
Remy
06967d80fa
Engine: scenario runner prefixes fresh nodeIds and contractIds with #
CHANGELOG_BEGIN
CHANGELOG_END
2020-02-03 14:43:53 +01:00
Samir Talwar
4d324f6aaf
Run scalafmt on all files and fix the errors. (#4260)
Unfortunately, downgrading `scalafmt` resulted in files that would be
reformatted to invalid code, because lines would be merged but trailing
commas would be left in.

I've manually run it everywhere and fixed these issues so people don't
have to fix them as they go.

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
2020-01-29 16:15:49 +00:00
Stefano Baghino
87b4917ccf
Run scalafmt to reduce noise on #4217 (#4245)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-29 10:18:56 +01:00
Remy
b6e848b576
Engine: Add node and contract Discriminator
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-22 18:49:30 +01:00
Moritz Kiefer
19dd7ed7c4 Handle unserializable scenario result types (#4156)
* Handle unserializable scenario result types

Previously, the conversions made some attempt at guarding against this
by matching on SPap and PClosure. While it would be possible to extend
this to match on STypeRep, this doesn’t actually fix the issue since
this can be nested, e.g., you can have a record with a field that is
an SPAP.

This PR changes this to simply catch any errors thrown from
`toValue`. While this feels a bit ugly, I think it’s a reasonable fix
for now.

changelog_begin

- [DAML Studio] Scenarios with unserializable result types no longer
  crash the scenario service.

changelog_end

* Only run test on DAML-LF >= 1.7
2020-01-22 11:15:46 +00:00
Remy
c0f387ff25 Engine: Small refactoring of partial transactions (#3951)
* small refactoring of partial transaction

CHANGELOG_BEGIN
CHANGELOG_END

* cosmetic changes
2020-01-09 19:01:44 +00:00
Andreas Herrmann
43bbfeaee6
Remove unused dependencies to da_scala_binary (#3937)
* Inline all scala_binary dependencies

* Run //:buildifier-fix

* da_scala_binary: Enable unused dependency checker

* //compiler/scenario-service/server:scenario-service-raw

* //language-support/scala/codegen:codegen-main

* //daml-lf/encoder:encoder_binary

* //daml-lf/repl:repl

* //language-support/codegen-main:codegen-main

* //language-support/scala/examples:quickstart-scala-bin

* //ledger-api/rs-grpc-akka:rs-grpc-akka-perf

* //ledger-service/jwt:jwt-bin

* //ledger/api-server-damlonx/reference-v2:reference-v2

* //ledger/api-server-damlonx/reference-v2:ephemeral-postgres-reference-server

* //ledger/ledger-api-auth:ledger-api-auth-bin

* //ledger/ledger-api-test-tool:ledger-api-test-tool

* //ledger/participant-state/kvutils/tools:integrity-check

* //navigator/integration-test:navigatortest-jar

* Run //:buildifier-fix

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-06 13:58:56 +01:00
Gary Verhaegen
878429e3bf
update copyright notices to 2020 (#3939)
copyright update 2020

* update template
* run script: `dade-copyright-headers update .`
* update script
* manual adjustments
* exclude frozen proto files from further header checks (by adding NO_AUTO_COPYRIGHT files)
2020-01-02 21:21:13 +01:00
Andreas Herrmann
9fbb787062 Remove unused dependencies to da_scala_test(_suite) (#3925)
* Remove unused scala.bzl imports

* override_targets org.scalatest.scalatest_2.12

Otherwise, rules_scala implicitly adds a different version to scala_test
than other packages transitively depending on scalatest. This causes
unused dependency checker to raise an error.

* Handle rules_scala scalatest in pom_file.bzl

* Inline all scala_test dependencies

So that `unused_dependency_checker = "error"` can be applied to them.

* Run //:buildifier-fix

* TMP scala_test_suite --> scala_test

* da_scala_test: Enable unused dependency checker

* //navigator/backend:navigator-scala-tests

* //ledger/sandbox:sandbox-scala-tests

* //ledger/participant-state/kvutils:kvutils-tests

* //ledger/participant-state:participant-state-tests

* //ledger/ledger-api-scala-logging:ledger-api-scala-logging-test

* //ledger/ledger-api-common:ledger-api-common-scala-tests

* //ledger/ledger-api-client:ledger-api-client-tests

* //ledger/ledger-api-auth:ledger-api-auth-scala-tests

* //ledger-service/lf-value-json:tests

* //ledger-service/jwt:tests

* //ledger-service/http-json:tests

* //ledger-api/rs-grpc-akka:rs-grpc-akka-tests

* //language-support/scala/codegen-sample-app:tests

* //language-support/scala/codegen-sample-app:ScalaCodeGenIT

* //language-support/scala/codegen:tests

* //language-support/scala/bindings-akka:tests

* //language-support/java/codegen:test

* //language-support/java/codegen:ledger-tests

* //language-support/java/bindings-rxjava:bindings-java-tests

* //language-support/codegen-common:test

* //extractor:extractor-scala-tests

* //daml-lf/scenario-interpreter:scenario-interpreter_tests

* //daml-lf/language:language-test

* //daml-lf/interface:tests

* //daml-lf/engine:tests

* //daml-lf/encoder:tests

* //daml-lf/archive:daml_lf_archive_reader_tests

* //daml-assistant/scala-daml-project-config:scala-daml-project-config-tests

* UNDO scala_test_suite --> scala_test

This reverts commit 13ed47ba725e944533ca1157a070cb8dc30569ac.

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2019-12-30 13:49:59 +00:00
Moritz Kiefer
1767b2e6bf
Remove mysterious hFlush stdout (#3825)
This has been there since before we open sourced DAML and afaict if it
has ever served any purpose, that purpose is long gone.
2019-12-12 09:36:47 +01:00
associahedron
08ee42fb30 Implement missing genmap fns (#3807) 2019-12-11 11:16:25 +00:00
Jussi Mäki
95ddb65483
DAML Engine: accurate package dependency annotations (#3726)
* Track used packages during whole of engine submit

- Introduce MutableCompiledPackages interface
- Add TrackingCompiledPackages that tracks fetched packages
- Make used packages in transaction optional to distinguish between
  missing dependencies and empty set of dependencies.

* Reimplement package dependency tracking

- Compute direct dependencies of a package during decoding
- Compute transitive dependencies of a package when adding a package
  to engine.
- Annotate the resulting transaction with package dependencies
  in Engine.submit.

* Create Ast.Package with proper direct deps in scenario service

While we don't have use for direct dependencies of a package in
scenario service (only Engine.submit needs it), it's better to be
accurate.

This of course overapproximates the direct dependencies.

* Compile a each new package once in ConcurrentCompiledPackages
2019-12-04 15:01:21 +01:00
Martin Huschenbett
bf5310060c Don't break long party names in scenario view weirdly (#3669)
Until now, we broke long party names in the table view in the scenario at
spaces. This looked quite ugly.

Now, we don't break them at spaces. At the same time we also moved the CSS
into a file rather than having it in the code to make changes like this one
easier in the future.

This fixes #3642.
2019-11-29 08:10:44 +00:00
nickchapman-da
d3d6891021
Rename daml lf tuples (#3658)
* Rename DAML-LF tuples as structs (structural records)
2019-11-28 07:58:30 +00:00
Andreas Herrmann
f4d0eb636e Replace Hazel by stack_snapshot (#2743)
* Unmangled libz.so and libbz2.so

* Use stack_snapshot instead of Hazel

* Remove Hazel

* Define stack_snapshot

* Update rules_haskell

* Document stack_snapshot

* Clean stack's lock file from aborted builds
2019-11-22 14:24:08 +00:00
Remy
3f8bd0da5e DAML-LF: rename ValueMap to ValueTextMap. (#3584) 2019-11-22 11:35:32 +00:00
Remy
0e92bc6f61
add genmap in scenario service (#3483) 2019-11-15 12:39:48 +01:00
Remy
4d36c01682 Daml lf genmap (#3453)
* shortcup for SBMapEmpty

* daml-lf: add GenMap in the interpreter.
2019-11-15 10:36:41 +00:00
Remy
bd054b4955 daml-lf: interned strings/names in scenarios (#3255)
* daml-lf: interned strings/names in scenarios

* clean up

* Address Moritz's comments
2019-10-30 10:25:46 +00:00
Andreas Herrmann
2bd1db490a
Replace bazel-deps by rules_jvm_external (#3253)
* Update bazel-common to fix javadoc issues

Specifically, to fix the following error

```
ERROR: /home/aj/tweag.io/da/da-bazel-1.1/ledger-api/rs-grpc-bridge/BUILD.bazel:7:1: in javadoc_library rule //ledger-api/rs-grpc-bridge:rs-grpc-bridge_javadoc:
Traceback (most recent call last):
        File "/home/aj/tweag.io/da/da-bazel-1.1/ledger-api/rs-grpc-bridge/BUILD.bazel", line 7
                javadoc_library(name = 'rs-grpc-bridge_javadoc')
        File "/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/com_github_google_bazel_common/tools/javadoc/javadoc.bzl", line 27, in _javadoc_library
                dep.java.transitive_deps
object of type 'JavaSkylarkApiProvider' has no field 'transitive_deps'
```

* Define Maven deps using rules_jvm_external

* Pin artifacts

* Remove bazel-deps generated targets

* Remove bazel-deps

* Switch to rules_jvm_external targets

* update bazel documentation

* pom_file: There are no more bazel-deps targets

* BAZEL-JVM.md `maven_install` typo
2019-10-28 13:53:14 +01:00
Gerolf Seitz
a5921e0274 Properly fill eventId for active contracts (#3126)
* Properly fill eventId for active contracts

This gets rid of the last remaining bit that assumes
contractId==eventId.

Fixes #65.
Contributes to #2068.

* Do not conflate eventId and contractId in the daml-lf interpreter

* Do not treat contractId as eventId in Ledger.scala

* Remember the transaction that divulged a contract.

* In this scope we can treat divulged contracts the same as disclosed ones

* revert a few more syntactical changes to make the overall diff smaller

* retain the same behavior on the scenario service api

* fix unreleased after rebase
2019-10-16 17:02:04 +00:00
Remy
e45b585307 daml-lf: repackage daml-lf archive proto (daml_lf -> daml_lf_dev) (#3169) 2019-10-15 09:36:11 +00:00
Remy
d64df4b5f7 daml-lf: clean achive bazel build (#3175)
* clean the mess in daml-lf achive bazel build

* add release note

* Address Moritz's comments

* more release notes
2019-10-15 08:36:46 +00:00
Remy
fc1a000090 daml-lf: rename daml_lf_archive_scala target to daml_lf_archive_reader (#3168)
* daml-lf: rename daml_lf_archive_scala target to daml_lf_archive_reader

* fix release
2019-10-14 14:53:50 +00:00
Martin Huschenbett
3b42a447f3 Refactor DAML-LF encoder/decoder in prep for string interning (#3060)
* Refactor DAML-LF encoder/decoder in prep for string interning

Refactor the encoder/decoder such that all the functions concerned with
interning live next to each other and code will break once the types of
the protobuf messages change.

This PR is a pure refactoring and does not change any functionality.

* Fix typos
2019-09-27 12:40:05 +00:00
Remy
23c3c33fe1
scenario-service: run no validation, when called from ide (#3003) 2019-09-25 11:06:47 +02:00
Jussi Mäki
868cb785ad
Preload packages to engine during upload (#2860)
* Preload packages to engine during upload

* Improve logging in KeyValueCommitting and add timing information

* Fix scenario service tests now that logging is done in interpreter
2019-09-13 14:31:52 +02:00
Andreas Herrmann
ed39800a9f Rename hazel_deps to hackage_deps (#2789)
* hazel_deps --> hackage_deps

Mechanical change:

```
sed -i 's/hazel_deps/hackage_deps/g' $(ag -l hazel_deps)
```

* Hazel dependencies --> Hackage dependencies
2019-09-06 09:01:09 +00:00
Martin Huschenbett
222f8c6fc1
Revert type based computation of table headers in scenario view (#2704)
The type based computation doesn't work as intended. Let's go back to the
value based computation for now and fix it later.
2019-09-02 12:35:52 +02:00
Remy
20649cf78e ledger-api: rename decimal field to numeric in value Proto (#2688)
* add Numeric.java

* ledger-api: rename `decimal` field to `numeric` in value protobuf

* Address Gerolf's comment

* ledger-api: add missing renammings

* ledger-api: relax syntax of numbers that can be sent as numerics

* extractor:  fix

* leger-api: change format of number though ledger api

* daml-lf: fix numeric regexp

* ledger: fix tests
2019-08-29 22:51:33 +00:00
Moritz Kiefer
67c2e2a9ef
Switch to upstream gRPC-haskell (#2642)
* Switch to upstream gRPC-haskell
2019-08-23 15:10:15 +02:00
Remy
997212c8f4
daml-lf: decommission internal Decimal type in favor of Numeric. (#2594)
* daml-lf: ValueDecimal -> ValueNumeric
* Apply suggestions from Stephen's code review
   Co-Authored-By: Stephen Compall <stephen.compall@daml.com>
* extractor: add comment about Numeric SQL format
2019-08-22 18:07:47 +02:00
Moritz Kiefer
3554596f9a Wait for all gRPC requests to finish before shutting down gRPC (#2551)
This fixes all flakiness in `damlc test` that I was able to
reproduce. Previously, I got it to fail in about 10% of the cases
whereas now I have successfully run tests 200 times under load without
issues.

There were two issues at play here:

1. We run scenarios in separate threads to be able to kill the running
Shake session quickly even if a scenario has an infinite loop or
something like that (there is a timeout but it’s quite long). This
could result in one of those left-over threads trying to issue a
request while we are already trying to shut down.

To fix that, we wait for the concurrency semaphore to be empty before
shutting down.

2. Just waiting for scenario executions is not quite sufficient as
`runAction` does not wait for all rules to finish (we could just use
runActionSync in `damlc test` but I’d rather make this work
properly). While we do wait for all scenario executions to finish
there is one gRPC request in offInterest that we do not wait for:
gcCtxs.

To fix this, I’ve now routed all gRPC requests through the semaphore
which means that we will also wait for these requests to finish (or
prevent them from spawning).

This makes more sense anyway as scenario executions are mostly fairly
cheap requests while things like setting up the context are expensive
so we want to limit their concurrency.

We should make the concurrency limit configurable but I’ll leave that
for a separate PR.
2019-08-15 09:39:30 +00:00
Moritz Kiefer
126ad13326
Only register gRPC methods once (#2537)
SS.scenarioServiceClient does not just read the actual client from
some IORef, it registers the available gRPC methods. Apparently we
never knew about this or at least I didn’t.

By only doing this once, we should speed things up a bit and this
fixes once of the assertion failures that we have been seing on
shutdown (pthread_mutex_lock(&mu->mutex) == 0 in sync_posix.cc) which
was caused by trying to register a method from another thread after
destroying the channel.
2019-08-14 16:21:17 +02:00
Martin Huschenbett
803fee057f Show function names in stack trace on failing scenario (#2516)
* Show function names in stack trace on failing scenario

So far, we've only shown the location of the function but not its name.
Now, we add the name of the function as well.
2019-08-14 09:16:07 +02:00
Gary Verhaegen
99ea93168d
update copyright notices (#2499) 2019-08-13 17:23:03 +01:00
Martin Huschenbett
c2940705ff Remove unused message from scenario service protobuf (#2503)
I assume the plan was to implement stack traces. I intend to do that as well
but the message type does not fit my approach. Thus, let's remove it first.
2019-08-13 07:07:38 +00:00
Martin Huschenbett
0ca2601cd9 Print stack traces in the scenario on failure (#2497)
* Print stack traces in the scenario on failure

Currently, we only print the last source location, which is not
particularly helpful for debugging. Now, we put all source locations we
encounter during execution on the continuation stack and print them when
a scenario fails. This PR does not print the names of entered functions
or choices. We leave this for a future PR.

* Address Moritz' comments
2019-08-12 19:05:19 +00:00
nickchapman-da
b90862ebec
improve haskell module hierarchy to be more consistent (#2319) 2019-07-29 15:55:55 +01:00
nickchapman-da
b30228ab95
{-# LANGUAGE OverloadedStrings #-} is now on by default (#2270) 2019-07-24 08:09:26 +01:00
Martin Huschenbett
3076aeb239 Remove DA.Daml.LF.Decimal module (#2251)
The module was only used to format decimal numbers. The only impact the
formatting could have had was to add/strip trailing zeros from the
presentation of the number. However, manual testing shows this did not
happen. Thus, the whole module is now useless.
2019-07-22 17:55:30 +00:00
Michał Majcherski
148d2a57d3
VSCode scenario codelenses improvements (#2141) 2019-07-22 10:50:30 +02:00
Moritz Kiefer
4cd5766ab4 Remove duplication from PrettyScenario (#2236)
While experimenting with the pure Haskell gRPC implementation I
noticed that there is a fair amount of duplication in PrettyScenario
so this PR cleans up some of that.
2019-07-22 08:26:48 +00:00
Francesco Mazzoli
ca5d045e62 check that submitter is in maintainers for lookup by key (#1967)
* check that submitter is in maintainers when looking up keys

Fixes #1866. Note that this limitation applies both for `lookupByKey`
and `fetchByKey` -- anything involving retrieving a key is affected.

* add UNTIL-LF to run tests up to a certain version of DAML-LF

* name targets for DAML tests better

* add notes about DAML-LF changes

* commit Test.daml with DAML-LF 1.5 rather than compiling it on the fly

* add scenario tests for #1866

* add warnings about future key behavior in docs

* use flag rather than version when executing
2019-07-05 09:34:26 +00:00
Moritz Kiefer
cf0e0d6243 Remove outdated fixme in scenario service client (#2008) 2019-07-04 13:31:26 +00:00
Moritz Kiefer
bc20ace034
Make the gRPC timeout used for the scenario service configurable (#2000)
Given that we already made the max message size configurable it only
seems reasonable to also make the timeout configurable and on very
large projects, we do sometimes hit this.
2019-07-04 11:01:01 +02:00
Moritz Kiefer
995ee82fd0 Fix race condition in termination of scenario service (#1974)
Previously we sometimes ended up declaring the expected exit of the
scenario service as an unexpected exit. This PR addresses this by
adding a new variable that we set to True before we ask the scenario
service to exit by closing stdin.
2019-07-02 15:07:33 +00:00
Moritz Kiefer
c2a3d6ea28
Allow controlling the gRPC message limit via daml.yaml (#1970)
* Allow controlling the gRPC message limit via daml.yaml

We have had to raise that in the past since it caused issues on large
projects so it makes sense to make it configurable.

* Update unreleased.rst

Co-Authored-By: Beth Aitman <bethaitman@users.noreply.github.com>
2019-07-02 14:22:35 +02:00
Stephen Compall
9bcc925a40
intern package IDs in LF (#1614)
* specify the new fields for interning package IDs

* percolating intern tables

* crawl packages for package IDs as a pre-phase: generic prep

* stub case for interned_id in Scala packageref reader

* HasPackageRefs instances for the rest of the ast

* make intern table and use when encoding PackageRefs in v1

* don't need where

* stub out decode for interned package IDs

* no benefit to using uint32 instead of uint64

* percolate in encode one step

* interned case for decoding PackageRefs

* naming details

* intern table decoder

* finish propagating the intern table in encoder

* encode the package ID table

* document the vital assumption of encodeInternedPackageIds

* propagate the intern table through the LF decoder

- done by stacking ReaderT on top of Decode internally,
  as discussed with @hurryabit

* daml-lf-proto requires mtl

* stub out interned case in Scala LF decoder

* stub interface decoder function

* get the interned table to most places in InterfaceReader

* support for interned package IDs in Scala decoder

* use ImmArraySeq instead of Vector for Scala intern decode table

* adding that ghc extension didn't make sense

* implement interned ID decoding for InterfaceReader

* scenario service won't have interned package IDs

* test the interned ID resolution in Scala by examining the proto -> AST in detail

* proper precondition for the dev phase of interned IDs testing

* better error reporting for malformed DALFs in intern test

* just import Data.Int

- suggested by @neil-da; thanks

* pass around the lookup function instead of the vector in decoder

- suggested by @neil-da; thanks

* remove derivations for types deleted in e63b012d2d

* rename VersionAware to EncodeCtx

- suggested by @hurryabit; thanks

* rename MDecode to MonadDecode

- suggested by @hurryabit; thanks

* pass a function through the encoder instead of a set

- based on suggestions by @hurryabit and @neil-da; thanks

* daml-ghc test that interned IDs are generated

- suggested by @hurryabit; thanks

* adapt to 5b480c99ec #1844
2019-06-26 11:15:24 +02:00
Martin Huschenbett
25f1369cd7 Add support for DAML-LF's enum types to damlc (#1824)
* Add support for DAML-LF's enum types to damlc

This is part of #105.

* Address feedback
2019-06-25 14:44:21 +00:00
Moritz Kiefer
98e91d2ca2
Handle early exits of the scenario service (#1858)
fixes #1772
2019-06-25 15:34:02 +02:00
Stephen Compall
5b480c99ec
Decode modules abstractely in scenario-service server (#1844)
* add scenario Module decoding to Decode.OfPackage

* use purely data-driven decoding in scenario service in Scala

- decouples scenario service from LF decoder implementation

* make DecodeV1 companion private

* make extension to LFv2 more obvious
2019-06-25 09:49:04 +02:00
Moritz Kiefer
1406c41c02
Use 127.0.0.1 instead of localhost to connect to scenario service (#1848)
This fixes issues when running in an Alpine Linux docker container.
2019-06-24 16:45:12 +02:00
Moritz Kiefer
b41775e4d8
Move webview src to a separate JS file (#1784)
This makes it easier to modify and @hurryabit can no longer claim to
review Haskell when I change JS ;)
2019-06-20 14:55:30 +02:00
Moritz Kiefer
647c4d539e
Preserve the selected view on scenario result updates (#1776)
Previously, we always reverted back to the table view when the
scenario results changed. This PR changes this to preserve the
selected view.

I’ve also tested that this does not break backwards compatibility: If
you use the newer extension with an older SDK, you will get the
previous behavior of reverting to the table view and you can still
switch by clicking on the button.

Fixes #1675
2019-06-20 13:03:14 +02:00
Moritz Kiefer
3636bc7846
Double gRPC limit in the scenario service (#1697)
This is a temporary fix to unblock users that have run into this
limit. The long-term solution here is to use compression and/or make
the limit configurable.
2019-06-17 09:55:27 +02:00
Remy
0591075187 cleanup daml-lf scala packages (#1581)
* cleanup daml-lf scala packages

* Address Stephen's Comments

* update maven coordinates of language package
2019-06-12 15:55:48 +00:00
Moritz Kiefer
1f76f23022 Run daml-ghc tests with full validation in the scenario service (#1546)
* Run daml-ghc tests with full validation in the scenario service

Fixes #128

* Swap default of optScenarioValidation
2019-06-06 13:14:11 +00:00
Moritz Kiefer
e400bc7eb8
Remove use of managed for starting the scenario service (#1508)
Ironically `managed` didn't turn out to make our code more manageable
and we ended up mostly using it in very isolated places only to then
immediately convert it back to bracket-style functions using `with`.

This PR also removes the use of `managed` from the GcpLogger which was
the only other place where we are using it and it finally kills the
rather silly logic that starting up the scenario service was tied to
having an event logger.
2019-06-04 17:17:05 +02:00
Remy
f84e7d79d2 Add enum type to daml-lf (#1397)
* add enum type to daml-lf dev

* Address Francesco's comments

* Address Martin's comments

* fix daml-lf proto version history
2019-05-29 12:15:01 +00:00
Anup Kalburgi
c0f4585033
Scenario header (#1285)
Scenario headers from type Constructor instead of data
2019-05-28 11:11:15 -04:00
Remy
4f18b1afa7 DAML-LF internal type safety (#1192)
* Rename Value's ContractId to VContractId

* daml-lf: a bit more about PartyId

* daml-lf: Concatenable MatchingStringModule

* daml-lf make clear type used for Scenarios only

* daml-lf create ContractId, LedgerId, TransactionId

* sandbox-sql conversion util

* LedgerName -> LedgerString

* futher type cleanup in the sandbox

* daml-lf add test for LedgerString

* fixing tests

* a bit more safety in the DB

* Address Stephen's comments

* fix rebase

* More fixes for StringModule

* change length of LedgerString (256 -> 255)
2019-05-24 09:53:29 +00:00
Martin Huschenbett
6e73868220 Replace all occurrences of Tagged in DAML-LF AST with newtypes (#1289)
* Replace all occurrences of Tagged in DAML-LF AST with newtypes

This must end as it makes the code bases harder to understand without
adding any benefits.

* Add two more usages of mkVal

* Remove Orphans.Lib_hashable

* Remove tagged from package dependencies

* Derive stock classes as such
2019-05-21 16:19:57 +00:00
Francesco Mazzoli
95e8dd01c7 Maintainers must be signatories (#1124)
* check that maintainers are a subset of signatories

fixes #1123

* add note on why `fetchByKey` gets you the contract data
2019-05-21 11:59:59 +00:00
Martin Huschenbett
02d61cc48f
Rename render/parse functions for DAML-LF minor versions in Haskell (#1182)
The current naming suggests, the protobuf encoding and the CLI use different
textual representations of minor versions, which is not true. They only
differ in their types. We push this type conversion to the call sites
of both functions instead.
2019-05-16 14:58:10 +02:00
Moritz Kiefer
ad10f98020
Fix SDK integration tests on Windows (#1125)
* Fix SDK integration tests on Windows

* Switch to Haskell-based tar extraction
2019-05-14 21:55:45 +02:00
Remy
2e3a87934b Daml lf type safty (ChoiceName, VarName, FieldName, ConstructorName) (#983)
* daml-lf: make DefinitionRef more typesafe

* daml-lf: Identifier -> DefinitionRef

* daml-lf: remove unsafe apply and copy methods from DottedName

* daml-lf: create identifier

* daml-lf: make ChoiceNames Identifiers

* daml-lf: cleanup TVar

* daml-lf: FieldNames & VariantConstructors -> Identifiers

* bazel fmt

* daml-lf: VarName -> Identifier

* daml-lf: drop return inside Ref.scala

* daml-lf Identifier -> Name

* daml-lf DefinitionRef -> Identifier

* daml-lf make iface more type safe
+ address Francesco's comments

* daml-lf: remove unsafe unapply from MatchingStringModule

* fix navigator

* Address Stephen's Comments
2019-05-13 11:17:12 +00:00
Francesco Mazzoli
de54e8f60f
dynamically check type of contract ids, fixes #1005 (#1037)
Up to now, the engine blindly assumed that contract ids pointed to
contracts of the right type. However, this assumption is faulty:
contract ids coming from the Ledger API cannot be type checked
in command translation since we need access to the contract itself
to do so.

This caused some seriously surprising / broken behavior: one could
send an exercise command with the wrong template id and still go
through, or break internal invariants about the type of choices.

This commit fixes this by checking that the type of the contract
instances we fetch is correct at runtime.

cc @hurryabit @dajmaki @remyhaemmerle-da @S11001001 @meiersi-da
2019-05-09 17:11:05 +02:00
Remy
0489c6e0a5
Daml lf type safty (Party & PackageId) (#761)
* daml-lf: split SimpleString into Party and PackageId

* daml-lf remove parameter from DefinitionRef
2019-05-06 20:40:43 +02:00
Neil Mitchell
fe3e5c9639
Delete DA.Prelude (#914)
* Use DA.Prelude a lot less

* Make LANGUAGE pragmas have the right case

* Don't reexport DA.Prelude

* Remove more DA.Prelude imports

* Remove the nastiest renaming DA.Prelude

* Final removal of DA.Prelude

* Kill DA.Prelude

* Add missing dependencies

* More missing package imports

* More missing package imports

* Update compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs

* Update compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs
2019-05-04 18:51:56 +01:00
Neil Mitchell
3cab59ad6d Remove completely redundant imports of DA.Prelude (#911)
* Remove completely redundant imports of DA.Prelude

* Start chipping away at some NoImplicitPrelude too
2019-05-04 12:40:07 +00:00
Stephen Compall
f5490a5454 add LF 1.dev "minor dev version" (#709)
* clean up v3 contract key case in TransactionVersions

* clean up duplicate cases in ValueVersions.assignVersion

* make LanguageMinorVersion a proper ADT, aliased LanguageVersion.Minor

* port DecodeV1 to LanguageMinorVersion ADT via implicit conversion

- @remyhaemmerle-da might prefer the explicit application of Stable/Dev

* make releasePrecedes private

* add dev versions to the timeline

* copyright header for LanguageMinorVersion

* build the package database for 1.dev, support 1.dev as --target

* test presence and new-ness of "dev" in timeline

* report dev versions in engine info; note 1.dev target in release notes

* spec and governance rules on 1.dev and minor dev in general

* make the governance rule about dev more direct

* 1.x

* missed plural; thanks @leo-da

* further definition of 1.dev in LFv1 spec; thanks @remyhaemmerle-da
2019-05-03 10:36:45 +02:00
Neil Mitchell
4040dffc7a
Start cleaning up pretty-print (#821)
* Move from prettyDiagnostic to prettyDiagnostics

* Remove as much pretty print stuff as we can

* Try moving duplicate named functions with similar semantics and identical types to different names

* Change to returning pretty printed outputs from Diagnostics

* Remove a redundant import
2019-05-01 19:06:00 +01:00