Skip to content

Commit 86e0b9c

Browse files
committed
[FAB-2822] Invoke before Instantiate
This bug about Invoke on a chaincode while the Instantiate transaction on the chaincode hasn't been completed. The current error mesage is too criptic. This changeset enhances the message. Change-Id: I0a2c553f586e55f4a26d03a96e72e9fabe023ff7 Signed-off-by: Binh Q. Nguyen <[email protected]>
1 parent 8b3c35c commit 86e0b9c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

core/endorser/endorser.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ func (e *Endorser) simulateProposal(ctx context.Context, chainID string, txid st
227227
if !syscc.IsSysCC(cid.Name) {
228228
cdLedger, err = e.getCDSFromLSCC(ctx, chainID, txid, signedProp, prop, cid.Name, txsim)
229229
if err != nil {
230-
return nil, nil, nil, nil, fmt.Errorf("failed to obtain cds for %s - %s", cid.Name, err)
230+
return nil, nil, nil, nil, fmt.Errorf("%s - make sure the chaincode %s has been successfully instantiated and try again", err, cid.Name)
231231
}
232232
version = cdLedger.Version
233233

234234
// we retrieve info about this chaincode from the file system
235235
ccpack, err := ccprovider.GetChaincodeFromFS(cid.Name, version)
236236
if err != nil {
237-
return nil, nil, nil, nil, fmt.Errorf("Chaincode data for cc %s/%s was not found, error %s", cid.Name, version, err)
237+
return nil, nil, nil, nil, fmt.Errorf("chaincode %s/%s not found on the file system, error %s", cid.Name, version, err)
238238
}
239239
// ccpack is guaranteed to be non-nil
240240
cdLocalFS := ccpack.GetChaincodeData()
@@ -253,7 +253,7 @@ func (e *Endorser) simulateProposal(ctx context.Context, chainID string, txid st
253253
// https://jira.hyperledger.org/browse/FAB-3156
254254
if cdLocalFS.InstantiationPolicy != nil {
255255
if !bytes.Equal(cdLocalFS.InstantiationPolicy, cdLedger.InstantiationPolicy) {
256-
return nil, nil, nil, nil, fmt.Errorf("Instantiation policy mismatch for cc %s/%s", cid.Name, version)
256+
return nil, nil, nil, nil, fmt.Errorf("instantiation policy mismatch for cc %s/%s", cid.Name, version)
257257
}
258258
}
259259
} else {
@@ -266,7 +266,7 @@ func (e *Endorser) simulateProposal(ctx context.Context, chainID string, txid st
266266
var ccevent *pb.ChaincodeEvent
267267
res, ccevent, err = e.callChaincode(ctx, chainID, version, txid, signedProp, prop, cis, cid, txsim)
268268
if err != nil {
269-
endorserLogger.Errorf("callChaincode() failed for txid: %s error: %s", txid, err)
269+
endorserLogger.Errorf("failed to invoke chaincode %s on transaction %s, error: %s", cid, txid, err)
270270
return nil, nil, nil, nil, err
271271
}
272272

@@ -423,7 +423,7 @@ func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedPro
423423
// here we handle uniqueness check and ACLs for proposals targeting a chain
424424
lgr := peer.GetLedger(chainID)
425425
if lgr == nil {
426-
return nil, errors.New(fmt.Sprintf("Failure while looking up the ledger %s", chainID))
426+
return nil, fmt.Errorf("failure while looking up the ledger %s", chainID)
427427
}
428428
if _, err := lgr.GetTransactionByID(txid); err == nil {
429429
return nil, fmt.Errorf("Duplicate transaction found [%s]. Creator [%x]. [%s]", txid, shdr.Creator, err)

0 commit comments

Comments
 (0)