From ec3ada227ab6247df0a356e1187a5e89a332e630 Mon Sep 17 00:00:00 2001 From: Will Lahti Date: Thu, 11 May 2017 15:44:35 -0400 Subject: [PATCH] [FAB-3562] CLI displays unexpected invoke result This CR improves the log messages after a successful invoke. The previous log message displayed the ESCC invoke result instead of the chaincode invoke result, which was confusing to end users. The previous log message now specifies that it is for the ESCC result and adds a new log message to display the chaincode invoke result. This CR also adds a few logging messages to the endorser code that were helpful during my time debugging and working to understand the endorsement logic. Change-Id: I02cb0dfe620e7c17472b8b12467c746c27598942 Signed-off-by: Will Lahti --- core/chaincode/chaincode_support.go | 3 +++ core/endorser/endorser.go | 2 +- peer/chaincode/common.go | 11 ++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/chaincode/chaincode_support.go b/core/chaincode/chaincode_support.go index bf9fb1b309a..1a330281d74 100644 --- a/core/chaincode/chaincode_support.go +++ b/core/chaincode/chaincode_support.go @@ -653,7 +653,10 @@ func createCCMessage(typ pb.ChaincodeMessage_Type, txid string, cMsg *pb.Chainco // Execute executes a transaction and waits for it to complete until a timeout value. func (chaincodeSupport *ChaincodeSupport) Execute(ctxt context.Context, cccid *ccprovider.CCContext, msg *pb.ChaincodeMessage, timeout time.Duration) (*pb.ChaincodeMessage, error) { + chaincodeLogger.Debugf("Entry") + defer chaincodeLogger.Debugf("Exit") canName := cccid.GetCanonicalName() + chaincodeLogger.Debugf("chaincode canonical name: %s", canName) chaincodeSupport.runningChaincodes.Lock() //we expect the chaincode to be running... sanity check chrte, ok := chaincodeSupport.chaincodeHasBeenLaunched(canName) diff --git a/core/endorser/endorser.go b/core/endorser/endorser.go index fd4962e62f3..e6b5dfd3495 100644 --- a/core/endorser/endorser.go +++ b/core/endorser/endorser.go @@ -418,7 +418,7 @@ func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedPro err = errors.New("Invalid txID. It must be different from the empty string.") return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err } - + endorserLogger.Debugf("processing txid: %s", txid) if chainID != "" { // here we handle uniqueness check and ACLs for proposals targeting a chain lgr := peer.GetLedger(chainID) diff --git a/peer/chaincode/common.go b/peer/chaincode/common.go index a278a41395a..ff9decea5fc 100644 --- a/peer/chaincode/common.go +++ b/peer/chaincode/common.go @@ -121,7 +121,16 @@ func chaincodeInvokeOrQuery(cmd *cobra.Command, args []string, invoke bool, cf * } logger.Warningf("Endorsement failure during invoke. chaincode result: %v", ca.Response) } else { - logger.Infof("Invoke result: %v", proposalResp) + logger.Debugf("ESCC invoke result: %v", proposalResp) + pRespPayload, err := putils.GetProposalResponsePayload(proposalResp.Payload) + if err != nil { + return fmt.Errorf("Error while unmarshaling proposal response payload: %s", err) + } + ca, err := putils.GetChaincodeAction(pRespPayload.Extension) + if err != nil { + return fmt.Errorf("Error while unmarshaling chaincode action: %s", err) + } + logger.Infof("Chaincode invoke successful. result: %v", ca.Response) } } else { if proposalResp == nil {