diff --git a/core/endorser/endorser.go b/core/endorser/endorser.go index 725c60ade0e..cbd2e3d837e 100644 --- a/core/endorser/endorser.go +++ b/core/endorser/endorser.go @@ -276,16 +276,10 @@ func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedPro chainID := hdr.ChannelHeader.ChannelId //chainless MSPs have "" chain name - ischainless := syscc.IsChainlessSysCC(hdrExt.ChaincodeId.Name) + ischainless := false - //chainID should be empty for chainless SysCC (such as CSCC for Join proposal) and for - //nothing else - if chainID == "" && !ischainless { - err = fmt.Errorf("chainID not provided for chaincode %s", hdrExt.ChaincodeId.Name) - return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err - } else if chainID != "" && ischainless { - err = fmt.Errorf("chainID %s provided for a chainless syscc", hdrExt.ChaincodeId.Name) - return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err + if chainID == "" { + ischainless = true } //TODO check for uniqueness of prop.TxID with ledger diff --git a/core/scc/importsysccs.go b/core/scc/importsysccs.go index 3a30e95f5ee..e20d3a6395a 100644 --- a/core/scc/importsysccs.go +++ b/core/scc/importsysccs.go @@ -28,44 +28,39 @@ import ( //see systemchaincode_test.go for an example using "sample_syscc" var systemChaincodes = []*SystemChaincode{ { - ChainlessCC: true, - Enabled: true, - Name: "cscc", - Path: "github.com/hyperledger/fabric/core/scc/cscc", - InitArgs: [][]byte{[]byte("")}, - Chaincode: &cscc.PeerConfiger{}, + Enabled: true, + Name: "cscc", + Path: "github.com/hyperledger/fabric/core/scc/cscc", + InitArgs: [][]byte{[]byte("")}, + Chaincode: &cscc.PeerConfiger{}, }, { - ChainlessCC: false, - Enabled: true, - Name: "lccc", - Path: "github.com/hyperledger/fabric/core/scc/lccc", - InitArgs: [][]byte{[]byte("")}, - Chaincode: &lccc.LifeCycleSysCC{}, + Enabled: true, + Name: "lccc", + Path: "github.com/hyperledger/fabric/core/scc/lccc", + InitArgs: [][]byte{[]byte("")}, + Chaincode: &lccc.LifeCycleSysCC{}, }, { - ChainlessCC: false, - Enabled: true, - Name: "escc", - Path: "github.com/hyperledger/fabric/core/scc/escc", - InitArgs: [][]byte{[]byte("")}, - Chaincode: &escc.EndorserOneValidSignature{}, + Enabled: true, + Name: "escc", + Path: "github.com/hyperledger/fabric/core/scc/escc", + InitArgs: [][]byte{[]byte("")}, + Chaincode: &escc.EndorserOneValidSignature{}, }, { - ChainlessCC: false, - Enabled: true, - Name: "vscc", - Path: "github.com/hyperledger/fabric/core/scc/vscc", - InitArgs: [][]byte{[]byte("")}, - Chaincode: &vscc.ValidatorOneValidSignature{}, + Enabled: true, + Name: "vscc", + Path: "github.com/hyperledger/fabric/core/scc/vscc", + InitArgs: [][]byte{[]byte("")}, + Chaincode: &vscc.ValidatorOneValidSignature{}, }, { - ChainlessCC: true, - Enabled: true, - Name: "qscc", - Path: "github.com/hyperledger/fabric/core/chaincode/qscc", - InitArgs: [][]byte{[]byte("")}, - Chaincode: &qscc.LedgerQuerier{}, + Enabled: true, + Name: "qscc", + Path: "github.com/hyperledger/fabric/core/chaincode/qscc", + InitArgs: [][]byte{[]byte("")}, + Chaincode: &qscc.LedgerQuerier{}, }, } @@ -81,19 +76,7 @@ func RegisterSysCCs() { //note the chaincode must still be deployed and launched like a user chaincode will be func DeploySysCCs(chainID string) { for _, sysCC := range systemChaincodes { - if !sysCC.ChainlessCC { - deploySysCC(chainID, sysCC) - } - } -} - -//DeployChainlessSysCCs is the hook for deploying chainless system chaincodes -//these chaincodes cannot make any ledger calls -func DeployChainlessSysCCs() { - for _, sysCC := range systemChaincodes { - if sysCC.ChainlessCC { - deploySysCC("", sysCC) - } + deploySysCC(chainID, sysCC) } } @@ -102,9 +85,7 @@ func DeployChainlessSysCCs() { //in the same process func DeDeploySysCCs(chainID string) { for _, sysCC := range systemChaincodes { - if !sysCC.ChainlessCC { - DeDeploySysCC(chainID, sysCC) - } + DeDeploySysCC(chainID, sysCC) } } @@ -119,17 +100,6 @@ func IsSysCC(name string) bool { return false } -//IsChainlessSysCC returns true if the name matches a chainless system chaincode's -//system chaincode names are system, chain wide -func IsChainlessSysCC(name string) bool { - for _, sysCC := range systemChaincodes { - if sysCC.Name == name && sysCC.ChainlessCC { - return true - } - } - return false -} - // MockRegisterSysCCs is used only for testing // This is needed to break import cycle func MockRegisterSysCCs(mockSysCCs []*SystemChaincode) []*SystemChaincode { diff --git a/core/scc/sysccapi.go b/core/scc/sysccapi.go index be3a945ecae..efbba3acb5e 100644 --- a/core/scc/sysccapi.go +++ b/core/scc/sysccapi.go @@ -39,10 +39,6 @@ var sysccLogger = logging.MustGetLogger("sysccapi") // when the fabric comes up. SystemChaincodes are installed by adding an // entry in importsysccs.go type SystemChaincode struct { - //Global, once only not tied to chains. Such chaincodes cannot - //save state in the ledger. CSCC is an example - ChainlessCC bool - // Enabled a convenient switch to enable/disable system chaincode without // having to remove entry from importsysccs.go Enabled bool @@ -88,10 +84,9 @@ func deploySysCC(chainID string, syscc *SystemChaincode) error { return nil } - if chainID == "" && !syscc.ChainlessCC { - return fmt.Errorf("cannot deploy system chaincode %s without chain id", syscc.Name) - } else if chainID != "" && syscc.ChainlessCC { - return fmt.Errorf("cannot deploy chainless system chaincode %s with chain id %s", syscc.Name, chainID) + chainless := false + if chainID == "" { + chainless = true } var err error @@ -99,7 +94,7 @@ func deploySysCC(chainID string, syscc *SystemChaincode) error { ccprov := ccprovider.GetChaincodeProvider() ctxt := context.Background() - if !syscc.ChainlessCC { + if !chainless { lgr := peer.GetLedger(chainID) if lgr == nil { panic(fmt.Sprintf("syschain %s start up failure - unexpected nil ledger for channel %s", syscc.Name, chainID)) diff --git a/peer/node/start.go b/peer/node/start.go index 75484600048..2dfc04a72c5 100644 --- a/peer/node/start.go +++ b/peer/node/start.go @@ -71,13 +71,11 @@ var nodeStartCmd = &cobra.Command{ }, } -//!!!!!----IMPORTANT----IMPORTANT---IMPORTANT------!!!! -//This is a place holder for multichain work. Currently -//user to create a single chain and initialize it -func initChainless() { - //deploy the chainless system chaincodes - scc.DeployChainlessSysCCs() - logger.Infof("Deployed chainless system chaincodess") +//start chaincodes +func initSysCCs() { + //deploy system chaincodes + scc.DeploySysCCs("") + logger.Infof("Deployed system chaincodess") } func serve(args []string) error { @@ -156,8 +154,8 @@ func serve(args []string) error { service.InitGossipService(serializedIdentity, peerEndpoint.Address, grpcServer, bootstrap...) defer service.GetGossipService().Stop() - //initialize the env for chainless startup - initChainless() + //initialize system chaincodes + initSysCCs() // Begin startup of default chain if peerDefaultChain {