Commit Graph

1062 Commits

Author SHA1 Message Date
Sofia Faro
fb09b72f96
Improve divulgence warning message. (#10595)
Based on feedback from @bame-da on issue #9947

changelog_begin
changelog_end
2021-08-17 13:06:03 +01:00
nickchapman-da
9db5ccfc4e
Normalize transactions & values as a separate pass (#10524)
* Normalize transactions & values as a separate pass. Use for simpler defintiion of isReplayedBy.

CHANGELOG_BEGIN
CHANGELOG_END

normalize transaction version

* remove stray import from bad merge which breaks scala 2_12 build

* change isReplayedBy to only norm its RIGHT (replay) argument

* add forgotton normalization for ValueEmum

* switch to use existing value normalization code (remove my newly coded duplicate code)

* normalize submittedTransaction before calling engine.validate

* dont call normalizeTx from Engine.validate

* *do* call normalizeTx from Engine.validate
2021-08-16 14:54:50 +00: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
Samir Talwar
41e60f7302
Upgrade to Scala 2.12.14 and 2.13.6. (#10573)
* Upgrade to Scala 2.12.14.

* Upgrade Scala to 2.13.6.

CHANGELOG_BEGIN
CHANGELOG_END

* compability: Re-pin the Maven dependencies.
2021-08-12 14:25:53 +00:00
Andreas Lochbihler
5728bbc14f
add cryptographic hash method to ChangeId and base equality on hash (#10554)
CHANGELOG_BEGIN
CHANGELOG_END
2021-08-11 17:34:44 +02:00
Andreas Herrmann
5cc78f5254
Handle missing template instances in Daml ledger export (#10526)
* LF 1.6 ledger export integration test

Test that Daml ledger export script handles DALF packages in LF version
1.6. These packages don't contain metadata, meanint `--package` flags
have to use the hash rather than the package name, and they contain no
type class instances, meaning the export script needs to contain newly
defined instances for type classes required to issue ledger commands in
Daml script.

changelog_begin
changelog_end

* Expose unconstrained Daml script commands

This will be used in Daml ledger exports of contracts defined in Daml LF
versions before 1.8. These versions did not include typeclass instances,
meaning that instances such as HasTemplateTypeRep need to be recreated
in the export Script. Not all instances required in the `Template t`
constraint can be recreated at the use-site. E.g. `HasSignatory`. By
avoiding these kinds of constraints it is possible to handle these cases
in Daml ledger exports anyway.

changelog_begin
changelog_end

* Identify all templates with missing instances

changelog_begin
changelog_end

* Use internal*Cmd on templates missing instances

changelog_begin
- [Daml export] Daml ledger export now handles templates in packages
  using LF versions 1.7 or older. These package versions don't include
  type class instances and Daml ledger export needs to generate
  replacement instances in the generated script. The generated script
  uses less type-safe versions of Daml script ledger commands.
changelog_end

* Add encodeType to encode Ast.Type in ledger export

This will be required to encode HasContractKey instances.

changelog_begin
changelog_end

* Simplify newline handling in encodeExport

* Encode missing template type class instances

* ZIP entries must use forward slash as path separator

* Throw error on encode of Any

Addressing
https://github.com/digital-asset/daml/pull/10526#discussion_r685807454

* Qualify choice using argument type

Addresses review comment
https://github.com/digital-asset/daml/pull/10526#discussion_r685817745

* Use lf.language.Util

Addresses
https://github.com/digital-asset/daml/pull/10526#discussion_r685827150

* Factor out header comment in tests

Addressing review comment
https://github.com/digital-asset/daml/pull/10526#discussion_r685830832

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-10 16:44:11 +00:00
Andreas Herrmann
7c6d3c5bc7
Handle package dependencies without metadata in Daml export (#10481)
* Expose set of stable-packages package-ids

Needed in Daml ledger export to decide whether to depend on a package
without metadata or not.

changelog_begin
changelog_end

* Handle package dependencies without metadata in Daml export

This addresses the immediate issue reported in
https://github.com/digital-asset/daml/issues/10435.

DALF before LF version 1.8 don't contain metadata such as the package
name and version. However, Daml ledger export assumed that metadata was
available to generate `--package` flags for data-dependencies.

This change generates `--package=<hash>` flags for such dependencies on
packages that don't have metadata available.

This change requires additional care when checking if a package is a
stable-package. As the package name is not available without metadata we
cannot just check against names such as `daml-stdlib`. Instead this
change uses the list of stable-package package-ids exposed by
`com.daml.lf.language.StablePackages.Ids`, which was introduced in
0da814d250 (diff-208c6948c7c7f2b582faa8e4792bfe78b231188881947ad0cdd5046e0b9a40e7)

Note that this does not fully resolve #10435. Building a generated Daml
ledger export script will fail on missing instances of standard classes
such as `HasTemplate` because packages prior to LF version 1.8 don't
contain type-class instances. This will be addressed in a separate PR.

changelog_begin
changelog_end

* Fix Scala 2.12

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-08-04 18:11:17 +02:00
Remy
dc47b105de
LF: Log internal errors (#10471)
part of #9974

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-04 12:31:58 +02:00
Remy
c243f82525
LF: Clean up of Errors (#10052)
part of #9974

 - rename `msg` field to `message`
 - drop `engine.Error.Validation.Generic`
 - rename argument `where` to `location`
 - Builtin set the `dependsOnTime` before throwing the callback `SResultNeedTime`

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-03 18:35:34 +02:00
Remy
5d5343aad5
LF: remove PartialTransaction argument from Speedy err pretty printer (#10470)
CHANGELOG_BEGIN
CHANGELOG_END
2021-08-03 18:09:59 +02: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
4ae4a9daf7
LF: restrict length of Name and DottedName (#10453)
fixes #10358

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-02 15:49:03 +02:00
Moritz Kiefer
4cf5641678
Build & releases 1.13 Ledger API test tool (#10456)
Temporary hack to unblock Canton until they finish their exception support.

changelog_begin
changelog_end
2021-08-02 13:27:45 +00:00
Remy
3d9c1a09f4
LF: Missing value decoding changes from #10393 (#10443)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-29 13:28:10 +02:00
Samir Talwar
9c08e4cf7e
Move logging value definitions alongside their objects. (#10439)
* logging-entries: Make `LoggingEntries` a non-case class.

There's no reason for it to need `equals`, etc.

CHANGELOG_BEGIN
CHANGELOG_END

* ledger-api-domain: Convert commands into a logging value.

Instead of having a function, let's use `ToLoggingContext`.

This also adds a couple of missing items, and always logs `workflowId`.

* participant-state: Convert updates into a logging value.

Instead of having a function, let's use `ToLoggingContext`.

This changes some of the logging context structure, but otherwise
everything remains the same.

* Make sure Scaladoc is lined up for modified code.
2021-07-29 09:21:27 +00:00
Remy
73290c29d5
LF: Add context in missing package errors (#10418)
explaining the origining of missing package.

This is part of #9974

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-28 12:17:07 +02:00
Remy
41009f79cc
Compiler: Make LF 1.14 the default output (#10394)
CHANGELOG_BEGIN

- [Compiler] Default compiler output LF version is now 1.14

CHANGELOG_END
2021-07-28 12:14:56 +02:00
Remy
cf7b1bb8b5
LF: ValueDecoder set recursion limit for values. (#10393)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-28 12:14:15 +02:00
Sofia Faro
0da814d250
Let stable packages bypass LF version restrictions. (#10377)
* Stable packages bypass version restrictions.

Part of #10029

changelog_begin
changelog_end

* Add missing bypass

* scalafmt

* Fix tests

* fix script runner

* Fix scenario service

* Dont make stable packages configurable

* unused import

* revert unnecessary formatting changes

* Added a StableOnly engine mode and a conformance test that uses it

* buildifier-fix

* Inline LanguageVersions.StableOnly

* scalafmt

* Remove EngineMode in favor of representing the version range directly

* Add -unsafe to flag name

* Apply suggestions from code review
2021-07-27 18:51:00 +00: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
72cf2f36d3
LF: replace bazel keyword stable by default (#10410)
to refer to the compiler default LF output.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-27 09:27:03 +02:00
nickchapman-da
1bed05fec2
Treat KeyWithMaintainers field structurally in all node types. (#10392)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-23 13:51:03 +00:00
nickchapman-da
387945298d
fix cut&paste typo bug; there are no insig lookup tweaks! (#10389)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-23 11:08:22 +01:00
nickchapman-da
90c3582ee8
treat exerciseResult structurally for isReplayedBy (#10381)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-23 09:46:08 +00:00
Remy
5242e2c618
LF: drop old serializability check for Values (#10382)
We drop this check for the following reasons:

* Its only usage was inside the transaction builder, this is subsumed
  by the check we added in the SValue to Value translation (#10370)

* It seems to origianl check more that nesting (and so to be
  overcomplicate)

* It was used in non-consitent way. It was used to check create
  arguments and choice arguments, but niether choice result nor
  contract key.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-22 20:49:35 +02:00
Remy
ee755306fe
LF: Specify nesting constraint for serialized values. (#10375)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-22 17:50:29 +02:00
Remy
4a33c03f72
LF: Add check of nesting in SValue.toValue (#10370)
The conversion of SValue to Value already ensures the resulting value
has a serializable type. Here we add a check to ensure it does not
overpass the maximum allow nesting.
2021-07-22 17:49:54 +02:00
nickchapman-da
42b70ad31d
Fetch actingParties always non-empty for supported versions (>=1.6) (#10357)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-22 12:04:10 +00:00
Moritz Kiefer
66284c17f2
Limit length of package ids to 64 characters (#10368)
* Limit length of package ids to 64 characters

In practice, you cannot use a package id that is not a valid sha256
outside of a test anyway since we validate them. However, we didn’t
enforce it at the daml-lf level which is a bit annoying.

This PR fixes this and adds a length restriction of 64
characters (i.e. 256 bytes for sha256).

We could go a bit further and also restrict the characters to valid
sha256 hashes (i.e. 64 character hex strings). I don’t feel all that
strongly about that either way. We use other characters in tests but
fixing that shouldn’t be particularly hard either. The extra
characters don’t seem to cause problem so far, so I think it’s fine to
keep that.

No changelog entry since I don’t see how a user can be affected by this.

changelog_begin
changelog_end

* Update daml-lf/encoder/src/main/scala/com/digitalasset/daml/lf/archive/testing/DamlLfEncoder.scala
2021-07-22 10:50:11 +00:00
Remy
faf479e8c8
LF: add context in LookupError (#10314)
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-21 19:03:53 +02:00
Remy
27d439d546
LF: Compile netsed ELets using constant stack (#10337)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-21 14:31:29 +02:00
Samir Talwar
cf2b61e6ac
participant-state: Remove the aliases to Ref.LedgerString. (#10325)
* participant-state: Remove the aliases to `Ref.LedgerString`.

Use the aliases directly in `Ref` instead.

CHANGELOG_BEGIN
CHANGELOG_END

* daml-lf/data: Improve comments on ID aliases.

* daml-lf/data: Fix a typo in a comment.

Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>

Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>
2021-07-21 08:34:46 +00:00
Moritz Kiefer
c9666c7fe0
Drop unnecessary mutability from speedy OnLedger state (#10340)
Those were only mutable for scenarios but now that we have split
scenario interpretation this is no longer required

changelog_begin
changelog_end
2021-07-21 09:53:47 +02:00
Sofia Faro
b701caab7d
Report divulgence warning at commit location. (#10329)
* Pass commitLocation along in engine warning log.

changelog_begin
changelog_end

* Use commitLocation in diagnostics.

* scalafmt

* update divulgence test

* Fix commitLocation and expected diagnostic locations
2021-07-20 15:47:49 +00:00
Samir Talwar
c3bc26fd1c
daml-lf/data: Move ID aliases to Ref from _ledger-api-common_. [KVL-1002] (#10323)
* daml-lf/data: Move ID aliases to `Ref` from _ledger-api-common_.

This allows us to remove a lot of dependencies on _ledger-api-common_,
and use these aliases in other places where that module is not used.

CHANGELOG_BEGIN
CHANGELOG_END

* participant-integration-api: Remove an unused import.

* http-json-oracle: Remove `ledger-api-common` as a dependency.

* bindings-rxjava: Remove a now-unused dependency.
2021-07-20 11:01:19 +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
nickchapman-da
0e09f3ba08
Remove optLocation field from transaction nodes. (#10301)
* Remove Optional[Location] field from transaction nodes.

xoptLocation

working but very messy!

cleanup PartialTransaction code

pass locationInfo in CompleteTransaction

dont pass locationInfo in SumittedTransaction

pass optLocation to CheckAuthorization

temp reinstate xoptLocation in ExerciseContextInfo

cleanup Conversions.scala

remove Optional[Location] field from transaction nodes.

CHANGELOG_BEGIN
CHANGELOG_END

* fix bad merge

* fix build after merge

* rename

* doc comment, and question
2021-07-19 13:03:30 +00:00
Remy
f033bc2bbb
LF: Clean legacy from archive proto + TEXT_TO_CODE_POINTS typo (#10286)
Thanks to @tristan-da for pointing this out.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-15 16:01:08 +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
Sofia Faro
b8e2198873
Separate traces from warnings in engine. (#10253)
* Separate traces from warnings in engine.

I decided to separate the engine warnings from the tracelog after all,
because I think it will make testing and maintenance easier in the
long run.

Part of #9947, follow up from #10179

changelog_begin
changelog_end

* scalafmt

* Apply suggestions from code review

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

* dont use case class for WarningLog

* revert TraceLog changes from last PR

* Scala 2.12 doesnt have ArrayBuffer.addOne :(

* remove isWarnEnabled check

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-07-13 14:24:27 +00:00
Remy
6e8ec1d618
LF: Drop old depreated code (#10251)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-13 13:10:00 +00:00
Remy
e4d7cd764a
LF: Deprecate com.daml.lf.data.TryOps.Bracket (#10249)
* LF: Deprecate com.daml.lf.data.TryOps.Bracket

CHANGELOG_BEGIN
CHANGELOG_END

* address reviews

* fix
2021-07-13 10:16:53 +00:00
Remy
6fe6ae075d
LF: Make DarReader ZipEntries immulatble (#10243)
* LF: Make DarReader ZipEntries immulatble

CHANGELOG_BEGIN
CHANGELOG_END

* optim

* Revert "optim"

This reverts commit 3b25a8c68b.

* a function should not close a stream it didn’t open

* typo

* we do not support dar without manifest !
2021-07-12 21:13:25 +00:00
Remy
f19f5b0821
LF: Simplify DarReader (#10217)
This PR simplifies a bit DarReader and UniversalDarReader

This is a follow up of #10208.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-08 17:03:45 +02:00
Remy
ebb76dca4c
LF: reorganize errors in com.daml.lf.archive (#10213)
* LF: reorganize errors in com.daml.lf.archive

part of #9974

CHANGELOG_BEGIN
CHANGELOG_END

* fix
2021-07-08 13:03:42 +00:00
nickchapman-da
69646451f2
Improvements for validation tests (#10214)
* prefer Seq to List when generating samples

CHANGELOG_BEGIN
CHANGELOG_END

* use TableDrivenPropertyChecks

* remove count/println
2021-07-08 13:48:07 +01: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
Moritz Kiefer
6586dde11e
Move exercise context computation to the client side (#10199)
We probably want to start displaying the full ptx on the client side
but for now this at least moves things out of speedy and into the
rendering layer where they belong.

It also fixes IncompleteTransaction to unwind properly so the roots
are really the roots.

changelog_begin
changelog_end
2021-07-07 15:44:47 +02:00