Commit Graph

315 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
6ece737e46
Desugar guards compatibly with 1.15/1.dev split (#14773)
* 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

* Temporarily disable decode extended interface primitives test

* Use dictionary comprehension to generate ledger/test-common test_names

* Move InterfaceSubscriptionsIT test back into 1.dev suite

* lint

* Make exercise guards nullable, ignore Nothing in decode/encode

* Desugar UExerciseInterface[Guarded] differently, point to updated GHC

* Update to new GHC revision, removes pred argument from `exercise`

* Attach correct range to guard support error (if any)

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

* Rename interface features

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

* Remove unnecessary mention of v1_14 from supportedInputVersions

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

* Clarify purpose of `Maybe Expr` type for exercise guard

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

* Remove guarded exercise when Extended Interfaces are not enabled

* Remove all instances of guarded exercises in versions <= 1.15

* Add check for isId to splitDFunId

* Exclude via $cexerciseGuarded check - ClassOpId approach did not work

* Run damlc interface tests w/o requires when since DAML_INTERFACE

* Update desugared daml for UExerciseInterface[Guarded] generation

* Temporarily disable failing damlc tests

* Remove 1.dev-only references from 1.15 protobuf

Co-authored-by: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>
2022-08-25 14:20:03 +01: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
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
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
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
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
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
Moisés Ackerman
ee394702b8
Add CoImplements to DefInterface in protobuf (#14053)
* Update docstring for TemplateImplements.tpiMethods
    * The change happend on https://github.com/digital-asset/daml/pull/13142

* Add CoImplements to DefInterface in protobuf
    * Also adds encoding/decoding logic in the haskell side

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

changelog_begin
changelog_end
2022-06-03 16:05:18 +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
Nicu Reut
a792de39a5
Update scalafmt to 3.5.1. (#13584)
CHANGELOG_BEGIN
CHANGELOG_END
2022-04-28 09:57:04 +00: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
b47fa3ba92
interface conversion primitives test cases (#13416)
* Add LF ParsersSpec cases for conversion primitives

* Add LF TypingSpec cases for conversion primitives

* Add LF DecodeV1Spec cases for conversion primitives

* Add LF EncodeV1Spec cases for conversion primitives

* update security-evidence.md

* Add missing cases in daml-lf encoder

* Add missing cases in EncodeV1Spec

* Add InterfaceMod in DamlLfEncoderTest

changelog_begin
changelog_end
2022-03-25 16:08:31 +00: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
Sergey Kisel
a4f4300502
Naming and logging improvements [DPP-956] (#13270)
* Naming and logging improvements [DPP-956]

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-15 09:40:39 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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