LF: Drop Archive Snapshot for LF < 1.14 (#11820)

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Remy 2021-11-26 09:18:52 +01:00 committed by GitHub
parent abc141b57e
commit d66ecc90c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 51 additions and 8920 deletions

View File

@ -14,7 +14,7 @@ load(
"lf_scalacopts_stricter",
"silencer_plugin",
)
load("//daml-lf/language:daml-lf.bzl", "LF_MAJOR_VERSIONS", "PROTO_LF_VERSIONS", "lf_version_package", "mangle_for_java")
load("//daml-lf/language:daml-lf.bzl", "LF_MAJOR_VERSIONS", "PROTO_LF_VERSIONS", "mangle_for_java", "versions")
load(
"//rules_daml:daml.bzl",
"daml_compile",
@ -29,8 +29,7 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar")
filegroup(
name = "daml_lf_%s_archive_proto_srcs" % version,
srcs = glob([
"src/{directory}/protobuf/com/{package}/daml_lf_{version}/*.proto".format(
package = package,
"src/{directory}/protobuf/com/daml/daml_lf_{version}/*.proto".format(
version = mangled_version,
directory = directory,
),
@ -39,12 +38,7 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar")
proto_jars(
name = "daml_lf_%s_archive_proto" % version,
srcs = [":daml_lf_%s_archive_proto_srcs" % version],
javadoc_root_packages = [
"com.{package}.daml_lf_{version}".format(
package = package,
version = mangled_version,
),
],
javadoc_root_packages = ["com.daml.daml_lf_%s" % mangled_version],
maven_artifact_prefix = "daml-lf-%s-archive" % version,
maven_group = "com.daml",
strip_import_prefix = "src/%s/protobuf" % directory,
@ -52,7 +46,6 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar")
),
]
for version in PROTO_LF_VERSIONS
for package in [lf_version_package(version)]
for mangled_version in [mangle_for_java(version)]
for directory in ["main" if version == "dev" else "stable"]
]
@ -169,10 +162,7 @@ da_scala_test_suite(
],
scalacopts = lf_scalacopts,
deps = [
":daml_lf_1.11_archive_proto_java",
":daml_lf_1.6_archive_proto_java",
":daml_lf_1.7_archive_proto_java",
":daml_lf_1.8_archive_proto_java",
":daml_lf_1.14_archive_proto_java",
":daml_lf_archive_reader",
":daml_lf_dev_archive_proto_java",
"//bazel_tools/runfiles:scala_runfiles",
@ -198,12 +188,7 @@ da_scala_binary(
],
)
SNASPSHOT_VERSIONS = [
"1.11",
"1.12",
"1.13",
"1.14",
]
SNASPSHOT_VERSIONS = [ver for ver in PROTO_LF_VERSIONS if ver != "dev"]
[
sh_test(

View File

@ -26,13 +26,11 @@ supported by the Daml-LF archive. Currently we have two major 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. For versions <= 1.8, those snapshots are kept in the directories
`src/protobuf/com/digitalasset/daml_lf_x_y/`, where `x.y` is a
already frozen Daml-LF version. For newer versions, the directory is
`src/protobuf/com/daml/daml_lf_x_y/`. A snapshot for version `x.y` can be
used to read any Daml-LF version from `1.0` to `x.y` without suffering
breaking changes (at the generated code level) often introduced in the
current version.
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
@ -42,7 +40,7 @@ definition, a Haskell one, and several Java ones:
```
$ bazel build //daml-lf/archive:daml_lf_archive_haskell_proto
$ bazel build //daml-lf/archive:daml_lf_dev_archive_proto_java
$ bazel build //daml-lf/archive:daml_lf_1_6_archive_proto_java
$ bazel build //daml-lf/archive:daml_lf_1_14_archive_proto_java
```
## Editing the `.proto` definitions

View File

@ -8,12 +8,6 @@ set -e
declare -a checkSums=(
"500eefd480e9af6940adf12e7ec4c2cf4975d4cb9b25096c15edb0d57d364de8 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_14/daml_lf_1.proto"
"455dfb894ce9648a86dadb408d1ee96c36d180e0f1d625706371ea9eca95c767 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_14/daml_lf.proto"
"83207610fc117b47ef1da586e36c791706504911ff41cbee8fc5d1da12128147 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_12/daml_lf_1.proto"
"6dbc0a0288c2447af690284e786c3fc1b58a296f2786e9cd5b4053069ff7c045 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_12/daml_lf.proto"
"6d0869fd8b326cc82f7507ec9deb37520af23ccc4c03a78af623683eb5df2bee daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_13/daml_lf_1.proto"
"2038b49e33825c4730b0119472073f3d5da9b0bd3df2f6d21d9d338c04a49c47 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_13/daml_lf.proto"
"9a9c86f4072ec08ac292517d377bb07b1436c2b9133da9ba03216c3ae8d3d27c daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_11/daml_lf_1.proto"
"05eb95f6bb15042624d2ca89d366e3bcd8618934471c6093efeecc09bb9d7df4 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_11/daml_lf.proto"
)
for checkSum in "${checkSums[@]}"; do

View File

@ -1,54 +0,0 @@
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
syntax = "proto3";
package daml_lf_1_11;
option java_package = "com.daml.daml_lf_1_11";
option csharp_namespace = "Com.Daml.Daml_Lf_1_11.DamlLf";
import "com/daml/daml_lf_1_11/daml_lf_1.proto";
message ArchivePayload {
// this is number 3 for historical reasons -- we had
// DAML-LF v0 and v1 before we had minor versions.
string minor = 3;
reserved 9999; // for the removed "dev" major version
reserved 1; // was daml_lf_0
oneof Sum {
daml_lf_1.Package daml_lf_1 = 2;
// lf_2 = 4, lf_3 = 5, etc
}
}
enum HashFunction {
SHA256 = 0;
}
message Archive {
HashFunction hash_function = 1;
// deprecated field (bytes hash = 2), replaced by
// field 4.
// Must be an encoded ArchivePayload. We store it as `bytes` to
// simplify hashing and in future signing.
bytes payload = 3;
// The hash is simply the ascii7 lowercase hex-encoded hash of the bytes
// according to the hash_function. We store it here for convenience, code
// reading the Archive should verify that the hash is valid.
//
// Note that the hash is computed directly on the blob and not
// on the decoded structure. This means that servers implementing
// a DAML ledger need to store the blob as-is somewhere to be able
// to always offer proof that they have a DAML package matching
// the requested hash. We decided to go for this route rather than
// relying on a canonical encoding of the AST since such a scheme
// would be extremely hard (for example protobuf encoding is not
// canonical) to maintain and does not buy us much.
string hash = 4;
}

View File

@ -1,54 +0,0 @@
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
syntax = "proto3";
package daml_lf_1_12;
option java_package = "com.daml.daml_lf_1_12";
option csharp_namespace = "Com.Daml.Daml_Lf_1_12.DamlLf";
import "com/daml/daml_lf_1_12/daml_lf_1.proto";
message ArchivePayload {
// this is number 3 for historical reasons -- we had
// Daml-LF v0 and v1 before we had minor versions.
string minor = 3;
reserved 9999; // for the removed "dev" major version
reserved 1; // was daml_lf_0
oneof Sum {
daml_lf_1.Package daml_lf_1 = 2;
// lf_2 = 4, lf_3 = 5, etc
}
}
enum HashFunction {
SHA256 = 0;
}
message Archive {
HashFunction hash_function = 1;
// deprecated field (bytes hash = 2), replaced by
// field 4.
// Must be an encoded ArchivePayload. We store it as `bytes` to
// simplify hashing and in future signing.
bytes payload = 3;
// The hash is simply the ascii7 lowercase hex-encoded hash of the bytes
// according to the hash_function. We store it here for convenience, code
// reading the Archive should verify that the hash is valid.
//
// Note that the hash is computed directly on the blob and not
// on the decoded structure. This means that servers implementing
// a Daml ledger need to store the blob as-is somewhere to be able
// to always offer proof that they have a Daml package matching
// the requested hash. We decided to go for this route rather than
// relying on a canonical encoding of the AST since such a scheme
// would be extremely hard (for example protobuf encoding is not
// canonical) to maintain and does not buy us much.
string hash = 4;
}

View File

@ -1,54 +0,0 @@
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
syntax = "proto3";
package daml_lf_1_13;
option java_package = "com.daml.daml_lf_1_13";
option csharp_namespace = "Com.Daml.Daml_Lf_1_13.DamlLf";
import "com/daml/daml_lf_1_13/daml_lf_1.proto";
message ArchivePayload {
// this is number 3 for historical reasons -- we had
// Daml-LF v0 and v1 before we had minor versions.
string minor = 3;
reserved 9999; // for the removed "dev" major version
reserved 1; // was daml_lf_0
oneof Sum {
daml_lf_1.Package daml_lf_1 = 2;
// lf_2 = 4, lf_3 = 5, etc
}
}
enum HashFunction {
SHA256 = 0;
}
message Archive {
HashFunction hash_function = 1;
// deprecated field (bytes hash = 2), replaced by
// field 4.
// Must be an encoded ArchivePayload. We store it as `bytes` to
// simplify hashing and in future signing.
bytes payload = 3;
// The hash is simply the ascii7 lowercase hex-encoded hash of the bytes
// according to the hash_function. We store it here for convenience, code
// reading the Archive should verify that the hash is valid.
//
// Note that the hash is computed directly on the blob and not
// on the decoded structure. This means that servers implementing
// a Daml ledger need to store the blob as-is somewhere to be able
// to always offer proof that they have a Daml package matching
// the requested hash. We decided to go for this route rather than
// relying on a canonical encoding of the AST since such a scheme
// would be extremely hard (for example protobuf encoding is not
// canonical) to maintain and does not buy us much.
string hash = 4;
}

View File

@ -1,54 +0,0 @@
// Copyright (c) 2019 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
syntax = "proto3";
package daml_lf_1_6;
option java_package = "com.digitalasset.daml_lf_1_6";
option csharp_namespace = "Com.DigitalAsset.Daml_Lf_1_6.DamlLf";
import "com/digitalasset/daml_lf_1_6/daml_lf_0.proto";
import "com/digitalasset/daml_lf_1_6/daml_lf_1.proto";
message ArchivePayload {
// this is number 3 for historical reasons -- we had
// DAML-LF v0 and v1 before we had minor versions.
string minor = 3;
reserved 9999; // for the removed "dev" major version
oneof Sum {
daml_lf_0.Package daml_lf_0 = 1;
daml_lf_1.Package daml_lf_1 = 2;
// lf_2 = 4, lf_3 = 5, etc
}
}
enum HashFunction {
SHA256 = 0;
}
message Archive {
HashFunction hash_function = 1;
// deprecated field (bytes hash = 2), replaced by
// field 4.
// Must be an encoded ArchivePayload. We store it as `bytes` to
// simplify hashing and in future signing.
bytes payload = 3;
// The hash is simply the ascii7 lowercase hex-encoded hash of the bytes
// according to the hash_function. We store it here for convenience, code
// reading the Archive should verify that the hash is valid.
//
// Note that the hash is computed directly on the blob and not
// on the decoded structure. This means that servers implementing
// a DAML ledger need to store the blob as-is somewhere to be able
// to always offer proof that they have a DAML package matching
// the requested hash. We decided to go for this route rather than
// relying on a canonical encoding of the AST since such a scheme
// would be extremely hard (for example protobuf encoding is not
// canonical) to maintain and does not buy us much.
string hash = 4;
}

View File

@ -1,17 +0,0 @@
// Copyright (c) 2019 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
// DAML-LF-0 was a .proto representation of the DAML core stored in
// the legacy sdaml format. We used it to ease transition between
// sdaml and DAML-LF archives. This stub remains so we can
// successfully decode LFv0 archives and then report that they are
// unsupported.
syntax = "proto3";
package daml_lf_0;
option java_package = "com.digitalasset.daml_lf_1_6";
option csharp_namespace = "Com.DigitalAsset.Daml_Lf_1_6.DamlLf0";
message Package {
}

View File

@ -1,54 +0,0 @@
// Copyright (c) 2019 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
syntax = "proto3";
package daml_lf_1_7;
option java_package = "com.digitalasset.daml_lf_1_7";
option csharp_namespace = "Com.DigitalAsset.Daml_Lf_1_7.DamlLf";
import "com/digitalasset/daml_lf_1_7/daml_lf_0.proto";
import "com/digitalasset/daml_lf_1_7/daml_lf_1.proto";
message ArchivePayload {
// this is number 3 for historical reasons -- we had
// DAML-LF v0 and v1 before we had minor versions.
string minor = 3;
reserved 9999; // for the removed "dev" major version
oneof Sum {
daml_lf_0.Package daml_lf_0 = 1;
daml_lf_1.Package daml_lf_1 = 2;
// lf_2 = 4, lf_3 = 5, etc
}
}
enum HashFunction {
SHA256 = 0;
}
message Archive {
HashFunction hash_function = 1;
// deprecated field (bytes hash = 2), replaced by
// field 4.
// Must be an encoded ArchivePayload. We store it as `bytes` to
// simplify hashing and in future signing.
bytes payload = 3;
// The hash is simply the ascii7 lowercase hex-encoded hash of the bytes
// according to the hash_function. We store it here for convenience, code
// reading the Archive should verify that the hash is valid.
//
// Note that the hash is computed directly on the blob and not
// on the decoded structure. This means that servers implementing
// a DAML ledger need to store the blob as-is somewhere to be able
// to always offer proof that they have a DAML package matching
// the requested hash. We decided to go for this route rather than
// relying on a canonical encoding of the AST since such a scheme
// would be extremely hard (for example protobuf encoding is not
// canonical) to maintain and does not buy us much.
string hash = 4;
}

View File

@ -1,17 +0,0 @@
// Copyright (c) 2019 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
// DAML-LF-0 was a .proto representation of the DAML core stored in
// the legacy sdaml format. We used it to ease transition between
// sdaml and DAML-LF archives. This stub remains so we can
// successfully decode LFv0 archives and then report that they are
// unsupported.
syntax = "proto3";
package daml_lf_0;
option java_package = "com.digitalasset.daml_lf_1_7";
option csharp_namespace = "Com.DigitalAsset.Daml_Lf_1_7.DamlLf0";
message Package {
}

View File

@ -1,54 +0,0 @@
// Copyright (c) 2020 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
syntax = "proto3";
package daml_lf_1_8;
option java_package = "com.digitalasset.daml_lf_1_8";
option csharp_namespace = "Com.DigitalAsset.Daml_Lf_1_8.DamlLf";
import "com/digitalasset/daml_lf_1_8/daml_lf_0.proto";
import "com/digitalasset/daml_lf_1_8/daml_lf_1.proto";
message ArchivePayload {
// this is number 3 for historical reasons -- we had
// DAML-LF v0 and v1 before we had minor versions.
string minor = 3;
reserved 9999; // for the removed "dev" major version
oneof Sum {
daml_lf_0.Package daml_lf_0 = 1;
daml_lf_1.Package daml_lf_1 = 2;
// lf_2 = 4, lf_3 = 5, etc
}
}
enum HashFunction {
SHA256 = 0;
}
message Archive {
HashFunction hash_function = 1;
// deprecated field (bytes hash = 2), replaced by
// field 4.
// Must be an encoded ArchivePayload. We store it as `bytes` to
// simplify hashing and in future signing.
bytes payload = 3;
// The hash is simply the ascii7 lowercase hex-encoded hash of the bytes
// according to the hash_function. We store it here for convenience, code
// reading the Archive should verify that the hash is valid.
//
// Note that the hash is computed directly on the blob and not
// on the decoded structure. This means that servers implementing
// a DAML ledger need to store the blob as-is somewhere to be able
// to always offer proof that they have a DAML package matching
// the requested hash. We decided to go for this route rather than
// relying on a canonical encoding of the AST since such a scheme
// would be extremely hard (for example protobuf encoding is not
// canonical) to maintain and does not buy us much.
string hash = 4;
}

View File

@ -1,17 +0,0 @@
// Copyright (c) 2020 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
// DAML-LF-0 was a .proto representation of the DAML core stored in
// the legacy sdaml format. We used it to ease transition between
// sdaml and DAML-LF archives. This stub remains so we can
// successfully decode LFv0 archives and then report that they are
// unsupported.
syntax = "proto3";
package daml_lf_0;
option java_package = "com.digitalasset.daml_lf_1_8";
option csharp_namespace = "Com.DigitalAsset.Daml_Lf_1_8.DamlLf0";
message Package {
}

View File

@ -1,6 +1,44 @@
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
def mangle_for_java(name):
return name.replace(".", "_")
def _to_major_minor(v):
(majorStr, _, minorStr) = v.partition(".")
return (int(majorStr), int(minorStr))
def _cmp(a, b):
if a == b:
return 0
elif a > b:
return 1
else:
return -1
def _cmp_lf_version(a, b):
if (a == "1.dev" or a == "dev") and (b == "1.dev" or b == "dev"):
return 0
elif (a == "1.dev" or a == "dev"):
return 1
elif (b == "1.dev" or b == "dev"):
return -1
else:
aVer = _to_major_minor(a)
bVer = _to_major_minor(b)
return _cmp(aVer, bVer)
def _gte(a, b):
return _cmp_lf_version(a, b) >= 0
def _lte(a, b):
return _cmp_lf_version(a, b) <= 0
versions = struct(
lte = _lte,
gte = _gte,
)
# The following dictionary alias LF versions to keywords:
# - "legacy" is the keyword for last LF version that supports legacy
# contract ID scheme,
@ -54,13 +92,13 @@ LF_VERSIONS = [
]
# All LF versions for which we have protobufs.
PROTO_LF_VERSIONS = LF_VERSIONS
PROTO_LF_VERSIONS = [ver for ver in LF_VERSIONS if versions.gte(ver, "1.14")]
# The subset of LF versions accepted by //daml-lf/encoder
ENCODER_LF_VERSIONS = ["1.dev" if ver == "dev" else ver for ver in LF_VERSIONS]
# We support older LF versions using an older compiler binary
LEGACY_COMPILER_LF_VERSIONS = ["1.6", "1.7", "1.8", "1.11", "1.12", "1.13"]
LEGACY_COMPILER_LF_VERSIONS = [ver for ver in LF_VERSIONS if versions.lte(ver, "1.13")]
# The subset of LF versions accepted by the compiler in the syntax
# expected by the --target option.
@ -68,55 +106,4 @@ COMPILER_LF_VERSIONS = [ver for ver in ENCODER_LF_VERSIONS if ver not in LEGACY_
ALL_COMPILER_LF_VERSIONS = LEGACY_COMPILER_LF_VERSIONS + COMPILER_LF_VERSIONS
LF_VERSION_PACKAGE_DIGITALASSET = {
"1.6": "digitalasset",
"1.7": "digitalasset",
"1.8": "digitalasset",
"1.11": "daml",
"1.12": "daml",
"1.13": "daml",
"1.14": "daml",
}
def lf_version_package(version):
return LF_VERSION_PACKAGE_DIGITALASSET.get(version, "daml")
LF_MAJOR_VERSIONS = ["1"]
def mangle_for_java(name):
return name.replace(".", "_")
def _to_major_minor(v):
(majorStr, _, minorStr) = v.partition(".")
return (int(majorStr), int(minorStr))
def _cmp(a, b):
if a == b:
return 0
elif a > b:
return 1
else:
return -1
def _cmp_lf_version(a, b):
if a == "1.dev" and b == "1.dev":
return 0
elif a == "1.dev":
return 1
elif b == "1.dev":
return -1
else:
aVer = _to_major_minor(a)
bVer = _to_major_minor(b)
return _cmp(aVer, bVer)
def _gte(a, b):
return _cmp_lf_version(a, b) >= 0
def _lte(a, b):
return _cmp_lf_version(a, b) <= 0
versions = struct(
lte = _lte,
gte = _gte,
)

View File

@ -3,30 +3,6 @@
- target: //daml-assistant/scala-daml-project-config:scala-daml-project-config
type: jar-scala
- target: //daml-lf/archive:daml_lf_1.6_archive_proto_jar
type: jar-lib
- target: //daml-lf/archive:daml_lf_1.6_archive_proto_java
type: jar-proto
- target: //daml-lf/archive:daml_lf_1.7_archive_proto_jar
type: jar-lib
- target: //daml-lf/archive:daml_lf_1.7_archive_proto_java
type: jar-proto
- target: //daml-lf/archive:daml_lf_1.8_archive_proto_jar
type: jar-lib
- target: //daml-lf/archive:daml_lf_1.8_archive_proto_java
type: jar-proto
- target: //daml-lf/archive:daml_lf_1.11_archive_proto_jar
type: jar-lib
- target: //daml-lf/archive:daml_lf_1.11_archive_proto_java
type: jar-proto
- target: //daml-lf/archive:daml_lf_1.12_archive_proto_jar
type: jar-lib
- target: //daml-lf/archive:daml_lf_1.12_archive_proto_java
type: jar-proto
- target: //daml-lf/archive:daml_lf_1.13_archive_proto_jar
type: jar-lib
- target: //daml-lf/archive:daml_lf_1.13_archive_proto_java
type: jar-proto
- target: //daml-lf/archive:daml_lf_1.14_archive_proto_jar
type: jar-lib
- target: //daml-lf/archive:daml_lf_1.14_archive_proto_java