LF: clone dev protobuf for LF 1.11 (#8373)

Create protobuf packages for DAML-LF 1.11

This is part of #7139

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Remy 2021-01-06 14:32:26 +01:00 committed by GitHub
parent 7f7e4f9fdc
commit acf1134bae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1598 additions and 12 deletions

View File

@ -126,12 +126,14 @@ da_scala_test_suite(
data = [
":DarReaderTest.dalf",
":DarReaderTest.dar",
":daml_lf_1.11_archive_proto_srcs",
":daml_lf_1.6_archive_proto_srcs",
":daml_lf_1.7_archive_proto_srcs",
":daml_lf_1.8_archive_proto_srcs",
],
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",
@ -159,6 +161,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",

View File

@ -0,0 +1,54 @@
// 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;
}

File diff suppressed because it is too large Load Diff

View File

@ -1164,7 +1164,6 @@ message Update {
// contract id
Expr cid = 3;
// actors
// *Available in version < 1.5*
reserved 4; // Was actor
// argument
Expr arg = 5;
@ -1287,7 +1286,7 @@ message TemplateChoice {
bool consuming = 2;
// The controllers of the choice. They have type `List Party` and the
// template parameter in scope, and (since 1.2) also the choice parameter. All of these
// template parameter in scope, and the choice parameter. All of these
// controllers need to authorize the exercising of this choice (aka
// conjunctive choice controllers).
Expr controllers = 3;
@ -1554,7 +1553,7 @@ message Module {
repeated DefDataType data_types = 5;
repeated DefValue values = 6;
repeated DefTemplate templates = 7;
repeated DefException exceptions = 10; // *Available in versions >= 1.dev* (#8020)
repeated DefException exceptions = 10; // *Available in versions >= 1.dev*
}
message InternedDottedName {

View File

@ -8,7 +8,7 @@ import java.util.zip.ZipFile
import com.daml.bazeltools.BazelRunfiles._
import com.digitalasset.{daml_lf_1_6, daml_lf_1_7, daml_lf_1_8}
import com.daml.daml_lf_dev
import com.daml.{daml_lf_1_11, daml_lf_dev}
import com.google.protobuf.CodedInputStream
import org.scalatest.prop.TableDrivenPropertyChecks
import org.scalatest.Assertion
@ -53,9 +53,9 @@ class ProtoTest extends AnyWordSpec with Matchers with TableDrivenPropertyChecks
}
}
"daml_lf_1_6 file" should {
"daml_lf_1_6 files" should {
// Do not change thiss test.
// Do not change this test.
// The test checks the snapshot of the proto definition are not modified.
val rootDir = "daml-lf/archive/src/main/protobuf/com/digitalasset/daml_lf_1_6"
@ -100,9 +100,9 @@ class ProtoTest extends AnyWordSpec with Matchers with TableDrivenPropertyChecks
}
}
"daml_lf_1_7 file" should {
"daml_lf_1_7 files" should {
// Do not change thiss test.
// Do not change this test.
// The test checks the snapshot of the proto definition are not modified.
val rootDir = "daml-lf/archive/src/main/protobuf/com/digitalasset/daml_lf_1_7"
@ -147,9 +147,9 @@ class ProtoTest extends AnyWordSpec with Matchers with TableDrivenPropertyChecks
}
}
"daml_lf_1_8 file" should {
"daml_lf_1_8 files" should {
// Do not change thiss test.
// Do not change this test.
// The test checks the snapshot of the proto definition are not modified.
val rootDir = "daml-lf/archive/src/main/protobuf/com/digitalasset/daml_lf_1_8"
@ -182,6 +182,51 @@ class ProtoTest extends AnyWordSpec with Matchers with TableDrivenPropertyChecks
}
}
"daml_lf_1_11.DamlLf" should {
"read dalf" in {
decodeTestWrapper(
darFile, { cis =>
val archive = daml_lf_1_11.DamlLf.Archive.parseFrom(cis)
val payload = daml_lf_1_11.DamlLf.ArchivePayload.parseFrom(archive.getPayload)
payload.hasDamlLf1 shouldBe true
}
)
}
}
"daml_lf_1_11 files" should {
// Do not change this test.
// The test checks the snapshot of the proto definition are not modified.
val rootDir = "daml-lf/archive/src/main/protobuf/com/daml/daml_lf_1_11"
def resolve(file: String) =
resource(rlocation(s"$rootDir/$file"))
"not be modified" in {
val files = Table(
("file", "Linux hash", "windows hash"),
(
"daml_lf_1.proto",
"da0c65d03cf8dcbbaec99f2e203d7c44a0f9bfb8a31b129138e343b2bd9ac35b",
"f7bcc05e5c3752318876fb836d6f566217984e3f0cc75387b32b326430a1072d",
),
(
"daml_lf.proto",
"05eb95f6bb15042624d2ca89d366e3bcd8618934471c6093efeecc09bb9d7df4",
"be0a1530cfe0727f2078c0db6bd27d15004549d3778beac235ad976d07b507f4",
)
)
forEvery(files) {
case (fileName, linuxHash, windowsHash) =>
List(linuxHash, windowsHash) should contain(hashFile(resolve(fileName)))
}
}
}
private def decodeTestWrapper(dar: Path, test: CodedInputStream => Assertion) = {
val zipFile = new ZipFile(dar.toFile)
val entries = zipFile.entries().asScala.filter(_.getName.endsWith(".dalf")).toList

View File

@ -55,7 +55,7 @@ class DecodeV1Spec
private[this] val dummyModuleStr = "dummyModule"
private[this] val dummyModuleName = Ref.DottedName.assertFromString(dummyModuleStr)
private[this] val lfVersions = List(LV.v1_6, LV.v1_7, LV.v1_8, LV.v1_dev)
private[this] val lfVersions = List(LV.v1_6, LV.v1_7, LV.v1_8, LV.v1_11, LV.v1_dev)
private[this] def forEveryVersionSuchThat[U](cond: LV => Boolean)(f: LV => U): Unit =
lfVersions.foreach { version =>

View File

@ -6,6 +6,7 @@
# we bump stable.
lf_stable_version = "1.8"
lf_latest_version = "1.8"
lf_preview_versions = ["1.11"]
lf_dev_version = "1.dev"
# All LF versions for which we have protobufs.
@ -13,10 +14,11 @@ LF_VERSIONS = [
"1.6",
"1.7",
"1.8",
"1.11",
"dev",
]
LF_VERSION_PACKAGE_DIGITALASSET = {"1.6": "digitalasset", "1.7": "digitalasset", "1.8": "digitalasset"}
LF_VERSION_PACKAGE_DIGITALASSET = {"1.6": "digitalasset", "1.7": "digitalasset", "1.8": "digitalasset", "1.11": "daml"}
def lf_version_package(version):
return LF_VERSION_PACKAGE_DIGITALASSET.get(version, "daml")

View File

@ -15,6 +15,10 @@
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_dev_archive_proto_jar
type: jar-lib
- target: //daml-lf/archive:daml_lf_dev_archive_proto_java