Commit Graph

180 Commits

Author SHA1 Message Date
Paul Brauner
da08791df4
Use feature names instead of explicit mentions to 1.dev in speedy (#17379) 2023-09-09 10:33:28 +02:00
Paul Brauner
818bb1e6e8
Clean up some bazel rules (#17359)
* Fix a probable typo in //daml-fl/encoder/testing-dar-*

* apply TODOs in bazel files

* remove obsolete comments in bazel files

* use 'default' instead of 'latest' for targets relying on 'latest' in order to ensure interfaces are supported
2023-09-06 08:25:58 +02:00
nickchapman-da
587efe4401
[Upgrades POC] softExercise (#16893) 2023-05-31 12:21:39 +00:00
Moisés Ackerman
990308ce53
[Upgrades PoC] softFetch (#16839)
* Refactor PackageMetadata construction

* Package Metadata now can include an upgraded package id

* define PackageInterface#lookupPredecessors

* Add SoftFetch in Daml LF

* Add softFetch function in Daml

* Add USoftFetch LFConversion primitive

* Define SoftFetch in terms of SBPromoteAnyContract

* daml_compile rule now takes upgrades arg

* Add script test for softFetch

* TODOs

* Check LF >= 1.dev when decoding 'upgradedPackageId' and 'softFetch' in DecodeV1.scala

* Check that softFetch is not called on templates with contract keys

* Seq=>List

* ModParser todo

* Extract PackageUpgradesIT from AbstractFuncIT

* Update docstring for SBPromoteAnyContract

* Fix build errors

* Fix build error

* DecodeV1Spec case for softFetch

* DecodeV1Spec case for upgradedPackageId

* EncodeV1 case for upgradedPackageId

* Fix build error

* Disable test due to cyclic dependency with canton

* Add transitive case to PackageUpgradesIT

* Clean up PackageUpgradesIT

* Fix build error

* Error if 'upgrades' field is present before featurePackageUpgrades

* Update doc on compileSoftFetchTemplate

* Reword WronglyTypedContractSoft error
2023-05-16 10:33:47 +02:00
Remy
31bfe9b4c4
[Engine] Implement numeric builtins compatible type nat erasure (#16773)
on the scala side except Speedy.

part of #11679
2023-05-02 12:07:54 +02:00
Remy
dc40709efe
[LF] add proper encoder tests for Builtins (#16758)
We test encoder with exhaustive list of builtins for 1.11, 1.12, 1.13,
1.14, 1.15, 1.dev.

This test indirectly allso, LF parser, and LF type checking for
builtins.
2023-04-26 17:09:38 +02:00
Remy
7a17c19bbf
LF: Rename builtins that would need a witness to allow nat type erasure (#16743)
part of #11679
2023-04-24 15:02:11 +00:00
nickchapman-da
3abbf2b972
[engine] Push choice authority through compilation pipeline (#16639) 2023-04-03 09:19:24 +00:00
Moisés Ackerman
98dd1a3045
Add dynamicExercise expression and builtin (#16431)
* Add dynamicExercise expression and builtin

* Add DAML_DYNAMIC_EXERCISE feature flag
2023-03-15 10:35:24 +01:00
Moisés Ackerman
8784ebd9ce
Add choiceController and choiceObserver functions (#16088)
* Add daml test file for choice functions

* Add HasChoice{Controller,Observer} type classes

* Add choice_{controller,observer} in LF

* Update GHC_REV

* Generate HasChoice{Controller,Observer} instances

* Remove manual instances in daml test file for choice functions

* Remove/forbid choice{Controller,Observer} before featureChoiceFuncs

* update *.desugared-daml golden files

* Apply code review suggestion

* Update GHC_REV (da-master-8.8.1)

Co-authored-by: Remy <remy.haemmerle@daml.com>
2023-01-18 14:50:00 +00:00
nickchapman-da
f9139f6761
revert actings_as_consortium changes; obsoleted by withAuthorityOf (#16067) 2023-01-16 15:27:56 +00:00
Gary Verhaegen
151e12b81a
bump copyright (#16002)
This is the result of:

- Updating `./COPY` to say `2023`.
- Running `./dev-env/bin/dade-copyright-headers update .`
2023-01-04 18:21:15 +01:00
nickchapman-da
2df734e1ce
[engine] consortium primitives in LF (#15864) 2022-12-14 15:06:15 +00:00
Remy
3dee676cbb
[LF] making LF 1.15 stable (#15614) 2022-11-17 23:30:11 +01:00
Remy
a18fe164ca
[LF] reenable requires for interface (#15561)
Co-authored-by: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>
2022-11-15 08:59:24 +00:00
Remy
49f4d2979e
[LF] strengthen compilation flags (#15481) 2022-11-09 14:12:04 +01:00
Remy
56dfeb1e87
[LF] improve AstRewriter (#15073)
CHANGELOG_BEGIN
CHANGELOG_END
2022-09-23 15:13:19 +02:00
Remy
a1e92e539f
[LF] fix encoder for ELocation (#15070)
* [LF] fix encoder for ELocation

CHANGELOG_BEGIN
CHANGELOG_END
2022-09-23 10:28:21 +00:00
Remy
769e26e104
LF: Remove unecesary spaces in LF snippet (#14762)
CHANGELOG_BEGIN
CHANGELOG_END
2022-08-19 15:29:32 +02:00
Remy
b53c7c3799
LF test use consistently record for interface view. (#14746)
CHANGELOG_BEGIN
CHANGELOG_END
2022-08-18 10:27:43 +00:00
dylant-da
a4e29299be
Implement Interface views in speedy (#14565)
* Add DA_Internal_Interface to convertTypeDef exclusion check

* Move desugared types/values for interface views into DA.Internal.Desugar

* Convert viewtype and view method declarations

* Typecheck view types and view declarations

* Add unit viewtypes to InterfaceChoiceCollision tests

* Add unit viewtypes to more compiler/damlc tests

* Modify empty interfaces/implements to have viewtypes/views

* Add unit viewtypes to remaining Interface tests

* Test for error thrown when viewtype not specified

* Fix daml-lf/ interface tests to use new syntax / unit views

* Add placeholder view of type Unit to TestInterfaces

CHANGELOG_BEGIN
CHANGELOG_END

* Fix typescript interface tests with unit viewtype

* Add unit viewtype to Java & Scala codegen

* Add unit viewtype to triggers tests interface

* Add unit viewtypes to ledger/test-common

* Add unit viewtypes to ledger-service/http-json

* Fix some damlc tests

* Use viewtype syntax in InterfaceViewNonSerializable test

* Remove HasInferfaceView instances in convertBind

* Add unit view to QualifiedInterface.daml test

* Generate HasInterfaceView instances in DataDependencies

* Add unit viewtypes and views to compiler/damlc/tests

* Document reconstruction of HasInterfaceView

* Move desugared types/values for interface views into DA.Internal.Desugar

* Add desugarable function view w/ EViewInterface desugaring

* Remove templateName and viewtype from generated EViewInterface

* Update desugared-daml

* Proof of concept: use _view -> EViewInterface prim via HasInterfaceView

* Move view, HasInterfaceView to DA.Internal.Interface

* Update desugared-daml tests

* Stop removing and re-generating HasInterfaceView instances

* Do not generate docs for generated "_view_" methods

* Report errors with interface TypeConNames prettily

* Fix InterfaceViewNotSpecified @ERROR to reflect new error text

* Don't import magic `view` method from Prelude to avoid name clash

* Update shake interface goto definition test locations

* Temp disable view spec tests, will re-implement views in speedy

* Add unit viewtype to Java code snippet docs

* Update Interface syntax docs for views

* Add unit viewtype to Transferrable.daml

* Add back "empty" interface implementation to interfaces.rst

* Re-enable view tests by having _view methods on InterfaceViews.daml file

* Remove deprecated commented-out view desugaring code

* Remove templateId and viewtype from EViewInterface

* Fix lint

* Compile DefRefs for views, return them in SBViewInterface

* Stop looking for `_view` method, remove ENoViewFound in TypeChecker.hs

* Remove ENoViewFound / remove view method lookup, use view param instead

* Fix use of viewMethod.returnType / import of MethodName

* Replace uses of `_view` in Scala, update parser w/ viewtype/view clauses

* Fix lint

* Update Interface LF encoding test for views

* Stop using unit views in ParsersSpec

* Fix tests to have new Scala test parser viewtype/view syntax

* Fix Interface_extended_1.dev_.lf to have viewtypes/views

* Change all spec/lf viewtypes/views to Unit

* Remove accidental use of requires

* Fix ParsersSpec to have record viewtypes/views

* Fix ValueEnricherSpec for switch to unit views

* Remove no view test from Scala - lack of view is caught at compile-time

* Remove unused _view method in InterfaceViews.daml test

* Return control expression via Control.Expression

* Retrieve compiled views via implementation body
2022-08-09 12:49:14 +01: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
df21aad8af
LF: Make ExerciseInterface guard field optional (#14493)
in protobuf

CHANGELOG_BEGIN
CHANGELOG_END
2022-07-25 11:33:02 +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
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
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
Hubert Slojewski
281de9ac2e
Publish daml-lf encoder, parser and error-test-lib [KVL-1424] (#13730) 2022-04-29 13:59:19 +02:00
Stefano Baghino
84c8be8181
Restrict Java codegen to types that can be seen over the Ledger API (#13571)
* Restrict Java codegen to types that can be seen over the Ledger API

Fixes #13324

Builds on top of refactorings part of #13372, #13439 and #13440,
alongside adding interface support to the transitive closure function
in #13557.

changelog_begin
[Java codegen] The Java codegen now restricts its output to Daml definitions
that are either directly or indirectly referred as part of a template or
interface (that is, only the types that can be seen over the Ledger API).
See #13324 for further details.
changelog_end

* Adapt tests to add template references for every type

* Address https://github.com/digital-asset/daml/pull/13440#discussion_r837318725

* Avoid invoking the recursion from two different places.

* Address https://github.com/digital-asset/daml/pull/13571#discussion_r848441581

* Address https://github.com/digital-asset/daml/pull/13571#discussion_r848442738

* Address https://github.com/digital-asset/daml/pull/13571#discussion_r848314960
2022-04-12 18:16:29 +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
Stefano Baghino
caa8025788
Reduce noise when building //daml-lf/encoder:testing-dar-* (#13313)
changelog_begin
changelog_end

Adding Logback to the runtime dependencies allows to avoid having
logging noise when building this due to the missing logger implementation.

Before:

```
> bazel build //daml-lf/encoder:testing-dar-1.12
INFO: Invocation ID: fd46d196-8780-4b3a-9c23-41501a4668d2
INFO: Analyzed target //daml-lf/encoder:testing-dar-1.12 (1 packages loaded, 27 targets configured).
INFO: Found 1 target...
INFO: From Executing genrule //daml-lf/encoder:testing-dar-1.12:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Target //daml-lf/encoder:testing-dar-1.12 up-to-date:
  bazel-bin/daml-lf/encoder/test-1.12.dar
INFO: Elapsed time: 0.365s, Critical Path: 0.01s
INFO: 5 processes: 1 remote cache hit, 4 internal.
INFO: Build completed successfully, 5 total actions
```

After:

```
> bazel build //daml-lf/encoder:testing-dar-1.12
INFO: Invocation ID: d79a9df8-8243-49db-bd67-56a4f53ca746
INFO: Analyzed target //daml-lf/encoder:testing-dar-1.12 (1 packages loaded, 27 targets configured).
INFO: Found 1 target...
Target //daml-lf/encoder:testing-dar-1.12 up-to-date:
  bazel-bin/daml-lf/encoder/test-1.12.dar
INFO: Elapsed time: 0.332s, Critical Path: 0.01s
INFO: 5 processes: 1 remote cache hit, 4 internal.
INFO: Build completed successfully, 5 total actions
```

Notice the lack of SLF4J warnings.

See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2022-03-16 16:24:16 +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
e2c13694f2
daml-lf:encoder/decoder for requires and tests (#13272)
This adds the parser for interface requires plus tests for it.

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-15 12:56:49 +01: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
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
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
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
Gary Verhaegen
ea55ea2d14
Further copyright updates (#12249)
Somewhat error-prone, so please review carefully.

Reasons we need this:

- Some file types are not properly handled by the script.
- The only exclusion mechanism we currently have (`NO_AUTO_COPYRIGHT`)
  is overly coarse.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-04 16:32:17 +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
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
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