8

I've followed 2 different tutorials

https://github.com/swetharepakula/Fabric101Workshop and

https://hyperledger-fabric.readthedocs.io/en/release-2.0/deploy_chaincode.html.

Both times when I query installed it shows fabcar is installed and it commits successfully, but in both when I try to invoke I receive the following:

Error: endorsement failure during invoke. response: status:500 message:"make sure the chaincode fabcar has been successfully defined on channel mychannel and try again: chaincode definition for 'fabcar' exists, but chaincode is not installed".

I've tried changing CORE_PEER_GOSSIP_USELEADERELECTION=true, but this stopped one of my peer nodes from starting up.

I'm working on a Mac and the nodes are running in docker, any help would be greatly appreciated.

Mehadi Hassan
  • 1,160
  • 1
  • 13
  • 33
Bess
  • 81
  • 1
  • 2

6 Answers6

1

I've had this error when I used the wrong packageID when approving on one of the organization

When using approveformyorg, checkout that you use respective $PACKAGE_ID_ORG1 and $PACKAGE_ID_ORG2:

On org1 :

peer lifecycle chaincode approveformyorg \
     --channelID $CHANNEL_NAME \
     --name $CHAINCODE_NAME --version $CC_VERSION \
     --package-id $PACKAGE_ID_ORG1 \
     --sequence $CC_SEQ -o orderer:7050 --tls --cafile $ORDERER_TLS_CA

On org2 :

peer lifecycle chaincode approveformyorg \
     --channelID $CHANNEL_NAME \
     --name $CHAINCODE_NAME --version $CC_VERSION \
     --package-id $PACKAGE_ID_ORG2 \
     --sequence $CC_SEQ -o orderer:7050 --tls --cafile 

Otherwise it would give me the following info :

On org1:

bash-5.0# peer lifecycle chaincode queryapproved -C bankscochannel -n fabcar
Approved chaincode definition for chaincode 'fabcar' on channel 'bankscochannel':
sequence: 1, version: 1.0, init-required: false, package-id: fabcar-v1:002d3fc291572c3e8bc52fea3b228cbd1877ab87669978759fc75f51f893a0dd, endorsement plugin: escc, validation plugin: vscc

bash-5.0# peer lifecycle chaincode querycommitted -C bankscochannel
Committed chaincode definitions on channel 'bankscochannel':
Name: fabcar, Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc

bash-5.0# peer lifecycle chaincode queryinstalled
Installed chaincodes on peer:
Package ID: fabcar-v1:002d3fc291572c3e8bc52fea3b228cbd1877ab87669978759fc75f51f893a0dd, Label: fabcar-v1

0n org2:

bash-5.0# peer lifecycle chaincode queryapproved -C bankscochannel -n fabcar
Approved chaincode definition for chaincode 'fabcar' on channel 'bankscochannel':
sequence: 1, version: 1.0, init-required: false, package-id: fabcar-v1:002d3fc291572c3e8bc52fea3b228cbd1877ab87669978759fc75f51f893a0dd, endorsement plugin: escc, validation plugin: vscc

bash-5.0#  peer lifecycle chaincode querycommitted -C bankscochannel
Committed chaincode definitions on channel 'bankscochannel':
Name: fabcar, Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc

bash-5.0# peer lifecycle chaincode queryinstalled 
Installed chaincodes on peer:
Package ID: fabcar-v1:c4430b8d45ee5bca03233272da19aafab73d41c973861adfab8d349c70d950e3, Label: fabcar-v1

Note that in the console output the result of both peer lifecycle chaincode queryapproved return the same package_id which is not correct

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
1

You may not have set the correct --package-id when you approved your chaincode definition

I encountered the same problem as you,that is because I have set uncorrect --package-id 1ec5f659f7b95978829202e4201cd969ccb0952a9c87a1bb51c9588b518923a1,but correct --package-id value should be sacc_1.0:1ec5f659f7b95978829202e4201cd969ccb0952a9c87a1bb51c9588b518923a1

reference https://hyperledger-fabric.readthedocs.io/en/release-2.2/deploy_chaincode.html#invoke-failure

Li Xian
  • 421
  • 4
  • 4
0

You will have to install the chaincode first and then invoke it. You can follow the steps mentioned in this link in order to install, instantiate and then invoke the chaincode.

Abhilash
  • 803
  • 1
  • 9
  • 32
0

It seems like your chaincode is not installed on the peers of all the organizations.You installed it on a peer of an organization and trying to query from another peer where it does not exist. And also follow the chaincode lifecycle (6 steps) from the documentation.

https://hyperledger-fabric.readthedocs.io/en/release-2.0/commands/peerlifecycle.html

Shubham Jaiswal
  • 570
  • 5
  • 11
0

I had the same problem when I packaged the chaincode using Go. Then I restarted the test network and tried to package the chaincode using Java, problem solved.

Weshome
  • 11
  • 2
0

For anyone that may have came across this issue. First it depends on your topology, if you have multiple peers per org configured, continue reading...

When you package your chaincode, you need to make sure the same package is shared and installed on all of the org's peers. Anything off will result in a different package-id which for an org will not get recognized.

For example if you install and approve one peer 1 with package id x and install and approve on peer 2 with package id y, then execute a queryapproved cmd, you'll see that package id y is installed and approve. When you invoke the chaincode on peer 1, you'll get the error above posted.

It's okay to have a different package-id across multiple orgs but not okay within an org.

Huy Tran
  • 367
  • 4
  • 12