diff --git a/core/chaincode/chaincode_support.go b/core/chaincode/chaincode_support.go index a730cf84a6e..183545bed2f 100644 --- a/core/chaincode/chaincode_support.go +++ b/core/chaincode/chaincode_support.go @@ -132,17 +132,17 @@ func (cs *ChaincodeSupport) Launch(cccid *ccprovider.CCContext, spec *pb.Chainco return nil } - // TODO: There has to be a better way to do this... - if cs.UserRunsCC && !cccid.Syscc { - chaincodeLogger.Error( - "You are attempting to perform an action other than Deploy on Chaincode that is not ready and you are in developer mode. Did you forget to Deploy your chaincode?", - ) - } - chaincodeName := spec.GetChaincodeSpec().Name() ccci, err := cs.Lifecycle.ChaincodeContainerInfo(cccid.ChainID, chaincodeName) if err != nil { + // TODO: There has to be a better way to do this... + if cs.UserRunsCC { + chaincodeLogger.Error( + "You are attempting to perform an action other than Deploy on Chaincode that is not ready and you are in developer mode. Did you forget to Deploy your chaincode?", + ) + } + return errors.Wrapf(err, "[channel %s] failed to get chaincode container info for %s", cccid.ChainID, chaincodeName) } diff --git a/core/chaincode/chaincode_support_test.go b/core/chaincode/chaincode_support_test.go index 2a4e4e27eef..b4378e86ca0 100644 --- a/core/chaincode/chaincode_support_test.go +++ b/core/chaincode/chaincode_support_test.go @@ -399,7 +399,7 @@ func deployCC(t *testing.T, ctx context.Context, cccid *ccprovider.CCContext, sp lsccSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeId: &pb.ChaincodeID{Name: "lscc", Version: sysCCVers}, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte(cccid.ChainID), b}}}} sprop, prop := putils.MockSignedEndorserProposal2OrPanic(cccid.ChainID, lsccSpec.ChaincodeSpec, signer) - lsccid := ccprovider.NewCCContext(cccid.ChainID, lsccSpec.ChaincodeSpec.ChaincodeId.Name, sysCCVers, cccid.TxID, true, sprop, prop) + lsccid := ccprovider.NewCCContext(cccid.ChainID, lsccSpec.ChaincodeSpec.ChaincodeId.Name, sysCCVers, cccid.TxID, sprop, prop) //write to lscc if _, _, err := chaincodeSupport.Execute(ctx, lsccid, lsccSpec); err != nil { @@ -443,13 +443,13 @@ func initializeCC(t *testing.T, chainID, ccname string, ccSide *mockpeer.MockCCC Responses: []*mockpeer.MockResponse{resp}, } - cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) execCC(t, ctxt, ccSide, cccid, false, true, done, cis, respSet, chaincodeSupport) //set the right TxID in response now resp.RespMsg.(*pb.ChaincodeMessage).Txid = txid - badcccid := ccprovider.NewCCContext(chainID, ccname, "unknownver", txid, false, sprop, prop) + badcccid := ccprovider.NewCCContext(chainID, ccname, "unknownver", txid, sprop, prop) //we are not going to reach the chaincode and so won't get a response from it. processDone will not //be triggered by the chaincode stream. We just expect an error from fabric. Hence pass nil for done @@ -513,7 +513,7 @@ func invokeCC(t *testing.T, chainID, ccname string, ccSide *mockpeer.MockCCComm, }, } - cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) execCC(t, ctxt, ccSide, cccid, false, false, done, cis, respSet, chaincodeSupport) //delete the extra var @@ -570,7 +570,7 @@ func invokePrivateDataGetPutDelCC(t *testing.T, chainID, ccname string, ccSide * }, } - cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) execCC(t, ctxt, ccSide, cccid, false, true, done, cis, respSet, chaincodeSupport) respSet = &mockpeer.MockResponseSet{ @@ -586,7 +586,7 @@ func invokePrivateDataGetPutDelCC(t *testing.T, chainID, ccname string, ccSide * }, } - cccid = ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid = ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) execCC(t, ctxt, ccSide, cccid, false, false, done, cis, respSet, chaincodeSupport) endTx(t, cccid, txsim, cis) @@ -603,7 +603,7 @@ func invokePrivateDataGetPutDelCC(t *testing.T, chainID, ccname string, ccSide * }, } - cccid = ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid = ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) execCC(t, ctxt, ccSide, cccid, false, true, done, cis, respSet, chaincodeSupport) endTx(t, cccid, txsim, cis) @@ -676,7 +676,7 @@ func getQueryStateByRange(t *testing.T, collection, chainID, ccname string, ccSi Responses: mkpeer, } - cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) if collection == "" { execCC(t, ctxt, ccSide, cccid, false, false, done, cis, respSet, chaincodeSupport) } else { @@ -717,7 +717,7 @@ func cc2cc(t *testing.T, chainID, chainID2, ccname string, ccSide *mockpeer.Mock mockAclProvider.On("CheckACL", resources.Lscc_GetChaincodeData, chainID, sprop).Return(nil) mockAclProvider.On("CheckACL", resources.Peer_Propose, chainID, sprop).Return(nil) - cccid := ccprovider.NewCCContext(chainID, calledCC, "0", txid, false, sprop, prop) + cccid := ccprovider.NewCCContext(chainID, calledCC, "0", txid, sprop, prop) deployCC(t, ctxt, cccid, cis.ChaincodeSpec, chaincodeSupport) @@ -763,7 +763,7 @@ func cc2cc(t *testing.T, chainID, chainID2, ccname string, ccSide *mockpeer.Mock } calledCCSide.SetResponses(respSet2) - cccid = ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid = ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) execCC(t, ctxt, ccSide, cccid, false, true, done, cis, respSet, chaincodeSupport) @@ -803,7 +803,7 @@ func cc2cc(t *testing.T, chainID, chainID2, ccname string, ccSide *mockpeer.Mock calledCCSide.SetResponses(respSet2) - cccid = ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid = ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) execCC(t, ctxt, ccSide, cccid, false, true, done, cis, respSet, chaincodeSupport) @@ -887,7 +887,7 @@ func getQueryResult(t *testing.T, collection, chainID, ccname string, ccSide *mo Responses: mkpeer, } - cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) if collection == "" { execCC(t, ctxt, ccSide, cccid, false, false, done, cis, respSet, chaincodeSupport) } else { @@ -952,7 +952,7 @@ func getHistory(t *testing.T, chainID, ccname string, ccSide *mockpeer.MockCCCom }, } - cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid := ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) execCC(t, ctxt, ccSide, cccid, false, false, done, cis, respSet, chaincodeSupport) endTx(t, cccid, txsim, cis) @@ -962,7 +962,7 @@ func getHistory(t *testing.T, chainID, ccname string, ccSide *mockpeer.MockCCCom func getLaunchConfigs(t *testing.T, cr *ContainerRuntime) { gt := NewGomegaWithT(t) - ccContext := ccprovider.NewCCContext("dummyChannelId", "mycc", "v0", "dummyTxid", false, nil, nil) + ccContext := ccprovider.NewCCContext("dummyChannelId", "mycc", "v0", "dummyTxid", nil, nil) lc, err := cr.LaunchConfig(ccContext.GetCanonicalName(), pb.ChaincodeSpec_GOLANG.String()) if err != nil { t.Fatalf("calling getLaunchConfigs() failed with error %s", err) @@ -1262,7 +1262,7 @@ func cc2SameCC(t *testing.T, chainID, chainID2, ccname string, ccSide *mockpeer. mockAclProvider.On("CheckACL", resources.Lscc_GetChaincodeData, chainID2, sprop).Return(nil) mockAclProvider.On("CheckACL", resources.Peer_Propose, chainID2, sprop).Return(nil) - cccid := ccprovider.NewCCContext(chainID2, ccname, "0", txid, false, sprop, prop) + cccid := ccprovider.NewCCContext(chainID2, ccname, "0", txid, sprop, prop) deployCC(t, ctxt, cccid, cis.ChaincodeSpec, chaincodeSupport) @@ -1302,7 +1302,7 @@ func cc2SameCC(t *testing.T, chainID, chainID2, ccname string, ccSide *mockpeer. }, } - cccid = ccprovider.NewCCContext(chainID, ccname, "0", txid, false, sprop, prop) + cccid = ccprovider.NewCCContext(chainID, ccname, "0", txid, sprop, prop) execCC(t, ctxt, ccSide, cccid, false, true, done, cis, respSet, chaincodeSupport) diff --git a/core/chaincode/exectransaction_test.go b/core/chaincode/exectransaction_test.go index e4c11a31bb2..65e501dc738 100644 --- a/core/chaincode/exectransaction_test.go +++ b/core/chaincode/exectransaction_test.go @@ -444,7 +444,7 @@ func deploy2(ctx context.Context, cccid *ccprovider.CCContext, chaincodeDeployme sysCCVers := util.GetSysCCVersion() sprop, prop := putils.MockSignedEndorserProposal2OrPanic(cccid.ChainID, cis.ChaincodeSpec, signer) - lsccid := ccprovider.NewCCContext(cccid.ChainID, cis.ChaincodeSpec.ChaincodeId.Name, sysCCVers, uuid, true, sprop, prop) + lsccid := ccprovider.NewCCContext(cccid.ChainID, cis.ChaincodeSpec.ChaincodeId.Name, sysCCVers, uuid, sprop, prop) //write to lscc if _, _, err = chaincodeSupport.Execute(ctx, lsccid, cis); err != nil { @@ -492,7 +492,7 @@ func invokeWithVersion(ctx context.Context, chainID string, version string, spec creator = []byte("Admin") } sprop, prop := putils.MockSignedEndorserProposalOrPanic(chainID, spec, creator, []byte("msg1")) - cccid := ccprovider.NewCCContext(chainID, cdInvocationSpec.ChaincodeSpec.ChaincodeId.Name, version, uuid, false, sprop, prop) + cccid := ccprovider.NewCCContext(chainID, cdInvocationSpec.ChaincodeSpec.ChaincodeId.Name, version, uuid, sprop, prop) var resp *pb.Response resp, ccevt, err = chaincodeSupport.Execute(ctx, cccid, cdInvocationSpec) if err != nil { @@ -526,7 +526,7 @@ func executeDeployTransaction(t *testing.T, chainID string, name string, url str args := util.ToChaincodeArgs(f, "a", "100", "b", "200") spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: &pb.ChaincodeID{Name: name, Path: url, Version: "0"}, Input: &pb.ChaincodeInput{Args: args}} - cccid := ccprovider.NewCCContext(chainID, name, "0", "", false, nil, nil) + cccid := ccprovider.NewCCContext(chainID, name, "0", "", nil, nil) defer chaincodeSupport.Stop( ccprovider.DeploymentSpecToChaincodeContainerInfo( @@ -907,7 +907,7 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) { spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID1, Input: &pb.ChaincodeInput{Args: args}} sProp, prop := putils.MockSignedEndorserProposalOrPanic(util.GetTestChainID(), spec1, []byte([]byte("Alice")), nil) - cccid1 := ccprovider.NewCCContext(chainID, "example02", "0", "", false, sProp, prop) + cccid1 := ccprovider.NewCCContext(chainID, "example02", "0", "", sProp, prop) var nextBlockNumber uint64 = 1 defer chaincodeSupport.Stop(&ccprovider.ChaincodeContainerInfo{ @@ -936,7 +936,7 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) { spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID2, Input: &pb.ChaincodeInput{Args: args}} - cccid2 := ccprovider.NewCCContext(chainID, "pthru", "0", "", false, sProp, prop) + cccid2 := ccprovider.NewCCContext(chainID, "pthru", "0", "", sProp, prop) defer chaincodeSupport.Stop(&ccprovider.ChaincodeContainerInfo{ Name: cID2.Name, @@ -1002,7 +1002,7 @@ func TestQueries(t *testing.T) { spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: args}} - cccid := ccprovider.NewCCContext(chainID, "tmap", "0", "", false, nil, nil) + cccid := ccprovider.NewCCContext(chainID, "tmap", "0", "", nil, nil) defer chaincodeSupport.Stop(&ccprovider.ChaincodeContainerInfo{ Name: cID.Name, @@ -1359,7 +1359,7 @@ func deployChaincode(ctx context.Context, name string, version string, chaincode signedProposal, proposal := putils.MockSignedEndorserProposal2OrPanic(channel, chaincodeSpec, signer) - chaincodeCtx := ccprovider.NewCCContext(channel, name, version, "", false, signedProposal, proposal) + chaincodeCtx := ccprovider.NewCCContext(channel, name, version, "", signedProposal, proposal) result, err := deploy(ctx, chaincodeCtx, chaincodeSpec, nextBlockNumber, chaincodeSupport) if err != nil { diff --git a/core/chaincode/executetransaction_pvtdata_test.go b/core/chaincode/executetransaction_pvtdata_test.go index e7ddcaa791b..7ff93a4ebbc 100644 --- a/core/chaincode/executetransaction_pvtdata_test.go +++ b/core/chaincode/executetransaction_pvtdata_test.go @@ -47,7 +47,7 @@ func TestQueriesPrivateData(t *testing.T) { spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: args}} - cccid := ccprovider.NewCCContext(chainID, "tmap", "0", "", false, nil, nil) + cccid := ccprovider.NewCCContext(chainID, "tmap", "0", "", nil, nil) var nextBlockNumber uint64 = 1 // this test assumes four collections diff --git a/core/chaincode/handler.go b/core/chaincode/handler.go index 211c30f31b5..b780ace1686 100644 --- a/core/chaincode/handler.go +++ b/core/chaincode/handler.go @@ -874,7 +874,7 @@ func (h *Handler) HandleInvokeChaincode(msg *pb.ChaincodeMessage, txContext *Tra // Launch the new chaincode if not already running chaincodeLogger.Debugf("[%s] launching chaincode %s on channel %s", shorttxid(msg.Txid), targetInstance.ChaincodeName, targetInstance.ChainID) - cccid := ccprovider.NewCCContext(targetInstance.ChainID, targetInstance.ChaincodeName, version, msg.Txid, false, txContext.SignedProp, txContext.Proposal) + cccid := ccprovider.NewCCContext(targetInstance.ChainID, targetInstance.ChaincodeName, version, msg.Txid, txContext.SignedProp, txContext.Proposal) cciSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: chaincodeSpec} // Execute the chaincode... this CANNOT be an init at least for now diff --git a/core/chaincode/handler_test.go b/core/chaincode/handler_test.go index a732c087320..81e62484f7b 100644 --- a/core/chaincode/handler_test.go +++ b/core/chaincode/handler_test.go @@ -1714,7 +1714,7 @@ var _ = Describe("Handler", func() { Signature: []byte("signature"), } - cccid = ccprovider.NewCCContext("channel-name", "chaincode-name", "chaincode-version", "tx-id", false, expectedSignedProp, expectedProposal) + cccid = ccprovider.NewCCContext("channel-name", "chaincode-name", "chaincode-version", "tx-id", expectedSignedProp, expectedProposal) incomingMessage = &pb.ChaincodeMessage{ Type: pb.ChaincodeMessage_TRANSACTION, Txid: "tx-id", @@ -1777,7 +1777,7 @@ var _ = Describe("Handler", func() { Context("when the proposal is missing", func() { BeforeEach(func() { - cccid = ccprovider.NewCCContext("channel-name", "chaincode-name", "chaincode-version", "tx-id", false, expectedSignedProp, nil) + cccid = ccprovider.NewCCContext("channel-name", "chaincode-name", "chaincode-version", "tx-id", expectedSignedProp, nil) }) It("sends a nil proposal", func() { @@ -1794,7 +1794,7 @@ var _ = Describe("Handler", func() { Context("when the signed proposal is missing", func() { BeforeEach(func() { - cccid = ccprovider.NewCCContext("channel-name", "chaincode-name", "chaincode-version", "tx-id", false, nil, expectedProposal) + cccid = ccprovider.NewCCContext("channel-name", "chaincode-name", "chaincode-version", "tx-id", nil, expectedProposal) }) It("returns an error", func() { @@ -2117,7 +2117,7 @@ var _ = Describe("Handler", func() { expectedProposal = &pb.Proposal{} expectedSignedProp = &pb.SignedProposal{} - cccid = ccprovider.NewCCContext("channel-name", "chaincode-name", "chaincode-version", "tx-id", false, expectedSignedProp, expectedProposal) + cccid = ccprovider.NewCCContext("channel-name", "chaincode-name", "chaincode-version", "tx-id", expectedSignedProp, expectedProposal) incomingMessage = &pb.ChaincodeMessage{ Type: pb.ChaincodeMessage_TRANSACTION, diff --git a/core/common/ccprovider/ccinfocache_test.go b/core/common/ccprovider/ccinfocache_test.go index 46e5ea3a438..7fb96fd5e86 100644 --- a/core/common/ccprovider/ccinfocache_test.go +++ b/core/common/ccprovider/ccinfocache_test.go @@ -211,16 +211,16 @@ func TestGetInstalledChaincodesErrorPaths(t *testing.T) { } func TestNewCCContext(t *testing.T) { - ccctx := NewCCContext("foo", "foo", "1.0", "", false, nil, nil) + ccctx := NewCCContext("foo", "foo", "1.0", "", nil, nil) assert.NotNil(t, ccctx) canName := ccctx.GetCanonicalName() assert.NotEmpty(t, canName) assert.Panics(t, func() { - NewCCContext("foo", "foo", "", "", false, nil, nil) + NewCCContext("foo", "foo", "", "", nil, nil) }, "NewCCContext should have paniced if version is empty") - ccctx = &CCContext{"foo", "foo", "1.0", "", false, nil, nil, "", nil} + ccctx = &CCContext{"foo", "foo", "1.0", "", nil, nil, "", nil} assert.Panics(t, func() { ccctx.GetCanonicalName() }, "GetConnonicalName should have paniced if cannonical name is empty") diff --git a/core/common/ccprovider/ccprovider.go b/core/common/ccprovider/ccprovider.go index 946abe8093e..506b897b5bc 100644 --- a/core/common/ccprovider/ccprovider.go +++ b/core/common/ccprovider/ccprovider.go @@ -364,9 +364,6 @@ type CCContext struct { // TxID is the transaction id for the proposal (if any) TxID string - // Syscc is this a system chaincode - Syscc bool - // SignedProposal for this invoke (if any) this is kept here for access // control and in case we need to pass something from this to the chaincode SignedProposal *pb.SignedProposal @@ -383,13 +380,12 @@ type CCContext struct { } // NewCCContext just construct a new struct with whatever args -func NewCCContext(cname, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal) *CCContext { +func NewCCContext(cname, name, version, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal) *CCContext { cccid := &CCContext{ ChainID: cname, Name: name, Version: version, TxID: txid, - Syscc: syscc, SignedProposal: signedProp, Proposal: prop, canonicalName: name + ":" + version, @@ -407,8 +403,8 @@ func NewCCContext(cname, name, version, txid string, syscc bool, signedProp *pb. } func (cccid *CCContext) String() string { - return fmt.Sprintf("chain=%s,chaincode=%s,version=%s,txid=%s,syscc=%t,proposal=%p,canname=%s", - cccid.ChainID, cccid.Name, cccid.Version, cccid.TxID, cccid.Syscc, cccid.Proposal, cccid.canonicalName) + return fmt.Sprintf("chain=%s,chaincode=%s,version=%s,txid=%s,proposal=%p,canname=%s", + cccid.ChainID, cccid.Name, cccid.Version, cccid.TxID, cccid.Proposal, cccid.canonicalName) } // GetCanonicalName returns the canonical name associated with the proposal context @@ -543,7 +539,7 @@ type ChaincodeProvider interface { Execute(ctxt context.Context, cccid *CCContext, spec *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) // ExecuteInit is a special case for executing chaincode deployment specs, needed for old lifecycle ExecuteInit(ctxt context.Context, cccid *CCContext, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) - // Stop stops the chaincode given + // Stop stops the chaincode give Stop(ccci *ChaincodeContainerInfo) error } diff --git a/core/endorser/endorser.go b/core/endorser/endorser.go index 8c4e17089ce..ce514e18214 100644 --- a/core/endorser/endorser.go +++ b/core/endorser/endorser.go @@ -59,10 +59,10 @@ type Support interface { IsSysCC(name string) bool // Execute - execute proposal, return original response of chaincode - Execute(ctxt context.Context, cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) + Execute(ctxt context.Context, cid, name, version, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) // ExecuteInit - executes a deployment proposal, return original response of chaincode - ExecuteInit(ctxt context.Context, cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) + ExecuteInit(ctxt context.Context, cid, name, version, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) // GetChaincodeDefinition returns ccprovider.ChaincodeDefinition for the chaincode with the supplied name GetChaincodeDefinition(chaincodeID string, txsim ledger.QueryExecutor) (ccprovider.ChaincodeDefinition, error) @@ -137,9 +137,7 @@ func (e *Endorser) callChaincode(ctxt context.Context, chainID string, version s } // is this a system chaincode - scc := e.s.IsSysCC(cid.Name) - - res, ccevent, err = e.s.Execute(ctxt, chainID, cid.Name, version, txid, scc, signedProp, prop, cis) + res, ccevent, err = e.s.Execute(ctxt, chainID, cid.Name, version, txid, signedProp, prop, cis) if err != nil { return nil, nil, err } @@ -176,7 +174,7 @@ func (e *Endorser) callChaincode(ctxt context.Context, chainID string, version s return nil, nil, errors.Errorf("attempting to deploy a system chaincode %s/%s", cds.ChaincodeSpec.ChaincodeId.Name, chainID) } - _, _, err = e.s.ExecuteInit(ctxt, chainID, cds.ChaincodeSpec.ChaincodeId.Name, cds.ChaincodeSpec.ChaincodeId.Version, txid, false, signedProp, prop, cds) + _, _, err = e.s.ExecuteInit(ctxt, chainID, cds.ChaincodeSpec.ChaincodeId.Name, cds.ChaincodeSpec.ChaincodeId.Version, txid, signedProp, prop, cds) if err != nil { return nil, nil, err } diff --git a/core/endorser/mocks/support.go b/core/endorser/mocks/support.go index 6e31440405a..1984b7abefe 100644 --- a/core/endorser/mocks/support.go +++ b/core/endorser/mocks/support.go @@ -101,7 +101,7 @@ type Support struct { isSysCCReturnsOnCall map[int]struct { result1 bool } - ExecuteStub func(ctxt context.Context, cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) + ExecuteStub func(ctxt context.Context, cid, name, version, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) executeMutex sync.RWMutex executeArgsForCall []struct { ctxt context.Context @@ -109,7 +109,6 @@ type Support struct { name string version string txid string - syscc bool signedProp *pb.SignedProposal prop *pb.Proposal spec *pb.ChaincodeInvocationSpec @@ -124,7 +123,7 @@ type Support struct { result2 *pb.ChaincodeEvent result3 error } - ExecuteInitStub func(ctxt context.Context, cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) + ExecuteInitStub func(ctxt context.Context, cid, name, version, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) executeInitMutex sync.RWMutex executeInitArgsForCall []struct { ctxt context.Context @@ -132,7 +131,6 @@ type Support struct { name string version string txid string - syscc bool signedProp *pb.SignedProposal prop *pb.Proposal spec *pb.ChaincodeDeploymentSpec @@ -620,7 +618,7 @@ func (fake *Support) IsSysCCReturnsOnCall(i int, result1 bool) { }{result1} } -func (fake *Support) Execute(ctxt context.Context, cid string, name string, version string, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) { +func (fake *Support) Execute(ctxt context.Context, cid string, name string, version string, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) { fake.executeMutex.Lock() ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { @@ -629,15 +627,14 @@ func (fake *Support) Execute(ctxt context.Context, cid string, name string, vers name string version string txid string - syscc bool signedProp *pb.SignedProposal prop *pb.Proposal spec *pb.ChaincodeInvocationSpec - }{ctxt, cid, name, version, txid, syscc, signedProp, prop, spec}) - fake.recordInvocation("Execute", []interface{}{ctxt, cid, name, version, txid, syscc, signedProp, prop, spec}) + }{ctxt, cid, name, version, txid, signedProp, prop, spec}) + fake.recordInvocation("Execute", []interface{}{ctxt, cid, name, version, txid, signedProp, prop, spec}) fake.executeMutex.Unlock() if fake.ExecuteStub != nil { - return fake.ExecuteStub(ctxt, cid, name, version, txid, syscc, signedProp, prop, spec) + return fake.ExecuteStub(ctxt, cid, name, version, txid, signedProp, prop, spec) } if specificReturn { return ret.result1, ret.result2, ret.result3 @@ -651,10 +648,10 @@ func (fake *Support) ExecuteCallCount() int { return len(fake.executeArgsForCall) } -func (fake *Support) ExecuteArgsForCall(i int) (context.Context, string, string, string, string, bool, *pb.SignedProposal, *pb.Proposal, *pb.ChaincodeInvocationSpec) { +func (fake *Support) ExecuteArgsForCall(i int) (context.Context, string, string, string, string, *pb.SignedProposal, *pb.Proposal, *pb.ChaincodeInvocationSpec) { fake.executeMutex.RLock() defer fake.executeMutex.RUnlock() - return fake.executeArgsForCall[i].ctxt, fake.executeArgsForCall[i].cid, fake.executeArgsForCall[i].name, fake.executeArgsForCall[i].version, fake.executeArgsForCall[i].txid, fake.executeArgsForCall[i].syscc, fake.executeArgsForCall[i].signedProp, fake.executeArgsForCall[i].prop, fake.executeArgsForCall[i].spec + return fake.executeArgsForCall[i].ctxt, fake.executeArgsForCall[i].cid, fake.executeArgsForCall[i].name, fake.executeArgsForCall[i].version, fake.executeArgsForCall[i].txid, fake.executeArgsForCall[i].signedProp, fake.executeArgsForCall[i].prop, fake.executeArgsForCall[i].spec } func (fake *Support) ExecuteReturns(result1 *pb.Response, result2 *pb.ChaincodeEvent, result3 error) { @@ -682,7 +679,7 @@ func (fake *Support) ExecuteReturnsOnCall(i int, result1 *pb.Response, result2 * }{result1, result2, result3} } -func (fake *Support) ExecuteInit(ctxt context.Context, cid string, name string, version string, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) { +func (fake *Support) ExecuteInit(ctxt context.Context, cid string, name string, version string, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) { fake.executeInitMutex.Lock() ret, specificReturn := fake.executeInitReturnsOnCall[len(fake.executeInitArgsForCall)] fake.executeInitArgsForCall = append(fake.executeInitArgsForCall, struct { @@ -691,15 +688,14 @@ func (fake *Support) ExecuteInit(ctxt context.Context, cid string, name string, name string version string txid string - syscc bool signedProp *pb.SignedProposal prop *pb.Proposal spec *pb.ChaincodeDeploymentSpec - }{ctxt, cid, name, version, txid, syscc, signedProp, prop, spec}) - fake.recordInvocation("ExecuteInit", []interface{}{ctxt, cid, name, version, txid, syscc, signedProp, prop, spec}) + }{ctxt, cid, name, version, txid, signedProp, prop, spec}) + fake.recordInvocation("ExecuteInit", []interface{}{ctxt, cid, name, version, txid, signedProp, prop, spec}) fake.executeInitMutex.Unlock() if fake.ExecuteInitStub != nil { - return fake.ExecuteInitStub(ctxt, cid, name, version, txid, syscc, signedProp, prop, spec) + return fake.ExecuteInitStub(ctxt, cid, name, version, txid, signedProp, prop, spec) } if specificReturn { return ret.result1, ret.result2, ret.result3 @@ -713,10 +709,10 @@ func (fake *Support) ExecuteInitCallCount() int { return len(fake.executeInitArgsForCall) } -func (fake *Support) ExecuteInitArgsForCall(i int) (context.Context, string, string, string, string, bool, *pb.SignedProposal, *pb.Proposal, *pb.ChaincodeDeploymentSpec) { +func (fake *Support) ExecuteInitArgsForCall(i int) (context.Context, string, string, string, string, *pb.SignedProposal, *pb.Proposal, *pb.ChaincodeDeploymentSpec) { fake.executeInitMutex.RLock() defer fake.executeInitMutex.RUnlock() - return fake.executeInitArgsForCall[i].ctxt, fake.executeInitArgsForCall[i].cid, fake.executeInitArgsForCall[i].name, fake.executeInitArgsForCall[i].version, fake.executeInitArgsForCall[i].txid, fake.executeInitArgsForCall[i].syscc, fake.executeInitArgsForCall[i].signedProp, fake.executeInitArgsForCall[i].prop, fake.executeInitArgsForCall[i].spec + return fake.executeInitArgsForCall[i].ctxt, fake.executeInitArgsForCall[i].cid, fake.executeInitArgsForCall[i].name, fake.executeInitArgsForCall[i].version, fake.executeInitArgsForCall[i].txid, fake.executeInitArgsForCall[i].signedProp, fake.executeInitArgsForCall[i].prop, fake.executeInitArgsForCall[i].spec } func (fake *Support) ExecuteInitReturns(result1 *pb.Response, result2 *pb.ChaincodeEvent, result3 error) { diff --git a/core/endorser/support.go b/core/endorser/support.go index 9c8f037159b..0178f175e8e 100644 --- a/core/endorser/support.go +++ b/core/endorser/support.go @@ -123,15 +123,15 @@ func (s *SupportImpl) GetChaincodeDeploymentSpecFS(cds *pb.ChaincodeDeploymentSp } // ExecuteInit a deployment proposal and return the chaincode response -func (s *SupportImpl) ExecuteInit(ctxt context.Context, cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal, cds *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) { - cccid := ccprovider.NewCCContext(cid, name, version, txid, syscc, signedProp, prop) +func (s *SupportImpl) ExecuteInit(ctxt context.Context, cid, name, version, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, cds *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) { + cccid := ccprovider.NewCCContext(cid, name, version, txid, signedProp, prop) return s.ChaincodeSupport.ExecuteInit(ctxt, cccid, cds) } // Execute a proposal and return the chaincode response -func (s *SupportImpl) Execute(ctxt context.Context, cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal, cis *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) { - cccid := ccprovider.NewCCContext(cid, name, version, txid, syscc, signedProp, prop) +func (s *SupportImpl) Execute(ctxt context.Context, cid, name, version, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, cis *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) { + cccid := ccprovider.NewCCContext(cid, name, version, txid, signedProp, prop) // decorate the chaincode input decorators := library.InitRegistry(library.Config{}).Lookup(library.Decoration).([]decoration.Decorator) diff --git a/core/mocks/endorser/support.go b/core/mocks/endorser/support.go index 06fb81aa05f..573d9eca318 100644 --- a/core/mocks/endorser/support.go +++ b/core/mocks/endorser/support.go @@ -95,11 +95,11 @@ func (s *MockSupport) IsSysCC(name string) bool { return s.IsSysCCRv } -func (s *MockSupport) ExecuteInit(ctxt context.Context, cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) { +func (s *MockSupport) ExecuteInit(ctxt context.Context, cid, name, version, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error) { return s.ExecuteCDSResp, s.ExecuteCDSEvent, s.ExecuteCDSError } -func (s *MockSupport) Execute(ctxt context.Context, cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) { +func (s *MockSupport) Execute(ctxt context.Context, cid, name, version, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, spec *pb.ChaincodeInvocationSpec) (*pb.Response, *pb.ChaincodeEvent, error) { return s.ExecuteResp, s.ExecuteEvent, s.ExecuteError } diff --git a/core/scc/sysccapi.go b/core/scc/sysccapi.go index 9df2c5fd88d..39236ffd471 100644 --- a/core/scc/sysccapi.go +++ b/core/scc/sysccapi.go @@ -170,7 +170,7 @@ func deploySysCC(chainID string, ccprov ccprovider.ChaincodeProvider, syscc Self // XXX This is an ugly hack, version should be tied to the chaincode instance, not he peer binary version := util.GetSysCCVersion() - cccid := ccprovider.NewCCContext(chainID, chaincodeDeploymentSpec.ChaincodeSpec.ChaincodeId.Name, version, txid, true, nil, nil) + cccid := ccprovider.NewCCContext(chainID, chaincodeDeploymentSpec.ChaincodeSpec.ChaincodeId.Name, version, txid, nil, nil) resp, _, err := ccprov.ExecuteInit(ctxt, cccid, chaincodeDeploymentSpec) if err == nil && resp.Status != shim.OK {