Problem in chaincode instantiation with distributed setup

1.4k Views Asked by At

I am working on Fabric version 1.2. Running a network with one orderer and one peer, both in same organisation, ORG1MSP. I followed this blog, but I am trying to run orderer and peer on different VMs.

Orderer IP: 192.168.1.5
Peer0 IP: 192.168.1.22

Orderer and CA containers were up on the first VM, and peer0, couchdb, cli on second VM. Peer0 was able to create channel, fetch channel configurations and join channel.

Now, I am trying to deploy the chaincode available in fabric/examples/chaincode/go/example02 path. I mounted the volume in all the containers as follows:

- /root/gopath/src/github.com/hyperledger/fabric/examples:/opt/gopath/src/github.com/hyperledger/fabric/examples

I run the commands from the CLI container. Install command: CORE_PEER_ADDRESS=peer0.org1.example.com:7051 peer chaincode install -n example02 -p github.com/hyperledger/fabric/examples/chaincode/go/example02 -v v0

It shows the following log:

2018-11-13 11:13:34.112 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-11-13 11:13:34.112 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2018-11-13 11:13:34.336 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >

Then, I try to instantiate the chaincode as follows:

root@fa36d48915d7:/opt/gopath/src/github.com/hyperledger/fabric# CORE_PEER_ADDRESS=peer0.org1.example.com:7051 peer chaincode instantiate -o 192.168.1.5:7050 -C mychannel -n example02 -v v0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.member','Org2MSP.member')"
2018-11-13 11:21:46.383 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-11-13 11:21:46.383 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err Proposal response was not successful, error code 500, msg failed to execute transaction 81b57fb4635092074d3585cec328e4c54f8f1d45028664795a56cfbc7f5a4c80: error starting container: error starting container: API error (400): OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"chaincode\": executable file not found in $PATH": unknown

Please provide the appropriate solution.

3

There are 3 best solutions below

2
On

I had a similar issue. I found that if the name of the package is not main, in that case, this error was generated.

Check the example02.go file, first line is the package name. Replace the package name to main, if it is something else, and try install again.

Install and initiate with -v v1

CORE_PEER_ADDRESS=peer0.org1.example.com:7051 peer chaincode install -n example02 -p github.com/hyperledger/fabric/examples/chaincode/go/example02 -v v1

CORE_PEER_ADDRESS=peer0.org1.example.com:7051 peer chaincode instantiate -o 192.168.1.5:7050 -C mychannel -n example02 -v v1 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.member','Org2MSP.member')"

0
On

Error

Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: API error (400): OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"chaincode\": executable file not found in $PATH": unknown

package name should be main

package main
0
On

Recently faced this issue and spent a lot of time googling. I fixed it by setting the CC_SRC_PATH path variable to the directory where chaincode is mounted in the docker container and then referencing it while installing and instantiating the chaincode. Links for reference:

  1. https://jira.hyperledger.org/browse/FAB-10019
  2. https://www.edureka.co/community/23994/how-to-define-the-path-to-hyperledger-fabric-chaincode

Seems like this can occur due to a variety of reasons as per discussions on multiple forums on how people got this fixed. Here is a list of links for a quick reference to all of them:

  1. OCI runtime error when sending Hyperledger Fabric's chaincode instantiation request to peers
  2. https://github.com/davidkhala/fabric-common#notes
  3. https://github.com/cloudhuang/fabric-vagrant-env#troubleshooting