Commit Graph

230 Commits

Author SHA1 Message Date
Remy
f3b98ca31d DAML LF: limit allocations for trivial constants (#3212)
* speedy: limit allocation of trivial SValue constants

* daml-lf: limit allocation of constants for Value, Exp, Type

* weaken numeric equality in ledger service test
2019-10-18 15:00:49 +00:00
Remy
5d9d679607 daml-lf. fix mapContractId for Any values (#3231) 2019-10-18 14:40:26 +00:00
Remy
25c3797d89
DAML-LF Numeric: compute properly the value version for + test update (#3122)
* extractor: update test with numerics
* java-codegen: test numeric
* fix some numeric tests
* fix assignVersion for values
2019-10-17 13:17:21 +02:00
Remy
416bfcfa8e
daml-lf: fix maven coordinates of daml_lf_archive_reader (#3209) 2019-10-17 10:50:56 +02: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
4815d6f9a9 daml-lf: fail if asked to encode unsupported features into older versions (#3204)
* fix LF value encoder

* fix futher tests
2019-10-16 16:42:55 +00:00
Moritz Kiefer
f4766ad903 Forbid quantifiers in Any in the Haskell typechecker (#3200)
This is a followup to #3196 which updated the Scala typechecker
2019-10-16 15:10:45 +00:00
Remy
506a3be6e5 Revert "Revert "Intern all strings and dotted names in the DAML-LF protobuf encoding (#3067)"" (#3120)
This reverts commit 4596c1bde6.
2019-10-16 12:12:07 +00:00
Remy
b2985c394f daml-lf: prevent use of quanitifier in any type (#3196) 2019-10-16 11:41:58 +00:00
Remy
a3518d671e daml-lf proto: archive proto for daml-lf 1.6 (#3142)
* daml-lf proto: archive proto for daml-lf 1.6

* try to fix archive ProtoTest for windows

* more windows fix for  archive ProtoTest
2019-10-15 18:35:20 +00:00
Remy
4cb883627f daml-lf: fix spec (#3070) 2019-10-15 18:01:20 +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
Remy
217405e883 daml-lf: Move archive protofile to a more usual place. (#3166)
* move daml-lf archive protobug to a more usual place

* formatting

* fix kvutils proto

* fix csharp namespace
2019-10-14 13:22:22 +00:00
Remy
dd5804bff5 validation: add mising cases in type traversable (#3164)
* validation: add mising cases in type traversable
+ remove default case

* minor simplification
2019-10-14 10:28:31 +00:00
Leonid Shlyapnikov
06a4d56025
Scala codegen StackOverflowError fix (#3159)
* introducing map and bimap

not relying on default implementations provided by Traverse and Bitraverse

* lazy collect

* updating release doc

* cleanup

* daml-lf/interface: add foldMap overrides

* implementing `bifoldMap` explicitly for `DefDataType` and `DataType`

* replacing `toStream` with `to[ImmArraySeq]`, updating release notes
2019-10-10 17:15:08 -04:00
Moritz Kiefer
dcdcf7f0c0
Generalize AnyTemplate type to Any in DAML-LF (#3141)
* Generalize AnyTemplate type to Any in DAML-LF

See #3131 for the motivation for this. The tl;dr is that we need
something like AnyTemplate for choice types as well.

Since the protobuf was already more general in anticipation of such a
change, this change only changes the internal AST on the Haskell and
Scala side.

Since AnyTemplate change has never made it out of 1.dev, I updated the
changelog in the LF spec instead of adding a new entry.

* Update daml-lf/spec/daml-lf-1.rst

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

* windows debugging

* more windows debugging

* clean expunge

* don’t cat the config file

* remove comment on type equality

* windows …

* gnah

* foobar

* foobar

* does anything ever work?

* reenable caching

* Do not build daml-lf-ast separately
2019-10-10 08:51:52 +02:00
Remy
fbad37d560 Engine: update daml-lf value proto (#3001)
* engine: create persisted value for numeric

* engine: update info test

* Apply suggestions from code review

Co-Authored-By: Gerolf Seitz <gerolf.seitz@digitalasset.com>

* engine: weaken scale constraints when transalting value

* Address Stephen's comments

* Address one of Stefano's comments

* daml-lf: fix transaction test
2019-10-07 19:27:23 +00:00
Andreas Herrmann
5266b042b2 Implement ToTextTemplateId in proto (#3118) 2019-10-07 14:56:52 +00:00
Andreas Herrmann
0ba7f9f8f2 Implement ToTextTemplateId primitive on Scala side (#3115)
* Implement TyCon primitive on Scala side

* tyCon --> toTextTemplateId

https://github.com/digital-asset/daml/pull/3115#discussion_r331901925
https://github.com/digital-asset/daml/pull/3115#discussion_r331903274
2019-10-07 13:09:14 +00:00
Remy
449500bad8 Revert "Intern all strings and dotted names in the DAML-LF protobuf encoding (#3067)" (#3114)
This reverts commit 68e4453324.
2019-10-04 16:13:27 +02:00
Martin Huschenbett
68e4453324 Intern all strings and dotted names in the DAML-LF protobuf encoding (#3067)
* Intern all strings and dotted names in the DAML-LF protobuf encoding

On one of our huge DAML code bases this has brought down the size of the
DALF by 60% and cut the memory usage during decoding by 50%.

The `@QUERY-LF` tests in the damlc integration tests check that the
interning actually works.

* Add scala decoder support for interned strings

* Memoize versionisOlderThan. Speeds up decoding by 6x.

* Properly fix the performance problem with version ordering

LanguageVersion.ordering was a `def` and not `val` causing us to
recreate the ordering tables every time.

* Clean up //daml-lf/archive:decode-test

* Use int32 for interning indices

* Adapt QUERY-LF tests

* Strip a few useless field_ prefixes

* Add test for uniqueness in interning tables

* Drop field_ prefix from jq queries

* Fix Scala encoder

* Fix bond-trading tests

* Rename decode-test to decode-tester

* Address @cocreature's comments

* daml-lf: proper versioning for reading internedStrings

* daml-lf repl: revert change
2019-10-04 11:26:31 +00:00
Remy
8b0a45d79b
Engine: add missing spec for Enum (#2997) 2019-09-26 09:08:46 +02:00
associahedron
46051e8d11
Start adding Numeric to the standard library. (#2950)
* Numeric implementation

* Dealing with all sorts of numeric literals.

* Fix DA.Generics

* Reduce code duplication with IF_NUMERIC

* Simplify Prelude with IF_NUMERIC

* Fix daml-lf validation for MUL_NUMERIC and DIV_NUMERIC
2019-09-25 10:56:33 +01:00
Remy
23c3c33fe1
scenario-service: run no validation, when called from ide (#3003) 2019-09-25 11:06:47 +02:00
Remy
337c5ff215 Engine: drop value versioning in commands (#2995)
* daml-lf: remove value Version from commands

* ledger-api: fix ledger api

* ledger: fix tests

* leger: drop dead code

* Address Gerolf's comment
2019-09-24 12:38:56 +00:00
Stephen Compall
22a5b17ea0 json-api: "table scan"-style query, literal equality and record subsets (#2826)
* ADT for json-api's LF value query predicates

* expand predicates into primitive cases

* expand more cases for the predicate reader

* instantiating type references

* record case

* get super-reductionist with ValuePredicate so we can tease out the proper model by operations

* just put the literal predicates in the ADT

* more primitive predicates

* properly build RecordSubset predicates

* tests for ValuePredicate LF value predicate functions

- false cases fail because outer layer still stubbed

* outer RecordSubset always used

* tests for comparing literal predicate and ApiCodecCompressed parsing

* map querying

* Adding ListMatch

* removing List test cases covered by LF-JSON encoding tests

* Optional support; precompile ListMatch elements

* use go instead of toFunPredicate

- deals with potential subst introduction as we make VP more abstract

* test cases for optional queries

* Adding VariantMatch

* Fixing comments

* some precompiling and fusion

* Adding value predicate to contracts/search endpoint, WIP

* Adding value predicate to contracts/search endpoint, WIP

* add filtering to ContractsService#filterSearch

* Adding contracts/search result filtering based on the constructed predicates

* cleanup

* make error throwing in ValuePredicate a little nicer

* scalafmt

* cleanup

* follow JSON format rules for numeric queries

* test that apiValueToLfValue . lfValueToApiValue = arr id

* API value -> LF value discards scale; account for that in ValuePredicate

- fixes queries that match numerics

* document query

* release note

* test for contracts/search with query

* more tests for contracts/search with query

* More tests and cleanup

* more cleanup

* better test

* Adding disclaimer

* records, not documents

* better error message in the fromCon case
2019-09-23 16:08:24 -04:00
Moritz Kiefer
2e9f300563 Address comments on AnyTemplate PRs (#2986)
* Address comments on AnyTemplate PRs

* Remove unnecessary HIDE
2019-09-23 17:58:02 +00:00
Stephen Compall
eebc901d8a
daml-lf: reserve % for use in the JSON API query language, or anything else (#2964) 2019-09-23 10:40:41 -04:00
Remy
d540f7aab0 Daml-LF: change Numeric max scale from 38 to 37 (#2969)
* daml-lf: numeric maxScale change from 38 to 37

* daml-lf: update spec

* udpate protobuf comments
2019-09-23 12:39:28 +00:00
Remy
a46f1c041a Daml-LF: make Numeric scale type safe (#2958)
* daml-lf: make numeric scale type safe

* navigator: fix scale

* ledger: fix scale in tests

* Update daml-lf/data/src/main/scala/com/digitalasset/daml/lf/data/NumericModule.scala

Co-Authored-By: Gerolf Seitz <gerolf.seitz@digitalasset.com>

* Update ApiCodecCompressedSpec.scala

* Update ApiCodecCompressedSpec.scala
2019-09-18 19:33:52 +00:00
Remy
5b36d5f88b Daml-LF: make archive decoder more restrictive for 1.dev (#2937)
* daml-lf: make decoder more restrictive

* daml-lf: update spec

* daml-lf: update comment in archive proto
2019-09-18 17:22:48 +00:00
Robert Autenrieth
b97ef28de1
Rename BlindingInfo fields (#2883) 2019-09-18 00:28:53 +02:00
Remy
220a03c9e8 Daml-LF: make MUL_NUMERIC and DIV_NUMERIC multi-scale (#2921)
* daml-lf: Make MUL_NUMERIC and DIV_NUMERIC multi-scale

* update release notes

* compiler: fix with type change
2019-09-17 14:32:49 +00:00
Moritz Kiefer
36e95f6cf3
Add Any type and to_any/from_any primitives to protobuf (#2930)
* Add Any type and to_any/from_any primitives to protobuf

Following a suggestion by Rémy, the protobuf representation is more
general and is associated with an arbitrary type instead of a
typecon. This allows us to easily extend this later to a full Any
type.

I’ve still called the type in the protobuf Any instead of Haskell’s
Dynamic since I find AnyTemplate more clear than DynamicTemplate and
having AnyTemplate and Dynamic seems confusing.

Right now, the decoder enforces that the type is a TypeCon.

* Fix some mistakes in the spec

* Update daml-lf/spec/daml-lf-1.rst

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

* Update daml-lf/spec/daml-lf-1.rst

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

* Update daml-lf/spec/daml-lf-1.rst

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

* Update daml-lf/spec/daml-lf-1.rst

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

* Add evaluation rule for to_any_template

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>
2019-09-17 15:02:59 +02:00
Remy
dc9429be1d Daml-LF: Add CAST_NUMERIC and SHIFT_NUMERIC (#2919)
* daml-lf: add CAST_NUMERIC and SHIFT_NUMERIC internally

* daml-lf: add CAST_NUMERIC and SHIFT_NUMERIC to archive proto

* daml-lf: update spec with CAST_NUMERIC and SHIFT_NUMERIC

* update release notes

* fix spec

* Address comments from Fran and Gerolf

* fix unrel
2019-09-17 08:52:54 +00:00
Jussi Mäki
ae6f0fd631
Revert "Do not consider archives that are already loaded in engine (#2898)" (#2910)
This reverts commit 6ed6e0e990.
2019-09-16 15:26:21 +02:00
Moritz Kiefer
1703a517de Implement AnyTemplate DAML-LF type on the Scala side (#2905)
* Implement AnyTemplate DAML-LF type on the Scala side

This is the first part of
https://github.com/digital-asset/daml/issues/2876. The PR adds
AnyTemplate to Speedy and to the internal expression representation
and adapts all the relevant infrastructure (e.g., the typechecker) and
the tests.

It does not yet change the protobuf representation, the Haskell side
or the spec. I’ll update the spec together with changing the protobuf.

* Add comments to SBToAnyTemplate and SBFromAnyTemplate

* Address some comments from Remy

* Only allocate TBuiltin(BTAnyTemplate) once
2019-09-16 10:54:52 +00:00
Remy
249e8a69fb ledger-service: fix numGen for scale 38 (#2908) 2019-09-16 10:18:43 +00:00
Jussi Mäki
6ed6e0e990 Do not consider archives that are already loaded in engine (#2898) 2019-09-13 15:44:18 +00: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
67ff23e199 Fix typo in DAML-LF spec (#2766)
* Fix type in DAML-LF spec

* Fix RST
2019-09-05 12:38:48 +00:00
Moritz Kiefer
5e962a2b61
DAML Triggers V0 (#2762)
This is a first step towards DAML triggers. At the moment, triggers
can consume (very simplified) create and archive events via the Ledger
API, update a state based on that and emit log mesages at each update.

All of this is likely to change significantly in the future, so I
would prefer to not focus too much on minor details for now.

As a test, I added a simple trigger that tracks active contract ids.
2019-09-05 12:56:41 +02:00
Moritz Kiefer
185579264f
Add a method to initialize speedy from a non-update expression (#2725)
* Add a method to initialize speedy from a non-update expression

We need something like this for DAML triggers. You can kind of fake it
since all the individual fields of Machine are exposed but `initial`
is private (for good reasons as it sets ctrl to null) which makes this
rather annoying to do.

* Base other initialization methods on fromSExpr
2019-09-02 18:50:13 +02:00
Stefano Baghino
e452aa2cea
Port semantic tests to the new test tool (#2718) 2019-09-02 14:40:10 +02:00
Remy
3ee9b83fb1 daml-lf: adapt interface reader to Numeric (#2666) 2019-09-02 10:02:56 +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
Remy
d26dcd82eb leger-api-test-tool: semantics equality (#2707)
* engine: factorize value translation out of CommandPreprocessor

* ledger-api-test: add semantic equality for events

* engine: fix package resolution for ValueTranslator
2019-08-29 16:38:13 +00:00