6

I'm trying to instantiate the chaincode, but an error happens, and I can not find solutions to it.

ubuntu 18.04
hyperledger fabric 1.4.1
I've followed the document and it succeeded last week. The same code works well on another computer.
Before instantiate, everything went on well including making channels. I have not applied node in my project.

Codes:

root@c442cc2748e7:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -l golang -v 1.0 -c '{"Args":[]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
2019-05-23 06:31:31.382 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-05-23 06:31:31.382 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg chaincode registration failed: container exited with 0
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
jsdtLin
  • 69
  • 1
  • 3
  • Some other information: container logs:[mychannel][e10540fc] failed to invoke chaincode name:"lscc" , error: container exited with 0 github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1 – jsdtLin May 23 '19 at 09:52
  • Please explain the answer – sachin murali Nov 13 '19 at 09:59

5 Answers5

0

Oh, I have fixed it! It is caused by docker compose .yaml file. I changed the name of directory, without updating the "network" in this file. After keeping it the same as the name of directory, there's no error now.

jsdtLin
  • 69
  • 1
  • 3
  • Hi I have the same problem and getting the same error. I changed the name of the directory for my chaincode, but I do not understand how it is related to the network name. Can you explain a bit more? – ethertest Jul 07 '19 at 23:33
  • 3
    @jsdtLin which directory name should be changed ? please make it clear, I'm also getting the same error. – Adarsha Jha Oct 01 '19 at 11:23
  • i am also struck in this...please explain it clearly – sachin murali Nov 13 '19 at 09:55
0

I had faced the same problem to install the java chaincode to setup the first-network using ubuntu 18.04 and hyperledger fabric 1.4.1. But I have resolved it following the below process.

in build.gradle my dependency was

compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.x'

and I had changed to

compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.1'

R.A.Munna
  • 1,699
  • 1
  • 15
  • 29
0

I faced the same issue. The issue basically states that the peer process is unable to register/create a container from the chaincode image. You can see the image is getting created or not by a simple docker ps -a. Also, while instantiation the peer downloads the fabric-ccenv image which contains the required libraries used for building the chaincode. In my case, an older image for fabric-ccenv was getting downloaded. It was this discrepancy which was causing the chaincode container to exit with 0 status code. I updated the fabric-ccenv docker image with the same tag used for peer and that resolved the error. Also, this might occur in a case where the CORE_PEER_CHAINCODELISTENADDRESS is wrongly set. It should be set to 0.0.0.0:7052. See explanation here

msingh
  • 399
  • 2
  • 15
0

I have fixed this issue by simply changing name of chaincode.

root@c442cc2748e7:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -l golang -v 1.0 -c '{"Args":[]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"

Just change -n mycc to -n give any name you want

Keep it
  • 13
  • 3
  • This is just a workout that you did. You just installed the same chaincode with a different name and now it is treated as a new chaincode. – Aditya Joshi Aug 27 '21 at 10:41
0

Solution

Remove the dev-* containers and try again.

docker images
...
dev-peer0.org1.example.com-fabcar-1.0-93f09...
...

docker rmi $(docker images dev-* -q)

Explanation

The lscc creates a docker image for the chaincode. Once this image exists, it will reuse it in the future. If the image is bad, you have to delete it, before attempting the instantiation again. I believe this is why so many of the "rename" solutions work, it causes a new image to be created (with a different name), since the name and version of the docker image name.

Troubleshooting

In order to determine why the chaincode failed to start, you can connect to the cli container and attempt to manually run the chaincode. For example, a nodejs chaincode might look something like this:

docker exec -it cli /bin/bash
#$ cd chaincode
#$ npm start
# <some npm error here>

Another option is to turn up logging on the peer and try again. Peer logging can be turned up via the FABRIC_LOGGING_SPEC environment variable. I would set to debug or info and then try again. Logs can be checked via

docker logs peer0.org1.example.com

At the end of the day, the error means that lscc chaincode failed to launch your chaincode.

jrasm91
  • 394
  • 2
  • 10