daml/daml-lf/archive
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
..
encoder Factor out shared DAR encoder (#8794) 2021-02-09 13:53:46 +00:00
src Drop support for Daml-LF party literals from the Scala side (#11922) 2021-12-01 10:37:42 +00:00
buf.yaml LF check stable proto with buf and md5sum. (#11888) 2021-11-25 20:23:46 +00:00
BUILD.bazel LF: replace "dev" LF version by "1.dev" in bazel files (#11894) 2021-11-26 12:23:17 +00:00
proto_breaking_changes.sh LF check stable proto with buf and md5sum. (#11888) 2021-11-25 20:23:46 +00:00
proto_check_hash.sh LF: Drop Archive Snapshot for LF < 1.14 (#11820) 2021-11-26 09:18:52 +01:00
README.md LF: replace "dev" LF version by "1.dev" in bazel files (#11894) 2021-11-26 12:23:17 +00:00

Daml-LF archive

This component contains the .proto definitions specifying the format in which Daml-LF packages are stored -- the Daml-LF archive. All the proto definitions are kept in the directory src/protobuf/com/daml/daml_lf_dev/

The entry point definition is Archive in src/protobuf/com/daml/daml_lf_dev/daml_lf.proto. Archive contains some metadata about the actual archive (currently the hashing function and the hash), and then a binary blob containing the archive. The binary blob must be an ArchivePayload -- we keep it in binary form to facilitate hashing, signing, etc. The encoding and decoding of the payload is handled by Haskell and Java libraries in daml-core-package, so that consumers and producers do not really need to worry about it.

ArchivePayload is a sum type containing the various Daml-LF versions supported by the Daml-LF archive. Currently we have two major versions:

Snapshot versions

The component contains also an arbitrary number of snapshots of the protobuf definitions as they were as the time a particular version of Daml-LF was frozen. Those snapshots are kept in the directories src/protobuf/com/daml/daml_lf_x_y/, where x.y is an already frozen Daml-LF version. A snapshot for version x.y can be used to read any Daml-LF version from 1.6 to x.y without suffering breaking changes (at the generated code level) often introduced in the current version.

Building

It produces several libraries containing code to encode / decode such definition, a Haskell one, and several Java ones:

$ bazel build //daml-lf/archive:daml_lf_dev_archive_haskell_proto
$ bazel build //daml-lf/archive:daml_lf_1.dev_archive_proto_java
$ bazel build //daml-lf/archive:daml_lf_1_14_archive_proto_java

Editing the .proto definitions

When editing the proto definitions, you must make sure to not change them in a backwards-incompatible way. To make sure this doesn't happen:

  • DO NOT delete message fields;
  • DO NOT change the number of a message field or an enum value;
  • DO NOT change the type of a message field;

Note that "fields" include oneof fields. Also note that the "don't delete fields" rule is there not because they introduce a backwards incompatible change, but rather because after a field has been deleted another commiter might redefine it with a different type without realizing.

What is OK is renaming message fields while keeping the number and semantics unchanged. For example, if you have

message Foo {
  bytes blah = 1;
}

it's OK to change it to

message Foo {
  // this field is deprecated -- use baz instead!
  bytes blah_deprecated = 1;
  string baz = 2;
}

Conversion from the .proto to AST

The .proto definitions contain the serialized format for Daml-LF packages, however the code to convert from the .proto definitions to the actual AST lives elsewhere.