Commit Graph

1460 Commits

Author SHA1 Message Date
Remy
39ee326a51
LF: Drop wrong toArraySeq method from ImmArray. (#12163)
The method is not correctly implement, as it should slice the
underlying array before returning it. Since it is not possible to
implement it in constant time, we simply drop it, in favor in other
conversion.

CHANGELOG_BEGIN
CHANGELOG_END
2021-12-16 10:18:52 +00:00
Moritz Kiefer
f146bc814b
Escape daml-lf tracelog messages (#12116)
* Escape daml-lf tracelog messages

Currently veracode complains because this allows for clrf
injection (injecting newlines to make user input look like separate
log statements).

With this change
```
debug "abc"
debug "eaiu\neaiu"
debug "def"
debugRaw "abc
```

is logged as

```
[DA.Internal.Prelude:555]: \"abc\"
[DA.Internal.Prelude:555]: \"eaiu\neaiu\"
[DA.Internal.Prelude:555]: \"def\"
[DA.Internal.Prelude:555]: abc
```

You can debate whether we should escape the quotes are necessary but
90% of the reason why people add them is because they call `debug` on
strings when they should be using `debugRaw` so this seems fine to me.

changelog_begin
changelog_end

* fix tests

changelog_begin
changelog_end
2021-12-14 11:20:33 +01:00
Remy
8c87a0e327
LF: Factorize interpretation loop emulation spread in multiple tests. (#12102)
CHANGELOG_BEGIN
CHANGELOG_END
2021-12-10 17:16:27 +01:00
Remy
1989a2def9
LF: Check non circularity of requires Interface field
CHANGELOG_BEGIN
CHANGELOG_END
2021-12-10 12:35:54 +00:00
Remy
35beb44c3c
LF: SErrorCrash should not be thrown by Speedy callbacks (#12099)
as it is normally caught in the interpreter loop.  In particular the
caller of the engine should not have to catch such an error.

CHANGELOG_BEGIN
CHANGELOG_END
2021-12-10 12:20:38 +00:00
Sofia Faro
b99952407c
Update TODOs to outdated issues. (#12090)
* Update TODOs to outdated issues.

In particular update a lot of defunct interface TODOs to the LF 1.15
issue (or add the LF 1.15 issue if it's also relevant).

changelog_begin
changelog_end

* typo

* remove numeric/bignumeric todo

* scalafmt!!

* drop choice observer TODO
2021-12-09 21:01:27 +00:00
Remy
a4fa1311ca
LF: Prevent circular and non-closed interface requirements (#12070)
CHANGELOG_BEGIN
CHANGELOG_END
2021-12-09 18:13:55 +01:00
nickchapman-da
fdf7431ad1
Move to using DB-levels (not DB-indexes) in SExpr0. This change includes both index and level, and performs a runtime check. (#11987)
changelog_begin
changelog_end

add runtime check in freeVars: determination that a variable is-free using levels instead of indexes

remove DB-indexes and runtime check; simplify freeVars computation in closure-conversion
2021-12-09 14:17:15 +00:00
nickchapman-da
39eca49586
compileCommand takes env (#12047)
changelog_begin
changelog_end
2021-12-09 11:38:54 +00:00
Moritz Kiefer
e036e2c00a
Implement user management in Daml script service (#12050)
* Implement user management in Daml script service

changelog_begin
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>

* move assertion into replaceInfo

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-12-08 16:11:09 +00:00
Remy
4f1892b0c8
Speedy: Implement EToRequiredInterface and EFromRequiredInterface (#12046)
Part of #11978.

CHANGELOG_BEGIN
CHANGELOG_END
2021-12-08 13:34:39 +00:00
Remy
c53cf758da
LF: Add EToRequiredInterface and EFromRequiredInterface to Scala Ast. (#12042)
Part of #11978. Adds typechecking for those primitives.

CHANGELOG_BEGIN
CHANGELOG_END
2021-12-08 11:09:10 +00:00
Remy
9e5bea193c
LF: Node statistics of a transaction (#12018)
fixes #11961

CHANGELOG_BEGIN
CHANGELOG_EN
2021-12-07 19:21:33 +00:00
Sofia Faro
43c8641215
interfaces: add up/downcast expressions in proto (#12030)
Part of https://github.com/digital-asset/daml/issues/11978

changelog_begin
changelog_end
2021-12-07 18:44:24 +00:00
Remy
9d7eb07745
LF: Add "requires" field to Scala Ast. (#12028)
Part of #11978. Adds typechecking for this field on the interface side,
and enforces that any template that implements A must implement B if A requires B.

CHANGELOG_BEGIN
CHANGELOG_END
2021-12-07 17:53:40 +00:00
Simon Meier
ef4ae931d1
Add Ledger API scala client for user management (#12000)
scala bindings: add client for user management API

CHANGELOG_BEGIN
- [Scala bindings] add methods to call the user management API
CHANGELOG_END
2021-12-07 13:36:05 +01:00
Sofia Faro
9430ee3131
interfaces: Add requires in DefInterface protobuf (#11986)
Part of #11978

changelog_begin
changelog_end
2021-12-07 00:38:59 +00:00
Remy
f228f9575c
LF: replace boolean by ADT in transaction traversal (#11988)
CHANGELOG_BEGIN
CHANGELOG_END
2021-12-06 18:19:47 +00:00
Moritz Kiefer
c29f4d333b
Fixed broken merge in //daml-lf (#11985)
changelog_begin
changelog_end
2021-12-06 14:32:37 +00:00
Moritz Kiefer
e01fcdf143
Add exhaustive tests for evaluation order on creates (#11957)
As mentioned in the comment, I view these tests as a way to guard us
against bricking ledgers on upgrades so they somewhat deliberately
ignore ordering of non-cachable errors relative to each other since
those only change error messages.

changelog_begin
changelog_end
2021-12-06 13:06:46 +01:00
Sergey Kisel
020712e2ed
Remove the use of nesting with size approach as suggested by scalacheck. (#11911)
* Remove the use of nesting with `size` and `resize` approach as suggested by scalacheck.

CHANGELOG_BEGIN
CHANGELOG_END

* Biased to shorter names generator for Name
2021-12-03 06:46:45 +01:00
Moritz Kiefer
53a74bc108
Include module names in LF type errors (#11962)
After staring at a type mismatch between `Nested` and `Nested` this
seemed like a sensible change. We could also include the package
ids. I don’t have strong feelings about this but this seems like a
clear uncontroversial improvement.

changelog_begin
changelog_end
2021-12-02 16:59:02 +00:00
Remy
b02ed7765a
LF: Introduce configurable limits on produced transactions (#11948)
This is part of #11691

This PR allows to limits:
- the number of signatories,
- the number of observers,
- the number of controllers,
- the number of inputContracts,

CHANGELOG_BEGIN
CHANGELOG_END
2021-12-02 16:31:09 +01:00
Moritz Kiefer
4571a48c48
Add skeleton for trace-based LF evaluation tests (#11949)
* Add skeleton for trace-based LF evaluation tests

The recent issues around wrong ordering of contract id typechecks got
me thinking about this again so I wanted to hack up a PR of how we can
test evaluation order sensibly directly at the LF level.

This is only testing a single create but I first wanted to see if we
agree that this is a sensible approach using a simple example.

If we agree that this is a sensible approach, I’d suggest to extend
those tests later in separate PRs to make them exhaustive.

changelog_begin
changelog_end

* cleanup

changelog_begin
changelog_end
2021-12-02 11:38:59 +00:00
nickchapman-da
a1db59f40f
Stack safe free-vars computation. (#11946)
* Adding missing stack-safety testcase for SEScopeExcerise.

changelog_begin
changelog_end

* run all testcases at depth of 10,000. This is plenty deep enough to ensure stack-safety

* recode free-vars computation to be stack-safe. and test
2021-12-01 17:06:57 +00:00
Moritz Kiefer
0eb88d6589
Drop outdated fixme comment about struct ordering (#11945)
This has been fixed over a year ago in #7319

changelog_begin
changelog_end
2021-12-01 14:02:46 +00:00
Moritz Kiefer
8179c73763
Drop support for Daml-LF party literals from the Scala side (#11922)
* Drop support for Daml-LF party literals from the Scala side

This PR enforces that forbidPartyLiterals is always `true` and drops
the corresponding literals from the AST. Haskell side is in #11930

fixes #11581

changelog_begin
changelog_end

* Update daml-lf/interpreter/src/test/scala/com/digitalasset/daml/lf/speedy/ComparisonSBuiltinTest.scala

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

* Revert "Update daml-lf/interpreter/src/test/scala/com/digitalasset/daml/lf/speedy/ComparisonSBuiltinTest.scala"

This reverts commit 55e542ce4e3a7fd15544ee703de3277ffc309b17.

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-12-01 10:37:42 +00:00
nickchapman-da
16a41f7da2
Avoid package validation in speedy compilation benchmark. (#11927)
changelog_begin
changelog_end
2021-11-30 16:50:42 +00:00
nickchapman-da
0ee4154972
Use Absolute-indexes as keys for the Env-mapping during closure-conversion (#11912)
* Use Absolute-indexes as keys for the Env-mapping during closure-conversion.

Do runtime check to confirm behaviour matches the existing Relative-indexes.

changelog_begin
changelog_end

* remove quadratic shift!

remove (dev)pretty-print code
remove relative-index keys from Env-mapping
remove runtime *diff* check
increase depth for stack-safety tests

* improve/simplify indexing calculation for Env-keys
2021-11-30 16:07:17 +00:00
Sofia Faro
1d7bca801e
Add optional typerep argument in UExerciseInterface. (#11910)
* Add type rep argument for interface exercises.

(Still WIP.)

Part of #11703. Fixes the order in which errors are raised ("wrong type"
takes priority over "does not implement interface"). This PR also simplifies
ExerciseInterface by making the guard mandatory, otherwise there's too
many variations. We can revisit that later if we want.

changelog_begin
changelog_end

* haskell side

* dont throw exception in checkTemplateId

* scalafmt

* evidence security

* fix TypingSpec test
2021-11-30 15:10:33 +00:00
Sofia Faro
0b9d57b95e
Add ContractDoesntImplementInterface error. (#11884)
* Add a ContractDoesntImplementInterface error

Part of #10810 and #11703

changelog_begin
changelog_end

* use inside

* rename error
2021-11-29 15:54:31 +00:00
nickchapman-da
2f4aa4797e
refactor to avoid impossible code path (#11901)
changelog_begin
changelog_end
2021-11-26 15:46:26 +00:00
Remy
58e69ade1a
LF: replace "dev" LF version by "1.dev" in bazel files (#11894)
the more consistent, as asked by Moritz in review of #11820

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-26 12:23:17 +00:00
nickchapman-da
8ef348dab0
Use absolute stack locations in SExpr1 (#11877)
* SExpr1.SELocS - carry relBad/absGood - abs unused so far

* compute/pass SELocS.abs in ClosureConversion, and check in Anf that it matches the reconstructed value

CHANGELOG_BEGIN
CHANGELOG_END

* Remove relative stack locations. Rename as SELocAbsoluteS. Simplify Anf. Remove shiftLoc in ClosureConversion.
2021-11-26 12:10:30 +00:00
Remy
d66ecc90c9
LF: Drop Archive Snapshot for LF < 1.14 (#11820)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-26 09:18:52 +01:00
Remy
b0dda53868
LF check stable proto with buf and md5sum. (#11888)
The resulting tests should be faster and more reliable

fixes #11443

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-25 20:23:46 +00:00
Sofia Faro
024400b9e4
Error when fetching the wrong template id (via fetch by interface). (#11862)
* Prevent wrongly typed fetch by interface.

When doing a "fetch by interface" command with a known template id,
error out with a WronglyTypedContract if the fetched contract has
a different template id. This doesn't affect daml, only affects
replays, so it's rather minor. I also enabled the engine test that
caught this.

Part of #11703, follow up to #11836.

changelog_begin
changelog_end

* strengthen test output checks
2021-11-25 16:19:36 +00:00
Sofia Faro
2f8f69e7cb
Drop DA.Next.Set and DA.Next.Map (#11864)
* Drop DA.Next.Set and DA.Next.Map

Fixes #11527. Also removed a bunch of unnecessary CPP, though there's
still a lot more CPP to remove.

changelog_begin

- [Daml Standard Library] DA.Next.Map and DA.Next.Set have been removed
  after being deprecated since Daml-LF 1.11

changelog_end

* Drop a deriving MapKey

* update unstable-types test
2021-11-25 13:02:08 +00:00
Andreas Lochbihler
3cd5028b61
fix a few more things in the daml-lf spec (#11851)
CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Remy Haemmerle <Remy.Haemmerle@daml.com>
2021-11-25 10:46:19 +01:00
Remy
86da6e8eef
LF: Test scala interface type checking (#11833)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-24 15:58:45 +00:00
Sofia Faro
5c12d757f4
Add a guard when exercising by interface. (#11836)
* Add a guard when exercising by interface.

This fixes part of #11703, when exercising an inherited choice by
interface and you know the template id, via the command preprocessor.

It does this by inserting a "guard" in between the interface fetch and
the exercise body. The guard is a function Interface -> Bool, which
is general enough to check the template id, without complicating too
much in speedy. And can be generalized in the future to check more,
like signatories, etc.

I added the guard as an optional argument to UExerciseByInterface.
This isn't hooked up to the protobuf AST yet (or Haskell side for
that matter) -- but I'll do it in the next PR! For now you can invoke
the guarded exercise via the command preprocessor, so I can enable the
approprate engine tests. (There's still some failing fetch tests left,
but I decided to leave this for later. Fetch can be a lot simpler than
guarded choices, since you always add a fetch node. No need for fancy
continuations.)

changelog_begin
changelog_end

* scalafmt

* Feedback and fix matches

* Update comments, we are always going to abort the transaction

* Raise WronglyTypedContract in SBGuardTemplateId.

* rebase and fix parser

* restore ANF

* scalafmt
2021-11-24 14:22:40 +00:00
nickchapman-da
0374843143
speedy compilation benchmark (#11852)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-24 13:10:18 +00:00
Remy
393893a601
LF encoder: make package validation optional (#11849)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-24 13:53:52 +01:00
nickchapman-da
970243dd46
Ensure stack-safety during closure-conversion. (#11778)
ClosureConversion -> Suffix with "Old"

CHANGELOG_BEGIN
CHANGELOG_END

ClosureConversion old-vs-new diff check

ClosureConversionNew, first cut. All tests in SBuiltinTest work.

In addition we change some Array --> List in SExpr1 (for human pp).
And we throw away ClosureConversionDup.

adapt AnfTest from Array to List change for SExpr1

all tests pass in daml-lf/interpreter

remove SExpr0.SELet1General

reorder things

testing for stack-safety of closure conversion

file/class renames

improve naming

pass cont as sep arg to commit (move out of Up/Down)

comment stack-safe closure conversion

fix bug: failed to use env1

fix 2x unmoored doc comment

comment stack safety testing

Remove old closure-conversion code & diff-check between old/new.

loose StackSafe suffix on ClosureConversion class/file

rename StackSafetyTest.scala to ClosureConversionTest.scala

prefer "sealed abstract class" to "sealed trait"

fvs.zipWithIndex --> fvs.view.zipWithIndex

(SExpr1) SEAppGeneral -> SEApp; prefer List to Array in SEApp/SECase

prefer xs.toArray to Array(xs: _*)

access SExpr0 via "source."

two more .view

improve comment and fix typo

link to Issue

switch to a continuation stack; avoids nesting in the Cont type
2021-11-24 11:47:39 +00:00
Remy
1610d977dc
LF: parsing interface primitives (#11825)
Continue work start in #11797

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-23 12:03:03 +00:00
Moritz Kiefer
5785bbfcfd
Drop LF < 1.14 from supported damlc output versions (#11701)
* Drop LF < 1.14 from supported damlc output versions

fixes #11319

We keep test coverage by depending on the most recent snapshot which
still has 1.14 support.

changelog_begin

- [Daml Compiler] Damlc can only produce Daml-LF 1.14 or
  newer. Passing aynthing older to `--target` is an error. If you
  need to produce older versions, use an older SDK.

changelog_end

* Switch around legacy_compiler_lf_versions

changelog_begin
changelog_end

* drop since-lf

changelog_begin
changelog_end
2021-11-22 16:20:17 +00:00
Remy
ae8391ee01
LF Parser: handle interface (#11797)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-22 14:49:02 +01:00
Sofia Faro
f8933d1f4b
Make lookupTemplateChoice return only choices in the template. (#11808)
This fixes a bug in the typechecker (#11558) and the command
preprocessor, since those were written with this behavior of
lookupTemplateChoice in mind. Enables the engine test that
caught this.

changelog_begin
changelog_end
2021-11-22 13:27:48 +00:00
Remy
f33486154f
LF: Simplify LF Syntax (#11795)
- Do not wrapped choices in `choices { ... }`
- use sytematic `;` after choice component instead of ',`

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-19 17:23:36 +01:00
Remy
cbe9c922ba
LF: Clean up Ast (#11786)
- rename non-default builders `apply` to `build`
  * avoid confusing both
  * make explicit the build can crash

- make interfaceId and templateId fields consitent

- use when possible named arguments

- check for non-repetition of inherited choices

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-19 15:40:28 +01:00
Remy
1bb2fc28a3
LF: Simplify transaction versionning for interface (#11744)
We revert #11626, and just change the way transaction version is
computed:

- As before, Node version is calculated from the
  package of the template ID action.

- Transaction version is the max of the version of all the nodes,
   instead of the root nodes.

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-18 22:46:46 +01:00
Sofia Faro
51f646cb22
Add engine tests for interfaces. (#11773)
* Add engine tests for interfaces.

Adds engine tests using the new commands. This uncovered a few issues:

- getDependencies doesn't work when given an interfaceId as a templateId
  (such as when exercising an interface via the ledger api). I patched
  it up so it deals with interface ids. We've already discussed a way to
  simplify getDependencies that will also avoid this in the future, but I'll
  leave that to the future.

- issue #11703 is confirmed via some tests that don't pass (and are
  currently disabled)

- PackageInterface.lookupTemplateChoice returns inherited choices, when it
  should only return own choices. At least, the typechecker assumes
  it doesn't -- this affects #11558 -- as does the command
  preprocessor. I'll leave the cleanup to a separate PR.

changelog_begin
changelog_end

* scalafmt, add missing file

* Move interfaces tests to separate file

* scalafmt
2021-11-18 16:40:03 +00:00
Moritz Kiefer
ac573551e7
Drop Scala 2.12 compatibility layer from //daml-lf/data (#11758)
* Drop Scala 2.12 compatibility layer from //daml-lf/data

changelog_begin
changelog_end

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

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

* drop dependency on compat libraries

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-11-18 17:34:06 +01:00
Moritz Kiefer
3b5f8a73e1
Remove precondition field from TemplateImplements (#11763)
* Remove precondition field from TemplateImplements

fixes #11635

changelog_begin
changelog_end

* Update daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-11-18 17:10:40 +01:00
Andreas Herrmann
39a38d3a37
Update to Java 11 (#11512)
* Update to Java 11

changelog_begin
changelog_end

* Fix RoundingMode deprecation warnings

* Fix dep-ann warning

* Integer constructor

* JavaX annotation dependency

* javax.xml.bind was removed in Java 11

Using Guava as a replacement, since it is already a project dependency.

* JDK 11 no longer has a separate JRE tree

* Remove unused jdk_nix import

* remove now redundant jdk11_nix

* Java 8 --> 9 increased Instant.now() precision

See https://bugs.openjdk.java.net/browse/JDK-8068730

The precision of `Instant.now()` increased between Java 8 and Java 9.
On Linux and MacOS this doesn't seem to be a problem, as the precision
still seems to be at micro seconds. However, on Windows this now causes
errors of the following form:
```
java.lang.IllegalArgumentException: Conversion of Instant
2021-11-05T13:58:56.726875100Z to microsecond granularity would result
in loss of precision.
```
Suggesting that it now offers sub-microsecond precision.

`TimestampConversion.instantToMicros` had a check to fail if the
conversion lead to a loss of precision. In the specific failing test
case this is not a concern, so this adds a `roundInstantToMicros`
variant that avoids this kind of error.

* TMP round timestamps

* Revert "TMP round timestamps"

This reverts commit af8e261278.

* Skip versions before 1.6.0 in migration tests

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-11-18 14:48:37 +00:00
Moritz Kiefer
c8ace8b1cf
Factor kind projector target into a variable (#11759)
Seems nicer than trying to format a string everywhere

changelog_begin
changelog_end
2021-11-18 09:51:43 +01:00
Moritz Kiefer
fa7663148a
Drop 2.12 versioned_scala_deps (#11748)
I’ve kept the infrastructure for versioned_scala_deps around because
I’m optimistic and hope that eventually we’ll do another Scala upgrade.

changelog_begin
changelog_end
2021-11-17 22:13:08 +00:00
Sofia Faro
c2d4ea4ef1
Add separate commands for create/fetch/exercise by template/interface. (#11724)
* Add separate commands wrt by template/interface

Resolves #11674 and #11675

changelog_begin
changelog_end

* remove unnecessary commands
2021-11-17 17:08:24 +00:00
Moritz Kiefer
f801314c16
Drop exercise with actor from LF spec (#11721)
This doesn’t exist since LF 1.5 and we don’t support that or any LF
version before anymore.

changelog_begin
changelog_end
2021-11-16 18:31:36 +01:00
nickchapman-da
a1fc5c6a25
Simplify handling for EqualList builtin. (#11676)
Step 1: SEBuiltinRecursiveDefinition(_) -> SEBuiltinEqualList

CHANGELOG_BEGIN
CHANGELOG_END

Step2: Replace SEBuiltinEqualList with SBuiltin.SBEqualList

update comment
2021-11-15 17:49:07 +00:00
Remy
775b41c235
LF: Reintroduce TransactionVersion.asVersionedTransaction (#11692)
* LF: Reintroduce TransactionVersion.asVersionedTransaction

This have been drop in #11626, but canton is using it.

CHANGELOG_BEGIN
CHANGELOG_END

* cosmetic

* cosmetic
2021-11-15 12:07:23 +00:00
Andreas Lochbihler
18433eb19e
fix arity of TArrow type constructor in Daml-LF spec (#11677)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-15 07:49:45 +01:00
Sofia Faro
57f1b868d3
Improve byInterfaceNodes based on suggestions (#11672)
* Improve byInterfaceNodes based on suggestions

From the last PR #11662

changelog_begin
changelog_end

* use transaction traversal order
2021-11-12 17:31:47 +00:00
Remy
15b925a116
LF: Compute transaction version as the maximum of the children (#11626)
fixes #11377

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-12 17:00:07 +01:00
Remy
7eb22ddf4f
LF: drop forgotten deprecate Node aliases. (#11673)
Because a bug in the scala compiler deprecated pattern matching are
not detected (See https://github.com/scala/bug/issues/12493).
Hence some deprecated usage of Node aliases have been forgotten in

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-12 15:07:22 +00:00
nickchapman-da
8c46559163
Remove unnecessary constructors: SEDamlException, SEImportValue, from SExpr{0,1} (#11668)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-12 12:40:52 +00:00
Sofia Faro
409864f220
Use by_interface field when fetching transaction dependencies. (#11662)
* Use by_interface field when fetching tx deps.

Fixes #10915

changelog_begin
changelog_end

* scalafmt
2021-11-12 09:37:24 +00:00
nickchapman-da
3192d5eb74
Different types before after closure conversion (#11661)
* avoid single letter (s./t.) import prefixes

* Split type SExpr0 -> SExpr{0,1} for before/after closure conversion

CHANGELOG_BEGIN
CHANGELOG_END

* remove unnecessary constructors in SExpr{0,1}

* remove SExpr0.SExprAtomic
2021-11-12 08:54:43 +00:00
nickchapman-da
7296ba4dfb
Move closureConvert and validate compiler phases into separate files. (#11656)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-11 13:38:05 +00:00
Sofia Faro
87f282c7f3
interfaces: Preserve/provide by_interface data for create actions. (#11639)
* interfaces: Preserve by_interface data for create.

Part of #10915

This was a lot more involved than fetch or exercise. The first issue is
that we need to preserve the interface id into speedy, so it needs a
separate primitive ("experimental" won't cut it). Second, because
speedy's create requires the template definition, and now the interface
id as well, we basically need to compile a separate version of "create"
for each interface that a template implements, hence the separate
`CreateByInterfaceDefRef(templateId, ifaceId)`.

changelog_begin
changelog_end

* scalafmt and refactoring

* fixx merge conflict

* fix silly mistakes
2021-11-11 12:57:55 +00:00
nickchapman-da
2dd5289a35
different types for different speedy phases (#11605)
* Refactor speedy to distinuish SExpr types before/after ANF compilation phase

CHANGELOG_BEGIN
CHANGELOG_END

* remove commment/marker left in error

* make SExpr0 private to speedy

* reinstate (non-pp) print of original expression in AnfTest faiure

* avoid use of s./t. prefixes for expressions in SBuiltin; add 3 TODO markers

* inline "runtime" apply methods of SDefinitionRef into sole caller: SBCallInterface

* avoid use of t. prefix in SExpr0

* change s./t. prefix to source./target.

* add comment to summarize differences between SExpr0 and SExpr
2021-11-11 08:21:12 +00:00
Remy
b8f384e193
LF: Drop typeparameter from KeyWithMaintainers (#11625)
Following up #10827 and #10921, we drop type parameter to
KeyWithMaintainers, and use the `Versioned` wrapper introduced in

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-10 13:21:13 +01:00
Remy
92181161cc
LF: Abstract VersionedValue and VersionedContractInstance (#11533)
* LF: Abstract VersionedValue and VersionedContractInstance

CHANGELOG_BEGIN
CHANGELOG_END

* formatting
2021-11-09 23:22:38 +00:00
Stephen Compall
b87acab897
foldLeft, foldRight, other Foldable specializations (#11592)
* FoldableContravariant, a mapping for Foldable instances

* use FoldableContravariant to specialize several ImmArraySeq, NonEmpty methods

* folding specializations for ImmArray

* a few docs for FoldableContravariant

* specializations for FrontStack

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-09 22:24:26 +00:00
Sofia Faro
70b2fe3534
Provide byInterface fields for fetch, exercise. (#11607)
Part of #10915

changelog_begin
changelog_end
2021-11-09 16:37:07 +00:00
Remy
830779ff78
LF: drop useless class com.daml.lf.transaction (#11601)
It became obsolete after #10524.

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-09 16:14:26 +00:00
Remy
a7559d047e
LF: Rename GenTransaction to Transaction (#11599)
* LF: Rename GenTransaction to Transaction

Following up #10827 and #10921 that drop type parameters from GenNode,
we rename GenTransaction to Transaction.

CHANGELOG_BEGIN
CHANGELOG_END

* fix

* a bit more fixes
2021-11-09 13:30:34 +00:00
Remy
3b61a1b748
LF: allow exercise command by template for inherited choice. (#11584)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-09 13:10:06 +00:00
Andreas Lochbihler
d4336510af
fix a few typos in Daml-LF spec (#11583)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-09 08:36:28 +01:00
Sofia Faro
cbc3c8c686
Add by_interface field in Create, Fetch, & Exercise transaction nodes. (#11576)
* Add by_interface field in tx nodes.

This PR adds an optional `by_interface` field in the Create, Fetch,
and Exercise nodes, as part of #10915. It also updates TransactionCoder
to support these fields.

Setting these fields (in the LF interpreter) is left to a separate PR.

changelog_begin
changelog_end

* update security-evidence.md

* Add version checks in TransactionCoder
2021-11-08 16:33:02 +00:00
Moisés Ackerman
7d68e05f7f
Remove virtual choices (#11482)
* Remove virtual choices

* Remove choices without a body in 'interface' definition
* Remove choices in 'template ... implements' section

part of #11372

changelog_begin
changelog_end

* Remove virtual choices cont.

Switch uses of virtual choices to fixed choice with method implementation

* update snapshot after pin on windows

* Disable failing interface tests with TODO #10810
2021-11-08 17:05:23 +01:00
Sofia Faro
4d4869f06e
interfaces: Improve fixed choice lookup (#11551)
* interfaces: Improve fixed choice lookup

This PR adds a lazy map to match fixed choice names to their
interface, to improve the worst case for choice lookup.

Part of #10810

changelog_begin
changelog_end

* scalafmt

* apply improvements from remy
2021-11-04 18:44:48 +00:00
Remy
692dac665d
LF: deprecate remaining type alias in Transaction (#11554)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-04 18:02:16 +00:00
Remy
73cb42e102
LF: deprecate ensureNoCid and assertNoCid in CidContainer (#11502)
After #10827 that drops type parameters in Value, `CidContainer`'s
`ensureNoCid` and `assertNoCid` loose their interest.
To check a value does not contain Contract Ids one should use
`foreachCid` or `cids` methods instead.

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-04 14:49:19 +01:00
Stefano Baghino
b84a9142d1
Extractor: replace sandbox-classic-based fixtures with sandbox-based ones (#11489)
* Replace `sandbox-classic`-based fixtures with `sandbox`-based ones

changelog_begin
changelog_end

* Replace Scenarios with Script for BasicPrimitiveTypes

* Adapt ListsSpec

* Adapt TextMapsSpec

* Adapt OptionalSpec

* Adapt more tests

* More tests passing

- removed workflow_id testing (Daml Script doesn't set one)
- reduced failure threshold for VeryLargeArchiveSpec
- solved issu in TransactionSingleTableSpec (wrong parties were used)

* Port EnumMod and make EnumSpec pass

* Port GenMapMod and make GenMapSpec pass

* Shaking things around to make Windows happy -- maybe
2021-11-04 13:08:51 +00:00
Sofia Faro
776790e386
Add choice collisions in scala name collision checker (#11528)
* Add choice collisions in scala name collision chk

This brings it in line with the LF spec.
This PR also adds collisions for inherited (interface) choices.
Closes #11137.

changelog_begin
changelog_end

* scalafmt

* Apply suggestions from code review

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-11-03 17:01:34 +00:00
Robin Krom
da76e2825b
iface: check for interface implementations precond (#11494)
* iface: check for interface implementations precond

We change speedy to also check all preconditions defined in interface
implementations upon a create.

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala

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

* format

* interfaces: lfconversion for iface preconditions

This adds interface preconditions to the interface implementations
during completion phase in the LF conversion.

CHANGELOG_BEGIN
CHANGELOG_END

* format

* rebase

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-11-02 17:27:49 +00:00
Remy
a8ae4d6f9c
LF: Rename GenNode to Node (#11469)
Following up #10827 and #10921 that drop type parameters from GenNode,
we rename GenNode into Node.

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-02 16:42:16 +00:00
Sofia Faro
48afb7b5ea
interface: Add inherited choice names in scala AST (#11503)
Also checks that they're right. There's no collision checking yet.

Part of #11137.

changelog_begin
changelog_end
2021-11-02 14:35:37 +00:00
Remy
f81d880bcc
LF: drop com.daml.lf.transaction.Transaction.Transaction type alias. (#11470)
After dropping type parameter from GenTransaction we do not
com.daml.lf.transaction.Transaction.Transaction type alias.  We use
instead directly com.daml.lf.transaction.VersionedTransaction, wich is
anyway more informative.

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-02 10:23:17 +01:00
Remy
98e7461fc5
LF: ContractInstance should be a CidContainer (#11487)
In #11419 we drop the implicit call that convert ContractInstance in
CidContainer. Thie is used by Canton and should be restore.

Note that now ContractInstance is not polymorphic anymore, hence we
can inherite CidContainer instead of defining an implicit.

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-01 18:58:47 +00:00
nickchapman-da
b5540a9c3b
Evidence for contract-key testing (#11479)
* Split contract-key tests from engine tests, and mark for evidence.

CHANGELOG_BEGIN
CHANGELOG_END

* remove contract key tests from their original location

* evidence for unique/non-unique contract keys
2021-11-01 16:38:26 +00:00
Sofia Faro
741a6e75a7
interfaces: Add list of fixed choices in TemplateImplements structure. (#11364)
* interfaces: Add fixed choices in TemplateImplements

To make template choice collision checks local.

changelog_begin
changelog_end

* LF completer

* lint

* scary non-shadowing

* improve comment

* change field name
2021-11-01 11:51:51 +00:00
Robin Krom
b98a3ade29
interfaces: precondition, scala ast, decoder/encoder (#11452)
* interfaces: precondition, scala ast, decoder/encoder

This adds the interface precondition to the scala Daml LF AST, plus
decoder/encoder and the typechecker.

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-lf/archive/src/main/scala/com/digitalasset/daml/lf/archive/DecodeV1.scala

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

* format

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-10-29 10:10:55 +00:00
Remy
3098b70624
pretty print contract IDs properly (#11359)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-29 09:02:33 +02:00
nicu-da
570160b718
Add LoggingValue instance for Time.Timestamp (#11444)
CHANGELOG_BEGIN
[daml LF] - Add LoggingValue instance for Time.Timestamp
CHANGELOG_END
2021-10-28 07:01:04 -07:00
Robin Krom
d3b9c84908
ifaces: preconditions, proto changes (#11448)
This adds a precondition expression to the protobuf and the
encoders/decoders on the haskell side.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-28 13:15:22 +00:00
Moritz Kiefer
fcc7e581cf
Make stable packages dependent on supported LF versions (#11382)
* Make stable packages dependent on supported LF versions

Note that this just introduces an API dependency, we are not yet
filtering the list of packages. For that, I’d really like to
autogenerate StablePackages.scala since I don’t want to make that
manually maintained list even more complex. But review seems easier if
we first change the usage sites and then switch to autogenerating than
trying to do both in one go.

changelog_begin
changelog_end

* Fix script export tests

changelog_begin
changelog_end
2021-10-28 11:20:42 +00:00
nickchapman-da
68f44325a6
Improve evidence of testing (#11428)
* fine grained test evidence for authorization

* fine grained test evidence for privacy

* fine grained test evidence for input-validation (typing)

* fix exit code of security/update.sh script (set -euo pipefail)

* add security evidence test category: Input Validation

* regenerate security-evidence.md

CHANGELOG_BEGIN
CHANGELOG_END

* fix bug in securoty evidence generation (must sort before group, or else we loose lines)

* evidence for input validation of commands

* address comments

* cleanup: remove backticks from evidence free text
2021-10-28 09:24:52 +00:00
Moritz Kiefer
ba106873b9
Replace 1.14 min version conformance test by custom test (#11433)
We waste 2 minutes on most CI runs with the conformance test for no
good reason. Uploading the package & sending a command should be
sufficient as an integration test.

changelog_begin
changelog_end
2021-10-27 16:55:52 +00:00
Remy
d678a4046d
LF: remove type parameter from ContractInstance (#11419)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-27 09:59:13 +02:00
Remy
c8006b866a
ScenarioRunner: enrich incomplete transactions (#11384)
* ScenarioRunner: enrich incomplete transactions

fixes #11352

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-26 19:28:05 +02:00
Robert Autenrieth
3587eb84a2
Use Timestamp instead of Instant (#11356)
changelog_begin
changelog_end
2021-10-26 16:30:10 +02:00
pbatko-da
c928f0e560
[Short] Typo (#11400)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-26 12:28:43 +02:00
nickchapman-da
a2a15716b4
Generate security evidence by documenting security testcases (#11306)
* Generate security evidence by documenting security testcases.

CHANGELOG_BEGIN
CHANGELOG_END

* move generated file to root of repo, so links work

* formatError function instead of Show instance

* dont use Show instances for generating Markdown

* magic comment: SECURITY_TEST --> TEST_EVIDENCE

* use megaparsec and Data.Text

* remove redundant T.pack

* use: Text.Megaparsec.Char.space
2021-10-26 09:07:59 +00:00
Moisés Ackerman
613aac3e47
Add support for non-star-kinded type synonyms in data-dependencies (#11293)
* Add DA.Internal.NatSyn as a stable package

This module exposes a type NatSyn, to be used for encoding
type synonyms of Nat-kinded types

* Add generalized roundtrip test helpers in LFConversion tests

roundtripTestsBy and roundtripTestsPartialBy are like their
non-By versions, except they take an explicit equality predicate
instead of relying on the Eq instance. This allows the source
and target types to differ.

* Define encoder/decoder for type synonyms

This works by saturating the RHS of the declaration with artificial
variable names and adding the corresponding parameters on the LHS
In the case of Nat type synonyms, the Proxy-like
DA.Internal.NatSyn.NatSyn type is used to wrap the value into
something of kind star.

* Use type synonym encoder/decoder when generating/consuming DALF

This closes #11226

changelog_begin
changelog_end

* Extend type synonyms over data-dependencies test

* Add test cases for multi-param type class synonyms
2021-10-25 17:10:05 +02:00
Robin Krom
f89ecc6b95
interfaces: add an experimental toTypeRep builtin. (#11378)
This adds an experimental `toTypeRep: forall t. t -> TypeRep` builtin.
It will only work on interface payloads and crash horribly otherwise.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-25 14:09:23 +00:00
Remy
9e94ae0f46
LF: move repl exception-auth test from dev to stable (#11369)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-25 11:13:43 +00:00
Remy
5365d68a38
LF: Remove PartialTransaction out from ScenarioRunner/IdeLedgerClient (#11368)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-25 13:07:23 +02:00
Remy
8d5cab5f16
LF: Simplify seeds generation in scenario runnner (#11353)
We just need the new seeds to be:
- fresh during a run,
- deterministic across two runs.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-25 08:54:42 +02:00
Moritz Kiefer
07ad3e0d9a
Suport multi-party readAs in triggers (#11299)
* Suport multi-party readAs in triggers

fixes #7640

This does not yet include the trigger service. We’ll tackle that separately.

changelog_begin

- [Daml Triggers] Triggers now support readAs parties. They can be
  specified via `--ledger-readas a,b,c`. As part of this change
  ``testRule`` gained an extra argument to specify the `readAs`
  parties. If you previously used

  ```
  testRule trigger party acsBuilder commandsInFlight s
  ```

  you now need to use

  ```
  testRule trigger party [] acsBuilder commandsInFlight s
  ```

changelog_end

* Update triggers/tests/src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/AbstractFuncTests.scala

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

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2021-10-20 18:17:15 +00:00
Remy
c06faf2764
LF: remove imperative environment from Speedy compiler (#11285)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-20 09:03:25 +02:00
Moritz Kiefer
8ff347d8ed
Expand type synonyms lazily (#11282)
* Expand type synonyms lazily

We really only need to expand type synonyms in two cases:
1. When pattern matching e.g. to check that a projection on a struct
   really happens on a struct. In this case we can first check if we
   have a struct in which case we don’t need to expand anything. If we
   don’t, we can expand afterwards.
2. When checking two types for alphaequivalence. This PR goes for the
   simplest solution: First check alphaequivalence without expanding
   anything treating type synonyms nominally. Then if that fails
   expand everything and check again. We could be more clever and
   interleave expansion with checking for alphaequivalence but this
   seems to give us most of the performance benefits while keeping the
   logic very simple.

On my local laptop this speeds up typechecking of the full DAR from
380ms to 176ms so roughly a 2x improvement.

For comparison: The Daml-LF 1.7 DAR which still relies on nonminal
typechecking of typeclasses everywhere takes 110ms. So we are still
leaving something on the table here but we’re much closer.

I think this also gets us to the point where speedy compilation is
slower than typechecking but I need to verify that again.

changelog_begin
changelog_end

* Apply suggestions from code review

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

* fix biuld

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-10-19 20:48:32 +00:00
Moritz Kiefer
243c120939
Add an LF typechecking benchmark (#11276)
changelog_begin
changelog_end
2021-10-18 12:53:17 +00:00
nickchapman-da
2db8c138a8
Test authorization within Exercise choice. (#11246)
* Test authorization within Exercise choice.

CHANGELOG_BEGIN
CHANGELOG_END

* fix build following rebase

* 4x shouldBe a Right

* test for exercise within exercise

* implicit Name.assertFromString

* def --> val. massive speedup!

* be more private

* implicit Identifier creation

* use implicit for Party and ChoiceName creation

* comment test purpose

* delete stray text; fix build
2021-10-18 12:33:23 +01:00
Moritz Kiefer
ec58ed68b3
Typecheck nested LF type applications more efficiently (#11253)
* Typecheck nested LF type applications more efficiently

This improves performance typechecking in the Scala LF typechecker by
matching on nested foralls & type applications which allows us to
check them with only a single substitution as opposed to the previous
state of doing one for each type application.

This is about a 25% improvement on typechecking performance of
GHC.Classes from 200ms to 150ms.

changelog_begin
changelog_end
2021-10-18 11:14:59 +00:00
Remy
a1d94e10ba
LF: Create special case class for VersionedContractInstance (#11127)
To replace usage of ContractInstance[VersionedValue]

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-14 08:53:26 +02:00
Remy
3c26852226
LF: Use template Id in exercise node of fixed choice. (#11229)
* LF: Put template Id in exercise node of fixed choice.

instead of interface id and fix ValueEnricher.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-13 15:24:00 +02:00
Sofia Faro
ce64cb2a13
interfaces: Do some TODOs (#11231)
* interfaces: Do some TODOs

- Add uniqueness check between fixed choices and virtual choices in
  haskell decoder.
- Encode interface methods and fixed choices in scala encoder.
- ExprIterable for interfaces.

changelog_begin
changelog_end

* scalafmt
2021-10-13 13:36:53 +01:00
Remy
d1611e8bc1
LF: Drop templateID from SEScopeExercise and KCloseExercise. (#11228)
We do not need to keep track of it because we have it in the partial
transaction.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-13 11:40:30 +02:00
Remy
b2988bc79a
LF: type and compile Interface fixed choices (#11175)
* LF: type and compile Interface fixed choices

CHANGELOG_BEGIN
CHANGELOG_END

* cleanup

* fix some token

* cleanup

* Address sophia's review

* add comment

* cosmetic

* fix
2021-10-12 15:48:36 +01:00
tudor-da
578fe7f10b
[Self-service error codes] Refactored for Canton compatibility [DPP-614] (#11164)
* [Self-service error codes] Refactored for Canton integration
* Introduces ErrorCodeLoggingContext which is used to abstract away the logging tech stack

CHANGELOG_BEGIN
CHANGELOG_END

* Moved all error definitions in //ledger/error

* Formatting

* Docs and remove of implicit conversion to DamlErrorCodeLoggingContext

* Fix compilation issues

* Fix tests

* Addressed Pawel's review comments

* Addressed Robert's review comments
2021-10-12 11:29:28 +00:00
nickchapman-da
9c107a7aa8
Fix fishy discards (#11197)
* dont discard errors

CHANGELOG_BEGIN
CHANGELOG_END

* remove redundant match case
2021-10-12 11:18:34 +00:00
Robin Krom
3115d104aa
daml script interfaces (#11124)
* interfaces: introduce TemplateOrInterface class in stdlib

The template typeclass is to strong for many applications. The new
constraint `TemplateOrInterface` only contains the methods to convert
contract IDs and choices.

CHANGELOG_BEGIN
CHANGELOG_END

* ghc-lib update, interface script tests

* pinned stackage on unix

* added missing implementation in preprocessor

* added test

* fixing tests

* remove Iface type

* pinned stackage windows

* make sure createAndExercise is not called on interfaces
2021-10-11 18:22:40 +02:00
Remy
4af98a63a2
LF: clarify compilation of choice body. (#11195)
* LF: clarify compilation of choice Body.

This is a purely cosmetic choice.

We move up the intro of the choice arg binder to make it clear it
affect the compilation of every expression in the body of a choices (
namely controllers, observers, and update expression).

CHANGELOG_BEGIN
CHANGELOG_END

* formatting
2021-10-11 16:16:05 +00:00
nickchapman-da
67d4011fcd
Fix NonUnitStatements in daml-lf code (#11145)
* build daml-lf/* with lf_scalacopts_stricter; and fix NonUnitStatements

fix daml-lf/archive

CHANGELOG_BEGIN
CHANGELOG_END

fix daml-lf/data/

fix daml-lf/engine

fixes for scala 2.12

data-scalacheck, interface, kv-transaction-support: switch on; nothing to do

* daml-lf/parser -- switch on; nothing to do

* daml-lf/validation : switch on lf_scalacopts_stricter & fix wartremover:NonUnitStatements

* lf_scalacopts_stricter in daml-lf/transaction-test-lib

* lf_scalacopts_stricter in daml-lf/scenario-interpreter
2021-10-11 14:54:33 +01:00
nicu-da
9b2a8c7eb5
Enable top level statement blank lines scalafmt rule, which adds a blank line after imports (#11180)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-10 23:16:48 -07:00
Remy
4336184a79
LF: Add interface fixed choices in scala AST and type checker (#11146)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-08 08:59:26 +02:00
Remy
dd233ef155
LF: clean daml-lf/language module (#11152)
- enable NonUnitStatements, and find a useless statement.

- add missing `final`s,

- replace `{ ... }` by `( ... )` for one statement anonymous function

- drop useless `new` for case class.

- replace `sealed class X { ... object Y extend X` by
  `class X private[Z] { ... val Y = new X` to avoid unecessary class
  alocation.

- move invariant check inside the body of some case class instead of
  the companion object.

- other cosmetic changes.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-07 13:56:36 +02:00
Sofia Faro
7f6c8608bd
Interface fixed choices: protobuf (#11139)
Adds protobuf for fixed choices. ASTs left for later.

changelog_begin
changelog_end
2021-10-06 16:01:41 +01:00
nickchapman-da
1522c84bae
Unit tests for FailedAuthorization (#11082)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-06 12:25:42 +01:00
Remy
11bc22d085
LF: builtins to create, signatory, and obersver on interface payload. (#11120)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-05 11:59:07 +00:00
Remy
9cffa1faf6
LF: check LF transaction protobuf aginst local snapshots (#11064)
instead of last stable branch.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-04 20:10:41 +02:00
nickchapman-da
fac05f657b
bypass value enrichment for the performance test (#11112)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-04 16:22:48 +01:00
Sofia Faro
db75f7da0f
interface methods: Scala Typechecker (#11097)
* interface methods: Scala Typechecker

Part of #11006.
I tried to match the behavior of the Haskell typechecker.

changelog_begin
changelog_end

* scalafmt

* Fix type
2021-09-30 16:41:49 +00:00
Moritz Kiefer
26d10b267d
Drop NodeId type parameter (#10921)
changelog_begin
changelog_end
2021-09-30 09:13:54 +00:00
Sofia Faro
bcd468625c
interface methods: Speedy (#11076)
* interface methods: Scala AST

Part of #11006
This PR takes care of the Scala AST and decoder.
It leaves the encoder, type checker, and speedy for later.

changelog_begin
changelog_end

* scalafmt

* AstRewriter

* interface methods: Speedy

Part of #11006

changelog_begin
changelog_end

* scalafmt

* Remove InterfaceMethods test

* Update daml-lf/archive/src/main/scala/com/digitalasset/daml/lf/archive/DecodeV1.scala

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-09-30 08:38:08 +00:00
Stefano Baghino
d7b280b60c
Remove debug print in daml-lf/interpreter build (#11091)
Seems to be a leftover from #11067

changelog_begin
changelog_end
2021-09-30 07:43:38 +00:00
Remy
1ed6428980
LF: move archive snapshots in a separate directory (#11081)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-30 08:43:55 +02:00
Sofia Faro
c1d1521a14
interface methods: Scala AST (#11070)
* interface methods: Scala AST

Part of #11006
This PR takes care of the Scala AST and decoder.
It leaves the encoder, type checker, and speedy for later.

changelog_begin
changelog_end

* scalafmt

* AstRewriter
2021-09-29 14:11:23 +00:00
nickchapman-da
51125991e5
Explicit discard in daml-lf/interpreter (#11067)
* Explicit discard to avoid NonUnitStatement.

CHANGELOG_BEGIN
CHANGELOG_END

* define lf_scalacopts_stricter in scala.bzl
2021-09-29 11:24:42 +00:00
nickchapman-da
5458aa890c
Switch on NonUnitStatements warning in daml-lf/transaction (#11048)
* Add NonUnitStatements warning in daml-lf/transaction & fix using discard or similar.

CHANGELOG_BEGIN
CHANGELOG_END

* address comment

* prefer parens to braces for single statement map/foreach bodies
2021-09-28 15:34:31 +00:00
Oliver Seeliger
626e1fbd7d
Small lf value.cids regression fix (found by canton unit tests) (#11032)
value.Value.cids was not invoking foreach1 fully

changelog_begin
changelog_end
2021-09-27 15:23:13 +00:00
Remy
eac7963b87
LF: Refactor ProtoTest.scala (#11020)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-24 18:03:12 +02:00
Remy
19b2bf477f
LF: Cosmetic clean-up in the Speedy Compiler (#11015)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-23 21:02:50 +00:00
Remy
cb0e41f101
LF: Add interface support to the Preprocessor (#11013)
This is part of #10810

We handle only the case of Exercise as Fetch is currenlty used only by
Canton

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-23 17:58:44 +00:00
nickchapman-da
c33297c5fe
Remove transactionNormalization flag. (#11010)
Transactions produced by the engine are now normalized unconditionally.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-23 17:10:10 +00:00
Sofia Faro
bf8b75dab5
interface methods: Add protobuf definitions. (#11005)
* interface methods: Add protobuf

Adds protobuf definitions for interface methods and calling them.
Encoders/decoders just ignore the extra stuff or error out.

Part of #10810 (maybe)

changelog_begin
changelog_end

* Update issue numbers where appropriate

* update stable protos
2021-09-23 14:55:19 +01:00
nickchapman-da
88e1430a42
Make LargeTransactionTest use ValueEnricher, so it can work with normalized transactions coming out of the engine. (#11003)
(Also: generalize type of `enrichTransaction` to work for _submitted_ and _committed_ transactions & adapt existing callers)

This change paves the way to remove the `transactionNormalization` flag, and always normalize transactions coming out of the engine.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-23 11:51:14 +00:00
Remy
58c82b6e41
LF: reduce usage of NodeCreate.coinst (#10988)
Access directly templateId, argument, and agreementText.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-22 18:52:23 +00:00
nickchapman-da
fe10ffbe8f
Use ValueEnricher in ScenarioRunner. (#10897)
1st attempt. Causes package recompilation (bad!).

CHANGELOG_BEGIN
CHANGELOG_END

fix build

Change ValueEnricher interface to work without passing an Engine

ValueEnricher has optional preprocessor

simplify new interface to ValueEnricher: caller passes translateValue function
2021-09-22 16:57:52 +01:00
Sofia Faro
34390f7062
interfaces: Implemented conversions, added test. (#10982)
Part of #10810

- Implemented ToInterface, FromInterface in speedy
- Added a test that exercises and fetches an interface
- Fixed a bug in SBUChoiceInterface

Hey, interfaces work now!

changelog_begin
changelog_end
2021-09-22 15:50:54 +01:00
Remy
eb4f1b2a05
LF: Move lookup tests out of EngineTest (#10973)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-22 13:36:46 +02:00
Moritz Kiefer
99836d2610
Handle fetchByKey callback correctly in scenario runner (#10980)
fixes #10977

Turns out assertions are good unless they’re wrong …

This only affects scenarios, the engine never looks at the callback.

changelog_begin
changelog_end
2021-09-22 13:19:57 +02:00
Sofia Faro
d50df11f77
interface: Add to/from interface in scala ast (#10960)
Part of #10810

changelog_begin
changelog_end
2021-09-21 16:30:01 +00:00
Remy
8b3b033fad
LF: Test preprocessor resuming (#10936)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-21 08:53:37 +02:00
Robin Krom
2edfc062a0
ifaces: name collision, typecheck fetch/exercise (#10896)
* ifaces: name collision, typecheck fetch/exercise

This adds name collision detection and adds typechecking for
fetch/exercising of interface instances.

CHANGELOG_BEGIN
CHANGELOG_END

* turn on exercises in InterfaceDesugared test case

* Update compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/NameCollision.hs

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-09-20 21:40:26 +00:00
Remy
5dc15c6911
LF: rename language Interface to PackageInterface (#10938)
To avoid confusion with the new Daml concept of Interface.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-20 19:04:14 +00:00
Remy
ac02dbdeb9
LF: Exhaustive test for valueTranslator. (#10927)
* LF: Exhaustive test for value translator.

CHANGELOG_BEGIN
CHANGELOG_END

* cosmetic
2021-09-20 14:21:45 +00:00
Sofia Faro
409c0b4f60
interfaces: Add to/from_interface in proto (#10937)
* interfaces: Add to/from_interface in proto

Part of #10810

changelog_begin
changelog_end

* fix typo
2021-09-20 13:44:00 +00:00
Remy
906368d7e2
LF: exhaustive test for CommandPreprocessor (#10914)
While implementing the tests I found a bug.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-17 11:41:29 +00:00
Sofia Faro
61d214e451
Add fetch, exercise implementations for interfaces in speedy. (#10911)
* Draft: Daml Interfaces Speedy PoC

Part of #10810
Extracted from #10670

changelog_begin
changelog_end

* Improve cacheing situation, add implements checks

* scalafmt

* Add comment for ImplementsDefRef

* compile the new update expressions
2021-09-17 10:44:40 +00:00
Robin Krom
50291ed61b
interfaces: scala typechecker implementation (#10867)
* interfaces: scala typechecker implementation

This is the scala side of the lf typechecker for interfaces.

CHANGELOG_BEGIN
CHANGELOG_END

* added collision check

* added exercise/fetch typechecking

* review suggestions

* added todos for collision/typing scala tests
2021-09-16 20:37:33 +00:00
tudor-da
b6a6bf7aac
[Ledger API error codes] Extracted common errors and groups [DPP-607] (#10890)
* Extracted common error implementations
* ErrorGroups
* TransactionError hierarchy
* LedgerApiErrors
* PackageServiceError
* ProtoDeserializationError
* PruningServiceError
* SubmissionErrors

CHANGELOG_BEGIN
CHANGELOG_END

* Adapt extracted error groups and definitions to adhere to local tech stack:
* Use //ledger/error:error core API
* Use DAML SDK logging stack
* Manual rebase to latest changes from Canton

* Extracted RejectionGenerator from Canton

* Adapted RejectionGenerator
* Added //ledger/error:error to artifacts

* Pass correlationId to errors
* Pass parameters as implicits to shave some lines and improve readability

* Workaround for encountered Scala/JDK8 bug

* Addressed Ratko's review comments
2021-09-16 17:19:03 +02:00
Remy
9582e019ec
LF: Refactor PreprocessorSpec test (#10909)
Just moving stuff arround

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-16 13:58:47 +00:00
Moritz Kiefer
9b0fa29aec
Separate exercise & fetch for interfaces from templates (#10908)
* Separate exercise & fetch for interfaces from templates

part of #10810

changelog_begin
changelog_end

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

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

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

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-09-16 12:05:11 +00:00
Moritz Kiefer
8e22bb6b2d
Drop ContractId typeparameter from Value (#10827)
99% of our usecases use Value[ContractId] so this PR just fixes it.

The few other usescases are:

1. Value[Nothing] which we use for keys. This is technically more
precise but we benefit very little from it.
2. Value[String] mostly because in a few places we are lazy.

We don’t have any code which benefits from being polymorphic in the
contract id type.

changelog_begin
changelog_end
2021-09-16 08:46:57 +00:00
Robin Krom
f7c07eaa0c
interfaces: scala protobuf encoder (#10878)
This implements the protobuf encoder of the scala side for interfaces.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-14 12:27:53 +00:00
nickchapman-da
7c29eee130
Cleanup normalize from svalue (#10873)
* better variable name

CHANGELOG_BEGIN
CHANGELOG_END

* remove disallowGenMapAtVersion check
2021-09-14 09:23:48 +00:00
nickchapman-da
053f22a1af
Convert SValue to Value, and normalize, in a single code pass. (#10828)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-14 08:07:26 +01:00
Remy
a471225fa3
LF: Add missing collision check for type synonyms (#10841)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-13 17:52:26 +02:00
Remy
1e1c452b36
LF: drop ad-hoc FrontStack builders (#10839)
Following #10763, we drop the ad-hoc builders for `FrontStack`.

* Building a `Fronstack` from individuals elements should be done with
  standard scala buidler.

* Building a `Fronstack` from a `TraversableOne` should be done with
  the scala 2.13 `.to(FrontStack)` methd

* Building a `Fronstack` from a `ImmArray` should be done with the
  `toImmArray` method.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-13 17:49:09 +02:00
Robin Krom
8f5b4fa84c
interfaces: protobuf encoder haskell side (#10850)
* interfaces: protobuf encoder haskell side

This is the implementation of the protobuf encoder on the haskell side.

CHANGELOG_BEGIN
CHANGELOG_END

* missing decoder cases for added interface data constructor
2021-09-13 14:36:14 +00:00
Remy
24fff88992
LF: Simplify TransactionBuilder (#10753)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-13 15:37:46 +02:00
Remy
6ed21247a3
LF: clean up useless version tests. (#10833)
Since SDK 1.0.0 the min LF version is 1.6.
We drop some checks that are now redundant.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-10 11:43:49 +00:00
Remy
e42cd3a1c6
LF: add interface to scala AST and decoder (#10830)
this is part of #10810

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-10 08:46:19 +02:00
Moritz Kiefer
1e6540f8f2
Stop using controller _ can syntax in daml-lf tests (#10805)
If we want to kill this, as a first step let’s stop using it in tests.

changelog_begin
changelog_end
2021-09-08 11:49:46 +02:00
nickchapman-da
8405ad58fd
Enhance InMemoryLedger to use the ValueEnricher (#10757)
* Enhance InMemoryLedger to use the ValueEnricher.

Allowing SandboxServer to run Engine with the default transactionNormalization=false

CHANGELOG_BEGIN
CHANGELOG_END

* enrich only when responding to verbose API queries
2021-09-08 08:47:47 +01:00
Robin Krom
b8bd5e6399
interface PoC: protobuf definitions (#10796)
* interface PoC: protobuf definitions

The protobuf changes for the Daml interface PoC.

CHANGELOG_BEGIN
CHANGELOG_END

* dummy interface decoder/encoder
2021-09-07 16:58:49 +02:00
nickchapman-da
a5999abf8e
remove dead code (#10765)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-06 13:35:37 +00:00
Remy
c4e0a755d4
LF: drop ad-hoc ImmArray builders (#10763)
Since we switch to scala 2.13, ImmArray companion object extends
`Factory`. Hence:

- the `apply` methods of `ImmArray` override the one from `Factory`

- we can use the notation `.to(ImmArray)` to convert an `Iterable` to
  `ImmArray`

This PR drops those `apply` ImmArray. Conversion from Iterable to
`ImmArray` should use the `.to(ImmArray)`.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-04 16:10:07 +02:00
Moritz Kiefer
50fecfb9ef
Wrap missing label names in quotes (#10749)
* Wrap missing label names in quotes

See
https://discuss.daml.com/t/why-might-i-be-getting-missing-record-label-identity-from-the-ledger-api-when-submitting-a-command/3059/5
this has caused some confusion for users since it’s not obvious that
it is the label name if you have a very generic label name like
`identity`.

I have no strong feelings on whether this should be single or double
quotes so happy to change it.

changelog_begin
changelog_end
2021-09-03 13:52:55 +00:00
Remy
c11323ddb1
LF: Refactor engine test reinterpret (#10724)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-01 09:57:16 +02:00
Moritz Kiefer
c6c304b778
Improve script error on invalid script identifier format (#10702)
fixes #9271

changelog_begin
changelog_end
2021-09-01 08:45:49 +02:00
Remy
27c13334b6
LF: Drop outdated TODOs (#10725)
* LF: Drop outdated TODOs

CHANGELOG_BEGIN
CHANGELOG_END

* Address Moritz' Review
2021-08-31 18:02:29 +00:00
Remy
9f072aeba0
Ledger-API Conformance test for Contract ID V0 (#10717)
CHANGELOG_BEGIN
CHANGELOG_END
2021-08-31 18:17:29 +02:00
Remy
9ef3377864
LF: Update specification with Contract ID Comparability check (#10703)
This is part of #10504.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-31 13:01:25 +02:00
Remy
97bda3ca36
LF: V1 Contract ID check in Preprocessor (#10687)
This PR makes possible to reject V0 contract IDs during preprocessing.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-30 20:14:55 +02:00
Remy
d54adb2543
Ledger-API: Conformance tests for contract IDs suffixing (#10654)
This is part of #10504

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-26 16:14:02 +02:00
Andreas Herrmann
0b7980d6eb
Update rules_haskell (#10674)
* update rules_haskell

changelog_begin
changelog_end

* Build proto3-suite lib and exe in same repo

changelog_begin
changelog_end

* drop unneeded stack_snapshot packages

* Use packages.bzl consistently

* Sort stack_snapshot attribute values

* Remove unused constant

* drop unneeded stack_snapshot packages in compat

changelog_begin
changelog_end

* Sort stack_snapshot attribute values in compat

* Remove redundant dicts.add in compat

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-26 10:41:58 +02:00
Moritz Kiefer
5204d3ce7a
Include committers in PartialTransaction root context (#10665)
This gets us into a state where PartialTransaction always has the
authorization context which is much more sensible than having the
committers in speedy while the rest is in ptx.

The reason for having the split in the first place was the scenario
service but now that we create a new speedy machine per submission
that’s no longer a valid reason.

changelog_begin
changelog_end
2021-08-25 10:45:45 +00:00
nickchapman-da
387c68b9eb
Normalize transaction values within the engine (#10648)
Create normalized TXs when a partial TX is finalised.

Except in limited cases! (i.e for scenario-runner, sandbox)

CHANGELOG_BEGIN
CHANGELOG_END

normalize values in the engine as they are converted from speedy-values

fix 2.12 build

backout redundant change

ensure byKey field is correctly normalized when constructed by engine

rename flag: valueNormalization -> transactionNormalization

improve comment

delete commented-out code

rename: toValueNorm --> toNormalizedValue

rename: (SValue.) toValue --> toUnNormalizedValue

revert changes to ptx so that the interface to insertCreate() etc is Value-based (not SValue-based)

improve comments

respell: toUnNormalizedValue --> toUnnormalizedValue

fix build
2021-08-25 09:53:26 +01:00
Remy
b22de6893b
LF: Contract ID suffix check in Preprocessor (#10642)
This PR makes possible to check for contract IDs suffix during
preprocessing.

This is the first part of the task 3 described in #10504.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-24 18:45:33 +02:00
Remy
5001329c9d
LF: Comparisons fail at runtime if comparing local vs global CIDs (#10630)
This PR enforces that LF Comparisons (both Ordering and Equality)
fails at runtime if comparing local vs global CID.

This corresponds to the second task of #10504.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-23 17:06:44 +02:00
Oliver Seeliger
e807f4a918
Upgrade to a newer canton version (post 0.27.0 snapshot version) (#10632)
* Upgrade to a newer canton version (post 0.27.0 snapshot version)

with canton-community configuration that supports higher throughput.

changelog_begin
changelog_end

* Disable flaky reject DeeplyNestedValueIT:Reject tests that time out half the time
2021-08-20 06:10:54 +00:00
Remy
3598e0928c
LF: Drop contract ID Freshness check (#10620)
As stated in #10504 the contract ID freshness check cannot be
implemented correctly in general.

This PR drops the support for this (buggy) check.

This corresponds to the fist task of #10504.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-19 18:07:29 +02:00
Moritz Kiefer
6d0109fca8
Support $ in daml-lf identifiers in the parser (#10609)
These are valid daml-lf identifiers and we use them e.g. in
f8a1820cc8/daml-lf/validation/src/main/scala/com/digitalasset/daml/lf/validation/Typing.scala (L49).

Arguably `experimental` is also just easier to understand than `$`.

changelog_begin
changelog_end
2021-08-19 09:59:18 +02:00
nickchapman-da
aec601f929
Fix badly versioned empty tx (#10596)
* build correctly versioned empty tx

* dont call normalizeTx from Engine.validate

* dont recalc the tx-version in normalizeTx; just assume it is correct

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-17 13:58:58 +01:00
Sofia Faro
fb09b72f96
Improve divulgence warning message. (#10595)
Based on feedback from @bame-da on issue #9947

changelog_begin
changelog_end
2021-08-17 13:06:03 +01:00
nickchapman-da
9db5ccfc4e
Normalize transactions & values as a separate pass (#10524)
* Normalize transactions & values as a separate pass. Use for simpler defintiion of isReplayedBy.

CHANGELOG_BEGIN
CHANGELOG_END

normalize transaction version

* remove stray import from bad merge which breaks scala 2_12 build

* change isReplayedBy to only norm its RIGHT (replay) argument

* add forgotton normalization for ValueEmum

* switch to use existing value normalization code (remove my newly coded duplicate code)

* normalize submittedTransaction before calling engine.validate

* dont call normalizeTx from Engine.validate

* *do* call normalizeTx from Engine.validate
2021-08-16 14:54:50 +00:00
Samir Talwar
4b8b67a1b5
Upgrade Scalatest to v3.2.9. (#10576)
* Upgrade Scalatest to v3.2.9.

Because of some coupling we also have to upgrade Scalaz to the latest
v7.2 point release, v7.2.33.

The Scalatest changes are quite involved because the JAR has been broken
up into several smaller JARs. Because Bazel expects us to specify all
dependencies and doesn't allow transitive dependencies to be used
directly, this means that we need to specify the explicit Scalatest
components that we use.

As you can imagine, this results in quite a big set of changes. They
are, however, constrained to dependency management; all the code remains
the same.

CHANGELOG_BEGIN
CHANGELOG_END

* http-json-oracle: Fix a Scalatest dependency.

* ledger-api-client: Fix a Scalatest dependency.
2021-08-12 23:19:35 +00:00
Samir Talwar
41e60f7302
Upgrade to Scala 2.12.14 and 2.13.6. (#10573)
* Upgrade to Scala 2.12.14.

* Upgrade Scala to 2.13.6.

CHANGELOG_BEGIN
CHANGELOG_END

* compability: Re-pin the Maven dependencies.
2021-08-12 14:25:53 +00:00
Andreas Lochbihler
5728bbc14f
add cryptographic hash method to ChangeId and base equality on hash (#10554)
CHANGELOG_BEGIN
CHANGELOG_END
2021-08-11 17:34:44 +02:00
Andreas Herrmann
5cc78f5254
Handle missing template instances in Daml ledger export (#10526)
* LF 1.6 ledger export integration test

Test that Daml ledger export script handles DALF packages in LF version
1.6. These packages don't contain metadata, meanint `--package` flags
have to use the hash rather than the package name, and they contain no
type class instances, meaning the export script needs to contain newly
defined instances for type classes required to issue ledger commands in
Daml script.

changelog_begin
changelog_end

* Expose unconstrained Daml script commands

This will be used in Daml ledger exports of contracts defined in Daml LF
versions before 1.8. These versions did not include typeclass instances,
meaning that instances such as HasTemplateTypeRep need to be recreated
in the export Script. Not all instances required in the `Template t`
constraint can be recreated at the use-site. E.g. `HasSignatory`. By
avoiding these kinds of constraints it is possible to handle these cases
in Daml ledger exports anyway.

changelog_begin
changelog_end

* Identify all templates with missing instances

changelog_begin
changelog_end

* Use internal*Cmd on templates missing instances

changelog_begin
- [Daml export] Daml ledger export now handles templates in packages
  using LF versions 1.7 or older. These package versions don't include
  type class instances and Daml ledger export needs to generate
  replacement instances in the generated script. The generated script
  uses less type-safe versions of Daml script ledger commands.
changelog_end

* Add encodeType to encode Ast.Type in ledger export

This will be required to encode HasContractKey instances.

changelog_begin
changelog_end

* Simplify newline handling in encodeExport

* Encode missing template type class instances

* ZIP entries must use forward slash as path separator

* Throw error on encode of Any

Addressing
https://github.com/digital-asset/daml/pull/10526#discussion_r685807454

* Qualify choice using argument type

Addresses review comment
https://github.com/digital-asset/daml/pull/10526#discussion_r685817745

* Use lf.language.Util

Addresses
https://github.com/digital-asset/daml/pull/10526#discussion_r685827150

* Factor out header comment in tests

Addressing review comment
https://github.com/digital-asset/daml/pull/10526#discussion_r685830832

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-10 16:44:11 +00:00
Andreas Herrmann
7c6d3c5bc7
Handle package dependencies without metadata in Daml export (#10481)
* Expose set of stable-packages package-ids

Needed in Daml ledger export to decide whether to depend on a package
without metadata or not.

changelog_begin
changelog_end

* Handle package dependencies without metadata in Daml export

This addresses the immediate issue reported in
https://github.com/digital-asset/daml/issues/10435.

DALF before LF version 1.8 don't contain metadata such as the package
name and version. However, Daml ledger export assumed that metadata was
available to generate `--package` flags for data-dependencies.

This change generates `--package=<hash>` flags for such dependencies on
packages that don't have metadata available.

This change requires additional care when checking if a package is a
stable-package. As the package name is not available without metadata we
cannot just check against names such as `daml-stdlib`. Instead this
change uses the list of stable-package package-ids exposed by
`com.daml.lf.language.StablePackages.Ids`, which was introduced in
0da814d250 (diff-208c6948c7c7f2b582faa8e4792bfe78b231188881947ad0cdd5046e0b9a40e7)

Note that this does not fully resolve #10435. Building a generated Daml
ledger export script will fail on missing instances of standard classes
such as `HasTemplate` because packages prior to LF version 1.8 don't
contain type-class instances. This will be addressed in a separate PR.

changelog_begin
changelog_end

* Fix Scala 2.12

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-04 18:11:17 +02:00
Remy
dc47b105de
LF: Log internal errors (#10471)
part of #9974

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-04 12:31:58 +02:00
Remy
c243f82525
LF: Clean up of Errors (#10052)
part of #9974

 - rename `msg` field to `message`
 - drop `engine.Error.Validation.Generic`
 - rename argument `where` to `location`
 - Builtin set the `dependsOnTime` before throwing the callback `SResultNeedTime`

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-03 18:35:34 +02:00
Remy
5d5343aad5
LF: remove PartialTransaction argument from Speedy err pretty printer (#10470)
CHANGELOG_BEGIN
CHANGELOG_END
2021-08-03 18:09:59 +02:00
Remy
1971274893
Reactive canton conformance test aginst LF 1.13 (#10458)
Now we compile the conformance test for 1.13, we can run conton
against 1.13.

follow up of #10456

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-02 19:43:37 +02:00
Remy
4ae4a9daf7
LF: restrict length of Name and DottedName (#10453)
fixes #10358

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-02 15:49:03 +02:00
Moritz Kiefer
4cf5641678
Build & releases 1.13 Ledger API test tool (#10456)
Temporary hack to unblock Canton until they finish their exception support.

changelog_begin
changelog_end
2021-08-02 13:27:45 +00:00
Remy
3d9c1a09f4
LF: Missing value decoding changes from #10393 (#10443)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-29 13:28:10 +02:00
Samir Talwar
9c08e4cf7e
Move logging value definitions alongside their objects. (#10439)
* logging-entries: Make `LoggingEntries` a non-case class.

There's no reason for it to need `equals`, etc.

CHANGELOG_BEGIN
CHANGELOG_END

* ledger-api-domain: Convert commands into a logging value.

Instead of having a function, let's use `ToLoggingContext`.

This also adds a couple of missing items, and always logs `workflowId`.

* participant-state: Convert updates into a logging value.

Instead of having a function, let's use `ToLoggingContext`.

This changes some of the logging context structure, but otherwise
everything remains the same.

* Make sure Scaladoc is lined up for modified code.
2021-07-29 09:21:27 +00:00
Remy
73290c29d5
LF: Add context in missing package errors (#10418)
explaining the origining of missing package.

This is part of #9974

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-28 12:17:07 +02:00
Remy
41009f79cc
Compiler: Make LF 1.14 the default output (#10394)
CHANGELOG_BEGIN

- [Compiler] Default compiler output LF version is now 1.14

CHANGELOG_END
2021-07-28 12:14:56 +02:00
Remy
cf7b1bb8b5
LF: ValueDecoder set recursion limit for values. (#10393)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-28 12:14:15 +02:00
Sofia Faro
0da814d250
Let stable packages bypass LF version restrictions. (#10377)
* Stable packages bypass version restrictions.

Part of #10029

changelog_begin
changelog_end

* Add missing bypass

* scalafmt

* Fix tests

* fix script runner

* Fix scenario service

* Dont make stable packages configurable

* unused import

* revert unnecessary formatting changes

* Added a StableOnly engine mode and a conformance test that uses it

* buildifier-fix

* Inline LanguageVersions.StableOnly

* scalafmt

* Remove EngineMode in favor of representing the version range directly

* Add -unsafe to flag name

* Apply suggestions from code review
2021-07-27 18:51:00 +00:00
Remy
85af078085
LF: parser for LF versions (#10424)
* LF: Simpler parser for LF version

CHANGELOG_BEGIN
CHANGELOG_END

* add a test
2021-07-27 15:46:47 +00:00
Remy
72cf2f36d3
LF: replace bazel keyword stable by default (#10410)
to refer to the compiler default LF output.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-27 09:27:03 +02:00
nickchapman-da
1bed05fec2
Treat KeyWithMaintainers field structurally in all node types. (#10392)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-23 13:51:03 +00:00
nickchapman-da
387945298d
fix cut&paste typo bug; there are no insig lookup tweaks! (#10389)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-23 11:08:22 +01:00
nickchapman-da
90c3582ee8
treat exerciseResult structurally for isReplayedBy (#10381)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-23 09:46:08 +00:00
Remy
5242e2c618
LF: drop old serializability check for Values (#10382)
We drop this check for the following reasons:

* Its only usage was inside the transaction builder, this is subsumed
  by the check we added in the SValue to Value translation (#10370)

* It seems to origianl check more that nesting (and so to be
  overcomplicate)

* It was used in non-consitent way. It was used to check create
  arguments and choice arguments, but niether choice result nor
  contract key.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-22 20:49:35 +02:00
Remy
ee755306fe
LF: Specify nesting constraint for serialized values. (#10375)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-22 17:50:29 +02:00
Remy
4a33c03f72
LF: Add check of nesting in SValue.toValue (#10370)
The conversion of SValue to Value already ensures the resulting value
has a serializable type. Here we add a check to ensure it does not
overpass the maximum allow nesting.
2021-07-22 17:49:54 +02:00
nickchapman-da
42b70ad31d
Fetch actingParties always non-empty for supported versions (>=1.6) (#10357)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-22 12:04:10 +00:00
Moritz Kiefer
66284c17f2
Limit length of package ids to 64 characters (#10368)
* Limit length of package ids to 64 characters

In practice, you cannot use a package id that is not a valid sha256
outside of a test anyway since we validate them. However, we didn’t
enforce it at the daml-lf level which is a bit annoying.

This PR fixes this and adds a length restriction of 64
characters (i.e. 256 bytes for sha256).

We could go a bit further and also restrict the characters to valid
sha256 hashes (i.e. 64 character hex strings). I don’t feel all that
strongly about that either way. We use other characters in tests but
fixing that shouldn’t be particularly hard either. The extra
characters don’t seem to cause problem so far, so I think it’s fine to
keep that.

No changelog entry since I don’t see how a user can be affected by this.

changelog_begin
changelog_end

* Update daml-lf/encoder/src/main/scala/com/digitalasset/daml/lf/archive/testing/DamlLfEncoder.scala
2021-07-22 10:50:11 +00:00
Remy
faf479e8c8
LF: add context in LookupError (#10314)
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-21 19:03:53 +02:00
Remy
27d439d546
LF: Compile netsed ELets using constant stack (#10337)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-21 14:31:29 +02:00
Samir Talwar
cf2b61e6ac
participant-state: Remove the aliases to Ref.LedgerString. (#10325)
* participant-state: Remove the aliases to `Ref.LedgerString`.

Use the aliases directly in `Ref` instead.

CHANGELOG_BEGIN
CHANGELOG_END

* daml-lf/data: Improve comments on ID aliases.

* daml-lf/data: Fix a typo in a comment.

Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>

Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>
2021-07-21 08:34:46 +00:00
Moritz Kiefer
c9666c7fe0
Drop unnecessary mutability from speedy OnLedger state (#10340)
Those were only mutable for scenarios but now that we have split
scenario interpretation this is no longer required

changelog_begin
changelog_end
2021-07-21 09:53:47 +02:00
Sofia Faro
b701caab7d
Report divulgence warning at commit location. (#10329)
* Pass commitLocation along in engine warning log.

changelog_begin
changelog_end

* Use commitLocation in diagnostics.

* scalafmt

* update divulgence test

* Fix commitLocation and expected diagnostic locations
2021-07-20 15:47:49 +00:00
Samir Talwar
c3bc26fd1c
daml-lf/data: Move ID aliases to Ref from _ledger-api-common_. [KVL-1002] (#10323)
* daml-lf/data: Move ID aliases to `Ref` from _ledger-api-common_.

This allows us to remove a lot of dependencies on _ledger-api-common_,
and use these aliases in other places where that module is not used.

CHANGELOG_BEGIN
CHANGELOG_END

* participant-integration-api: Remove an unused import.

* http-json-oracle: Remove `ledger-api-common` as a dependency.

* bindings-rxjava: Remove a now-unused dependency.
2021-07-20 11:01:19 +00:00
Remy
159728d716
LF: use Either by default in all archive reader API (#10295)
This is a follow up of #10277.
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-19 19:48:37 +02:00
nickchapman-da
0e09f3ba08
Remove optLocation field from transaction nodes. (#10301)
* Remove Optional[Location] field from transaction nodes.

xoptLocation

working but very messy!

cleanup PartialTransaction code

pass locationInfo in CompleteTransaction

dont pass locationInfo in SumittedTransaction

pass optLocation to CheckAuthorization

temp reinstate xoptLocation in ExerciseContextInfo

cleanup Conversions.scala

remove Optional[Location] field from transaction nodes.

CHANGELOG_BEGIN
CHANGELOG_END

* fix bad merge

* fix build after merge

* rename

* doc comment, and question
2021-07-19 13:03:30 +00:00
Remy
f033bc2bbb
LF: Clean legacy from archive proto + TEXT_TO_CODE_POINTS typo (#10286)
Thanks to @tristan-da for pointing this out.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-15 16:01:08 +02:00
Remy
a8f190214c
LF: change type from Try to Either in archive module (#10277)
* LF: change type from Try to Either in archive module

This is the first part of restructuring errors in archive module.
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END

* Apply suggestions from code review

Co-authored-by: Stephen Compall <stephen.compall@daml.com>

* remove type alias

* apply stephen suggestion

* fix after rebase

* fix test

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-07-14 19:24:31 +00:00
Remy
906184ce1a
LF: Simplify UniversalDarReader (#10271)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-14 15:38:22 +02:00
Remy
caf85a2270
LF: rationalize archive Parser/Reader/Decoder (#10239)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-14 11:05:17 +02:00
Sofia Faro
b8e2198873
Separate traces from warnings in engine. (#10253)
* Separate traces from warnings in engine.

I decided to separate the engine warnings from the tracelog after all,
because I think it will make testing and maintenance easier in the
long run.

Part of #9947, follow up from #10179

changelog_begin
changelog_end

* scalafmt

* Apply suggestions from code review

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

* dont use case class for WarningLog

* revert TraceLog changes from last PR

* Scala 2.12 doesnt have ArrayBuffer.addOne :(

* remove isWarnEnabled check

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-07-13 14:24:27 +00:00
Remy
6e8ec1d618
LF: Drop old depreated code (#10251)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-13 13:10:00 +00:00
Remy
e4d7cd764a
LF: Deprecate com.daml.lf.data.TryOps.Bracket (#10249)
* LF: Deprecate com.daml.lf.data.TryOps.Bracket

CHANGELOG_BEGIN
CHANGELOG_END

* address reviews

* fix
2021-07-13 10:16:53 +00:00
Remy
6fe6ae075d
LF: Make DarReader ZipEntries immulatble (#10243)
* LF: Make DarReader ZipEntries immulatble

CHANGELOG_BEGIN
CHANGELOG_END

* optim

* Revert "optim"

This reverts commit 3b25a8c68b.

* a function should not close a stream it didn’t open

* typo

* we do not support dar without manifest !
2021-07-12 21:13:25 +00:00
Remy
f19f5b0821
LF: Simplify DarReader (#10217)
This PR simplifies a bit DarReader and UniversalDarReader

This is a follow up of #10208.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-08 17:03:45 +02:00
Remy
ebb76dca4c
LF: reorganize errors in com.daml.lf.archive (#10213)
* LF: reorganize errors in com.daml.lf.archive

part of #9974

CHANGELOG_BEGIN
CHANGELOG_END

* fix
2021-07-08 13:03:42 +00:00
nickchapman-da
69646451f2
Improvements for validation tests (#10214)
* prefer Seq to List when generating samples

CHANGELOG_BEGIN
CHANGELOG_END

* use TableDrivenPropertyChecks

* remove count/println
2021-07-08 13:48:07 +01:00
Remy
41b8448b17
LF: Simplify archive reader. (#10208)
* LF: Simplify archive reader.

- decouple Reader and Decoder
- introduce case class to handle hash, proto payload, and version

CHANGELOG_BEGIN
CHANGELOG_END

* Address Moritz' review

* cosmetic
2021-07-07 19:56:40 +00:00
Moritz Kiefer
6586dde11e
Move exercise context computation to the client side (#10199)
We probably want to start displaying the full ptx on the client side
but for now this at least moves things out of speedy and into the
rendering layer where they belong.

It also fixes IncompleteTransaction to unwind properly so the roots
are really the roots.

changelog_begin
changelog_end
2021-07-07 15:44:47 +02:00
nickchapman-da
e2bdca6be9
Use PartialFunction for more concise code. (#10191)
* Use PartialFunction for more concise code.

CHANGELOG_BEGIN
CHANGELOG_END

* tweak to use guards

* blind fix for 2.12

* try fix 2.12 build

* loose if-guard parens

* fixes for 2.12 build (should actually work this time!)
2021-07-06 16:43:49 +00:00
Sofia Faro
98b5ffee01
Add divulgence warning and test in script service. (#10179)
* Add divulgence warning and test in script service.

Part of #9947, building on the key visibility checks from #10136

This PR adds a divulgence warning inside the traceLog.
I wasn't sure whether:

1. these warnings should be kept in a separate structure from the
   traceLog, and therefore transmitted separately, or
2. these warnings should be kept together with traces, but the severity
   should be tracked and also transmitted over grpc, and warnings should
   be logged as warnings instead of as debug messages, or
3. these warnings should be kept together with traces, but
   logged as warnings instead of debug messages,
4. these warnings should be treated exactly like traces

I'm leaning toward #2, but this PR implements #3.

This PR tests the warning via the script service tests.

changelog_begin
changelog_end

* scalafmt

* Address Moritz's review

* Rename traceLog.add to traceLog.addDebug

* fix test

* Add test using exercise

* add single transaction test
2021-07-06 13:05:52 +01:00