Commit Graph

750 Commits

Author SHA1 Message Date
Remy
e2e0523b78
LF: fix versioning output in LF Repl. (#8219)
With this PR, the Repl now:
* outputs the transaction version (not sure why it was not
there before)
* outputs the node version, because each node is now versioned
independently (See #7788)
* drops the value version, because it is dictated by the node version
(See #7788)

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-09 17:40:12 +01:00
Remy
8f3c6a4494
LF: Add version directly in GenNode (#8154)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-08 16:12:12 +01:00
Moritz Kiefer
7e05dc7932
Upgrade rules-scala and scalatest (#8187)
This is necessary to at least attempt an upgrade to 2.13 and
generally, I want to keep our rulesets up2date. rules-scala forces the
version of scalatest so we have to bump that at the same time.

This requires changes to basically all Scala test suites since the
import structure has changed and a bunch of things (primarily
scalacheck support) got split out.

Apologies for the giant PR, I don’t see a way to keep it smaller.

changelog_begin
changelog_end
2020-12-08 06:59:23 +01:00
Remy
ab43da3f7a
Speedy: Add a built to optimize cons with 1 elems (#8177)
We have a builtin SBConsMany use to concatenate a list with a prefix
of variable size. Its appear that most of the concatenation happens
with only one element. For this reason we add a new builtin to handle
the most efficiently possible the case with 1 element.

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-07 15:13:33 +01:00
Samir Talwar
88cb4c0981
daml-lf: Include position information in the testing parsers. (#8182)
So it's easier to figure out where I've gone wrong.

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-07 12:33:00 +00:00
Samir Talwar
5943e1ae8d
daml-lf: Simplify types in the TransactionBuilder test helper. (#8178)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-07 09:46:24 +00:00
Samir Talwar
38de5b1eb3
daml-lf: Remove aliases that have been deprecated since v1.4. (#8155)
CHANGELOG_BEGIN
- [DAML-LF] Some types that were deprecated in DAML 1.4 have been
  removed. Please fix any deprecation warnings by using the new types
  before upgrading.
CHANGELOG_END
2020-12-03 17:07:42 +00:00
Stefano Baghino
56292dc191
Address leftover comments from 8019 (#8139)
changelog_begin
changelog_end

Address https://github.com/digital-asset/daml/pull/8019#discussion_r528755357

Address https://github.com/digital-asset/daml/pull/8019#discussion_r528763902

Address https://github.com/digital-asset/daml/pull/8019#discussion_r528767077

Address https://github.com/digital-asset/daml/pull/8019#discussion_r528773062
2020-12-03 09:23:16 +01:00
Remy
45b04724ec
LF: Change ordering of builtin type to follow proto declaration (#8133)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-02 18:38:03 +01:00
Samir Talwar
93acf1e6cd
Bazel: Reduce visibility of Protobuf JARs and accoutrements. (#8121)
* Bazel: Reduce the visibility of some Protobuf targets.

* Bazel: Make Protobuf JAR visibility parameterizable.

Default to private, and explicitly make it public where it's needed.

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-01 14:00:44 +00:00
nickchapman-da
7d25cbba8b
test tail calls execute in constant env-stack (#8102)
* Tail-recursive function definitions execute with bounded environment and continuation stacks.

changelog_begin
changelog_end

* be more precise about the throw exception; use thrownBy

* add test for the KFoldr1Map/Reduce case
2020-12-01 10:35:58 +00:00
Martin Huschenbett
fbabb5e0f4
DAML-LF spec: Incorporate Remy's feedback on exceptions (#8111)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-30 18:08:31 +01:00
Remy
17bed0fd3b
LF: clean spec from deprecated version (#8108)
* LF: clean the spec from deprecated versions

This advances the state of #7155.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-30 15:32:57 +01:00
Kamil Bożek
012ae55d65
Engine API - multi-party submissions [KVL-703] (#8081)
* Multiple submitters field for Command

* Multiple submitters field for Engine API

* Tests for multi-party submissions in Engine

* Make use of multi-party Engine capabilities in the engine benchmark

* Enable multi-party submission in Engine's API
CHANGELOG_BEGIN
CHANGELOG_END

* Separate unit tests for multi-party engine

* Unit tests for multi-party submission transaction replay
2020-11-30 15:04:30 +01:00
Sofia Faro
72e2f7d967
Update protobuf for exceptions. (#8087)
* Update proto file for exceptions

* s/CONS/MAKE

* typo

* DefException

* var is interned

* fix DefException numbers

* adjust decoding slightly

* lint

* Update scala decoder.

changelog_begin
changelog_end

* update simplifier tests

* move the MAKE up front

* suggestions

* fix pretty

* add placeholder builtin infos on scala side

* add exceptions feature on scala side

* fix typos

* forgot THROW
2020-11-30 10:42:17 +00:00
Remy
e4869083fe
LF: drop support from deprecated LF versions. (#8083)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-27 21:33:45 +01:00
Samir Talwar
052f69cde9
ledger-api: Use proto_jars, and publish Protobuf sources separately from the Scala classes. [KVL-714] (#8091)
* ledger-api: Use `proto_jars`.

CHANGELOG_BEGIN
- [Ledger API] The Scala JARs containing the gRPC definitions no longer
  contain the *.proto files used to generate the ScalaPB-based classes.
CHANGELOG_END

* Create a source JAR for *.proto files in `proto_jars`.

* ledger-api: Publish the protobuf sources as "ledger-api-proto".

CHANGELOG_BEGIN
- [Ledger API] The *.proto files containing the gRPC definitions are now
  provided by a new Maven Central artifact, with the group "com.daml"
  and the artifact name "ledger-api-proto".
CHANGELOG_END

* release: We don't need the "main-jar" option.

* Bazel: Proto JARs will always have a Maven artifact suffix.

* Bazel: Simplify Protobuf source file TAR and JAR targets.

* Bazel: Extract out Protobuf functions.
2020-11-27 17:14:48 +00:00
Remy
10e360942b
LF: Optimize string validators (#8086)
String validators from com.daml.lf.data.IdString are use extensively.
This PR optimize the implementation of some of those.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-27 17:43:25 +01:00
Martin Huschenbett
da823c2c35
First batch of formal exception semantics (#8068)
* WIP Draft of formal exception semantics

CHANGELOG_BEGIN
CHANGELOG_END

* Make throw take an AnyException

* Don't allow templates as exceptions

* Make throw a builtin

* Pass the textual error message to to_any_exception

* Rename builtin exceptions to errors

* Rename to_any_exception in make_any_exception

* Fix typing rules for make/from_any_exception

* Add availability notes

* Fix typo
2020-11-27 16:12:32 +00:00
Remy
0c793790c9
LF: require type interning for 1.dev (#8069)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-27 13:20:54 +01:00
nickchapman-da
6afe9fff25
Refactor continuations for speedy machine (#8063)
* simplify interface to construct speedy continuations

move code from caller to definition

* relocate comment to the relocated code it refers to!

changelog_begin
changelog_end

* rename var: m -> machine

* relocate instrumentation print() from where KFinished is thrown, to where it is handled in run()

* revert KFinished back to an object (instead of a class taking machne); and revert back to use initialKontStack()
2020-11-27 11:56:46 +00:00
Samir Talwar
68459e60e9
Fix the paths of the files in protobufs.zip. (#8088)
Turns out the `package_dir` is not what we're looking for. Omitting it
fixes the path.

_Before:_

```
     1766  2010-01-01 00:00   protos-0.0.0/com/digitalasset/daml_lf_1_8/com/digitalasset/daml_lf_1_8/daml_lf.proto
```

_After:_

```
     1766  2010-01-01 00:00   protos-0.0.0/com/digitalasset/daml_lf_1_8/daml_lf.proto
```

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-27 11:51:22 +00:00
Samir Talwar
9976b4cd50
Bazel: Factor out logic around Protobuf JARs. [KVL-714] (#8084)
* kvutils: Use ScalaPB to generate a Scala JAR for daml_kvutils.proto.

* Bazel: Delete the unused `da_java_binary` rule, and inline `_wrap_rule`.

* Bazel: Factor out Java/Scala protobuf class generation into a helper.

CHANGELOG_BEGIN
CHANGELOG_END

* daml-lf/archive: Use `proto_jars`.

* Bazel: Remove the visibility modifier from `proto_jars`.

It's too confusing. Just make everything public.

* daml-lf/archive: Push protobuf source tarballs into `proto_jars`.

* Bazel: Add comments to the various parts of `proto_jars`.

* daml-assistant: Do unpleasant things with `location` in Bazel.
2020-11-27 08:34:53 +00:00
Remy
2b67c74d9a
LF: clean scala Decoder test. (#8077)
As requested by Martin in #8069, we extract most of the changes from
DecodeV1Spec in a separate PR.
This advances the state of #7155

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-26 16:16:27 +01:00
Remy
174ba1de30
Compiler: Clean compiler from from Exercise's actors (#8076)
This is the Haskell counterpart of #8071.
This advances the state of #7155.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-26 15:38:30 +01:00
Remy
41543ad161
LF: drop support for Exercise's actors (#8071)
This is a first set toward dropping support of deprecated LF version
(#7155).

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-26 14:38:16 +01:00
nickchapman-da
654f5e33b6
Fix tail-calls to execute in constant space by doing early pop of temporaries stack. (#8036)
changelog_begin
changelog_end
2020-11-25 15:12:21 +00:00
Andreas Lochbihler
2156f946d1
kvutils reports lookupByKey inconsistencies as Inconsistent (#7914)
CHANGELOG_BEGIN
kvutils reports LookupByKey node mismatches during validation as Inconsistent
instead of Disputed if they can be due to contention on the contract key
CHANGELOG_END
2020-11-25 13:36:26 +01:00
Martin Huschenbett
38a9c70a79
DAML-LF spec: Some minor fixes (#8050)
We correct some spelling mistakes and make the formatting of some rules a bit more consistent.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-24 15:07:54 +00:00
Remy
0e4adfc47b
LF: clean LF encoder from deprecated LF versions (#8049)
This advances the state of #7788.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-24 15:56:13 +01:00
Remy
68c92b479c
LF: version transaction node independently in proto (#7925)
This advances the state of #7788.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-24 14:07:33 +01:00
Stefano Baghino
d5ff0dd8ea
Refactor indexing to minimize transaction traversals (#8019)
* Refactor indexing to minimize transaction traversals

changelog_begin
[Integration Kit] Bugfix: daml.index.db.store_transaction metrics were keeping track of empty insertions, skewing down the numbers
[Integration Kit] Performance: minimizing the number of traversals of a transaction to index it, more efficient indexing
changelog_end

* Add empty stakeholders for non-consuming exercises

* Fix test to check usage of pre-computed blinding info

* Remove unnecessary string interpolators

* Shorten creation of net visibility

* Delete obsolete comment

* Add visibility of divulged contracts

* Address review https://github.com/digital-asset/daml/pull/8019#discussion_r527666572

* Address review https://github.com/digital-asset/daml/pull/8019#pullrequestreview-535399441

* Address review https://github.com/digital-asset/daml/pull/8019#discussion_r527681774

* Fix ordering of batches, use explicitly named types to avoid confusion

* Default to an empty set if a divulged contract is not visible in the current transaction

* Shorten references to store transaction metrics when writing

* Address review https://github.com/digital-asset/daml/pull/8019#discussion_r527745640

* Add divulgences from past transactions

* More fine-grained types and signatures
2020-11-24 13:08:35 +01:00
Martin Huschenbett
da551ea142
DAML-LF spec: Explain how to use LaTeX input (#8018)
Add a description of how to enable LaTeX input mode when editing the
DAML-LF spec in VS Code. Also add some additional symbols.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-20 13:41:10 +01:00
fabiotudone-da
2ff4d923a9
[KV] proto: add optional DamlTransactionBlindingInfo to DamlTransactionEntry [KVL-736] (#8005)
* KV proto: add optional DamlTransactionBlindingInfo to DamlTransactionEntry

CHANGELOG_BEGIN
CHANGELOG_END

* Wording

* Wording

* Rename party -> <action>_to for consistency

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

* Address review comments
2020-11-19 15:09:23 +01:00
Martin Huschenbett
cfb8681b1c
DAML-LF spec: Fix some bad markup for links (#8010)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-19 09:06:34 +00:00
nickchapman-da
6a745ed1fa
Support choice observers in 1.dev (#7922)
* Adapt to new desugaring for choice observers.

update hash of ghc patch.

changelog_begin
changelog_end

update ghc patch to final version

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

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

expose Optional constructors for desugared code to use

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

update LFConversion for choice-observers

first example using new choice observer syntax.

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

remove comment from example which says it is broken

improve variable names

improve tests for choice-observer clause

only test choice-observers SINCE 1.dev

add jq queries for choice observeres

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

test behaviour of choice observers

squash me

typo

* test more choice-observer divulgence

* Update documention for choice observers.

changelog_begin
Support choice observers in 1.dev
changelog_end

* fix docs build

* fix daml docs choice-observers example

* address comments: rewording text

* annotate choices observers as early-access in documention

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

* final tweaks to documentation text
2020-11-18 19:51:15 +00:00
Martin Huschenbett
f0e5bed36f
DAML-LF: Add interning for type to DAML-LF 1.dev (#7893)
* DAML-LF: Add interning for type to DAML-LF 1.dev

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

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

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

Doing this has a few benefits:

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

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

CHANGELOG_BEGIN
CHANGELOG_END

* Make jq tests aware of type interning

CHANGELOG_BEGIN
CHANGELOG_END

* Improve jq test

CHANGELOG_BEGIN
CHANGELOG_END

* Apply Remy's suggestions

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

* Improve the imperative bits

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Remy <remy.haemmerle@daml.com>
2020-11-18 11:14:30 +00:00
nickchapman-da
cdcfd379f0
When computing blinding info, divulge to choice-observers. (#7970)
changelog_begin
changelog_end
2020-11-16 16:35:31 +00:00
Remy
6700400760
LF: Update DAML-LF Governance process (#7926)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-13 15:03:54 +01:00
Remy
5ca5cc7e98
LF: few more tests for pattern matching exhaustiveness (#7959)
This follows late requests made by Martin in #7936.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-13 13:03:36 +00:00
Remy
c093e094cb
LF: Check DAML-LF pattern matches for exhaustiveness (#7936)
This reproduces changes made to the Haskell type checker (in #7892) in
the Scala type checker.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-13 10:47:11 +01:00
Remy
732c1ac792
LF: Make node validation taking into account version (#7947)
We introduce in #7835 VersionedNode which associate to each node a
version. In this PR, we update Transaction validation to take into
account this version when comparing nodes.

This advances the state of #7788

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-13 10:46:29 +01:00
Remy
57bc2c95c1
LF: check for ill-formed kinds in scala type checker. (#7949)
Following what have been done in #7944, we add a check in the Scala
version of the LF type checker that rejects invalid kinds (i.e. kinds
of the form k -> Nat).

This PR does the "Scala side" of #7917.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-12 13:52:56 +01:00
Sofia Faro
0057016519
Require pattern matching exhaustiveness in the LF spec. (#7946)
* Require pattern match exhaustiveness in spec.

Changes the rules for case expressions to require exhaustiveness.
This involves moving out the "well-formed case alternative" rules
to a separate judgement, and introducing a "pattern match
exhaustiveness" judgement.

The symbol ⊲ used for pattern match exhaustiveness comes from
sheaf theory and formal topology, where "A ⊲ B₁, …, Bₙ" means
"A is covered by { B₁, …, Bₙ }", indicating an exhaustive
coverage of A by possibly overlapping conditions B₁, …, Bₙ.
For example, see [this nlab page](https://ncatlab.org/nlab/show/posite).

It seemed appropriate.

changelog_begin
changelog_end

* rst syntax

* fix ExhaustVariant and some weird other syntax

* review comments
2020-11-12 11:47:55 +00:00
Remy
51d134f925
LF: fix complexity of TransactionBuilder#addNode (#7930)
Fix issue with slowSnoc underlines by Martin in #7835

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-11 12:57:59 +01:00
Remy
a14035cea5
Drop plan to implement contract key. (#7924)
Remove file describing how contract key will be implement.  The file
is not usefull as contract key have been fully implemented. Futhermore
the file contains plenty of out of date information.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-10 12:41:41 +01:00
Remy
a8902a75db
LF: version transaction node independently (#7835)
This PR prepares the change of inference algorithm described #7788
where each node is version independently. This PR associates to each
node of `VersionedTransaction` a version. In the current state, all
nodes are associated to the version of the transaction itself. The
inference algorithm (that will make those versions potentially
distinct) will be implemented in an upcoming PR.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-10 12:12:16 +01:00
Remy
db8fbcb502
LF: fix test scala type checker (#7905)
This PR fixes two bugs in the type checker:

- Fetch are now rejected if the type constructor does not match a
  template
- to_any, from_any, and type_rep are now rejected if the type
  parameter contains synonyms.


Additionally, this PR adds the type of the validation error that each
test case should throw in the test that ill formed expression are
properly rejected.  In the way we fix some wrong test cases.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-09 16:26:34 +01:00
Remy
6fd12862c2
LF: redesign transaction validation to return mismatching nodes. (#7826)
- Exercises' results are checked after the children have been checked.
- output the mismatching nodes in case of comparison failure.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-05 18:25:10 +01:00
Martin Huschenbett
feb3510a7c
DALF Reader: Refactor decoder environment (#7891)
* DALF Reader: Refactor decoder environment

Currently, the module to be decoded is part of the decoder environment.
This turned out to be unpleasant during my attempts to implement
interning for types since decoding the type interning table does not
happen in the context of a module.

This PR moves the module out of the decoder environment and passes it
to the decoder function for modules directly. Unfornatunately, we still
need to keep the module name in the environment since that is used as a
default when decoding location information. We solve this problem by
making the module name in the environment optional and always filling
it in when decoding in actual module.

CHANGELOG_BEGIN
CHANGELOG_END

* Adapt tests

CHANGELOG_BEGIN
CHANGELOG_END

* Follow Remy's suggestion

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-04 21:18:34 +00:00