Commit Graph

1346 Commits

Author SHA1 Message Date
Robin Krom
492e5fdd07
ifaces:tests: extend encoder tests, fix bugs (#13253)
This extends the Scala encoder tests to include interface definitions
and interface implementatioins. Some bugs in the encoder and ast
rewriter are fixed.

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-14 12:55:27 +01:00
nickchapman-da
e1030365f0
Fix the ANF transform for case-alternatives to be stack-stafe. (#13251)
changelog_begin
changelog_end
2022-03-10 17:33:28 +00:00
Remy
3e6642f957
LF: Test that FetchInterface load unknown module (#13244)
The issue was indirectly fixed by #13080.

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-10 16:16:38 +01:00
Robin Krom
69a2339906
ifaces: tests: name collisions between defs (#13216)
We add a check and a fix to make sure interface/exception/template names
don't collide.

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-10 11:26:14 +01:00
nickchapman-da
cdf1be9464
Remove AExpr wrapper type. (#13233)
changelog_begin
changelog_end
2022-03-10 09:19:58 +00:00
Remy
8abf0bae96
Generate SubmissionEntry from KV export (#13209)
We split kv replay as follow:

- [LF] we introduce a simple protobuf to store submission entry (which
  roughly correspond to TRANSACTION_ENTRY and PACKAGE_UPLOAD_ENTRY KV
  submission)

- [KV] we create a tool to extract form a ledger export a sequence of
  submission entry

- [LF] we move the replay tool from KV to LF, and base it on
  submission entries instead of ledger export

The objectify of this split is double:

- on the one side it will simplify maintenance, as it will make API
  between KV and LF more clear (depends only on a protobuf definition)

- on the other side, it will made the use of the tool handy, as it
  will make possible to benchmark the engine without direct dependency
  between KV and LF.

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-10 08:47:04 +01:00
Sergey Kisel
9a27edd656
Improve MessageDigest and Mac instance creation to solve lock contention [DPP-956] (#13221)
* Improve MessageDigest and Mac instance creation to solve lock contention problem [DPP-956]

changelog_begin
Scalability bottleneck in regard to hashing has been fixed in multiple places.
changelog_end
2022-03-09 22:15:32 +01:00
Sofia Faro
7bfd5e40c8
Fix a bug in AstRewriter (#13232)
And change the test that used AstRewriter to also serve as a regression
test. This bug has no impact on production code.

changelog_begin
changelog_end
2022-03-09 18:18:42 +00:00
nickchapman-da
d6bb26a978
Fix stack-safety when processing function-args in ANF transform. (#13198)
changelog_begin
changelog_end
2022-03-09 16:01:43 +00:00
Robin Krom
ca7efdabde
iface: tests: test DefInterface in daml-lf ast (#13220)
This adds tests for the DefInterface in Daml-lf.

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-09 14:38:21 +01:00
Gary Verhaegen
dfa648f585
hunt down DAML better (#13195)
Process:

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

To review:

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

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

Fixes #13190

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

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

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-08 17:04:58 +01:00
Robin Krom
d130bd2516
ifaces: tests: check for iface defs in templates (#13194)
* ifaces: tests: check for iface defs in templates

This adds a test that will fail when an interface definition is present
in a module when daml-lf < 1.dev.

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-lf/archive/src/test/scala/com/digitalasset/daml/lf/archive/DecodeV1Spec.scala

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

* Update daml-lf/archive/src/test/scala/com/digitalasset/daml/lf/archive/DecodeV1Spec.scala

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

* Update daml-lf/archive/src/test/scala/com/digitalasset/daml/lf/archive/DecodeV1Spec.scala

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

* remy's suggestions

Co-authored-by: Remy <remy.haemmerle@daml.com>
2022-03-08 14:44:46 +00:00
Robin Krom
be6bbc82b9
ifaces: tests: check for interface collisions in ast (#13196)
* ifaces: tests: check for interface collisions in ast

We add a test to check for interface name collisions in the daml-lf AST.

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-lf/language/src/test/scala/com/digitalasset/daml/lf/language/AstSpec.scala

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2022-03-08 14:08:48 +00:00
Sofia Faro
85c4ea0b5c
LF spce: Make controller/observer errors fatal (#13192)
changelog_begin
changelog_end
2022-03-08 12:32:10 +00:00
Sofia Faro
190fd2487c
LF: Add interface preconditions to spec (#13173)
* LF: Add interface preconditions to spec.

Part of #11349

changelog_begin
changelog_end

* two should be True

* Incorporate remy suggestion
2022-03-08 10:11:54 +00:00
Robin Krom
878754e9ac
interfaces: tests: no interfaces below 1.dev (#13179)
We add a check for the decoder that tests that implementations in
templates are only accepted in 1.dev.

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-07 21:26:39 +00:00
Remy
d5471076ad
Speedy: Factorize fetch part between fetch by template and by itnerface (#13148)
CHANGELOG_BEGIN
CHANGELOG_END
2022-03-07 20:32:47 +01:00
nickchapman-da
9e71184582
Thorough stack-safety testing for all speedy compiler phases. (#13168)
changelog_begin
changelog_end
2022-03-07 15:53:35 +00:00
Remy
3e3fccacfd
LF: Make exceptions in choice's controller/obervser uncatchable (#13106)
fixes #13099

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-03 18:37:12 +01:00
Sofia Faro
b2d6f8014c
LF: Use template parameter (this) in method bodies. (#13142)
* Use `this` param in method bodies in LF.

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

Fixes #13123

changelog_begin
changelog_end

* fix validation-test
2022-03-03 13:50:59 +00:00
Moisés Ackerman
2dbd91aab9
Interface methods can use plain function declaration syntax (#13102)
* Update 'implements' blocks to use new syntax

* Add InterfaceSyntax test case

* Add InterfaceMultipleMethodDeclsError test case

* Add InterfaceDifferentNumArgsError test case

changelog_begin
changelog_end
2022-03-02 15:59:01 +00:00
Sofia Faro
8075a64f7f
LF Spec: Add interface expressions (#13103)
* LF Spec: Add interface expressions

This PR adds type rules and operational semantics for interface
expressions (including updates). The only thing I haven't added yet is
the operational semantics for exercise interface, and the operational
semantics for interface preconditions.

changelog_begin
changelog_end

* typo

* spurious duplicate

* minor edits

* review suggestions
2022-03-02 11:20:07 +00:00
tudor-da
ea48173350
Switch daml-lf/engine and leger-api-tests/tool not depend on kvutils (#13107)
changelog_begin
changelog_end
2022-03-01 15:41:12 +01:00
Sofia Faro
db100c131a
Prevent iface choice & method name collisions. (#13075)
* Prevent iface choice & method name collisions.

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

changelog_begin
changelog_end

* check the names from interfaces

* add error

* implement name collision check in scala side

* scalafmt
2022-02-28 13:21:41 +00:00
Remy
5616846a7f
LF: Factorize logic to compute contract meta data (#13080)
between Create and Fetch.

meta data includes, signatories, observers, and contract key.

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-28 12:02:33 +01:00
Robin Krom
3692a4a565
interfaces:ensure that implementations are ordered (#13071)
* interfaces:ensure that implementations are ordered

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

CHANGELOG_BEGIN
CHANGELOG_END

* use VectorMap instead of ListMap
2022-02-25 15:14:50 +00:00
Sofia Faro
0e03e2f100
Add interfaces to LF spec (#13020)
* Add interfaces to LF spec.

Part of #11349. This PR adds the interface & implements declarations, deals with "requires", and name collisions. I'm leaving expression types and operational semantics to a future PR.

changelog_begin
changelog_end

* missing curly

* change T to I for interfaces

* revisions from Remy
2022-02-24 17:09:20 +00:00
Moritz Kiefer
0ea4866adc
Fix activeness display in script service (#13059)
The previous way of tracking this only worked for direct children of
rollback nodes but lost the information when there was an exercise
node in between.

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

changelog_begin

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

changelog_end
2022-02-24 16:20:00 +01:00
nickchapman-da
b19567aa7a
Stack safe speedy compilation (#12925)
* Rework speedy compilation phase1 to be stack safe.

changelog_begin
changelog_end
2022-02-23 16:06:21 +00:00
Robin Krom
adaddde058
speedy: short circuit precondition checking (#12984)
* speedy: short circuit precondition checking

Instead of evaluating all preconditions of templates and interfaces we
evaluate preconditions one by one and throw an exception as soon as we
find a failing one.

This implemented via a lazy SBCheckPrecond builtin and a foldleft
expression over the list of preconditions.

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>

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

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

* fix SUnit -> Unit

* tests

Co-authored-by: Remy <remy.haemmerle@daml.com>
2022-02-22 14:24:06 +00:00
Sofia Faro
b842b53ff4
Delete vestigial InterfaceChoice from AST (#13017)
* Delete vestigial InterfaceChoice from AST

This is a leftover from when interfaces had virtual choices.

changelog_begin
changelog_end

* delete more
2022-02-22 13:59:04 +00:00
Moisés Ackerman
6d268fdc16
Wrap interfaces in SAny in speedy (#12954)
* wrap interfaces in SAny in speedy

* expect SAny representation for interfaces in builtins

* Update SBResolveVirtual

* SBResolveSBUInsertFetchNode uses SAnyInterface

* SBResolveSBUBeginExercise uses SAnyInterface

* Wrap 'this' in SAnyInterface for interface preconditions

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

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

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-21 13:34:46 +01:00
Remy
515f4277a9
LF: Make TransactionVersion.Ordering public (#12966)
To be accessible from Canton.

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-16 16:15:50 +00:00
Remy
380dfa3502
LF: Add cause to internal error (#12965)
When an internal error is due to an unexpected exception, we wrap the
exception into the InternalError.

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-16 11:06:10 +00:00
tudor-da
307931d5b4
Extracted kvutils Config to //leger/ledger-runner-common [DPP-865] (#12889)
* Extracted kvutils Config to //leger/ledger-runner-config

changelog_begin
changelog_end

* Sandbox-on-X logback.xml does not depend on the kvutils/app one

* Remove unused dependencies

* Add copyright header back

* Remove dependency of SoX on kvutils
2022-02-14 13:52:06 +00:00
Remy
6983af8133
Speedy: Fix computation of Node version (#12879)
The computation of Node version relies on the
`packageToTransactionVersion` field of the PartialTransaction.  This
is initialized during the Speedy `Machine` construction with the
compiledPackage used to initialized the Machine. However the
compiledPackage is a mutable field and can be udpated during
interpreation, potentially making the 'PartialTransaction''s
`packageToTransactionVersion` out of date.

This is not a production bug, as production code use the Machine's
`CompiledPackage` in a imutable way (with a mutable
ConcurrentCompilePackage), however this is a problem for testing code
that may use the field in a mutable way (with an immutable
`PureCompiledPackage`).

We solve the issue by making the computation of the version, outise
the PartialTransaction object.

CHANGELOG_BEGING
CHANGELOG_END
2022-02-11 10:22:10 +01:00
nickchapman-da
1ca90b6013
Split out phase1 of speedy compilation in preparation for making it stack-safe. (#12877)
changelog_begin
changelog_end
2022-02-11 09:14:40 +00:00
Moritz Kiefer
0fb0bf2f52
Disable implicit party allocation in Daml Studio (#12839)
* Disable implicit party allocation in Daml Studio

fixes #12058

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

changelog_begin
changelog_end

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

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2022-02-09 17:47:40 +00:00
Remy
ab758fac71
LF: kill some old deprecated definitions (#12815)
CHANGELOG_BEGIN
CHANGELOG_END
2022-02-08 15:35:50 +00:00
Moisés Ackerman
7f6e1f08d4
Interface primitives continued (#12795)
* Extend daml lf parser to support new interface primitives

* Test parser on new interface primitives

* Add daml lf decoding test cases for new interface primitives

* Add TypingSpec test cases for new interface primitives

* add SBuiltinTest test cases for interface primitives

changelog_begin
changelog_end
2022-02-08 16:02:20 +01:00
tudor-da
c9dcd1c493
Update kvutils Config with missing flags options from SandboxConfig [DPP-864] (#12629)
* Update kvutils Config and SandboxConfig
* Remove `eager-package-loading` and `scenario` from SandboxConfig
* Add `profile-dir` and `stackTraces` to kvutils Config
* Configurable authService in kvutils

changelog_begin
changelog_end

* Addressed Samir's review comments

* Add back Maximum supported deduplication duration enforcement of 1 hour
2022-02-07 20:13:04 +00:00
Remy
ee7e0c1cd8
Engine: fix compilation exception catch (#12787)
During refactoring of #9993, the "unsafe" compilation of the seedy command
has been moved out of the scope of `Engine.runSafely`, whose only purpose
was to catch exceptions thrown by the Speedy compiler.

This fixes the issue and renames the function `runSafely` to
`runCompilkerSafely` to make its purpose more obvious.

This is not a critical bug, as the command preprocessing should ensure
that (1) the command are properly typed and (2) all the dependencies
have been loaded.

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-07 20:07:53 +00:00
Remy
e6fed38c1a
LF: reduce number of fieds in test-scenario-stable-many-fields (#12793)
from 130 to 125, reason the test is currently flaky (It fails around 20% of the time).

Surprisingly, #12678 seems to have increase the stack usage for the type checker.

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-07 17:47:42 +01:00
Moisés Ackerman
3ce272b9f0
Replace experimental interface primitives with proper LF primitives (#12678)
* Add new primitives to proto spec

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

* define EToTypeRep primitive in terms of EToTypeRep Expr

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

changelog_begin
changelog_end
2022-02-03 13:36:45 +00:00
Victor Peter Rouven Müller
aa45f48798
Upgrade to Scala 2.13.8 (#12506)
* Upgrade to Scala 2.13.8

changelog_begin
changelog_end

* Update hash for scala in nixpkgs

* update more hashes for scala upgrade

* Fix most warnings etc.

* Fix remaining errors etc.

* Fix formatting

* Resolve last errors hopefully

* Fix ledger api common build file

* Combine imports & revert accidental change that broke the CI run

* Rename exporting vals to scriptExport & minimize diff

* Remove more wrong changes

* moved warning around
2022-02-03 09:05:31 +00:00
Remy
ed1bf2469a
LF: Check activeness of cached contracts inside FetchInterface (#12698)
Missed in #12527.

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-01 19:06:40 +00:00
Remy
aa2494f11a
Speedy: check contract type after checking if they are consumed (#12691)
Missed in #12527.

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-01 15:36:40 +00:00
Remy
183f936def
LF: Imporve safety of the Serialization of proto message. (#12686)
This is a follow up of #12638, applied to LF support for KV.

CHANGELOG_BEGIN
CHANGELOG_END
2022-02-01 15:45:17 +01:00