Commit Graph

238 Commits

Author SHA1 Message Date
Paul Brauner
f4ee00361e
Make LF v2 non backwards-compatible with LF v1 in the compiler (#17492)
* initial commit

* split gen-stable-packages-v_i into two targets

* rename compatibleWith to canDependOn

* update damlc integration tests annotation to allow for 2.x

* use the right package ID for preconditionFailed when compiling to V2

* fuse stable-packages-v1 and stable-packages-v2 into one single filegroup

* Fix DA.Daml.LF.Ast.Tests

* remove leftover 'undefined' in Version.hs

* progress on fixing DataDependencies.hs

* fix Cross-SDK typeclasses test for 2.dev

* Fix the 'Typeclasses and instances' data dependency test

* Update comment

* fix //compiler/damlc/tests:packaging

* Add TODO

* parameterize the machine by the langage version, hardcode v1 in script v2, v2 in script v2, v1 in exports

* get EngineTests to pass

* fix more tests

* fix canton integration tests

* formatting

* fix more tests

* fix transactionversiontest

* fix exceptiontest

* Fix ValueEnricherSpec

* Fix EngineInfoTest

* fix PartialTransactionSpec

* fix upgragetest

* fix TransactionSnapshot

* Fix ContractKeySpec

* Fix ReinterpretTest

* fix InterfaceViewSpec

* fix InterfacesTest

* fix stable package v1 names

* fix validate.sh tests

* formatting

* Fix ChoiceAuthorityTest

* fix explicit disclosure test

* Fix SpeedyTest

* formatting

* Fix integration test

* fix data dependency tests

* fix package vetting count, increased due to metadata being added

* Redact stable package IDs in error messages in order for the ExceptionSemantics test to work for both v1 and v2

* cleanup

* fix Daml2ScriptTestRunner

* fix JsonApiIT and daml-script golden tests

* fix daml3-script runner test

* enable v2 for all integration tests

* formatting

* fix NodeSeedsTest

* fix since-lf annotations

* add comments, improve consistency

* stop hardcoding V1 in runPureExpr and runPureSExpr

* formatting

* remove harcoding of LFv1 in ConcurrentCompiledPackages.apply

* Parameterize Compiler.Config.Default with major language version

* remove global parser implicit and default package ID and language version
2023-10-11 11:40:17 +02:00
Paul Brauner
a5cd445d3b
Introduce LF2 major version (#17348)
- Introduces a new major version, "2", in the daml_lf proto
- Adds new major versions to the compiler and the engine
- Updates all code that assumes only one major version
- Updates all code that assumes only one dev version
2023-09-13 10:01:42 +02:00
nickchapman-da
587efe4401
[Upgrades POC] softExercise (#16893) 2023-05-31 12:21:39 +00:00
mziolekda
95cc249ddd
Remove sandbox on x (#16890)
* remove sandbox-on-x project

* update bazel readme

* update release artifacts

* comment out last remaining SoX test

* remove ledger-runner-common

* remove participant-state-kv-errors

* remove recovering-indexer-integration-tests

* remove participant-integration-api

* update doc pages

* cleanup ledger-api-auth usage

* remove participant-state

* fix build

* fix build
2023-05-23 09:25:54 +02: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
47be2db143
[LF] Kill expirmental optimized text primitives (#16759)
Those have never proved their usefullness.
2023-04-25 15:42:03 +00: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
ac68bdf416
[engine] kill Daml withAuthority / LF WITH_AUTHORITY (#16548) 2023-04-17 16:50:10 +01: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
mziolekda
1a3980bf89
Separate test-common from the rest of the ledger code (#16307)
* move files

* format

* wrong file

* fix conformance tests

* add readme

* fix compatibility tests

* fix haskell tests
2023-02-14 15:29:13 +00:00
Remy
aad8725ea7
[damlc] change default output to 1.15 (#16157) 2023-02-06 08:58:47 +01:00
nickchapman-da
d406e0a8df
remove clunky of suffix from with-authority internal names (#16214) 2023-02-01 16:19:06 +00: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
nickchapman-da
f32419da20
[engine] withAuthorityOf: support from Daml --> Speedy (#16029) 2023-01-16 12:55:34 +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
dylant-da
05d9ee89f3
Improve interpretation error consistency (#15680)
* Add custom viewtype mismatch error

* Modify error message on EViewTypeMismatch to be like GHC error

* Make EUnknownMethodInInterfaceInstance error consistent w/ GHC

* Add MethodTypeMismatch error, sync with GHC error

* Prefix fields in new errors

* Intercept type mismatch in method to throw EMethodTypeMismatch

* Synchronize EUnknownField with GHC-side message

* Complete synchronizing EUnknownField with GHC-side error message

* satisfy lint and changelog check

CHANGELOG_BEGIN
CHANGELOG_END

* lint

* Fix TypingSpec for new EMethodTypeMismatch

* lint

* lint again

* EFieldTypeMismatch error for ERecUpd/ERecProj mismatch, like in GHC

* lint
2022-11-29 13:02:46 +00:00
Remy
3dee676cbb
[LF] making LF 1.15 stable (#15614) 2022-11-17 23:30:11 +01:00
tudor-da
346bb48904
Extract Ledger API error definitions in //ledger/ledger-api-errors [DPP-1269] (#15439)
* Extract Ledger API error definitions in //ledger/error-definitions

changelog_begin
SERVICE_INTERNAL_ERROR error code is created in CommonErrors and replaces the usage of LEDGER_API_INTERNAL_ERROR in ledger-api-client (as a fix).
changelog_end

* Tests in //ledger/error do not depend on //ledger/ledger-api-errors

* Remove unused dependency from //ledger/error

changelog_begin
changelog_end

* Address Martino's comment
2022-11-07 17:24:43 +01:00
Claudio Bley
e24497635d
Rework evidence security categories (#15226)
* Rework evidence security categories

using the 7 industry standard security testing areas:

* Authentication
* Authorization
* Confidentiality
* Integrity
* Availability
* Non-Repudiation
* Resilience

CHANGELOG_BEGIN
CHANGELOG_END

* Replace category `Input Validation`

* Replace category `Privacy`

* Replace category `Semantics`

* Replace category `Semantics`

* Replace category `Performance`

* Skip categories `NonRepudiation` and `Resilience` for now

There are currently no tests for these categories.

* Regenerate `security-evidence.md`
2022-10-13 09:55:45 +00:00
dylant-da
db652ef270
Improve EExpectedViewType (#15048)
* Add dylant-da as a codeowner on compiler-related directories

CHANGELOG_BEGIN
CHANGELOG_END

* SPlit EExpectedViewType into three variants with non-Text bodies

* Duplicate Haskell viewtype typechecking behaviour onto Scala side

* Split TypingSpec tests for different viewtype failures

* lint & changelog

CHANGELOG_BEGIN
CHANGELOG_END

* Fix lint
2022-09-26 14:38:12 +00:00
Remy
6dd9a45e50
[Engine] small cleaning of LookupError (#15060)
* [Engine] small cleaning of LookupError

CHANGELOG_BEGIN
CHANGELOG_END
2022-09-23 13:46:14 +00:00
Remy
0f662a66a9
LF: simplify error about unserializability of view (#14803)
CHANGELOG_BEGIN
CHANGELOG_END
2022-08-25 09:53:03 +00:00
Remy
5a07b6596f
LF: check viewtype is a monomorphic record (#14802)
CHANGELOG_BEGIN
CHANGELOG_END
2022-08-25 10:02:13 +02:00
Remy
769e26e104
LF: Remove unecesary spaces in LF snippet (#14762)
CHANGELOG_BEGIN
CHANGELOG_END
2022-08-19 15:29:32 +02: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
b53c7c3799
LF test use consistently record for interface view. (#14746)
CHANGELOG_BEGIN
CHANGELOG_END
2022-08-18 10:27:43 +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
nickchapman-da
cd1a64c8cb
[engine] stack-safe alpha equivalence (#14645)
* testcases which show current lack of stack-safety

changelog_begin
changelog_end

* make alpha-equiv be stack-safe; enable large tests

* use ++: in preference to ++ (and toList)
2022-08-09 14:20:47 +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
nickchapman-da
454fc397a7
[engine] stack-safe kind-checking (#14632)
* add tests for stack-safe kind-checking

changelog_begin
changelog_end

* make kind-checking be stack-safe

* dont forget struct types!

* add missing comment
2022-08-05 16:44:02 +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
nickchapman-da
848fff4f13
[engine] make type checking stack-safe (#14533)
make type-checking stack-safe

changelog_begin
changelog_end
2022-08-02 13:37:47 +00: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
nickchapman-da
76e9fd8658
Burn unused sub-classes of ValidationError (#14530)
changelog_begin
changelog_end
2022-07-26 13:33:45 +01:00
Remy
8a02a050b1
LF: Remove interface methods from collision check (#14513)
CHANGELOG_BEGIN
CHANGELOG_END
2022-07-26 13:31:55 +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
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
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
415cf95c78
Retroactive implements scala runtime (#14372)
* Use lookupTemplateImplementsOrInterfaceCoImplements in checkGenImplementation

* Update docs for ImplementsDefRef to reflect reality

Namely, it does not point to a conversion function, and the actual value it points to is irrelevant.
Only its presence is used to determine whether a template implements an interface or not.

Consequently, it now points to the unit value instead of the identity function.

* Generate 'CoImplementsDefRef's for each co-implemented template

* Consider CoImplementsDefRef in SBuiltin when checking if a template implements an interface

Also factor out check into private function

* Compile co-implemented methods using CoImplementsMethodDefRef

* SBCallInterface now uses CoImplementsDefRef for co-implemented methods

* Add test cases for (co)implemented interfaces in SBuiltinInterfaceTest

* Remove TemplateDoesNotImplementInterface error

* Explicitly override def in '*Implements*DefRef'

changelog_begin
changelog_end
2022-07-11 18:03:59 +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
dylant-da
3c7ab41bc3
Check interface view exists and is serializable, in compiler and in engine (#14112) (#14322)
CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>
2022-07-05 13:43:28 +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
Remy
52ec65040f
[Engine] Rename values/arguments of type PackageInterface (#14305)
to avoid confusion with Daml interface.

CHANGELOG_BEGIN
CHANGELOG_END
2022-07-01 15:38:04 +02:00