Delbert
Delbert

Reputation: 3

How to solve the prob using peer lifecycle chaincode approveformyorg command with argument '--signature-policy'

I am using Hyperledger Fabric v2.3.1.I am trying to approve my chaincode definition with argument --signature-policy "OR('Org1MSP.peer','Org2MSP.peer')" instead of the default endorsement for the test-network. The whole command is below

peer lifecycle chaincode approveformyorg  -o orderer.example.com:7050 \
  --tls --cafile $ORDERER_CA --channelID mychannel --name fabcar \
  --version 1.0 \
  --package-id fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506 \
  --sequence 1 --signature-policy "OR ('Org1MSP.peer','Org2MSP.peer')"

And I get this result

2021-06-09 11:56:14.132 CST [chaincodeCmd] ClientWait -> INFO 001 txid [f77193563630eaca758a4e3e360e77625be3bba51a7ac361e0353291a9441ffc] committed with status (VALID) at localhost:7051

However, when I commit the chaincode definition(the whole command is below), I got this error message

peer lifecycle chaincode commit  -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA --channelID mychannel --name fabcar --peerAddresses localhost:7051 --tlsRootCertFiles $PEER_CA --version 1.0 --sequence 1
Error: proposal failed with status: 500 - failed to invoke backing implementation of 'CommitChaincodeDefinition': chaincode definition not agreed to by this org (Org1MSP)

What's wrong with it?

Upvotes: 0

Views: 1200

Answers (2)

Delbert
Delbert

Reputation: 3

Actually,my pros has been solved by LI Xian.However, I found something confusing.When I used the command below to alter the default endorsement policy with argument '--signature-policy'.

peer lifecycle chaincode approveformyorg  -o orderer.example.com:7050 \
  --tls --cafile $ORDERER_CA --channelID mychannel --name fabcar \
  --version 1.0 \
  --package-id fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506 \
  --sequence 1 --signature-policy "OR ('Org1MSP.peer','Org2MSP.peer')"

Then I entered 'peer lifecycle chaincode checkcommitreadiness' sub-command, and I got this confusing result.

{
    "approvals": {
        "Org1MSP": false,
        "Org2MSP": false
    }
}

The result showed I didn't get any approvals from either orgs, but I still could commit my chaincode definition.Maybe it is a bug of Fabric v2.3.1.

Upvotes: 0

Li Xian
Li Xian

Reputation: 411

add flag --signature-policywhen you commit your chaincode,like these

peer lifecycle chaincode commit  -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA --channelID mychannel --name fabcar --peerAddresses localhost:7051 --tlsRootCertFiles $PEER_CA --version 1.0 --sequence 1 --signature-policy "OR ('Org1MSP.peer','Org2MSP.peer')"

Upvotes: 1

Related Questions