Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot commit chaincode approve #240

Open
luca-simonetti opened this issue Oct 17, 2022 · 3 comments
Open

Cannot commit chaincode approve #240

luca-simonetti opened this issue Oct 17, 2022 · 3 comments

Comments

@luca-simonetti
Copy link

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

@bestbeforetoday
Copy link
Member

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.

@luca-simonetti
Copy link
Author

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.

@luca-simonetti
Copy link
Author

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants