rationalize transaction proto (#18490)

This commit is contained in:
Remy 2024-02-16 08:49:00 +01:00 committed by GitHub
parent 26fd657b5c
commit 190eefe266
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 3 additions and 328 deletions

View File

@ -404,8 +404,6 @@ scala_library(
":pekko-stream-minus-patched-classes",
"//daml-lf/data",
"//daml-lf/transaction",
"//daml-lf/transaction:transaction_proto_java",
"//daml-lf/transaction:value_proto_java",
"//libs-scala/concurrent",
"//libs-scala/contextualized-logging",
"//libs-scala/executors",
@ -501,7 +499,6 @@ scala_library(
"//daml-lf/interpreter",
"//daml-lf/language",
"//daml-lf/transaction",
"//daml-lf/transaction:transaction_proto_java",
"//libs-scala/concurrent",
"//libs-scala/contextualized-logging",
"//libs-scala/executors",
@ -609,7 +606,6 @@ scala_library(
"//daml-lf/engine",
"//daml-lf/language",
"//daml-lf/transaction",
"//daml-lf/transaction:value_proto_java",
"//daml-lf/validation",
"//libs-scala/build-info",
"//libs-scala/concurrent",
@ -942,7 +938,6 @@ scala_library(
"//daml-lf/engine",
"//daml-lf/language",
"//daml-lf/transaction",
"//daml-lf/transaction:transaction_proto_java",
"//libs-scala/contextualized-logging",
"//libs-scala/executors",
"//libs-scala/jwt",

View File

@ -15,23 +15,6 @@ TARGET="${SYSTEM_PULLREQUEST_TARGETBRANCH:-main}"
echo "The target branch is '${TARGET}'."
readonly BREAKING_PROTOBUF_CHANGE_TRAILER_KEY="Breaks-protobuf"
# LF protobufs are checked against local snapshots.
function check_lf_protos() {
readonly stable_snapshot_dir="daml-lf/transaction/src/stable/protobuf"
declare -a checkSums=(
"73572a9d1a8985a611a5d8c94c983bd3d03617ddf7782161fdba5f90c3b20672 ${stable_snapshot_dir}/com/daml/lf/value.proto"
"e29470fb6077a5872cf4ffb5bc12a4b307aed81879f3b93bac1646c08dcdb8e2 ${stable_snapshot_dir}/com/daml/lf/transaction.proto"
)
for checkSum in "${checkSums[@]}"; do
echo ${checkSum} | sha256sum -c
done
buf breaking --config "buf-lf-transaction.yaml" --against ${stable_snapshot_dir}
}
# Other protobufs are checked against the chosen git target
function check_non_lf_protos() {
@ -58,7 +41,6 @@ is_check_skipped() {
}
check_protos() {
check_lf_protos
check_non_lf_protos
}

View File

@ -34,7 +34,6 @@ da_scala_library(
"//daml-lf/engine",
"//daml-lf/language",
"//daml-lf/transaction",
"//daml-lf/transaction:transaction_proto_java",
"//daml-lf/transaction-test-lib",
"//libs-scala/contextualized-logging",
"@maven//:com_google_protobuf_protobuf_java",

View File

@ -10,39 +10,15 @@ load(
"lf_scalacopts_stricter",
)
#
# Transaction and value protocol buffers
#
proto_jars(
name = "value_proto",
srcs = ["src/main/protobuf/com/daml/lf/value.proto"],
maven_artifact_prefix = "daml-lf-value",
maven_group = "com.daml",
strip_import_prefix = "src/main/protobuf/",
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//:empty_proto",
],
)
proto_jars(
name = "transaction_proto",
srcs = ["src/main/protobuf/com/daml/lf/transaction.proto"],
srcs = glob(["src/main/protobuf/com/daml/lf/**/*.proto"]),
maven_artifact_prefix = "daml-lf-transaction",
maven_group = "com.daml",
proto_deps = [
":value_proto",
],
strip_import_prefix = "src/main/protobuf/",
visibility = ["//visibility:public"],
deps = ["@com_google_protobuf//:empty_proto"],
)
#
# Transaction library providing a high-level scala transaction
# data structure and associated utilities.
#
da_scala_library(
name = "transaction",
srcs = glob(["src/main/**/*.scala"]),
@ -52,9 +28,9 @@ da_scala_library(
scalacopts = lf_scalacopts_stricter,
tags = ["maven_coordinates=com.daml:daml-lf-transaction:__VERSION__"],
visibility = ["//visibility:public"],
exports = [":transaction_proto_java"],
deps = [
":transaction_proto_java",
":value_proto_java",
"//daml-lf/data",
"//daml-lf/language",
"//libs-scala/crypto",
@ -81,7 +57,6 @@ da_scala_test(
scalacopts = lf_scalacopts,
deps = [
":transaction",
":value_proto_java",
"//daml-lf/api-type-signature",
"//daml-lf/data",
"//daml-lf/transaction-test-lib",
@ -106,8 +81,6 @@ da_scala_test(
scalacopts = lf_scalacopts,
deps = [
":transaction",
":transaction_proto_java",
":value_proto_java",
"//daml-lf/api-type-signature",
"//daml-lf/data",
"//daml-lf/language",

View File

@ -1,124 +0,0 @@
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
// Please refer to the transaction spec (in daml-foundations/daml-lf/spec/transaction.rst)
// which describes the semantics of Daml-LF transactions in more detail.
//
// [one-line] version summary
// * 10 -- new field key_with_maintainers in NodeFetch
// * 11 -- add choice observer
// * 12 -- drop value version in profit of node version
// * 13 -- no change w.r.t. 12
// * 14 -- add rollback nodes
// add byKey flag to fetch and exercise node
syntax = "proto3";
package com.daml.lf.transaction;
option java_package = "com.daml.lf.transaction";
import "com/daml/lf/value.proto";
// data structure represent an update to the ledger. executing a Daml-LF action of type
// Update A produces produces one of these.
// architecture-handbook-entry-begin: Transaction
message Transaction {
string version = 1;
repeated string roots = 2;
repeated Node nodes = 3;
}
// architecture-handbook-entry-end: Transaction
// architecture-handbook-entry-begin: Contract
message ContractInstance {
com.daml.lf.value.Identifier template_id = 1;
com.daml.lf.value.VersionedValue arg_versioned = 2;
string agreement = 3;
}
// architecture-handbook-entry-end: Contract
// architecture-handbook-entry-begin: Nodes
message Node {
string node_id = 1;
oneof node_type {
NodeCreate create = 3;
NodeFetch fetch = 4;
NodeExercise exercise = 5;
NodeLookupByKey lookup_by_key = 6;
NodeRollback rollback = 7; // *since version 14*
}
string version = 63; // *since 11*, optional
}
message KeyWithMaintainers {
oneof key {
com.daml.lf.value.VersionedValue key_versioned = 1; // *until version 11*
bytes key_unversioned = 3; // *defined in version >= 1.11*
}
repeated string maintainers = 2; // the maintainers induced by the key
}
message NodeCreate {
reserved 1; // was contract_id
ContractInstance contract_instance = 2; // *until version 11*
com.daml.lf.value.Identifier template_id = 7; // *since version 12*
bytes arg_unversioned = 8; // *since version 12*
string agreement = 9; // *since version 12*
repeated string stakeholders = 3;
repeated string signatories = 4;
KeyWithMaintainers key_with_maintainers = 5;
com.daml.lf.value.ContractId contract_id_struct = 6;
}
message NodeFetch {
reserved 1; // was contract_id
com.daml.lf.value.Identifier template_id = 2;
repeated string actors = 7;
repeated string stakeholders = 3;
repeated string signatories = 4;
reserved 5; // was value_version
com.daml.lf.value.ContractId contract_id_struct = 6;
KeyWithMaintainers key_with_maintainers = 8;
bool byKey = 9; // *since version 1.14*
}
message NodeExercise {
reserved 1; // was contract_id
com.daml.lf.value.Identifier template_id = 2;
repeated string actors = 3;
string choice = 4;
oneof arg {
com.daml.lf.value.VersionedValue arg_versioned = 5; // *until version 11*
bytes arg_unversioned = 16; // *since version 12*
}
bool consuming = 6;
repeated string children = 7; // node ids
repeated string stakeholders = 8;
repeated string signatories = 9;
reserved 10; // was controllers
com.daml.lf.value.ContractId contract_id_struct = 11;
oneof result {
com.daml.lf.value.VersionedValue result_versioned = 12; // *until version 11*
bytes result_unversioned = 17; // *since version 12*
}
reserved 13; // was contract_key
KeyWithMaintainers key_with_maintainers = 14; // optional
repeated string observers = 15; // *since version 11*
bool byKey = 18; // *since version 14*
}
message NodeLookupByKey {
com.daml.lf.value.Identifier template_id = 1;
KeyWithMaintainers key_with_maintainers = 2;
reserved 3; // was contract_id
com.daml.lf.value.ContractId contract_id_struct = 4;
}
message NodeRollback { // *since version 14*
repeated string children = 1; // node ids
}
// architecture-handbook-entry-end: Nodes

View File

@ -1,143 +0,0 @@
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
// Please refer to the value spec (in daml-foundations/daml-lf/spec/value.rst)
// which describes the semantics of Daml-LF values in more detail.
//
// [one-line] version summary
// * 10 -- new field key_with_maintainers in NodeFetch
// * 11 -- add choice observer
// * 12 -- drop value version in profit of node version
// * 13 -- no change w.r.t. 12
// * 14 -- add rollback nodes
// add byKey flag to fetch and exercise node
syntax = "proto3";
package com.daml.lf.value;
option java_package = "com.daml.lf.value";
import "google/protobuf/empty.proto";
message VersionedValue {
string version = 1;
bytes value = 2;
}
// The universe of serializable Daml-LF values.
// architecture-handbook-entry-begin: Value
message Value {
oneof sum {
Record record = 1;
Variant variant = 2;
List list = 4;
sint64 int64 = 5;
// Between v1 and v5 this field expressed a number in base-10 with up
// to 28 digits before the decimal point and up to 10 after the decimal
// point.
//
// Starting from v5 this field expressed a number in base-10 with at most
// 38 digits from which at most 37 can be used in the right hand side
// of the decimal point.
//
// See value.rst for the exact syntaxes.
string numeric = 6; // the field was named decimal in SDK 0.13.26 or earlier
string text = 8;
// microseconds since the UNIX epoch. can go backwards. fixed
// since the vast majority of values will be greater than
// 2^28, since currently the number of microseconds since the
// epoch is greater than that. Range: 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59.999999Z, so that we can convert to/from
// https://www.ietf.org/rfc/rfc3339.txt
sfixed64 timestamp = 9;
string party = 10;
bool bool = 11;
google.protobuf.Empty unit = 12;
// days since the unix epoch. can go backwards. limited from
// 0001-01-01 to 9999-12-31, also to be compatible with
// https://www.ietf.org/rfc/rfc3339.txt
int32 date = 13;
Optional optional = 14;
ContractId contract_id_struct = 15;
Map map = 16;
Enum enum = 17;
GenMap gen_map = 18; // *since version 11*
}
reserved 3; // was `contract_id`
}
// architecture-handbook-entry-end: Value
message Record {
Identifier record_id = 1; // *until version 11*, optional
repeated RecordField fields = 2;
}
message RecordField {
string label = 1; // *until version 11*, optional
Value value = 2;
}
// Each component of the module name and the name have additional
// lexical restrictions besides non-emptiness -- see the value.rst
// spec for more info.
message Identifier {
string package_id = 1; // non-empty
repeated string module_name = 2; // at least length 1
repeated string name = 3; // at least length 1
}
message Variant {
Identifier variant_id = 1; // *until version 11*, optional
string constructor = 2;
Value value = 3;
}
message Enum {
Identifier enum_id = 1; // *until version 11*, optional
string value = 2;
}
message ContractId {
string contract_id = 1;
reserved 2; // was `relative`
}
message List {
repeated Value elements = 1;
}
message Optional {
Value value = 1; // optional
}
message Map {
message Entry {
string key = 1;
Value value = 2;
}
repeated Entry entries = 1;
}
message GenMap { // *since version 11*
message Entry {
Value key = 1;
Value value = 2;
}
repeated Entry entries = 1;
}

View File

@ -75,7 +75,6 @@ da_scala_library(
"//daml-lf/language",
"//daml-lf/scenario-interpreter",
"//daml-lf/transaction",
"//daml-lf/transaction:value_proto_java",
"//daml-script/converter",
"//ledger-service/lf-value-json",
"//libs-scala/auth-utils",

View File

@ -33,14 +33,8 @@
type: jar-proto
- target: //daml-lf/transaction:transaction
type: jar-scala
- target: //daml-lf/transaction:transaction_proto_jar
type: jar-lib
- target: //daml-lf/transaction:transaction_proto_java
type: jar-proto
- target: //daml-lf/transaction:value_proto_jar
type: jar-lib
- target: //daml-lf/transaction:value_proto_java
type: jar-proto
- target: //daml-lf/transaction-test-lib:transaction-test-lib
type: jar-scala
- target: //daml-lf/validation:validation