I am facing an issue and because of this issue all the write operations are stopped. Neither write operation on couchdb are working nor in ledger.
It shows me an error that EventHub has been shutdown.
I have to restart all the peers to fix this.
Can any one explain why it is happening? How can I prevent this error?
Any help would be appreciated.
The reasons why it was happening in my case were that fabric-samples/bin folder was removed and it could not find cryptogen inside the bin. Also that invoke.js and all other references to localhost needed to be replaced by docker container's new given IP. The orphan containers needed to be reset and node.js needed to be updated too.
I run inside the fabric-samples this command
git checkout
It confirmed all the files I had updated by saying:
M fabcar/enrollAdmin.js
M fabcar/invoke.js
M fabcar/query.js
M fabcar/registerUser.js
Your branch is up-to-date with 'origin/release-1.1'.
Then copied the folder fabric-samples/bin from my old source. Then I entered into fabric-samples/first-network and generated the network artifacts again
./byfn.sh down
./byfn.sh -m generate
Then I entered fabcar and run
docker network prune
npm install
./startFabric.sh node
node enrollAdmin.js
node registerUser.js
Then after updating the invoke.js with new data and fcn function name createCar
node invoke.js
Output:
Store path:C:\Users\John\fabric-samples\fabcar\hfc-key-store
Successfully loaded user1 from persistence Assigning transaction_id:
7573040d7bf4c3b2f5599f50650620de2ff81afcd9c153e1cc6187704d91b2bf
Transaction proposal was good
Successfully sent Proposal and received ProposalResponse: Status - 200, message - "OK"
The transaction has been committed on peer 192.168.99.100:7053
Send transaction promise and event listener promise have completed
Successfully sent transaction to the orderer.
Successfully committed the change to the ledger by the peer
Then querying all cars using the original query.js
node query.js
Output:
Store path:C:\Users\John\fabric-samples\fabcar\hfc-key-store
Successfully loaded user1 from persistence Query has completed,
checking results Response is [{"Key":"CAR0","Record":
{"color":"blue","docType":"car","make":"Toyota","model":"Prius","owner":"Tomoko"}},
{"Key":"CAR1","Record":
{"color":"red","docType":"car","make":"Ford","model":"Mustang","owner":"Brad"}},
{"Key":"CAR10","Record":
{"color":"Red","docType":"car","make":"Chevy","model":"Volt","owner":"John"}},
{"Key":"CAR11","Record":
{"color":"White","docType":"car","make":"Chevy","model":"Volt","owner":"Ahsan"}},...]
Related
I am working with this blockchain application for medics traceability (https://github.com/rastringer/medication-blockchain) based on hyperledger fabric blockchain.
It's exactly the same app as this project (https://github.com/hyperledger/education/tree/master/LFS171x/fabric-material/tuna-app) except that this project is for tuna traceability.
I modify the chaincode file (the file is "drug-chaincode.go"), and now apparently I need to reconfigure all my network in "basic-network" folder so that the modification is add, but I don't how I can do this.
I tried to follow this link without results (How to upgrade a chaincode after modification?)
Anyhelp is welcome, thank you in advance ;)
if u r trying to build hyperledger project similar to drug-app. Then do following things:
Delete node_modules:
drug-blockchain/drug-app/node_modules
Then change every parameter which states the drug blockchain, basically u have to change parameters to Yours on following sources:
drug-chaincode.go
startFabric.sh
server.js
routes.js
registerUser.js
registerAdmin.js
package.json
controller.js
recordDrug.js
queryDrug.js
queryAllDrug.js
changeDrugHolder.js
app.ja
index.html
In the end re-run the network:
cd drug-blockchain/drug-app
$./startFabric.sh
$npm install -g
$node registerAdmin.js
$node registerUser.js
$node server.js
if u do change parameters properly, it should work fine, otherwise recheck, there shouldn't be any data of previous drug-blockchain!
I was following the documentation to run the GO chaincode in fabric network. Chaincode for Developers
For installing the chaincode and running, it instruct to open 3 terminals:
Terminal 1 - Start the network
Terminal 2 - Build & start the chaincode
Terminal 3 - Use the chaincode (install, instantiate, invoke etc in peer)
Terminal 2 :
The chaincode is started with peer and chaincode logs indicating successful registration with the peer.
What exactly terminal 2 is doing as chaincode will install and instantiated in terminal 3?
What is the meaning of start the chaincode and chaincode registration with peer?
Thanks!
In "dev mode" chaincode is built and started by us as a user, where normally it's the peer who starts and maintains the chaincode.
So in the second terminal, we are building the chaincode on our own by running :
go build
whereas, you are right if we run peer chaincode instantiate peer builds the chaincode on its own but not in this case as we build it.
Moreover, we set the properties in the second terminal for use during chaincode install and instantiate as the chaincode has not yet been associated with any channel by running,
CORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./sacc
But yeah they have mentioned
Even though you are in --peer-chaincodedev mode, you still have to install the chaincode so the life-cycle system chaincode can go through its checks normally. This requirement may be removed in future when in --peer-chaincodedev mode.
Lets hope its soon :)
Problem
I'm getting the following error on a fabric-peer: Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package chaincodes/simple: no buildable Go source files in /chaincode/input/src/chaincodes/simple.
Context
I'm trying to instantiate a chaincode package after having successfully installed it.
Both the install and instantiate proposals are created by the Fabric NodeJS SDK (fabric-client).
Steps leading up to the problem
Package a go file using the fabric-client (succeeds)
Create an install proposal and send it to the peer (succeeds
Create and instantiate proposal and send it to the peer (fails with above error-message)
Steps taken to solve the problem
I tried to assert how the chaincode container create process works by reading the code.
What I got from it was the following:
- The chaincode is build using the fabric-ccenv image
- It loads a .tar as an Inputstream (The package?)
I tried adding the files to the go-path but I still couldn't get it to work.
What I want to know
- Where does the chaincode building process expect these files to be?
- Why do I need to provide the files when I've previously sent a package of chaincode inside an InstallRequest?
Further information
I'm also getting an error about an MSP being unknown. Something along the lines of: Error: MSP Org1MSP is unkown. This happens during deserialization of the proposal.
Which is weird because I'm 100% that MSP exists. What I'm not certain about is whether I need to add anchor peers to the channel I'm installing and instantiating the chaincode on in order for the MSP to be found.
I thought that happens during channel creation.
Versions
This happens in the following versions:
- 1.0.0
- 1.0.6
Please do not suggest I try version 1.1 because I cannot upgrade easily.
Please advise.
Above was caused by an actual unknown MSP.
Double check the profile/profiles in configtx.yaml used for creating the channel and the genesis block for orderers. I had a mismatch between those.
I read a related issue [FAB-7952] in Fabric's issue manager and it made me think something else was going on, instead of an actual unknown MSP.
I am currently trying to run through the example first application for Hyperledger Fabric here -> http://hyperledger-fabric.readthedocs.io/en/release-1.1/write_first_app.html
I am unable to get past calling node invoke.js
Originally I was getting the same error as this question Error invoking chaincode using Node.js SDK [TypeError: Cannot read property 'getConnectivityState' of undefined]
But after reverting to grpc#1.9.1 I get the following result:
I am able to do everything up to the node query.js method and that returns successfully but can't quite get past this.
Node version: 8.11.1
Docker Version:
fabric client section of package-lock.json
FYI: I am trying to run on Windows 10 mostly using the docker toolbox bash, or a separate git bash CLI.
Last piece of info!
Even though the invoke js command fails with the above error, I can see that the PUT command to couch db does go through and car10 has been successfully added.
If I check the docker logs for peer0.org1.example.com I see the following:
So did it actually work?
I tried two different tutorials:
This one to deploy docker images locally:
https://github.com/hyperledger/fabric-samples
I tried the fabcar sample. Everything works fine. I'm able to enroll the admin, register a user and invoke transactions using this user identity. Nice.
The second one to deploy a fabric composer playground on bluemix:
https://ibm-blockchain.github.io/setup/
I was able to get into the composer playground and deploy business network examples. I'm also able to upload and deploy my own business networks I designed locally with composer-cli. I exposed the network over a Rest Server with admin rights in order to test the transactions. All works fine.
Now it comes to my problem. I want to combine both examples (just for fun, learning by doing:)). I want to deploy the fabcar samples network to the kubernetes environment on bluemix and interact with the network using the fabric node sdk like in example 1. So I made following changes in the scripts/yaml files of example 2:
adapt the chaincode installation procedure
in the create_all.sh. line 41 (for peer 1) and line 45 (for peer 2). I changed the values of the env variables CHAINCODE_NAME and CHAINCODE_VERSION
echo "=> CREATE_ALL: Running Install Chaincode on Org1 Peer1" CHAINCODE_NAME="fabcar" CHAINCODE_VERSION="1.0" MSP_CONFIGPATH="/shared/crypto-config/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp" PEER_MSPID="Org1MSP" PEER_ADDRESS="blockchain-org1peer1:30110" create/chaincode_install.sh
in the chaincode_install.yaml.base line 16, I changed the path of the chaincode. I forked the https://github.com/hyperledger/fabric and added the fabcar.go chaincode from example 1 to the new repository https://github.com/bigbelette/fabric
command: ["sh", "-c", "git clone https://github.com/bigbelette/fabric $GOPATH/src/github.com/bigbelette/fabric/ && peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p github.com/bigbelette/fabric/examples/chaincode/go/fabcar/"]
adapt the chaincode instantiation procedure:
in the create_all.sh. line 49. I changed the values of the env variables CHAINCODE_NAME and CHAINCODE_VERSION:
CHANNEL_NAME="channel1" CHAINCODE_NAME="fabcar" CHAINCODE_VERSION="1.0" MSP_CONFIGPATH="/shared/crypto-config/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp" PEER_MSPID="Org1MSP" PEER_ADDRESS="blockchain-org1peer1:30110" create/chaincode_instantiate.sh
In the chaincode_instantiate.yaml.base, I made the parameter list empty:
command: ["sh", "-c", "peer chaincode instantiate -o blockchain-orderer:31010 -C ${CHANNEL_NAME} -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -c '{\"Args\":[\"\"]}'"]
The deployment on the cluster works without an error. In the fabcar examples node js file enrollAdmin, regiserUser, query and invoke, I changed the channel name (from mychannel to channel1) and the IPs and ports to match to the online kubernetes services:
enrollAdmin.js and registerUser.js work fine so I can get the certificates and store it in the key store. But when I try to invoke a transaction, i get the following error:
It seems the CA which gave me the certificates is not recognized by the peers. But there is only one CA in my network!? Or is it a problem in the MSP definition (something I still dont understand well).
Thanks for your help.
I finally found the error.
My network has 1 CA (the root CA, named ca) and 2 "sub" CAs (ca1 und ca2). I was enrolling admin and user directly by the root CA because I didnt mention the name of the ca in the parameters of the Fabric_CA_Client class:
fabric_ca_client = new Fabric_CA_Client('http://184.173.5.108:30054', tlsOption, crypto_suite)
Without the name, the used CA will be the default CA (Root CA in my case). But the signature of user certificates by the root CA wont be recognized by the peers. Only the signatures from the last hierarchical CA levels will be accepted. So the solution was to refer the name of the CA:
fabric_ca_client = new Fabric_CA_Client('http://184.173.5.108:30054', tlsOptions , 'CA1', crypto_suite)
It works. Now the user can invoke transactions.