Search code examples
dockerhyperledger-fabrichyperledgerhyperledger-chaincodechaincode

Hyperledger Fabric error: signature set did not satisfy policy


I've created a network configuration with 2 orgs, each one with 1 peer and CA. I've successfully installed and instantiated my chaincode on both peers But after invoking a transaction this error occurs on both peers:

peer0.org1.example.com|2020-01-27 21:32:00.531 UTC [committer.txvalidator] validateTx -> ERRO 047 VSCCValidateTx for transaction txId = d18ad9c8c5e6aada47b7c8677676b4d748bf2ae16256c093ae8f9dfb0bf17779 returned error: VSCC error: endorsement policy failure, err: signature set did not satisfy policy
peer0.org2.example.com|2020-01-27 21:32:00.531 UTC [committer.txvalidator] validateTx -> ERRO 069 VSCCValidateTx for transaction txId = d18ad9c8c5e6aada47b7c8677676b4d748bf2ae16256c093ae8f9dfb0bf17779 returned error: VSCC error: endorsement policy failure, err: signature set did not satisfy policy

that's how I installed the chaincode on both peers:

peer chaincode install -n mycc -v 1.0 -l node -p /opt/gopath/src/github.com/mychaincodes/

that's how I instantiated my contract

peer chaincode instantiate -o orderer.example.com:7050 --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -l node -v 1.0 -c '{"Args":[]}' -P "AND ('Org1MSP.member','Org2MSP.member')"

and that's how I invoked transaction

peer chaincode invoke -o orderer.example.com:7050 --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/ca/ca.example.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem -c '{"Args":["createMyAsset","001","Model X"]}'

Thanks in advance


Solution

  • During chaincode instantiation, you specify the endorsement policy for this chaincode as "AND ('Org1MSP.member','Org2MSP.member')", which means that peers from both organisations have to endorse the transaction.

    Then you only connect to peer0.org1.example.com:7051 during chaincode invocation.

    To make this work, you have to either change the endorsement policy to "OR ('Org1MSP.member','Org2MSP.member')", or connect to peers in both orgs while invoking chaincode, by adding another --peerAddresses ... entry.