mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 09:17:43 +03:00
LF: Freeze archive proto for LF 1.13 (#9345)
CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
0251e930a2
commit
35759fc83a
@ -129,6 +129,7 @@ da_scala_test_suite(
|
|||||||
":DarReaderTest.dar",
|
":DarReaderTest.dar",
|
||||||
":daml_lf_1.11_archive_proto_srcs",
|
":daml_lf_1.11_archive_proto_srcs",
|
||||||
":daml_lf_1.12_archive_proto_srcs",
|
":daml_lf_1.12_archive_proto_srcs",
|
||||||
|
":daml_lf_1.13_archive_proto_srcs",
|
||||||
":daml_lf_1.6_archive_proto_srcs",
|
":daml_lf_1.6_archive_proto_srcs",
|
||||||
":daml_lf_1.7_archive_proto_srcs",
|
":daml_lf_1.7_archive_proto_srcs",
|
||||||
":daml_lf_1.8_archive_proto_srcs",
|
":daml_lf_1.8_archive_proto_srcs",
|
||||||
@ -146,6 +147,7 @@ da_scala_test_suite(
|
|||||||
},
|
},
|
||||||
deps = [
|
deps = [
|
||||||
":daml_lf_1.12_archive_proto_java",
|
":daml_lf_1.12_archive_proto_java",
|
||||||
|
":daml_lf_1.13_archive_proto_java",
|
||||||
":daml_lf_1.6_archive_proto_java",
|
":daml_lf_1.6_archive_proto_java",
|
||||||
":daml_lf_1.7_archive_proto_java",
|
":daml_lf_1.7_archive_proto_java",
|
||||||
":daml_lf_1.8_archive_proto_java",
|
":daml_lf_1.8_archive_proto_java",
|
||||||
|
@ -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_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;
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@ import java.util.zip.ZipFile
|
|||||||
|
|
||||||
import com.daml.bazeltools.BazelRunfiles._
|
import com.daml.bazeltools.BazelRunfiles._
|
||||||
import com.digitalasset.{daml_lf_1_6, daml_lf_1_7, daml_lf_1_8}
|
import com.digitalasset.{daml_lf_1_6, daml_lf_1_7, daml_lf_1_8}
|
||||||
import com.daml.{daml_lf_1_12, daml_lf_dev}
|
import com.daml.{daml_lf_1_12, daml_lf_1_13, daml_lf_dev}
|
||||||
import com.google.protobuf.CodedInputStream
|
import com.google.protobuf.CodedInputStream
|
||||||
import org.scalatest.prop.TableDrivenPropertyChecks
|
import org.scalatest.prop.TableDrivenPropertyChecks
|
||||||
import org.scalatest.Assertion
|
import org.scalatest.Assertion
|
||||||
@ -271,6 +271,51 @@ class ProtoTest extends AnyWordSpec with Matchers with TableDrivenPropertyChecks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"daml_lf_1_13.DamlLf" should {
|
||||||
|
"read dalf" in {
|
||||||
|
decodeTestWrapper(
|
||||||
|
darFile,
|
||||||
|
{ cis =>
|
||||||
|
val archive = daml_lf_1_13.DamlLf.Archive.parseFrom(cis)
|
||||||
|
val payload = daml_lf_1_13.DamlLf.ArchivePayload.parseFrom(archive.getPayload)
|
||||||
|
payload.hasDamlLf1 shouldBe true
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"daml_lf_1_13 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_13"
|
||||||
|
|
||||||
|
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",
|
||||||
|
"d39be086ffd1ef8d510bc850f0d01b9ab671a7be829a61abfdc66bae08028f75",
|
||||||
|
"905f035efa5c06e1a07a925eaedbe7f430fd0f30ef6e5bad33cd2b7f8f9be1a1",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"daml_lf.proto",
|
||||||
|
"2038b49e33825c4730b0119472073f3d5da9b0bd3df2f6d21d9d338c04a49c47",
|
||||||
|
"3a00793bbb591746778b13994ba1abb1763dad0612bbdafd88d97f250da37d7d",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
forEvery(files) { case (fileName, linuxHash, windowsHash) =>
|
||||||
|
List(linuxHash, windowsHash) should contain(hashFile(resolve(fileName)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private def decodeTestWrapper(dar: Path, test: CodedInputStream => Assertion) = {
|
private def decodeTestWrapper(dar: Path, test: CodedInputStream => Assertion) = {
|
||||||
val zipFile = new ZipFile(dar.toFile)
|
val zipFile = new ZipFile(dar.toFile)
|
||||||
val entries = zipFile.entries().asScala.filter(_.getName.endsWith(".dalf")).toList
|
val entries = zipFile.entries().asScala.filter(_.getName.endsWith(".dalf")).toList
|
||||||
|
@ -45,7 +45,7 @@ LF_VERSIONS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# All LF versions for which we have protobufs.
|
# All LF versions for which we have protobufs.
|
||||||
PROTO_LF_VERSIONS = [ver for ver in LF_VERSIONS if ver != lf_version_configuration.get("preview")]
|
PROTO_LF_VERSIONS = LF_VERSIONS
|
||||||
|
|
||||||
# The subset of LF versions accepted by //daml-lf/encoder
|
# 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]
|
ENCODER_LF_VERSIONS = ["1.dev" if ver == "dev" else ver for ver in LF_VERSIONS]
|
||||||
|
Loading…
Reference in New Issue
Block a user