Hyperledger Fabric can't find go files when building chaincode - hyperledger-fabric

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.

Related

How to make core.yaml effect in a container in Hyperledger Fabric

A peer has been installed in a container.
I wanted to instantiate a chaincode in the container, but it failed because the version of a docker image doesn't exist.
so, I want to change "fabric-ccenv:latest" to "fabric-ccenv:2.1".
I have tried to modify the core.yaml, but it has no effect.
I also tried to directly export the varible, it also has no effect.
my question is how to make the configure effective. maybe my solution is false, but i reffer this link:Instantiation of Chaincode using Fabric Node SDK gives API error (404): manifest for hyperledger/fabric-ccenv:latest not found
I really appreciate your warm-hearted help.
In docker-compose.yaml
in "volumes" section of your peer: create bind to location of your edited core.yaml
e.g.: - ./channel/config-peers/org1-peer0/:/etc/hyperledger/peer
in the "environment" section of your peer: add FABRIC_CFG_PATH= path to location of edited core.yaml
e.g.: FABRIC_CFG_PATH=/etc/hyperledger/peer

Getting error as ccenv:latest removal from docker hub caused problem for chaincode instantiation

I am trying to init the chaincode on hyperledger fabric 1.4.5 setup with k8s, however getting error as
"Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: Failed to generate platform-specific docker build: Failed to pull hyperledger/fabric-ccenv:latest: API error (404): manifest for hyperledger/fabric-ccenv:latest not found: manifest unknown: manifest unknown
"
Please anybody help me on this issue
latest tag has been deprecated. You can add
CORE_CHAINCODE_BUILDER: hyperledger/fabric-ccenv:your_version
under peer's environment in compose file.
This issue is resolved in Fabric v1.4.8 as it will now look for fabric-ccenv:1.4 by default, instead of fabric-ccenv:latest.
See the v1.4.8 release notes for more details.
The tag was removed. The workaround is to pull the matching version and tag it locally as latest.
docker pull hyperledger/fabric-ccenv:1.4.0
docker tag hyperledger/fabric-ccenv:1.4.0 hyperledger/fabric-ccenv:latest

debug node js chaincode ...?

This link gives tutorial on debugging javascript chaincode in hyperledger fabric. I was able to debug my chaincode following it but recently I updated to fabric 1.2 and the peer channel list command
CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=/home/bct/fabric-samples/basic-network/crypto-config/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp peer channel list
fails with:
Fatal error when initializing core config : error when reading core
config file: Unsupported Config Type ""
I tried to go back to v1.1 but the problem persists. Can someone give me the complete list of configuration steps that may have been missed in tutorial video (which I was following) that make the debugging chaincode work.
Thanks in advance.
Finally, figured out that fabric sdk (https://github.com/hyperledger/fabric-sdk-node) has to be downloaded and configured before following the video tutorial in the question.

How to enable private data in fabric v1.3.0

I am using fabric 1.3.0 in docker environment. I am getting error while trying to instantiate the chaincode with --collections-config. The setup is working fine if I remove the --collections-config
While executing :
peer chaincode instantiate -C org12 -n tranargy -v 1.0 -c '{"Args":[]}' -P "OR('Org1MSP.member','Org2MSP.member')" --collections-config /opt/gopath/src/tranargy/collections/collections_config.json
Getting following error :
Error: could not assemble transaction, err Proposal response was not
successful, error code 500, msg as V1_2 or later capability is not
enabled, private channel collections and data are not available
Can any one help in how to enable private data in fabric v1.3.0.
You must enable the V1_3 capability when creating the channel configuration transaction. See the required configuration in the sample. This is required so that all peers on a channel behave consistently, even if a rolling upgrade is in progress for the peers in the channel.
Problem is you are not using fabric 1.3.0 docker image
Even though it is present in your local, when you do compose up at that time it will download a new image of different version
Make sure
hyperledger/fabric-peer 1.2.0 82c262e65984 3 months ago 159MB
compose file service image: hyperledger/fabric-ca-peer:1.2.0
Both versions are same here i used 1.2.0
In your case 1.3.0
Make Sure:
Application: &ApplicationCapabilities
V1_3: true
See configtx.yaml

Hyperledger Fabric EventHub has been shut down [Write operations stopped]

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"}},...]

Resources