Commit Graph

1703 Commits

Author SHA1 Message Date
Moisés Ackerman
f59d1cd0b4
Convert experimental primitive TYPEREP_TYCON_NAME into proper LF builtin (#13465)
* Convert experimental primitive TYPEREP_TYCON_NAME into proper LF builtin

* Add entry for TYPEREP_TYCON_NAME in daml-lf spec

* disable quickcheck test in DA.Test.Packaging

changelog_begin
changelog_end
2022-03-31 14:35:46 +02:00
Sofia Faro
7000875e62
interfaces: Make fromInterfaceContractId pure, add fetchFromInterface (#13453)
* interfaces: Make fromInterfaceContractId pure.

This PR changes `fromInterfaceContractId` to make it pure. This means
it cannot verify the contract id coercion, and should only be used
with care. To balance this, this PR also adds `fetchFromInterface` which
combines a `fetch` with a `fromInterface` and `fromInterfaceContractId`,
to serve as a safer alternative to `fromInterfaceContractId`, and is more
useful than the old `fromInterfaceContractId` since it also returns the
fetched & converted contract payload.

changelog_begin
changelog_end

* fix integration tests

* add submitMustFail tests for fromInterfaceContractId
2022-03-30 16:42:03 +00:00
Moisés Ackerman
da812e4c8b
Drop duplicate packages in dependency graph (#13442)
* Drop duplicate packages in dependency graph

* Add double data-dependency test

changelog_begin
changelog_end
2022-03-30 14:54:26 +02:00
Moisés Ackerman
f9f1611d46
Unsafe interface conversion primitives (#13391)
* Add unsafeFromInterface method to HasFromInterface class

* Use unsafeFromInterface instead of fromInterface + experimental primitive

* Drop THROW_WRONGLY_TYPED_CONTRACT experimental primitive

* Add UnsafeFrom{,Required}Interface LF primitives

* Add convertPrim cases for UnsafeFrom{,Required}Interface

* Add InterfaceGuarded tests for WronglyTypedContract cases

changelog_begin
changelog_end

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2022-03-25 10:07:14 +00:00
Moisés Ackerman
1185eb32bc
Preserve inherited choice info in daml test coverage report (#13354)
* Preserve inherited choice info in 'daml test' coverage report

changelog_begin
changelog_end
2022-03-23 12:28:04 +01:00
Stefano Baghino
50fd93c250
Address remaining issues about CVE-2021-44906 (#13382)
Addresses https://github.com/digital-asset/daml/security/dependabot/28
Addresses https://github.com/digital-asset/daml/security/dependabot/24

changelog_begin
changelog_end
2022-03-23 11:06:31 +00:00
Robin Krom
d10f678518
ifaces: tests for by_interface in transactions (#13365)
We add tests to check that by_interface fields are set for interface
transactions. We also extend the scenario service to show the
by_interface fields in the pretty printed transactions.

Fixes #13333

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-22 19:53:49 +00:00
Moisés Ackerman
b800fdc99a
expand buildLfPackageGraph docstring (#13343)
changelog_begin
changelog_end
2022-03-21 13:29:59 +01:00
Moisés Ackerman
2971949913
Allow dependencies that depend on data-deps (#13205)
Previously, all dependencies were installed first in a single step, and then
the data-dependencies were installed according to the dependency graph. 
This failed for dependencies with data-dependencies since those are processed later.

This was achieved by installing _all_ dependencies and data-dependencies according to the
dependency graph. Additionally, to ensure that the instance-rewriting behavior is preserved, 
the dependency graph is extended with edges from each data-dependency to the subset of 
dependencies without data-dependencies.

[instance rewriting behaviour: the class instances from data-dependencies are rewritten 
to refer to a matching class definition from a dependency when such a class definition exists.
]

* Add edges from each data-dependency to all dependencies without data-dependencies

* Generate stub sources inside for loop

* Update PackageMap manually

* Make PackageNode a sum type

* Add TODO for replacing recachePkgDb

* Tests

    * Generalize 'data-dependencies + exposed-modules' test with QuickCheck

    * Add test for building a project where a dependency has a data-dependency

    * Add test for building a project where a dependency has a data-dependency which is a plain dependency of the main project

    * Add test for building a project where a dependency has a data-dependency which is not a dependency of any kind of the main project

changelog_begin
changelog_end
2022-03-18 16:10:29 +01:00
Sofia Faro
79715ad32d
interfaces: Drop the typerep, raise WronglyTypedContract (#13314)
* Drop the typerep in interface desugaring.

GHC PR: https://github.com/digital-asset/ghc/pull/110

Fixes https://github.com/digital-asset/daml/issues/13275 and https://github.com/digital-asset/daml/issues/13283

changelog_begin
changelog_end

* compile ghc-lib

* update bazel-haskell-deps

* update InterfaceTypeRepCheck test

* scalafmt

* update compile.yml

* update bazel-haskell-deps last time
2022-03-17 16:12:46 +00:00
Sofia Faro
1feb4d25eb
Drop typerep argument from ExerciseInterface. (#13284)
* ifaces: Remove typerep arg from UExerciseInterface

changelog_begin
changelog_end

* Drop typerep argument in protobuf and haskell ast

changelog_begin
changelog_end

* scalafmt

* fix ExprParser

* fix PhaseOneTest

* fix validation test

* update evidencing security
2022-03-15 13:53:06 +00:00
Sofia Faro
83bdd983da
interfaces: Mark interface functions as 1.dev only in docs (#13268)
* iface: Mark functions as 1.dev only in docs

changelog_begin
changelog_end

* Update compiler/damlc/daml-stdlib-src/DA/Internal/Interface.daml

Co-authored-by: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

Co-authored-by: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>
2022-03-14 11:47:14 +00:00
Moritz Kiefer
a8057a5741
Handle absence of table view in Daml Studio (#13245)
We encounter that when there are no transactions which can happen
legitimately if you’re testing pure functions.

fixes #11244

changelog_begin

- [Daml Studio] Fix an issue where script views failed to display if
  there were no transactions. Now you can see trace messages even in
  those cases.

changelog_end
2022-03-10 11:56:06 +01:00
Remy
851fb53083
add milli/micro-seconds to RelTime and fix doc (#13217)
CHANGELOG_BEGIN
CHANGELOG_END
2022-03-09 19:09:10 +00:00
Moritz Kiefer
4e004e0a88
Replace scenario messages with script (#13207)
* Replace scenario messages with script

In theory we could try to be clever and print the "right" thing. In
practice, scenarios are almost dead so the complexity for that doesn’t
seem worth it.

fixes #13178

changelog_begin
changelog_end

* .
2022-03-09 11:35:37 +01:00
Moritz Kiefer
af855e5675
Speed up Daml repl startup (#13172)
* Speed up Daml repl startup

Daml repl startup is stupidly slow to the point where starting up and
executing 1+1 takes ~7s (piped to stdin so no typing included).

This PR speeds this up to ~4.5s. In addition to that, we also display
the repl process sooner and complete the last bit of setup while the
user is typing.

Specifically, we do the following:

1. Startup the JVM process in parallel with initializing our package
   db and only block on it once it’s started (and remove a stupid 1s
   sleep which doesn’t actually matter).
2. Load all packages in one go instead of one by one. This (roughly)
   matches how the script service works.
3. Only block on packages being loaded once we start running the
   script. Users can type before and we even typecheck their stuff
   before.

We could take this further and do even more in parallel with users
typing but this seems to strike a good balance between implementation
complexity, UX (if startup actually fails you get somewhat sensible
errors) & performance.

changelog_begin
changelog_end

* handle tls logs

changelog_begin
changelog_end

* Update compiler/damlc/daml-compiler/src/DA/Daml/Compiler/Repl.hs

Co-authored-by: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

* s/terminateBarrier/exitBarrier/

changelog_begin
changelog_end

Co-authored-by: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>
2022-03-09 08:22:42 +00:00
Gary Verhaegen
dfa648f585
hunt down DAML better (#13195)
Process:

- `git ls-files -z | xargs -0 -n 100 sed -i --follow-symlinks 's/DAML/Daml/g'`
- `git add -p`
- `git restore -p`
- Check there is no unstaged change left.

To review:

- Check for false positives by carefully reviewing the diff in this PR.
- Check for false negatives with `git grep DAML`.
- Quicker check for fals positives:

```
git grep DAML | grep -v migration | grep -v DAML_
```

Fixes #13190

Note: This is the "second half" of #13191, which failed to cover all the
remaining DAMLs because of:

```
$ git ls-files | grep "'"
compiler/damlc/tests/daml-test-files/MangledScenario'.daml
```

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-08 17:04:58 +01:00
Gary Verhaegen
961ca80b77
hunt down DAML (#13191)
Process:

- `git ls-files | xargs sed -i 's/DAML/Daml/g'`
- `git add -p`

To review:

- Check for false positives by carefully reviewing the diff in this PR.
- Check for false negatives with `git grep DAML`.

CHANGELOG_BEGIN
- Removed all traces of DAML. This may affect error messages and debug
  outputs.
CHANGELOG_END
2022-03-08 14:25:25 +01:00
Sofia Faro
b2d6f8014c
LF: Use template parameter (this) in method bodies. (#13142)
* Use `this` param in method bodies in LF.

Instead of having method bodies be functions from the template, have them reuse the existing template parameter (usually `this`).

Fixes #13123

changelog_begin
changelog_end

* fix validation-test
2022-03-03 13:50:59 +00:00
Moisés Ackerman
7ca26b01ce
make interface declaration where optional (#13129)
* Extend InterfaceSyntax test file with interfaces declared without 'where'

changelog_begin
changelog_end
2022-03-03 11:09:56 +00:00
Moisés Ackerman
2dbd91aab9
Interface methods can use plain function declaration syntax (#13102)
* Update 'implements' blocks to use new syntax

* Add InterfaceSyntax test case

* Add InterfaceMultipleMethodDeclsError test case

* Add InterfaceDifferentNumArgsError test case

changelog_begin
changelog_end
2022-03-02 15:59:01 +00:00
Moritz Kiefer
7acc6a9009
Pipe hpp through package_app (#13128)
This is needed so shared libraries are properly resolved and this
actually works outside of our build. Same issue that broke
damlc_legacy originally and we had someone trying to use cpp on their
own project (whether they should is another question but having it
half working is even worse).

I don’t know how to write a test for this unfortunately. It would only
fail if our nix store is not available which is pretty hard to
simulate. I could spin up a docker image or something but that doesn’t
seem worth the trouble.

fixes #13100

changelog_begin
changelog_end
2022-03-02 16:04:12 +01:00
Sofia Faro
db100c131a
Prevent iface choice & method name collisions. (#13075)
* Prevent iface choice & method name collisions.

This PR adds interface choices and methods to the name collision checker.

changelog_begin
changelog_end

* check the names from interfaces

* add error

* implement name collision check in scala side

* scalafmt
2022-02-28 13:21:41 +00:00
Moisés Ackerman
7af4215261
Interfaces accept at most a single ensure clause (#13093)
* Add test for multiple ensure declarations in interface

* update ghc patch

* Update expected result for daml-doc interface test

changelog_begin
changelog_end
2022-02-28 14:12:40 +01:00
Robin Krom
3692a4a565
interfaces:ensure that implementations are ordered (#13071)
* interfaces:ensure that implementations are ordered

We make sure that the implementations are ordered by insertion in the
Scala AST. This is important to guarantee an evaluation order of the
interface preconditions that is determined by the order of interface
implementations of a template.

CHANGELOG_BEGIN
CHANGELOG_END

* use VectorMap instead of ListMap
2022-02-25 15:14:50 +00:00
Moritz Kiefer
0ea4866adc
Fix activeness display in script service (#13059)
The previous way of tracking this only worked for direct children of
rollback nodes but lost the information when there was an exercise
node in between.

Reported in https://discuss.daml.com/t/exception-rollback/4000

changelog_begin

- [Daml Studio] Fix a bug where contracts that have been rolled back
  would still show up as active in the table view and in the list of
  active contracts at the end of the transaction view. This only
  affected display. Fetching those contracts failed and `query` also
  did not return those contracts.

changelog_end
2022-02-24 16:20:00 +01:00
Moisés Ackerman
58132cf71c
Fix data-deps orphan imports without explicit packageRefs (#13055)
* Include orphan instance imports in buildLfPackageGraph

* Add failing test for cross-DAML-LF version data-deps with stdlib orphan instances

* Add failing test for cross-DAML-LF version data-deps with custom orphan instance

changelog_begin
changelog_end
2022-02-24 15:03:10 +01:00
Moisés Ackerman
91ddbe9cf0
Include interface choices in 'damlc test' coverage stats (#13012)
changelog_begin
changelog_end
2022-02-23 13:44:36 +01:00
Remy
e834a7b85c
Triggers: Connect Logging context from Triggers to the Speedy. (#13009)
Follow up of #12976.
fixes #12208

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-22 18:28:49 +01:00
Moisés Ackerman
2532cf8991
Derive Eq for interfaces (#12988)
changelog_begin
changelog_end
2022-02-22 16:33:48 +01:00
Moritz Kiefer
8a966bfaf3
Upgrade sphinx (#12968)
* Upgrade sphinx

Don’t want to be stuck on 1.8.3 forever. The current version is
4.4.0 (this upgrades to 4.3.1 which is the latest in nixpkgs).

I did had to drop footnotebackref. This runs into the same issue as
https://tex.stackexchange.com/questions/137594/hyperref-footnotebackref-in-longtable
but just copying the fix doesn’t work and I don’t understand enough
about the details here to fix this myself.

We have 7 footnotes in the Daml docs + some in the Canton docs. That
does not seem worth sticking on a sphinx version from 2018 for just to
get backreferences from footnotes to the link on the same page.

changelog_begin
changelog_end

* turns out you need fonts maybe

* .

changelog_begin
changelog_end

* suppport :force: in daml-docs

changelog_begin
changelog_end
2022-02-22 14:30:15 +00:00
Sofia Faro
b842b53ff4
Delete vestigial InterfaceChoice from AST (#13017)
* Delete vestigial InterfaceChoice from AST

This is a leftover from when interfaces had virtual choices.

changelog_begin
changelog_end

* delete more
2022-02-22 13:59:04 +00:00
Sofia Faro
b626aeb632
Add experimental builtin to show template typerep (#13004)
Part of #12792, this is the builtin we need to be able to effectively
store a TemplateTypeRep inside a template (i.e. you store a string
containing the template id, not a typerep).

changelog_begin
changelog_end
2022-02-21 18:24:56 +00:00
Remy
ac3d9a4647
LF: Add LoggingContext to Speedy Machine (#12976)
This advances the state of #12208

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-21 13:34:46 +01:00
Moritz Kiefer
04eff2722c
Drop daml-lf-verify (#12942)
This is completely unmaintained, unused and partially broken so delete
it for now. Worst case, we recover it from Git history.

closes #6550 because it now refers to deleted code.

changelog_begin
changelog_end
2022-02-15 12:31:32 +01:00
Moisés Ackerman
4848519fc6
Enable go-to-definition for interface methods and choices (#12903)
* Extend interface go to def test to cover methods and choices

changelog_begin
changelog_end
2022-02-15 08:30:30 +00:00
Moritz Kiefer
d6e6c568fe
Fold daml test-script under daml script --all (#12895)
I tried to keep the changes somewhat minimal and reuse what is already
there. I think there is a fair amount of cleanup we can do afterwards
but hopefully this way it’s easier to review.

fixes #12837

changelog_begin

- [Daml Script] `daml test-script` has been replaced by `daml script
  --all`. The option to spin up a ledger automatically has been
  removed and you always have to specify one.

changelog_end
2022-02-14 14:23:21 +01:00
Victor Peter Rouven Müller
c0c40bd10f
Add autoformatting to ts bindings & navigator frontend (#12693)
* Add autoformatting for the ts&tsx files (typescript effectively)

changelog_begin
changelog_end

* Format ts files

* Fix ts linter warnings
2022-02-11 11:44:52 +00:00
Moisés Ackerman
a179f03197
Enable go-to-definition for interfaces (#12865)
* Add goto definition test cases for exceptions and interfaces

changelog_begin
changelog_end
2022-02-11 11:01:30 +00:00
Moisés Ackerman
a59156084f
Generate Eq instances for interfaces (#12850)
changelog_begin
changelog_end
2022-02-10 15:13:20 +00:00
Moritz Kiefer
0fb0bf2f52
Disable implicit party allocation in Daml Studio (#12839)
* Disable implicit party allocation in Daml Studio

fixes #12058

This matches what sandbox does in 2.0 so it reduces a source of
inconsistency and potential confusion.

changelog_begin
changelog_end

* Update compiler/scenario-service/protos/scenario_service.proto

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2022-02-09 17:47:40 +00:00
Sofia Faro
55cada7c47
Make interfaceTypeRep return a TemplateTypeRep (#12838)
* Make interfaceTypeRep return a TemplateTypeRep

Part of https://github.com/digital-asset/daml/issues/12788

* Update bazel-haskell-deps and code

changelog_begin
changelog_end

* Add missing import

* update ghc-lib sha

* update bazel-haskell-deps
2022-02-09 15:39:08 +00:00
Moritz Kiefer
22165730bf
Migrate Haskell tests to Sandbox on X (#12761)
* Migrate Haskell tests to Sandbox on X

The diff here looks extremely confusing. sandbox-classic is now
sandbox on x not sandbox classic so this isn’t a typo. It is really
moving to sandbox on x.

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2022-02-07 21:18:16 +01:00
Moritz Kiefer
486c869986
Replace most scenario references in the docs by Daml script (#12741)
* Replace most scenario references in the docs by Daml script

There are still some left in the Daml studio docs (should be updated)
and in quickstart-java (should be updated but probably not by us
🤷) but I’ll leave those for separate PRs.

changelog_begin
changelog_end

* delete unused code

changelog_begin
changelog_end
2022-02-03 15:55:55 +00:00
Moisés Ackerman
3ce272b9f0
Replace experimental interface primitives with proper LF primitives (#12678)
* Add new primitives to proto spec

* implement E{Signatory,Observer}Interface in terms of EResolveVirtual{Signatory,Observer}

* define EToTypeRep primitive in terms of EToTypeRep Expr

* Remove experimental primitives TO_TYPE_REP and RESOLVE_VIRTUAL_{SIGNATORY,OBSERVER} 

changelog_begin
changelog_end
2022-02-03 13:36:45 +00:00
nickchapman-da
cd16eb740e
Rename: listUsers --> listAllUsers (within daml-script) (#12734)
* Rename: listUsers --> listAllUsers (within daml-script)

changelog_begin
changelog_end

* fix/rename in newly add def: clearUsers

* improve comment doc
2022-02-03 13:07:09 +00:00
Remy
ed1bf2469a
LF: Check activeness of cached contracts inside FetchInterface (#12698)
Missed in #12527.

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-01 19:06:40 +00:00
Moisés Ackerman
e4764cc426
Upgrade to GHC 9.0.2 (#12300)
changelog_begin
changelog_end

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2022-02-01 11:27:11 +01:00
Stephen Compall
1fa095a327
match Foldable.foldl1's argument order to DA.List.foldl1's order (#12685)
List.foldl1 uses the first argument as the accumulator, whereas
Foldable.foldl1 uses the second argument.  I believe the latter is an
oversight (though the documentation doesn't suggest one way or the
other), so swap them here.

As discovered and reported by @gyorgybalazsi on the Daml Forum:
https://discuss.daml.com/t/in-daml-foldl1-works-differently-from-haskell-is-this-intentional/3819

CHANGELOG_BEGIN
- [Daml Standard Library] An argument order in the default
  implementation of ``Foldable.foldl1`` was reversed from that of
  ``DA.List.foldl1``; this incompatibly changes the former to match the
  latter.
CHANGELOG_END
2022-02-01 08:05:30 +00:00
Sofia Faro
dcbb398cae
Typecheck experimental primitives in damlc (#12650)
Adds a check that experimental primitive is defined in damlc, before you can use it.

This is only for the Haskell side, and only intended so we can catch bugs in the compiler more easily. (It would have caught the bug where `observer` wasn't defined correctly in LFConversion.)

I also removed RESOLVE_VIRTUAL_CREATE since we're not using it anywhere, it has been superseded by UCreateInterface.

changelog_begin
changelog_end
2022-01-31 09:33:34 +00:00