Unable to install sacc chaincode - hyperledger-fabric

I have a network with 2 orgs and 2 peers. I am trying to install the sample chaincode from the tutorial on one of the peers.
/opt/gopath/src/chaincode/sacc# CORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./sacc
2018-10-04 00:36:40.699 UTC [shim] SetupChaincodeLogging -> INFO 001 Chaincode log level not provided; defaulting to: INFO
2018-10-04 00:36:40.699 UTC [shim] SetupChaincodeLogging -> INFO 002 Chaincode (build level: ) starting up ...
2018-10-04 00:36:40.699 UTC [shim] userChaincodeStreamGetter -> ERRO 003 open : no such file or directory
error trying to read file content
github.com/hyperledger/fabric/core/chaincode/shim.userChaincodeStreamGetter
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/chaincode.go:89
github.com/hyperledger/fabric/core/chaincode/shim.Start
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/chaincode.go:150
main.main
/opt/gopath/src/chaincode/sacc/sacc.go:88
runtime.main
/opt/go/src/runtime/proc.go:198
runtime.goexit
/opt/go/src/runtime/asm_amd64.s:2361
Error starting SimpleAsset chaincode: error trying to read file content : open : no such file or directoryroot#31b1a3b7d3da:/opt/gopath/src/chaincode/sacc#
Any suggestions?
thanks

ERRO 003 open : no such file or directory error trying to read file content
your chaincode file dose not exist in the directory, please check that you have provided correct path of chaincode

Related

How fix "rpc error: code = Unknown desc = access denied: channel [mychannel] creator org [Org1MSP]" error in Hyperledger Fabric

Currently I am using Hyperledger Fabric 1.4, and I am trying to modify the basic-network. I am trying to add an org2 with one peer. Whenever I try to invoke the chaincode from the peer on the second organization (Org2) I get the following error:
Error: Error endorsing chaincode: rpc error: code = Unknown desc = access denied: channel [] creator org [Org2MSP]
My current network components are:
org1, with two peers
org2, with one peer
CA1
CA2
Ordere
CLI
and a channel called "mychannel"
I am able to create the channel "mychannel" and join the 3 peers from the two organizations. Also, I am able to install the chaincode on three of the peers from both organizations. And I am instantiating the chaincode on peer0 in Org1
Part of the Ordere logs:
2019-05-13 13:17:42.384 UTC [fsblkstorage] newBlockfileMgr -> INFO 003 Getting block information from block storage
2019-05-13 13:17:42.970 UTC [orderer.commmon.multichannel] Initialize -> INFO 004 Starting system channel 'testchainid' with genesis block hash f1bcfe55588bd24faaa699bc740045455283b63950436a36d5cf473f4b3d8f81 and orderer type solo
2019-05-13 13:17:42.970 UTC [orderer.common.server] Start -> INFO 005 Starting orderer:
Version: 1.4.1
Commit SHA: 87074a7
Go version: go1.11.5
OS/Arch: linux/amd64
2019-05-13 13:17:42.970 UTC [orderer.common.server] Start -> INFO 006 Beginning to serve requests
2019-05-13 13:21:30.921 UTC [comm.grpc.server] 1 -> INFO 007 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.20.0.6:36544 grpc.code=OK grpc.call_duration=27.428231ms
2019-05-13 13:21:30.927 UTC [fsblkstorage] newBlockfileMgr -> INFO 008 Getting block information from block storage
2019-05-13 13:21:31.038 UTC [orderer.commmon.multichannel] newChain -> INFO 009 Created and starting new chain mychannel
2019-05-13 13:21:31.044 UTC [comm.grpc.server] 1 -> INFO 00a streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=172.20.0.6:36542 grpc.code=OK grpc.call_duration=152.538972ms
2019-05-13 13:22:11.867 UTC [common.deliver] Handle -> WARN 00b Error reading from 172.20.0.6:36578: rpc error: code = Canceled desc = context canceled
2019-05-13 13:22:11.867 UTC [comm.grpc.server] 1 -> INFO 00c streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=172.20.0.6:36578 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=5.757971ms
2019-05-13 13:22:22.295 UTC [orderer.common.broadcast] Handle -> WARN 00d Error reading from 172.20.0.8:34272: rpc error: code = Canceled desc = context canceled
2019-05-13 13:22:22.295 UTC [comm.grpc.server] 1 -> INFO 00e streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.20.0.8:34272 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=7.238573847s
2019-05-13 13:23:46.748 UTC [orderer.common.broadcast] Handle -> WARN 00f Error reading from 172.20.0.8:34362: rpc error: code = Canceled desc = context canceled
2019-05-13 13:23:46.748 UTC [comm.grpc.server] 1 -> INFO 010 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.20.0.8:34362 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=49.20235ms
In summery, I can not invoke the chaincode from the second organization (Org2) because of channel access error.
Note:
I am generating the CA and I have checked the files and it seems to be correct
If anyone can help I would appreciate it.
Thanks in advance
This can be caused by wrong MSPID name for example "orgMSP" is wrong as it starts with lowercase "o"
to solve the problem use correct MSPID
export CORE_PEER_LOCALMSPID="Org1MSP"
It would be easy to answer if you have shared the peer logs.
The error could be because of the Certificates to sign the transaction.Double check your certificate received from CA and also checked the certificates and path used inside the docker container of peer1.

