Skip to content

Commit 9f6788d

Browse files
committed
remove exec_env from ChaincodeDeploymentSpec
- CCContext is extended with flag to indicate if it is a system chaincode - ChaincodeContainerInfo sets container type to SYSTEM when dealing with system chaincode and DOCKER for everything else. FAB-14491 Change-Id: I801e8249dcbc0acb6fc2b48f313c67e11f924129 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent 44f0d8b commit 9f6788d

File tree

7 files changed

+60
-96
lines changed

7 files changed

+60
-96
lines changed

core/chaincode/chaincode_support.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func createCCMessage(messageType pb.ChaincodeMessage_Type, cid string, txid stri
159159
// It does not attempt to start the chaincode based on the information from lifecycle, but instead
160160
// accepts the container information directly in the form of a ChaincodeDeploymentSpec.
161161
func (cs *ChaincodeSupport) ExecuteLegacyInit(txParams *ccprovider.TransactionParams, cccid *ccprovider.CCContext, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) {
162-
ccci := ccprovider.DeploymentSpecToChaincodeContainerInfo(spec)
162+
ccci := ccprovider.DeploymentSpecToChaincodeContainerInfo(spec, cccid.SystemCC)
163163
ccci.Version = cccid.Version
164164
// FIXME: this is a hack, we shouldn't construct the
165165
// packageID manually but rather let lifecycle construct it

core/common/ccprovider/ccprovider.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ type CCContext struct {
391391
// InitRequired indicates whether the chaincode must have 'Init' invoked
392392
// before other transactions can proceed.
393393
InitRequired bool
394+
395+
// SystemCC indictes whether or not this is system chaincode.
396+
SystemCC bool
394397
}
395398

396399
//-------- ChaincodeDefinition - interface for ChaincodeData ------
@@ -544,13 +547,17 @@ type ChaincodeProvider interface {
544547
Stop(ccci *ChaincodeContainerInfo) error
545548
}
546549

547-
func DeploymentSpecToChaincodeContainerInfo(cds *pb.ChaincodeDeploymentSpec) *ChaincodeContainerInfo {
548-
return &ChaincodeContainerInfo{
550+
func DeploymentSpecToChaincodeContainerInfo(cds *pb.ChaincodeDeploymentSpec, systemCC bool) *ChaincodeContainerInfo {
551+
cci := &ChaincodeContainerInfo{
549552
Name: cds.ChaincodeSpec.ChaincodeId.Name,
550553
Version: cds.ChaincodeSpec.ChaincodeId.Version,
551554
Path: cds.ChaincodeSpec.ChaincodeId.Path,
552555
Type: cds.ChaincodeSpec.Type.String(),
553-
ContainerType: cds.ExecEnv.String(),
556+
ContainerType: "DOCKER",
554557
PackageID: persistence.PackageID(cds.ChaincodeSpec.ChaincodeId.Name + ":" + cds.ChaincodeSpec.ChaincodeId.Version),
555558
}
559+
if systemCC {
560+
cci.ContainerType = "SYSTEM"
561+
}
562+
return cci
556563
}

core/scc/lscc/lscc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func (lscc *LifeCycleSysCC) ChaincodeContainerInfo(channelID, chaincodeName stri
192192
return nil, errors.Wrapf(err, "could not get chaincode code")
193193
}
194194

195-
return ccprovider.DeploymentSpecToChaincodeContainerInfo(cds), nil
195+
return ccprovider.DeploymentSpecToChaincodeContainerInfo(cds, false), nil
196196
}
197197

198198
func (lscc *LifeCycleSysCC) ChaincodeDefinition(channelID, chaincodeName string, qe ledger.SimpleQueryExecutor) (ccprovider.ChaincodeDefinition, error) {

core/scc/lscc/lscc_noncc_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
)
2020

2121
var _ = Describe("LSCC", func() {
22-
2322
var (
2423
l *lscc.LifeCycleSysCC
2524
fakeSupport *mock.FileSystemSupport
@@ -84,7 +83,7 @@ var _ = Describe("LSCC", func() {
8483
It("returns the chaincode deployment spec for a valid chaincode", func() {
8584
ccci, err := l.ChaincodeContainerInfo("", "chaincode-data-name", fakeQueryExecutor)
8685
Expect(err).NotTo(HaveOccurred())
87-
Expect(ccci).To(Equal(ccprovider.DeploymentSpecToChaincodeContainerInfo(deploymentSpec)))
86+
Expect(ccci).To(Equal(ccprovider.DeploymentSpecToChaincodeContainerInfo(deploymentSpec, false)))
8887

8988
Expect(fakeQueryExecutor.GetStateCallCount()).To(Equal(1))
9089
getStateNamespace, getStateCCName := fakeQueryExecutor.GetStateArgsForCall(0)

core/scc/sysccapi.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,15 @@ func (p *Provider) deploySysCC(chainID string, ccprov ccprovider.ChaincodeProvid
160160
chaincodeID := &pb.ChaincodeID{Path: syscc.Path(), Name: syscc.Name()}
161161
spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value["GOLANG"]), ChaincodeId: chaincodeID, Input: &pb.ChaincodeInput{Args: syscc.InitArgs()}}
162162

163-
chaincodeDeploymentSpec := &pb.ChaincodeDeploymentSpec{ExecEnv: pb.ChaincodeDeploymentSpec_SYSTEM, ChaincodeSpec: spec}
163+
chaincodeDeploymentSpec := &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}
164164

165165
// XXX This is an ugly hack, version should be tied to the chaincode instance, not he peer binary
166166
version := util.GetSysCCVersion()
167167

168168
cccid := &ccprovider.CCContext{
169-
Name: chaincodeDeploymentSpec.ChaincodeSpec.ChaincodeId.Name,
170-
Version: version,
169+
Name: chaincodeDeploymentSpec.ChaincodeSpec.ChaincodeId.Name,
170+
Version: version,
171+
SystemCC: true,
171172
}
172173

173174
resp, _, err := ccprov.ExecuteLegacyInit(txParams, cccid, chaincodeDeploymentSpec)

protos/peer/chaincode.pb.go

Lines changed: 41 additions & 78 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/peer/chaincode.proto

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,11 @@ message ChaincodeSpec {
7676
// TODO: Define `codePackage`.
7777
message ChaincodeDeploymentSpec {
7878
// Prevent removed tag re-use
79-
reserved 2;
80-
reserved "effective_date";
81-
82-
enum ExecutionEnvironment {
83-
DOCKER = 0;
84-
SYSTEM = 1;
85-
}
79+
reserved 2, 4;
80+
reserved "effective_date", "exec_env";
8681

8782
ChaincodeSpec chaincode_spec = 1;
8883
bytes code_package = 3;
89-
ExecutionEnvironment exec_env= 4;
9084

9185
}
9286

0 commit comments

Comments
 (0)