diff --git a/.apilinter.yaml b/.apilinter.yaml new file mode 100644 index 000000000..73235f448 --- /dev/null +++ b/.apilinter.yaml @@ -0,0 +1,31 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +--- +- disabled_rules: + - core::0192::only-leading-comments # Forbid inline comments + - core::0192::has-comments # Required comment in every service, message, and field + - core::0141::forbidden-types # E.g., uint is forbidden + - core::0215::versioned-packages # E.g., applicationpb.v1 + - core::0131::method-signature # A google.api.method_signature annotation should be present + - core::0215::foreign-type-reference # We require foreign types. + - core::0127::http-annotation # HTTP annotations (might be added in the future) + - core::0203::field-behavior-required # E.g., [(google.api.field_behavior) = REQUIRED] + - core::0123::resource-annotation # Forces resources annotation (not applicable) + # Enforces connection between method names to the request/reposne message name. + - core::0136::response-message-name + - core::0131::response-message-name + - core::0136::request-message-name + - core::0131::request-message-name + # Grammar related issues (e.g., forbid use "of" and "with"). + - core::0140::prepositions + - core::0136::prepositions + - core::0134::synonyms + - core::0216::synonyms + # Java related issues (might be addressed in the future if required) + - core::0191::java-multiple-files + - core::0191::java-package + - core::0191::java-outer-classnam + - core::0191::java-outer-classname diff --git a/Makefile b/Makefile index c6d33ffb7..ecbc14320 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,12 @@ GO_TAGS ?= go_cmd ?= go go_test ?= $(go_cmd) test -json -v -timeout 30m +project_dir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +proto_flags ?= + +ifneq ("$(wildcard /usr/include)","") + proto_flags += --proto_path="/usr/include" +endif TOOLS_EXES = configtxgen configtxlator cryptogen @@ -58,7 +64,7 @@ $(BUILD_DIR)/%: clean: ## Cleans the build area -@rm -rf $(BUILD_DIR) -lint: FORCE +lint: lint-proto FORCE @echo "Running Go Linters..." golangci-lint run --color=always --new-from-rev=main --timeout=4m @echo "Running License Header Linters..." @@ -74,28 +80,35 @@ FORCE: # Generate protos ######################### -PROTO_TARGETS ?= $(shell find ./api \ - -name '*.proto' -print0 | \ - xargs -0 -n 1 dirname | xargs -n 1 basename | \ - sort -u | sed -e "s/^proto/proto-/" \ -) - BUILD_DIR := .build PROTOS_REPO := https://github.com/hyperledger/fabric-protos.git PROTOS_DIR := $(BUILD_DIR)/fabric-protos # We depend on this specific file to ensure the repo is actually cloned PROTOS_SENTINEL := $(PROTOS_DIR)/.git -proto: $(PROTOS_SENTINEL) - @echo "==> Compiling protos..." - protoc \ - -I=. \ +proto: FORCE $(PROTOS_SENTINEL) + @echo "Generating protobufs: $(shell find ${project_dir}/api -name '*.proto' -print0 \ + | xargs -0 -n 1 dirname | xargs -n 1 basename | sort -u)" + @protoc \ + -I=${project_dir} \ -I=$(PROTOS_DIR) \ --go_opt=Mmsp/msp_config.proto=github.com/hyperledger/fabric-protos-go-apiv2/msp \ --go-grpc_opt=Mmsp/msp_config.proto=github.com/hyperledger/fabric-protos-go-apiv2/msp \ - --go-grpc_out=. --go-grpc_opt=paths=source_relative \ + --go-grpc_out=. \ + --go-grpc_opt=paths=source_relative \ --go_out=paths=source_relative:. \ - ./api/*/*.proto + ${proto_flags} \ + ${project_dir}/api/*/*.proto + +lint-proto: FORCE $(PROTOS_SENTINEL) + @echo "Running protobuf linters..." + @api-linter \ + -I="${project_dir}/api" \ + -I="$(PROTOS_DIR)" \ + --config .apilinter.yaml \ + --set-exit-status \ + --output-format github \ + $(shell find ${project_dir}/api -name '*.proto' -exec realpath --relative-to ${project_dir}/api {} \;) $(PROTOS_SENTINEL): @mkdir -p $(BUILD_DIR) diff --git a/api/applicationpb/asn1.go b/api/applicationpb/asn1.go new file mode 100644 index 000000000..7a5149920 --- /dev/null +++ b/api/applicationpb/asn1.go @@ -0,0 +1,108 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package applicationpb + +import ( + "encoding/asn1" + + "github.com/cockroachdb/errors" +) + +// ASN1Marshal marshals a transactions for a given namespace index. +// It uses the schema described in asn1_tx_schema.asn. +func (ns *TxNamespace) ASN1Marshal(txID string) ([]byte, error) { + ret, err := asn1.Marshal(*ns.translate(txID)) + return ret, errors.Wrap(err, "failed to marshal tx namespace") +} + +// translate translates a [TxNamespace] to a stab struct for asn1_tx_schema.asn. +// Any change to [TxNamespace] requires a change to this method. +func (ns *TxNamespace) translate(txID string) *asn1Namespace { + n := asn1Namespace{ + TxID: txID, + NamespaceID: ns.NsId, + NamespaceVersion: protoToAsnVersion(&ns.NsVersion), + ReadsOnly: make([]asn1Read, len(ns.ReadsOnly)), + ReadWrites: make([]asn1ReadWrite, len(ns.ReadWrites)), + BlindWrites: make([]asn1Write, len(ns.BlindWrites)), + } + for i, r := range ns.ReadsOnly { + n.ReadsOnly[i] = asn1Read{ + Key: r.Key, + Version: protoToAsnVersion(r.Version), + } + } + for i, rw := range ns.ReadWrites { + n.ReadWrites[i] = asn1ReadWrite{ + Key: rw.Key, + Version: protoToAsnVersion(rw.Version), + Value: rw.Value, + } + } + for i, w := range ns.BlindWrites { + n.BlindWrites[i] = asn1Write{ + Key: w.Key, + Value: w.Value, + } + } + return &n +} + +// protoToAsnVersion converts the proto version to ASN.1 version. +// ASN.1 uses -1 to encode nil version. +func protoToAsnVersion(ver *uint64) int64 { + if ver == nil { + return -1 + } + return int64(*ver) //nolint:gosec // ASN.1 does not support unsigned numbers. +} + +// asnToProtoVersion converts the ASN.1 version to proto version. +// ASN.1 uses -1 to encode nil version. +func asnToProtoVersion(ver int64) *uint64 { + if ver < 0 { + return nil + } + protoVer := uint64(ver) + return &protoVer +} + +type ( + // asn1Namespace is a stab for [Tx] and [TxNamespace]. + // Any change to these protobuf requires a change to these structures. + // It conforms with asn1_tx_schema.asn. + // We force the ASN.1 library to use UTF8 strings to avoid incompatibility with the schema. + // If not specified, the library choose to use ASCII (PrintableString) for simple strings, + // and UTF8 otherwise. + asn1Namespace struct { + TxID string `asn1:"utf8"` + NamespaceID string `asn1:"utf8"` + NamespaceVersion int64 + ReadsOnly []asn1Read + ReadWrites []asn1ReadWrite + BlindWrites []asn1Write + } + // asn1Read is a stab for [Read]. + // Any change to this protobuf requires a change to these structures. + asn1Read struct { + Key []byte + Version int64 `asn1:"optional,default:-1"` + } + // asn1ReadWrite is a stab for [ReadWrite]. + // Any change to this protobuf requires a change to these structures. + asn1ReadWrite struct { + Key []byte + Value []byte + Version int64 `asn1:"optional,default:-1"` + } + // asn1Write is a stab for [Write]. + // Any change to this protobuf requires a change to these structures. + asn1Write struct { + Key []byte + Value []byte + } +) diff --git a/api/applicationpb/asn1_test.go b/api/applicationpb/asn1_test.go new file mode 100644 index 000000000..fae91d24c --- /dev/null +++ b/api/applicationpb/asn1_test.go @@ -0,0 +1,317 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package applicationpb + +import ( + "math/rand" + "testing" + "unicode/utf8" + + "github.com/stretchr/testify/require" + + "github.com/hyperledger/fabric-x-common/utils/test" +) + +func TestAsnMarshal(t *testing.T) { + t.Parallel() + CommonTestAsnMarshal(t, []*TestTx{{ + ID: "some-tx-id", + Namespaces: txTestCases, + }}) +} + +func FuzzASN1MarshalTxNamespace(f *testing.F) { + i := uint32(1024) + for _, ns := range txTestCases { + //nolint:gosec // false positive; safe integer conversion. + for _, r := range ns.ReadsOnly { + f.Add( + "some-tx-id", ns.NsId, ns.NsVersion, protoToAsnVersion(r.Version), + uint32(len(ns.ReadsOnly)), uint32(len(ns.ReadWrites)), uint32(len(ns.BlindWrites)), + i, int64(1234+i), + ) + i++ + } + //nolint:gosec // false positive; safe integer conversion. + for _, r := range ns.ReadWrites { + f.Add( + "another-tx-id", ns.NsId, ns.NsVersion, protoToAsnVersion(r.Version), + uint32(len(ns.ReadsOnly)), uint32(len(ns.ReadWrites)), uint32(len(ns.BlindWrites)), + i, int64(1234+i), + ) + i++ + } + } + f.Fuzz(func( + t *testing.T, + id, nsID string, nsVersion uint64, readVersion int64, + rCount, rwCount, wCount uint32, + maxSize uint32, seed int64, + ) { + txID, txNs := generateTxNs(t, id, nsID, nsVersion, readVersion, rCount, rwCount, wCount, maxSize, seed) + derBytes := requireASN1Marshal(t, txID, txNs) + actualTxID, actualTxNs := reconstructTX(t, [][]byte{derBytes}) + require.Equal(t, txID, actualTxID) + test.RequireProtoElementsMatch(t, []*TxNamespace{txNs}, actualTxNs) + }) +} + +// generateTxNs creates a TX with a single namespace given the input parameters. +func generateTxNs( //nolint:revive // required parameters. + t *testing.T, + id, nsID string, nsVersion uint64, readVersion int64, + rCount, rwCount, wCount uint32, + maxSize uint32, seed int64, +) (txID string, tx *TxNamespace) { + t.Helper() + if !utf8.ValidString(id) || !utf8.ValidString(nsID) { + t.Skip("invalid UTF8") + } + tx = &TxNamespace{ + NsId: nsID, + NsVersion: nsVersion, + ReadsOnly: make([]*Read, rCount), + ReadWrites: make([]*ReadWrite, rwCount), + BlindWrites: make([]*Write, wCount), + } + rnd := rand.New(rand.NewSource(seed)) + for i := range tx.ReadsOnly { + tx.ReadsOnly[i] = &Read{ + Key: mustRead(t, rnd, maxSize), + Version: asnToProtoVersion(readVersion), + } + } + for i := range tx.ReadWrites { + tx.ReadWrites[i] = &ReadWrite{ + Key: mustRead(t, rnd, maxSize), + Value: mustRead(t, rnd, maxSize), + Version: asnToProtoVersion(readVersion), + } + } + for i := range tx.BlindWrites { + tx.BlindWrites[i] = &Write{ + Key: mustRead(t, rnd, maxSize), + Value: mustRead(t, rnd, maxSize), + } + } + return id, tx +} + +var txTestCases = []*TxNamespace{ + { + NsId: "empty", + NsVersion: 1, + }, + { + NsId: "only reads", + NsVersion: 2, + ReadsOnly: []*Read{ + { + Key: []byte{1}, + Version: NewVersion(2), + }, + { + Key: []byte{3, 4, 5}, + Version: NewVersion(0), + }, + }, + }, + { + NsId: "only reads with nil version", + NsVersion: 2, + ReadsOnly: []*Read{ + { + Key: []byte{1}, + Version: NewVersion(2), + }, + { + Key: []byte{3, 4, 5}, + Version: NewVersion(0), + }, + { + Key: []byte{7, 8, 9}, + Version: nil, + }, + }, + }, + { + NsId: "only read-write", + NsVersion: 3, + ReadWrites: []*ReadWrite{ + { + Key: []byte{1}, + Version: NewVersion(2), + Value: []byte{3}, + }, + { + Key: []byte{5}, + Version: NewVersion(0), + Value: []byte{6}, + }, + }, + }, + { + NsId: "only read-write with nil value or version", + NsVersion: 3, + ReadWrites: []*ReadWrite{ + { + Key: []byte{1}, + Version: NewVersion(2), + Value: []byte{3}, + }, + { + Key: []byte{7}, + Version: nil, + Value: []byte{8}, + }, + { + Key: []byte{9}, + Version: NewVersion(3), + Value: nil, + }, + { + Key: []byte{10}, + Version: nil, + Value: nil, + }, + }, + }, + { + NsId: "only blind writes", + NsVersion: 4, + BlindWrites: []*Write{ + { + Key: []byte{5}, + Value: []byte{6, 7}, + }, + { + Key: []byte{10}, + Value: make([]byte, 0), + }, + }, + }, + { + NsId: "only blind writes with nil value", + NsVersion: 4, + BlindWrites: []*Write{ + { + Key: []byte{5}, + Value: []byte{6, 7}, + }, + { + Key: []byte{10}, + Value: make([]byte, 0), + }, + { + Key: []byte{11}, + Value: nil, + }, + }, + }, + { + NsId: "all", + NsVersion: 5, + ReadsOnly: []*Read{ + { + Key: []byte{6}, + Version: NewVersion(7), + }, + { + Key: []byte{9, 10, 11}, + Version: NewVersion(12), + }, + }, + ReadWrites: []*ReadWrite{ + { + Key: []byte{100}, + Version: NewVersion(1), + Value: []byte{2}, + }, + { + Key: []byte{5}, + Version: NewVersion(10), + Value: []byte{13}, + }, + }, + BlindWrites: []*Write{ + { + Key: []byte{1, 2, 3}, + Value: []byte{100, 101, 102}, + }, + { + Key: []byte{5}, + Value: []byte{6}, + }, + }, + }, + { + NsId: "varying number of items", + NsVersion: 6, + ReadsOnly: []*Read{ + { + Key: []byte{1, 2}, + Version: NewVersion(3), + }, + }, + ReadWrites: []*ReadWrite{ + { + Key: []byte{1}, + Version: NewVersion(2), + Value: []byte{3}, + }, + { + Key: []byte{4}, + Version: NewVersion(5), + Value: []byte{6}, + }, + { + Key: []byte{7}, + Version: NewVersion(8), + Value: []byte{9}, + }, + }, + BlindWrites: []*Write{ + { + Key: []byte{10}, + Value: []byte{12}, + }, + { + Key: []byte{13}, + Value: []byte{14}, + }, + }, + }, + { + NsId: "varying length", + NsVersion: 6, + ReadsOnly: []*Read{ + {Key: make([]byte, 127)}, + {Key: make([]byte, 128)}, + {Key: make([]byte, 129)}, + {Key: make([]byte, 255)}, + {Key: make([]byte, 256)}, + {Key: make([]byte, 257)}, + {Key: make([]byte, 0xffff)}, + {Key: make([]byte, 0x10000)}, + {Key: make([]byte, 0x10001)}, + {Key: make([]byte, 0x100000)}, + }, + }, +} + +// mustRead reads a byte array of the given size from the source. +// It panics if the read fails, or cannot read the requested size. +// "crypto/rand" and "math/rand" never fail and always returns the correct length. +func mustRead(t *testing.T, source *rand.Rand, maxSize uint32) []byte { + t.Helper() + size := source.Intn(int(maxSize)) + value := make([]byte, size) + n, err := source.Read(value) + require.NoError(t, err) + require.Equal(t, size, n) + return value +} diff --git a/api/applicationpb/asn1_test_exports.go b/api/applicationpb/asn1_test_exports.go new file mode 100644 index 000000000..643e100b7 --- /dev/null +++ b/api/applicationpb/asn1_test_exports.go @@ -0,0 +1,135 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package applicationpb + +import ( + "encoding/asn1" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/hyperledger/fabric-x-common/utils/test" +) + +// TestTx represents a test transaction for ASN1 marshalling tests. +type TestTx struct { + ID string + Namespaces []*TxNamespace +} + +// CommonTestAsnMarshal tests ASN1 marshalling and unmarshalling of the given TXs. +// It can be used by other test packages (e.g., loadgen) to ensure consistency with the implementation. +func CommonTestAsnMarshal(t *testing.T, txs []*TestTx) { + t.Helper() + for _, tx := range txs { + t.Run(tx.ID, func(t *testing.T) { + t.Parallel() + for _, ns := range tx.Namespaces { + t.Run(ns.NsId, func(t *testing.T) { + t.Parallel() + requireASN1Marshal(t, tx.ID, ns) + }) + } + + // Test that we can reconstruct the TX from the marshalled version. + // This ensures we didn't lose any data in the translation. + t.Run("verify reconstruction of the TX", func(t *testing.T) { + t.Parallel() + translatedNamespace := make([][]byte, len(tx.Namespaces)) + for i, ns := range tx.Namespaces { + var err error + translatedNamespace[i], err = ns.ASN1Marshal(tx.ID) + require.NoError(t, err) + } + txID, actualTxNs := reconstructTX(t, translatedNamespace) + require.Equal(t, tx.ID, txID) + test.RequireProtoElementsMatch(t, tx.Namespaces, actualTxNs) + }) + }) + } +} + +func requireASN1Marshal(t *testing.T, txID string, ns *TxNamespace) []byte { + t.Helper() + translated := ns.translate(txID) + + // The marshalled object cannot distinguish between empty and nil slice. + // So, we convert all nils to empty slices to allow comparison with the unmarshalled object. + for i := range translated.ReadWrites { + rw := &translated.ReadWrites[i] + if rw.Value == nil { + rw.Value = make([]byte, 0) + } + } + for i := range translated.BlindWrites { + w := &translated.BlindWrites[i] + if w.Value == nil { + w.Value = make([]byte, 0) + } + } + + derBytes, err := ns.ASN1Marshal(txID) + require.NoError(t, err) + + actual := &asn1Namespace{} + _, err = asn1.Unmarshal(derBytes, actual) + require.NoError(t, err) + require.Equal(t, translated, actual) + return derBytes +} + +// reconstructTX unmarshal the given namespaces and reconstruct a TX. +// Any change to [*applicationpb.Tx] requires a change to this method. +func reconstructTX(t *testing.T, namespaces [][]byte) (txID string, txNs []*TxNamespace) { + t.Helper() + txNs = make([]*TxNamespace, len(namespaces)) + + for i, nsDer := range namespaces { + translated := &asn1Namespace{} + _, err := asn1.Unmarshal(nsDer, translated) + require.NoError(t, err) + + if i == 0 { + txID = translated.TxID + } else { + require.Equal(t, txID, translated.TxID) + } + + nsVer := asnToProtoVersion(translated.NamespaceVersion) + require.NotNil(t, nsVer) + ns := &TxNamespace{ + NsId: translated.NamespaceID, + NsVersion: *nsVer, + ReadsOnly: make([]*Read, len(translated.ReadsOnly)), + ReadWrites: make([]*ReadWrite, len(translated.ReadWrites)), + BlindWrites: make([]*Write, len(translated.BlindWrites)), + } + txNs[i] = ns + + for j, read := range translated.ReadsOnly { + ns.ReadsOnly[j] = &Read{ + Key: read.Key, + Version: asnToProtoVersion(read.Version), + } + } + for j, rw := range translated.ReadWrites { + ns.ReadWrites[j] = &ReadWrite{ + Key: rw.Key, + Value: rw.Value, + Version: asnToProtoVersion(rw.Version), + } + } + for j, w := range translated.BlindWrites { + ns.BlindWrites[j] = &Write{ + Key: w.Key, + Value: w.Value, + } + } + } + + return txID, txNs +} diff --git a/api/applicationpb/asn1_tx_schema.asn b/api/applicationpb/asn1_tx_schema.asn new file mode 100644 index 000000000..1b8f1abc0 --- /dev/null +++ b/api/applicationpb/asn1_tx_schema.asn @@ -0,0 +1,24 @@ +-- Copyright IBM Corp. All Rights Reserved. +-- SPDX-License-Identifier: Apache-2.0 + +-- Any change to [*protoblocktx.Tx] requires a change to this schema. +-- Quick reference: https://www.oss.com/asn1/resources/asn1-made-simple/asn1-quick-reference.html + +TxWithNamespace ::= SEQUENCE { + txID UTF8String, + namespaceID UTF8String, + namespaceVersion INTEGER, + reads SEQUENCE OF SEQUENCE { + key OCTET STRING, + version INTEGER OPTIONAL DEFAULT "-1" + }, + readWrites SEQUENCE OF SEQUENCE { + key OCTET STRING, + value OCTET STRING + version INTEGER OPTIONAL DEFAULT "-1", + }, + writes SEQUENCE OF SEQUENCE { + key OCTET STRING, + value OCTET STRING + } +} diff --git a/api/applicationpb/block_tx.pb.go b/api/applicationpb/block_tx.pb.go new file mode 100644 index 000000000..18b49c9c2 --- /dev/null +++ b/api/applicationpb/block_tx.pb.go @@ -0,0 +1,635 @@ +// +//Copyright IBM Corp. All Rights Reserved. +// +//SPDX-License-Identifier: Apache-2.0 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v5.29.3 +// source: api/applicationpb/block_tx.proto + +package applicationpb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Represents a transaction in the blockchain. +type Tx struct { + state protoimpl.MessageState `protogen:"open.v1"` + // A list of namespaces that define the transaction's scope. + Namespaces []*TxNamespace `protobuf:"bytes,1,rep,name=namespaces,proto3" json:"namespaces,omitempty"` + // A list of endorsements. + // IMPORTANT: This list MUST be the same size as the namespaces list. + // The Endorsement at index i corresponds to the namespace at index i. + Endorsements []*Endorsements `protobuf:"bytes,2,rep,name=endorsements,proto3" json:"endorsements,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Tx) Reset() { + *x = Tx{} + mi := &file_api_applicationpb_block_tx_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Tx) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Tx) ProtoMessage() {} + +func (x *Tx) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_block_tx_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Tx.ProtoReflect.Descriptor instead. +func (*Tx) Descriptor() ([]byte, []int) { + return file_api_applicationpb_block_tx_proto_rawDescGZIP(), []int{0} +} + +func (x *Tx) GetNamespaces() []*TxNamespace { + if x != nil { + return x.Namespaces + } + return nil +} + +func (x *Tx) GetEndorsements() []*Endorsements { + if x != nil { + return x.Endorsements + } + return nil +} + +// Represents a namespace within a transaction. +type TxNamespace struct { + state protoimpl.MessageState `protogen:"open.v1"` + NsId string `protobuf:"bytes,1,opt,name=ns_id,json=nsId,proto3" json:"ns_id,omitempty"` // The namespace ID. + NsVersion uint64 `protobuf:"varint,2,opt,name=ns_version,json=nsVersion,proto3" json:"ns_version,omitempty"` // The version of the namespace. + ReadsOnly []*Read `protobuf:"bytes,3,rep,name=reads_only,json=readsOnly,proto3" json:"reads_only,omitempty"` // List of read only operations within the namespace. + ReadWrites []*ReadWrite `protobuf:"bytes,4,rep,name=read_writes,json=readWrites,proto3" json:"read_writes,omitempty"` // List of read-write operations within the namespace. + BlindWrites []*Write `protobuf:"bytes,5,rep,name=blind_writes,json=blindWrites,proto3" json:"blind_writes,omitempty"` // List of blind write operations within the namespace. + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TxNamespace) Reset() { + *x = TxNamespace{} + mi := &file_api_applicationpb_block_tx_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TxNamespace) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TxNamespace) ProtoMessage() {} + +func (x *TxNamespace) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_block_tx_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TxNamespace.ProtoReflect.Descriptor instead. +func (*TxNamespace) Descriptor() ([]byte, []int) { + return file_api_applicationpb_block_tx_proto_rawDescGZIP(), []int{1} +} + +func (x *TxNamespace) GetNsId() string { + if x != nil { + return x.NsId + } + return "" +} + +func (x *TxNamespace) GetNsVersion() uint64 { + if x != nil { + return x.NsVersion + } + return 0 +} + +func (x *TxNamespace) GetReadsOnly() []*Read { + if x != nil { + return x.ReadsOnly + } + return nil +} + +func (x *TxNamespace) GetReadWrites() []*ReadWrite { + if x != nil { + return x.ReadWrites + } + return nil +} + +func (x *TxNamespace) GetBlindWrites() []*Write { + if x != nil { + return x.BlindWrites + } + return nil +} + +// Represents a read operation. +type Read struct { + state protoimpl.MessageState `protogen:"open.v1"` + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // The key being read. + Version *uint64 `protobuf:"varint,2,opt,name=version,proto3,oneof" json:"version,omitempty"` // The version of the key being read. Nil version means it doesn't exist. + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Read) Reset() { + *x = Read{} + mi := &file_api_applicationpb_block_tx_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Read) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Read) ProtoMessage() {} + +func (x *Read) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_block_tx_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Read.ProtoReflect.Descriptor instead. +func (*Read) Descriptor() ([]byte, []int) { + return file_api_applicationpb_block_tx_proto_rawDescGZIP(), []int{2} +} + +func (x *Read) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *Read) GetVersion() uint64 { + if x != nil && x.Version != nil { + return *x.Version + } + return 0 +} + +// Represents a read-write operation. +type ReadWrite struct { + state protoimpl.MessageState `protogen:"open.v1"` + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // The key involved in the read-write operation. + Version *uint64 `protobuf:"varint,2,opt,name=version,proto3,oneof" json:"version,omitempty"` // The version of the key being read and written. Nil version means it doesn't exist. + Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` // The value associated with the key being written. + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReadWrite) Reset() { + *x = ReadWrite{} + mi := &file_api_applicationpb_block_tx_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReadWrite) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadWrite) ProtoMessage() {} + +func (x *ReadWrite) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_block_tx_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadWrite.ProtoReflect.Descriptor instead. +func (*ReadWrite) Descriptor() ([]byte, []int) { + return file_api_applicationpb_block_tx_proto_rawDescGZIP(), []int{3} +} + +func (x *ReadWrite) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *ReadWrite) GetVersion() uint64 { + if x != nil && x.Version != nil { + return *x.Version + } + return 0 +} + +func (x *ReadWrite) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + +// Represents a write operation. +type Write struct { + state protoimpl.MessageState `protogen:"open.v1"` + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // The key being written. + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // The value associated with the key being written. + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Write) Reset() { + *x = Write{} + mi := &file_api_applicationpb_block_tx_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Write) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Write) ProtoMessage() {} + +func (x *Write) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_block_tx_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Write.ProtoReflect.Descriptor instead. +func (*Write) Descriptor() ([]byte, []int) { + return file_api_applicationpb_block_tx_proto_rawDescGZIP(), []int{4} +} + +func (x *Write) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *Write) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + +// Endorsements holds all the signatures that correspond to a single namespace +// in the transaction's namespaces list. +type Endorsements struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The list of individual signatures for the corresponding namespace. + EndorsementsWithIdentity []*EndorsementWithIdentity `protobuf:"bytes,1,rep,name=endorsements_with_identity,json=endorsementsWithIdentity,proto3" json:"endorsements_with_identity,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Endorsements) Reset() { + *x = Endorsements{} + mi := &file_api_applicationpb_block_tx_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Endorsements) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Endorsements) ProtoMessage() {} + +func (x *Endorsements) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_block_tx_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Endorsements.ProtoReflect.Descriptor instead. +func (*Endorsements) Descriptor() ([]byte, []int) { + return file_api_applicationpb_block_tx_proto_rawDescGZIP(), []int{5} +} + +func (x *Endorsements) GetEndorsementsWithIdentity() []*EndorsementWithIdentity { + if x != nil { + return x.EndorsementsWithIdentity + } + return nil +} + +// EndorsementWithIdentity bundles a single signature with the identity of its creator. +type EndorsementWithIdentity struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The actual cryptographic signature bytes. + Endorsement []byte `protobuf:"bytes,1,opt,name=endorsement,proto3" json:"endorsement,omitempty"` + // The identity of the creator who produced the signature, i.e., the endorsement. + Identity *Identity `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EndorsementWithIdentity) Reset() { + *x = EndorsementWithIdentity{} + mi := &file_api_applicationpb_block_tx_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EndorsementWithIdentity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EndorsementWithIdentity) ProtoMessage() {} + +func (x *EndorsementWithIdentity) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_block_tx_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EndorsementWithIdentity.ProtoReflect.Descriptor instead. +func (*EndorsementWithIdentity) Descriptor() ([]byte, []int) { + return file_api_applicationpb_block_tx_proto_rawDescGZIP(), []int{6} +} + +func (x *EndorsementWithIdentity) GetEndorsement() []byte { + if x != nil { + return x.Endorsement + } + return nil +} + +func (x *EndorsementWithIdentity) GetIdentity() *Identity { + if x != nil { + return x.Identity + } + return nil +} + +type Identity struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The identifier of the associated membership service provider + MspId string `protobuf:"bytes,1,opt,name=msp_id,json=mspId,proto3" json:"msp_id,omitempty"` + // Types that are valid to be assigned to Creator: + // + // *Identity_Certificate + // *Identity_CertificateId + Creator isIdentity_Creator `protobuf_oneof:"creator"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Identity) Reset() { + *x = Identity{} + mi := &file_api_applicationpb_block_tx_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Identity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Identity) ProtoMessage() {} + +func (x *Identity) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_block_tx_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Identity.ProtoReflect.Descriptor instead. +func (*Identity) Descriptor() ([]byte, []int) { + return file_api_applicationpb_block_tx_proto_rawDescGZIP(), []int{7} +} + +func (x *Identity) GetMspId() string { + if x != nil { + return x.MspId + } + return "" +} + +func (x *Identity) GetCreator() isIdentity_Creator { + if x != nil { + return x.Creator + } + return nil +} + +func (x *Identity) GetCertificate() []byte { + if x != nil { + if x, ok := x.Creator.(*Identity_Certificate); ok { + return x.Certificate + } + } + return nil +} + +func (x *Identity) GetCertificateId() string { + if x != nil { + if x, ok := x.Creator.(*Identity_CertificateId); ok { + return x.CertificateId + } + } + return "" +} + +type isIdentity_Creator interface { + isIdentity_Creator() +} + +type Identity_Certificate struct { + // The full raw bytes of the creator's certificate (e.g., an X.509 certificate). + Certificate []byte `protobuf:"bytes,2,opt,name=certificate,proto3,oneof"` +} + +type Identity_CertificateId struct { + // An identifier for a certificate that is pre-stored or known by the committer. + CertificateId string `protobuf:"bytes,3,opt,name=certificate_id,json=certificateId,proto3,oneof"` +} + +func (*Identity_Certificate) isIdentity_Creator() {} + +func (*Identity_CertificateId) isIdentity_Creator() {} + +var File_api_applicationpb_block_tx_proto protoreflect.FileDescriptor + +const file_api_applicationpb_block_tx_proto_rawDesc = "" + + "\n" + + " api/applicationpb/block_tx.proto\x12\rapplicationpb\"\x81\x01\n" + + "\x02Tx\x12:\n" + + "\n" + + "namespaces\x18\x01 \x03(\v2\x1a.applicationpb.TxNamespaceR\n" + + "namespaces\x12?\n" + + "\fendorsements\x18\x02 \x03(\v2\x1b.applicationpb.EndorsementsR\fendorsements\"\xe9\x01\n" + + "\vTxNamespace\x12\x13\n" + + "\x05ns_id\x18\x01 \x01(\tR\x04nsId\x12\x1d\n" + + "\n" + + "ns_version\x18\x02 \x01(\x04R\tnsVersion\x122\n" + + "\n" + + "reads_only\x18\x03 \x03(\v2\x13.applicationpb.ReadR\treadsOnly\x129\n" + + "\vread_writes\x18\x04 \x03(\v2\x18.applicationpb.ReadWriteR\n" + + "readWrites\x127\n" + + "\fblind_writes\x18\x05 \x03(\v2\x14.applicationpb.WriteR\vblindWrites\"C\n" + + "\x04Read\x12\x10\n" + + "\x03key\x18\x01 \x01(\fR\x03key\x12\x1d\n" + + "\aversion\x18\x02 \x01(\x04H\x00R\aversion\x88\x01\x01B\n" + + "\n" + + "\b_version\"^\n" + + "\tReadWrite\x12\x10\n" + + "\x03key\x18\x01 \x01(\fR\x03key\x12\x1d\n" + + "\aversion\x18\x02 \x01(\x04H\x00R\aversion\x88\x01\x01\x12\x14\n" + + "\x05value\x18\x03 \x01(\fR\x05valueB\n" + + "\n" + + "\b_version\"/\n" + + "\x05Write\x12\x10\n" + + "\x03key\x18\x01 \x01(\fR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\fR\x05value\"t\n" + + "\fEndorsements\x12d\n" + + "\x1aendorsements_with_identity\x18\x01 \x03(\v2&.applicationpb.EndorsementWithIdentityR\x18endorsementsWithIdentity\"p\n" + + "\x17EndorsementWithIdentity\x12 \n" + + "\vendorsement\x18\x01 \x01(\fR\vendorsement\x123\n" + + "\bidentity\x18\x02 \x01(\v2\x17.applicationpb.IdentityR\bidentity\"y\n" + + "\bIdentity\x12\x15\n" + + "\x06msp_id\x18\x01 \x01(\tR\x05mspId\x12\"\n" + + "\vcertificate\x18\x02 \x01(\fH\x00R\vcertificate\x12'\n" + + "\x0ecertificate_id\x18\x03 \x01(\tH\x00R\rcertificateIdB\t\n" + + "\acreatorB:Z8github.com/hyperledger/fabric-x-common/api/applicationpbb\x06proto3" + +var ( + file_api_applicationpb_block_tx_proto_rawDescOnce sync.Once + file_api_applicationpb_block_tx_proto_rawDescData []byte +) + +func file_api_applicationpb_block_tx_proto_rawDescGZIP() []byte { + file_api_applicationpb_block_tx_proto_rawDescOnce.Do(func() { + file_api_applicationpb_block_tx_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_applicationpb_block_tx_proto_rawDesc), len(file_api_applicationpb_block_tx_proto_rawDesc))) + }) + return file_api_applicationpb_block_tx_proto_rawDescData +} + +var file_api_applicationpb_block_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_api_applicationpb_block_tx_proto_goTypes = []any{ + (*Tx)(nil), // 0: applicationpb.Tx + (*TxNamespace)(nil), // 1: applicationpb.TxNamespace + (*Read)(nil), // 2: applicationpb.Read + (*ReadWrite)(nil), // 3: applicationpb.ReadWrite + (*Write)(nil), // 4: applicationpb.Write + (*Endorsements)(nil), // 5: applicationpb.Endorsements + (*EndorsementWithIdentity)(nil), // 6: applicationpb.EndorsementWithIdentity + (*Identity)(nil), // 7: applicationpb.Identity +} +var file_api_applicationpb_block_tx_proto_depIdxs = []int32{ + 1, // 0: applicationpb.Tx.namespaces:type_name -> applicationpb.TxNamespace + 5, // 1: applicationpb.Tx.endorsements:type_name -> applicationpb.Endorsements + 2, // 2: applicationpb.TxNamespace.reads_only:type_name -> applicationpb.Read + 3, // 3: applicationpb.TxNamespace.read_writes:type_name -> applicationpb.ReadWrite + 4, // 4: applicationpb.TxNamespace.blind_writes:type_name -> applicationpb.Write + 6, // 5: applicationpb.Endorsements.endorsements_with_identity:type_name -> applicationpb.EndorsementWithIdentity + 7, // 6: applicationpb.EndorsementWithIdentity.identity:type_name -> applicationpb.Identity + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_api_applicationpb_block_tx_proto_init() } +func file_api_applicationpb_block_tx_proto_init() { + if File_api_applicationpb_block_tx_proto != nil { + return + } + file_api_applicationpb_block_tx_proto_msgTypes[2].OneofWrappers = []any{} + file_api_applicationpb_block_tx_proto_msgTypes[3].OneofWrappers = []any{} + file_api_applicationpb_block_tx_proto_msgTypes[7].OneofWrappers = []any{ + (*Identity_Certificate)(nil), + (*Identity_CertificateId)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_applicationpb_block_tx_proto_rawDesc), len(file_api_applicationpb_block_tx_proto_rawDesc)), + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_api_applicationpb_block_tx_proto_goTypes, + DependencyIndexes: file_api_applicationpb_block_tx_proto_depIdxs, + MessageInfos: file_api_applicationpb_block_tx_proto_msgTypes, + }.Build() + File_api_applicationpb_block_tx_proto = out.File + file_api_applicationpb_block_tx_proto_goTypes = nil + file_api_applicationpb_block_tx_proto_depIdxs = nil +} diff --git a/api/applicationpb/block_tx.proto b/api/applicationpb/block_tx.proto new file mode 100644 index 000000000..fa9791908 --- /dev/null +++ b/api/applicationpb/block_tx.proto @@ -0,0 +1,79 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +syntax = "proto3"; + +option go_package = "github.com/hyperledger/fabric-x-common/api/applicationpb"; + +package applicationpb; + +// Represents a transaction in the blockchain. +message Tx { + // A list of namespaces that define the transaction's scope. + repeated TxNamespace namespaces = 1; + + // A list of endorsements. + // IMPORTANT: This list MUST be the same size as the namespaces list. + // The Endorsement at index i corresponds to the namespace at index i. + repeated Endorsements endorsements = 2; +} + +// Represents a namespace within a transaction. +message TxNamespace { + string ns_id = 1; // The namespace ID. + uint64 ns_version = 2; // The version of the namespace. + repeated Read reads_only = 3; // List of read only operations within the namespace. + repeated ReadWrite read_writes = 4; // List of read-write operations within the namespace. + repeated Write blind_writes = 5; // List of blind write operations within the namespace. +} + +// Represents a read operation. +message Read { + bytes key = 1; // The key being read. + optional uint64 version = 2; // The version of the key being read. Nil version means it doesn't exist. +} + +// Represents a read-write operation. +message ReadWrite { + bytes key = 1; // The key involved in the read-write operation. + optional uint64 version = 2; // The version of the key being read and written. Nil version means it doesn't exist. + bytes value = 3; // The value associated with the key being written. +} + +// Represents a write operation. +message Write { + bytes key = 1; // The key being written. + bytes value = 2; // The value associated with the key being written. +} + +// Endorsements holds all the signatures that correspond to a single namespace +// in the transaction's namespaces list. +message Endorsements { + // The list of individual signatures for the corresponding namespace. + repeated EndorsementWithIdentity endorsements_with_identity = 1; +} + +// EndorsementWithIdentity bundles a single signature with the identity of its creator. +message EndorsementWithIdentity { + // The actual cryptographic signature bytes. + bytes endorsement = 1; + + // The identity of the creator who produced the signature, i.e., the endorsement. + Identity identity = 2; +} + +message Identity { + // The identifier of the associated membership service provider + string msp_id = 1; + + oneof creator { + // The full raw bytes of the creator's certificate (e.g., an X.509 certificate). + bytes certificate = 2; + + // An identifier for a certificate that is pre-stored or known by the committer. + string certificate_id = 3; + } +} diff --git a/api/applicationpb/config.pb.go b/api/applicationpb/config.pb.go new file mode 100644 index 000000000..2f9ea5868 --- /dev/null +++ b/api/applicationpb/config.pb.go @@ -0,0 +1,404 @@ +// +//Copyright IBM Corp. All Rights Reserved. +// +//SPDX-License-Identifier: Apache-2.0 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v5.29.3 +// source: api/applicationpb/config.proto + +package applicationpb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Represents a namespace policy. +type NamespacePolicy struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Rule: + // + // *NamespacePolicy_ThresholdRule + // *NamespacePolicy_MspRule + Rule isNamespacePolicy_Rule `protobuf_oneof:"rule"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NamespacePolicy) Reset() { + *x = NamespacePolicy{} + mi := &file_api_applicationpb_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamespacePolicy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamespacePolicy) ProtoMessage() {} + +func (x *NamespacePolicy) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_config_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamespacePolicy.ProtoReflect.Descriptor instead. +func (*NamespacePolicy) Descriptor() ([]byte, []int) { + return file_api_applicationpb_config_proto_rawDescGZIP(), []int{0} +} + +func (x *NamespacePolicy) GetRule() isNamespacePolicy_Rule { + if x != nil { + return x.Rule + } + return nil +} + +func (x *NamespacePolicy) GetThresholdRule() *ThresholdRule { + if x != nil { + if x, ok := x.Rule.(*NamespacePolicy_ThresholdRule); ok { + return x.ThresholdRule + } + } + return nil +} + +func (x *NamespacePolicy) GetMspRule() []byte { + if x != nil { + if x, ok := x.Rule.(*NamespacePolicy_MspRule); ok { + return x.MspRule + } + } + return nil +} + +type isNamespacePolicy_Rule interface { + isNamespacePolicy_Rule() +} + +type NamespacePolicy_ThresholdRule struct { + ThresholdRule *ThresholdRule `protobuf:"bytes,1,opt,name=threshold_rule,json=thresholdRule,proto3,oneof"` +} + +type NamespacePolicy_MspRule struct { + MspRule []byte `protobuf:"bytes,2,opt,name=msp_rule,json=mspRule,proto3,oneof"` +} + +func (*NamespacePolicy_ThresholdRule) isNamespacePolicy_Rule() {} + +func (*NamespacePolicy_MspRule) isNamespacePolicy_Rule() {} + +// Represents a threshold signature rule. +type ThresholdRule struct { + state protoimpl.MessageState `protogen:"open.v1"` + Scheme string `protobuf:"bytes,1,opt,name=scheme,proto3" json:"scheme,omitempty"` // The scheme for signature verification. + PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` // The public key for signature verification. + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ThresholdRule) Reset() { + *x = ThresholdRule{} + mi := &file_api_applicationpb_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ThresholdRule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ThresholdRule) ProtoMessage() {} + +func (x *ThresholdRule) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_config_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ThresholdRule.ProtoReflect.Descriptor instead. +func (*ThresholdRule) Descriptor() ([]byte, []int) { + return file_api_applicationpb_config_proto_rawDescGZIP(), []int{1} +} + +func (x *ThresholdRule) GetScheme() string { + if x != nil { + return x.Scheme + } + return "" +} + +func (x *ThresholdRule) GetPublicKey() []byte { + if x != nil { + return x.PublicKey + } + return nil +} + +// A batch of namespace policies. +type NamespacePolicies struct { + state protoimpl.MessageState `protogen:"open.v1"` + Policies []*PolicyItem `protobuf:"bytes,1,rep,name=policies,proto3" json:"policies,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NamespacePolicies) Reset() { + *x = NamespacePolicies{} + mi := &file_api_applicationpb_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamespacePolicies) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamespacePolicies) ProtoMessage() {} + +func (x *NamespacePolicies) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_config_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamespacePolicies.ProtoReflect.Descriptor instead. +func (*NamespacePolicies) Descriptor() ([]byte, []int) { + return file_api_applicationpb_config_proto_rawDescGZIP(), []int{2} +} + +func (x *NamespacePolicies) GetPolicies() []*PolicyItem { + if x != nil { + return x.Policies + } + return nil +} + +// A namespace policy item with the update version. +type PolicyItem struct { + state protoimpl.MessageState `protogen:"open.v1"` + Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` + Policy []byte `protobuf:"bytes,2,opt,name=policy,proto3" json:"policy,omitempty"` + Version uint64 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PolicyItem) Reset() { + *x = PolicyItem{} + mi := &file_api_applicationpb_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PolicyItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PolicyItem) ProtoMessage() {} + +func (x *PolicyItem) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_config_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PolicyItem.ProtoReflect.Descriptor instead. +func (*PolicyItem) Descriptor() ([]byte, []int) { + return file_api_applicationpb_config_proto_rawDescGZIP(), []int{3} +} + +func (x *PolicyItem) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +func (x *PolicyItem) GetPolicy() []byte { + if x != nil { + return x.Policy + } + return nil +} + +func (x *PolicyItem) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +// The config TX envelope with the update version. +type ConfigTransaction struct { + state protoimpl.MessageState `protogen:"open.v1"` + Envelope []byte `protobuf:"bytes,1,opt,name=envelope,proto3" json:"envelope,omitempty"` + Version uint64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ConfigTransaction) Reset() { + *x = ConfigTransaction{} + mi := &file_api_applicationpb_config_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ConfigTransaction) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigTransaction) ProtoMessage() {} + +func (x *ConfigTransaction) ProtoReflect() protoreflect.Message { + mi := &file_api_applicationpb_config_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigTransaction.ProtoReflect.Descriptor instead. +func (*ConfigTransaction) Descriptor() ([]byte, []int) { + return file_api_applicationpb_config_proto_rawDescGZIP(), []int{4} +} + +func (x *ConfigTransaction) GetEnvelope() []byte { + if x != nil { + return x.Envelope + } + return nil +} + +func (x *ConfigTransaction) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +var File_api_applicationpb_config_proto protoreflect.FileDescriptor + +const file_api_applicationpb_config_proto_rawDesc = "" + + "\n" + + "\x1eapi/applicationpb/config.proto\x12\rapplicationpb\"}\n" + + "\x0fNamespacePolicy\x12E\n" + + "\x0ethreshold_rule\x18\x01 \x01(\v2\x1c.applicationpb.ThresholdRuleH\x00R\rthresholdRule\x12\x1b\n" + + "\bmsp_rule\x18\x02 \x01(\fH\x00R\amspRuleB\x06\n" + + "\x04rule\"F\n" + + "\rThresholdRule\x12\x16\n" + + "\x06scheme\x18\x01 \x01(\tR\x06scheme\x12\x1d\n" + + "\n" + + "public_key\x18\x02 \x01(\fR\tpublicKey\"J\n" + + "\x11NamespacePolicies\x125\n" + + "\bpolicies\x18\x01 \x03(\v2\x19.applicationpb.PolicyItemR\bpolicies\"\\\n" + + "\n" + + "PolicyItem\x12\x1c\n" + + "\tnamespace\x18\x01 \x01(\tR\tnamespace\x12\x16\n" + + "\x06policy\x18\x02 \x01(\fR\x06policy\x12\x18\n" + + "\aversion\x18\x03 \x01(\x04R\aversion\"I\n" + + "\x11ConfigTransaction\x12\x1a\n" + + "\benvelope\x18\x01 \x01(\fR\benvelope\x12\x18\n" + + "\aversion\x18\x02 \x01(\x04R\aversionB:Z8github.com/hyperledger/fabric-x-common/api/applicationpbb\x06proto3" + +var ( + file_api_applicationpb_config_proto_rawDescOnce sync.Once + file_api_applicationpb_config_proto_rawDescData []byte +) + +func file_api_applicationpb_config_proto_rawDescGZIP() []byte { + file_api_applicationpb_config_proto_rawDescOnce.Do(func() { + file_api_applicationpb_config_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_applicationpb_config_proto_rawDesc), len(file_api_applicationpb_config_proto_rawDesc))) + }) + return file_api_applicationpb_config_proto_rawDescData +} + +var file_api_applicationpb_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_api_applicationpb_config_proto_goTypes = []any{ + (*NamespacePolicy)(nil), // 0: applicationpb.NamespacePolicy + (*ThresholdRule)(nil), // 1: applicationpb.ThresholdRule + (*NamespacePolicies)(nil), // 2: applicationpb.NamespacePolicies + (*PolicyItem)(nil), // 3: applicationpb.PolicyItem + (*ConfigTransaction)(nil), // 4: applicationpb.ConfigTransaction +} +var file_api_applicationpb_config_proto_depIdxs = []int32{ + 1, // 0: applicationpb.NamespacePolicy.threshold_rule:type_name -> applicationpb.ThresholdRule + 3, // 1: applicationpb.NamespacePolicies.policies:type_name -> applicationpb.PolicyItem + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_api_applicationpb_config_proto_init() } +func file_api_applicationpb_config_proto_init() { + if File_api_applicationpb_config_proto != nil { + return + } + file_api_applicationpb_config_proto_msgTypes[0].OneofWrappers = []any{ + (*NamespacePolicy_ThresholdRule)(nil), + (*NamespacePolicy_MspRule)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_applicationpb_config_proto_rawDesc), len(file_api_applicationpb_config_proto_rawDesc)), + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_api_applicationpb_config_proto_goTypes, + DependencyIndexes: file_api_applicationpb_config_proto_depIdxs, + MessageInfos: file_api_applicationpb_config_proto_msgTypes, + }.Build() + File_api_applicationpb_config_proto = out.File + file_api_applicationpb_config_proto_goTypes = nil + file_api_applicationpb_config_proto_depIdxs = nil +} diff --git a/api/applicationpb/config.proto b/api/applicationpb/config.proto new file mode 100644 index 000000000..03db8fdeb --- /dev/null +++ b/api/applicationpb/config.proto @@ -0,0 +1,43 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +syntax = "proto3"; + +option go_package = "github.com/hyperledger/fabric-x-common/api/applicationpb"; + +package applicationpb; + +// Represents a namespace policy. +message NamespacePolicy { + oneof rule { + ThresholdRule threshold_rule = 1; + bytes msp_rule = 2; + } +} + +// Represents a threshold signature rule. +message ThresholdRule { + string scheme = 1; // The scheme for signature verification. + bytes public_key = 2; // The public key for signature verification. +} + +// A batch of namespace policies. +message NamespacePolicies { + repeated PolicyItem policies = 1; +} + +// A namespace policy item with the update version. +message PolicyItem { + string namespace = 1; + bytes policy = 2; + uint64 version = 3; +} + +// The config TX envelope with the update version. +message ConfigTransaction { + bytes envelope = 1; + uint64 version = 2; +} diff --git a/api/applicationpb/types.go b/api/applicationpb/types.go new file mode 100644 index 000000000..ff412d912 --- /dev/null +++ b/api/applicationpb/types.go @@ -0,0 +1,12 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package applicationpb + +// NewVersion is a convenient method to create a version pointer in a single line. +func NewVersion(version uint64) *uint64 { + return &version +} diff --git a/api/committerpb/notify.pb.go b/api/committerpb/notify.pb.go new file mode 100644 index 000000000..888b3f570 --- /dev/null +++ b/api/committerpb/notify.pb.go @@ -0,0 +1,215 @@ +// +//Copyright IBM Corp. All Rights Reserved. +// +//SPDX-License-Identifier: Apache-2.0 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v5.29.3 +// source: api/committerpb/notify.proto + +package committerpb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + durationpb "google.golang.org/protobuf/types/known/durationpb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// NotificationRequest is sent by the clients to subscribe to events. +type NotificationRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + TxStatusRequest *TxIDsBatch `protobuf:"bytes,1,opt,name=tx_status_request,json=txStatusRequest,proto3,oneof" json:"tx_status_request,omitempty"` + // The timeout duration that applies to ALL the subscriptions in this request. + // It is non-strict, i.e., it is possible to receive notifications for this request + // after the timeout has passed. + // If this field is not set or has a default value (zero), the default would be applied as + // per the committer's configuration. + Timeout *durationpb.Duration `protobuf:"bytes,2,opt,name=timeout,proto3" json:"timeout,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NotificationRequest) Reset() { + *x = NotificationRequest{} + mi := &file_api_committerpb_notify_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NotificationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NotificationRequest) ProtoMessage() {} + +func (x *NotificationRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_notify_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NotificationRequest.ProtoReflect.Descriptor instead. +func (*NotificationRequest) Descriptor() ([]byte, []int) { + return file_api_committerpb_notify_proto_rawDescGZIP(), []int{0} +} + +func (x *NotificationRequest) GetTxStatusRequest() *TxIDsBatch { + if x != nil { + return x.TxStatusRequest + } + return nil +} + +func (x *NotificationRequest) GetTimeout() *durationpb.Duration { + if x != nil { + return x.Timeout + } + return nil +} + +// NotificationResponse contains a batch of event details. +// It is pushed to the client via the stream. +type NotificationResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + TxStatusEvents []*TxStatus `protobuf:"bytes,1,rep,name=tx_status_events,json=txStatusEvents,proto3" json:"tx_status_events,omitempty"` // List of transaction status events. + TimeoutTxIds []string `protobuf:"bytes,2,rep,name=timeout_tx_ids,json=timeoutTxIds,proto3" json:"timeout_tx_ids,omitempty"` // List of timeout events. + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NotificationResponse) Reset() { + *x = NotificationResponse{} + mi := &file_api_committerpb_notify_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NotificationResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NotificationResponse) ProtoMessage() {} + +func (x *NotificationResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_notify_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NotificationResponse.ProtoReflect.Descriptor instead. +func (*NotificationResponse) Descriptor() ([]byte, []int) { + return file_api_committerpb_notify_proto_rawDescGZIP(), []int{1} +} + +func (x *NotificationResponse) GetTxStatusEvents() []*TxStatus { + if x != nil { + return x.TxStatusEvents + } + return nil +} + +func (x *NotificationResponse) GetTimeoutTxIds() []string { + if x != nil { + return x.TimeoutTxIds + } + return nil +} + +var File_api_committerpb_notify_proto protoreflect.FileDescriptor + +const file_api_committerpb_notify_proto_rawDesc = "" + + "\n" + + "\x1capi/committerpb/notify.proto\x12\vcommitterpb\x1a\x1egoogle/protobuf/duration.proto\x1a\x19api/committerpb/ref.proto\x1a\x1capi/committerpb/status.proto\"\xaa\x01\n" + + "\x13NotificationRequest\x12H\n" + + "\x11tx_status_request\x18\x01 \x01(\v2\x17.committerpb.TxIDsBatchH\x00R\x0ftxStatusRequest\x88\x01\x01\x123\n" + + "\atimeout\x18\x02 \x01(\v2\x19.google.protobuf.DurationR\atimeoutB\x14\n" + + "\x12_tx_status_request\"}\n" + + "\x14NotificationResponse\x12?\n" + + "\x10tx_status_events\x18\x01 \x03(\v2\x15.committerpb.TxStatusR\x0etxStatusEvents\x12$\n" + + "\x0etimeout_tx_ids\x18\x02 \x03(\tR\ftimeoutTxIds2m\n" + + "\bNotifier\x12a\n" + + "\x16OpenNotificationStream\x12 .committerpb.NotificationRequest\x1a!.committerpb.NotificationResponse(\x010\x01B8Z6github.com/hyperledger/fabric-x-common/api/committerpbb\x06proto3" + +var ( + file_api_committerpb_notify_proto_rawDescOnce sync.Once + file_api_committerpb_notify_proto_rawDescData []byte +) + +func file_api_committerpb_notify_proto_rawDescGZIP() []byte { + file_api_committerpb_notify_proto_rawDescOnce.Do(func() { + file_api_committerpb_notify_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_committerpb_notify_proto_rawDesc), len(file_api_committerpb_notify_proto_rawDesc))) + }) + return file_api_committerpb_notify_proto_rawDescData +} + +var file_api_committerpb_notify_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_api_committerpb_notify_proto_goTypes = []any{ + (*NotificationRequest)(nil), // 0: committerpb.NotificationRequest + (*NotificationResponse)(nil), // 1: committerpb.NotificationResponse + (*TxIDsBatch)(nil), // 2: committerpb.TxIDsBatch + (*durationpb.Duration)(nil), // 3: google.protobuf.Duration + (*TxStatus)(nil), // 4: committerpb.TxStatus +} +var file_api_committerpb_notify_proto_depIdxs = []int32{ + 2, // 0: committerpb.NotificationRequest.tx_status_request:type_name -> committerpb.TxIDsBatch + 3, // 1: committerpb.NotificationRequest.timeout:type_name -> google.protobuf.Duration + 4, // 2: committerpb.NotificationResponse.tx_status_events:type_name -> committerpb.TxStatus + 0, // 3: committerpb.Notifier.OpenNotificationStream:input_type -> committerpb.NotificationRequest + 1, // 4: committerpb.Notifier.OpenNotificationStream:output_type -> committerpb.NotificationResponse + 4, // [4:5] is the sub-list for method output_type + 3, // [3:4] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_api_committerpb_notify_proto_init() } +func file_api_committerpb_notify_proto_init() { + if File_api_committerpb_notify_proto != nil { + return + } + file_api_committerpb_ref_proto_init() + file_api_committerpb_status_proto_init() + file_api_committerpb_notify_proto_msgTypes[0].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_committerpb_notify_proto_rawDesc), len(file_api_committerpb_notify_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_api_committerpb_notify_proto_goTypes, + DependencyIndexes: file_api_committerpb_notify_proto_depIdxs, + MessageInfos: file_api_committerpb_notify_proto_msgTypes, + }.Build() + File_api_committerpb_notify_proto = out.File + file_api_committerpb_notify_proto_goTypes = nil + file_api_committerpb_notify_proto_depIdxs = nil +} diff --git a/api/committerpb/notify.proto b/api/committerpb/notify.proto new file mode 100644 index 000000000..292e343c5 --- /dev/null +++ b/api/committerpb/notify.proto @@ -0,0 +1,40 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +syntax = "proto3"; + +option go_package = "github.com/hyperledger/fabric-x-common/api/committerpb"; + +package committerpb; + +import "google/protobuf/duration.proto"; + +import "api/committerpb/ref.proto"; +import "api/committerpb/status.proto"; + +// The notifier service provides API to subscribe to ledger events and receive asynchronous notifications. +service Notifier { + rpc OpenNotificationStream (stream NotificationRequest) returns (stream NotificationResponse); +} + +// NotificationRequest is sent by the clients to subscribe to events. +message NotificationRequest { + optional TxIDsBatch tx_status_request = 1; + + // The timeout duration that applies to ALL the subscriptions in this request. + // It is non-strict, i.e., it is possible to receive notifications for this request + // after the timeout has passed. + // If this field is not set or has a default value (zero), the default would be applied as + // per the committer's configuration. + google.protobuf.Duration timeout = 2; +} + +// NotificationResponse contains a batch of event details. +// It is pushed to the client via the stream. +message NotificationResponse { + repeated TxStatus tx_status_events = 1; // List of transaction status events. + repeated string timeout_tx_ids = 2; // List of timeout events. +} diff --git a/api/committerpb/notify_grpc.pb.go b/api/committerpb/notify_grpc.pb.go new file mode 100644 index 000000000..ab9dcf052 --- /dev/null +++ b/api/committerpb/notify_grpc.pb.go @@ -0,0 +1,146 @@ +// +//Copyright IBM Corp. All Rights Reserved. +// +//SPDX-License-Identifier: Apache-2.0 + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v5.29.3 +// source: api/committerpb/notify.proto + +package committerpb + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Notifier_OpenNotificationStream_FullMethodName = "/committerpb.Notifier/OpenNotificationStream" +) + +// NotifierClient is the client API for Notifier service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type NotifierClient interface { + OpenNotificationStream(ctx context.Context, opts ...grpc.CallOption) (Notifier_OpenNotificationStreamClient, error) +} + +type notifierClient struct { + cc grpc.ClientConnInterface +} + +func NewNotifierClient(cc grpc.ClientConnInterface) NotifierClient { + return ¬ifierClient{cc} +} + +func (c *notifierClient) OpenNotificationStream(ctx context.Context, opts ...grpc.CallOption) (Notifier_OpenNotificationStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &Notifier_ServiceDesc.Streams[0], Notifier_OpenNotificationStream_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := ¬ifierOpenNotificationStreamClient{stream} + return x, nil +} + +type Notifier_OpenNotificationStreamClient interface { + Send(*NotificationRequest) error + Recv() (*NotificationResponse, error) + grpc.ClientStream +} + +type notifierOpenNotificationStreamClient struct { + grpc.ClientStream +} + +func (x *notifierOpenNotificationStreamClient) Send(m *NotificationRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *notifierOpenNotificationStreamClient) Recv() (*NotificationResponse, error) { + m := new(NotificationResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// NotifierServer is the server API for Notifier service. +// All implementations must embed UnimplementedNotifierServer +// for forward compatibility +type NotifierServer interface { + OpenNotificationStream(Notifier_OpenNotificationStreamServer) error + mustEmbedUnimplementedNotifierServer() +} + +// UnimplementedNotifierServer must be embedded to have forward compatible implementations. +type UnimplementedNotifierServer struct { +} + +func (UnimplementedNotifierServer) OpenNotificationStream(Notifier_OpenNotificationStreamServer) error { + return status.Errorf(codes.Unimplemented, "method OpenNotificationStream not implemented") +} +func (UnimplementedNotifierServer) mustEmbedUnimplementedNotifierServer() {} + +// UnsafeNotifierServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to NotifierServer will +// result in compilation errors. +type UnsafeNotifierServer interface { + mustEmbedUnimplementedNotifierServer() +} + +func RegisterNotifierServer(s grpc.ServiceRegistrar, srv NotifierServer) { + s.RegisterService(&Notifier_ServiceDesc, srv) +} + +func _Notifier_OpenNotificationStream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(NotifierServer).OpenNotificationStream(¬ifierOpenNotificationStreamServer{stream}) +} + +type Notifier_OpenNotificationStreamServer interface { + Send(*NotificationResponse) error + Recv() (*NotificationRequest, error) + grpc.ServerStream +} + +type notifierOpenNotificationStreamServer struct { + grpc.ServerStream +} + +func (x *notifierOpenNotificationStreamServer) Send(m *NotificationResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *notifierOpenNotificationStreamServer) Recv() (*NotificationRequest, error) { + m := new(NotificationRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Notifier_ServiceDesc is the grpc.ServiceDesc for Notifier service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Notifier_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "committerpb.Notifier", + HandlerType: (*NotifierServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "OpenNotificationStream", + Handler: _Notifier_OpenNotificationStream_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "api/committerpb/notify.proto", +} diff --git a/api/committerpb/query.pb.go b/api/committerpb/query.pb.go new file mode 100644 index 000000000..a9cc3d18b --- /dev/null +++ b/api/committerpb/query.pb.go @@ -0,0 +1,680 @@ +// +//Copyright IBM Corp. All Rights Reserved. +// +//SPDX-License-Identifier: Apache-2.0 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v5.29.3 +// source: api/committerpb/query.proto + +package committerpb + +import ( + applicationpb "github.com/hyperledger/fabric-x-common/api/applicationpb" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type IsoLevel int32 + +const ( + IsoLevel_ISO_LEVEL_UNSPECIFIED IsoLevel = 0 // Unspecified level will default to serializable. + IsoLevel_SERIALIZABLE IsoLevel = 1 + IsoLevel_REPEATABLE_READ IsoLevel = 2 + IsoLevel_READ_COMMITTED IsoLevel = 3 + IsoLevel_READ_UNCOMMITTED IsoLevel = 4 +) + +// Enum value maps for IsoLevel. +var ( + IsoLevel_name = map[int32]string{ + 0: "ISO_LEVEL_UNSPECIFIED", + 1: "SERIALIZABLE", + 2: "REPEATABLE_READ", + 3: "READ_COMMITTED", + 4: "READ_UNCOMMITTED", + } + IsoLevel_value = map[string]int32{ + "ISO_LEVEL_UNSPECIFIED": 0, + "SERIALIZABLE": 1, + "REPEATABLE_READ": 2, + "READ_COMMITTED": 3, + "READ_UNCOMMITTED": 4, + } +) + +func (x IsoLevel) Enum() *IsoLevel { + p := new(IsoLevel) + *p = x + return p +} + +func (x IsoLevel) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (IsoLevel) Descriptor() protoreflect.EnumDescriptor { + return file_api_committerpb_query_proto_enumTypes[0].Descriptor() +} + +func (IsoLevel) Type() protoreflect.EnumType { + return &file_api_committerpb_query_proto_enumTypes[0] +} + +func (x IsoLevel) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use IsoLevel.Descriptor instead. +func (IsoLevel) EnumDescriptor() ([]byte, []int) { + return file_api_committerpb_query_proto_rawDescGZIP(), []int{0} +} + +type View struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *View) Reset() { + *x = View{} + mi := &file_api_committerpb_query_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *View) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*View) ProtoMessage() {} + +func (x *View) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_query_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use View.ProtoReflect.Descriptor instead. +func (*View) Descriptor() ([]byte, []int) { + return file_api_committerpb_query_proto_rawDescGZIP(), []int{0} +} + +func (x *View) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type Query struct { + state protoimpl.MessageState `protogen:"open.v1"` + View *View `protobuf:"bytes,1,opt,name=view,proto3,oneof" json:"view,omitempty"` + Namespaces []*QueryNamespace `protobuf:"bytes,2,rep,name=namespaces,proto3" json:"namespaces,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Query) Reset() { + *x = Query{} + mi := &file_api_committerpb_query_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Query) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Query) ProtoMessage() {} + +func (x *Query) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_query_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Query.ProtoReflect.Descriptor instead. +func (*Query) Descriptor() ([]byte, []int) { + return file_api_committerpb_query_proto_rawDescGZIP(), []int{1} +} + +func (x *Query) GetView() *View { + if x != nil { + return x.View + } + return nil +} + +func (x *Query) GetNamespaces() []*QueryNamespace { + if x != nil { + return x.Namespaces + } + return nil +} + +type Rows struct { + state protoimpl.MessageState `protogen:"open.v1"` + Namespaces []*RowsNamespace `protobuf:"bytes,1,rep,name=namespaces,proto3" json:"namespaces,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Rows) Reset() { + *x = Rows{} + mi := &file_api_committerpb_query_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Rows) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Rows) ProtoMessage() {} + +func (x *Rows) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_query_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Rows.ProtoReflect.Descriptor instead. +func (*Rows) Descriptor() ([]byte, []int) { + return file_api_committerpb_query_proto_rawDescGZIP(), []int{2} +} + +func (x *Rows) GetNamespaces() []*RowsNamespace { + if x != nil { + return x.Namespaces + } + return nil +} + +type ViewParameters struct { + state protoimpl.MessageState `protogen:"open.v1"` + IsoLevel IsoLevel `protobuf:"varint,1,opt,name=iso_level,json=isoLevel,proto3,enum=committerpb.IsoLevel" json:"iso_level,omitempty"` // View's isolation level. Defaults to serializable. + NonDeferrable bool `protobuf:"varint,2,opt,name=non_deferrable,json=nonDeferrable,proto3" json:"non_deferrable,omitempty"` // Do not defer errors. Defaults deferrable. + TimeoutMilliseconds uint64 `protobuf:"varint,3,opt,name=timeout_milliseconds,json=timeoutMilliseconds,proto3" json:"timeout_milliseconds,omitempty"` // View's timeout. Zero => maximal value + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ViewParameters) Reset() { + *x = ViewParameters{} + mi := &file_api_committerpb_query_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ViewParameters) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ViewParameters) ProtoMessage() {} + +func (x *ViewParameters) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_query_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ViewParameters.ProtoReflect.Descriptor instead. +func (*ViewParameters) Descriptor() ([]byte, []int) { + return file_api_committerpb_query_proto_rawDescGZIP(), []int{3} +} + +func (x *ViewParameters) GetIsoLevel() IsoLevel { + if x != nil { + return x.IsoLevel + } + return IsoLevel_ISO_LEVEL_UNSPECIFIED +} + +func (x *ViewParameters) GetNonDeferrable() bool { + if x != nil { + return x.NonDeferrable + } + return false +} + +func (x *ViewParameters) GetTimeoutMilliseconds() uint64 { + if x != nil { + return x.TimeoutMilliseconds + } + return 0 +} + +type QueryNamespace struct { + state protoimpl.MessageState `protogen:"open.v1"` + NsId string `protobuf:"bytes,1,opt,name=ns_id,json=nsId,proto3" json:"ns_id,omitempty"` + Keys [][]byte `protobuf:"bytes,2,rep,name=keys,proto3" json:"keys,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *QueryNamespace) Reset() { + *x = QueryNamespace{} + mi := &file_api_committerpb_query_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *QueryNamespace) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryNamespace) ProtoMessage() {} + +func (x *QueryNamespace) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_query_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use QueryNamespace.ProtoReflect.Descriptor instead. +func (*QueryNamespace) Descriptor() ([]byte, []int) { + return file_api_committerpb_query_proto_rawDescGZIP(), []int{4} +} + +func (x *QueryNamespace) GetNsId() string { + if x != nil { + return x.NsId + } + return "" +} + +func (x *QueryNamespace) GetKeys() [][]byte { + if x != nil { + return x.Keys + } + return nil +} + +type RowsNamespace struct { + state protoimpl.MessageState `protogen:"open.v1"` + NsId string `protobuf:"bytes,1,opt,name=ns_id,json=nsId,proto3" json:"ns_id,omitempty"` + Rows []*Row `protobuf:"bytes,2,rep,name=rows,proto3" json:"rows,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RowsNamespace) Reset() { + *x = RowsNamespace{} + mi := &file_api_committerpb_query_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RowsNamespace) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RowsNamespace) ProtoMessage() {} + +func (x *RowsNamespace) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_query_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RowsNamespace.ProtoReflect.Descriptor instead. +func (*RowsNamespace) Descriptor() ([]byte, []int) { + return file_api_committerpb_query_proto_rawDescGZIP(), []int{5} +} + +func (x *RowsNamespace) GetNsId() string { + if x != nil { + return x.NsId + } + return "" +} + +func (x *RowsNamespace) GetRows() []*Row { + if x != nil { + return x.Rows + } + return nil +} + +type Row struct { + state protoimpl.MessageState `protogen:"open.v1"` + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Version uint64 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Row) Reset() { + *x = Row{} + mi := &file_api_committerpb_query_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Row) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Row) ProtoMessage() {} + +func (x *Row) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_query_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Row.ProtoReflect.Descriptor instead. +func (*Row) Descriptor() ([]byte, []int) { + return file_api_committerpb_query_proto_rawDescGZIP(), []int{6} +} + +func (x *Row) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *Row) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + +func (x *Row) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +type TxStatusQuery struct { + state protoimpl.MessageState `protogen:"open.v1"` + View *View `protobuf:"bytes,1,opt,name=view,proto3,oneof" json:"view,omitempty"` + TxIds []string `protobuf:"bytes,2,rep,name=tx_ids,json=txIds,proto3" json:"tx_ids,omitempty"` // List of transaction IDs. + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TxStatusQuery) Reset() { + *x = TxStatusQuery{} + mi := &file_api_committerpb_query_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TxStatusQuery) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TxStatusQuery) ProtoMessage() {} + +func (x *TxStatusQuery) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_query_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TxStatusQuery.ProtoReflect.Descriptor instead. +func (*TxStatusQuery) Descriptor() ([]byte, []int) { + return file_api_committerpb_query_proto_rawDescGZIP(), []int{7} +} + +func (x *TxStatusQuery) GetView() *View { + if x != nil { + return x.View + } + return nil +} + +func (x *TxStatusQuery) GetTxIds() []string { + if x != nil { + return x.TxIds + } + return nil +} + +type TxStatusResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Statuses []*TxStatus `protobuf:"bytes,1,rep,name=statuses,proto3" json:"statuses,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TxStatusResponse) Reset() { + *x = TxStatusResponse{} + mi := &file_api_committerpb_query_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TxStatusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TxStatusResponse) ProtoMessage() {} + +func (x *TxStatusResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_query_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TxStatusResponse.ProtoReflect.Descriptor instead. +func (*TxStatusResponse) Descriptor() ([]byte, []int) { + return file_api_committerpb_query_proto_rawDescGZIP(), []int{8} +} + +func (x *TxStatusResponse) GetStatuses() []*TxStatus { + if x != nil { + return x.Statuses + } + return nil +} + +var File_api_committerpb_query_proto protoreflect.FileDescriptor + +const file_api_committerpb_query_proto_rawDesc = "" + + "\n" + + "\x1bapi/committerpb/query.proto\x12\vcommitterpb\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1eapi/applicationpb/config.proto\x1a\x1capi/committerpb/status.proto\"\x16\n" + + "\x04View\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\"y\n" + + "\x05Query\x12*\n" + + "\x04view\x18\x01 \x01(\v2\x11.committerpb.ViewH\x00R\x04view\x88\x01\x01\x12;\n" + + "\n" + + "namespaces\x18\x02 \x03(\v2\x1b.committerpb.QueryNamespaceR\n" + + "namespacesB\a\n" + + "\x05_view\"B\n" + + "\x04Rows\x12:\n" + + "\n" + + "namespaces\x18\x01 \x03(\v2\x1a.committerpb.RowsNamespaceR\n" + + "namespaces\"\x9e\x01\n" + + "\x0eViewParameters\x122\n" + + "\tiso_level\x18\x01 \x01(\x0e2\x15.committerpb.IsoLevelR\bisoLevel\x12%\n" + + "\x0enon_deferrable\x18\x02 \x01(\bR\rnonDeferrable\x121\n" + + "\x14timeout_milliseconds\x18\x03 \x01(\x04R\x13timeoutMilliseconds\"9\n" + + "\x0eQueryNamespace\x12\x13\n" + + "\x05ns_id\x18\x01 \x01(\tR\x04nsId\x12\x12\n" + + "\x04keys\x18\x02 \x03(\fR\x04keys\"J\n" + + "\rRowsNamespace\x12\x13\n" + + "\x05ns_id\x18\x01 \x01(\tR\x04nsId\x12$\n" + + "\x04rows\x18\x02 \x03(\v2\x10.committerpb.RowR\x04rows\"G\n" + + "\x03Row\x12\x10\n" + + "\x03key\x18\x01 \x01(\fR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\fR\x05value\x12\x18\n" + + "\aversion\x18\x03 \x01(\x04R\aversion\"[\n" + + "\rTxStatusQuery\x12*\n" + + "\x04view\x18\x01 \x01(\v2\x11.committerpb.ViewH\x00R\x04view\x88\x01\x01\x12\x15\n" + + "\x06tx_ids\x18\x02 \x03(\tR\x05txIdsB\a\n" + + "\x05_view\"E\n" + + "\x10TxStatusResponse\x121\n" + + "\bstatuses\x18\x01 \x03(\v2\x15.committerpb.TxStatusR\bstatuses*v\n" + + "\bIsoLevel\x12\x19\n" + + "\x15ISO_LEVEL_UNSPECIFIED\x10\x00\x12\x10\n" + + "\fSERIALIZABLE\x10\x01\x12\x13\n" + + "\x0fREPEATABLE_READ\x10\x02\x12\x12\n" + + "\x0eREAD_COMMITTED\x10\x03\x12\x14\n" + + "\x10READ_UNCOMMITTED\x10\x042\xb6\x03\n" + + "\fQueryService\x122\n" + + "\aGetRows\x12\x12.committerpb.Query\x1a\x11.committerpb.Rows\"\x00\x12=\n" + + "\tBeginView\x12\x1b.committerpb.ViewParameters\x1a\x11.committerpb.View\"\x00\x126\n" + + "\aEndView\x12\x11.committerpb.View\x1a\x16.google.protobuf.Empty\"\x00\x12R\n" + + "\x14GetNamespacePolicies\x12\x16.google.protobuf.Empty\x1a .applicationpb.NamespacePolicies\"\x00\x12R\n" + + "\x14GetConfigTransaction\x12\x16.google.protobuf.Empty\x1a .applicationpb.ConfigTransaction\"\x00\x12S\n" + + "\x14GetTransactionStatus\x12\x1a.committerpb.TxStatusQuery\x1a\x1d.committerpb.TxStatusResponse\"\x00B8Z6github.com/hyperledger/fabric-x-common/api/committerpbb\x06proto3" + +var ( + file_api_committerpb_query_proto_rawDescOnce sync.Once + file_api_committerpb_query_proto_rawDescData []byte +) + +func file_api_committerpb_query_proto_rawDescGZIP() []byte { + file_api_committerpb_query_proto_rawDescOnce.Do(func() { + file_api_committerpb_query_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_committerpb_query_proto_rawDesc), len(file_api_committerpb_query_proto_rawDesc))) + }) + return file_api_committerpb_query_proto_rawDescData +} + +var file_api_committerpb_query_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_api_committerpb_query_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_api_committerpb_query_proto_goTypes = []any{ + (IsoLevel)(0), // 0: committerpb.IsoLevel + (*View)(nil), // 1: committerpb.View + (*Query)(nil), // 2: committerpb.Query + (*Rows)(nil), // 3: committerpb.Rows + (*ViewParameters)(nil), // 4: committerpb.ViewParameters + (*QueryNamespace)(nil), // 5: committerpb.QueryNamespace + (*RowsNamespace)(nil), // 6: committerpb.RowsNamespace + (*Row)(nil), // 7: committerpb.Row + (*TxStatusQuery)(nil), // 8: committerpb.TxStatusQuery + (*TxStatusResponse)(nil), // 9: committerpb.TxStatusResponse + (*TxStatus)(nil), // 10: committerpb.TxStatus + (*emptypb.Empty)(nil), // 11: google.protobuf.Empty + (*applicationpb.NamespacePolicies)(nil), // 12: applicationpb.NamespacePolicies + (*applicationpb.ConfigTransaction)(nil), // 13: applicationpb.ConfigTransaction +} +var file_api_committerpb_query_proto_depIdxs = []int32{ + 1, // 0: committerpb.Query.view:type_name -> committerpb.View + 5, // 1: committerpb.Query.namespaces:type_name -> committerpb.QueryNamespace + 6, // 2: committerpb.Rows.namespaces:type_name -> committerpb.RowsNamespace + 0, // 3: committerpb.ViewParameters.iso_level:type_name -> committerpb.IsoLevel + 7, // 4: committerpb.RowsNamespace.rows:type_name -> committerpb.Row + 1, // 5: committerpb.TxStatusQuery.view:type_name -> committerpb.View + 10, // 6: committerpb.TxStatusResponse.statuses:type_name -> committerpb.TxStatus + 2, // 7: committerpb.QueryService.GetRows:input_type -> committerpb.Query + 4, // 8: committerpb.QueryService.BeginView:input_type -> committerpb.ViewParameters + 1, // 9: committerpb.QueryService.EndView:input_type -> committerpb.View + 11, // 10: committerpb.QueryService.GetNamespacePolicies:input_type -> google.protobuf.Empty + 11, // 11: committerpb.QueryService.GetConfigTransaction:input_type -> google.protobuf.Empty + 8, // 12: committerpb.QueryService.GetTransactionStatus:input_type -> committerpb.TxStatusQuery + 3, // 13: committerpb.QueryService.GetRows:output_type -> committerpb.Rows + 1, // 14: committerpb.QueryService.BeginView:output_type -> committerpb.View + 11, // 15: committerpb.QueryService.EndView:output_type -> google.protobuf.Empty + 12, // 16: committerpb.QueryService.GetNamespacePolicies:output_type -> applicationpb.NamespacePolicies + 13, // 17: committerpb.QueryService.GetConfigTransaction:output_type -> applicationpb.ConfigTransaction + 9, // 18: committerpb.QueryService.GetTransactionStatus:output_type -> committerpb.TxStatusResponse + 13, // [13:19] is the sub-list for method output_type + 7, // [7:13] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_api_committerpb_query_proto_init() } +func file_api_committerpb_query_proto_init() { + if File_api_committerpb_query_proto != nil { + return + } + file_api_committerpb_status_proto_init() + file_api_committerpb_query_proto_msgTypes[1].OneofWrappers = []any{} + file_api_committerpb_query_proto_msgTypes[7].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_committerpb_query_proto_rawDesc), len(file_api_committerpb_query_proto_rawDesc)), + NumEnums: 1, + NumMessages: 9, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_api_committerpb_query_proto_goTypes, + DependencyIndexes: file_api_committerpb_query_proto_depIdxs, + EnumInfos: file_api_committerpb_query_proto_enumTypes, + MessageInfos: file_api_committerpb_query_proto_msgTypes, + }.Build() + File_api_committerpb_query_proto = out.File + file_api_committerpb_query_proto_goTypes = nil + file_api_committerpb_query_proto_depIdxs = nil +} diff --git a/api/committerpb/query.proto b/api/committerpb/query.proto new file mode 100644 index 000000000..0b6807962 --- /dev/null +++ b/api/committerpb/query.proto @@ -0,0 +1,78 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +syntax = "proto3"; + +option go_package = "github.com/hyperledger/fabric-x-common/api/committerpb"; + +package committerpb; + +import "google/protobuf/empty.proto"; + +import "api/applicationpb/config.proto"; + +import "api/committerpb/status.proto"; + +service QueryService { + rpc GetRows(Query) returns (Rows) {}; + rpc BeginView(ViewParameters) returns (View) {}; + rpc EndView(View) returns (google.protobuf.Empty) {}; + rpc GetNamespacePolicies(google.protobuf.Empty) returns (applicationpb.NamespacePolicies) {}; + rpc GetConfigTransaction(google.protobuf.Empty) returns (applicationpb.ConfigTransaction) {}; + rpc GetTransactionStatus(TxStatusQuery) returns (TxStatusResponse) {}; +} + +message View { + string id = 1; +} + +message Query { + optional View view = 1; + repeated QueryNamespace namespaces = 2; +} + +message Rows { + repeated RowsNamespace namespaces = 1; +} + +message ViewParameters { + IsoLevel iso_level = 1; // View's isolation level. Defaults to serializable. + bool non_deferrable = 2; // Do not defer errors. Defaults deferrable. + uint64 timeout_milliseconds = 3; // View's timeout. Zero => maximal value +} + +message QueryNamespace { + string ns_id = 1; + repeated bytes keys = 2; +} + +message RowsNamespace { + string ns_id = 1; + repeated Row rows = 2; +} + +message Row { + bytes key = 1; + bytes value = 2; + uint64 version = 3; +} + +message TxStatusQuery { + optional View view = 1; + repeated string tx_ids = 2; // List of transaction IDs. +} + +message TxStatusResponse { + repeated TxStatus statuses = 1; +} + +enum IsoLevel { + ISO_LEVEL_UNSPECIFIED = 0; // Unspecified level will default to serializable. + SERIALIZABLE = 1; + REPEATABLE_READ = 2; + READ_COMMITTED = 3; + READ_UNCOMMITTED = 4; +} diff --git a/api/committerpb/query_grpc.pb.go b/api/committerpb/query_grpc.pb.go new file mode 100644 index 000000000..ec03d66a3 --- /dev/null +++ b/api/committerpb/query_grpc.pb.go @@ -0,0 +1,301 @@ +// +//Copyright IBM Corp. All Rights Reserved. +// +//SPDX-License-Identifier: Apache-2.0 + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v5.29.3 +// source: api/committerpb/query.proto + +package committerpb + +import ( + context "context" + applicationpb "github.com/hyperledger/fabric-x-common/api/applicationpb" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + QueryService_GetRows_FullMethodName = "/committerpb.QueryService/GetRows" + QueryService_BeginView_FullMethodName = "/committerpb.QueryService/BeginView" + QueryService_EndView_FullMethodName = "/committerpb.QueryService/EndView" + QueryService_GetNamespacePolicies_FullMethodName = "/committerpb.QueryService/GetNamespacePolicies" + QueryService_GetConfigTransaction_FullMethodName = "/committerpb.QueryService/GetConfigTransaction" + QueryService_GetTransactionStatus_FullMethodName = "/committerpb.QueryService/GetTransactionStatus" +) + +// QueryServiceClient is the client API for QueryService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type QueryServiceClient interface { + GetRows(ctx context.Context, in *Query, opts ...grpc.CallOption) (*Rows, error) + BeginView(ctx context.Context, in *ViewParameters, opts ...grpc.CallOption) (*View, error) + EndView(ctx context.Context, in *View, opts ...grpc.CallOption) (*emptypb.Empty, error) + GetNamespacePolicies(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*applicationpb.NamespacePolicies, error) + GetConfigTransaction(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*applicationpb.ConfigTransaction, error) + GetTransactionStatus(ctx context.Context, in *TxStatusQuery, opts ...grpc.CallOption) (*TxStatusResponse, error) +} + +type queryServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewQueryServiceClient(cc grpc.ClientConnInterface) QueryServiceClient { + return &queryServiceClient{cc} +} + +func (c *queryServiceClient) GetRows(ctx context.Context, in *Query, opts ...grpc.CallOption) (*Rows, error) { + out := new(Rows) + err := c.cc.Invoke(ctx, QueryService_GetRows_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryServiceClient) BeginView(ctx context.Context, in *ViewParameters, opts ...grpc.CallOption) (*View, error) { + out := new(View) + err := c.cc.Invoke(ctx, QueryService_BeginView_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryServiceClient) EndView(ctx context.Context, in *View, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, QueryService_EndView_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryServiceClient) GetNamespacePolicies(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*applicationpb.NamespacePolicies, error) { + out := new(applicationpb.NamespacePolicies) + err := c.cc.Invoke(ctx, QueryService_GetNamespacePolicies_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryServiceClient) GetConfigTransaction(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*applicationpb.ConfigTransaction, error) { + out := new(applicationpb.ConfigTransaction) + err := c.cc.Invoke(ctx, QueryService_GetConfigTransaction_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryServiceClient) GetTransactionStatus(ctx context.Context, in *TxStatusQuery, opts ...grpc.CallOption) (*TxStatusResponse, error) { + out := new(TxStatusResponse) + err := c.cc.Invoke(ctx, QueryService_GetTransactionStatus_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServiceServer is the server API for QueryService service. +// All implementations must embed UnimplementedQueryServiceServer +// for forward compatibility +type QueryServiceServer interface { + GetRows(context.Context, *Query) (*Rows, error) + BeginView(context.Context, *ViewParameters) (*View, error) + EndView(context.Context, *View) (*emptypb.Empty, error) + GetNamespacePolicies(context.Context, *emptypb.Empty) (*applicationpb.NamespacePolicies, error) + GetConfigTransaction(context.Context, *emptypb.Empty) (*applicationpb.ConfigTransaction, error) + GetTransactionStatus(context.Context, *TxStatusQuery) (*TxStatusResponse, error) + mustEmbedUnimplementedQueryServiceServer() +} + +// UnimplementedQueryServiceServer must be embedded to have forward compatible implementations. +type UnimplementedQueryServiceServer struct { +} + +func (UnimplementedQueryServiceServer) GetRows(context.Context, *Query) (*Rows, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRows not implemented") +} +func (UnimplementedQueryServiceServer) BeginView(context.Context, *ViewParameters) (*View, error) { + return nil, status.Errorf(codes.Unimplemented, "method BeginView not implemented") +} +func (UnimplementedQueryServiceServer) EndView(context.Context, *View) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method EndView not implemented") +} +func (UnimplementedQueryServiceServer) GetNamespacePolicies(context.Context, *emptypb.Empty) (*applicationpb.NamespacePolicies, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetNamespacePolicies not implemented") +} +func (UnimplementedQueryServiceServer) GetConfigTransaction(context.Context, *emptypb.Empty) (*applicationpb.ConfigTransaction, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetConfigTransaction not implemented") +} +func (UnimplementedQueryServiceServer) GetTransactionStatus(context.Context, *TxStatusQuery) (*TxStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTransactionStatus not implemented") +} +func (UnimplementedQueryServiceServer) mustEmbedUnimplementedQueryServiceServer() {} + +// UnsafeQueryServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to QueryServiceServer will +// result in compilation errors. +type UnsafeQueryServiceServer interface { + mustEmbedUnimplementedQueryServiceServer() +} + +func RegisterQueryServiceServer(s grpc.ServiceRegistrar, srv QueryServiceServer) { + s.RegisterService(&QueryService_ServiceDesc, srv) +} + +func _QueryService_GetRows_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Query) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServiceServer).GetRows(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: QueryService_GetRows_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServiceServer).GetRows(ctx, req.(*Query)) + } + return interceptor(ctx, in, info, handler) +} + +func _QueryService_BeginView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ViewParameters) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServiceServer).BeginView(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: QueryService_BeginView_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServiceServer).BeginView(ctx, req.(*ViewParameters)) + } + return interceptor(ctx, in, info, handler) +} + +func _QueryService_EndView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(View) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServiceServer).EndView(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: QueryService_EndView_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServiceServer).EndView(ctx, req.(*View)) + } + return interceptor(ctx, in, info, handler) +} + +func _QueryService_GetNamespacePolicies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(emptypb.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServiceServer).GetNamespacePolicies(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: QueryService_GetNamespacePolicies_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServiceServer).GetNamespacePolicies(ctx, req.(*emptypb.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _QueryService_GetConfigTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(emptypb.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServiceServer).GetConfigTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: QueryService_GetConfigTransaction_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServiceServer).GetConfigTransaction(ctx, req.(*emptypb.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _QueryService_GetTransactionStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TxStatusQuery) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServiceServer).GetTransactionStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: QueryService_GetTransactionStatus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServiceServer).GetTransactionStatus(ctx, req.(*TxStatusQuery)) + } + return interceptor(ctx, in, info, handler) +} + +// QueryService_ServiceDesc is the grpc.ServiceDesc for QueryService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var QueryService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "committerpb.QueryService", + HandlerType: (*QueryServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetRows", + Handler: _QueryService_GetRows_Handler, + }, + { + MethodName: "BeginView", + Handler: _QueryService_BeginView_Handler, + }, + { + MethodName: "EndView", + Handler: _QueryService_EndView_Handler, + }, + { + MethodName: "GetNamespacePolicies", + Handler: _QueryService_GetNamespacePolicies_Handler, + }, + { + MethodName: "GetConfigTransaction", + Handler: _QueryService_GetConfigTransaction_Handler, + }, + { + MethodName: "GetTransactionStatus", + Handler: _QueryService_GetTransactionStatus_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "api/committerpb/query.proto", +} diff --git a/api/committerpb/ref.pb.go b/api/committerpb/ref.pb.go new file mode 100644 index 000000000..2c534d3ba --- /dev/null +++ b/api/committerpb/ref.pb.go @@ -0,0 +1,195 @@ +// +//Copyright IBM Corp. All Rights Reserved. +// +//SPDX-License-Identifier: Apache-2.0 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v5.29.3 +// source: api/committerpb/ref.proto + +package committerpb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// The TX reference with respect to the block generated by the orderer. +type TxRef struct { + state protoimpl.MessageState `protogen:"open.v1"` + BlockNum uint64 `protobuf:"varint,1,opt,name=block_num,json=blockNum,proto3" json:"block_num,omitempty"` // The block number. + TxNum uint32 `protobuf:"varint,2,opt,name=tx_num,json=txNum,proto3" json:"tx_num,omitempty"` // Transaction number within the block + TxId string `protobuf:"bytes,3,opt,name=tx_id,json=txId,proto3" json:"tx_id,omitempty"` // Transaction ID within the block. + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TxRef) Reset() { + *x = TxRef{} + mi := &file_api_committerpb_ref_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TxRef) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TxRef) ProtoMessage() {} + +func (x *TxRef) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_ref_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TxRef.ProtoReflect.Descriptor instead. +func (*TxRef) Descriptor() ([]byte, []int) { + return file_api_committerpb_ref_proto_rawDescGZIP(), []int{0} +} + +func (x *TxRef) GetBlockNum() uint64 { + if x != nil { + return x.BlockNum + } + return 0 +} + +func (x *TxRef) GetTxNum() uint32 { + if x != nil { + return x.TxNum + } + return 0 +} + +func (x *TxRef) GetTxId() string { + if x != nil { + return x.TxId + } + return "" +} + +// A batch of TX IDs. +type TxIDsBatch struct { + state protoimpl.MessageState `protogen:"open.v1"` + TxIds []string `protobuf:"bytes,1,rep,name=tx_ids,json=txIds,proto3" json:"tx_ids,omitempty"` // List of transaction IDs. + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TxIDsBatch) Reset() { + *x = TxIDsBatch{} + mi := &file_api_committerpb_ref_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TxIDsBatch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TxIDsBatch) ProtoMessage() {} + +func (x *TxIDsBatch) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_ref_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TxIDsBatch.ProtoReflect.Descriptor instead. +func (*TxIDsBatch) Descriptor() ([]byte, []int) { + return file_api_committerpb_ref_proto_rawDescGZIP(), []int{1} +} + +func (x *TxIDsBatch) GetTxIds() []string { + if x != nil { + return x.TxIds + } + return nil +} + +var File_api_committerpb_ref_proto protoreflect.FileDescriptor + +const file_api_committerpb_ref_proto_rawDesc = "" + + "\n" + + "\x19api/committerpb/ref.proto\x12\vcommitterpb\"P\n" + + "\x05TxRef\x12\x1b\n" + + "\tblock_num\x18\x01 \x01(\x04R\bblockNum\x12\x15\n" + + "\x06tx_num\x18\x02 \x01(\rR\x05txNum\x12\x13\n" + + "\x05tx_id\x18\x03 \x01(\tR\x04txId\"#\n" + + "\n" + + "TxIDsBatch\x12\x15\n" + + "\x06tx_ids\x18\x01 \x03(\tR\x05txIdsB8Z6github.com/hyperledger/fabric-x-common/api/committerpbb\x06proto3" + +var ( + file_api_committerpb_ref_proto_rawDescOnce sync.Once + file_api_committerpb_ref_proto_rawDescData []byte +) + +func file_api_committerpb_ref_proto_rawDescGZIP() []byte { + file_api_committerpb_ref_proto_rawDescOnce.Do(func() { + file_api_committerpb_ref_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_committerpb_ref_proto_rawDesc), len(file_api_committerpb_ref_proto_rawDesc))) + }) + return file_api_committerpb_ref_proto_rawDescData +} + +var file_api_committerpb_ref_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_api_committerpb_ref_proto_goTypes = []any{ + (*TxRef)(nil), // 0: committerpb.TxRef + (*TxIDsBatch)(nil), // 1: committerpb.TxIDsBatch +} +var file_api_committerpb_ref_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_api_committerpb_ref_proto_init() } +func file_api_committerpb_ref_proto_init() { + if File_api_committerpb_ref_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_committerpb_ref_proto_rawDesc), len(file_api_committerpb_ref_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_api_committerpb_ref_proto_goTypes, + DependencyIndexes: file_api_committerpb_ref_proto_depIdxs, + MessageInfos: file_api_committerpb_ref_proto_msgTypes, + }.Build() + File_api_committerpb_ref_proto = out.File + file_api_committerpb_ref_proto_goTypes = nil + file_api_committerpb_ref_proto_depIdxs = nil +} diff --git a/api/committerpb/ref.proto b/api/committerpb/ref.proto new file mode 100644 index 000000000..8c04b2b15 --- /dev/null +++ b/api/committerpb/ref.proto @@ -0,0 +1,23 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +syntax = "proto3"; + +option go_package = "github.com/hyperledger/fabric-x-common/api/committerpb"; + +package committerpb; + +// The TX reference with respect to the block generated by the orderer. +message TxRef { + uint64 block_num = 1; // The block number. + uint32 tx_num = 2; // Transaction number within the block + string tx_id = 3; // Transaction ID within the block. +} + +// A batch of TX IDs. +message TxIDsBatch { + repeated string tx_ids = 1; // List of transaction IDs. +} diff --git a/api/committerpb/status.pb.go b/api/committerpb/status.pb.go new file mode 100644 index 000000000..743896c1f --- /dev/null +++ b/api/committerpb/status.pb.go @@ -0,0 +1,322 @@ +// +//Copyright IBM Corp. All Rights Reserved. +// +//SPDX-License-Identifier: Apache-2.0 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v5.29.3 +// source: api/committerpb/status.proto + +package committerpb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Status represents the result of transaction validation. +// Except for STATUS_UNSPECIFIED, all statuses are recorded in the ledger. +// Some statuses are also stored in the state database which prevent resubmission of the same transaction ID. +type Status int32 + +const ( + // Should never be persisted or reported. + Status_STATUS_UNSPECIFIED Status = 0 // Default. The transaction has not been validated yet. + // Stored in the state database. Prevents submitting a transaction with the same ID. + Status_COMMITTED Status = 1 // Successfully committed and state updated. + Status_ABORTED_SIGNATURE_INVALID Status = 2 // Signature is invalid according to the namespace policy. + Status_ABORTED_MVCC_CONFLICT Status = 3 // Read-write set conflict. + // Cannot be stored in the state database because the TX ID cannot be extracted, + // or the TX ID entry is already occupied. + Status_REJECTED_DUPLICATE_TX_ID Status = 100 // Transaction with the same ID has already been processed. + Status_MALFORMED_BAD_ENVELOPE Status = 101 // Cannot unmarshal envelope. + Status_MALFORMED_MISSING_TX_ID Status = 102 // Envelope is missing transaction ID. + // Stored in the state database. Prevents submitting a transaction with the same ID. + Status_MALFORMED_UNSUPPORTED_ENVELOPE_PAYLOAD Status = 103 // Unsupported envelope payload type. + Status_MALFORMED_BAD_ENVELOPE_PAYLOAD Status = 104 // Cannot unmarshal envelope's payload. + Status_MALFORMED_TX_ID_CONFLICT Status = 105 // Envelope's TX ID does not match the payload's TX ID. + Status_MALFORMED_EMPTY_NAMESPACES Status = 106 // No namespaces provided. + Status_MALFORMED_DUPLICATE_NAMESPACE Status = 107 // Duplicate namespace detected. + Status_MALFORMED_NAMESPACE_ID_INVALID Status = 108 // Invalid namespace identifier. + Status_MALFORMED_BLIND_WRITES_NOT_ALLOWED Status = 109 // Blind writes are not allowed in a namespace transaction. + Status_MALFORMED_NO_WRITES Status = 110 // No write operations in the transaction. + Status_MALFORMED_EMPTY_KEY Status = 111 // Unset key detected. + Status_MALFORMED_DUPLICATE_KEY_IN_READ_WRITE_SET Status = 112 // Duplicate key in the read-write set. + Status_MALFORMED_MISSING_SIGNATURE Status = 113 // Number of signatures does not match the number of namespaces. + Status_MALFORMED_NAMESPACE_POLICY_INVALID Status = 114 // Invalid namespace policy. + Status_MALFORMED_CONFIG_TX_INVALID Status = 115 // Invalid configuration transaction. +) + +// Enum value maps for Status. +var ( + Status_name = map[int32]string{ + 0: "STATUS_UNSPECIFIED", + 1: "COMMITTED", + 2: "ABORTED_SIGNATURE_INVALID", + 3: "ABORTED_MVCC_CONFLICT", + 100: "REJECTED_DUPLICATE_TX_ID", + 101: "MALFORMED_BAD_ENVELOPE", + 102: "MALFORMED_MISSING_TX_ID", + 103: "MALFORMED_UNSUPPORTED_ENVELOPE_PAYLOAD", + 104: "MALFORMED_BAD_ENVELOPE_PAYLOAD", + 105: "MALFORMED_TX_ID_CONFLICT", + 106: "MALFORMED_EMPTY_NAMESPACES", + 107: "MALFORMED_DUPLICATE_NAMESPACE", + 108: "MALFORMED_NAMESPACE_ID_INVALID", + 109: "MALFORMED_BLIND_WRITES_NOT_ALLOWED", + 110: "MALFORMED_NO_WRITES", + 111: "MALFORMED_EMPTY_KEY", + 112: "MALFORMED_DUPLICATE_KEY_IN_READ_WRITE_SET", + 113: "MALFORMED_MISSING_SIGNATURE", + 114: "MALFORMED_NAMESPACE_POLICY_INVALID", + 115: "MALFORMED_CONFIG_TX_INVALID", + } + Status_value = map[string]int32{ + "STATUS_UNSPECIFIED": 0, + "COMMITTED": 1, + "ABORTED_SIGNATURE_INVALID": 2, + "ABORTED_MVCC_CONFLICT": 3, + "REJECTED_DUPLICATE_TX_ID": 100, + "MALFORMED_BAD_ENVELOPE": 101, + "MALFORMED_MISSING_TX_ID": 102, + "MALFORMED_UNSUPPORTED_ENVELOPE_PAYLOAD": 103, + "MALFORMED_BAD_ENVELOPE_PAYLOAD": 104, + "MALFORMED_TX_ID_CONFLICT": 105, + "MALFORMED_EMPTY_NAMESPACES": 106, + "MALFORMED_DUPLICATE_NAMESPACE": 107, + "MALFORMED_NAMESPACE_ID_INVALID": 108, + "MALFORMED_BLIND_WRITES_NOT_ALLOWED": 109, + "MALFORMED_NO_WRITES": 110, + "MALFORMED_EMPTY_KEY": 111, + "MALFORMED_DUPLICATE_KEY_IN_READ_WRITE_SET": 112, + "MALFORMED_MISSING_SIGNATURE": 113, + "MALFORMED_NAMESPACE_POLICY_INVALID": 114, + "MALFORMED_CONFIG_TX_INVALID": 115, + } +) + +func (x Status) Enum() *Status { + p := new(Status) + *p = x + return p +} + +func (x Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Status) Descriptor() protoreflect.EnumDescriptor { + return file_api_committerpb_status_proto_enumTypes[0].Descriptor() +} + +func (Status) Type() protoreflect.EnumType { + return &file_api_committerpb_status_proto_enumTypes[0] +} + +func (x Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Status.Descriptor instead. +func (Status) EnumDescriptor() ([]byte, []int) { + return file_api_committerpb_status_proto_rawDescGZIP(), []int{0} +} + +// A batch of TXs' status. +type TxStatusBatch struct { + state protoimpl.MessageState `protogen:"open.v1"` + Status []*TxStatus `protobuf:"bytes,1,rep,name=status,proto3" json:"status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TxStatusBatch) Reset() { + *x = TxStatusBatch{} + mi := &file_api_committerpb_status_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TxStatusBatch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TxStatusBatch) ProtoMessage() {} + +func (x *TxStatusBatch) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_status_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TxStatusBatch.ProtoReflect.Descriptor instead. +func (*TxStatusBatch) Descriptor() ([]byte, []int) { + return file_api_committerpb_status_proto_rawDescGZIP(), []int{0} +} + +func (x *TxStatusBatch) GetStatus() []*TxStatus { + if x != nil { + return x.Status + } + return nil +} + +// The status of a TX. +type TxStatus struct { + state protoimpl.MessageState `protogen:"open.v1"` + Ref *TxRef `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` + Status Status `protobuf:"varint,2,opt,name=status,proto3,enum=committerpb.Status" json:"status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TxStatus) Reset() { + *x = TxStatus{} + mi := &file_api_committerpb_status_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TxStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TxStatus) ProtoMessage() {} + +func (x *TxStatus) ProtoReflect() protoreflect.Message { + mi := &file_api_committerpb_status_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TxStatus.ProtoReflect.Descriptor instead. +func (*TxStatus) Descriptor() ([]byte, []int) { + return file_api_committerpb_status_proto_rawDescGZIP(), []int{1} +} + +func (x *TxStatus) GetRef() *TxRef { + if x != nil { + return x.Ref + } + return nil +} + +func (x *TxStatus) GetStatus() Status { + if x != nil { + return x.Status + } + return Status_STATUS_UNSPECIFIED +} + +var File_api_committerpb_status_proto protoreflect.FileDescriptor + +const file_api_committerpb_status_proto_rawDesc = "" + + "\n" + + "\x1capi/committerpb/status.proto\x12\vcommitterpb\x1a\x19api/committerpb/ref.proto\">\n" + + "\rTxStatusBatch\x12-\n" + + "\x06status\x18\x01 \x03(\v2\x15.committerpb.TxStatusR\x06status\"]\n" + + "\bTxStatus\x12$\n" + + "\x03ref\x18\x01 \x01(\v2\x12.committerpb.TxRefR\x03ref\x12+\n" + + "\x06status\x18\x02 \x01(\x0e2\x13.committerpb.StatusR\x06status*\x88\x05\n" + + "\x06Status\x12\x16\n" + + "\x12STATUS_UNSPECIFIED\x10\x00\x12\r\n" + + "\tCOMMITTED\x10\x01\x12\x1d\n" + + "\x19ABORTED_SIGNATURE_INVALID\x10\x02\x12\x19\n" + + "\x15ABORTED_MVCC_CONFLICT\x10\x03\x12\x1c\n" + + "\x18REJECTED_DUPLICATE_TX_ID\x10d\x12\x1a\n" + + "\x16MALFORMED_BAD_ENVELOPE\x10e\x12\x1b\n" + + "\x17MALFORMED_MISSING_TX_ID\x10f\x12*\n" + + "&MALFORMED_UNSUPPORTED_ENVELOPE_PAYLOAD\x10g\x12\"\n" + + "\x1eMALFORMED_BAD_ENVELOPE_PAYLOAD\x10h\x12\x1c\n" + + "\x18MALFORMED_TX_ID_CONFLICT\x10i\x12\x1e\n" + + "\x1aMALFORMED_EMPTY_NAMESPACES\x10j\x12!\n" + + "\x1dMALFORMED_DUPLICATE_NAMESPACE\x10k\x12\"\n" + + "\x1eMALFORMED_NAMESPACE_ID_INVALID\x10l\x12&\n" + + "\"MALFORMED_BLIND_WRITES_NOT_ALLOWED\x10m\x12\x17\n" + + "\x13MALFORMED_NO_WRITES\x10n\x12\x17\n" + + "\x13MALFORMED_EMPTY_KEY\x10o\x12-\n" + + ")MALFORMED_DUPLICATE_KEY_IN_READ_WRITE_SET\x10p\x12\x1f\n" + + "\x1bMALFORMED_MISSING_SIGNATURE\x10q\x12&\n" + + "\"MALFORMED_NAMESPACE_POLICY_INVALID\x10r\x12\x1f\n" + + "\x1bMALFORMED_CONFIG_TX_INVALID\x10sB8Z6github.com/hyperledger/fabric-x-common/api/committerpbb\x06proto3" + +var ( + file_api_committerpb_status_proto_rawDescOnce sync.Once + file_api_committerpb_status_proto_rawDescData []byte +) + +func file_api_committerpb_status_proto_rawDescGZIP() []byte { + file_api_committerpb_status_proto_rawDescOnce.Do(func() { + file_api_committerpb_status_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_committerpb_status_proto_rawDesc), len(file_api_committerpb_status_proto_rawDesc))) + }) + return file_api_committerpb_status_proto_rawDescData +} + +var file_api_committerpb_status_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_api_committerpb_status_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_api_committerpb_status_proto_goTypes = []any{ + (Status)(0), // 0: committerpb.Status + (*TxStatusBatch)(nil), // 1: committerpb.TxStatusBatch + (*TxStatus)(nil), // 2: committerpb.TxStatus + (*TxRef)(nil), // 3: committerpb.TxRef +} +var file_api_committerpb_status_proto_depIdxs = []int32{ + 2, // 0: committerpb.TxStatusBatch.status:type_name -> committerpb.TxStatus + 3, // 1: committerpb.TxStatus.ref:type_name -> committerpb.TxRef + 0, // 2: committerpb.TxStatus.status:type_name -> committerpb.Status + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_api_committerpb_status_proto_init() } +func file_api_committerpb_status_proto_init() { + if File_api_committerpb_status_proto != nil { + return + } + file_api_committerpb_ref_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_committerpb_status_proto_rawDesc), len(file_api_committerpb_status_proto_rawDesc)), + NumEnums: 1, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_api_committerpb_status_proto_goTypes, + DependencyIndexes: file_api_committerpb_status_proto_depIdxs, + EnumInfos: file_api_committerpb_status_proto_enumTypes, + MessageInfos: file_api_committerpb_status_proto_msgTypes, + }.Build() + File_api_committerpb_status_proto = out.File + file_api_committerpb_status_proto_goTypes = nil + file_api_committerpb_status_proto_depIdxs = nil +} diff --git a/api/committerpb/status.proto b/api/committerpb/status.proto new file mode 100644 index 000000000..a23476666 --- /dev/null +++ b/api/committerpb/status.proto @@ -0,0 +1,58 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +syntax = "proto3"; + +option go_package = "github.com/hyperledger/fabric-x-common/api/committerpb"; + +package committerpb; + +import "api/committerpb/ref.proto"; + +// A batch of TXs' status. +message TxStatusBatch { + repeated TxStatus status = 1; +} + +// The status of a TX. +message TxStatus { + TxRef ref = 1; + Status status = 2; +} + +// Status represents the result of transaction validation. +// Except for STATUS_UNSPECIFIED, all statuses are recorded in the ledger. +// Some statuses are also stored in the state database which prevent resubmission of the same transaction ID. +enum Status { + // Should never be persisted or reported. + STATUS_UNSPECIFIED = 0; // Default. The transaction has not been validated yet. + + // Stored in the state database. Prevents submitting a transaction with the same ID. + COMMITTED = 1; // Successfully committed and state updated. + ABORTED_SIGNATURE_INVALID = 2; // Signature is invalid according to the namespace policy. + ABORTED_MVCC_CONFLICT = 3; // Read-write set conflict. + + // Cannot be stored in the state database because the TX ID cannot be extracted, + // or the TX ID entry is already occupied. + REJECTED_DUPLICATE_TX_ID = 100; // Transaction with the same ID has already been processed. + MALFORMED_BAD_ENVELOPE = 101; // Cannot unmarshal envelope. + MALFORMED_MISSING_TX_ID = 102; // Envelope is missing transaction ID. + + // Stored in the state database. Prevents submitting a transaction with the same ID. + MALFORMED_UNSUPPORTED_ENVELOPE_PAYLOAD = 103; // Unsupported envelope payload type. + MALFORMED_BAD_ENVELOPE_PAYLOAD = 104; // Cannot unmarshal envelope's payload. + MALFORMED_TX_ID_CONFLICT = 105; // Envelope's TX ID does not match the payload's TX ID. + MALFORMED_EMPTY_NAMESPACES = 106; // No namespaces provided. + MALFORMED_DUPLICATE_NAMESPACE = 107; // Duplicate namespace detected. + MALFORMED_NAMESPACE_ID_INVALID = 108; // Invalid namespace identifier. + MALFORMED_BLIND_WRITES_NOT_ALLOWED = 109; // Blind writes are not allowed in a namespace transaction. + MALFORMED_NO_WRITES = 110; // No write operations in the transaction. + MALFORMED_EMPTY_KEY = 111; // Unset key detected. + MALFORMED_DUPLICATE_KEY_IN_READ_WRITE_SET = 112; // Duplicate key in the read-write set. + MALFORMED_MISSING_SIGNATURE = 113; // Number of signatures does not match the number of namespaces. + MALFORMED_NAMESPACE_POLICY_INVALID = 114; // Invalid namespace policy. + MALFORMED_CONFIG_TX_INVALID = 115; // Invalid configuration transaction. +} diff --git a/api/committerpb/types.go b/api/committerpb/types.go new file mode 100644 index 000000000..b5b41c5c2 --- /dev/null +++ b/api/committerpb/types.go @@ -0,0 +1,47 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package committerpb + +const ( + // MetaNamespaceID is the system's namespace ID that holds information about application's namespaces. + MetaNamespaceID = "_meta" + // ConfigNamespaceID is the system's namespace ID that holds the config transaction. + ConfigNamespaceID = "_config" + // ConfigKey is the key of the config transaction. + ConfigKey = "_config" +) + +// NewTxRef is a convenient method to create a full TX reference in a single line. +func NewTxRef(txID string, blockNum uint64, txNum uint32) *TxRef { + return &TxRef{TxId: txID, BlockNum: blockNum, TxNum: txNum} +} + +// NewTxStatus is a convenient method to create a [TxStatus] in a single line. +func NewTxStatus(s Status, txID string, blkNum uint64, txNum uint32) *TxStatus { + return NewTxStatusFromRef(NewTxRef(txID, blkNum, txNum), s) +} + +// NewTxStatusFromRef is a convenient method to create a [TxStatus] from a [TxRef] in a single line. +func NewTxStatusFromRef(ref *TxRef, s Status) *TxStatus { + return &TxStatus{Ref: ref, Status: s} +} + +// AreSameHeight returns true if both references' heights are either nil or equal. +func AreSameHeight(h1, h2 *TxRef) bool { + if h1 == nil { + return h2 == nil + } + if h2 == nil { + return false + } + return h1.IsHeight(h2.BlockNum, h2.TxNum) +} + +// IsHeight returns true if the reference heights matches the input. +func (x *TxRef) IsHeight(blockNum uint64, txNum uint32) bool { + return x.BlockNum == blockNum && x.TxNum == txNum +} diff --git a/api/committerpb/types_test.go b/api/committerpb/types_test.go new file mode 100644 index 000000000..e38ed7087 --- /dev/null +++ b/api/committerpb/types_test.go @@ -0,0 +1,28 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package committerpb + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestHeightComparison(t *testing.T) { + t.Parallel() + require.True(t, AreSameHeight(NewTxRef("tx1", 10, 100), NewTxRef("tx2", 10, 100))) + require.False(t, AreSameHeight(NewTxRef("tx1", 10, 100), NewTxRef("tx1", 11, 100))) + require.False(t, AreSameHeight(NewTxRef("tx1", 10, 100), NewTxRef("tx1", 10, 101))) + + require.True(t, AreSameHeight(nil, nil)) + require.False(t, AreSameHeight(NewTxRef("tx1", 10, 100), nil)) + require.False(t, AreSameHeight(nil, NewTxRef("tx1", 10, 100))) + + require.True(t, NewTxRef("tx1", 10, 100).IsHeight(10, 100)) + require.False(t, NewTxRef("tx1", 10, 100).IsHeight(11, 100)) + require.False(t, NewTxRef("tx1", 10, 100).IsHeight(10, 101)) +} diff --git a/api/ordererpb/configuration.pb.go b/api/ordererpb/configuration.pb.go index c1b744fd7..10788dea1 100644 --- a/api/ordererpb/configuration.pb.go +++ b/api/ordererpb/configuration.pb.go @@ -3,9 +3,13 @@ // //SPDX-License-Identifier: Apache-2.0 +// The following rule disables snake names requirements for the entire file. +// It should be removed once this issue is solved. +// (-- api-linter: core::0140::lower-snake=disabled --) + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.36.10 // protoc v5.29.3 // source: api/ordererpb/configuration.proto @@ -16,6 +20,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -28,22 +33,19 @@ const ( // SharedConfig holds the initial configuration that will be used to bootstrap new nodes. // This configuration is common to all Arma nodes. type SharedConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PartiesConfig []*PartyConfig `protobuf:"bytes,1,rep,name=PartiesConfig,proto3" json:"PartiesConfig,omitempty"` - ConsensusConfig *ConsensusConfig `protobuf:"bytes,2,opt,name=ConsensusConfig,proto3" json:"ConsensusConfig,omitempty"` - BatchingConfig *BatchingConfig `protobuf:"bytes,3,opt,name=BatchingConfig,proto3" json:"BatchingConfig,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + PartiesConfig []*PartyConfig `protobuf:"bytes,1,rep,name=PartiesConfig,proto3" json:"PartiesConfig,omitempty"` + ConsensusConfig *ConsensusConfig `protobuf:"bytes,2,opt,name=ConsensusConfig,proto3" json:"ConsensusConfig,omitempty"` + BatchingConfig *BatchingConfig `protobuf:"bytes,3,opt,name=BatchingConfig,proto3" json:"BatchingConfig,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *SharedConfig) Reset() { *x = SharedConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SharedConfig) String() string { @@ -54,7 +56,7 @@ func (*SharedConfig) ProtoMessage() {} func (x *SharedConfig) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -92,10 +94,7 @@ func (x *SharedConfig) GetBatchingConfig() *BatchingConfig { // PartyConfig carries the identity, certificates and nodes configuration of a party. type PartyConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // the identity of the party, type unit16, id > 0 PartyID uint32 `protobuf:"varint,1,opt,name=PartyID,proto3" json:"PartyID,omitempty"` // the certificates of the certificate authorities who generates the party's signing key-pairs @@ -110,15 +109,15 @@ type PartyConfig struct { ConsenterConfig *ConsenterNodeConfig `protobuf:"bytes,6,opt,name=ConsenterConfig,proto3" json:"ConsenterConfig,omitempty"` // the shared configuration of the assembler AssemblerConfig *AssemblerNodeConfig `protobuf:"bytes,7,opt,name=AssemblerConfig,proto3" json:"AssemblerConfig,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PartyConfig) Reset() { *x = PartyConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PartyConfig) String() string { @@ -129,7 +128,7 @@ func (*PartyConfig) ProtoMessage() {} func (x *PartyConfig) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -194,25 +193,22 @@ func (x *PartyConfig) GetAssemblerConfig() *AssemblerNodeConfig { } type RouterNodeConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // the hostname or IP on which the gRPC server will listen Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` // the port on which the gRPC server will listen Port uint32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` // the certificate used to authenticate with clients - TlsCert []byte `protobuf:"bytes,3,opt,name=tls_cert,json=tlsCert,proto3" json:"tls_cert,omitempty"` + TlsCert []byte `protobuf:"bytes,3,opt,name=tls_cert,json=tlsCert,proto3" json:"tls_cert,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *RouterNodeConfig) Reset() { *x = RouterNodeConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RouterNodeConfig) String() string { @@ -223,7 +219,7 @@ func (*RouterNodeConfig) ProtoMessage() {} func (x *RouterNodeConfig) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -260,10 +256,7 @@ func (x *RouterNodeConfig) GetTlsCert() []byte { } type BatcherNodeConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // the ID of the shard to which the batcher is associated ShardID uint32 `protobuf:"varint,1,opt,name=shardID,proto3" json:"shardID,omitempty"` // the hostname or IP on which the gRPC server will listen @@ -273,16 +266,16 @@ type BatcherNodeConfig struct { // the signing certificate (that includes the public key) of the batcher used to authenticate signatures on BAS's SignCert []byte `protobuf:"bytes,4,opt,name=sign_cert,json=signCert,proto3" json:"sign_cert,omitempty"` // the certificate used to authenticate with clients - TlsCert []byte `protobuf:"bytes,5,opt,name=tls_cert,json=tlsCert,proto3" json:"tls_cert,omitempty"` + TlsCert []byte `protobuf:"bytes,5,opt,name=tls_cert,json=tlsCert,proto3" json:"tls_cert,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *BatcherNodeConfig) Reset() { *x = BatcherNodeConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *BatcherNodeConfig) String() string { @@ -293,7 +286,7 @@ func (*BatcherNodeConfig) ProtoMessage() {} func (x *BatcherNodeConfig) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -344,10 +337,7 @@ func (x *BatcherNodeConfig) GetTlsCert() []byte { } type ConsenterNodeConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // the hostname or IP on which the gRPC server will listen Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` // the port on which the gRPC server will listen @@ -355,16 +345,16 @@ type ConsenterNodeConfig struct { // the signing certificate (that includes the public key) of the consensus used to authenticate signatures on blocks SignCert []byte `protobuf:"bytes,3,opt,name=sign_cert,json=signCert,proto3" json:"sign_cert,omitempty"` // the certificate used to authenticate with clients - TlsCert []byte `protobuf:"bytes,4,opt,name=tls_cert,json=tlsCert,proto3" json:"tls_cert,omitempty"` + TlsCert []byte `protobuf:"bytes,4,opt,name=tls_cert,json=tlsCert,proto3" json:"tls_cert,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ConsenterNodeConfig) Reset() { *x = ConsenterNodeConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ConsenterNodeConfig) String() string { @@ -375,7 +365,7 @@ func (*ConsenterNodeConfig) ProtoMessage() {} func (x *ConsenterNodeConfig) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -419,25 +409,22 @@ func (x *ConsenterNodeConfig) GetTlsCert() []byte { } type AssemblerNodeConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // the hostname or IP on which the gRPC server will listen Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` // the port on which the gRPC server will listen Port uint32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` // the certificate used to authenticate with clients - TlsCert []byte `protobuf:"bytes,3,opt,name=tls_cert,json=tlsCert,proto3" json:"tls_cert,omitempty"` + TlsCert []byte `protobuf:"bytes,3,opt,name=tls_cert,json=tlsCert,proto3" json:"tls_cert,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *AssemblerNodeConfig) Reset() { *x = AssemblerNodeConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AssemblerNodeConfig) String() string { @@ -448,7 +435,7 @@ func (*AssemblerNodeConfig) ProtoMessage() {} func (x *AssemblerNodeConfig) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -486,20 +473,17 @@ func (x *AssemblerNodeConfig) GetTlsCert() []byte { // BFT configuration type ConsensusConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SmartBFTConfig *SmartBFTConfig `protobuf:"bytes,1,opt,name=SmartBFTConfig,proto3" json:"SmartBFTConfig,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + SmartBFTConfig *SmartBFTConfig `protobuf:"bytes,1,opt,name=SmartBFTConfig,proto3" json:"SmartBFTConfig,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ConsensusConfig) Reset() { *x = ConsensusConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ConsensusConfig) String() string { @@ -510,7 +494,7 @@ func (*ConsensusConfig) ProtoMessage() {} func (x *ConsensusConfig) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -533,10 +517,7 @@ func (x *ConsensusConfig) GetSmartBFTConfig() *SmartBFTConfig { } type SmartBFTConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // RequestBatchMaxCount is the maximal number of requests in a batch. // A request batch that reaches this count is proposed immediately. RequestBatchMaxCount uint64 `protobuf:"varint,1,opt,name=RequestBatchMaxCount,proto3" json:"RequestBatchMaxCount,omitempty"` @@ -596,15 +577,15 @@ type SmartBFTConfig struct { // RequestPoolSubmitTimeout the total amount of time a client can wait for the submission of a single // request into the request pool. RequestPoolSubmitTimeout string `protobuf:"bytes,20,opt,name=RequestPoolSubmitTimeout,proto3" json:"RequestPoolSubmitTimeout,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *SmartBFTConfig) Reset() { *x = SmartBFTConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SmartBFTConfig) String() string { @@ -615,7 +596,7 @@ func (*SmartBFTConfig) ProtoMessage() {} func (x *SmartBFTConfig) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -771,25 +752,22 @@ func (x *SmartBFTConfig) GetRequestPoolSubmitTimeout() string { } type BatchingConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // BatchTimeouts controls the timeouts of a batch. BatchTimeouts *BatchTimeouts `protobuf:"bytes,1,opt,name=BatchTimeouts,proto3" json:"BatchTimeouts,omitempty"` // BatchSize controls the number of messages batched into a block and defines limits on a batch size. BatchSize *BatchSize `protobuf:"bytes,2,opt,name=BatchSize,proto3" json:"BatchSize,omitempty"` // RequestMaxBytes is the maximal request size in bytes. RequestMaxBytes uint64 `protobuf:"varint,3,opt,name=RequestMaxBytes,proto3" json:"RequestMaxBytes,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *BatchingConfig) Reset() { *x = BatchingConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *BatchingConfig) String() string { @@ -800,7 +778,7 @@ func (*BatchingConfig) ProtoMessage() {} func (x *BatchingConfig) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -837,10 +815,7 @@ func (x *BatchingConfig) GetRequestMaxBytes() uint64 { } type BatchSize struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // MaxMessageCount is the maximum number of messages to permit in a batch. No block will contain more than this number of messages. MaxMessageCount uint32 `protobuf:"varint,1,opt,name=MaxMessageCount,proto3" json:"MaxMessageCount,omitempty"` // AbsoluteMaxBytes is the absolute maximum number of bytes allowed for the serialized messages in a batch. @@ -856,15 +831,15 @@ type BatchSize struct { // Because messages may be larger than preferred max bytes (up to AbsoluteMaxBytes), some batches may exceed the preferred max bytes, but will always contain exactly one transaction. // *** NOTE: This field is not in use. *** PreferredMaxBytes uint32 `protobuf:"varint,3,opt,name=PreferredMaxBytes,proto3" json:"PreferredMaxBytes,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *BatchSize) Reset() { *x = BatchSize{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *BatchSize) String() string { @@ -875,7 +850,7 @@ func (*BatchSize) ProtoMessage() {} func (x *BatchSize) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -912,10 +887,7 @@ func (x *BatchSize) GetPreferredMaxBytes() uint32 { } type BatchTimeouts struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // BatchCreationTimeout is the time a batch can wait before it is created. BatchCreationTimeout string `protobuf:"bytes,1,opt,name=BatchCreationTimeout,proto3" json:"BatchCreationTimeout,omitempty"` // FirstStrikeThreshold defines the maximum time a request can remain in the memory pool without being batched. @@ -928,15 +900,15 @@ type BatchTimeouts struct { // If this timeout is reached, the request is removed from the pool. // NOTE: This timeout's intended purpose is not implemented and is used for GC by the memory pool. AutoRemoveTimeout string `protobuf:"bytes,4,opt,name=AutoRemoveTimeout,proto3" json:"AutoRemoveTimeout,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *BatchTimeouts) Reset() { *x = BatchTimeouts{} - if protoimpl.UnsafeEnabled { - mi := &file_api_ordererpb_configuration_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_ordererpb_configuration_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *BatchTimeouts) String() string { @@ -947,7 +919,7 @@ func (*BatchTimeouts) ProtoMessage() {} func (x *BatchTimeouts) ProtoReflect() protoreflect.Message { mi := &file_api_ordererpb_configuration_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -992,216 +964,117 @@ func (x *BatchTimeouts) GetAutoRemoveTimeout() string { var File_api_ordererpb_configuration_proto protoreflect.FileDescriptor -var file_api_ordererpb_configuration_proto_rawDesc = []byte{ - 0x0a, 0x21, 0x61, 0x70, 0x69, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x70, 0x62, 0x2f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0xb7, 0x01, 0x0a, 0x0c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x32, 0x0a, 0x0d, 0x50, 0x61, 0x72, 0x74, 0x69, 0x65, 0x73, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x50, 0x61, - 0x72, 0x74, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x50, 0x61, 0x72, 0x74, 0x69, - 0x65, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3a, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x73, - 0x65, 0x6e, 0x73, 0x75, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x10, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x0f, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x37, 0x0a, 0x0e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x42, - 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x42, - 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0xd4, 0x02, - 0x0a, 0x0b, 0x50, 0x61, 0x72, 0x74, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, - 0x07, 0x50, 0x61, 0x72, 0x74, 0x79, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, - 0x50, 0x61, 0x72, 0x74, 0x79, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x43, 0x41, 0x43, 0x65, 0x72, - 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x07, 0x43, 0x41, 0x43, 0x65, 0x72, 0x74, - 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x4c, 0x53, 0x43, 0x41, 0x43, 0x65, 0x72, 0x74, 0x73, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0a, 0x54, 0x4c, 0x53, 0x43, 0x41, 0x43, 0x65, 0x72, 0x74, - 0x73, 0x12, 0x35, 0x0a, 0x0c, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0c, 0x52, 0x6f, 0x75, 0x74, - 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3a, 0x0a, 0x0e, 0x42, 0x61, 0x74, 0x63, - 0x68, 0x65, 0x72, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x12, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x73, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3e, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x65, - 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, - 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x0f, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3e, 0x0a, 0x0f, 0x41, 0x73, 0x73, 0x65, 0x6d, 0x62, 0x6c, 0x65, - 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, - 0x41, 0x73, 0x73, 0x65, 0x6d, 0x62, 0x6c, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x0f, 0x41, 0x73, 0x73, 0x65, 0x6d, 0x62, 0x6c, 0x65, 0x72, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x22, 0x55, 0x0a, 0x10, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x4e, 0x6f, - 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, - 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6c, 0x73, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x07, 0x74, 0x6c, 0x73, 0x43, 0x65, 0x72, 0x74, 0x22, 0x8d, 0x01, 0x0a, 0x11, - 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, 0x68, - 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, - 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, - 0x6f, 0x72, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x5f, 0x63, 0x65, 0x72, 0x74, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x73, 0x69, 0x67, 0x6e, 0x43, 0x65, 0x72, 0x74, - 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6c, 0x73, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x07, 0x74, 0x6c, 0x73, 0x43, 0x65, 0x72, 0x74, 0x22, 0x75, 0x0a, 0x13, 0x43, - 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x69, - 0x67, 0x6e, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x73, - 0x69, 0x67, 0x6e, 0x43, 0x65, 0x72, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6c, 0x73, 0x5f, 0x63, - 0x65, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x6c, 0x73, 0x43, 0x65, - 0x72, 0x74, 0x22, 0x58, 0x0a, 0x13, 0x41, 0x73, 0x73, 0x65, 0x6d, 0x62, 0x6c, 0x65, 0x72, 0x4e, - 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, - 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6c, 0x73, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x6c, 0x73, 0x43, 0x65, 0x72, 0x74, 0x22, 0x4a, 0x0a, 0x0f, - 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, - 0x37, 0x0a, 0x0e, 0x53, 0x6d, 0x61, 0x72, 0x74, 0x42, 0x46, 0x54, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x53, 0x6d, 0x61, 0x72, 0x74, 0x42, - 0x46, 0x54, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x53, 0x6d, 0x61, 0x72, 0x74, 0x42, - 0x46, 0x54, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x96, 0x08, 0x0a, 0x0e, 0x53, 0x6d, 0x61, - 0x72, 0x74, 0x42, 0x46, 0x54, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x32, 0x0a, 0x14, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x61, 0x78, 0x43, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, - 0x32, 0x0a, 0x14, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, - 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x61, 0x78, 0x42, 0x79, - 0x74, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x17, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x61, - 0x74, 0x63, 0x68, 0x4d, 0x61, 0x78, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x17, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x61, 0x74, - 0x63, 0x68, 0x4d, 0x61, 0x78, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x3c, 0x0a, - 0x19, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x19, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, 0x6f, 0x6f, - 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x34, 0x0a, 0x15, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x6f, 0x72, - 0x77, 0x61, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x36, 0x0a, 0x16, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x54, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, - 0x6f, 0x75, 0x74, 0x12, 0x3a, 0x0a, 0x18, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x41, 0x75, - 0x74, 0x6f, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x41, 0x75, - 0x74, 0x6f, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, - 0x3a, 0x0a, 0x18, 0x56, 0x69, 0x65, 0x77, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, - 0x65, 0x6e, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x18, 0x56, 0x69, 0x65, 0x77, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, - 0x65, 0x6e, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x2c, 0x0a, 0x11, 0x56, - 0x69, 0x65, 0x77, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x56, 0x69, 0x65, 0x77, 0x43, 0x68, 0x61, 0x6e, - 0x67, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x36, 0x0a, 0x16, 0x4c, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x54, 0x69, 0x6d, 0x65, - 0x6f, 0x75, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x4c, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, - 0x74, 0x12, 0x32, 0x0a, 0x14, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x65, 0x61, 0x72, 0x74, - 0x62, 0x65, 0x61, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x14, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, - 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x44, 0x0a, 0x1d, 0x4e, 0x75, 0x6d, 0x4f, 0x66, 0x54, 0x69, - 0x63, 0x6b, 0x73, 0x42, 0x65, 0x68, 0x69, 0x6e, 0x64, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x53, - 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x1d, 0x4e, 0x75, - 0x6d, 0x4f, 0x66, 0x54, 0x69, 0x63, 0x6b, 0x73, 0x42, 0x65, 0x68, 0x69, 0x6e, 0x64, 0x42, 0x65, - 0x66, 0x6f, 0x72, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x26, 0x0a, 0x0e, 0x43, - 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x0e, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x54, 0x69, 0x6d, 0x65, - 0x6f, 0x75, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x53, 0x79, 0x6e, 0x63, 0x4f, 0x6e, 0x53, 0x74, 0x61, - 0x72, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x53, 0x79, 0x6e, 0x63, 0x4f, 0x6e, - 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x2c, 0x0a, 0x11, 0x53, 0x70, 0x65, 0x65, 0x64, 0x55, 0x70, - 0x56, 0x69, 0x65, 0x77, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x11, 0x53, 0x70, 0x65, 0x65, 0x64, 0x55, 0x70, 0x56, 0x69, 0x65, 0x77, 0x43, 0x68, 0x61, - 0x6e, 0x67, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x6f, 0x74, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x4c, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x52, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x0a, 0x12, 0x44, - 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x65, 0x72, 0x4c, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x18, 0x12, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x73, 0x50, 0x65, 0x72, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x0f, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x13, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x61, 0x78, - 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x18, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x50, 0x6f, 0x6f, 0x6c, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, - 0x74, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x50, 0x6f, 0x6f, 0x6c, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, - 0x74, 0x22, 0x9a, 0x01, 0x0a, 0x0e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x34, 0x0a, 0x0d, 0x42, 0x61, 0x74, 0x63, 0x68, 0x54, 0x69, 0x6d, - 0x65, 0x6f, 0x75, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x42, 0x61, - 0x74, 0x63, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x73, 0x52, 0x0d, 0x42, 0x61, 0x74, - 0x63, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x09, 0x42, 0x61, - 0x74, 0x63, 0x68, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, - 0x42, 0x61, 0x74, 0x63, 0x68, 0x53, 0x69, 0x7a, 0x65, 0x52, 0x09, 0x42, 0x61, 0x74, 0x63, 0x68, - 0x53, 0x69, 0x7a, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, - 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x22, 0x8f, - 0x01, 0x0a, 0x09, 0x42, 0x61, 0x74, 0x63, 0x68, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x28, 0x0a, 0x0f, - 0x4d, 0x61, 0x78, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x4d, 0x61, 0x78, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x41, 0x62, 0x73, 0x6f, 0x6c, 0x75, - 0x74, 0x65, 0x4d, 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x10, 0x41, 0x62, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x65, 0x4d, 0x61, 0x78, 0x42, 0x79, 0x74, - 0x65, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x64, 0x4d, - 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x50, - 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x64, 0x4d, 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, - 0x22, 0xdb, 0x01, 0x0a, 0x0d, 0x42, 0x61, 0x74, 0x63, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, - 0x74, 0x73, 0x12, 0x32, 0x0a, 0x14, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x14, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x32, 0x0a, 0x14, 0x46, 0x69, 0x72, 0x73, 0x74, 0x53, - 0x74, 0x72, 0x69, 0x6b, 0x65, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x46, 0x69, 0x72, 0x73, 0x74, 0x53, 0x74, 0x72, 0x69, 0x6b, - 0x65, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x12, 0x34, 0x0a, 0x15, 0x53, 0x65, - 0x63, 0x6f, 0x6e, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6b, 0x65, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, - 0x6f, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x53, 0x65, 0x63, 0x6f, 0x6e, - 0x64, 0x53, 0x74, 0x72, 0x69, 0x6b, 0x65, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, - 0x12, 0x2c, 0x0a, 0x11, 0x41, 0x75, 0x74, 0x6f, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x41, 0x75, 0x74, - 0x6f, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x42, 0x36, - 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x79, 0x70, - 0x65, 0x72, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x72, 0x2f, 0x66, 0x61, 0x62, 0x72, 0x69, 0x63, 0x2d, - 0x78, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6f, 0x72, 0x64, - 0x65, 0x72, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_api_ordererpb_configuration_proto_rawDesc = "" + + "\n" + + "!api/ordererpb/configuration.proto\x12\tordererpb\"\xd5\x01\n" + + "\fSharedConfig\x12<\n" + + "\rPartiesConfig\x18\x01 \x03(\v2\x16.ordererpb.PartyConfigR\rPartiesConfig\x12D\n" + + "\x0fConsensusConfig\x18\x02 \x01(\v2\x1a.ordererpb.ConsensusConfigR\x0fConsensusConfig\x12A\n" + + "\x0eBatchingConfig\x18\x03 \x01(\v2\x19.ordererpb.BatchingConfigR\x0eBatchingConfig\"\xfc\x02\n" + + "\vPartyConfig\x12\x18\n" + + "\aPartyID\x18\x01 \x01(\rR\aPartyID\x12\x18\n" + + "\aCACerts\x18\x02 \x03(\fR\aCACerts\x12\x1e\n" + + "\n" + + "TLSCACerts\x18\x03 \x03(\fR\n" + + "TLSCACerts\x12?\n" + + "\fRouterConfig\x18\x04 \x01(\v2\x1b.ordererpb.RouterNodeConfigR\fRouterConfig\x12D\n" + + "\x0eBatchersConfig\x18\x05 \x03(\v2\x1c.ordererpb.BatcherNodeConfigR\x0eBatchersConfig\x12H\n" + + "\x0fConsenterConfig\x18\x06 \x01(\v2\x1e.ordererpb.ConsenterNodeConfigR\x0fConsenterConfig\x12H\n" + + "\x0fAssemblerConfig\x18\a \x01(\v2\x1e.ordererpb.AssemblerNodeConfigR\x0fAssemblerConfig\"U\n" + + "\x10RouterNodeConfig\x12\x12\n" + + "\x04host\x18\x01 \x01(\tR\x04host\x12\x12\n" + + "\x04port\x18\x02 \x01(\rR\x04port\x12\x19\n" + + "\btls_cert\x18\x03 \x01(\fR\atlsCert\"\x8d\x01\n" + + "\x11BatcherNodeConfig\x12\x18\n" + + "\ashardID\x18\x01 \x01(\rR\ashardID\x12\x12\n" + + "\x04host\x18\x02 \x01(\tR\x04host\x12\x12\n" + + "\x04port\x18\x03 \x01(\rR\x04port\x12\x1b\n" + + "\tsign_cert\x18\x04 \x01(\fR\bsignCert\x12\x19\n" + + "\btls_cert\x18\x05 \x01(\fR\atlsCert\"u\n" + + "\x13ConsenterNodeConfig\x12\x12\n" + + "\x04host\x18\x01 \x01(\tR\x04host\x12\x12\n" + + "\x04port\x18\x02 \x01(\rR\x04port\x12\x1b\n" + + "\tsign_cert\x18\x03 \x01(\fR\bsignCert\x12\x19\n" + + "\btls_cert\x18\x04 \x01(\fR\atlsCert\"X\n" + + "\x13AssemblerNodeConfig\x12\x12\n" + + "\x04host\x18\x01 \x01(\tR\x04host\x12\x12\n" + + "\x04port\x18\x02 \x01(\rR\x04port\x12\x19\n" + + "\btls_cert\x18\x03 \x01(\fR\atlsCert\"T\n" + + "\x0fConsensusConfig\x12A\n" + + "\x0eSmartBFTConfig\x18\x01 \x01(\v2\x19.ordererpb.SmartBFTConfigR\x0eSmartBFTConfig\"\x96\b\n" + + "\x0eSmartBFTConfig\x122\n" + + "\x14RequestBatchMaxCount\x18\x01 \x01(\x04R\x14RequestBatchMaxCount\x122\n" + + "\x14RequestBatchMaxBytes\x18\x02 \x01(\x04R\x14RequestBatchMaxBytes\x128\n" + + "\x17RequestBatchMaxInterval\x18\x03 \x01(\tR\x17RequestBatchMaxInterval\x12<\n" + + "\x19IncomingMessageBufferSize\x18\x04 \x01(\x04R\x19IncomingMessageBufferSize\x12(\n" + + "\x0fRequestPoolSize\x18\x05 \x01(\x04R\x0fRequestPoolSize\x124\n" + + "\x15RequestForwardTimeout\x18\x06 \x01(\tR\x15RequestForwardTimeout\x126\n" + + "\x16RequestComplainTimeout\x18\a \x01(\tR\x16RequestComplainTimeout\x12:\n" + + "\x18RequestAutoRemoveTimeout\x18\b \x01(\tR\x18RequestAutoRemoveTimeout\x12:\n" + + "\x18ViewChangeResendInterval\x18\t \x01(\tR\x18ViewChangeResendInterval\x12,\n" + + "\x11ViewChangeTimeout\x18\n" + + " \x01(\tR\x11ViewChangeTimeout\x126\n" + + "\x16LeaderHeartbeatTimeout\x18\v \x01(\tR\x16LeaderHeartbeatTimeout\x122\n" + + "\x14LeaderHeartbeatCount\x18\f \x01(\x04R\x14LeaderHeartbeatCount\x12D\n" + + "\x1dNumOfTicksBehindBeforeSyncing\x18\r \x01(\x04R\x1dNumOfTicksBehindBeforeSyncing\x12&\n" + + "\x0eCollectTimeout\x18\x0e \x01(\tR\x0eCollectTimeout\x12 \n" + + "\vSyncOnStart\x18\x0f \x01(\bR\vSyncOnStart\x12,\n" + + "\x11SpeedUpViewChange\x18\x10 \x01(\bR\x11SpeedUpViewChange\x12&\n" + + "\x0eLeaderRotation\x18\x11 \x01(\bR\x0eLeaderRotation\x12.\n" + + "\x12DecisionsPerLeader\x18\x12 \x01(\x04R\x12DecisionsPerLeader\x12(\n" + + "\x0fRequestMaxBytes\x18\x13 \x01(\x04R\x0fRequestMaxBytes\x12:\n" + + "\x18RequestPoolSubmitTimeout\x18\x14 \x01(\tR\x18RequestPoolSubmitTimeout\"\xae\x01\n" + + "\x0eBatchingConfig\x12>\n" + + "\rBatchTimeouts\x18\x01 \x01(\v2\x18.ordererpb.BatchTimeoutsR\rBatchTimeouts\x122\n" + + "\tBatchSize\x18\x02 \x01(\v2\x14.ordererpb.BatchSizeR\tBatchSize\x12(\n" + + "\x0fRequestMaxBytes\x18\x03 \x01(\x04R\x0fRequestMaxBytes\"\x8f\x01\n" + + "\tBatchSize\x12(\n" + + "\x0fMaxMessageCount\x18\x01 \x01(\rR\x0fMaxMessageCount\x12*\n" + + "\x10AbsoluteMaxBytes\x18\x02 \x01(\rR\x10AbsoluteMaxBytes\x12,\n" + + "\x11PreferredMaxBytes\x18\x03 \x01(\rR\x11PreferredMaxBytes\"\xdb\x01\n" + + "\rBatchTimeouts\x122\n" + + "\x14BatchCreationTimeout\x18\x01 \x01(\tR\x14BatchCreationTimeout\x122\n" + + "\x14FirstStrikeThreshold\x18\x02 \x01(\tR\x14FirstStrikeThreshold\x124\n" + + "\x15SecondStrikeThreshold\x18\x03 \x01(\tR\x15SecondStrikeThreshold\x12,\n" + + "\x11AutoRemoveTimeout\x18\x04 \x01(\tR\x11AutoRemoveTimeoutB6Z4github.com/hyperledger/fabric-x-common/api/ordererpbb\x06proto3" var ( file_api_ordererpb_configuration_proto_rawDescOnce sync.Once - file_api_ordererpb_configuration_proto_rawDescData = file_api_ordererpb_configuration_proto_rawDesc + file_api_ordererpb_configuration_proto_rawDescData []byte ) func file_api_ordererpb_configuration_proto_rawDescGZIP() []byte { file_api_ordererpb_configuration_proto_rawDescOnce.Do(func() { - file_api_ordererpb_configuration_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_ordererpb_configuration_proto_rawDescData) + file_api_ordererpb_configuration_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_ordererpb_configuration_proto_rawDesc), len(file_api_ordererpb_configuration_proto_rawDesc))) }) return file_api_ordererpb_configuration_proto_rawDescData } var file_api_ordererpb_configuration_proto_msgTypes = make([]protoimpl.MessageInfo, 11) -var file_api_ordererpb_configuration_proto_goTypes = []interface{}{ - (*SharedConfig)(nil), // 0: SharedConfig - (*PartyConfig)(nil), // 1: PartyConfig - (*RouterNodeConfig)(nil), // 2: RouterNodeConfig - (*BatcherNodeConfig)(nil), // 3: BatcherNodeConfig - (*ConsenterNodeConfig)(nil), // 4: ConsenterNodeConfig - (*AssemblerNodeConfig)(nil), // 5: AssemblerNodeConfig - (*ConsensusConfig)(nil), // 6: ConsensusConfig - (*SmartBFTConfig)(nil), // 7: SmartBFTConfig - (*BatchingConfig)(nil), // 8: BatchingConfig - (*BatchSize)(nil), // 9: BatchSize - (*BatchTimeouts)(nil), // 10: BatchTimeouts +var file_api_ordererpb_configuration_proto_goTypes = []any{ + (*SharedConfig)(nil), // 0: ordererpb.SharedConfig + (*PartyConfig)(nil), // 1: ordererpb.PartyConfig + (*RouterNodeConfig)(nil), // 2: ordererpb.RouterNodeConfig + (*BatcherNodeConfig)(nil), // 3: ordererpb.BatcherNodeConfig + (*ConsenterNodeConfig)(nil), // 4: ordererpb.ConsenterNodeConfig + (*AssemblerNodeConfig)(nil), // 5: ordererpb.AssemblerNodeConfig + (*ConsensusConfig)(nil), // 6: ordererpb.ConsensusConfig + (*SmartBFTConfig)(nil), // 7: ordererpb.SmartBFTConfig + (*BatchingConfig)(nil), // 8: ordererpb.BatchingConfig + (*BatchSize)(nil), // 9: ordererpb.BatchSize + (*BatchTimeouts)(nil), // 10: ordererpb.BatchTimeouts } var file_api_ordererpb_configuration_proto_depIdxs = []int32{ - 1, // 0: SharedConfig.PartiesConfig:type_name -> PartyConfig - 6, // 1: SharedConfig.ConsensusConfig:type_name -> ConsensusConfig - 8, // 2: SharedConfig.BatchingConfig:type_name -> BatchingConfig - 2, // 3: PartyConfig.RouterConfig:type_name -> RouterNodeConfig - 3, // 4: PartyConfig.BatchersConfig:type_name -> BatcherNodeConfig - 4, // 5: PartyConfig.ConsenterConfig:type_name -> ConsenterNodeConfig - 5, // 6: PartyConfig.AssemblerConfig:type_name -> AssemblerNodeConfig - 7, // 7: ConsensusConfig.SmartBFTConfig:type_name -> SmartBFTConfig - 10, // 8: BatchingConfig.BatchTimeouts:type_name -> BatchTimeouts - 9, // 9: BatchingConfig.BatchSize:type_name -> BatchSize + 1, // 0: ordererpb.SharedConfig.PartiesConfig:type_name -> ordererpb.PartyConfig + 6, // 1: ordererpb.SharedConfig.ConsensusConfig:type_name -> ordererpb.ConsensusConfig + 8, // 2: ordererpb.SharedConfig.BatchingConfig:type_name -> ordererpb.BatchingConfig + 2, // 3: ordererpb.PartyConfig.RouterConfig:type_name -> ordererpb.RouterNodeConfig + 3, // 4: ordererpb.PartyConfig.BatchersConfig:type_name -> ordererpb.BatcherNodeConfig + 4, // 5: ordererpb.PartyConfig.ConsenterConfig:type_name -> ordererpb.ConsenterNodeConfig + 5, // 6: ordererpb.PartyConfig.AssemblerConfig:type_name -> ordererpb.AssemblerNodeConfig + 7, // 7: ordererpb.ConsensusConfig.SmartBFTConfig:type_name -> ordererpb.SmartBFTConfig + 10, // 8: ordererpb.BatchingConfig.BatchTimeouts:type_name -> ordererpb.BatchTimeouts + 9, // 9: ordererpb.BatchingConfig.BatchSize:type_name -> ordererpb.BatchSize 10, // [10:10] is the sub-list for method output_type 10, // [10:10] is the sub-list for method input_type 10, // [10:10] is the sub-list for extension type_name @@ -1214,145 +1087,11 @@ func file_api_ordererpb_configuration_proto_init() { if File_api_ordererpb_configuration_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_api_ordererpb_configuration_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SharedConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_ordererpb_configuration_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PartyConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_ordererpb_configuration_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RouterNodeConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_ordererpb_configuration_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BatcherNodeConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_ordererpb_configuration_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ConsenterNodeConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_ordererpb_configuration_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AssemblerNodeConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_ordererpb_configuration_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ConsensusConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_ordererpb_configuration_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SmartBFTConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_ordererpb_configuration_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BatchingConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_ordererpb_configuration_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BatchSize); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_ordererpb_configuration_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BatchTimeouts); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_api_ordererpb_configuration_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_ordererpb_configuration_proto_rawDesc), len(file_api_ordererpb_configuration_proto_rawDesc)), NumEnums: 0, NumMessages: 11, NumExtensions: 0, @@ -1363,7 +1102,6 @@ func file_api_ordererpb_configuration_proto_init() { MessageInfos: file_api_ordererpb_configuration_proto_msgTypes, }.Build() File_api_ordererpb_configuration_proto = out.File - file_api_ordererpb_configuration_proto_rawDesc = nil file_api_ordererpb_configuration_proto_goTypes = nil file_api_ordererpb_configuration_proto_depIdxs = nil } diff --git a/api/ordererpb/configuration.proto b/api/ordererpb/configuration.proto index 8b4820c13..d63cc7ec8 100644 --- a/api/ordererpb/configuration.proto +++ b/api/ordererpb/configuration.proto @@ -4,9 +4,17 @@ Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ + +// The following rule disables snake names requirements for the entire file. +// It should be removed once this issue is solved. +// (-- api-linter: core::0140::lower-snake=disabled --) + syntax = "proto3"; + option go_package = "github.com/hyperledger/fabric-x-common/api/ordererpb"; +package ordererpb; + // SharedConfig holds the initial configuration that will be used to bootstrap new nodes. // This configuration is common to all Arma nodes. message SharedConfig { diff --git a/api/protomsp/msp.pb.go b/api/protomsp/msp.pb.go index 09c3cf2d5..e717432c6 100644 --- a/api/protomsp/msp.pb.go +++ b/api/protomsp/msp.pb.go @@ -5,7 +5,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.36.10 // protoc v5.29.3 // source: api/protomsp/msp.proto @@ -17,6 +17,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -35,10 +36,7 @@ const ( // it can also issue signing identities. If it does not, it can only // be used to validate and verify certificates. type FabricMSPConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Name holds the identifier of the MSP; MSP identifier // is chosen by the application that governs this MSP. // For example, and assuming the default implementation of MSP, @@ -83,16 +81,16 @@ type FabricMSPConfig struct { // based on the OUs. FabricNodeOus *msp.FabricNodeOUs `protobuf:"bytes,11,opt,name=fabric_node_ous,json=fabricNodeOus,proto3" json:"fabric_node_ous,omitempty"` // List of known certificates of this MSP. - KnownCerts [][]byte `protobuf:"bytes,12,rep,name=known_certs,json=knownCerts,proto3" json:"known_certs,omitempty"` + KnownCerts [][]byte `protobuf:"bytes,12,rep,name=known_certs,json=knownCerts,proto3" json:"known_certs,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *FabricMSPConfig) Reset() { *x = FabricMSPConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_api_protomsp_msp_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_protomsp_msp_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *FabricMSPConfig) String() string { @@ -103,7 +101,7 @@ func (*FabricMSPConfig) ProtoMessage() {} func (x *FabricMSPConfig) ProtoReflect() protoreflect.Message { mi := &file_api_protomsp_msp_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -203,26 +201,23 @@ func (x *FabricMSPConfig) GetKnownCerts() [][]byte { } type Identity struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The identifier of the associated membership service provider MspId string `protobuf:"bytes,1,opt,name=msp_id,json=mspId,proto3" json:"msp_id,omitempty"` - // Types that are assignable to Creator: + // Types that are valid to be assigned to Creator: // // *Identity_Certificate // *Identity_CertificateId - Creator isIdentity_Creator `protobuf_oneof:"creator"` + Creator isIdentity_Creator `protobuf_oneof:"creator"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Identity) Reset() { *x = Identity{} - if protoimpl.UnsafeEnabled { - mi := &file_api_protomsp_msp_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_api_protomsp_msp_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Identity) String() string { @@ -233,7 +228,7 @@ func (*Identity) ProtoMessage() {} func (x *Identity) ProtoReflect() protoreflect.Message { mi := &file_api_protomsp_msp_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -255,23 +250,27 @@ func (x *Identity) GetMspId() string { return "" } -func (m *Identity) GetCreator() isIdentity_Creator { - if m != nil { - return m.Creator +func (x *Identity) GetCreator() isIdentity_Creator { + if x != nil { + return x.Creator } return nil } func (x *Identity) GetCertificate() []byte { - if x, ok := x.GetCreator().(*Identity_Certificate); ok { - return x.Certificate + if x != nil { + if x, ok := x.Creator.(*Identity_Certificate); ok { + return x.Certificate + } } return nil } func (x *Identity) GetCertificateId() string { - if x, ok := x.GetCreator().(*Identity_CertificateId); ok { - return x.CertificateId + if x != nil { + if x, ok := x.Creator.(*Identity_CertificateId); ok { + return x.CertificateId + } } return "" } @@ -296,88 +295,57 @@ func (*Identity_CertificateId) isIdentity_Creator() {} var File_api_protomsp_msp_proto protoreflect.FileDescriptor -var file_api_protomsp_msp_proto_rawDesc = []byte{ - 0x0a, 0x16, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6d, 0x73, 0x70, 0x2f, 0x6d, - 0x73, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x74, 0x78, 0x1a, 0x14, 0x6d, 0x73, 0x70, 0x2f, 0x6d, 0x73, 0x70, 0x5f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd1, 0x04, 0x0a, - 0x0f, 0x46, 0x61, 0x62, 0x72, 0x69, 0x63, 0x4d, 0x53, 0x50, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x63, 0x65, 0x72, - 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x72, 0x6f, 0x6f, 0x74, 0x43, 0x65, - 0x72, 0x74, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, - 0x61, 0x74, 0x65, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, - 0x11, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x43, 0x65, 0x72, - 0x74, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0c, 0x52, 0x06, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x65, - 0x76, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x05, 0x20, - 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x72, 0x65, 0x76, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, - 0x69, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x10, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x69, - 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, - 0x6d, 0x73, 0x70, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x74, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0f, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x5f, 0x0a, 0x1f, 0x6f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x5f, - 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x73, 0x70, 0x2e, 0x46, 0x61, 0x62, 0x72, 0x69, 0x63, 0x4f, 0x55, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x1d, 0x6f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x55, 0x6e, 0x69, 0x74, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x73, 0x12, 0x3c, 0x0a, 0x0d, 0x63, 0x72, 0x79, - 0x70, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x17, 0x2e, 0x6d, 0x73, 0x70, 0x2e, 0x46, 0x61, 0x62, 0x72, 0x69, 0x63, 0x43, 0x72, 0x79, - 0x70, 0x74, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0c, 0x63, 0x72, 0x79, 0x70, 0x74, - 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x24, 0x0a, 0x0e, 0x74, 0x6c, 0x73, 0x5f, 0x72, - 0x6f, 0x6f, 0x74, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0c, 0x52, - 0x0c, 0x74, 0x6c, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x43, 0x65, 0x72, 0x74, 0x73, 0x12, 0x34, 0x0a, - 0x16, 0x74, 0x6c, 0x73, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, - 0x65, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x14, 0x74, - 0x6c, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x43, 0x65, - 0x72, 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x0f, 0x66, 0x61, 0x62, 0x72, 0x69, 0x63, 0x5f, 0x6e, 0x6f, - 0x64, 0x65, 0x5f, 0x6f, 0x75, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, - 0x73, 0x70, 0x2e, 0x46, 0x61, 0x62, 0x72, 0x69, 0x63, 0x4e, 0x6f, 0x64, 0x65, 0x4f, 0x55, 0x73, - 0x52, 0x0d, 0x66, 0x61, 0x62, 0x72, 0x69, 0x63, 0x4e, 0x6f, 0x64, 0x65, 0x4f, 0x75, 0x73, 0x12, - 0x1f, 0x0a, 0x0b, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x73, 0x18, 0x0c, - 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0a, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x43, 0x65, 0x72, 0x74, 0x73, - 0x22, 0x79, 0x0a, 0x08, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x15, 0x0a, 0x06, - 0x6d, 0x73, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6d, 0x73, - 0x70, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x27, 0x0a, 0x0e, 0x63, 0x65, 0x72, 0x74, 0x69, - 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, - 0x00, 0x52, 0x0d, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x49, 0x64, - 0x42, 0x09, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x42, 0x35, 0x5a, 0x33, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x79, 0x70, 0x65, 0x72, 0x6c, - 0x65, 0x64, 0x67, 0x65, 0x72, 0x2f, 0x66, 0x61, 0x62, 0x72, 0x69, 0x63, 0x2d, 0x78, 0x2d, 0x63, - 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6d, - 0x73, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_api_protomsp_msp_proto_rawDesc = "" + + "\n" + + "\x16api/protomsp/msp.proto\x12\bprotomsp\x1a\x14msp/msp_config.proto\"\xd1\x04\n" + + "\x0fFabricMSPConfig\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x1d\n" + + "\n" + + "root_certs\x18\x02 \x03(\fR\trootCerts\x12-\n" + + "\x12intermediate_certs\x18\x03 \x03(\fR\x11intermediateCerts\x12\x16\n" + + "\x06admins\x18\x04 \x03(\fR\x06admins\x12'\n" + + "\x0frevocation_list\x18\x05 \x03(\fR\x0erevocationList\x12C\n" + + "\x10signing_identity\x18\x06 \x01(\v2\x18.msp.SigningIdentityInfoR\x0fsigningIdentity\x12_\n" + + "\x1forganizational_unit_identifiers\x18\a \x03(\v2\x17.msp.FabricOUIdentifierR\x1dorganizationalUnitIdentifiers\x12<\n" + + "\rcrypto_config\x18\b \x01(\v2\x17.msp.FabricCryptoConfigR\fcryptoConfig\x12$\n" + + "\x0etls_root_certs\x18\t \x03(\fR\ftlsRootCerts\x124\n" + + "\x16tls_intermediate_certs\x18\n" + + " \x03(\fR\x14tlsIntermediateCerts\x12:\n" + + "\x0ffabric_node_ous\x18\v \x01(\v2\x12.msp.FabricNodeOUsR\rfabricNodeOus\x12\x1f\n" + + "\vknown_certs\x18\f \x03(\fR\n" + + "knownCerts\"y\n" + + "\bIdentity\x12\x15\n" + + "\x06msp_id\x18\x01 \x01(\tR\x05mspId\x12\"\n" + + "\vcertificate\x18\x02 \x01(\fH\x00R\vcertificate\x12'\n" + + "\x0ecertificate_id\x18\x03 \x01(\tH\x00R\rcertificateIdB\t\n" + + "\acreatorB5Z3github.com/hyperledger/fabric-x-common/api/protomspb\x06proto3" var ( file_api_protomsp_msp_proto_rawDescOnce sync.Once - file_api_protomsp_msp_proto_rawDescData = file_api_protomsp_msp_proto_rawDesc + file_api_protomsp_msp_proto_rawDescData []byte ) func file_api_protomsp_msp_proto_rawDescGZIP() []byte { file_api_protomsp_msp_proto_rawDescOnce.Do(func() { - file_api_protomsp_msp_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_protomsp_msp_proto_rawDescData) + file_api_protomsp_msp_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_protomsp_msp_proto_rawDesc), len(file_api_protomsp_msp_proto_rawDesc))) }) return file_api_protomsp_msp_proto_rawDescData } var file_api_protomsp_msp_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_api_protomsp_msp_proto_goTypes = []interface{}{ - (*FabricMSPConfig)(nil), // 0: protoblocktx.FabricMSPConfig - (*Identity)(nil), // 1: protoblocktx.Identity +var file_api_protomsp_msp_proto_goTypes = []any{ + (*FabricMSPConfig)(nil), // 0: protomsp.FabricMSPConfig + (*Identity)(nil), // 1: protomsp.Identity (*msp.SigningIdentityInfo)(nil), // 2: msp.SigningIdentityInfo (*msp.FabricOUIdentifier)(nil), // 3: msp.FabricOUIdentifier (*msp.FabricCryptoConfig)(nil), // 4: msp.FabricCryptoConfig (*msp.FabricNodeOUs)(nil), // 5: msp.FabricNodeOUs } var file_api_protomsp_msp_proto_depIdxs = []int32{ - 2, // 0: protoblocktx.FabricMSPConfig.signing_identity:type_name -> msp.SigningIdentityInfo - 3, // 1: protoblocktx.FabricMSPConfig.organizational_unit_identifiers:type_name -> msp.FabricOUIdentifier - 4, // 2: protoblocktx.FabricMSPConfig.crypto_config:type_name -> msp.FabricCryptoConfig - 5, // 3: protoblocktx.FabricMSPConfig.fabric_node_ous:type_name -> msp.FabricNodeOUs + 2, // 0: protomsp.FabricMSPConfig.signing_identity:type_name -> msp.SigningIdentityInfo + 3, // 1: protomsp.FabricMSPConfig.organizational_unit_identifiers:type_name -> msp.FabricOUIdentifier + 4, // 2: protomsp.FabricMSPConfig.crypto_config:type_name -> msp.FabricCryptoConfig + 5, // 3: protomsp.FabricMSPConfig.fabric_node_ous:type_name -> msp.FabricNodeOUs 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name @@ -390,33 +358,7 @@ func file_api_protomsp_msp_proto_init() { if File_api_protomsp_msp_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_api_protomsp_msp_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FabricMSPConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_protomsp_msp_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Identity); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_api_protomsp_msp_proto_msgTypes[1].OneofWrappers = []interface{}{ + file_api_protomsp_msp_proto_msgTypes[1].OneofWrappers = []any{ (*Identity_Certificate)(nil), (*Identity_CertificateId)(nil), } @@ -424,7 +366,7 @@ func file_api_protomsp_msp_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_api_protomsp_msp_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_protomsp_msp_proto_rawDesc), len(file_api_protomsp_msp_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -435,7 +377,6 @@ func file_api_protomsp_msp_proto_init() { MessageInfos: file_api_protomsp_msp_proto_msgTypes, }.Build() File_api_protomsp_msp_proto = out.File - file_api_protomsp_msp_proto_rawDesc = nil file_api_protomsp_msp_proto_goTypes = nil file_api_protomsp_msp_proto_depIdxs = nil } diff --git a/api/protomsp/msp.proto b/api/protomsp/msp.proto index 2081d874b..644b35c79 100644 --- a/api/protomsp/msp.proto +++ b/api/protomsp/msp.proto @@ -8,7 +8,7 @@ syntax = "proto3"; option go_package = "github.com/hyperledger/fabric-x-common/api/protomsp"; -package protoblocktx; +package protomsp; import "msp/msp_config.proto"; diff --git a/common/grpcmetrics/testpb/echo.pb.go b/common/grpcmetrics/testpb/echo.pb.go index ce957176c..8972d8717 100644 --- a/common/grpcmetrics/testpb/echo.pb.go +++ b/common/grpcmetrics/testpb/echo.pb.go @@ -5,7 +5,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.36.10 // protoc v5.29.3 // source: echo.proto @@ -16,6 +16,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -26,21 +27,18 @@ const ( ) type Message struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Sequence int32 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` - Sequence int32 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Message) Reset() { *x = Message{} - if protoimpl.UnsafeEnabled { - mi := &file_echo_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_echo_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Message) String() string { @@ -51,7 +49,7 @@ func (*Message) ProtoMessage() {} func (x *Message) ProtoReflect() protoreflect.Message { mi := &file_echo_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -82,40 +80,32 @@ func (x *Message) GetSequence() int32 { var File_echo_proto protoreflect.FileDescriptor -var file_echo_proto_rawDesc = []byte{ - 0x0a, 0x0a, 0x65, 0x63, 0x68, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x74, 0x65, - 0x73, 0x74, 0x70, 0x62, 0x22, 0x3f, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, - 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x73, 0x65, 0x71, - 0x75, 0x65, 0x6e, 0x63, 0x65, 0x32, 0x6b, 0x0a, 0x0b, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x0f, 0x2e, 0x74, - 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x0f, 0x2e, - 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x32, - 0x0a, 0x0a, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x0f, 0x2e, 0x74, - 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x0f, 0x2e, - 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x28, 0x01, - 0x30, 0x01, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x68, 0x79, 0x70, 0x65, 0x72, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x72, 0x2f, 0x66, 0x61, 0x62, - 0x72, 0x69, 0x63, 0x2d, 0x78, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x63, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, - 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_echo_proto_rawDesc = "" + + "\n" + + "\n" + + "echo.proto\x12\x06testpb\"?\n" + + "\aMessage\x12\x18\n" + + "\amessage\x18\x01 \x01(\tR\amessage\x12\x1a\n" + + "\bsequence\x18\x02 \x01(\x05R\bsequence2k\n" + + "\vEchoService\x12(\n" + + "\x04Echo\x12\x0f.testpb.Message\x1a\x0f.testpb.Message\x122\n" + + "\n" + + "EchoStream\x12\x0f.testpb.Message\x1a\x0f.testpb.Message(\x010\x01BBZ@github.com/hyperledger/fabric-x-common/common/grpcmetrics/testpbb\x06proto3" var ( file_echo_proto_rawDescOnce sync.Once - file_echo_proto_rawDescData = file_echo_proto_rawDesc + file_echo_proto_rawDescData []byte ) func file_echo_proto_rawDescGZIP() []byte { file_echo_proto_rawDescOnce.Do(func() { - file_echo_proto_rawDescData = protoimpl.X.CompressGZIP(file_echo_proto_rawDescData) + file_echo_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_echo_proto_rawDesc), len(file_echo_proto_rawDesc))) }) return file_echo_proto_rawDescData } var file_echo_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_echo_proto_goTypes = []interface{}{ +var file_echo_proto_goTypes = []any{ (*Message)(nil), // 0: testpb.Message } var file_echo_proto_depIdxs = []int32{ @@ -135,25 +125,11 @@ func file_echo_proto_init() { if File_echo_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_echo_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Message); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_echo_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_echo_proto_rawDesc), len(file_echo_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -164,7 +140,6 @@ func file_echo_proto_init() { MessageInfos: file_echo_proto_msgTypes, }.Build() File_echo_proto = out.File - file_echo_proto_rawDesc = nil file_echo_proto_goTypes = nil file_echo_proto_depIdxs = nil } diff --git a/scripts/install-dev-dependencies.sh b/scripts/install-dev-dependencies.sh index 0936b952b..32b9b1cd6 100755 --- a/scripts/install-dev-dependencies.sh +++ b/scripts/install-dev-dependencies.sh @@ -8,12 +8,13 @@ set -e # Versions protoc_bin_version="29.3" -protoc_gen_go_version="v1.33" +protoc_gen_go_version="v1.36.10" protoc_gen_go_grpc_version="v1.3" goimports_version="v0.33.0" -golang_ci_version="v2.7.2" gotestfmt_version="v2.5.0" +golang_ci_version="v2.7.2" gofumpt_version="v0.9.2" +api_linter_version="v2.1.0" mockery_version="v2.53.5" download_dir=$(mktemp -d -t "sc_dev_depedencies.XXXX") @@ -38,6 +39,9 @@ go install "google.golang.org/grpc/cmd/protoc-gen-go-grpc@${protoc_gen_go_grpc_v echo echo "Installing goimports" go install "golang.org/x/tools/cmd/goimports@${goimports_version}" +echo +echo "Installing api-linter" +go install "github.com/googleapis/api-linter/v2/cmd/api-linter@${api_linter_version}" echo echo "Installing golangci-lint" diff --git a/tools/pkg/comm/testpb/test.pb.go b/tools/pkg/comm/testpb/test.pb.go index 1cd46d319..737847eea 100644 --- a/tools/pkg/comm/testpb/test.pb.go +++ b/tools/pkg/comm/testpb/test.pb.go @@ -5,7 +5,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.36.10 // protoc v5.29.3 // source: test.proto @@ -16,6 +16,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -26,18 +27,16 @@ const ( ) type Empty struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Empty) Reset() { *x = Empty{} - if protoimpl.UnsafeEnabled { - mi := &file_test_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Empty) String() string { @@ -48,7 +47,7 @@ func (*Empty) ProtoMessage() {} func (x *Empty) ProtoReflect() protoreflect.Message { mi := &file_test_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -64,20 +63,17 @@ func (*Empty) Descriptor() ([]byte, []int) { } type Echo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` unknownFields protoimpl.UnknownFields - - Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Echo) Reset() { *x = Echo{} - if protoimpl.UnsafeEnabled { - mi := &file_test_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Echo) String() string { @@ -88,7 +84,7 @@ func (*Echo) ProtoMessage() {} func (x *Echo) ProtoReflect() protoreflect.Message { mi := &file_test_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -112,41 +108,35 @@ func (x *Echo) GetPayload() []byte { var File_test_proto protoreflect.FileDescriptor -var file_test_proto_rawDesc = []byte{ - 0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x07, 0x0a, 0x05, - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x20, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x18, 0x0a, - 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, - 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x32, 0x2a, 0x0a, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x43, - 0x61, 0x6c, 0x6c, 0x12, 0x06, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x06, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x32, 0x4e, 0x0a, 0x0c, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x43, 0x61, 0x6c, 0x6c, - 0x12, 0x06, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x06, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x12, 0x21, 0x0a, 0x0b, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, - 0x06, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x06, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x28, - 0x01, 0x30, 0x01, 0x32, 0x27, 0x0a, 0x0b, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x18, 0x0a, 0x08, 0x45, 0x63, 0x68, 0x6f, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x05, - 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x1a, 0x05, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x42, 0x39, 0x5a, 0x37, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x79, 0x70, 0x65, 0x72, - 0x6c, 0x65, 0x64, 0x67, 0x65, 0x72, 0x2f, 0x66, 0x61, 0x62, 0x72, 0x69, 0x63, 0x2d, 0x78, 0x2d, - 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, - 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_test_proto_rawDesc = "" + + "\n" + + "\n" + + "test.proto\"\a\n" + + "\x05Empty\" \n" + + "\x04Echo\x12\x18\n" + + "\apayload\x18\x01 \x01(\fR\apayload2*\n" + + "\vTestService\x12\x1b\n" + + "\tEmptyCall\x12\x06.Empty\x1a\x06.Empty2N\n" + + "\fEmptyService\x12\x1b\n" + + "\tEmptyCall\x12\x06.Empty\x1a\x06.Empty\x12!\n" + + "\vEmptyStream\x12\x06.Empty\x1a\x06.Empty(\x010\x012'\n" + + "\vEchoService\x12\x18\n" + + "\bEchoCall\x12\x05.Echo\x1a\x05.EchoB9Z7github.com/hyperledger/fabric-x-common/core/comm/testpbb\x06proto3" var ( file_test_proto_rawDescOnce sync.Once - file_test_proto_rawDescData = file_test_proto_rawDesc + file_test_proto_rawDescData []byte ) func file_test_proto_rawDescGZIP() []byte { file_test_proto_rawDescOnce.Do(func() { - file_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_proto_rawDescData) + file_test_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_test_proto_rawDesc), len(file_test_proto_rawDesc))) }) return file_test_proto_rawDescData } var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_test_proto_goTypes = []interface{}{ +var file_test_proto_goTypes = []any{ (*Empty)(nil), // 0: Empty (*Echo)(nil), // 1: Echo } @@ -171,37 +161,11 @@ func file_test_proto_init() { if File_test_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Empty); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Echo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_test_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_test_proto_rawDesc), len(file_test_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -212,7 +176,6 @@ func file_test_proto_init() { MessageInfos: file_test_proto_msgTypes, }.Build() File_test_proto = out.File - file_test_proto_rawDesc = nil file_test_proto_goTypes = nil file_test_proto_depIdxs = nil } diff --git a/utils/test/require.go b/utils/test/require.go new file mode 100644 index 000000000..4c1871484 --- /dev/null +++ b/utils/test/require.go @@ -0,0 +1,104 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package test + +import ( + "bytes" + "fmt" + + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" +) + +type tHelper = interface { + Helper() +} + +// RequireProtoEqual verifies that two proto are equal. +func RequireProtoEqual(t require.TestingT, expected, actual proto.Message) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + require.Truef( + t, + proto.Equal(expected, actual), + "EXPECTED: %v\nACTUAL: %v", + protojson.Format(expected), + protojson.Format(actual), + ) +} + +// RequireProtoElementsMatch verifies that two arrays of proto have the same elements. +func RequireProtoElementsMatch[T proto.Message]( + t require.TestingT, expected, actual []T, msgAndArgs ...any, +) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if expected == nil { + require.Nil(t, actual, msgAndArgs...) + return + } + if msg, haveDiff := protoElemDiff(expected, actual); haveDiff { + require.Fail(t, msg, msgAndArgs...) + } +} + +func protoElemDiff[T proto.Message](expected, actual []T) (string, bool) { //nolint:gocognit // cognitive complexity 23 + var msg bytes.Buffer + if len(expected) != len(actual) { + msg.WriteString(fmt.Sprintf("\nSIZE MISMATCH: expected=%d != actual=%d\n", len(expected), len(actual))) + } + expectedMatched := make([]bool, len(expected)) + actualMatched := make([]bool, len(actual)) + for aInd, aElem := range actual { + for eInd, eElem := range expected { + if expectedMatched[eInd] { + continue + } + if proto.Equal(eElem, aElem) { + expectedMatched[eInd] = true + actualMatched[aInd] = true + break + } + } + } + + var missing []string + for eInd, eElem := range expected { + if !expectedMatched[eInd] { + missing = append(missing, protojson.Format(eElem)) + } + } + var extra []string + for aInd, aElem := range actual { + if !actualMatched[aInd] { + extra = append(extra, protojson.Format(aElem)) + } + } + + if len(extra) == 0 && len(missing) == 0 { + return "", false + } + + if len(extra) > 0 { + msg.WriteString(fmt.Sprintf("\nEXTRA ELEMENTS (%d):\n\n", len(extra))) + for _, extraElem := range extra { + msg.WriteString(extraElem) + msg.WriteString("\n") + } + } + if len(missing) > 0 { + msg.WriteString(fmt.Sprintf("\n\nMISSING ELEMENTS (%d):\n\n", len(missing))) + for _, missingElem := range missing { + msg.WriteString(missingElem) + msg.WriteString("\n") + } + } + return msg.String(), true +} diff --git a/utils/test/require_test.go b/utils/test/require_test.go new file mode 100644 index 000000000..36a975c67 --- /dev/null +++ b/utils/test/require_test.go @@ -0,0 +1,49 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + + "google.golang.org/protobuf/types/known/durationpb" +) + +func TestRequireProtoEqual(t *testing.T) { + t.Parallel() + a := durationpb.New(5 * time.Minute) + RequireProtoEqual(t, a, a) + b := proto.Clone(a) + RequireProtoEqual(t, a, b) + c := durationpb.New(5 * time.Minute) + RequireProtoEqual(t, a, c) +} + +func TestProtoDiff(t *testing.T) { + t.Parallel() + a := []*durationpb.Duration{ + durationpb.New(5 * time.Minute), durationpb.New(10 * time.Minute), + } + msg, haveDiff := protoElemDiff(a, a) + require.False(t, haveDiff, msg) + + b := []*durationpb.Duration{ + durationpb.New(5 * time.Minute), durationpb.New(10 * time.Minute), + } + msg, haveDiff = protoElemDiff(a, b) + require.False(t, haveDiff, msg) + + c := []*durationpb.Duration{ + durationpb.New(10 * time.Minute), durationpb.New(20 * time.Minute), + } + msg, haveDiff = protoElemDiff(a, c) + require.True(t, haveDiff, msg) + t.Log(msg) +}