Skip to content

Commit

Permalink
[FAB-17123] Update dep for fabric-protos-go
Browse files Browse the repository at this point in the history
* Move type references for protobufs related to collection from common
to peer package

Change-Id: I42427393e8b7813f8025879cb3c3d48dc19125e0
Signed-off-by: Danny Cao <[email protected]>
  • Loading branch information
caod123 authored and mastersingh24 committed Nov 22, 2019
1 parent 8d073c1 commit fb56820
Show file tree
Hide file tree
Showing 90 changed files with 1,571 additions and 1,251 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions common/chaincode/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ package chaincode
import (
"sync"

"github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric-protos-go/gossip"
"github.com/hyperledger/fabric-protos-go/peer"
)

// InstalledChaincode defines metadata about an installed chaincode
Expand All @@ -36,7 +36,7 @@ type Metadata struct {
Version string
Policy []byte
Id []byte
CollectionsConfig *common.CollectionConfigPackage
CollectionsConfig *peer.CollectionConfigPackage
// These two fields (Approved, Installed) are only set for
// _lifecycle chaincodes. They are used to ensure service
// discovery doesn't publish a stale chaincode definition
Expand Down
6 changes: 3 additions & 3 deletions core/cclifecycle/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"testing"
"time"

"github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric/common/chaincode"
"github.com/hyperledger/fabric/common/flogging/floggingtest"
"github.com/hyperledger/fabric/core/cclifecycle"
Expand Down Expand Up @@ -446,14 +446,14 @@ func TestMetadata(t *testing.T) {
// and go straight into the stateDB.
queryCreator.On("NewQuery").Return(query, nil).Once()
query.On("GetState", "lscc", "cc1").Return(cc1Bytes, nil).Once()
query.On("GetState", "lscc", privdata.BuildCollectionKVSKey("cc1")).Return(protoutil.MarshalOrPanic(&common.CollectionConfigPackage{}), nil).Once()
query.On("GetState", "lscc", privdata.BuildCollectionKVSKey("cc1")).Return(protoutil.MarshalOrPanic(&peer.CollectionConfigPackage{}), nil).Once()
md = m.Metadata("mychannel", "cc1", true)
assert.Equal(t, &chaincode.Metadata{
Name: "cc1",
Version: "1.0",
Id: []byte{42},
Policy: []byte{1, 2, 3, 4, 5},
CollectionsConfig: &common.CollectionConfigPackage{},
CollectionsConfig: &peer.CollectionConfigPackage{},
}, md)
assertLogged(t, recorder, "Retrieved collection config for cc1 from cc1~collection")

Expand Down
6 changes: 3 additions & 3 deletions core/chaincode/exectransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func getDeploymentSpec(spec *pb.ChaincodeSpec) (*pb.ChaincodeDeploymentSpec, err
}

//getDeployLSCCSpec gets the spec for the chaincode deployment to be sent to LSCC
func getDeployLSCCSpec(channelID string, cds *pb.ChaincodeDeploymentSpec, ccp *common.CollectionConfigPackage) (*pb.ChaincodeInvocationSpec, error) {
func getDeployLSCCSpec(channelID string, cds *pb.ChaincodeDeploymentSpec, ccp *pb.CollectionConfigPackage) (*pb.ChaincodeInvocationSpec, error) {
b, err := proto.Marshal(cds)
if err != nil {
return nil, err
Expand Down Expand Up @@ -439,7 +439,7 @@ func deploy(channelID string, ccContext *CCContext, spec *pb.ChaincodeSpec, bloc
}

func deployWithCollectionConfigs(channelID string, ccContext *CCContext, spec *pb.ChaincodeSpec,
collectionConfigPkg *common.CollectionConfigPackage, blockNumber uint64, chaincodeSupport *ChaincodeSupport) (resp *pb.Response, err error) {
collectionConfigPkg *pb.CollectionConfigPackage, blockNumber uint64, chaincodeSupport *ChaincodeSupport) (resp *pb.Response, err error) {
// First build and get the deployment spec
cdDeploymentSpec, err := getDeploymentSpec(spec)
if err != nil {
Expand All @@ -449,7 +449,7 @@ func deployWithCollectionConfigs(channelID string, ccContext *CCContext, spec *p
}

func deploy2(channelID string, ccContext *CCContext, chaincodeDeploymentSpec *pb.ChaincodeDeploymentSpec,
collectionConfigPkg *common.CollectionConfigPackage, blockNumber uint64, chaincodeSupport *ChaincodeSupport) (resp *pb.Response, err error) {
collectionConfigPkg *pb.CollectionConfigPackage, blockNumber uint64, chaincodeSupport *ChaincodeSupport) (resp *pb.Response, err error) {
cis, err := getDeployLSCCSpec(channelID, chaincodeDeploymentSpec, collectionConfigPkg)
if err != nil {
return nil, fmt.Errorf("Error creating lscc spec : %s\n", err)
Expand Down
13 changes: 6 additions & 7 deletions core/chaincode/executetransaction_pvtdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"testing"
"time"

"github.com/hyperledger/fabric-protos-go/common"
pb "github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/core/peer"
Expand Down Expand Up @@ -53,7 +52,7 @@ func TestQueriesPrivateData(t *testing.T) {

var nextBlockNumber uint64 = 1
// this test assumes four collections
collectionConfig := []*common.StaticCollectionConfig{{Name: "c1"}, {Name: "c2"}, {Name: "c3"}, {Name: "c4"}}
collectionConfig := []*pb.StaticCollectionConfig{{Name: "c1"}, {Name: "c2"}, {Name: "c3"}, {Name: "c4"}}
collectionConfigPkg := constructCollectionConfigPkg(collectionConfig)
defer chaincodeSupport.Runtime.Stop(cID.Name + ":" + cID.Version)
_, err = deployWithCollectionConfigs(channelID, ccContext, spec, collectionConfigPkg, nextBlockNumber, chaincodeSupport)
Expand Down Expand Up @@ -520,12 +519,12 @@ func TestQueriesPrivateData(t *testing.T) {
}
}

func constructCollectionConfigPkg(staticCollectionConfigs []*common.StaticCollectionConfig) *common.CollectionConfigPackage {
var cc []*common.CollectionConfig
func constructCollectionConfigPkg(staticCollectionConfigs []*pb.StaticCollectionConfig) *pb.CollectionConfigPackage {
var cc []*pb.CollectionConfig
for _, sc := range staticCollectionConfigs {
cc = append(cc, &common.CollectionConfig{
Payload: &common.CollectionConfig_StaticCollectionConfig{
cc = append(cc, &pb.CollectionConfig{
Payload: &pb.CollectionConfig_StaticCollectionConfig{
StaticCollectionConfig: sc}})
}
return &common.CollectionConfigPackage{Config: cc}
return &pb.CollectionConfigPackage{Config: cc}
}
18 changes: 9 additions & 9 deletions core/chaincode/lifecycle/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ package lifecycle_test
import (
"fmt"

cb "github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric-protos-go/ledger/queryresult"
"github.com/hyperledger/fabric-protos-go/ledger/rwset/kvrwset"
pb "github.com/hyperledger/fabric-protos-go/peer"
lb "github.com/hyperledger/fabric-protos-go/peer/lifecycle"
"github.com/hyperledger/fabric/common/chaincode"
commonledger "github.com/hyperledger/fabric/common/ledger"
Expand Down Expand Up @@ -90,7 +90,7 @@ var _ = Describe("Cache", func() {
ValidationInfo: &lb.ChaincodeValidationInfo{
ValidationParameter: []byte("validation-parameter"),
},
Collections: &cb.CollectionConfigPackage{},
Collections: &pb.CollectionConfigPackage{},
},
Approved: true,
Hashes: []string{
Expand Down Expand Up @@ -191,7 +191,7 @@ var _ = Describe("Cache", func() {
ValidationInfo: &lb.ChaincodeValidationInfo{
ValidationParameter: []byte("validation-parameter"),
},
Collections: &cb.CollectionConfigPackage{},
Collections: &pb.CollectionConfigPackage{},
},
InstallInfo: &lifecycle.ChaincodeInstallInfo{
Type: "cc-type",
Expand Down Expand Up @@ -595,7 +595,7 @@ var _ = Describe("Cache", func() {
ValidationInfo: &lb.ChaincodeValidationInfo{
ValidationParameter: []byte("validation-parameter"),
},
Collections: &cb.CollectionConfigPackage{},
Collections: &pb.CollectionConfigPackage{},
},
Approved: true,
},
Expand All @@ -608,7 +608,7 @@ var _ = Describe("Cache", func() {
ValidationInfo: &lb.ChaincodeValidationInfo{
ValidationParameter: []byte("validation-parameter"),
},
Collections: &cb.CollectionConfigPackage{},
Collections: &pb.CollectionConfigPackage{},
},
Approved: false,
},
Expand All @@ -621,7 +621,7 @@ var _ = Describe("Cache", func() {
ValidationInfo: &lb.ChaincodeValidationInfo{
ValidationParameter: []byte("validation-parameter"),
},
Collections: &cb.CollectionConfigPackage{},
Collections: &pb.CollectionConfigPackage{},
},
Approved: true,
},
Expand Down Expand Up @@ -656,23 +656,23 @@ var _ = Describe("Cache", func() {
Name: "installedAndApprovedCC",
Version: "3",
Policy: []byte("validation-parameter"),
CollectionsConfig: &cb.CollectionConfigPackage{},
CollectionsConfig: &pb.CollectionConfigPackage{},
Approved: true,
Installed: true,
},
chaincode.Metadata{
Name: "ididntinstall",
Version: "3",
Policy: []byte("validation-parameter"),
CollectionsConfig: &cb.CollectionConfigPackage{},
CollectionsConfig: &pb.CollectionConfigPackage{},
Approved: true,
Installed: false,
},
chaincode.Metadata{
Name: "idontapprove",
Version: "3",
Policy: []byte("validation-parameter"),
CollectionsConfig: &cb.CollectionConfigPackage{},
CollectionsConfig: &pb.CollectionConfigPackage{},
Approved: false,
Installed: true,
},
Expand Down
27 changes: 14 additions & 13 deletions core/chaincode/lifecycle/deployedcc_infoprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
cb "github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric-protos-go/ledger/rwset/kvrwset"
"github.com/hyperledger/fabric-protos-go/msp"
pb "github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric/common/cauthdsl"
"github.com/hyperledger/fabric/common/util"
validationState "github.com/hyperledger/fabric/core/handlers/validation/api/state"
Expand Down Expand Up @@ -103,7 +104,7 @@ var ImplicitCollectionMatcher = regexp.MustCompile("^" + ImplicitCollectionNameF

// AllCollectionsConfigPkg implements function in interface ledger.DeployedChaincodeInfoProvider
// this implementation returns a combined collection config pkg that contains both explicit and implicit collections
func (vc *ValidatorCommitter) AllCollectionsConfigPkg(channelName, chaincodeName string, qe ledger.SimpleQueryExecutor) (*cb.CollectionConfigPackage, error) {
func (vc *ValidatorCommitter) AllCollectionsConfigPkg(channelName, chaincodeName string, qe ledger.SimpleQueryExecutor) (*pb.CollectionConfigPackage, error) {
chaincodeInfo, err := vc.ChaincodeInfo(channelName, chaincodeName, qe)
if err != nil {
return nil, err
Expand All @@ -119,23 +120,23 @@ func (vc *ValidatorCommitter) AllCollectionsConfigPkg(channelName, chaincodeName
return nil, err
}

var combinedColls []*cb.CollectionConfig
var combinedColls []*pb.CollectionConfig
if explicitCollectionConfigPkg != nil {
combinedColls = append(combinedColls, explicitCollectionConfigPkg.Config...)
}
for _, implicitColl := range implicitCollections {
c := &cb.CollectionConfig{}
c.Payload = &cb.CollectionConfig_StaticCollectionConfig{StaticCollectionConfig: implicitColl}
c := &pb.CollectionConfig{}
c.Payload = &pb.CollectionConfig_StaticCollectionConfig{StaticCollectionConfig: implicitColl}
combinedColls = append(combinedColls, c)
}
return &cb.CollectionConfigPackage{
return &pb.CollectionConfigPackage{
Config: combinedColls,
}, nil
}

// CollectionInfo implements function in interface ledger.DeployedChaincodeInfoProvider, it returns config for
// both static and implicit collections.
func (vc *ValidatorCommitter) CollectionInfo(channelName, chaincodeName, collectionName string, qe ledger.SimpleQueryExecutor) (*cb.StaticCollectionConfig, error) {
func (vc *ValidatorCommitter) CollectionInfo(channelName, chaincodeName, collectionName string, qe ledger.SimpleQueryExecutor) (*pb.StaticCollectionConfig, error) {
exists, definedChaincode, err := vc.Resources.ChaincodeDefinitionIfDefined(chaincodeName, &SimpleQueryExecutorShim{
Namespace: LifecycleNamespace,
SimpleQueryExecutor: qe,
Expand Down Expand Up @@ -166,7 +167,7 @@ func (vc *ValidatorCommitter) CollectionInfo(channelName, chaincodeName, collect

// ImplicitCollections implements function in interface ledger.DeployedChaincodeInfoProvider. It returns
//a slice that contains one proto msg for each of the implicit collections
func (vc *ValidatorCommitter) ImplicitCollections(channelName, chaincodeName string, qe ledger.SimpleQueryExecutor) ([]*cb.StaticCollectionConfig, error) {
func (vc *ValidatorCommitter) ImplicitCollections(channelName, chaincodeName string, qe ledger.SimpleQueryExecutor) ([]*pb.StaticCollectionConfig, error) {
exists, _, err := vc.Resources.ChaincodeDefinitionIfDefined(chaincodeName, &SimpleQueryExecutorShim{
Namespace: LifecycleNamespace,
SimpleQueryExecutor: qe,
Expand All @@ -184,7 +185,7 @@ func (vc *ValidatorCommitter) ImplicitCollections(channelName, chaincodeName str
}

// ChaincodeImplicitCollections assumes the chaincode exists in the new lifecycle and returns the implicit collections
func (vc *ValidatorCommitter) ChaincodeImplicitCollections(channelName string) ([]*cb.StaticCollectionConfig, error) {
func (vc *ValidatorCommitter) ChaincodeImplicitCollections(channelName string) ([]*pb.StaticCollectionConfig, error) {
channelConfig := vc.Resources.ChannelConfigSource.GetStableChannelConfig(channelName)
if channelConfig == nil {
return nil, errors.Errorf("could not get channelconfig for channel %s", channelName)
Expand All @@ -195,19 +196,19 @@ func (vc *ValidatorCommitter) ChaincodeImplicitCollections(channelName string) (
}

orgs := ac.Organizations()
implicitCollections := make([]*cb.StaticCollectionConfig, 0, len(orgs))
implicitCollections := make([]*pb.StaticCollectionConfig, 0, len(orgs))
for _, org := range orgs {
implicitCollections = append(implicitCollections, GenerateImplicitCollectionForOrg(org.MSPID()))
}

return implicitCollections, nil
}

func GenerateImplicitCollectionForOrg(mspid string) *cb.StaticCollectionConfig {
return &cb.StaticCollectionConfig{
func GenerateImplicitCollectionForOrg(mspid string) *pb.StaticCollectionConfig {
return &pb.StaticCollectionConfig{
Name: ImplicitCollectionNameForOrg(mspid),
MemberOrgsPolicy: &cb.CollectionPolicyConfig{
Payload: &cb.CollectionPolicyConfig_SignaturePolicy{
MemberOrgsPolicy: &pb.CollectionPolicyConfig{
Payload: &pb.CollectionPolicyConfig_SignaturePolicy{
SignaturePolicy: cauthdsl.SignedByMspMember(mspid),
},
},
Expand Down
35 changes: 18 additions & 17 deletions core/chaincode/lifecycle/deployedcc_infoprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
cb "github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric-protos-go/ledger/rwset/kvrwset"
"github.com/hyperledger/fabric-protos-go/msp"
pb "github.com/hyperledger/fabric-protos-go/peer"
lb "github.com/hyperledger/fabric-protos-go/peer/lifecycle"
"github.com/hyperledger/fabric/common/channelconfig"
"github.com/hyperledger/fabric/common/util"
Expand Down Expand Up @@ -84,11 +85,11 @@ var _ = Describe("ValidatorCommitter", func() {
ValidationPlugin: "validation-plugin",
ValidationParameter: []byte("validation-parameter"),
},
Collections: &cb.CollectionConfigPackage{
Config: []*cb.CollectionConfig{
Collections: &pb.CollectionConfigPackage{
Config: []*pb.CollectionConfig{
{
Payload: &cb.CollectionConfig_StaticCollectionConfig{
StaticCollectionConfig: &cb.StaticCollectionConfig{
Payload: &pb.CollectionConfig_StaticCollectionConfig{
StaticCollectionConfig: &pb.StaticCollectionConfig{
Name: "collection-name",
},
},
Expand Down Expand Up @@ -228,7 +229,7 @@ var _ = Describe("ValidatorCommitter", func() {
It("returns the collection info as defined in the new lifecycle", func() {
res, err := vc.CollectionInfo("channel-name", "cc-name", "collection-name", fakeQueryExecutor)
Expect(err).NotTo(HaveOccurred())
Expect(proto.Equal(res, &cb.StaticCollectionConfig{
Expect(proto.Equal(res, &pb.StaticCollectionConfig{
Name: "collection-name",
})).To(BeTrue())
})
Expand Down Expand Up @@ -262,11 +263,11 @@ var _ = Describe("ValidatorCommitter", func() {

Context("when the chaincode is not in the new lifecycle", func() {
var (
collInfo *cb.StaticCollectionConfig
collInfo *pb.StaticCollectionConfig
)

BeforeEach(func() {
collInfo = &cb.StaticCollectionConfig{}
collInfo = &pb.StaticCollectionConfig{}
fakeLegacyProvider.CollectionInfoReturns(collInfo, fmt.Errorf("collection-info-error"))
})

Expand Down Expand Up @@ -300,7 +301,7 @@ var _ = Describe("ValidatorCommitter", func() {
res, err := vc.ImplicitCollections("channel-id", "cc-name", fakeQueryExecutor)
Expect(err).NotTo(HaveOccurred())
Expect(len(res)).To(Equal(2))
var firstOrg, secondOrg *cb.StaticCollectionConfig
var firstOrg, secondOrg *pb.StaticCollectionConfig
for _, collection := range res {
switch collection.Name {
case "_implicit_org_first-mspid":
Expand Down Expand Up @@ -427,11 +428,11 @@ var _ = Describe("ValidatorCommitter", func() {

Context("when the chaincode is not in the new lifecycle", func() {
var (
ccPkg *cb.CollectionConfigPackage
ccPkg *pb.CollectionConfigPackage
)

BeforeEach(func() {
ccPkg = &cb.CollectionConfigPackage{}
ccPkg = &pb.CollectionConfigPackage{}
fakeLegacyProvider.ChaincodeInfoReturns(
&ledger.DeployedChaincodeInfo{
ExplicitCollectionConfigPkg: ccPkg,
Expand Down Expand Up @@ -653,11 +654,11 @@ var _ = Describe("ValidatorCommitter", func() {
})

Context("when the endorsement policy is specified in the collection config", func() {
var expectedPolicy *cb.ApplicationPolicy
var expectedPolicy *pb.ApplicationPolicy

BeforeEach(func() {
expectedPolicy = &cb.ApplicationPolicy{
Type: &cb.ApplicationPolicy_SignaturePolicy{
expectedPolicy = &pb.ApplicationPolicy{
Type: &pb.ApplicationPolicy_SignaturePolicy{
SignaturePolicy: &cb.SignaturePolicyEnvelope{
Identities: []*msp.MSPPrincipal{
{
Expand All @@ -675,11 +676,11 @@ var _ = Describe("ValidatorCommitter", func() {
ValidationPlugin: "validation-plugin",
ValidationParameter: []byte("validation-parameter"),
},
Collections: &cb.CollectionConfigPackage{
Config: []*cb.CollectionConfig{
Collections: &pb.CollectionConfigPackage{
Config: []*pb.CollectionConfig{
{
Payload: &cb.CollectionConfig_StaticCollectionConfig{
StaticCollectionConfig: &cb.StaticCollectionConfig{
Payload: &pb.CollectionConfig_StaticCollectionConfig{
StaticCollectionConfig: &pb.StaticCollectionConfig{
Name: "collection-name",
EndorsementPolicy: expectedPolicy,
},
Expand Down
Loading

0 comments on commit fb56820

Please sign in to comment.