Commit Graph

1264 Commits

Author SHA1 Message Date
Simon Maxen
51b9405f5c
TransactionNodesStatistics.stats to return case class of same name (#12159)
* TransactionNodesStatistics.stats now returns case class of same name

changelog_begin
changelog_end

* Rename TransactionNodesStats to Detail and make inner class

* Rename TransactionNodesStatistics.stats to apply

* Rename TransactionNodesStatistics to TransactionNodeStatistics

* Reformat

* Remove rollback from statistic action count

* Update with review comments

* Update with review comments
2021-12-17 15:27:53 +00:00
Stefano Baghino
52110e31a3
Remove Extractor (#12188)
* Remove Extractor

Extractor is being removed after a long time being in Labs status.

This should improve the flakiness on CI.

🔥

changelog_begin
Extractor has been removed from the SDK
changelog_end

* Remove Extractor documentation

* Remove Extractor from CODEOWNERS

* Remove Extractor references in Daml-LF build files

* Remove Extractor references in the Daml SDK assistant

* Remove Extractor from the SDK

* Remove Extractor reference from CONTRIBUTING.md
2021-12-17 13:43:23 +00:00
Moritz Kiefer
5f688dd704
Cache localContract calls in contractKeyInputs (#12183)
changelog_begin
changelog_end
2021-12-17 11:37:24 +00:00
Remy
7ecc12645e
LF: make Struct lookup logarithmic (#12170)
CHANGELOG_BEGIN
CHANGELOG_END
2021-12-16 16:48:45 +00:00
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