How to change Endorsement policies

2019-05-06 14:41发布

问题:

I changed the endorsement policy from "OR" to "AND" with BYFN and instantiate the Chaincode. But, the data in the ledger is not changed even after the Invoke is executed. I confirmed "OR" condition is working.(data in the ledger is changed)

Kindly let me know how I can solve it.

peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "**OR** ('Org1MSP.member','Org2MSP.member')"

==>

peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "**AND** ('Org1MSP.member','Org2MSP.member')"

回答1:

Well the good news is that it looks like the modified endorsement policy is actually working. The bad news is that it's not possible to use an endorsement policy with an AND condition in BYFN without creating your own client using one of the SDKs. The issue is that the BYFN script uses the peer CLI to run invoke (and query too) and the peer CLI does not have the ability to collect multiple endorsements. So when you change the endorsement policy to AND, the script is only collecting a single endorsement and therefore validation fails when trying to process the invoke.



回答2:

Let me add to @Gari Singh answer and clarify about the change of endorsement policies for already instantiated chaincode. Once you initialized the chaincode with endorsement policy and you would like to update/change it later you can do so by upgrading chaincode and specifying new endorsement policies.