I am unable to instantiate chaincode in Hyperledge Fabric.
When executing:
peer chaincode instantiate -o orderer -n test_cc -C test-channel -v 0.1 -c '{"Args":["initLedger"]}'
I get the error:
peer0 | 2018-04-17 13:02:11.097 UTC [dockercontroller] Start -> ERRO 046 start-could not start container: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
When searching the internet, the error message is the same as on the original post at [OCI Runtimer Error when installing Hyperledger Chaincode via Java-SDK and [OCI runtime error when sending Hyperledger Fabric's chaincode instantiation request to peers, but the comments on these posts did not led me to the solution.
I am using the following software versions:
Hyperledger 1.1.0
Docker version 18.03.0-ce (on Linux), Hyperledger Docker images: x86_64-1.1.0
The following steps succeed:
Building the chaincode. The code compiles without errors. I did not include any dependencies except the two required "github.com/hyperledger/fabric/core/chaincode/shim" and
"github.com/hyperledger/fabric/protos/peer"
Packaging the chaincode.
Signing the chaincode.
Installing the chaincode (it ends up in the peer's /var/hyperledger/production/chaincodes/test_cc.0.1.
(Steps according to Hyperledger documentation: [http://hyperledger-fabric-docs.readthedocs.io/en/latest/chaincode4noah.html])
In the CLI Docker container, files are located in the directory /opt/gopath/src/chaincode/go/test_cc/, where 4 files are present: test_cc, test_cc.go, test_cc_pack.out, test_cc_signed_pack.out (the binary, source file, packaged file and signed package file).
The full output of the orderer and peer is:
orderer | 2018-04-17 13:29:43.617 UTC [orderer/common/server] Broadcast -> DEBU 167 Starting new Broadcast handler
orderer | 2018-04-17 13:29:43.617 UTC [orderer/common/broadcast] Handle -> DEBU 168 Starting new broadcast loop for 172.18.0.6:41228
couchdb | [notice] 2018-04-17T13:29:43.624931Z nonode#nohost <0.16042.3> b5d38cd27d couchdb:5984 172.18.0.5 undefined GET /test-channel_lscc/test_cc?attachments=true 404 ok 2
peer | 2018-04-17 13:29:44.416 UTC [dockercontroller] Start -> ERRO 04a start-could not start container: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer | 2018-04-17 13:29:44.647 UTC [chaincode] Launch -> ERRO 04b launchAndWaitForRegister failed: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer |
peer | error starting container
peer | 2018-04-17 13:29:44.647 UTC [endorser] simulateProposal -> ERRO 04c [test-channel][39e4414a] failed to invoke chaincode name:"lscc" , error: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer |
peer | error starting container
orderer | 2018-04-17 13:29:44.648 UTC [orderer/common/broadcast] Handle -> DEBU 169 Received EOF from 172.18.0.6:41228, hangup
orderer | 2018-04-17 13:29:44.648 UTC [orderer/common/server] func1 -> DEBU 16a Closing Broadcast stream
It looks like there is some path issue, but the process of the creation of the chaincode container and the variables which influence this process.
I'm messing around with this issue for few days(!) now, tried all path combinations like placing the file in /opt/gopath/bin, etcetera, but to no avail.
Someone who can shine a light on this issue? Or knows what the correct paths are and where they are, or where they should be defined?
Thanks
The issue was that in the Go source files I used 'package test_package', which, when building, does not create an executable file, but a linkable object file.
Having 'package main' in my Go files, then rebuilding and repackaging, made the 'peer chaincode install' and 'peer chaincode instantiate' commands working as expected.
Related
I get the following error when I try to install chaincode
VirtualBox:~/fabric-samples/test-network$ peer lifecycle chaincode install GameEX.tar.gz --peerAddresses peer0.org1.example.com:7051
2021-08-12 16:01:53.066 IST [main] InitCmd -> ERRO 001 Cannot run peer because error when setting up MSP of type bccsp from directory /home/raju/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp: KeyMaterial not found in SigningIdentityInfo
The code was written in java and compiled fine. Using test-network to deploy chaincode the network was running
What am I missing?
I follow by instruction from the fabric-sample/test-network, but trying to reproduce steps of control in docker container. All steps of chaincode installation went good except one of the final - peer chaincode invoke.
On this step I got an error: 2020-07-09 10:40:00.755 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 05a ESCC invoke result: response:<status:500 message:"make sure the chaincode fabcar has been successfully defined on channel appchannel and try again: chaincode definition for 'fabcar' exists, but chaincode is not installed" > Error: endorsement failure during invoke. response: status:500 message:"make sure the chaincode fabcar has been successfully defined on channel appchannel and try again: chaincode definition for 'fabcar' exists, but chaincode is not installed"
When I check chaincode with peer lifecycle chaincode queryinstalled I receive a normal response:
Installed chaincodes on peer: Package ID: fabcar_1:644530ed4e097a65073d6e0fc8a7aaa9282945e55aa1ec7d2014746fd598f631, Label: fabcar_1
But when I check chaincode with peer chaincode list --installed I receive empty set:
Get installed chaincodes on peer:
configtx.yaml from test-example is used.
Where is my mistake?
Here is my Dockerfile. The main idea is to make a self-sufficient docker environment of hyperledger with outscripting needs.
The command peer chaincode ... use the LSCC - Lifecycle System Chaincode, which is used for the 1.x Fabric network. The 2.x docs about this here
You can try using the old-style command to install chaincode peer chaincode install ..., then you can query the installed chaincode with peer chaincode list --installed. But from version 2.0, it's recommended using the new lifecycle chaincode.
I also found the in-practice chaincode comparison of version 1.4 and 2.0 here. Hope this can give you some ideas.
As mentioned by #HoaiNam that you have to use fabricv2.x api's since you are using test-network. Also you can try previous command by adding v1.4.x capabilities(not sure). for understanding latest CC lifecycle process, you can refer here. for commands, you can refer to test-network/scripts/deployCC.sh. I hope this helps.
In the new lifecycle we have to use :
peer lifecycle chaincode queryinstalled
In the old lifecycle we use
peer chaincode list --installed
I've come across an error starting the hyperledger-composer network that isn't answered in the composer-wiki.
✖ Starting business network definition. This may take a minute...
Error: Error trying to start business network. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: transaction returned with failure: can't find PEM header: undefined
Command failed
Checking pre-requisites,
Fabric 1.2
Composer 0.20.4
Node 8.12.0
Docker 18.01.1
"composer network install" was successful, with file appearing in the docker peer at /var/hyperleder/production/chaincodes
After running the "composer network start" command, a "docker ps" shows new docker instance with name:
dev-peer0.org1.example.com-<<business-network-name>>-0.0.7
But any attempt to ping this results in a failure like this:
Error: Error trying to ping. Error: make sure the chaincode <<business-network-name>> has been successfully instantiated and try again: getccdata composerchannel/<<business-network-name>> responded with error: could not find chaincode with name '<<business-network-name>>'
Checking the log of the dev-peer0, it ends with the following:
2018-11-05T05:03:18.227Z [4264161f] ERROR :Composer :Init() can't find PEM header: undefined
2018-11-05T05:03:18.227Z [4264161f] VERBOSE :Composer :#PERF Init() Total (ms) duration for txnID [4264161fc30a61c70884d4c7efb460fea6a755d07bc4852875c393346795227a]: 929.00
2018-11-05T05:03:18.228Z ERROR [lib/handler.js] [composerchannel-4264161f]Calling chaincode Init() returned error response [can't find PEM header: undefined]. Sending ERROR message back to peer
The corresponding error in the peer0 log is a big larger:
2018-11-05 05:03:18.229 UTC [endorser] SimulateProposal -> ERRO 439d [composerchannel][4264161f] failed to invoke chaincode name:"lscc" , error: transaction returned with failure: can't find PEM header: undefined
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Execute
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:202
github.com/hyperledger/fabric/core/endorser.(*SupportImpl).Execute
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/support.go:131
github.com/hyperledger/fabric/core/endorser.(*Endorser).callChaincode
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:173
github.com/hyperledger/fabric/core/endorser.(*Endorser).SimulateProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:287
github.com/hyperledger/fabric/core/endorser.(*Endorser).ProcessProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:501
github.com/hyperledger/fabric/core/handlers/auth/filter.(*expirationCheckFilter).ProcessProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/handlers/auth/filter/expiration.go:61
github.com/hyperledger/fabric/core/handlers/auth/filter.(*filter).ProcessProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/handlers/auth/filter/filter.go:31
github.com/hyperledger/fabric/protos/peer._Endorser_ProcessProposal_Handler
/opt/gopath/src/github.com/hyperledger/fabric/protos/peer/peer.pb.go:112
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).processUnaryRPC
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:923
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).handleStream
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:1148
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:637
runtime.goexit
/opt/go/src/runtime/asm_amd64.s:2361
2018-11-05 05:03:18.229 UTC [endorser] SimulateProposal -> DEBU 439e [composerchannel][4264161f] Exit
Since this last worked I have updated composer from 0.19 to 0.20.4, and taken Fabric from 1.1 to 1.2.
Googling suggests that this kind of error "can't find PEM header: undefined" is associated with a change in key signing. After tearing down Fabric I re-ran ./createPeerAdminCard.sh - is there another card or similar that needs to be re-created to accomodate the latest versions?
Thanks to #R Thatcher for putting me onto the right direction. This was all down to mismatching cards, and was resolved by clearing out everything and starting again.
Specifically, in /fabric-dev-servers:
./stopFabric.sh
./teardownFabric.sh
composer card list
composer card delete -c admin#<business-network-name>
composer card delete -c PeerAdmin#hlfv1
./startFabric.sh
./createPeerAdminCard.sh
Then changing into the composer/business-network-name directory:
composer network install --card PeerAdmin#hlfv1 --archiveFile business-network-name\#0.0.7.bna
composer network start -c PeerAdmin#hlfv1 -n business-network-name -V 0.0.7 -A admin -S adminpw --file networkadmin.card
composer card import --file networkadmin.card --card admin#business-network-name
composer network ping -c admin#business-network-name
So yes, it was about mismatching cards and not cleaning these up as part of a new deployment.
Although not part of the original problem, it's also worth noting that the -A and -S parameters of the composer network start command HAD to be set to admin and adminpw respectively. See composer issue #3781.
Answering the the last remark from #Capn Sparrow
"the -A and -S parameters of the composer network start command HAD to be set to admin and adminpw respectively."
This is the correct and expected behaviour :-)
with the composer network start command the -A and -S are specifying an existing user in the CA that we want a new set of Credentials (certificate and keys) for which is then bound to a Composer System participant.
When you use the 'standard development fabric' this has a CA configured with a user called 'admin' with a secret of 'adminpw'. If you had build your own Fabric from scratch you could choose the name and secret of your first default user. Alternatively you could work with the fabric-ca client software to create additional users in the CA.
I am trying to get started with Hyperledger Fabric. I managed to run the "build your first network"-tutorial from the samples, and I followed the "write your first application"-tutorial as well, which also worked.
As a next step, I wanted to create my own network more or less from scratch, by adjusting the .yaml files from the samples and running cryptogen and configtxgen manually. I managed to build a network with three organisations, two peers per org and a solo ordering service. I now want to install some basic chaincode on one of the peers, but I'm stuck, as I get a couple of weird errors:
2018-03-01 22:27:30.525 UTC [grpc] Printf -> DEBU 003 transport: http2Client.notifyError got notified that the client transport was broken read tcp 172.20.0.9:45178->172.20.0.3:7050: read: connection reset by peer.
Error: Error getting broadcast client: Error connecting to orderer.rle.de:7050 due to rpc error: code = Internal desc = transport: write tcp 172.20.0.9:45178->172.20.0.3:7050: write: broken pipe
2018-03-01 22:27:30.525 UTC [grpc] Printf -> DEBU 004 grpc: addrConn.resetTransport failed to create client transport: connection error: desc = "transport: Error while dialing dial tcp: lookup orderer.rle.de on 127.0.0.11:53: dial udp 127.0.0.11:53: operation was canceled"; Reconnecting to {orderer.rle.de:7050 <nil>}
2018-03-01 22:27:30.525 UTC [grpc] Printf -> DEBU 005 grpc: addrConn.transportMonitor exits due to: grpc: the connection is closing
After that, I get the usage information for peer chaincode instantiate
If you could provide any insight into what might be causing this error, I would be super grateful. I don't even know if it is caused by the network config or by the chaincode itself (I don't think so, since I tried two different chaincodes, one of which was "sacc" from the samples) but the installation of the chaincode seems to be working. My problem is that I have no idea what I'm doing, so after googling and fooling around with the arguments for peer chaincode instantiate, I'm all out of ideas.
My command (I run it from a .sh file) is:
peer chaincode instantiate -o orderer.rle.de:7050 -C driverlogschannel -n test -v 1.0 -c '{"Args":["John","0"]}' -P "OR ('rleMSP.member')"
The chaincode is taken from the sacc example installed via
peer chaincode install -n test -v 1.0 -p sacc
Thanks a lot! If you need more logs or other info, I can provide them.
Solved it. The problem had to do with the fact that I was not submitting a cafile. Basically, what I did is going back to this tutorial and trying it with their chaincode again:
peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
but I adjusted it to
peer chaincode install -n mycc -v 1.0 -p chaincode_example02
(I put the chaincode_example02.go file from fabric-samples/chaincode/ into my $GOPATH/src/chaincode_example02 folder and adjusted my docker-compose-cli.yaml by adding this line to cli -->volumes)
- $GOPATH/src/chaincode_example02:/opt/gopath/src/chaincode_example02
Then, the crucial point:
peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.member','Org2MSP.member')"
although I adjusted this line again so that it matched my folder structure (exchanging example.com for my domain and so on.)
That solved the issue.
I just a new beginner of Hyperledger Composer.So I try to deploy REST server using Docker by following this guide
Deploying the REST server for a business network
Then when i run docker, it show this error on docker logs
docker logs rest
0|composer | WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
0|composer | WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
0|composer | Discovering types from business network definition ...
0|composer | D0831 07:04:36.180952003 24 env_linux.c:66] Warning: insecure environment read function 'getenv' used
0|composer | D0831 07:04:37.574385287 24 env_linux.c:66] Warning: insecure environment read function 'getenv' used
0|composer | Connection fails: Error: Error trying to ping. Error: Composer runtime (0.11.3) is not compatible with client (0.11.2)
0|composer | It will be retried for the next request.
0|composer | Exception: Error: Error trying to ping. Error: Composer runtime (0.11.3) is not compatible with client (0.11.2)
0|composer | Error: Error trying to ping. Error: Composer runtime (0.11.3) is not compatible with client (0.11.2)
0|composer | at _checkRuntimeVersions.then.catch (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:696:34)
PM2 | App [composer-rest-server] with id [0] and pid [24], exited with code [1] via signal [SIGINT]
PM2 | Starting execution sequence in -fork mode- for app name:composer-rest-server id:0
PM2 | App name:composer-rest-server id:0 online
So i try to update the version by following on this guide on the same doc
Updating Hyperledger Composer
But after I stop/reboot fabric, redeploy the chaincode again and run the docker, the error still exist.
Can anyone please tell me what i've missing?
Note: I try this solution too but still have the same problem.
Ok i've solve the problem. I remove all docker image and start new fabric to download image again,and it works!!
docker rmi $(docker images -q)