fabric-sdk-java
fabric-sdk-java copied to clipboard
Cannot commit chaincode approve
I'm trying to use the fabric sdk to install a chaincode on my network. The chaincode gets correctly packaged. I then approve it. which returns some weird thing:
System.out.printf("[approve] chaincodeId: %s, message: %s\n",
lifecycleApproveChaincodeDefinitionForMyOrgProposalResponse
.getChaincodeID(),
lifecycleApproveChaincodeDefinitionForMyOrgProposalResponse
.getMessage());
prints:
[approve] chaincodeId: ChaincodeID(_lifecycle::), message:
with status 200.
Then when I try to commit I get:
[commit] chaincodeId: ChaincodeID(_lifecycle::), message: failed to invoke backing implementation of 'CommitChaincodeDefinition': chaincode definition not agreed to by this org (Org1MSP)
I think there's some kind of issue with the install operation. I'm using version 2.2.2
I don't see you mention installing the packaged chaincode before approving. Check the Fabric documentation on chaincode lifecycle for the steps required and their order.
It's also worth checking that after the approval call in the Java API, you also submit the endorsed approval. It's not particularly readable but the integration tests do exercise the chaincode lifecycle API to successfully deploy chaincode:
https://github.com/hyperledger/fabric-sdk-java/blob/main/src/test/java/org/hyperledger/fabric/sdkintegration/End2endLifecycleIT.java
The last thing to say is that the currently recommended approach for admin operations is to use the Fabric CLI commands. The Java API here works and should continue to work but is not being actively developed anymore. For business applications deployed to Fabric v2.4+, the recommended and supported application API is the Fabric Gateway client API. This does not include admin capability, including chaincode lifecycle.
I also have installed the package (I tried to check with peer lifecycle chaincode queryinstalled and it prints out fine) using the peer command would be a little bit of a mess on our cluster, that's why I'm trying to use this SDK to install chaincodes.
it might be related to the signing policy. I can't really find any documentation on this, are these equivalent?
OR('Org1MSP.peer')
identities: # list roles to be used in the policy
peer: {"role": {"name": "peer", "mspId": "Org1MSP"}} # role member in org with mspid Org1MSP
policy: # the policy .. could have been flat but show grouping.
1-of: # signed by one of these groups can be <n>-of where <n> is any digit 2-of, 3-of etc..
- signed-by: "peer"