Commit Graph

146 Commits

Author SHA1 Message Date
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
Remy
393893a601
LF encoder: make package validation optional (#11849)
CHANGELOG_BEGIN
CHANGELOG_END
2021-11-24 13:53:52 +01:00
Remy
f33486154f
LF: Simplify LF Syntax (#11795)
- Do not wrapped choices in `choices { ... }`
- use sytematic `;` after choice component instead of ',`

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-19 17:23:36 +01: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
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
b98a3ade29
interfaces: precondition, scala ast, decoder/encoder (#11452)
* interfaces: precondition, scala ast, decoder/encoder

This adds the interface precondition to the scala Daml LF AST, plus
decoder/encoder and the typechecker.

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-lf/archive/src/main/scala/com/digitalasset/daml/lf/archive/DecodeV1.scala

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

* format

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-10-29 10:10:55 +00:00
Sofia Faro
ce64cb2a13
interfaces: Do some TODOs (#11231)
* interfaces: Do some TODOs

- Add uniqueness check between fixed choices and virtual choices in
  haskell decoder.
- Encode interface methods and fixed choices in scala encoder.
- ExprIterable for interfaces.

changelog_begin
changelog_end

* scalafmt
2021-10-13 13:36:53 +01:00
Remy
4336184a79
LF: Add interface fixed choices in scala AST and type checker (#11146)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-08 08:59:26 +02:00
Sofia Faro
c1d1521a14
interface methods: Scala AST (#11070)
* interface methods: Scala AST

Part of #11006
This PR takes care of the Scala AST and decoder.
It leaves the encoder, type checker, and speedy for later.

changelog_begin
changelog_end

* scalafmt

* AstRewriter
2021-09-29 14:11:23 +00:00
Sofia Faro
bf8b75dab5
interface methods: Add protobuf definitions. (#11005)
* interface methods: Add protobuf

Adds protobuf definitions for interface methods and calling them.
Encoders/decoders just ignore the extra stuff or error out.

Part of #10810 (maybe)

changelog_begin
changelog_end

* Update issue numbers where appropriate

* update stable protos
2021-09-23 14:55:19 +01:00
Sofia Faro
d50df11f77
interface: Add to/from interface in scala ast (#10960)
Part of #10810

changelog_begin
changelog_end
2021-09-21 16:30:01 +00:00
Remy
5dc15c6911
LF: rename language Interface to PackageInterface (#10938)
To avoid confusion with the new Daml concept of Interface.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-20 19:04:14 +00:00
Moritz Kiefer
9b0fa29aec
Separate exercise & fetch for interfaces from templates (#10908)
* Separate exercise & fetch for interfaces from templates

part of #10810

changelog_begin
changelog_end

* Update compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs

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

* Update compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs

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

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-09-16 12:05:11 +00:00
Robin Krom
f7c07eaa0c
interfaces: scala protobuf encoder (#10878)
This implements the protobuf encoder of the scala side for interfaces.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-14 12:27:53 +00:00
Remy
6ed21247a3
LF: clean up useless version tests. (#10833)
Since SDK 1.0.0 the min LF version is 1.6.
We drop some checks that are now redundant.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-10 11:43:49 +00:00
Remy
e42cd3a1c6
LF: add interface to scala AST and decoder (#10830)
this is part of #10810

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-10 08:46:19 +02:00
Remy
c4e0a755d4
LF: drop ad-hoc ImmArray builders (#10763)
Since we switch to scala 2.13, ImmArray companion object extends
`Factory`. Hence:

- the `apply` methods of `ImmArray` override the one from `Factory`

- we can use the notation `.to(ImmArray)` to convert an `Iterable` to
  `ImmArray`

This PR drops those `apply` ImmArray. Conversion from Iterable to
`ImmArray` should use the `.to(ImmArray)`.

CHANGELOG_BEGIN
CHANGELOG_END
2021-09-04 16:10:07 +02:00
Samir Talwar
4b8b67a1b5
Upgrade Scalatest to v3.2.9. (#10576)
* Upgrade Scalatest to v3.2.9.

Because of some coupling we also have to upgrade Scalaz to the latest
v7.2 point release, v7.2.33.

The Scalatest changes are quite involved because the JAR has been broken
up into several smaller JARs. Because Bazel expects us to specify all
dependencies and doesn't allow transitive dependencies to be used
directly, this means that we need to specify the explicit Scalatest
components that we use.

As you can imagine, this results in quite a big set of changes. They
are, however, constrained to dependency management; all the code remains
the same.

CHANGELOG_BEGIN
CHANGELOG_END

* http-json-oracle: Fix a Scalatest dependency.

* ledger-api-client: Fix a Scalatest dependency.
2021-08-12 23:19:35 +00:00
Remy
1971274893
Reactive canton conformance test aginst LF 1.13 (#10458)
Now we compile the conformance test for 1.13, we can run conton
against 1.13.

follow up of #10456

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-02 19:43:37 +02:00
Remy
85af078085
LF: parser for LF versions (#10424)
* LF: Simpler parser for LF version

CHANGELOG_BEGIN
CHANGELOG_END

* add a test
2021-07-27 15:46:47 +00:00
Remy
159728d716
LF: use Either by default in all archive reader API (#10295)
This is a follow up of #10277.
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-19 19:48:37 +02:00
Remy
a8f190214c
LF: change type from Try to Either in archive module (#10277)
* LF: change type from Try to Either in archive module

This is the first part of restructuring errors in archive module.
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END

* Apply suggestions from code review

Co-authored-by: Stephen Compall <stephen.compall@daml.com>

* remove type alias

* apply stephen suggestion

* fix after rebase

* fix test

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-07-14 19:24:31 +00:00
Remy
906184ce1a
LF: Simplify UniversalDarReader (#10271)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-14 15:38:22 +02:00
Remy
caf85a2270
LF: rationalize archive Parser/Reader/Decoder (#10239)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-14 11:05:17 +02:00
Remy
41b8448b17
LF: Simplify archive reader. (#10208)
* LF: Simplify archive reader.

- decouple Reader and Decoder
- introduce case class to handle hash, proto payload, and version

CHANGELOG_BEGIN
CHANGELOG_END

* Address Moritz' review

* cosmetic
2021-07-07 19:56:40 +00:00
Samir Talwar
e7e8a5705b
daml-lf/data: Optionally truncate party names in structured logs. [KVL-996] (#10163)
* daml-lf/data: Truncate party names in log output, on request.

The party name can grow quite long, so we offer ledger implementors the
opportunity to truncate it in structured log output.

Unfortunately, because we use Logback through the global
`LoggerFactory`, there is no place to inject logging configuration. This
means we also need to use global, mutable state to configure logging
output. I have added a `LoggingConfiguration` class+object in Daml-LF
Data, which may not be the best place, but I can't think of a better
one right now. I suggest we leave it there until it has reason to grow,
at which point we may want to move it.

CHANGELOG_BEGIN
CHANGELOG_END

* logging-entries: Make `ToLoggingValue` mixin-able.

* participant-integration-api: Truncate parties in filters when logging.

* participant-integration-api: Cast to `Party` for logging.

Invalid input should not break the request at this point. No assertions.

* daml-lf/data: Move `Party to LoggingValue` to a new package.

This avoids the transitive dependency issue most of the time.

* daml-lf-data: Move the `Identifier` logging to another package.

Again, reduces the need for transitively depending on _logging-entries_.
2021-07-01 16:50:49 +00:00
Samir Talwar
eda1245311
daml-lf/data: Add a conversion from Ref.Identifier to LoggingValue. (#10157)
I am getting quite tired of (Bazel + Scala)'s attitude to transitive
dependencies.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-30 20:05:06 +00:00
Remy
af144e8592
LF: Structure package loading errors (#9980)
part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-15 18:39:26 +02:00
Remy
512f1fd87d
LF: Preview version of LF 1.14 (#9906)
+ Preview support for Exceptions.
+ byKey flag for transaction nodes.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-03 20:40:53 +02:00
Remy
3dee3d042d
LF: Fix encoder for Exception (#9904)
* LF: Fix encoder for Exception

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-lf/encoder/src/main/scala/com/digitalasset/daml/lf/archive/testing/EncodeV1.scala

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

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-06-03 13:03:08 +00:00
Remy
7bc925e4d2
LF: Factorize the logic for AST lookup (#9871)
Factorize the logic for AST lookup in
 - compiler 
 - type checker 
 - preprocessor
 - script triggers 
 - some tests

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-03 13:32:56 +02:00
Miklos
f5c84a2aa4
Daml-LF: Damlification of Scala/Haskell files (#9666)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-20 09:52:33 +02:00
Remy
fcbba1cd95
LF: rename convertion builtins to be more obvious (#9716)
The name of some builtins will be exposed as part of the Exception
message. This PR, try to make conversion builtins more consistent and
more obvious, before we could not rename those.

This is part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-19 10:11:26 +00:00