Skip to content

Commit ffe4c91

Browse files
author
Srinivasan Muralidharan
committed
FAB-2177 remove need for "chainless" sccs
https://jira.hyperledger.org/browse/FAB-2177 There is no need for "chainless" System Chaincodes as the new model chaincodes are launched outside of channels and are instantiated on each. Use "" for system chaincode operation outside of any channel. With this change LCCC can be invoked outside of channel. Change-Id: I82f4f1bfb5a2b05abd082a0b8d91fc1da1f94afb Signed-off-by: Srinivasan Muralidharan <[email protected]>
1 parent 0e5b8a2 commit ffe4c91

File tree

4 files changed

+41
-84
lines changed

4 files changed

+41
-84
lines changed

core/endorser/endorser.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,10 @@ func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedPro
276276
chainID := hdr.ChannelHeader.ChannelId
277277

278278
//chainless MSPs have "" chain name
279-
ischainless := syscc.IsChainlessSysCC(hdrExt.ChaincodeId.Name)
279+
ischainless := false
280280

281-
//chainID should be empty for chainless SysCC (such as CSCC for Join proposal) and for
282-
//nothing else
283-
if chainID == "" && !ischainless {
284-
err = fmt.Errorf("chainID not provided for chaincode %s", hdrExt.ChaincodeId.Name)
285-
return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err
286-
} else if chainID != "" && ischainless {
287-
err = fmt.Errorf("chainID %s provided for a chainless syscc", hdrExt.ChaincodeId.Name)
288-
return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err
281+
if chainID == "" {
282+
ischainless = true
289283
}
290284

291285
//TODO check for uniqueness of prop.TxID with ledger

core/scc/importsysccs.go

+27-57
Original file line numberDiff line numberDiff line change
@@ -28,44 +28,39 @@ import (
2828
//see systemchaincode_test.go for an example using "sample_syscc"
2929
var systemChaincodes = []*SystemChaincode{
3030
{
31-
ChainlessCC: true,
32-
Enabled: true,
33-
Name: "cscc",
34-
Path: "github.com/hyperledger/fabric/core/scc/cscc",
35-
InitArgs: [][]byte{[]byte("")},
36-
Chaincode: &cscc.PeerConfiger{},
31+
Enabled: true,
32+
Name: "cscc",
33+
Path: "github.com/hyperledger/fabric/core/scc/cscc",
34+
InitArgs: [][]byte{[]byte("")},
35+
Chaincode: &cscc.PeerConfiger{},
3736
},
3837
{
39-
ChainlessCC: false,
40-
Enabled: true,
41-
Name: "lccc",
42-
Path: "github.com/hyperledger/fabric/core/scc/lccc",
43-
InitArgs: [][]byte{[]byte("")},
44-
Chaincode: &lccc.LifeCycleSysCC{},
38+
Enabled: true,
39+
Name: "lccc",
40+
Path: "github.com/hyperledger/fabric/core/scc/lccc",
41+
InitArgs: [][]byte{[]byte("")},
42+
Chaincode: &lccc.LifeCycleSysCC{},
4543
},
4644
{
47-
ChainlessCC: false,
48-
Enabled: true,
49-
Name: "escc",
50-
Path: "github.com/hyperledger/fabric/core/scc/escc",
51-
InitArgs: [][]byte{[]byte("")},
52-
Chaincode: &escc.EndorserOneValidSignature{},
45+
Enabled: true,
46+
Name: "escc",
47+
Path: "github.com/hyperledger/fabric/core/scc/escc",
48+
InitArgs: [][]byte{[]byte("")},
49+
Chaincode: &escc.EndorserOneValidSignature{},
5350
},
5451
{
55-
ChainlessCC: false,
56-
Enabled: true,
57-
Name: "vscc",
58-
Path: "github.com/hyperledger/fabric/core/scc/vscc",
59-
InitArgs: [][]byte{[]byte("")},
60-
Chaincode: &vscc.ValidatorOneValidSignature{},
52+
Enabled: true,
53+
Name: "vscc",
54+
Path: "github.com/hyperledger/fabric/core/scc/vscc",
55+
InitArgs: [][]byte{[]byte("")},
56+
Chaincode: &vscc.ValidatorOneValidSignature{},
6157
},
6258
{
63-
ChainlessCC: true,
64-
Enabled: true,
65-
Name: "qscc",
66-
Path: "github.com/hyperledger/fabric/core/chaincode/qscc",
67-
InitArgs: [][]byte{[]byte("")},
68-
Chaincode: &qscc.LedgerQuerier{},
59+
Enabled: true,
60+
Name: "qscc",
61+
Path: "github.com/hyperledger/fabric/core/chaincode/qscc",
62+
InitArgs: [][]byte{[]byte("")},
63+
Chaincode: &qscc.LedgerQuerier{},
6964
},
7065
}
7166

@@ -81,19 +76,7 @@ func RegisterSysCCs() {
8176
//note the chaincode must still be deployed and launched like a user chaincode will be
8277
func DeploySysCCs(chainID string) {
8378
for _, sysCC := range systemChaincodes {
84-
if !sysCC.ChainlessCC {
85-
deploySysCC(chainID, sysCC)
86-
}
87-
}
88-
}
89-
90-
//DeployChainlessSysCCs is the hook for deploying chainless system chaincodes
91-
//these chaincodes cannot make any ledger calls
92-
func DeployChainlessSysCCs() {
93-
for _, sysCC := range systemChaincodes {
94-
if sysCC.ChainlessCC {
95-
deploySysCC("", sysCC)
96-
}
79+
deploySysCC(chainID, sysCC)
9780
}
9881
}
9982

@@ -102,9 +85,7 @@ func DeployChainlessSysCCs() {
10285
//in the same process
10386
func DeDeploySysCCs(chainID string) {
10487
for _, sysCC := range systemChaincodes {
105-
if !sysCC.ChainlessCC {
106-
DeDeploySysCC(chainID, sysCC)
107-
}
88+
DeDeploySysCC(chainID, sysCC)
10889
}
10990
}
11091

@@ -119,17 +100,6 @@ func IsSysCC(name string) bool {
119100
return false
120101
}
121102

122-
//IsChainlessSysCC returns true if the name matches a chainless system chaincode's
123-
//system chaincode names are system, chain wide
124-
func IsChainlessSysCC(name string) bool {
125-
for _, sysCC := range systemChaincodes {
126-
if sysCC.Name == name && sysCC.ChainlessCC {
127-
return true
128-
}
129-
}
130-
return false
131-
}
132-
133103
// MockRegisterSysCCs is used only for testing
134104
// This is needed to break import cycle
135105
func MockRegisterSysCCs(mockSysCCs []*SystemChaincode) []*SystemChaincode {

core/scc/sysccapi.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ var sysccLogger = logging.MustGetLogger("sysccapi")
3939
// when the fabric comes up. SystemChaincodes are installed by adding an
4040
// entry in importsysccs.go
4141
type SystemChaincode struct {
42-
//Global, once only not tied to chains. Such chaincodes cannot
43-
//save state in the ledger. CSCC is an example
44-
ChainlessCC bool
45-
4642
// Enabled a convenient switch to enable/disable system chaincode without
4743
// having to remove entry from importsysccs.go
4844
Enabled bool
@@ -88,18 +84,17 @@ func deploySysCC(chainID string, syscc *SystemChaincode) error {
8884
return nil
8985
}
9086

91-
if chainID == "" && !syscc.ChainlessCC {
92-
return fmt.Errorf("cannot deploy system chaincode %s without chain id", syscc.Name)
93-
} else if chainID != "" && syscc.ChainlessCC {
94-
return fmt.Errorf("cannot deploy chainless system chaincode %s with chain id %s", syscc.Name, chainID)
87+
chainless := false
88+
if chainID == "" {
89+
chainless = true
9590
}
9691

9792
var err error
9893

9994
ccprov := ccprovider.GetChaincodeProvider()
10095

10196
ctxt := context.Background()
102-
if !syscc.ChainlessCC {
97+
if !chainless {
10398
lgr := peer.GetLedger(chainID)
10499
if lgr == nil {
105100
panic(fmt.Sprintf("syschain %s start up failure - unexpected nil ledger for channel %s", syscc.Name, chainID))

peer/node/start.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,11 @@ var nodeStartCmd = &cobra.Command{
7171
},
7272
}
7373

74-
//!!!!!----IMPORTANT----IMPORTANT---IMPORTANT------!!!!
75-
//This is a place holder for multichain work. Currently
76-
//user to create a single chain and initialize it
77-
func initChainless() {
78-
//deploy the chainless system chaincodes
79-
scc.DeployChainlessSysCCs()
80-
logger.Infof("Deployed chainless system chaincodess")
74+
//start chaincodes
75+
func initSysCCs() {
76+
//deploy system chaincodes
77+
scc.DeploySysCCs("")
78+
logger.Infof("Deployed system chaincodess")
8179
}
8280

8381
func serve(args []string) error {
@@ -156,8 +154,8 @@ func serve(args []string) error {
156154
service.InitGossipService(serializedIdentity, peerEndpoint.Address, grpcServer, bootstrap...)
157155
defer service.GetGossipService().Stop()
158156

159-
//initialize the env for chainless startup
160-
initChainless()
157+
//initialize system chaincodes
158+
initSysCCs()
161159

162160
// Begin startup of default chain
163161
if peerDefaultChain {

0 commit comments

Comments
 (0)