Commit Graph

224 Commits

Author SHA1 Message Date
Remy
45bfb26ade
LF clean up proto snapshot of LF 1.15 (#14799)
CHANGELOG_BEGIN
CHANGELOG_END
2022-08-29 10:40:19 +00:00
dylant-da
a74c020ddd
Add version 1.15 - move interfaces into them (#14770)
* Add version 1.15 - move interfaces into them

* Update Ast/Version & docs for 1.15, split interface into simple/extended

* Stage 1.15 protobuf

* Remove references to dev from 1.15 protobufs

* Add Tests file for 1.15 in ledger API testtool

* Update Version 1.15 changelog with Call/implements

* Make 1.14 default again

* Add 1.15 as preview version

* Add 1.15 test suite to testtool

* Reinclude 1.15 in COMPILER_LF_VERSIONS to build model-tests-1.15

* Move v1_15 ledger-api-tests into own suite

* Fix InterfaceNotSupported message to 1.15 or higher

* satisfy changelog check

CHANGELOG_BEGIN
CHANGELOG_END

* Update tests with extended interface features to only run on 1.dev

* Allow unsafe_from_interface and interface_template_type_rep in 1.15

* Fix StableVersions back to 1.14, make EarlyAccessVersions 1.15

* Run retroactive implements tests only in extended interfaces

* lint

* Temporarily disable 1.15 conformance tests - handle in another PR

* Also disable conformance-test-tls1.2-or-newer-1.15

* Disable PureConfigReaderWriter tests that assume early-access == stable

* lint
2022-08-23 13:39:16 +00:00
Remy
4ac224b518
LF: Move TemplateOrInterface form language package to data package (#14748)
to be able to use it without direct dependence to language package.

CHANGELOG_BEGIN
CHANGELOG_END
2022-08-18 16:20:18 +02:00
Remy
4acdb85d4a
LF: missing braces in string interpolation for ConcreteInterfaceInstance#pretty (#14739)
CHANGELOG_BEGIN
CHANGELOG_END
2022-08-17 15:04:35 +00:00
dylant-da
b8a17e5dac
Remove TODOs relevant to #14112 (#14663)
* Remove outdated TODO on ValueEnricher

* Rename collectNewPackagesFromTemplateIds for interface use, remove TODO

* Remove outdated TODO on interfaceInstanceBody parser

* Check body view has interface viewtype as type

* Amend type iterator to go over Interface view method, remove TODO

* empty changelog commit

CHANGELOG_BEGIN
CHANGELOG_END

* Fail in Preprocessing when viewing nonimplementing interfaces

* Fix interface instance check in Typing

* Fix lint

* Typecheck view expression with tmplParam in scope

* Remove done TODO in checkInterfaceInstance

* Move AmbiguousInterfaceInstance error into LookupError as a case variant

* lint

* Add unapply to LookupError to default to NotFound
2022-08-15 16:12:42 +00:00
Moisés Ackerman
992942b573
Refactor interface instance typechecking and compilation (scala) (#14647)
* Refactor (Co)Implements(Method) DefRefs

InterfaceInstanceDefRef replaces ImplementsDefRef and CoImplementsDefRef
InterfaceInstanceMethodDefRef replaces ImplementsMethodDefRef and CoImplementsMethodDefRef

* Define PackageInterface.lookupInterfaceInstance

* Remove lookupTemplateImplements and related functions

* Replace uses of lookupTemplateImplements and similar with lookupInterfaceInstance

* Rename ETemplateDoesNotImplementInterface=>EMissingInterfaceInstance

* Rename EConflictingImplementsCoImplements=>EAmbiguousInterfaceInstance

* Replace checkIface(Co)Implementations with direct use of checkInterfaceInstance

* Remove LookupError.Reference cases for implements/co-implements

* Rename and refactor EMissingRequiredInterface{=>Instance}

* Rename and refactor EMissingInterfaceMethod=>EMissingMethodInInterfaceInstance

* Rename and refactor EUnknownInterfaceMethod=>EUnknownMethodInInterfaceInstance

* Clean up checkInterfaceInstance

* Include interface signature in InterfaceInstanceInfo

changelog_begin
changelog_end
2022-08-09 16:17:29 +00:00
Moisés Ackerman
c146bee87d
Reduce duplication between implements and co-implements (#14607)
* Reduce duplication between implements and co-implements

This extracts the common part (methods and view) to a new type InterfaceInstanceBody

changelog_begin
changelog_end
2022-08-04 17:01:15 +02:00
Remy
b475d710aa
LF: Create LF 1.15 in scala to park basic interface constructs (#14534)
basic interface constructs contain:
- interface definition
- interface implementation
- retroactive template implemenation
- exerciseInterface and fetchInterface
- basic builin

but do not contain:
- "requires"
- exercise guards

CHANGELOG_BEGIN
CHANGELOG_END
2022-07-29 20:09:57 +02:00
Carl Pulley
c87732c438
Disclosure testing of contracts and keys
* Basic explicit disclosure testing

CHANGELOG_BEGIN

  * Engine/speedy-level tests for explicit disclosure (#14227): test that explicit disclosure works for contracts and keys.

CHANGELOG_END
2022-07-28 16:00:55 +01:00
Remy
88d4ff93f2
LF: remove precondition in interface (proto & scala side) (#14511)
CHANGELOG_BEGIN
CHANGELOG_END
2022-07-27 10:52:35 +02:00
Remy
7c89050c60
LF: Utility function to compute the relation interface/implementation (#14409)
in a package.

CHANGELOG_BEGIN
CHANGELOG_END
2022-07-25 11:20:42 +00:00
Remy
df21aad8af
LF: Make ExerciseInterface guard field optional (#14493)
in protobuf

CHANGELOG_BEGIN
CHANGELOG_END
2022-07-25 11:33:02 +02:00
Remy
c3789e70c3
[LF] minor refactoring of the type chect to reduce stack consumption (#14510)
After this change //daml-lf/tests:test-scenario-stable-many-fields
does not seem to stack overflow anymore.

This is a workaround until we make the type checker stack safe, See #13410.

CHANGELOG_BEGIN
CHANGELOG_END
2022-07-25 08:26:05 +00:00
dylant-da
8d93efdd12
Add EViewInterface to LF - stub compilation/interpretation in speedy (#14486)
* Add ViewInterface to LF - stub interpretation in speedy

* Remove templateId and viewtype from EViewInterface

* Fix lint
2022-07-21 15:10:53 +00:00
Remy
1cbc21e719
[LF] Cleanup Relation data structure (#14471)
CHANGELOG_BEGIN
CHANGELOG_END
2022-07-21 13:03:29 +02:00
dylant-da
ab948dd8de
Update LF AST protobuf for interface viewtype and implementation view (#14439)
* Update protobuf to include viewtype and implementation view

* Stub interface viewtype and implements view in updated AST

* Set views on Java builders in DecodeV1Spec

CHANGELOG_BEGIN
Update LF AST protobuf for interface viewtype and implementation view -
not currently linked to syntax or engine changes, all stubbed out in
LFConversion.
CHANGELOG_END

* Add view field to CoImplements

* Update iterators & parsers to account for CoImplements view

* Replace uses of TBuiltin(BTUnit) with TUnit

* Remove superfluous "Available in versions >= 1.dev" comment

* Fix missing TUnit imports, missing view param in daml-lf/parser

* Remove unused imports from DecodeV1Spec

* Add stub view in AstSpec
2022-07-19 12:00:04 +00:00
Moisés Ackerman
d3824945b0
Retroactive implements scala typecheck (cont) (#14346)
* Extend EncodeV1Spec with interface co-implements

* Add lookupTemplateImplementsOrInterfaceCoImplements to PackageInterface

* Use lookupTemplateImplementsOrInterfaceCoImplements in checkImplements

* Add TypingSpec cases for interface conversion functions via co-implements

* Add TypingSpec cases for interfaces with co-implements

* Apply code review suggestions: result type formatting

changelog_begin
changelog_end
2022-07-07 12:49:09 +00:00
Sergey Kisel
e151090cf3
Introduction of HOCON configuration for SoX [DPP-1033] (#14029)
* Introduction of HOCON configuration

CHANGELOG_BEGIN
CHANGELOG_END
2022-07-05 15:35:16 +02:00
Moisés Ackerman
1f1f2785b0
Retroactive implements scala typecheck (#14266)
* Add lookup functions for co-implements

* Typecheck interface co-implementations

    * Use new environment in checkIfaceCoImplementation

* Fix Interface_1.dev_.lf

* OtherMod=>InterfaceMod0

changelog_begin
changelog_end
2022-07-05 09:53:56 +02:00
Remy
2d8a016a3e
[Engine] add a glorified Either to handle Template or Interface cases (#14306)
CHANGELOG_BEGIN
CHANGELOG_END
2022-06-30 17:55:29 +00:00
Moisés Ackerman
0d1ef10472
Retroactive Implements - Scala side (#14130)
* Add CoImplements to daml-lf AST

* Add AstSpec case for duplicate co-implements in interface

* Add placeholders for CoImplements in daml-lf validation

* Handle CoImplements in daml-lf iterators

* Handle CoImplements in daml-lf scala decoder

* Test DefInterface components in DecodeV1Spec

* Handle CoImplements in daml-lf (testing) parser

* Handle CoImplements in daml-lf (testing) encoder

changelog_begin
changelog_end
2022-06-23 17:13:38 +00:00
Remy
ae8f50dbb8
LF: drop inheretedChoices from Implements (#14068)
part of #13653

CHANGELOG_BEGIN
CHANGELOG_END
2022-06-02 18:48:54 +00:00
Remy
62877ab78b
LF: Cleanup Fetches (#13804)
- Rename fetch to fetch_template
- Rename misnamed fetch_by_interface to fetch_interface
- Drop dead fetch_by_interface

CHANGELOG_BEGIN
CHANGELOG_END
2022-05-30 18:55:41 +02:00
Remy
ea0d101913
Interface: Rename fixedChoice to choice (#13883)
CHANGELOG_BEGIN
CHANGELOG_END
2022-05-17 12:03:53 +02:00
Remy
6f6a3052a1
Repurpose templateId in ExerciseCommand and add interfaceId in ExerciseEvent (#13660)
part of #13653

CHANGELOG_BEGIN
CHANGELOG_END
2022-05-16 15:30:07 +00:00
Nicu Reut
a792de39a5
Update scalafmt to 3.5.1. (#13584)
CHANGELOG_BEGIN
CHANGELOG_END
2022-04-28 09:57:04 +00:00
Remy
0be64a8dd0
LF: Structure stable packages (#13682)
CHANGELOG_BEGIN
CHANGELOG_END
2022-04-26 12:47:06 +00:00
Sofia Faro
8c864b439b
iface: Use ImplementsDefRef instead of PackageInterface in speedy builtins (#13644)
* iface: Use ImplementsDefRef instead of pkg iface

For looking up required interface conversions, like we already do in other cases.

Fixes #11345 (updated the ticket for the package interface TODO since it's very different)

changelog_begin
changelog_end

* scalafmt

* errors only a compiler could notice

* scalafmt again :-(
2022-04-21 11:20:58 +01:00
Robin Krom
fcd3b6622b
ifaces:support exercising by required interface (#13554)
* ifaces:support exercising by required interface

This adds support to exercise an interface choice on a contract ID,
where the interface is required by one of the implemented interfaces of
the contract template.

Fixes #13434.

CHANGELOG_BEGIN
CHANGELOG_END

* some improvements based on review

* added a test plus a bugfix

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

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

* 2 more interface tests for the command preprocessor

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2022-04-12 18:15:29 +00:00
Remy
c048966d91
LF: Slightly reduce stack consumption of the type cheker. (#13513)
Workaroung to solve flakyness of
//daml-lf/tests:test-scenario-stable-many-field until #13410 is fixed.

CHANGELOG_BEGIN
CHANGELOG_END
2022-04-06 13:10:18 +01:00
Moisés Ackerman
f59d1cd0b4
Convert experimental primitive TYPEREP_TYCON_NAME into proper LF builtin (#13465)
* Convert experimental primitive TYPEREP_TYCON_NAME into proper LF builtin

* Add entry for TYPEREP_TYCON_NAME in daml-lf spec

* disable quickcheck test in DA.Test.Packaging

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

* Use unsafeFromInterface instead of fromInterface + experimental primitive

* Drop THROW_WRONGLY_TYPED_CONTRACT experimental primitive

* Add UnsafeFrom{,Required}Interface LF primitives

* Add convertPrim cases for UnsafeFrom{,Required}Interface

* Add InterfaceGuarded tests for WronglyTypedContract cases

changelog_begin
changelog_end

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2022-03-25 10:07:14 +00:00
Sofia Faro
1feb4d25eb
Drop typerep argument from ExerciseInterface. (#13284)
* ifaces: Remove typerep arg from UExerciseInterface

changelog_begin
changelog_end

* Drop typerep argument in protobuf and haskell ast

changelog_begin
changelog_end

* scalafmt

* fix ExprParser

* fix PhaseOneTest

* fix validation test

* update evidencing security
2022-03-15 13:53:06 +00:00
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
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
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
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
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
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
Moisés Ackerman
7567cf50aa
Add scala serializability checks for interfaces (#12631)
* interfaces should not be implicitly serializable

* Add scala serializability check for interface choices

* Add scala serializability check for interface payloads

changelog_begin
changelog_end
2022-01-28 09:44:02 +01:00
Stefano Baghino
aec3390904
Replace silencer plugin with built-in warning configuration (#12543)
Since Scala 2.13.2, Scala introduced built-in support to
manage warnings in a more granular fashion, thus making
the silencer plugin we are currently using no longer
strictly useful. Removing compiler plugins also removes
friction from migrating to Scala 3 in the future. As a
cherry on top, the built-in warning configuration also
allows to check whether a `@nowarn` actually does
anything, allowing us to proactively remove unused
warnings should the need arise.

[Here][1] is s a blog post by the Scala team about it.

Warnings have been either solved or preserved if useful,
trying to minimize the scope (keeping it at the single
expression scope if possible). In particular, all
remaining usages of the Scala Collection API compatibility
module have been removed.

Using the silencer plugin also apparently hid a few
remaining usages of compatibility libraries that were used
as part of the transition from Scala 2.12 to Scala 2.13
that are no longer needed. Removing those warnings
highlighted those.

changelog_begin
changelog_end

[1]: https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html
2022-01-24 15:01:35 +00:00
Remy
30300fdac6
LF: Revert #7742 (#12354)
Following #12338 which merges the two implementations of the
structural record projection introduced by #7740, this PR merges the two
implementations of the structural record introduced by #7742.

However, this PR does not try to cache the field index as it is done

1- unlike what it is suggested by commit message of #7742, the update
   has a linear complexity anyway, as it has to copy the whole struct.

2- the compiler does not produce any structural record updates

As result the PR is basically a revert of #7742.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-11 15:53:10 +00:00
Remy
7ec55d7f33
LF: Cache field index inside structural record projection builtin (#12338)
Currently we have two implementations for the projection of structural
record.

1- The first implementation takes as parameter the index of the
projected field and is therefore constant. This implementations is
used when the type checking is enable, as the index cannot be directly
inferred from the AST and must hence be filled in by the DAML-LF type
checker.

2- The second implementation takes as parameter the name of the
projected field and is therefore logarithmic as the field must be
lookup by binary search at each call. This version is used when the
type checking is disable as the index cannot be inferred without type
inference.

In this PR, we modify the second implementation so it cache the index
at the first call, hence avoiding the recomputation during further
calls.  In this way we reach an amortized constant complexity.  The
first implementation is decommissioned in benefit of the second one.

The advantages of this approach are:

- We have a unique implementation of the projection, so the behavior
  of a program is the same whenever the type checking is on or off.

- The AST for structural projection is immutable.

Benchmarks show no performance differences when the type checking is on.

Based on an idea by @sofiafaro-da.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-11 13:03:21 +01:00
Gary Verhaegen
d2e2c21684
update copyright headers (#12240)
New year, new copyright, new expected unknown issues with various files
that won't be covered by the script and/or will be but shouldn't change.

I'll do the details on Jan 1, but would appreciate this being
preapproved so I can actually get it merged by then.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-03 16:36:51 +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
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
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
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
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
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