Cannot instantiate chaincode on hyperledger fabric network

I tried instantiating well tested chaincode onto my fabric network but got issue summarized as "cannot register chaincode".
There is no trace of chaincode container. I have tested my chaincodes and they pass all the base tests so there is no issue with the code. No matter on whichever orgs peer I run this, instantiation keeps failing.
Can someone help?
Hyperledger fabric version controlling platform mentions a same bug filed but I don't see what solution they came up with (https://jira.hyperledger.org/browse/FAB-14638). They seem to say something about the node version mismatch.
cli logs :
peer chaincode instantiate -o orderer.flightcommand.com:7050 -C flightcommandchannel -l node -n TripCC -v v0 -c '{"Args":["init"]}' -P 'AND ("CapitalcityMSP.member")' 2019-05-08 05:40:55.146 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2019-05-08 05:40:55.150 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**
peer logs :
[flightcommandchannel][97cbe635] Exit chaincode: name:"lscc" (98834ms)
2019-05-08 05:42:33.897 UTC [endorser] SimulateProposal -> ERRO 18f [flightcommandchannel][97cbe635] failed to invoke chaincode name:"lscc" , error: container exited with 0
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1 /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:63 runtime.goexit /opt/go/src/runtime/asm_amd64.s:1333 chaincode registration failed
2019-05-08 05:42:33.898 UTC [comm.grpc.server] 1 -> INFO 190 unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=192.168.96.12:38100 grpc.code=OK grpc.call_duration=1m38.836283s
I have finally found the issue. I missed out a ENV Variable to specify in the peer docker-compose.yaml.
"- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=network_1.0"
Where network_1.0 is the name of the docker network. Although the error messages was not so descriptive, I took some pain and rebuilt my prevoius project where chaincode deployment did work and compared it with my current project. Found only this piece missing and after adding it, to my surprise, everything worked.
Port 7052 is unlikely to be the problem here. This is the explanation (from core.yaml) about port 7052.
# The endpoint this peer uses to listen for inbound chaincode connections.
# If this is commented-out, the listen address is selected to be
# the peer's address (see below) with port 7052
# chaincodeListenAddress: 0.0.0.0:7052
In your debug output I see "chaincodeBuildlevel":"1.4.1-rc1"
I think you are using Fabric Images for 1.4.1-rc1.
I would suggest removing the Docker Images on your system and replacing with 1.4.1 and then using fabric-shim 1.4.1 too for consistency. This might clear the problem, but will certainly be a better place to continue investigations.
Updated following comments
With Docker Compose, if your group of containers are started on the same Network Bridge (on the same host machine/VM) they can resolve each others' addresses and connect on any port.
The mapping of Ports in the docker-compose.yaml file maps ports from the host computer into the container (not between containers).
Port 7053 used to be used for Events in older versions of Fabric, but it is not used in 1.4.1
The error you have now shown in the comment is a Name Resolution error so not to do with the ports. Perhaps your containers are not on the same Docker Bridge?
I modified the logging level of the peer and got to see something bizzare. Following are the chaincode logs in debug mode.
2019-05-08 11:21:52.980 UTC [endorser] callChaincode -> INFO 04f [flightcommandchannel][d01daf8c] Entry chaincode: name:"lscc"
2019-05-08 11:21:54.424 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 050
2019-05-08 11:21:54.426 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 051 > trip#1.0.0 start /usr/local/src
2019-05-08 11:21:54.427 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 052 > **NODE_ENV=development node account.js "--peer.address" "peer0.onesky.flightcommand.com:7052"**
2019-05-08 11:21:54.428 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 053
2019-05-08 11:21:55.124 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 054 2019-05-08T11:21:55.118Z debug [lib/chaincode.js] debug: Starting chaincode using options {"_":[],"peer.address":"peer0.onesky.flightcommand.com:7052","chaincodeBuildlevel":"1.4.1-rc1","chaincodeLoggingLevel":"debug","chaincodeLoggingFormat":"%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}","chaincodeIdName":"AccountChaincode:v0","chaincodeLoggingShim":"debug","peerTlsEnabled":"false","grpc.max_send_message_length":-1,"grpc.max_receive_message_length":-1,"grpc.keepalive_time_ms":110000,"grpc.http2.min_time_between_pings_ms":110000,"grpc.keepalive_timeout_ms":20000,"grpc.http2.max_pings_without_data":0,"grpc.keepalive_permit_without_calls":1,"module-path":"/usr/local/src","modulePath":"/usr/local/src","chaincode-id-name":"AccountChaincode:v0","timestamp":"2019-05-08T11:21:55.118Z"}
2019-05-08 11:21:55.128 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 055 2019-05-08T11:21:55.127Z debug [lib/chaincode.js] debug: Peer URL {"0":"g","1":"r","2":"p","3":"c","4":":","5":"/","6":"/","7":"p","8":"e","9":"e","10":"r","11":"0","12":".","13":"o","14":"n","15":"e","16":"s","17":"k","18":"y","19":".","20":"f","21":"l","22":"i","23":"g","24":"h","25":"t","26":"c","27":"o","28":"m","29":"m","30":"a","31":"n","32":"d","33":".","34":"c","35":"o","36":"m","37":":","38":"7","39":"0","40":"5","41":"2","timestamp":"2019-05-08T11:21:55.127Z"}
2019-05-08 11:21:55.135 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 056 2019-05-08T11:21:55.135Z info [lib/chaincode.js] info: Registering with peer peer0.onesky.flightcommand.com:7052 as chaincode "AccountChaincode:v0" {"timestamp":"2019-05-08T11:21:55.135Z"}
2019-05-08 11:21:55.147 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 057 2019-05-08T11:21:55.146Z debug [lib/handler.js] debug: Sending chat message: {"type":1,"payload":{"type":"Buffer","data":[18,19,65,99,99,111,117,110,116,67,104,97,105,110,99,111,100,101,58,118,48]}} {"timestamp":"2019-05-08T11:21:55.146Z"}
2019-05-08 11:21:55.440 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 058 2019-05-08T11:21:55.437Z error [lib/handler.js] error: Chat stream with peer - on error: "Error: 14 UNAVAILABLE: Name resolution failure\n at Object.exports.createStatusError (/usr/local/src/node_modules/grpc/src/common.js:91:15)\n at ClientDuplexStream._emitStatusIfDone (/usr/local/src/node_modules/grpc/src/client.js:233:26)\n at ClientDuplexStream._receiveStatus (/usr/local/src/node_modules/grpc/src/client.js:211:8)\n at Object.onReceiveStatus (/usr/local/src/node_modules/grpc/src/client_interceptors.js:1306:15)\n at InterceptingListener._callNext (/usr/local/src/node_modules/grpc/src/client_interceptors.js:568:42)\n at InterceptingListener.onReceiveStatus (/usr/local/src/node_modules/grpc/src/client_interceptors.js:618:8)\n at /usr/local/src/node_modules/grpc/src/client_interceptors.js:1123:18" {"timestamp":"2019-05-08T11:21:55.437Z"}
2019-05-08 11:21:55.617 UTC [dockercontroller] func2 -> INFO 059 Container dev-peer0.onesky.flightcommand.com-AccountChaincode-v0 has closed its IO channel
2019-05-08 11:21:56.091 UTC [endorser] callChaincode -> INFO 05a [flightcommandchannel][d01daf8c] Exit chaincode: name:"lscc" (3111ms)
2019-05-08 11:21:56.091 UTC [endorser] SimulateProposal -> ERRO 05b [flightcommandchannel][d01daf8c] failed to invoke chaincode name:"lscc" , error: container exited with 0
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:63
runtime.goexit
/opt/go/src/runtime/asm_amd64.s:1333
chaincode registration failed
2019-05-08 11:21:56.091 UTC [comm.grpc.server] 1 -> INFO 05c unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=172.25.0.4:59932 grpc.code=OK grpc.call_duration=3.1157286s
So here lies the problem. My peer listens on port 7051, not 7052. Ideally the command should look like "NODE_ENV=development node account.js "--peer.address" "peer0.onesky.flightcommand.com:7051"". I have no idea from where it is getting 7052.
P.S.
I added following to get a better overview of the issue in the chaincode instantiation.
FABRIC_LOGGING_SPEC=info
CORE_CHAINCODE_LOGGING_SHIM=debug
CORE_CHAINCODE_LOGGING_LEVEL=debug
core.yaml says
# The endpoint this peer uses to listen for inbound chaincode connections.
# If this is commented-out, the listen address is selected to be
# the peer's address (see below) with port 7052
# chaincodeListenAddress: 0.0.0.0:7052
# The endpoint the chaincode for this peer uses to connect to the peer.
# If this is not specified, the chaincodeListenAddress address is selected.
# And if chaincodeListenAddress is not specified, address is selected from
# peer listenAddress.
# chaincodeAddress: 0.0.0.0:7052
So I concluded since both are commented, 7051 is used as the address to listen to chaincode.
I faced exactly the same problem whenever I tried to instantiate the chaincode, I got this error
peer logs:
2019-05-09 04:05:38.285 EDT [endorser] SimulateProposal -> ERRO 15c [mychannel][03349c15] failed to invoke chaincode name:"lscc" , error: container exited with 1
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1
/home/alex/go/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:63
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1337
chaincode registration failed
I was able to fix it by changing build.gradle file, make sure in your build.gradle you have set Main-Class in manifest attributes to your main java file.
shadowJar {
baseName = 'chaincode'
version = null
classifier = null
manifest {
attributes 'Main-Class': 'org.hyperledger.fabric.chaincode.XXX'
}
}
Where XXX is the XXX.java file where your main() function is defined
Not sure how can this be done in node. But I hope this will give you the idea.
i faced the same issue not find any solution yet.
2021-03-25 04:53:55.840 UTC [endorser] SimulateProposal -> ERRO 046 failed to invoke chaincode bankcc, error: container exited with 0
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1
/go/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:118
and this my chaincode container logs
Error starting Marbles02 chaincode: ccid must be specified
but i specified the ccid here
server := &shim.ChaincodeServer{
//CCID: ccid,
CCID: os.Getenv("CHAINCODE_CCID"),
Address: os.Getenv("CHAINCODE_ADDRESS"),
CC: chaincode,
TLSProps: shim.TLSProperties{
Disabled: true,
},
I had the same problem,and I have sloved it by change peer env,and I think this problem was caused by CORE_PEER_ADDRESSAUTODETECT,actual,I dont know why .
I set CORE_PEER_ADDRESSAUTODETECT=true ,commented CORE_PEER_CHAINCODEADDRESS and CORE_PEER_CHAINCODELISTENADDRESS,It is work.
my peer env like this :
CORE_PEER_ADDRESSAUTODETECT=true
#CORE_PEER_CHAINCODEADDRESS=peer0.org1.example.com:30012
#CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:30012

Unable to install Hyperledger Fabric Marbles chaincode from a repository to a peer

I'm using this Hyperledger Fabric tutorial, I am block on the step 1 of part Install chaincode on all peers
When I run the command peer chaincode install -n marblesp -v 1.0 -p github.com/chaincode/marbles02_private/go/I have the following result containing an error :
2018-12-10 13:19:37.515 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-12-10 13:19:37.515 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: Error getting chaincode code chaincode: path to chaincode does not exist: /opt/gopath/src/github.com/fabric-samples/chaincode/marbles02_private
Could you help me please? thanks
Do you have the chaincodes in this path? Be sure you have the chaincode in this path.
Do you have Go installed? If yes, do you export the Go path?
Try with this:
export PATH=$PATH:/usr/local/go/bin

Error: Error getting chaincode code chaincode: <go, [env]>: failed with error: "exec: not started"

I have created hyperledger in azure blockchain and created fabric-ca, orderer and 2 peer nodes. I am able to create channel and 2 peers joined in the channel. I am not able to install chaincode. The commands are executed form Git bash. Getting below error while running the command from peer node. Please help...
root#d62e3aedc701:/# peer chaincode install -n balcc -v 1.0 -p Chaincode/fabric-samples/balance-transfer/artifacts/src/github.com/example_cc/go/
2018-05-25 05:32:42.702 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-05-25 05:32:42.702 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: Error getting chaincode code chaincode: : failed with error: "exec: not started"
In my case, I just reinstall go and this problem fix.

Fail to instantiate the chaincode in first network of fabric-samples

The official hyperledger fabric v1.0.0 gives a simple demo by using docker.
What i am doing is to avoid docker and directly run them on the machine. Thanks to the answer from my previous question, I have successfully launched 1 solo orderer, two peers (each from one org), created and joined the channels from peers, installed the chaincode on two peers.
The client side's command to install chaincode is
peer chaincode install -n myC1 -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
Both peers return the following message and I think it should be correct.
2017-09-11 16:34:26.361 SGT [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2017-09-11 16:34:26.361 SGT [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2017-09-11 16:34:26.556 SGT [main] main -> INFO 003 Exiting.....
However, when i try to instantiate the chaincode as follows
peer chaincode instantiate -o orderer.example.com:7040 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n myC1 -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.member','Org2MSP.member')
Client console returns the error message
2017-09-11 17:00:18.181 SGT [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2017-09-11 17:00:18.181 SGT [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: Error endorsing chaincode: rpc error: code = Unknown desc = Failed to init chaincode(handler not found for chaincode myC1:1.0)
The console of Peer0.org2 gives NO error message. But Peer0.org1's console gives the following:
2017-09-11 17:00:18.183 SGT [chaincode] Launch -> ERRO 032 sending init failed(handler not found for chaincode myC1:1.0)
2017-09-11 17:00:18.184 SGT [endorser] simulateProposal -> ERRO 033 failed to invoke chaincode name:"lscc" on transaction a665c5305c5e3f158d272e4a39b04611e5335406e2a7c7057f11d32d8e07670e, error: Failed to init chaincode(handler not found for chaincode myC1:1.0)
Can any one help me to solve this problem and give me a simple explanation??

Resources