From 4e85206b174ca2a133b83545e689d1e3470a9f66 Mon Sep 17 00:00:00 2001 From: David VIEJO Date: Wed, 11 Oct 2023 17:30:32 +0200 Subject: [PATCH 01/10] Add support for ConsensusTypeBFT in the orderer.go Signed-off-by: David VIEJO --- configtx/orderer.go | 92 +++++++++++++++++++++++++++++++++++++ configtx/orderer/orderer.go | 3 ++ 2 files changed, 95 insertions(+) diff --git a/configtx/orderer.go b/configtx/orderer.go index 650e91e..885e907 100644 --- a/configtx/orderer.go +++ b/configtx/orderer.go @@ -16,10 +16,14 @@ import ( "time" "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/configtx/internal/policydsl" "github.com/hyperledger/fabric-config/configtx/orderer" + "github.com/hyperledger/fabric-protos-go/common" cb "github.com/hyperledger/fabric-protos-go/common" + mspa "github.com/hyperledger/fabric-protos-go/msp" ob "github.com/hyperledger/fabric-protos-go/orderer" eb "github.com/hyperledger/fabric-protos-go/orderer/etcdraft" + sb "github.com/hyperledger/fabric-protos-go/orderer/smartbft" ) const ( @@ -38,6 +42,9 @@ type Orderer struct { Kafka orderer.Kafka EtcdRaft orderer.EtcdRaft Organizations []Organization + + SmartBFT *sb.Options + ConsenterMapping []common.Consenter // MaxChannels is the maximum count of channels an orderer supports. MaxChannels uint64 // Capabilities is a map of the capabilities the orderer supports. @@ -821,6 +828,36 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { if consensusMetadata, err = marshalEtcdRaftMetadata(o.EtcdRaft); err != nil { return fmt.Errorf("marshaling etcdraft metadata for orderer type '%s': %v", orderer.ConsensusTypeEtcdRaft, err) } + case orderer.ConsensusTypeBFT: + consenterMapping := []*cb.Consenter{} + for _, consenter := range o.ConsenterMapping { + consenterMapping = append(consenterMapping, &cb.Consenter{ + Id: consenter.Id, + Host: consenter.Host, + Port: consenter.Port, + MspId: consenter.MspId, + Identity: consenter.Identity, + ClientTlsCert: consenter.ClientTlsCert, + ServerTlsCert: consenter.ServerTlsCert, + }) + } + consentersProto, err := proto.Marshal(&cb.Orderers{ + ConsenterMapping: consenterMapping, + }) + if err != nil { + return fmt.Errorf("marshaling consenters for orderer type '%s': %v", orderer.ConsensusTypeBFT, err) + } + + ordererGroup.Values["Orderers"] = &cb.ConfigValue{ + Value: consentersProto, + ModPolicy: "Admins", + } + // addValue(ordererGroup, channelconfig.OrderersValue(consenterProtos), channelconfig.AdminsPolicyKey) + if consensusMetadata, err = MarshalBFTOptions(o.SmartBFT); err != nil { + return fmt.Errorf("consenter options read failed with error %s for orderer type %s", err, orderer.ConsensusTypeBFT) + } + // Overwrite policy manually by computing it from the consenters + EncodeBFTBlockVerificationPolicy(o.ConsenterMapping, ordererGroup) default: return fmt.Errorf("unknown orderer type '%s'", o.OrdererType) } @@ -838,6 +875,15 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { return nil } +// MarshalBFTOptions serializes smartbft options. +func MarshalBFTOptions(op *sb.Options) ([]byte, error) { + if copyMd, ok := proto.Clone(op).(*sb.Options); ok { + return proto.Marshal(copyMd) + } else { + return nil, errors.New("consenter options type mismatch") + } +} + // setOrdererPolicies adds *cb.ConfigPolicies to the passed Orderer *cb.ConfigGroup's Policies map. // It checks that the BlockValidation policy is defined alongside the standard policy checks. func setOrdererPolicies(cg *cb.ConfigGroup, policyMap map[string]Policy, modPolicy string) error { @@ -1060,3 +1106,49 @@ func blockDataHashingStructureValue() *standardConfigValue { }, } } + +func EncodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordererGroup *cb.ConfigGroup) error { + n := len(consenterProtos) + f := (n - 1) / 3 + + var identities []*mspa.MSPPrincipal + var pols []*cb.SignaturePolicy + for i, consenter := range consenterProtos { + pols = append(pols, &cb.SignaturePolicy{ + Type: &cb.SignaturePolicy_SignedBy{ + SignedBy: int32(i), + }, + }) + principalBytes, err := proto.Marshal(&mspa.SerializedIdentity{Mspid: consenter.MspId, IdBytes: consenter.Identity}) + if err != nil { + return err + } + identities = append(identities, &mspa.MSPPrincipal{ + PrincipalClassification: mspa.MSPPrincipal_IDENTITY, + Principal: principalBytes, + }) + } + + quorumSize := ComputeBFTQuorum(n, f) + sp := &cb.SignaturePolicyEnvelope{ + Rule: policydsl.NOutOf(int32(quorumSize), pols), + Identities: identities, + } + policyValue, err := proto.Marshal(sp) + if err != nil { + return err + } + ordererGroup.Policies[BlockValidationPolicyKey] = &cb.ConfigPolicy{ + // Inherit modification policy + ModPolicy: ordererGroup.Policies[BlockValidationPolicyKey].ModPolicy, + Policy: &cb.Policy{ + Type: int32(cb.Policy_SIGNATURE), + Value: policyValue, + }, + } + return nil +} + +func ComputeBFTQuorum(totalNodes, faultyNodes int) int { + return int(math.Ceil(float64(totalNodes+faultyNodes+1) / 2)) +} diff --git a/configtx/orderer/orderer.go b/configtx/orderer/orderer.go index 5ece74c..252c3db 100644 --- a/configtx/orderer/orderer.go +++ b/configtx/orderer/orderer.go @@ -28,6 +28,9 @@ const ( // ConsensusTypeEtcdRaft identifies the Raft-based consensus implementation. ConsensusTypeEtcdRaft = "etcdraft" + // ConsensusTypeBFT identifies the SmartBFT-based consensus implementation. + ConsensusTypeBFT = "BFT" + // KafkaBrokersKey is the common.ConfigValue type key name for the KafkaBrokers message. // Deprecated: the kafka consensus type is no longer supported KafkaBrokersKey = "KafkaBrokers" From e61bb40ee0863952b95a637b98a004b7570e1e98 Mon Sep 17 00:00:00 2001 From: David VIEJO Date: Wed, 11 Oct 2023 17:42:51 +0200 Subject: [PATCH 02/10] fix lint errors Signed-off-by: David VIEJO --- configtx/orderer.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/configtx/orderer.go b/configtx/orderer.go index 885e907..a5c3333 100644 --- a/configtx/orderer.go +++ b/configtx/orderer.go @@ -857,7 +857,7 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { return fmt.Errorf("consenter options read failed with error %s for orderer type %s", err, orderer.ConsensusTypeBFT) } // Overwrite policy manually by computing it from the consenters - EncodeBFTBlockVerificationPolicy(o.ConsenterMapping, ordererGroup) + encodeBFTBlockVerificationPolicy(o.ConsenterMapping, ordererGroup) default: return fmt.Errorf("unknown orderer type '%s'", o.OrdererType) } @@ -879,9 +879,8 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { func MarshalBFTOptions(op *sb.Options) ([]byte, error) { if copyMd, ok := proto.Clone(op).(*sb.Options); ok { return proto.Marshal(copyMd) - } else { - return nil, errors.New("consenter options type mismatch") } + return nil, errors.New("consenter options type mismatch") } // setOrdererPolicies adds *cb.ConfigPolicies to the passed Orderer *cb.ConfigGroup's Policies map. @@ -1107,7 +1106,7 @@ func blockDataHashingStructureValue() *standardConfigValue { } } -func EncodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordererGroup *cb.ConfigGroup) error { +func encodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordererGroup *cb.ConfigGroup) error { n := len(consenterProtos) f := (n - 1) / 3 @@ -1129,7 +1128,7 @@ func EncodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordere }) } - quorumSize := ComputeBFTQuorum(n, f) + quorumSize := computeBFTQuorum(n, f) sp := &cb.SignaturePolicyEnvelope{ Rule: policydsl.NOutOf(int32(quorumSize), pols), Identities: identities, @@ -1149,6 +1148,6 @@ func EncodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordere return nil } -func ComputeBFTQuorum(totalNodes, faultyNodes int) int { +func computeBFTQuorum(totalNodes, faultyNodes int) int { return int(math.Ceil(float64(totalNodes+faultyNodes+1) / 2)) } From 3f92a9f58af33a2cdd59eb47d58cf7b52e45c2c9 Mon Sep 17 00:00:00 2001 From: David VIEJO Date: Wed, 11 Oct 2023 17:30:32 +0200 Subject: [PATCH 03/10] Add support for ConsensusTypeBFT in the orderer.go Signed-off-by: David VIEJO --- configtx/orderer.go | 92 +++++++++++++++++++++++++++++++++++++ configtx/orderer/orderer.go | 3 ++ 2 files changed, 95 insertions(+) diff --git a/configtx/orderer.go b/configtx/orderer.go index 650e91e..885e907 100644 --- a/configtx/orderer.go +++ b/configtx/orderer.go @@ -16,10 +16,14 @@ import ( "time" "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/configtx/internal/policydsl" "github.com/hyperledger/fabric-config/configtx/orderer" + "github.com/hyperledger/fabric-protos-go/common" cb "github.com/hyperledger/fabric-protos-go/common" + mspa "github.com/hyperledger/fabric-protos-go/msp" ob "github.com/hyperledger/fabric-protos-go/orderer" eb "github.com/hyperledger/fabric-protos-go/orderer/etcdraft" + sb "github.com/hyperledger/fabric-protos-go/orderer/smartbft" ) const ( @@ -38,6 +42,9 @@ type Orderer struct { Kafka orderer.Kafka EtcdRaft orderer.EtcdRaft Organizations []Organization + + SmartBFT *sb.Options + ConsenterMapping []common.Consenter // MaxChannels is the maximum count of channels an orderer supports. MaxChannels uint64 // Capabilities is a map of the capabilities the orderer supports. @@ -821,6 +828,36 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { if consensusMetadata, err = marshalEtcdRaftMetadata(o.EtcdRaft); err != nil { return fmt.Errorf("marshaling etcdraft metadata for orderer type '%s': %v", orderer.ConsensusTypeEtcdRaft, err) } + case orderer.ConsensusTypeBFT: + consenterMapping := []*cb.Consenter{} + for _, consenter := range o.ConsenterMapping { + consenterMapping = append(consenterMapping, &cb.Consenter{ + Id: consenter.Id, + Host: consenter.Host, + Port: consenter.Port, + MspId: consenter.MspId, + Identity: consenter.Identity, + ClientTlsCert: consenter.ClientTlsCert, + ServerTlsCert: consenter.ServerTlsCert, + }) + } + consentersProto, err := proto.Marshal(&cb.Orderers{ + ConsenterMapping: consenterMapping, + }) + if err != nil { + return fmt.Errorf("marshaling consenters for orderer type '%s': %v", orderer.ConsensusTypeBFT, err) + } + + ordererGroup.Values["Orderers"] = &cb.ConfigValue{ + Value: consentersProto, + ModPolicy: "Admins", + } + // addValue(ordererGroup, channelconfig.OrderersValue(consenterProtos), channelconfig.AdminsPolicyKey) + if consensusMetadata, err = MarshalBFTOptions(o.SmartBFT); err != nil { + return fmt.Errorf("consenter options read failed with error %s for orderer type %s", err, orderer.ConsensusTypeBFT) + } + // Overwrite policy manually by computing it from the consenters + EncodeBFTBlockVerificationPolicy(o.ConsenterMapping, ordererGroup) default: return fmt.Errorf("unknown orderer type '%s'", o.OrdererType) } @@ -838,6 +875,15 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { return nil } +// MarshalBFTOptions serializes smartbft options. +func MarshalBFTOptions(op *sb.Options) ([]byte, error) { + if copyMd, ok := proto.Clone(op).(*sb.Options); ok { + return proto.Marshal(copyMd) + } else { + return nil, errors.New("consenter options type mismatch") + } +} + // setOrdererPolicies adds *cb.ConfigPolicies to the passed Orderer *cb.ConfigGroup's Policies map. // It checks that the BlockValidation policy is defined alongside the standard policy checks. func setOrdererPolicies(cg *cb.ConfigGroup, policyMap map[string]Policy, modPolicy string) error { @@ -1060,3 +1106,49 @@ func blockDataHashingStructureValue() *standardConfigValue { }, } } + +func EncodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordererGroup *cb.ConfigGroup) error { + n := len(consenterProtos) + f := (n - 1) / 3 + + var identities []*mspa.MSPPrincipal + var pols []*cb.SignaturePolicy + for i, consenter := range consenterProtos { + pols = append(pols, &cb.SignaturePolicy{ + Type: &cb.SignaturePolicy_SignedBy{ + SignedBy: int32(i), + }, + }) + principalBytes, err := proto.Marshal(&mspa.SerializedIdentity{Mspid: consenter.MspId, IdBytes: consenter.Identity}) + if err != nil { + return err + } + identities = append(identities, &mspa.MSPPrincipal{ + PrincipalClassification: mspa.MSPPrincipal_IDENTITY, + Principal: principalBytes, + }) + } + + quorumSize := ComputeBFTQuorum(n, f) + sp := &cb.SignaturePolicyEnvelope{ + Rule: policydsl.NOutOf(int32(quorumSize), pols), + Identities: identities, + } + policyValue, err := proto.Marshal(sp) + if err != nil { + return err + } + ordererGroup.Policies[BlockValidationPolicyKey] = &cb.ConfigPolicy{ + // Inherit modification policy + ModPolicy: ordererGroup.Policies[BlockValidationPolicyKey].ModPolicy, + Policy: &cb.Policy{ + Type: int32(cb.Policy_SIGNATURE), + Value: policyValue, + }, + } + return nil +} + +func ComputeBFTQuorum(totalNodes, faultyNodes int) int { + return int(math.Ceil(float64(totalNodes+faultyNodes+1) / 2)) +} diff --git a/configtx/orderer/orderer.go b/configtx/orderer/orderer.go index 5ece74c..252c3db 100644 --- a/configtx/orderer/orderer.go +++ b/configtx/orderer/orderer.go @@ -28,6 +28,9 @@ const ( // ConsensusTypeEtcdRaft identifies the Raft-based consensus implementation. ConsensusTypeEtcdRaft = "etcdraft" + // ConsensusTypeBFT identifies the SmartBFT-based consensus implementation. + ConsensusTypeBFT = "BFT" + // KafkaBrokersKey is the common.ConfigValue type key name for the KafkaBrokers message. // Deprecated: the kafka consensus type is no longer supported KafkaBrokersKey = "KafkaBrokers" From 023c0b6bf07b27ad002118df5b8a7d12ffa656db Mon Sep 17 00:00:00 2001 From: David VIEJO Date: Wed, 11 Oct 2023 17:42:51 +0200 Subject: [PATCH 04/10] fix lint errors Signed-off-by: David VIEJO --- configtx/orderer.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/configtx/orderer.go b/configtx/orderer.go index 885e907..a5c3333 100644 --- a/configtx/orderer.go +++ b/configtx/orderer.go @@ -857,7 +857,7 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { return fmt.Errorf("consenter options read failed with error %s for orderer type %s", err, orderer.ConsensusTypeBFT) } // Overwrite policy manually by computing it from the consenters - EncodeBFTBlockVerificationPolicy(o.ConsenterMapping, ordererGroup) + encodeBFTBlockVerificationPolicy(o.ConsenterMapping, ordererGroup) default: return fmt.Errorf("unknown orderer type '%s'", o.OrdererType) } @@ -879,9 +879,8 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { func MarshalBFTOptions(op *sb.Options) ([]byte, error) { if copyMd, ok := proto.Clone(op).(*sb.Options); ok { return proto.Marshal(copyMd) - } else { - return nil, errors.New("consenter options type mismatch") } + return nil, errors.New("consenter options type mismatch") } // setOrdererPolicies adds *cb.ConfigPolicies to the passed Orderer *cb.ConfigGroup's Policies map. @@ -1107,7 +1106,7 @@ func blockDataHashingStructureValue() *standardConfigValue { } } -func EncodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordererGroup *cb.ConfigGroup) error { +func encodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordererGroup *cb.ConfigGroup) error { n := len(consenterProtos) f := (n - 1) / 3 @@ -1129,7 +1128,7 @@ func EncodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordere }) } - quorumSize := ComputeBFTQuorum(n, f) + quorumSize := computeBFTQuorum(n, f) sp := &cb.SignaturePolicyEnvelope{ Rule: policydsl.NOutOf(int32(quorumSize), pols), Identities: identities, @@ -1149,6 +1148,6 @@ func EncodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordere return nil } -func ComputeBFTQuorum(totalNodes, faultyNodes int) int { +func computeBFTQuorum(totalNodes, faultyNodes int) int { return int(math.Ceil(float64(totalNodes+faultyNodes+1) / 2)) } From a7e02f73ec582a9d52c4d23db93f5e9118114106 Mon Sep 17 00:00:00 2001 From: David VIEJO Date: Thu, 18 Jan 2024 18:35:42 +0100 Subject: [PATCH 05/10] Unmarshall metadata Signed-off-by: David VIEJO --- configtx/orderer.go | 66 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/configtx/orderer.go b/configtx/orderer.go index a5c3333..9c44178 100644 --- a/configtx/orderer.go +++ b/configtx/orderer.go @@ -108,6 +108,7 @@ func (o *OrdererGroup) Organization(name string) *OrdererOrg { func (o *OrdererGroup) Configuration() (Orderer, error) { // CONSENSUS TYPE, STATE, AND METADATA var etcdRaft orderer.EtcdRaft + var smartBFT *sb.Options kafkaBrokers := orderer.Kafka{} consensusTypeProto := &ob.ConsensusType{} @@ -139,6 +140,11 @@ func (o *OrdererGroup) Configuration() (Orderer, error) { if err != nil { return Orderer{}, fmt.Errorf("unmarshaling etcd raft metadata: %v", err) } + case orderer.ConsensusTypeBFT: + smartBFT, err = unmarshalSmartBFTOptions(consensusTypeProto.Metadata) + if err != nil { + return Orderer{}, fmt.Errorf("unmarshaling smart BFT options: %v", err) + } default: return Orderer{}, fmt.Errorf("config contains unknown consensus type '%s'", consensusTypeProto.Type) } @@ -160,6 +166,27 @@ func (o *OrdererGroup) Configuration() (Orderer, error) { if err != nil { return Orderer{}, fmt.Errorf("batch timeout configuration '%s' is not a duration string", batchTimeoutProto.Timeout) } + orderersConfigValue, ok := o.ordererGroup.Values["Orderers"] + if !ok { + return Orderer{}, errors.New("unable to find orderers for orderer org") + } + orderers := cb.Orderers{} + err = proto.Unmarshal(orderersConfigValue.Value, &orderers) + if err != nil { + return Orderer{}, fmt.Errorf("unmarshaling orderers: %v", err) + } + var consenterMapping []common.Consenter + for _, consenterItem := range orderers.ConsenterMapping { + consenterMapping = append(consenterMapping, common.Consenter{ + Id: consenterItem.Id, + Host: consenterItem.Host, + Port: consenterItem.Port, + MspId: consenterItem.MspId, + Identity: consenterItem.Identity, + ClientTlsCert: consenterItem.ClientTlsCert, + ServerTlsCert: consenterItem.ServerTlsCert, + }) + } // ORDERER ORGS var ordererOrgs []Organization @@ -199,14 +226,16 @@ func (o *OrdererGroup) Configuration() (Orderer, error) { AbsoluteMaxBytes: batchSize.AbsoluteMaxBytes, PreferredMaxBytes: batchSize.PreferredMaxBytes, }, - Kafka: kafkaBrokers, - EtcdRaft: etcdRaft, - Organizations: ordererOrgs, - MaxChannels: channelRestrictions.MaxCount, - Capabilities: capabilities, - Policies: policies, - State: state, - ModPolicy: o.ordererGroup.GetModPolicy(), + Kafka: kafkaBrokers, + EtcdRaft: etcdRaft, + ConsenterMapping: consenterMapping, + SmartBFT: smartBFT, + Organizations: ordererOrgs, + MaxChannels: channelRestrictions.MaxCount, + Capabilities: capabilities, + Policies: policies, + State: state, + ModPolicy: o.ordererGroup.GetModPolicy(), }, nil } @@ -853,11 +882,14 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { ModPolicy: "Admins", } // addValue(ordererGroup, channelconfig.OrderersValue(consenterProtos), channelconfig.AdminsPolicyKey) - if consensusMetadata, err = MarshalBFTOptions(o.SmartBFT); err != nil { + if consensusMetadata, err = marshalBFTOptions(o.SmartBFT); err != nil { return fmt.Errorf("consenter options read failed with error %s for orderer type %s", err, orderer.ConsensusTypeBFT) } // Overwrite policy manually by computing it from the consenters - encodeBFTBlockVerificationPolicy(o.ConsenterMapping, ordererGroup) + err = encodeBFTBlockVerificationPolicy(o.ConsenterMapping, ordererGroup) + if err != nil { + return fmt.Errorf("failed to encode BFT block verification policy: %v", err) + } default: return fmt.Errorf("unknown orderer type '%s'", o.OrdererType) } @@ -875,8 +907,8 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { return nil } -// MarshalBFTOptions serializes smartbft options. -func MarshalBFTOptions(op *sb.Options) ([]byte, error) { +// marshalBFTOptions serializes smartbft options. +func marshalBFTOptions(op *sb.Options) ([]byte, error) { if copyMd, ok := proto.Clone(op).(*sb.Options); ok { return proto.Marshal(copyMd) } @@ -1078,6 +1110,16 @@ func unmarshalEtcdRaftMetadata(mdBytes []byte) (orderer.EtcdRaft, error) { }, nil } +// unmarshalSmartBFTOptions deserializes . +func unmarshalSmartBFTOptions(optsBytes []byte) (*sb.Options, error) { + smartBFTOptions := &sb.Options{} + err := proto.Unmarshal(optsBytes, smartBFTOptions) + if err != nil { + return nil, err + } + return smartBFTOptions, nil +} + // getOrdererOrg returns the organization config group for an orderer org in the // provided config. It returns nil if the org doesn't exist in the config. func getOrdererOrg(config *cb.Config, orgName string) *cb.ConfigGroup { From d0ca879ab321e8f4e74647ac40f5bf5ee129503e Mon Sep 17 00:00:00 2001 From: David VIEJO Date: Thu, 18 Jan 2024 18:43:40 +0100 Subject: [PATCH 06/10] Fix orderer tests Signed-off-by: David VIEJO --- configtx/orderer.go | 53 +++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/configtx/orderer.go b/configtx/orderer.go index 9c44178..34dd8e9 100644 --- a/configtx/orderer.go +++ b/configtx/orderer.go @@ -18,7 +18,6 @@ import ( "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/configtx/internal/policydsl" "github.com/hyperledger/fabric-config/configtx/orderer" - "github.com/hyperledger/fabric-protos-go/common" cb "github.com/hyperledger/fabric-protos-go/common" mspa "github.com/hyperledger/fabric-protos-go/msp" ob "github.com/hyperledger/fabric-protos-go/orderer" @@ -44,7 +43,7 @@ type Orderer struct { Organizations []Organization SmartBFT *sb.Options - ConsenterMapping []common.Consenter + ConsenterMapping []cb.Consenter // MaxChannels is the maximum count of channels an orderer supports. MaxChannels uint64 // Capabilities is a map of the capabilities the orderer supports. @@ -109,6 +108,7 @@ func (o *OrdererGroup) Configuration() (Orderer, error) { // CONSENSUS TYPE, STATE, AND METADATA var etcdRaft orderer.EtcdRaft var smartBFT *sb.Options + var consenterMapping []cb.Consenter kafkaBrokers := orderer.Kafka{} consensusTypeProto := &ob.ConsensusType{} @@ -145,6 +145,27 @@ func (o *OrdererGroup) Configuration() (Orderer, error) { if err != nil { return Orderer{}, fmt.Errorf("unmarshaling smart BFT options: %v", err) } + + orderersConfigValue, ok := o.ordererGroup.Values["Orderers"] + if !ok { + return Orderer{}, errors.New("unable to find orderers for orderer org") + } + orderers := cb.Orderers{} + err = proto.Unmarshal(orderersConfigValue.Value, &orderers) + if err != nil { + return Orderer{}, fmt.Errorf("unmarshaling orderers: %v", err) + } + for _, consenterItem := range orderers.ConsenterMapping { + consenterMapping = append(consenterMapping, cb.Consenter{ + Id: consenterItem.Id, + Host: consenterItem.Host, + Port: consenterItem.Port, + MspId: consenterItem.MspId, + Identity: consenterItem.Identity, + ClientTlsCert: consenterItem.ClientTlsCert, + ServerTlsCert: consenterItem.ServerTlsCert, + }) + } default: return Orderer{}, fmt.Errorf("config contains unknown consensus type '%s'", consensusTypeProto.Type) } @@ -166,27 +187,6 @@ func (o *OrdererGroup) Configuration() (Orderer, error) { if err != nil { return Orderer{}, fmt.Errorf("batch timeout configuration '%s' is not a duration string", batchTimeoutProto.Timeout) } - orderersConfigValue, ok := o.ordererGroup.Values["Orderers"] - if !ok { - return Orderer{}, errors.New("unable to find orderers for orderer org") - } - orderers := cb.Orderers{} - err = proto.Unmarshal(orderersConfigValue.Value, &orderers) - if err != nil { - return Orderer{}, fmt.Errorf("unmarshaling orderers: %v", err) - } - var consenterMapping []common.Consenter - for _, consenterItem := range orderers.ConsenterMapping { - consenterMapping = append(consenterMapping, common.Consenter{ - Id: consenterItem.Id, - Host: consenterItem.Host, - Port: consenterItem.Port, - MspId: consenterItem.MspId, - Identity: consenterItem.Identity, - ClientTlsCert: consenterItem.ClientTlsCert, - ServerTlsCert: consenterItem.ServerTlsCert, - }) - } // ORDERER ORGS var ordererOrgs []Organization @@ -909,10 +909,7 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { // marshalBFTOptions serializes smartbft options. func marshalBFTOptions(op *sb.Options) ([]byte, error) { - if copyMd, ok := proto.Clone(op).(*sb.Options); ok { - return proto.Marshal(copyMd) - } - return nil, errors.New("consenter options type mismatch") + return proto.Marshal(op) } // setOrdererPolicies adds *cb.ConfigPolicies to the passed Orderer *cb.ConfigGroup's Policies map. @@ -1148,7 +1145,7 @@ func blockDataHashingStructureValue() *standardConfigValue { } } -func encodeBFTBlockVerificationPolicy(consenterProtos []common.Consenter, ordererGroup *cb.ConfigGroup) error { +func encodeBFTBlockVerificationPolicy(consenterProtos []cb.Consenter, ordererGroup *cb.ConfigGroup) error { n := len(consenterProtos) f := (n - 1) / 3 From b397f0346372a7526ba089f8333cb604bb750a03 Mon Sep 17 00:00:00 2001 From: David VIEJO Date: Thu, 18 Jan 2024 18:48:23 +0100 Subject: [PATCH 07/10] SmartBFT -> SmartBFTOptions Signed-off-by: David VIEJO --- configtx/constants.go | 3 +++ configtx/orderer.go | 10 +++++----- configtx/orderer/orderer.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/configtx/constants.go b/configtx/constants.go index 4addb35..ca585c6 100644 --- a/configtx/constants.go +++ b/configtx/constants.go @@ -68,6 +68,9 @@ const ( // OrdererGroupKey is the group name for the orderer config. OrdererGroupKey = "Orderer" + // OrderersGroupKey is the group name for the orderer config. + OrderersGroupKey = "Orderers" + // ApplicationGroupKey is the group name for the Application config. ApplicationGroupKey = "Application" diff --git a/configtx/orderer.go b/configtx/orderer.go index 34dd8e9..d316b33 100644 --- a/configtx/orderer.go +++ b/configtx/orderer.go @@ -42,7 +42,7 @@ type Orderer struct { EtcdRaft orderer.EtcdRaft Organizations []Organization - SmartBFT *sb.Options + SmartBFTOptions *sb.Options ConsenterMapping []cb.Consenter // MaxChannels is the maximum count of channels an orderer supports. MaxChannels uint64 @@ -146,7 +146,7 @@ func (o *OrdererGroup) Configuration() (Orderer, error) { return Orderer{}, fmt.Errorf("unmarshaling smart BFT options: %v", err) } - orderersConfigValue, ok := o.ordererGroup.Values["Orderers"] + orderersConfigValue, ok := o.ordererGroup.Values[OrderersGroupKey] if !ok { return Orderer{}, errors.New("unable to find orderers for orderer org") } @@ -229,7 +229,7 @@ func (o *OrdererGroup) Configuration() (Orderer, error) { Kafka: kafkaBrokers, EtcdRaft: etcdRaft, ConsenterMapping: consenterMapping, - SmartBFT: smartBFT, + SmartBFTOptions: smartBFT, Organizations: ordererOrgs, MaxChannels: channelRestrictions.MaxCount, Capabilities: capabilities, @@ -877,12 +877,12 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { return fmt.Errorf("marshaling consenters for orderer type '%s': %v", orderer.ConsensusTypeBFT, err) } - ordererGroup.Values["Orderers"] = &cb.ConfigValue{ + ordererGroup.Values[OrderersGroupKey] = &cb.ConfigValue{ Value: consentersProto, ModPolicy: "Admins", } // addValue(ordererGroup, channelconfig.OrderersValue(consenterProtos), channelconfig.AdminsPolicyKey) - if consensusMetadata, err = marshalBFTOptions(o.SmartBFT); err != nil { + if consensusMetadata, err = marshalBFTOptions(o.SmartBFTOptions); err != nil { return fmt.Errorf("consenter options read failed with error %s for orderer type %s", err, orderer.ConsensusTypeBFT) } // Overwrite policy manually by computing it from the consenters diff --git a/configtx/orderer/orderer.go b/configtx/orderer/orderer.go index 252c3db..9ffecb4 100644 --- a/configtx/orderer/orderer.go +++ b/configtx/orderer/orderer.go @@ -28,7 +28,7 @@ const ( // ConsensusTypeEtcdRaft identifies the Raft-based consensus implementation. ConsensusTypeEtcdRaft = "etcdraft" - // ConsensusTypeBFT identifies the SmartBFT-based consensus implementation. + // ConsensusTypeBFT identifies the SmartBFTOptions-based consensus implementation. ConsensusTypeBFT = "BFT" // KafkaBrokersKey is the common.ConfigValue type key name for the KafkaBrokers message. From ef1a1564900ae1375dc57684e203f6270c9cfc36 Mon Sep 17 00:00:00 2001 From: David VIEJO Date: Thu, 18 Jan 2024 18:58:15 +0100 Subject: [PATCH 08/10] Revert SmartBFTOptions -> SmartBFT to be consistent with Fabric Signed-off-by: David VIEJO --- configtx/orderer.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configtx/orderer.go b/configtx/orderer.go index d316b33..a25612b 100644 --- a/configtx/orderer.go +++ b/configtx/orderer.go @@ -42,7 +42,7 @@ type Orderer struct { EtcdRaft orderer.EtcdRaft Organizations []Organization - SmartBFTOptions *sb.Options + SmartBFT *sb.Options ConsenterMapping []cb.Consenter // MaxChannels is the maximum count of channels an orderer supports. MaxChannels uint64 @@ -229,7 +229,7 @@ func (o *OrdererGroup) Configuration() (Orderer, error) { Kafka: kafkaBrokers, EtcdRaft: etcdRaft, ConsenterMapping: consenterMapping, - SmartBFTOptions: smartBFT, + SmartBFT: smartBFT, Organizations: ordererOrgs, MaxChannels: channelRestrictions.MaxCount, Capabilities: capabilities, @@ -882,7 +882,7 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { ModPolicy: "Admins", } // addValue(ordererGroup, channelconfig.OrderersValue(consenterProtos), channelconfig.AdminsPolicyKey) - if consensusMetadata, err = marshalBFTOptions(o.SmartBFTOptions); err != nil { + if consensusMetadata, err = marshalBFTOptions(o.SmartBFT); err != nil { return fmt.Errorf("consenter options read failed with error %s for orderer type %s", err, orderer.ConsensusTypeBFT) } // Overwrite policy manually by computing it from the consenters From a0b16ca530c2d19f5744bf0d88661c73b02df4f8 Mon Sep 17 00:00:00 2001 From: David VIEJO Date: Mon, 19 Aug 2024 20:43:44 +0200 Subject: [PATCH 09/10] Add SetConsenterMapping Signed-off-by: David VIEJO --- configtx/orderer.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/configtx/orderer.go b/configtx/orderer.go index a25612b..8e29999 100644 --- a/configtx/orderer.go +++ b/configtx/orderer.go @@ -469,6 +469,20 @@ func (o *OrdererGroup) SetConfiguration(ord Orderer) error { return nil } +func (o *OrdererGroup) SetConsenterMapping(consenterMapping []*cb.Consenter) error { + val, err := proto.Marshal(&cb.Orderers{ + ConsenterMapping: consenterMapping, + }) + if err != nil { + return err + } + o.ordererGroup.Values[OrderersGroupKey] = &cb.ConfigValue{ + Value: val, + ModPolicy: "Admins", + } + return nil +} + // AddConsenter adds a consenter to an etcdraft configuration. func (o *OrdererGroup) AddConsenter(consenter orderer.Consenter) error { cfg, err := o.Configuration() From 9507b45ddcca19aed989e357345c96ce6467c91f Mon Sep 17 00:00:00 2001 From: dviejokfs Date: Fri, 18 Jul 2025 20:27:49 +0200 Subject: [PATCH 10/10] Update Go module dependencies and refactor proto imports - Bump Go version to 1.22.0 and set toolchain to go1.23.5 in go.mod. - Update indirect dependencies in go.mod and go.sum, including: - Upgrade `golang.org/x/net` to v0.34.0 - Upgrade `golang.org/x/sys` to v0.29.0 - Upgrade `golang.org/x/text` to v0.21.0 - Upgrade `google.golang.org/grpc` to v1.67.3 - Upgrade `google.golang.org/protobuf` to v1.36.3 - Add `github.com/hyperledger/fabric-protos-go-apiv2` v0.3.7 - Refactor proto imports across multiple files to use `github.com/hyperledger/fabric-protos-go-apiv2` instead of `github.com/hyperledger/fabric-protos-go`. Signed-off-by: dviejokfs --- configtx/application.go | 6 +- configtx/application_test.go | 4 +- configtx/capabilities.go | 4 +- configtx/channel.go | 2 +- configtx/channel_test.go | 2 +- configtx/config.go | 6 +- configtx/config_test.go | 6 +- configtx/consortiums.go | 6 +- configtx/consortiums_test.go | 4 +- configtx/example_test.go | 10 +- configtx/internal/policydsl/policyparser.go | 6 +- .../internal/policydsl/policyparser_test.go | 6 +- configtx/msp.go | 6 +- configtx/msp_test.go | 6 +- configtx/orderer.go | 24 +- configtx/orderer_test.go | 14 +- configtx/organization.go | 8 +- configtx/policies.go | 6 +- configtx/policies_test.go | 4 +- configtx/signer.go | 6 +- configtx/signer_test.go | 4 +- configtx/update.go | 4 +- configtx/update_test.go | 2 +- go.mod | 15 +- go.sum | 12 + protolator/api.go | 2 +- protolator/dynamic.go | 2 +- protolator/integration/integration_test.go | 24 +- protolator/json.go | 60 +- protolator/json_test.go | 2 +- protolator/nested.go | 2 +- protolator/protoext/commonext/common.go | 8 +- protolator/protoext/commonext/common_test.go | 4 +- protolator/protoext/commonext/configtx.go | 4 +- .../protoext/commonext/configuration.go | 6 +- protolator/protoext/commonext/policies.go | 4 +- protolator/protoext/decorate.go | 12 +- protolator/protoext/decorate_test.go | 23 +- protolator/protoext/ledger/rwsetext/rwset.go | 6 +- protolator/protoext/mspext/msp_config.go | 4 +- protolator/protoext/mspext/msp_principal.go | 4 +- .../protoext/ordererext/configuration.go | 12 +- protolator/protoext/peerext/configuration.go | 8 +- protolator/protoext/peerext/proposal.go | 6 +- .../protoext/peerext/proposal_response.go | 4 +- protolator/protoext/peerext/transaction.go | 6 +- protolator/statically_opaque.go | 2 +- protolator/statically_opaque_test.go | 2 +- protolator/testprotos/sample.go | 2 +- protolator/testprotos/sample.pb.go | 924 ++++++++++++------ protolator/variably_opaque.go | 2 +- protolator/variably_opaque_test.go | 2 +- 52 files changed, 813 insertions(+), 497 deletions(-) diff --git a/configtx/application.go b/configtx/application.go index 356f814..87f4b6a 100644 --- a/configtx/application.go +++ b/configtx/application.go @@ -10,9 +10,9 @@ import ( "errors" "fmt" - "github.com/golang/protobuf/proto" - cb "github.com/hyperledger/fabric-protos-go/common" - pb "github.com/hyperledger/fabric-protos-go/peer" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + pb "github.com/hyperledger/fabric-protos-go-apiv2/peer" + "google.golang.org/protobuf/proto" ) // Application is a copy of the orderer configuration with the addition of an anchor peers diff --git a/configtx/application_test.go b/configtx/application_test.go index 8b697db..73111a3 100644 --- a/configtx/application_test.go +++ b/configtx/application_test.go @@ -15,12 +15,12 @@ import ( "math/big" "testing" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/configtx/internal/policydsl" "github.com/hyperledger/fabric-config/protolator" "github.com/hyperledger/fabric-config/protolator/protoext/peerext" - cb "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" ) func TestNewApplicationGroup(t *testing.T) { diff --git a/configtx/capabilities.go b/configtx/capabilities.go index 0be7434..c3fbe3d 100644 --- a/configtx/capabilities.go +++ b/configtx/capabilities.go @@ -10,8 +10,8 @@ import ( "errors" "fmt" - "github.com/golang/protobuf/proto" - cb "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + "google.golang.org/protobuf/proto" ) // capabilitiesValue returns the config definition for a set of capabilities. diff --git a/configtx/channel.go b/configtx/channel.go index 5a8406e..924aa54 100644 --- a/configtx/channel.go +++ b/configtx/channel.go @@ -10,7 +10,7 @@ import ( "errors" "fmt" - cb "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" ) // ChannelGroup encapsulates the parts of the config that control channels. diff --git a/configtx/channel_test.go b/configtx/channel_test.go index 692d266..5ce2a4b 100644 --- a/configtx/channel_test.go +++ b/configtx/channel_test.go @@ -12,7 +12,7 @@ import ( "github.com/hyperledger/fabric-config/protolator" "github.com/hyperledger/fabric-config/protolator/protoext/commonext" - cb "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" . "github.com/onsi/gomega" ) diff --git a/configtx/config.go b/configtx/config.go index 261b5e1..af68dc4 100644 --- a/configtx/config.go +++ b/configtx/config.go @@ -24,11 +24,11 @@ import ( "strconv" "strings" - "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/timestamp" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "google.golang.org/protobuf/proto" ) // Channel is a channel configuration. diff --git a/configtx/config_test.go b/configtx/config_test.go index 6f633fa..b84c880 100644 --- a/configtx/config_test.go +++ b/configtx/config_test.go @@ -13,10 +13,10 @@ import ( "fmt" "testing" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/protolator" - cb "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" ) func TestNewConfigTx(t *testing.T) { @@ -251,7 +251,7 @@ func TestNewCreateChannelTx(t *testing.T) { err = proto.Unmarshal(actualData.ConfigUpdate, &actualConfigUpdate) gt.Expect(err).NotTo(HaveOccurred()) - gt.Expect(actualConfigUpdate).To(Equal(expectedConfigUpdate)) + gt.Expect(&actualConfigUpdate).To(Equal(&expectedConfigUpdate)) // setting timestamps to match in ConfigUpdate actualTimestamp := actualHeader.Timestamp diff --git a/configtx/consortiums.go b/configtx/consortiums.go index 094b8b7..e6528a4 100644 --- a/configtx/consortiums.go +++ b/configtx/consortiums.go @@ -10,9 +10,9 @@ import ( "errors" "fmt" - "github.com/golang/protobuf/proto" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "google.golang.org/protobuf/proto" ) // Consortium is a group of non-orderer organizations used in channel transactions. diff --git a/configtx/consortiums_test.go b/configtx/consortiums_test.go index 6d4f1c4..d5839ae 100644 --- a/configtx/consortiums_test.go +++ b/configtx/consortiums_test.go @@ -15,11 +15,11 @@ import ( "math/big" "testing" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/protolator" "github.com/hyperledger/fabric-config/protolator/protoext/commonext" - cb "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" ) func TestNewConsortiumsGroup(t *testing.T) { diff --git a/configtx/example_test.go b/configtx/example_test.go index 3bd45aa..5ba1871 100644 --- a/configtx/example_test.go +++ b/configtx/example_test.go @@ -19,15 +19,15 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/configtx" "github.com/hyperledger/fabric-config/configtx/membership" "github.com/hyperledger/fabric-config/configtx/orderer" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" - ob "github.com/hyperledger/fabric-protos-go/orderer" - pb "github.com/hyperledger/fabric-protos-go/peer" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" + ob "github.com/hyperledger/fabric-protos-go-apiv2/orderer" + pb "github.com/hyperledger/fabric-protos-go-apiv2/peer" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" ) const ( diff --git a/configtx/internal/policydsl/policyparser.go b/configtx/internal/policydsl/policyparser.go index 4d54526..a22c09a 100644 --- a/configtx/internal/policydsl/policyparser.go +++ b/configtx/internal/policydsl/policyparser.go @@ -14,9 +14,9 @@ import ( "strings" "github.com/Knetic/govaluate" - "github.com/golang/protobuf/proto" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "google.golang.org/protobuf/proto" ) // Gate values diff --git a/configtx/internal/policydsl/policyparser_test.go b/configtx/internal/policydsl/policyparser_test.go index 562c055..b479965 100644 --- a/configtx/internal/policydsl/policyparser_test.go +++ b/configtx/internal/policydsl/policyparser_test.go @@ -9,10 +9,10 @@ package policydsl_test import ( "testing" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/configtx/internal/policydsl" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "google.golang.org/protobuf/proto" . "github.com/onsi/gomega" ) diff --git a/configtx/msp.go b/configtx/msp.go index 422c1e5..8aa5995 100644 --- a/configtx/msp.go +++ b/configtx/msp.go @@ -17,10 +17,10 @@ import ( "reflect" "time" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/configtx/membership" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "google.golang.org/protobuf/proto" ) // MSP is the configuration information for a Fabric MSP. diff --git a/configtx/msp_test.go b/configtx/msp_test.go index 329128f..5546393 100644 --- a/configtx/msp_test.go +++ b/configtx/msp_test.go @@ -18,13 +18,13 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/configtx/membership" "github.com/hyperledger/fabric-config/configtx/orderer" "github.com/hyperledger/fabric-config/protolator" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" ) func TestMSPConfigurationFailures(t *testing.T) { diff --git a/configtx/orderer.go b/configtx/orderer.go index 8e29999..1bf82e2 100644 --- a/configtx/orderer.go +++ b/configtx/orderer.go @@ -15,14 +15,14 @@ import ( "reflect" "time" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/configtx/internal/policydsl" "github.com/hyperledger/fabric-config/configtx/orderer" - cb "github.com/hyperledger/fabric-protos-go/common" - mspa "github.com/hyperledger/fabric-protos-go/msp" - ob "github.com/hyperledger/fabric-protos-go/orderer" - eb "github.com/hyperledger/fabric-protos-go/orderer/etcdraft" - sb "github.com/hyperledger/fabric-protos-go/orderer/smartbft" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mspa "github.com/hyperledger/fabric-protos-go-apiv2/msp" + ob "github.com/hyperledger/fabric-protos-go-apiv2/orderer" + eb "github.com/hyperledger/fabric-protos-go-apiv2/orderer/etcdraft" + sb "github.com/hyperledger/fabric-protos-go-apiv2/orderer/smartbft" + "google.golang.org/protobuf/proto" ) const ( @@ -425,9 +425,7 @@ func (o *OrdererOrg) Configuration() (Organization, error) { return Organization{}, err } ordererEndpoints := make([]string, len(endpointsProtos.Addresses)) - for i, address := range endpointsProtos.Addresses { - ordererEndpoints[i] = address - } + copy(ordererEndpoints, endpointsProtos.Addresses) org.OrdererEndpoints = ordererEndpoints } @@ -469,6 +467,8 @@ func (o *OrdererGroup) SetConfiguration(ord Orderer) error { return nil } +// SetConsenterMapping sets the consenter mapping for the orderer group. +// It marshals the provided consenter mapping and updates the orderer group's values. func (o *OrdererGroup) SetConsenterMapping(consenterMapping []*cb.Consenter) error { val, err := proto.Marshal(&cb.Orderers{ ConsenterMapping: consenterMapping, @@ -873,7 +873,8 @@ func addOrdererValues(ordererGroup *cb.ConfigGroup, o Orderer) error { } case orderer.ConsensusTypeBFT: consenterMapping := []*cb.Consenter{} - for _, consenter := range o.ConsenterMapping { + for i := range o.ConsenterMapping { + consenter := &o.ConsenterMapping[i] consenterMapping = append(consenterMapping, &cb.Consenter{ Id: consenter.Id, Host: consenter.Host, @@ -1165,7 +1166,8 @@ func encodeBFTBlockVerificationPolicy(consenterProtos []cb.Consenter, ordererGro var identities []*mspa.MSPPrincipal var pols []*cb.SignaturePolicy - for i, consenter := range consenterProtos { + for i := range consenterProtos { + consenter := &consenterProtos[i] pols = append(pols, &cb.SignaturePolicy{ Type: &cb.SignaturePolicy_SignedBy{ SignedBy: int32(i), diff --git a/configtx/orderer_test.go b/configtx/orderer_test.go index bdd12f3..0108dad 100644 --- a/configtx/orderer_test.go +++ b/configtx/orderer_test.go @@ -16,13 +16,13 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/configtx/orderer" "github.com/hyperledger/fabric-config/protolator" "github.com/hyperledger/fabric-config/protolator/protoext/ordererext" - cb "github.com/hyperledger/fabric-protos-go/common" - ob "github.com/hyperledger/fabric-protos-go/orderer" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + ob "github.com/hyperledger/fabric-protos-go-apiv2/orderer" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" ) func TestNewOrdererGroup(t *testing.T) { @@ -3637,14 +3637,14 @@ func TestRemoveOrdererPolicyFailures(t *testing.T) { tests := []struct { testName string - ordererGrpMod func(cb.ConfigGroup) *cb.ConfigGroup + ordererGrpMod func(*cb.ConfigGroup) *cb.ConfigGroup policyName string expectedErr string }{ { testName: "when removing blockvalidation policy", - ordererGrpMod: func(og cb.ConfigGroup) *cb.ConfigGroup { - return &og + ordererGrpMod: func(og *cb.ConfigGroup) *cb.ConfigGroup { + return og }, policyName: BlockValidationPolicyKey, expectedErr: "BlockValidation policy must be defined", @@ -3656,7 +3656,7 @@ func TestRemoveOrdererPolicyFailures(t *testing.T) { t.Run(tt.testName, func(t *testing.T) { gt := NewGomegaWithT(t) - ordererGroup := tt.ordererGrpMod(*ordererGroup) + ordererGroup := tt.ordererGrpMod(ordererGroup) if ordererGroup == nil { delete(config.ChannelGroup.Groups, OrdererGroupKey) } else { diff --git a/configtx/organization.go b/configtx/organization.go index c5757f0..ea5eeb4 100644 --- a/configtx/organization.go +++ b/configtx/organization.go @@ -9,10 +9,10 @@ package configtx import ( "fmt" - "github.com/golang/protobuf/proto" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" - pb "github.com/hyperledger/fabric-protos-go/peer" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" + pb "github.com/hyperledger/fabric-protos-go-apiv2/peer" + "google.golang.org/protobuf/proto" ) // newOrgConfigGroup returns an config group for an organization. diff --git a/configtx/policies.go b/configtx/policies.go index b69d21a..6df708e 100644 --- a/configtx/policies.go +++ b/configtx/policies.go @@ -12,10 +12,10 @@ import ( "strconv" "strings" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/configtx/internal/policydsl" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "google.golang.org/protobuf/proto" ) // getPolicies returns a map of Policy from given map of ConfigPolicy in organization config group. diff --git a/configtx/policies_test.go b/configtx/policies_test.go index bb9af35..4280063 100644 --- a/configtx/policies_test.go +++ b/configtx/policies_test.go @@ -9,9 +9,9 @@ package configtx import ( "testing" - "github.com/golang/protobuf/proto" - cb "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" ) func TestPolicies(t *testing.T) { diff --git a/configtx/signer.go b/configtx/signer.go index 2286301..9aa0c8a 100644 --- a/configtx/signer.go +++ b/configtx/signer.go @@ -18,9 +18,9 @@ import ( "io" "math/big" - "github.com/golang/protobuf/proto" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "google.golang.org/protobuf/proto" ) // SigningIdentity is an MSP Identity that can be used to sign configuration diff --git a/configtx/signer_test.go b/configtx/signer_test.go index ab65112..5dba867 100644 --- a/configtx/signer_test.go +++ b/configtx/signer_test.go @@ -21,9 +21,9 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" - cb "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" ) func TestSign(t *testing.T) { diff --git a/configtx/update.go b/configtx/update.go index 81e0dbc..c80b079 100644 --- a/configtx/update.go +++ b/configtx/update.go @@ -10,8 +10,8 @@ import ( "bytes" "fmt" - "github.com/golang/protobuf/proto" - cb "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + "google.golang.org/protobuf/proto" ) // Compute computes the difference between two *cb.Configs and returns the diff --git a/configtx/update_test.go b/configtx/update_test.go index b2c7cde..3641bc8 100644 --- a/configtx/update_test.go +++ b/configtx/update_test.go @@ -9,7 +9,7 @@ package configtx import ( "testing" - cb "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" . "github.com/onsi/gomega" ) diff --git a/go.mod b/go.mod index 499c7e0..786dd3a 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/hyperledger/fabric-config -go 1.20 +go 1.22.0 + +toolchain go1.23.5 require ( github.com/Knetic/govaluate v3.0.0+incompatible @@ -10,12 +12,13 @@ require ( ) require ( - golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect - golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 // indirect - golang.org/x/text v0.3.3 // indirect + github.com/hyperledger/fabric-protos-go-apiv2 v0.3.7 + golang.org/x/net v0.34.0 // indirect + golang.org/x/sys v0.29.0 // indirect + golang.org/x/text v0.21.0 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect - google.golang.org/grpc v1.46.2 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/grpc v1.67.3 // indirect + google.golang.org/protobuf v1.36.3 // indirect gopkg.in/yaml.v2 v2.2.4 // indirect ) diff --git a/go.sum b/go.sum index e1a180e..19b1cd9 100644 --- a/go.sum +++ b/go.sum @@ -52,6 +52,8 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hyperledger/fabric-protos-go v0.3.0 h1:MXxy44WTMENOh5TI8+PCK2x6pMj47Go2vFRKDHB2PZs= github.com/hyperledger/fabric-protos-go v0.3.0/go.mod h1:WWnyWP40P2roPmmvxsUXSvVI/CF6vwY1K1UFidnKBys= +github.com/hyperledger/fabric-protos-go-apiv2 v0.3.7 h1:sQ5qv8vQQfwewa1JlCiSCC8dLElmaU2/frLolpgibEY= +github.com/hyperledger/fabric-protos-go-apiv2 v0.3.7/go.mod h1:bJnwzfv03oZQeCc863pdGTDgf5nmCy6Za3RAE7d2XsQ= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= @@ -79,6 +81,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -93,9 +97,13 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -120,6 +128,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.67.3 h1:OgPcDAFKHnH8X3O4WcO4XUc8GRDeKsKReqbQtiCj7N8= +google.golang.org/grpc v1.67.3/go.mod h1:YGaHCc6Oap+FzBJTZLBzkGSYt/cvGPFTPxkn7QfSU8s= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -134,6 +144,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= +google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= diff --git a/protolator/api.go b/protolator/api.go index 243691f..d1d4c05 100644 --- a/protolator/api.go +++ b/protolator/api.go @@ -7,7 +7,7 @@ SPDX-License-Identifier: Apache-2.0 package protolator import ( - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/protolator/dynamic.go b/protolator/dynamic.go index 8a40b64..ce95884 100644 --- a/protolator/dynamic.go +++ b/protolator/dynamic.go @@ -19,7 +19,7 @@ package protolator import ( "reflect" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) func dynamicFrom(dynamicMsg func(underlying proto.Message) (proto.Message, error), value interface{}, destType reflect.Type) (reflect.Value, error) { diff --git a/protolator/integration/integration_test.go b/protolator/integration/integration_test.go index 1fab94a..99f27d4 100644 --- a/protolator/integration/integration_test.go +++ b/protolator/integration/integration_test.go @@ -8,15 +8,15 @@ package integration import ( "bytes" - "io/ioutil" + "os" "testing" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/protolator" - cb "github.com/hyperledger/fabric-protos-go/common" - mb "github.com/hyperledger/fabric-protos-go/msp" - pb "github.com/hyperledger/fabric-protos-go/peer" + cb "github.com/hyperledger/fabric-protos-go-apiv2/common" + mb "github.com/hyperledger/fabric-protos-go-apiv2/msp" + pb "github.com/hyperledger/fabric-protos-go-apiv2/peer" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" ) func bidirectionalMarshal(t *testing.T, doc proto.Message) { @@ -28,7 +28,7 @@ func bidirectionalMarshal(t *testing.T, doc proto.Message) { gt.Expect(err).NotTo(HaveOccurred()) newRoot := proto.Clone(doc) - newRoot.Reset() + proto.Reset(newRoot) err = protolator.DeepUnmarshalJSON(bytes.NewReader(buffer.Bytes()), newRoot) gt.Expect(err).NotTo(HaveOccurred()) @@ -46,7 +46,7 @@ func bidirectionalMarshal(t *testing.T, doc proto.Message) { func TestConfigUpdate(t *testing.T) { gt := NewGomegaWithT(t) - blockBin, err := ioutil.ReadFile("testdata/block.pb") + blockBin, err := os.ReadFile("testdata/block.pb") gt.Expect(err).NotTo(HaveOccurred()) block := &cb.Block{} @@ -85,7 +85,7 @@ func TestIdemix(t *testing.T) { func TestBlock(t *testing.T) { gt := NewGomegaWithT(t) - blockBin, err := ioutil.ReadFile("testdata/block.pb") + blockBin, err := os.ReadFile("testdata/block.pb") gt.Expect(err).NotTo(HaveOccurred()) block := &cb.Block{} @@ -134,7 +134,7 @@ func TestEmitDefaultsBug(t *testing.T) { "epoch": "0", "extension": null, "timestamp": null, - "tls_cert_hash": null, + "tls_cert_hash": "", "tx_id": "", "type": 1, "version": 0 @@ -147,7 +147,7 @@ func TestEmitDefaultsBug(t *testing.T) { ] }, "header": { - "data_hash": null, + "data_hash": "", "number": "0", "previous_hash": "Zm9v" }, @@ -299,14 +299,14 @@ func TestStaticMarshal(t *testing.T) { // configtxgen -channelID test -outputBlock block.pb -profile SampleSingleMSPSolo -configPath FABRICPATH/sampleconfig // configtxgen -configPath FABRICPATH/sampleconfig -inspectBlock block.pb > block.json - blockBin, err := ioutil.ReadFile("testdata/block.pb") + blockBin, err := os.ReadFile("testdata/block.pb") gt.Expect(err).NotTo(HaveOccurred()) block := &cb.Block{} err = proto.Unmarshal(blockBin, block) gt.Expect(err).NotTo(HaveOccurred()) - jsonBin, err := ioutil.ReadFile("testdata/block.json") + jsonBin, err := os.ReadFile("testdata/block.json") gt.Expect(err).NotTo(HaveOccurred()) buf := &bytes.Buffer{} diff --git a/protolator/json.go b/protolator/json.go index e4b6d61..27af807 100644 --- a/protolator/json.go +++ b/protolator/json.go @@ -11,12 +11,12 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "reflect" + "strings" - "github.com/golang/protobuf/jsonpb" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/protolator/protoext" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" ) // MostlyDeterministicMarshal is _NOT_ the function you are looking for. @@ -26,12 +26,9 @@ import ( // the same process wants to compare binary messages for equality without // needing to unmarshal first, but should not be used generally. func MostlyDeterministicMarshal(msg proto.Message) ([]byte, error) { - buffer := proto.NewBuffer(make([]byte, 0)) - buffer.SetDeterministic(true) - if err := buffer.Marshal(msg); err != nil { - return nil, err - } - return buffer.Bytes(), nil + return proto.MarshalOptions{ + Deterministic: true, + }.Marshal(msg) } type protoFieldFactory interface { @@ -243,18 +240,17 @@ func protoToJSON(msg proto.Message) ([]byte, error) { if reflect.ValueOf(msg).IsNil() { panic("We're nil here") } - var b bytes.Buffer - m := jsonpb.Marshaler{ - EnumsAsInts: false, - EmitDefaults: true, - Indent: " ", - OrigName: true, + m := protojson.MarshalOptions{ + UseEnumNumbers: false, + EmitUnpopulated: true, + Indent: " ", + UseProtoNames: true, } - err := m.Marshal(&b, msg) + b, err := m.Marshal(msg) if err != nil { return nil, err } - return b.Bytes(), nil + return b, nil } func mapToProto(tree map[string]interface{}, msg proto.Message) error { @@ -263,7 +259,7 @@ func mapToProto(tree map[string]interface{}, msg proto.Message) error { return err } - return jsonpb.UnmarshalString(string(jsonOut), msg) + return protojson.Unmarshal(jsonOut, msg) } // jsonToMap allocates a map[string]interface{}, unmarshals a JSON document into it @@ -315,20 +311,28 @@ func protoFields(msg proto.Message, uMsg proto.Message) ([]protoField, error) { } iResult := make([][]protoField, len(fieldFactories)) - - protoProps := proto.GetProperties(mVal.Type()) + t := mVal.Type() // TODO, this will skip oneof fields, this should be handled // correctly at some point - for _, prop := range protoProps.Prop { - fieldName := prop.OrigName - fieldValue := mVal.FieldByName(prop.Name) - fieldTypeStruct, ok := mVal.Type().FieldByName(prop.Name) + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + fieldName := f.Name + tagField := f.Tag.Get("protobuf") + for _, s := range strings.Split(tagField, ",") { + if strings.HasPrefix(s, "name=") { + fieldName = s[len("name="):] + break + } + } + + fieldValue := mVal.FieldByName(f.Name) + fieldTypeStruct, ok := mVal.Type().FieldByName(f.Name) if !ok { return nil, fmt.Errorf("programming error: proto does not have field advertised by proto package") } fieldType := fieldTypeStruct.Type - for i, factory := range fieldFactories { + for j, factory := range fieldFactories { if !factory.Handles(msg, fieldName, fieldType, fieldValue) { continue } @@ -337,7 +341,7 @@ func protoFields(msg proto.Message, uMsg proto.Message) ([]protoField, error) { if err != nil { return nil, err } - iResult[i] = append(iResult[i], field) + iResult[j] = append(iResult[j], field) break } } @@ -450,7 +454,7 @@ func recursivelyPopulateMessageFromTree(tree map[string]interface{}, msg proto.M if !ok { continue } - if err := field.PopulateFrom(specialField); err != nil { + if err = field.PopulateFrom(specialField); err != nil { return err } } @@ -461,7 +465,7 @@ func recursivelyPopulateMessageFromTree(tree map[string]interface{}, msg proto.M // DeepUnmarshalJSON takes JSON output as generated by DeepMarshalJSON and decodes it into msg // This includes re-marshaling the expanded nested elements to binary form func DeepUnmarshalJSON(r io.Reader, msg proto.Message) error { - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(r) if err != nil { return err } diff --git a/protolator/json_test.go b/protolator/json_test.go index 3c59a42..7e34b44 100644 --- a/protolator/json_test.go +++ b/protolator/json_test.go @@ -24,8 +24,8 @@ import ( "reflect" "testing" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/protolator/testprotos" + "google.golang.org/protobuf/proto" . "github.com/onsi/gomega" ) diff --git a/protolator/nested.go b/protolator/nested.go index 5d17ca4..34b54a2 100644 --- a/protolator/nested.go +++ b/protolator/nested.go @@ -19,8 +19,8 @@ package protolator import ( "reflect" - "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/timestamp" + "google.golang.org/protobuf/proto" ) func nestedFrom(value interface{}, destType reflect.Type) (reflect.Value, error) { diff --git a/protolator/protoext/commonext/common.go b/protolator/protoext/commonext/common.go index 908b92c..c14750b 100644 --- a/protolator/protoext/commonext/common.go +++ b/protolator/protoext/commonext/common.go @@ -9,10 +9,10 @@ package commonext import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/common" - "github.com/hyperledger/fabric-protos-go/msp" - "github.com/hyperledger/fabric-protos-go/peer" + "github.com/hyperledger/fabric-protos-go-apiv2/common" + "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "github.com/hyperledger/fabric-protos-go-apiv2/peer" + "google.golang.org/protobuf/proto" ) type Envelope struct{ *common.Envelope } diff --git a/protolator/protoext/commonext/common_test.go b/protolator/protoext/commonext/common_test.go index 31e0d1d..922ddfe 100644 --- a/protolator/protoext/commonext/common_test.go +++ b/protolator/protoext/commonext/common_test.go @@ -9,8 +9,8 @@ package commonext import ( "testing" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-protos-go-apiv2/common" + "google.golang.org/protobuf/proto" . "github.com/onsi/gomega" ) diff --git a/protolator/protoext/commonext/configtx.go b/protolator/protoext/commonext/configtx.go index 841415c..3c689cb 100644 --- a/protolator/protoext/commonext/configtx.go +++ b/protolator/protoext/commonext/configtx.go @@ -9,8 +9,8 @@ package commonext import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-protos-go-apiv2/common" + "google.golang.org/protobuf/proto" ) type ConfigUpdateEnvelope struct{ *common.ConfigUpdateEnvelope } diff --git a/protolator/protoext/commonext/configuration.go b/protolator/protoext/commonext/configuration.go index f11f860..10dd16d 100644 --- a/protolator/protoext/commonext/configuration.go +++ b/protolator/protoext/commonext/configuration.go @@ -9,11 +9,11 @@ package commonext import ( "fmt" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/protolator/protoext/ordererext" "github.com/hyperledger/fabric-config/protolator/protoext/peerext" - "github.com/hyperledger/fabric-protos-go/common" - "github.com/hyperledger/fabric-protos-go/msp" + "github.com/hyperledger/fabric-protos-go-apiv2/common" + "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "google.golang.org/protobuf/proto" ) type DynamicChannelGroup struct { diff --git a/protolator/protoext/commonext/policies.go b/protolator/protoext/commonext/policies.go index 5cbbd30..6ff1984 100644 --- a/protolator/protoext/commonext/policies.go +++ b/protolator/protoext/commonext/policies.go @@ -9,8 +9,8 @@ package commonext import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-protos-go-apiv2/common" + "google.golang.org/protobuf/proto" ) type Policy struct{ *common.Policy } diff --git a/protolator/protoext/decorate.go b/protolator/protoext/decorate.go index a59565b..7815072 100644 --- a/protolator/protoext/decorate.go +++ b/protolator/protoext/decorate.go @@ -7,17 +7,17 @@ SPDX-License-Identifier: Apache-2.0 package protoext import ( - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/protolator/protoext/commonext" "github.com/hyperledger/fabric-config/protolator/protoext/ledger/rwsetext" "github.com/hyperledger/fabric-config/protolator/protoext/mspext" "github.com/hyperledger/fabric-config/protolator/protoext/ordererext" "github.com/hyperledger/fabric-config/protolator/protoext/peerext" - "github.com/hyperledger/fabric-protos-go/common" - "github.com/hyperledger/fabric-protos-go/ledger/rwset" - "github.com/hyperledger/fabric-protos-go/msp" - "github.com/hyperledger/fabric-protos-go/orderer" - "github.com/hyperledger/fabric-protos-go/peer" + "github.com/hyperledger/fabric-protos-go-apiv2/common" + "github.com/hyperledger/fabric-protos-go-apiv2/ledger/rwset" + "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "github.com/hyperledger/fabric-protos-go-apiv2/orderer" + "github.com/hyperledger/fabric-protos-go-apiv2/peer" + "google.golang.org/protobuf/proto" ) // Docorate will add additional capabilities to some protobuf messages that diff --git a/protolator/protoext/decorate_test.go b/protolator/protoext/decorate_test.go index 7eec178..f8bcf95 100644 --- a/protolator/protoext/decorate_test.go +++ b/protolator/protoext/decorate_test.go @@ -9,20 +9,19 @@ package protoext import ( "testing" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-config/protolator/protoext/commonext" "github.com/hyperledger/fabric-config/protolator/protoext/ledger/rwsetext" "github.com/hyperledger/fabric-config/protolator/protoext/mspext" "github.com/hyperledger/fabric-config/protolator/protoext/ordererext" "github.com/hyperledger/fabric-config/protolator/protoext/peerext" - "github.com/hyperledger/fabric-protos-go/common" - "github.com/hyperledger/fabric-protos-go/ledger/rwset" - "github.com/hyperledger/fabric-protos-go/msp" - "github.com/hyperledger/fabric-protos-go/orderer" - "github.com/hyperledger/fabric-protos-go/peer" - + "github.com/hyperledger/fabric-protos-go-apiv2/common" + "github.com/hyperledger/fabric-protos-go-apiv2/ledger/rwset" + "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "github.com/hyperledger/fabric-protos-go-apiv2/orderer" + "github.com/hyperledger/fabric-protos-go-apiv2/peer" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/protoadapt" ) type GenericProtoMessage struct { @@ -292,12 +291,12 @@ func TestDecorate(t *testing.T) { }, { testSpec: "default", - msg: &GenericProtoMessage{ + msg: protoadapt.MessageV2Of(&GenericProtoMessage{ GenericField: "test", - }, - expectedReturn: &GenericProtoMessage{ + }), + expectedReturn: protoadapt.MessageV2Of(&GenericProtoMessage{ GenericField: "test", - }, + }), }, } diff --git a/protolator/protoext/ledger/rwsetext/rwset.go b/protolator/protoext/ledger/rwsetext/rwset.go index 9a578e8..f70f2c0 100644 --- a/protolator/protoext/ledger/rwsetext/rwset.go +++ b/protolator/protoext/ledger/rwsetext/rwset.go @@ -9,9 +9,9 @@ package rwsetext import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/ledger/rwset" - "github.com/hyperledger/fabric-protos-go/ledger/rwset/kvrwset" + "github.com/hyperledger/fabric-protos-go-apiv2/ledger/rwset" + "github.com/hyperledger/fabric-protos-go-apiv2/ledger/rwset/kvrwset" + "google.golang.org/protobuf/proto" ) type TxReadWriteSet struct{ *rwset.TxReadWriteSet } diff --git a/protolator/protoext/mspext/msp_config.go b/protolator/protoext/mspext/msp_config.go index 8fbc7be..2bbe661 100644 --- a/protolator/protoext/mspext/msp_config.go +++ b/protolator/protoext/mspext/msp_config.go @@ -9,8 +9,8 @@ package mspext import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/msp" + "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "google.golang.org/protobuf/proto" ) type MSPConfig struct{ *msp.MSPConfig } diff --git a/protolator/protoext/mspext/msp_principal.go b/protolator/protoext/mspext/msp_principal.go index f8c45f5..43cb1d2 100644 --- a/protolator/protoext/mspext/msp_principal.go +++ b/protolator/protoext/mspext/msp_principal.go @@ -9,8 +9,8 @@ package mspext import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/msp" + "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "google.golang.org/protobuf/proto" ) type MSPPrincipal struct{ *msp.MSPPrincipal } diff --git a/protolator/protoext/ordererext/configuration.go b/protolator/protoext/ordererext/configuration.go index 6c47350..005c827 100644 --- a/protolator/protoext/ordererext/configuration.go +++ b/protolator/protoext/ordererext/configuration.go @@ -9,14 +9,14 @@ package ordererext import ( "fmt" - "github.com/hyperledger/fabric-protos-go/orderer/smartbft" + "github.com/hyperledger/fabric-protos-go-apiv2/orderer/smartbft" - "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/empty" - "github.com/hyperledger/fabric-protos-go/common" - "github.com/hyperledger/fabric-protos-go/msp" - "github.com/hyperledger/fabric-protos-go/orderer" - "github.com/hyperledger/fabric-protos-go/orderer/etcdraft" + "github.com/hyperledger/fabric-protos-go-apiv2/common" + "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "github.com/hyperledger/fabric-protos-go-apiv2/orderer" + "github.com/hyperledger/fabric-protos-go-apiv2/orderer/etcdraft" + "google.golang.org/protobuf/proto" ) type DynamicOrdererGroup struct { diff --git a/protolator/protoext/peerext/configuration.go b/protolator/protoext/peerext/configuration.go index a9adc92..a7b09e1 100644 --- a/protolator/protoext/peerext/configuration.go +++ b/protolator/protoext/peerext/configuration.go @@ -9,10 +9,10 @@ package peerext import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/common" - "github.com/hyperledger/fabric-protos-go/msp" - "github.com/hyperledger/fabric-protos-go/peer" + "github.com/hyperledger/fabric-protos-go-apiv2/common" + "github.com/hyperledger/fabric-protos-go-apiv2/msp" + "github.com/hyperledger/fabric-protos-go-apiv2/peer" + "google.golang.org/protobuf/proto" ) type DynamicApplicationGroup struct { diff --git a/protolator/protoext/peerext/proposal.go b/protolator/protoext/peerext/proposal.go index ba79d3b..e9ca481 100644 --- a/protolator/protoext/peerext/proposal.go +++ b/protolator/protoext/peerext/proposal.go @@ -9,9 +9,9 @@ package peerext import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/ledger/rwset" - "github.com/hyperledger/fabric-protos-go/peer" + "github.com/hyperledger/fabric-protos-go-apiv2/ledger/rwset" + "github.com/hyperledger/fabric-protos-go-apiv2/peer" + "google.golang.org/protobuf/proto" ) type ChaincodeProposalPayload struct { diff --git a/protolator/protoext/peerext/proposal_response.go b/protolator/protoext/peerext/proposal_response.go index 508284f..0eb859a 100644 --- a/protolator/protoext/peerext/proposal_response.go +++ b/protolator/protoext/peerext/proposal_response.go @@ -9,8 +9,8 @@ package peerext import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/peer" + "github.com/hyperledger/fabric-protos-go-apiv2/peer" + "google.golang.org/protobuf/proto" ) type ProposalResponsePayload struct { diff --git a/protolator/protoext/peerext/transaction.go b/protolator/protoext/peerext/transaction.go index 552d9b3..3870811 100644 --- a/protolator/protoext/peerext/transaction.go +++ b/protolator/protoext/peerext/transaction.go @@ -9,9 +9,9 @@ package peerext import ( "fmt" - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric-protos-go/common" - "github.com/hyperledger/fabric-protos-go/peer" + "github.com/hyperledger/fabric-protos-go-apiv2/common" + "github.com/hyperledger/fabric-protos-go-apiv2/peer" + "google.golang.org/protobuf/proto" ) type TransactionAction struct { // nothing was testing this diff --git a/protolator/statically_opaque.go b/protolator/statically_opaque.go index 7e6ad81..b5b2e5c 100644 --- a/protolator/statically_opaque.go +++ b/protolator/statically_opaque.go @@ -19,7 +19,7 @@ package protolator import ( "reflect" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) func opaqueFrom(opaqueType func() (proto.Message, error), value interface{}, destType reflect.Type) (reflect.Value, error) { diff --git a/protolator/statically_opaque_test.go b/protolator/statically_opaque_test.go index 5686934..0e7aead 100644 --- a/protolator/statically_opaque_test.go +++ b/protolator/statically_opaque_test.go @@ -10,8 +10,8 @@ import ( "bytes" "testing" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/protolator/testprotos" + "google.golang.org/protobuf/proto" . "github.com/onsi/gomega" ) diff --git a/protolator/testprotos/sample.go b/protolator/testprotos/sample.go index 8a4ec05..8c208ec 100644 --- a/protolator/testprotos/sample.go +++ b/protolator/testprotos/sample.go @@ -19,7 +19,7 @@ package testprotos import ( "fmt" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) func (som *StaticallyOpaqueMsg) StaticallyOpaqueFields() []string { diff --git a/protolator/testprotos/sample.pb.go b/protolator/testprotos/sample.pb.go index db5aff5..7ae8044 100644 --- a/protolator/testprotos/sample.pb.go +++ b/protolator/testprotos/sample.pb.go @@ -1,135 +1,166 @@ +// +//Copyright IBM Corp. 2017 All Rights Reserved. +// +//Licensed under the Apache License, Version 2.0 (the "License"); +//you may not use this file except in compliance with the License. +//You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +//Unless required by applicable law or agreed to in writing, software +//distributed under the License is distributed on an "AS IS" BASIS, +//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +//See the License for the specific language governing permissions and +//limitations under the License. + // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc v5.27.3 // source: sample.proto package testprotos import ( - fmt "fmt" - math "math" + reflect "reflect" + sync "sync" - proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +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) +) // SimpleMsg is designed to test that all three types of message fields, plain, map, // and slice are handled by the protolator tool type SimpleMsg struct { - PlainField string `protobuf:"bytes,1,opt,name=plain_field,json=plainField,proto3" json:"plain_field,omitempty"` - MapField map[string]string `protobuf:"bytes,2,rep,name=map_field,json=mapField,proto3" json:"map_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SliceField []string `protobuf:"bytes,3,rep,name=slice_field,json=sliceField,proto3" json:"slice_field,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *SimpleMsg) Reset() { *m = SimpleMsg{} } -func (m *SimpleMsg) String() string { return proto.CompactTextString(m) } -func (*SimpleMsg) ProtoMessage() {} -func (*SimpleMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_2141552de9bf11d0, []int{0} + PlainField string `protobuf:"bytes,1,opt,name=plain_field,json=plainField,proto3" json:"plain_field,omitempty"` + MapField map[string]string `protobuf:"bytes,2,rep,name=map_field,json=mapField,proto3" json:"map_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SliceField []string `protobuf:"bytes,3,rep,name=slice_field,json=sliceField,proto3" json:"slice_field,omitempty"` } -func (m *SimpleMsg) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SimpleMsg.Unmarshal(m, b) -} -func (m *SimpleMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SimpleMsg.Marshal(b, m, deterministic) -} -func (m *SimpleMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_SimpleMsg.Merge(m, src) +func (x *SimpleMsg) Reset() { + *x = SimpleMsg{} + if protoimpl.UnsafeEnabled { + mi := &file_sample_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *SimpleMsg) XXX_Size() int { - return xxx_messageInfo_SimpleMsg.Size(m) + +func (x *SimpleMsg) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *SimpleMsg) XXX_DiscardUnknown() { - xxx_messageInfo_SimpleMsg.DiscardUnknown(m) + +func (*SimpleMsg) ProtoMessage() {} + +func (x *SimpleMsg) ProtoReflect() protoreflect.Message { + mi := &file_sample_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_SimpleMsg proto.InternalMessageInfo +// Deprecated: Use SimpleMsg.ProtoReflect.Descriptor instead. +func (*SimpleMsg) Descriptor() ([]byte, []int) { + return file_sample_proto_rawDescGZIP(), []int{0} +} -func (m *SimpleMsg) GetPlainField() string { - if m != nil { - return m.PlainField +func (x *SimpleMsg) GetPlainField() string { + if x != nil { + return x.PlainField } return "" } -func (m *SimpleMsg) GetMapField() map[string]string { - if m != nil { - return m.MapField +func (x *SimpleMsg) GetMapField() map[string]string { + if x != nil { + return x.MapField } return nil } -func (m *SimpleMsg) GetSliceField() []string { - if m != nil { - return m.SliceField +func (x *SimpleMsg) GetSliceField() []string { + if x != nil { + return x.SliceField } return nil } // NestedMsg is designed to test the nested message component type NestedMsg struct { - PlainNestedField *SimpleMsg `protobuf:"bytes,1,opt,name=plain_nested_field,json=plainNestedField,proto3" json:"plain_nested_field,omitempty"` - MapNestedField map[string]*SimpleMsg `protobuf:"bytes,2,rep,name=map_nested_field,json=mapNestedField,proto3" json:"map_nested_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SliceNestedField []*SimpleMsg `protobuf:"bytes,3,rep,name=slice_nested_field,json=sliceNestedField,proto3" json:"slice_nested_field,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *NestedMsg) Reset() { *m = NestedMsg{} } -func (m *NestedMsg) String() string { return proto.CompactTextString(m) } -func (*NestedMsg) ProtoMessage() {} -func (*NestedMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_2141552de9bf11d0, []int{1} + PlainNestedField *SimpleMsg `protobuf:"bytes,1,opt,name=plain_nested_field,json=plainNestedField,proto3" json:"plain_nested_field,omitempty"` + MapNestedField map[string]*SimpleMsg `protobuf:"bytes,2,rep,name=map_nested_field,json=mapNestedField,proto3" json:"map_nested_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SliceNestedField []*SimpleMsg `protobuf:"bytes,3,rep,name=slice_nested_field,json=sliceNestedField,proto3" json:"slice_nested_field,omitempty"` } -func (m *NestedMsg) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_NestedMsg.Unmarshal(m, b) -} -func (m *NestedMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_NestedMsg.Marshal(b, m, deterministic) -} -func (m *NestedMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_NestedMsg.Merge(m, src) +func (x *NestedMsg) Reset() { + *x = NestedMsg{} + if protoimpl.UnsafeEnabled { + mi := &file_sample_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *NestedMsg) XXX_Size() int { - return xxx_messageInfo_NestedMsg.Size(m) + +func (x *NestedMsg) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *NestedMsg) XXX_DiscardUnknown() { - xxx_messageInfo_NestedMsg.DiscardUnknown(m) + +func (*NestedMsg) ProtoMessage() {} + +func (x *NestedMsg) ProtoReflect() protoreflect.Message { + mi := &file_sample_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_NestedMsg proto.InternalMessageInfo +// Deprecated: Use NestedMsg.ProtoReflect.Descriptor instead. +func (*NestedMsg) Descriptor() ([]byte, []int) { + return file_sample_proto_rawDescGZIP(), []int{1} +} -func (m *NestedMsg) GetPlainNestedField() *SimpleMsg { - if m != nil { - return m.PlainNestedField +func (x *NestedMsg) GetPlainNestedField() *SimpleMsg { + if x != nil { + return x.PlainNestedField } return nil } -func (m *NestedMsg) GetMapNestedField() map[string]*SimpleMsg { - if m != nil { - return m.MapNestedField +func (x *NestedMsg) GetMapNestedField() map[string]*SimpleMsg { + if x != nil { + return x.MapNestedField } return nil } -func (m *NestedMsg) GetSliceNestedField() []*SimpleMsg { - if m != nil { - return m.SliceNestedField +func (x *NestedMsg) GetSliceNestedField() []*SimpleMsg { + if x != nil { + return x.SliceNestedField } return nil } @@ -137,56 +168,64 @@ func (m *NestedMsg) GetSliceNestedField() []*SimpleMsg { // StaticallyOpaqueMsg is designed to test the statically opaque message component // All fields are statically marshaled to the NestedMsg type type StaticallyOpaqueMsg struct { - PlainOpaqueField []byte `protobuf:"bytes,1,opt,name=plain_opaque_field,json=plainOpaqueField,proto3" json:"plain_opaque_field,omitempty"` - MapOpaqueField map[string][]byte `protobuf:"bytes,2,rep,name=map_opaque_field,json=mapOpaqueField,proto3" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SliceOpaqueField [][]byte `protobuf:"bytes,3,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_opaque_field,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *StaticallyOpaqueMsg) Reset() { *m = StaticallyOpaqueMsg{} } -func (m *StaticallyOpaqueMsg) String() string { return proto.CompactTextString(m) } -func (*StaticallyOpaqueMsg) ProtoMessage() {} -func (*StaticallyOpaqueMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_2141552de9bf11d0, []int{2} + PlainOpaqueField []byte `protobuf:"bytes,1,opt,name=plain_opaque_field,json=plainOpaqueField,proto3" json:"plain_opaque_field,omitempty"` + MapOpaqueField map[string][]byte `protobuf:"bytes,2,rep,name=map_opaque_field,json=mapOpaqueField,proto3" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SliceOpaqueField [][]byte `protobuf:"bytes,3,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_opaque_field,omitempty"` } -func (m *StaticallyOpaqueMsg) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_StaticallyOpaqueMsg.Unmarshal(m, b) -} -func (m *StaticallyOpaqueMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_StaticallyOpaqueMsg.Marshal(b, m, deterministic) -} -func (m *StaticallyOpaqueMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_StaticallyOpaqueMsg.Merge(m, src) +func (x *StaticallyOpaqueMsg) Reset() { + *x = StaticallyOpaqueMsg{} + if protoimpl.UnsafeEnabled { + mi := &file_sample_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *StaticallyOpaqueMsg) XXX_Size() int { - return xxx_messageInfo_StaticallyOpaqueMsg.Size(m) + +func (x *StaticallyOpaqueMsg) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *StaticallyOpaqueMsg) XXX_DiscardUnknown() { - xxx_messageInfo_StaticallyOpaqueMsg.DiscardUnknown(m) + +func (*StaticallyOpaqueMsg) ProtoMessage() {} + +func (x *StaticallyOpaqueMsg) ProtoReflect() protoreflect.Message { + mi := &file_sample_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_StaticallyOpaqueMsg proto.InternalMessageInfo +// Deprecated: Use StaticallyOpaqueMsg.ProtoReflect.Descriptor instead. +func (*StaticallyOpaqueMsg) Descriptor() ([]byte, []int) { + return file_sample_proto_rawDescGZIP(), []int{2} +} -func (m *StaticallyOpaqueMsg) GetPlainOpaqueField() []byte { - if m != nil { - return m.PlainOpaqueField +func (x *StaticallyOpaqueMsg) GetPlainOpaqueField() []byte { + if x != nil { + return x.PlainOpaqueField } return nil } -func (m *StaticallyOpaqueMsg) GetMapOpaqueField() map[string][]byte { - if m != nil { - return m.MapOpaqueField +func (x *StaticallyOpaqueMsg) GetMapOpaqueField() map[string][]byte { + if x != nil { + return x.MapOpaqueField } return nil } -func (m *StaticallyOpaqueMsg) GetSliceOpaqueField() [][]byte { - if m != nil { - return m.SliceOpaqueField +func (x *StaticallyOpaqueMsg) GetSliceOpaqueField() [][]byte { + if x != nil { + return x.SliceOpaqueField } return nil } @@ -194,64 +233,72 @@ func (m *StaticallyOpaqueMsg) GetSliceOpaqueField() [][]byte { // VariablyOpaqueMsg is designed to test the staticaly opaque message component // The opaque type is determined by opaque_type type VariablyOpaqueMsg struct { - OpaqueType string `protobuf:"bytes,1,opt,name=opaque_type,json=opaqueType,proto3" json:"opaque_type,omitempty"` - PlainOpaqueField []byte `protobuf:"bytes,2,opt,name=plain_opaque_field,json=plainOpaqueField,proto3" json:"plain_opaque_field,omitempty"` - MapOpaqueField map[string][]byte `protobuf:"bytes,3,rep,name=map_opaque_field,json=mapOpaqueField,proto3" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SliceOpaqueField [][]byte `protobuf:"bytes,4,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_opaque_field,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *VariablyOpaqueMsg) Reset() { *m = VariablyOpaqueMsg{} } -func (m *VariablyOpaqueMsg) String() string { return proto.CompactTextString(m) } -func (*VariablyOpaqueMsg) ProtoMessage() {} -func (*VariablyOpaqueMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_2141552de9bf11d0, []int{3} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + OpaqueType string `protobuf:"bytes,1,opt,name=opaque_type,json=opaqueType,proto3" json:"opaque_type,omitempty"` + PlainOpaqueField []byte `protobuf:"bytes,2,opt,name=plain_opaque_field,json=plainOpaqueField,proto3" json:"plain_opaque_field,omitempty"` + MapOpaqueField map[string][]byte `protobuf:"bytes,3,rep,name=map_opaque_field,json=mapOpaqueField,proto3" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SliceOpaqueField [][]byte `protobuf:"bytes,4,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_opaque_field,omitempty"` +} + +func (x *VariablyOpaqueMsg) Reset() { + *x = VariablyOpaqueMsg{} + if protoimpl.UnsafeEnabled { + mi := &file_sample_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *VariablyOpaqueMsg) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_VariablyOpaqueMsg.Unmarshal(m, b) -} -func (m *VariablyOpaqueMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_VariablyOpaqueMsg.Marshal(b, m, deterministic) -} -func (m *VariablyOpaqueMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_VariablyOpaqueMsg.Merge(m, src) -} -func (m *VariablyOpaqueMsg) XXX_Size() int { - return xxx_messageInfo_VariablyOpaqueMsg.Size(m) +func (x *VariablyOpaqueMsg) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *VariablyOpaqueMsg) XXX_DiscardUnknown() { - xxx_messageInfo_VariablyOpaqueMsg.DiscardUnknown(m) + +func (*VariablyOpaqueMsg) ProtoMessage() {} + +func (x *VariablyOpaqueMsg) ProtoReflect() protoreflect.Message { + mi := &file_sample_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_VariablyOpaqueMsg proto.InternalMessageInfo +// Deprecated: Use VariablyOpaqueMsg.ProtoReflect.Descriptor instead. +func (*VariablyOpaqueMsg) Descriptor() ([]byte, []int) { + return file_sample_proto_rawDescGZIP(), []int{3} +} -func (m *VariablyOpaqueMsg) GetOpaqueType() string { - if m != nil { - return m.OpaqueType +func (x *VariablyOpaqueMsg) GetOpaqueType() string { + if x != nil { + return x.OpaqueType } return "" } -func (m *VariablyOpaqueMsg) GetPlainOpaqueField() []byte { - if m != nil { - return m.PlainOpaqueField +func (x *VariablyOpaqueMsg) GetPlainOpaqueField() []byte { + if x != nil { + return x.PlainOpaqueField } return nil } -func (m *VariablyOpaqueMsg) GetMapOpaqueField() map[string][]byte { - if m != nil { - return m.MapOpaqueField +func (x *VariablyOpaqueMsg) GetMapOpaqueField() map[string][]byte { + if x != nil { + return x.MapOpaqueField } return nil } -func (m *VariablyOpaqueMsg) GetSliceOpaqueField() [][]byte { - if m != nil { - return m.SliceOpaqueField +func (x *VariablyOpaqueMsg) GetSliceOpaqueField() [][]byte { + if x != nil { + return x.SliceOpaqueField } return nil } @@ -260,64 +307,72 @@ func (m *VariablyOpaqueMsg) GetSliceOpaqueField() [][]byte { // The dynamic wrapper applied to ContextlessMsg is determined by // dynamic_type type DynamicMsg struct { - DynamicType string `protobuf:"bytes,1,opt,name=dynamic_type,json=dynamicType,proto3" json:"dynamic_type,omitempty"` - PlainDynamicField *ContextlessMsg `protobuf:"bytes,2,opt,name=plain_dynamic_field,json=plainDynamicField,proto3" json:"plain_dynamic_field,omitempty"` - MapDynamicField map[string]*ContextlessMsg `protobuf:"bytes,3,rep,name=map_dynamic_field,json=mapDynamicField,proto3" json:"map_dynamic_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SliceDynamicField []*ContextlessMsg `protobuf:"bytes,4,rep,name=slice_dynamic_field,json=sliceDynamicField,proto3" json:"slice_dynamic_field,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DynamicMsg) Reset() { *m = DynamicMsg{} } -func (m *DynamicMsg) String() string { return proto.CompactTextString(m) } -func (*DynamicMsg) ProtoMessage() {} -func (*DynamicMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_2141552de9bf11d0, []int{4} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DynamicType string `protobuf:"bytes,1,opt,name=dynamic_type,json=dynamicType,proto3" json:"dynamic_type,omitempty"` + PlainDynamicField *ContextlessMsg `protobuf:"bytes,2,opt,name=plain_dynamic_field,json=plainDynamicField,proto3" json:"plain_dynamic_field,omitempty"` + MapDynamicField map[string]*ContextlessMsg `protobuf:"bytes,3,rep,name=map_dynamic_field,json=mapDynamicField,proto3" json:"map_dynamic_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SliceDynamicField []*ContextlessMsg `protobuf:"bytes,4,rep,name=slice_dynamic_field,json=sliceDynamicField,proto3" json:"slice_dynamic_field,omitempty"` +} + +func (x *DynamicMsg) Reset() { + *x = DynamicMsg{} + if protoimpl.UnsafeEnabled { + mi := &file_sample_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *DynamicMsg) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DynamicMsg.Unmarshal(m, b) -} -func (m *DynamicMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DynamicMsg.Marshal(b, m, deterministic) -} -func (m *DynamicMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_DynamicMsg.Merge(m, src) +func (x *DynamicMsg) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *DynamicMsg) XXX_Size() int { - return xxx_messageInfo_DynamicMsg.Size(m) -} -func (m *DynamicMsg) XXX_DiscardUnknown() { - xxx_messageInfo_DynamicMsg.DiscardUnknown(m) + +func (*DynamicMsg) ProtoMessage() {} + +func (x *DynamicMsg) ProtoReflect() protoreflect.Message { + mi := &file_sample_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_DynamicMsg proto.InternalMessageInfo +// Deprecated: Use DynamicMsg.ProtoReflect.Descriptor instead. +func (*DynamicMsg) Descriptor() ([]byte, []int) { + return file_sample_proto_rawDescGZIP(), []int{4} +} -func (m *DynamicMsg) GetDynamicType() string { - if m != nil { - return m.DynamicType +func (x *DynamicMsg) GetDynamicType() string { + if x != nil { + return x.DynamicType } return "" } -func (m *DynamicMsg) GetPlainDynamicField() *ContextlessMsg { - if m != nil { - return m.PlainDynamicField +func (x *DynamicMsg) GetPlainDynamicField() *ContextlessMsg { + if x != nil { + return x.PlainDynamicField } return nil } -func (m *DynamicMsg) GetMapDynamicField() map[string]*ContextlessMsg { - if m != nil { - return m.MapDynamicField +func (x *DynamicMsg) GetMapDynamicField() map[string]*ContextlessMsg { + if x != nil { + return x.MapDynamicField } return nil } -func (m *DynamicMsg) GetSliceDynamicField() []*ContextlessMsg { - if m != nil { - return m.SliceDynamicField +func (x *DynamicMsg) GetSliceDynamicField() []*ContextlessMsg { + if x != nil { + return x.SliceDynamicField } return nil } @@ -326,40 +381,48 @@ func (m *DynamicMsg) GetSliceDynamicField() []*ContextlessMsg { // Because there is no context for the type embedded in the message, the opaque // type must be dynamically added at runtime type ContextlessMsg struct { - OpaqueField []byte `protobuf:"bytes,1,opt,name=opaque_field,json=opaqueField,proto3" json:"opaque_field,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *ContextlessMsg) Reset() { *m = ContextlessMsg{} } -func (m *ContextlessMsg) String() string { return proto.CompactTextString(m) } -func (*ContextlessMsg) ProtoMessage() {} -func (*ContextlessMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_2141552de9bf11d0, []int{5} + OpaqueField []byte `protobuf:"bytes,1,opt,name=opaque_field,json=opaqueField,proto3" json:"opaque_field,omitempty"` } -func (m *ContextlessMsg) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ContextlessMsg.Unmarshal(m, b) -} -func (m *ContextlessMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ContextlessMsg.Marshal(b, m, deterministic) -} -func (m *ContextlessMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_ContextlessMsg.Merge(m, src) +func (x *ContextlessMsg) Reset() { + *x = ContextlessMsg{} + if protoimpl.UnsafeEnabled { + mi := &file_sample_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *ContextlessMsg) XXX_Size() int { - return xxx_messageInfo_ContextlessMsg.Size(m) + +func (x *ContextlessMsg) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *ContextlessMsg) XXX_DiscardUnknown() { - xxx_messageInfo_ContextlessMsg.DiscardUnknown(m) + +func (*ContextlessMsg) ProtoMessage() {} + +func (x *ContextlessMsg) ProtoReflect() protoreflect.Message { + mi := &file_sample_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_ContextlessMsg proto.InternalMessageInfo +// Deprecated: Use ContextlessMsg.ProtoReflect.Descriptor instead. +func (*ContextlessMsg) Descriptor() ([]byte, []int) { + return file_sample_proto_rawDescGZIP(), []int{5} +} -func (m *ContextlessMsg) GetOpaqueField() []byte { - if m != nil { - return m.OpaqueField +func (x *ContextlessMsg) GetOpaqueField() []byte { + if x != nil { + return x.OpaqueField } return nil } @@ -367,117 +430,350 @@ func (m *ContextlessMsg) GetOpaqueField() []byte { // UnmarshalableDeepFields contains fields which are defined to be opaque, but will // return an error if they are asked to be deserialized. type UnmarshalableDeepFields struct { - PlainOpaqueField []byte `protobuf:"bytes,1,opt,name=plain_opaque_field,json=plainOpaqueField,proto3" json:"plain_opaque_field,omitempty"` - MapOpaqueField map[string][]byte `protobuf:"bytes,2,rep,name=map_opaque_field,json=mapOpaqueField,proto3" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SliceOpaqueField [][]byte `protobuf:"bytes,3,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_opaque_field,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *UnmarshalableDeepFields) Reset() { *m = UnmarshalableDeepFields{} } -func (m *UnmarshalableDeepFields) String() string { return proto.CompactTextString(m) } -func (*UnmarshalableDeepFields) ProtoMessage() {} -func (*UnmarshalableDeepFields) Descriptor() ([]byte, []int) { - return fileDescriptor_2141552de9bf11d0, []int{6} + PlainOpaqueField []byte `protobuf:"bytes,1,opt,name=plain_opaque_field,json=plainOpaqueField,proto3" json:"plain_opaque_field,omitempty"` + MapOpaqueField map[string][]byte `protobuf:"bytes,2,rep,name=map_opaque_field,json=mapOpaqueField,proto3" json:"map_opaque_field,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SliceOpaqueField [][]byte `protobuf:"bytes,3,rep,name=slice_opaque_field,json=sliceOpaqueField,proto3" json:"slice_opaque_field,omitempty"` } -func (m *UnmarshalableDeepFields) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UnmarshalableDeepFields.Unmarshal(m, b) -} -func (m *UnmarshalableDeepFields) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UnmarshalableDeepFields.Marshal(b, m, deterministic) -} -func (m *UnmarshalableDeepFields) XXX_Merge(src proto.Message) { - xxx_messageInfo_UnmarshalableDeepFields.Merge(m, src) +func (x *UnmarshalableDeepFields) Reset() { + *x = UnmarshalableDeepFields{} + if protoimpl.UnsafeEnabled { + mi := &file_sample_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *UnmarshalableDeepFields) XXX_Size() int { - return xxx_messageInfo_UnmarshalableDeepFields.Size(m) + +func (x *UnmarshalableDeepFields) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *UnmarshalableDeepFields) XXX_DiscardUnknown() { - xxx_messageInfo_UnmarshalableDeepFields.DiscardUnknown(m) + +func (*UnmarshalableDeepFields) ProtoMessage() {} + +func (x *UnmarshalableDeepFields) ProtoReflect() protoreflect.Message { + mi := &file_sample_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_UnmarshalableDeepFields proto.InternalMessageInfo +// Deprecated: Use UnmarshalableDeepFields.ProtoReflect.Descriptor instead. +func (*UnmarshalableDeepFields) Descriptor() ([]byte, []int) { + return file_sample_proto_rawDescGZIP(), []int{6} +} -func (m *UnmarshalableDeepFields) GetPlainOpaqueField() []byte { - if m != nil { - return m.PlainOpaqueField +func (x *UnmarshalableDeepFields) GetPlainOpaqueField() []byte { + if x != nil { + return x.PlainOpaqueField } return nil } -func (m *UnmarshalableDeepFields) GetMapOpaqueField() map[string][]byte { - if m != nil { - return m.MapOpaqueField +func (x *UnmarshalableDeepFields) GetMapOpaqueField() map[string][]byte { + if x != nil { + return x.MapOpaqueField } return nil } -func (m *UnmarshalableDeepFields) GetSliceOpaqueField() [][]byte { - if m != nil { - return m.SliceOpaqueField +func (x *UnmarshalableDeepFields) GetSliceOpaqueField() [][]byte { + if x != nil { + return x.SliceOpaqueField } return nil } -func init() { - proto.RegisterType((*SimpleMsg)(nil), "testprotos.SimpleMsg") - proto.RegisterMapType((map[string]string)(nil), "testprotos.SimpleMsg.MapFieldEntry") - proto.RegisterType((*NestedMsg)(nil), "testprotos.NestedMsg") - proto.RegisterMapType((map[string]*SimpleMsg)(nil), "testprotos.NestedMsg.MapNestedFieldEntry") - proto.RegisterType((*StaticallyOpaqueMsg)(nil), "testprotos.StaticallyOpaqueMsg") - proto.RegisterMapType((map[string][]byte)(nil), "testprotos.StaticallyOpaqueMsg.MapOpaqueFieldEntry") - proto.RegisterType((*VariablyOpaqueMsg)(nil), "testprotos.VariablyOpaqueMsg") - proto.RegisterMapType((map[string][]byte)(nil), "testprotos.VariablyOpaqueMsg.MapOpaqueFieldEntry") - proto.RegisterType((*DynamicMsg)(nil), "testprotos.DynamicMsg") - proto.RegisterMapType((map[string]*ContextlessMsg)(nil), "testprotos.DynamicMsg.MapDynamicFieldEntry") - proto.RegisterType((*ContextlessMsg)(nil), "testprotos.ContextlessMsg") - proto.RegisterType((*UnmarshalableDeepFields)(nil), "testprotos.UnmarshalableDeepFields") - proto.RegisterMapType((map[string][]byte)(nil), "testprotos.UnmarshalableDeepFields.MapOpaqueFieldEntry") -} - -func init() { proto.RegisterFile("sample.proto", fileDescriptor_2141552de9bf11d0) } - -var fileDescriptor_2141552de9bf11d0 = []byte{ - // 617 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x94, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0x86, 0x15, 0xbb, 0x20, 0x72, 0x1c, 0x4a, 0xe2, 0x14, 0x51, 0x65, 0xd3, 0x10, 0x36, 0x45, - 0xad, 0x62, 0x48, 0x16, 0x20, 0xd8, 0x94, 0xb6, 0xb0, 0x40, 0x2a, 0x48, 0x09, 0x37, 0x81, 0x00, - 0x4d, 0x9c, 0x69, 0x62, 0x31, 0xbe, 0xe0, 0x99, 0x20, 0xbc, 0xe3, 0x1d, 0x58, 0xf2, 0x12, 0x3c, - 0x04, 0x4b, 0x1e, 0x0a, 0xcd, 0x25, 0xcd, 0x19, 0x6a, 0x17, 0x21, 0x84, 0xd4, 0x55, 0xe2, 0xe3, - 0x39, 0xff, 0xf9, 0xff, 0xcf, 0x33, 0x03, 0x0d, 0x4e, 0xe2, 0x8c, 0xd1, 0x7e, 0x96, 0xa7, 0x22, - 0xf5, 0x41, 0x50, 0x2e, 0xd4, 0x5f, 0xde, 0xfb, 0x59, 0x83, 0xfa, 0x38, 0x92, 0x2f, 0x8f, 0xf8, - 0xcc, 0xdf, 0x02, 0x2f, 0x63, 0x24, 0x4a, 0xde, 0x1f, 0x47, 0x94, 0x4d, 0x37, 0x6b, 0xdd, 0xda, - 0x76, 0x7d, 0x04, 0xaa, 0xf4, 0x48, 0x56, 0xfc, 0x3d, 0xa8, 0xc7, 0x24, 0x33, 0xaf, 0x9d, 0xae, - 0xbb, 0xed, 0x0d, 0x6e, 0xf4, 0x57, 0x72, 0xfd, 0x13, 0xa9, 0xfe, 0x11, 0xc9, 0x54, 0xcb, 0xc3, - 0x44, 0xe4, 0xc5, 0xe8, 0x52, 0x6c, 0x1e, 0xe5, 0x08, 0xce, 0xa2, 0x90, 0x1a, 0x0d, 0xb7, 0xeb, - 0xca, 0x11, 0xaa, 0xa4, 0x16, 0x74, 0xee, 0xc3, 0x65, 0xab, 0xd7, 0x6f, 0x82, 0xfb, 0x81, 0x16, - 0xc6, 0x8c, 0xfc, 0xeb, 0x6f, 0xc0, 0x85, 0x4f, 0x84, 0x2d, 0xe8, 0xa6, 0xa3, 0x6a, 0xfa, 0xe1, - 0x9e, 0x73, 0xb7, 0xd6, 0xfb, 0xe1, 0x40, 0xfd, 0x09, 0xe5, 0x82, 0x4e, 0x65, 0x9c, 0x03, 0xf0, - 0x75, 0x9c, 0x44, 0x95, 0x50, 0x2a, 0x6f, 0x70, 0xb5, 0xd4, 0xf6, 0xa8, 0xa9, 0x1a, 0xb4, 0x84, - 0x36, 0x3c, 0x86, 0xa6, 0x8c, 0x6c, 0x49, 0xe8, 0xe4, 0x37, 0xb1, 0xc4, 0xc9, 0x54, 0x99, 0x1c, - 0xf5, 0xeb, 0xfc, 0xeb, 0xb1, 0x55, 0x94, 0xce, 0x34, 0x05, 0x4b, 0xd6, 0x55, 0xb2, 0x55, 0xce, - 0x54, 0x03, 0x12, 0xe9, 0xbc, 0x82, 0x76, 0xc9, 0xac, 0x12, 0x5e, 0x3b, 0x98, 0x57, 0xe5, 0x00, - 0x84, 0xf1, 0xab, 0x03, 0xed, 0xb1, 0x20, 0x22, 0x0a, 0x09, 0x63, 0xc5, 0xd3, 0x8c, 0x7c, 0x5c, - 0xa8, 0xfd, 0xb1, 0xbb, 0x04, 0x9a, 0xaa, 0x12, 0x02, 0xda, 0x30, 0xe4, 0xf4, 0x5a, 0x1d, 0xf2, - 0xad, 0x26, 0x67, 0xad, 0xd5, 0xe4, 0x86, 0x96, 0x83, 0xd3, 0x83, 0x24, 0x43, 0xa4, 0xb4, 0x62, - 0x88, 0xe5, 0x77, 0x97, 0x0c, 0xad, 0x01, 0x92, 0x61, 0xc3, 0xc0, 0x42, 0xab, 0x3b, 0x0f, 0x14, - 0xac, 0xdf, 0x45, 0xff, 0xb4, 0xb9, 0x1a, 0x98, 0xca, 0x77, 0x07, 0x5a, 0x2f, 0x48, 0x1e, 0x91, - 0x09, 0x66, 0xb2, 0x05, 0x9e, 0x31, 0x20, 0x8a, 0x8c, 0x2e, 0xcf, 0x8c, 0x2e, 0x3d, 0x2b, 0x32, - 0x5a, 0x01, 0xcd, 0xa9, 0x80, 0xf6, 0xa6, 0x04, 0x9a, 0xde, 0x17, 0xb7, 0x31, 0xb4, 0x53, 0x3e, - 0xfe, 0x01, 0xd9, 0xda, 0xff, 0x43, 0xf6, 0xc5, 0x05, 0x38, 0x2c, 0x12, 0x12, 0x47, 0xa1, 0x64, - 0x75, 0x1d, 0x1a, 0x53, 0xfd, 0x84, 0x61, 0x79, 0xa6, 0xa6, 0x68, 0x3d, 0x86, 0xb6, 0xa6, 0xb5, - 0x5c, 0xb8, 0xc2, 0xe5, 0x0d, 0x3a, 0x18, 0xc1, 0x41, 0x9a, 0x08, 0xfa, 0x59, 0x30, 0xca, 0xb9, - 0xdc, 0xbe, 0x2d, 0xd5, 0x66, 0x86, 0xe9, 0xb8, 0x2f, 0xa1, 0x25, 0x59, 0xda, 0x4a, 0x1a, 0xe6, - 0x0e, 0x56, 0x5a, 0x39, 0x94, 0x14, 0xb1, 0x84, 0xc6, 0x78, 0x25, 0xb6, 0xab, 0xd2, 0xa4, 0xe6, - 0x68, 0x4b, 0xaf, 0x29, 0xe9, 0x33, 0x4d, 0xaa, 0x36, 0xac, 0xd5, 0x79, 0x07, 0x1b, 0x65, 0x43, - 0x4b, 0x30, 0xdf, 0xb2, 0x8f, 0xf1, 0x59, 0x73, 0xd0, 0x27, 0x18, 0xc2, 0xba, 0xfd, 0x52, 0x7e, - 0x85, 0x92, 0xf3, 0x6b, 0x76, 0xb1, 0x72, 0xd0, 0xfb, 0xe6, 0xc0, 0xb5, 0xe7, 0x49, 0x4c, 0x72, - 0x3e, 0x27, 0x8c, 0x4c, 0x18, 0x3d, 0xa4, 0x54, 0xdf, 0xc9, 0xfc, 0x2f, 0x2f, 0x01, 0x52, 0x79, - 0x09, 0xdc, 0xc1, 0xfe, 0x2b, 0x86, 0x9d, 0xcb, 0x8b, 0x60, 0x7f, 0xff, 0xf5, 0xde, 0x2c, 0x12, - 0xf3, 0xc5, 0xa4, 0x1f, 0xa6, 0x71, 0x30, 0x2f, 0x32, 0x9a, 0x33, 0x3a, 0x9d, 0xd1, 0x3c, 0x38, - 0x26, 0x93, 0x3c, 0x0a, 0x83, 0x30, 0x8d, 0xe3, 0x34, 0x09, 0x44, 0x9a, 0x32, 0x1e, 0xa8, 0x84, - 0x8c, 0x88, 0x34, 0x0f, 0x56, 0x81, 0x27, 0x17, 0xd5, 0xef, 0xf0, 0x57, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xbc, 0xe8, 0xa5, 0x47, 0x9b, 0x07, 0x00, 0x00, +var File_sample_proto protoreflect.FileDescriptor + +var file_sample_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, + 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x22, 0xcc, 0x01, 0x0a, 0x09, 0x53, + 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x73, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6c, 0x61, 0x69, + 0x6e, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, + 0x6c, 0x61, 0x69, 0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x40, 0x0a, 0x09, 0x6d, 0x61, 0x70, + 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, + 0x4d, 0x73, 0x67, 0x2e, 0x4d, 0x61, 0x70, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x08, 0x6d, 0x61, 0x70, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x73, + 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x0a, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x1a, 0x3b, 0x0a, 0x0d, + 0x4d, 0x61, 0x70, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xc4, 0x02, 0x0a, 0x09, 0x4e, 0x65, + 0x73, 0x74, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x12, 0x43, 0x0a, 0x12, 0x70, 0x6c, 0x61, 0x69, 0x6e, + 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, + 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x73, 0x67, 0x52, 0x10, 0x70, 0x6c, 0x61, 0x69, + 0x6e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x53, 0x0a, 0x10, + 0x6d, 0x61, 0x70, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x73, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x2e, 0x4d, 0x61, + 0x70, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x0e, 0x6d, 0x61, 0x70, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x12, 0x43, 0x0a, 0x12, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, + 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, + 0x65, 0x4d, 0x73, 0x67, 0x52, 0x10, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x4e, 0x65, 0x73, 0x74, 0x65, + 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x1a, 0x58, 0x0a, 0x13, 0x4d, 0x61, 0x70, 0x4e, 0x65, 0x73, + 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x2b, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, + 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x53, 0x69, 0x6d, 0x70, + 0x6c, 0x65, 0x4d, 0x73, 0x67, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0x93, 0x02, 0x0a, 0x13, 0x53, 0x74, 0x61, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x6c, 0x79, 0x4f, + 0x70, 0x61, 0x71, 0x75, 0x65, 0x4d, 0x73, 0x67, 0x12, 0x2c, 0x0a, 0x12, 0x70, 0x6c, 0x61, 0x69, + 0x6e, 0x5f, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x4f, 0x70, 0x61, 0x71, 0x75, + 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x5d, 0x0a, 0x10, 0x6d, 0x61, 0x70, 0x5f, 0x6f, 0x70, + 0x61, 0x71, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x33, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x53, 0x74, + 0x61, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x6c, 0x79, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x4d, 0x73, + 0x67, 0x2e, 0x4d, 0x61, 0x70, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x6d, 0x61, 0x70, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x6f, + 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0c, 0x52, 0x10, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x1a, 0x41, 0x0a, 0x13, 0x4d, 0x61, 0x70, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xb0, 0x02, 0x0a, 0x11, 0x56, 0x61, 0x72, 0x69, 0x61, + 0x62, 0x6c, 0x79, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x4d, 0x73, 0x67, 0x12, 0x1f, 0x0a, 0x0b, + 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2c, 0x0a, + 0x12, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x66, 0x69, + 0x65, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x70, 0x6c, 0x61, 0x69, 0x6e, + 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x5b, 0x0a, 0x10, 0x6d, + 0x61, 0x70, 0x5f, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x73, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x79, 0x4f, 0x70, 0x61, 0x71, 0x75, + 0x65, 0x4d, 0x73, 0x67, 0x2e, 0x4d, 0x61, 0x70, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x6d, 0x61, 0x70, 0x4f, 0x70, 0x61, + 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x6c, 0x69, 0x63, + 0x65, 0x5f, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0c, 0x52, 0x10, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x61, 0x71, 0x75, + 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x1a, 0x41, 0x0a, 0x13, 0x4d, 0x61, 0x70, 0x4f, 0x70, 0x61, + 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x80, 0x03, 0x0a, 0x0a, 0x44, 0x79, + 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x4d, 0x73, 0x67, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x79, 0x6e, 0x61, + 0x6d, 0x69, 0x63, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x64, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4a, 0x0a, 0x13, 0x70, + 0x6c, 0x61, 0x69, 0x6e, 0x5f, 0x64, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x5f, 0x66, 0x69, 0x65, + 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x6c, 0x65, 0x73, + 0x73, 0x4d, 0x73, 0x67, 0x52, 0x11, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x44, 0x79, 0x6e, 0x61, 0x6d, + 0x69, 0x63, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x57, 0x0a, 0x11, 0x6d, 0x61, 0x70, 0x5f, 0x64, + 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, + 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x4d, 0x73, 0x67, 0x2e, 0x4d, 0x61, 0x70, 0x44, 0x79, + 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x0f, 0x6d, 0x61, 0x70, 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x12, 0x4a, 0x0a, 0x13, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x64, 0x79, 0x6e, 0x61, 0x6d, 0x69, + 0x63, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x78, 0x74, 0x6c, 0x65, 0x73, 0x73, 0x4d, 0x73, 0x67, 0x52, 0x11, 0x73, 0x6c, 0x69, 0x63, 0x65, + 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x1a, 0x5e, 0x0a, 0x14, + 0x4d, 0x61, 0x70, 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x30, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x6c, 0x65, 0x73, 0x73, 0x4d, 0x73, + 0x67, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x33, 0x0a, 0x0e, + 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x6c, 0x65, 0x73, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x21, + 0x0a, 0x0c, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x22, 0x9b, 0x02, 0x0a, 0x17, 0x55, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c, 0x61, + 0x62, 0x6c, 0x65, 0x44, 0x65, 0x65, 0x70, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x12, 0x2c, 0x0a, + 0x12, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x66, 0x69, + 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x70, 0x6c, 0x61, 0x69, 0x6e, + 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x61, 0x0a, 0x10, 0x6d, + 0x61, 0x70, 0x5f, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x73, 0x2e, 0x55, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c, 0x61, 0x62, 0x6c, 0x65, + 0x44, 0x65, 0x65, 0x70, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x2e, 0x4d, 0x61, 0x70, 0x4f, 0x70, + 0x61, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, + 0x6d, 0x61, 0x70, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x2c, + 0x0a, 0x12, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x66, + 0x69, 0x65, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x10, 0x73, 0x6c, 0x69, 0x63, + 0x65, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x1a, 0x41, 0x0a, 0x13, + 0x4d, 0x61, 0x70, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, + 0x3c, 0x5a, 0x3a, 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, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6c, 0x61, 0x74, + 0x6f, 0x72, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_sample_proto_rawDescOnce sync.Once + file_sample_proto_rawDescData = file_sample_proto_rawDesc +) + +func file_sample_proto_rawDescGZIP() []byte { + file_sample_proto_rawDescOnce.Do(func() { + file_sample_proto_rawDescData = protoimpl.X.CompressGZIP(file_sample_proto_rawDescData) + }) + return file_sample_proto_rawDescData +} + +var file_sample_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_sample_proto_goTypes = []any{ + (*SimpleMsg)(nil), // 0: testprotos.SimpleMsg + (*NestedMsg)(nil), // 1: testprotos.NestedMsg + (*StaticallyOpaqueMsg)(nil), // 2: testprotos.StaticallyOpaqueMsg + (*VariablyOpaqueMsg)(nil), // 3: testprotos.VariablyOpaqueMsg + (*DynamicMsg)(nil), // 4: testprotos.DynamicMsg + (*ContextlessMsg)(nil), // 5: testprotos.ContextlessMsg + (*UnmarshalableDeepFields)(nil), // 6: testprotos.UnmarshalableDeepFields + nil, // 7: testprotos.SimpleMsg.MapFieldEntry + nil, // 8: testprotos.NestedMsg.MapNestedFieldEntry + nil, // 9: testprotos.StaticallyOpaqueMsg.MapOpaqueFieldEntry + nil, // 10: testprotos.VariablyOpaqueMsg.MapOpaqueFieldEntry + nil, // 11: testprotos.DynamicMsg.MapDynamicFieldEntry + nil, // 12: testprotos.UnmarshalableDeepFields.MapOpaqueFieldEntry +} +var file_sample_proto_depIdxs = []int32{ + 7, // 0: testprotos.SimpleMsg.map_field:type_name -> testprotos.SimpleMsg.MapFieldEntry + 0, // 1: testprotos.NestedMsg.plain_nested_field:type_name -> testprotos.SimpleMsg + 8, // 2: testprotos.NestedMsg.map_nested_field:type_name -> testprotos.NestedMsg.MapNestedFieldEntry + 0, // 3: testprotos.NestedMsg.slice_nested_field:type_name -> testprotos.SimpleMsg + 9, // 4: testprotos.StaticallyOpaqueMsg.map_opaque_field:type_name -> testprotos.StaticallyOpaqueMsg.MapOpaqueFieldEntry + 10, // 5: testprotos.VariablyOpaqueMsg.map_opaque_field:type_name -> testprotos.VariablyOpaqueMsg.MapOpaqueFieldEntry + 5, // 6: testprotos.DynamicMsg.plain_dynamic_field:type_name -> testprotos.ContextlessMsg + 11, // 7: testprotos.DynamicMsg.map_dynamic_field:type_name -> testprotos.DynamicMsg.MapDynamicFieldEntry + 5, // 8: testprotos.DynamicMsg.slice_dynamic_field:type_name -> testprotos.ContextlessMsg + 12, // 9: testprotos.UnmarshalableDeepFields.map_opaque_field:type_name -> testprotos.UnmarshalableDeepFields.MapOpaqueFieldEntry + 0, // 10: testprotos.NestedMsg.MapNestedFieldEntry.value:type_name -> testprotos.SimpleMsg + 5, // 11: testprotos.DynamicMsg.MapDynamicFieldEntry.value:type_name -> testprotos.ContextlessMsg + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name +} + +func init() { file_sample_proto_init() } +func file_sample_proto_init() { + if File_sample_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_sample_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*SimpleMsg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sample_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*NestedMsg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sample_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*StaticallyOpaqueMsg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sample_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*VariablyOpaqueMsg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sample_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*DynamicMsg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sample_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*ContextlessMsg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sample_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*UnmarshalableDeepFields); 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_sample_proto_rawDesc, + NumEnums: 0, + NumMessages: 13, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_sample_proto_goTypes, + DependencyIndexes: file_sample_proto_depIdxs, + MessageInfos: file_sample_proto_msgTypes, + }.Build() + File_sample_proto = out.File + file_sample_proto_rawDesc = nil + file_sample_proto_goTypes = nil + file_sample_proto_depIdxs = nil } diff --git a/protolator/variably_opaque.go b/protolator/variably_opaque.go index f4f1e38..49e3889 100644 --- a/protolator/variably_opaque.go +++ b/protolator/variably_opaque.go @@ -19,7 +19,7 @@ package protolator import ( "reflect" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) type variablyOpaqueFieldFactory struct{} diff --git a/protolator/variably_opaque_test.go b/protolator/variably_opaque_test.go index 9436830..4bbc5fa 100644 --- a/protolator/variably_opaque_test.go +++ b/protolator/variably_opaque_test.go @@ -10,8 +10,8 @@ import ( "bytes" "testing" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-config/protolator/testprotos" + "google.golang.org/protobuf/proto" . "github.com/onsi/gomega" )