Skip to content

Commit

Permalink
[FAB-5895] Enhance peer logging for pol. eval. failure
Browse files Browse the repository at this point in the history
This CR improves the wording of the log messages when an endorsement
policy fails to make it clear to an end user what error has occurred.
It also removes two unnecessary log messages as those errors are logged
by the calling function.

Change-Id: I96aea7c556f38a2b95da147aa42a35c3b27c8d93
Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
  • Loading branch information
wlahti committed Feb 1, 2018
1 parent f435c34 commit a7db795
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common/cauthdsl/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (p *policy) Evaluate(signatureSet []*cb.SignedData) error {

ok := p.evaluator(deduplicate(signatureSet, p.deserializer), make([]bool, len(signatureSet)))
if !ok {
return errors.New("Failed to authenticate policy")
return errors.New("signature set did not satisfy policy")
}
return nil
}
4 changes: 1 addition & 3 deletions core/committer/txvalidator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func validateTx(req *blockValidationRequest, results chan<- *blockValidationResu
logger.Debug("Validating transaction vscc tx validate")
err, cde := v.vscc.VSCCValidateTx(payload, d, env)
if err != nil {
logger.Errorf("VSCCValidateTx for transaction txId = %s returned error %s", txID, err)
logger.Errorf("VSCCValidateTx for transaction txId = %s returned error: %s", txID, err)
switch err.(type) {
case *commonerrors.VSCCExecutionFailureError:
results <- &blockValidationResult{
Expand Down Expand Up @@ -834,11 +834,9 @@ func (v *vsccValidatorImpl) VSCCValidateTxForCC(envBytes []byte, txid, chid, vsc
res, _, err := v.ccprovider.ExecuteChaincode(ctxt, cccid, args)
if err != nil {
msg := fmt.Sprintf("Invoke VSCC failed for transaction txid=%s, error: %s", txid, err)
logger.Errorf(msg)
return &commonerrors.VSCCExecutionFailureError{msg}
}
if res.Status != shim.OK {
logger.Errorf("VSCC check failed for transaction txid=%s, error %s", txid, res.Message)
return &commonerrors.VSCCEndorsementPolicyError{fmt.Sprintf("%s", res.Message)}
}

Expand Down
2 changes: 1 addition & 1 deletion core/scc/vscc/validator_onevalidsignature.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (vscc *ValidatorOneValidSignature) Invoke(stub shim.ChaincodeStubInterface)
// Warning: duplicated identities exist, endorsement failure might be cause by this reason
return shim.Error(DUPLICATED_IDENTITY_ERROR)
}
return shim.Error(fmt.Sprintf("VSCC error: policy evaluation failed, err %s", err))
return shim.Error(fmt.Sprintf("VSCC error: endorsement policy failure, err: %s", err))
}

hdrExt, err := utils.GetChaincodeHeaderExtension(payl.Header)
Expand Down

0 comments on commit a7db795

Please sign in to comment.