Deploying chaincode from tutorial on hyperledger fabric throws error - hyperledger-fabric

I've been following the hyperledger fabric tutorials and the asset-transfer-basic chaincode is not being deployed properly. My fabric version is 2.2, and my golang version is 1.18.x .
I've run this command :
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
I'm being presented with this error :
Error: failed to read chaincode package at 'basic.tar.gz': open basic.tar.gz: no such
file or directory
+ PACKAGE_ID=
Error: failed to normalize chaincode path: 'go list' failed with: go: could not
create module cache: mkdir /home/hypernew/go/pkg/mod: permission denied: exit status 1
What can I do to solve this?

It would be better to go through the Getting Started and Prerequisites.
Have you pulled the code properly from github fabric-samples ? Most of the cases, this should solve the problem.
There is a possibility that the GOPATH env variable is not set properly. As the go module is enabled in the 2.2+ for vendoring, the GOPATH setup is critical.
Try the following command
go mod vendor
from the chaincode directory. You can even try to compile this package locally and see whether the golang/ gopath etc is correctly handled. Compile using the following
go build --tags nopkcs11
If this works locally, then the same should work from network.sh also.

Related

Instantiation of Chaincode using Fabric Node SDK gives API error (404): manifest for hyperledger/fabric-ccenv:latest not found

I am trying to instantiate a Golang chaincode on my Hyperledger Fabric network (setup on cloud) using Fabric Node SDK. However, I am facing the following error while performing the same:
Error: 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
The stack trace for the same is:
at self._endorserClient.processProposal (./node_modules/fabric-client/lib/Peer.js:140:36)
at Object.onReceiveStatus (./node_modules/grpc/src/client_interceptors.js:1207:9)
at InterceptingListener._callNext (./node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (./node_modules/grpc/src/client_interceptors.js:618:8)
at callback (./node_modules/grpc/src/client_interceptors.js:845:24)
I also tried to directly pull the image hyperledger/fabric-ccenv in my local environment but getting a similar error there as well:
Command:
docker pull hyperledger/fabric-ccenv
Error:
Using default tag: latest
Error response from daemon: manifest for hyperledger/fabric-ccenv:latest not found: manifest unknown: manifest unknown
Fabric Peer Version: 1.4.4
Fabric Node SDK Version: 1.4.4
As mentioned by alpha above, latest tag for hyperledger/fabric-ccenv does not exist anymore.
The value is defined as chaincode.builder in core.yaml file and can be overridden by the environment variable CORE_CHAINCODE_BUILDER.
So, the correct approach to solve the issue is passing the environment variable to peer with preferred ccenv version. For example:
CORE_CHAINCODE_BUILDER: hyperledger/fabric-ccenv:2.1
See this commit as an example of how to use it in a Helm chart.
latest tag isn't available anymore. you have to use specific tag. Below is the snippet of dave comment infabric-maintainers group.
The Hyperledger Fabric maintainers are pleased to announce the availability of Fabric v2.2.0!
v2.2 continues to build on the v2.0 foundation with additional improvements and fixes. For details, check out the release notes:
https://github.com/hyperledger/fabric/releases/tag/v2.2.0
Additionally we are happy to announce that v2.2 is the next long-term support (LTS) release for Hyperledger Fabric. v2.2.x will be the target release for most fix backports, while the most important fixes will continue to be backported to v1.4.x as well.
More details of the LTS strategy can be found in the RFC that was merged earlier this year:
https://github.com/hyperledger/fabric-rfcs/blob/master/text/0000-lts-release-strategy.md
Finally, it is worth noting that the 'latest' tag on dockerhub images has been retired. We felt that the tag was too confusing, given that there is a combination of regular releases and LTS releases available now - the definition of 'latest' may not be the same for everyone.
Give v2.2 a try and let us know what you think!
https://hyperledger-fabric.readthedocs.io/en/release-2.2/install.html```
link: https://chat.hyperledger.org/channel/fabric-maintainers?msg=dCMSGymRoWPiJ8fiv
I was trying to install/instantiate a year old chaincode and obviously I haven't updated any dependencies so I also ran into this issue.
This particular [hyperledger/fabric-ccenv:latest] docker pull is being done by one of dependencies and following is the way around that.
Do a docker pull of fabric-ccenv for whatever version you want.
docker pull hyperledger/fabric-ccenv:2.1
And then tag it as latest,
docker tag hyperledger/fabric-ccenv:2.1 hyperledger/fabric-ccenv:latest
Now when you try to install the chaincode, the docker pull for latest image wont happen as the image with the tag is already available on your machine.
The above two commands is something you can add in your start script.
Thanks to #alpha for mentioning that the latest tag has been taken down.

Problem on changing Hyperledger Composer version from 0.16.60 to 0.19.14

I am new in blockchain development. Actually i done a demo in composer vertion .16.6. Now i upgrade my composer vertion from 0.16.6 to 0.19.14. And i changed the code in createPeerAdmin.sh file for suitable to vertion 0.19.14. But always showing an error that
Connection profile has no x-type property defined. It is not valid for this version of composer
Please help me as possible.
Thanks
try to reset the environment variable for before starting or setup the development server using the following command by changing the fabric version u're going to use specific version from the development servers.
cd ~/fabric-dev-servers
export FABRIC_VERSION=hlfv11
./startFabric.sh
./createPeerAdminCard.sh
You can also find better information about the installation of the documentation in the link below:
https://hyperledger.github.io/composer/v0.19/installing/development-tools.html

Hyperledger Fabric 1.2.0 developer chaincode tutorial failed to go get and build

Attempting to follow the hyperledger fabric 1.2.0 developers chaincode tutorial.
I was unable to get the hyperledger fabric dependencies by executing
go get -u github.com/hyperledger/fabric/core/chaincode/shim. I tried deleting the hyperledger/fabric source folder from my GOPATH's src directory as suggested here, but the same error messages keep popping up:
github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive
../github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:364:5: hdr.Format undefined (type *tar.Header has no field or method Format)
../github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:364:15: undefined: tar.FormatPAX
../github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:1166:7: hdr.Format undefined (type *tar.Header has no field or method Format)
../github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:1166:17: undefined: tar.FormatPAX
Skipping the go get command and going straight to go build would output the same error as above.
I've also tried installing gnu-tar to no avail.
Reinstalling the latest stable version of Golang did the trick. At the time of this writing the stable version of go is 1.10.3.
The issue was caused by golang version 1.9.3 having an undefined struct for tar.FormatPAX which was needed for one of the hyperledger fabric go source files.

Hyperledger - Chaincode Fingerprint Mismatch

We have internally set up a Hyperledger network to run some tests. The version of Hyperledger Fabric being used is 1.1.
We have a network of 5 machines, each representing an organization, and all of them have - running over Docker - two peers, a CA, as well as a Command-line Interface. We also have an Orderer node that is running on a standalone machine.
We can install Golang chaincodes and make the organizations communicate just fine. The problem arises when we try to install business network logic via BNAs. We are using Hyperledger Composer 0.19.7. to do that and here is what happens:
I generate the BNA by using npm install.
I install it successfully on my local peers and start the network via the composer install and composer start commands.
I send the very same BNA file over to other members of the network, and they also successfully install it on their peers with the composer install command.
However, when they try to communicate with the network (composer network ping) with the appropriate admin card the following message is shown:
Error: Error trying to ping. Error: 2 UNKNOWN: error executing
chaincode: could not get ChaincodeDeploymentSpec for
todo-poc5-network:0.0.1: get ChaincodeDeploymentSpec for
todo-poc5-network/default from LSCC error: chaincode fingerprint
mismatch data mismatch Command failed
The really weird part is that if I - instead of the BNA - distribute the bin file that is installed on my peers (which is found in the /var/hyperledger/peer0/chaincodes folder) the ping command works perfectly and the organizations can communicate. But distributing bin files rather than the BNA itself does not seem like the ideal solution.
Has anyone experienced anything that is similar to that?
Thanks in advance.
EDIT:
Ok, sorry for the long absence.
It turns out we had different versions of CLI running, but even after normalizing them the error still appears. Any other suggestions?
You mentioned that following an install a path, ID, and version are provided. Is there anywhere I can see them?
Over the command line, by doing a composer install all I see is:
✔ Installing business network.
This may take a minute...
Successfully installed business network predic-poc, version 1.0.2 Command succeeded
A fingerprint mismatch data mismatch occurs because the package that is installed onto the peers differs in same way and as such fabric sees this difference as an issue and reports this error.
In order to understand how this can occur, details about how composer puts the bna onto a peer is needed.
An expanded bna file looks like a node module, it has a package.json file and some artifacts that make up the business network, so composer unpacks the bna file and uses the fabric-node-sdk to package it up, telling it is is a node module and the fabric-node-sdk will package it up appropriately and send it to the peer. fabric can then unpackage this package and perform an npm install --production to complete the setting up of this business network.
However there is a need to ensure that a reference to some composer npm modules are present in the package.json of the bna in order for the business network to be able to actually run, if these references do not exist then the composer network install command injects them into the package.json for you before the fabric-node-sdk creates the final package and sends it to the peer.
What the command effectively does is to add these lines to the dependencies section of the package.json file
“composer-runtime-hlfv1”: “0.19.9”,
“composer-common”: “0.19.9”
(note the version number presented here was the latest version at the time of writing, you may want to use a different/newer version of the composer runtime)
And the version number that is inserted is taken from the version of the composer-cli you have currently installed, so if you have differing versions of the composer-cli you can see that when you deploy the same bna onto different peers, the package that ends up on the peer will differ if different versions of composer-cli are installed.
(As a side point, the fabric-node-sdk doesn’t use the date/time of the files but sets them to a deterministic value so differing date/times are not an issue.)
There are 2 ways you can ensure this problem doesn’t occur.
Ensure you use the exact same levels of composer-cli for installing onto different organisations’ peers
You can explicitly set the version of the composer-runtime-hlfv1 and composer-common dependencies yourself inside the package.json of your business network implementation. If these are present then the command line will not overwrite or inject entries into the package.json prior to sending the package to the peers.
When installing chaincode you provide a path, ID, and version. All three attributes become part of a "fingerprint" that must match when invoking chaincode. The issue appears when you install the same chaincode but used a different path. This situation will happen organically when different people on the same channel want to run the chaincode independently. example:
person A installs on Peer1 with:
path - /uhoh/chaincode/marbles/dir,
id - marbles
version - v1
and person B installs on Peer2 with:
path - /marbles
id - marbles
version - v1
then lets pick Person A to instantiate the chaincode on a channel both peers have joined. the intent was that each person would have their own chaincode running, but b/c the path is different invokes will fail to run on person B's peer.
This issue has been closed at the version of fabric v1.1.3, v1.2.2, and v1.3+ , see issues FABN-855 for more detail.

Hyperledger Composer not being able to deploy Business Network

I updated my local environment to Composer v0.14.3 and I have been following the Developer Tutorial from Hyperledger Composer website. Then, when I try to deploy the Business Network to local Hyperledger Fabric I am getting the following error under the section "Deploy to the running Hyperledger Fabric". The error I get is shown below:
Deploying business network from archive: my-network.bna
Business network definition:
Identifier: my-network#0.0.1
Description: My Commodity Trading network
✖ Deploying business network definition. This may take a minute...
Error: Error trying deploy. Error: Error trying install composer runtime. Error: Endpoint read failed
Command failed
Another issue I saw is that I am able to start the local Hyperledger Fabric via "startFabric.sh" script, but after several minutes the container "hyperledger/fabric-peer:x86_64-1.0.4" stops suddenly, so I have to run the "stopFabric.sh" and "startFabric.sh" scripts again, see this picture.
As a reference, I have done what is suggested on this Post, but I am still getting the same error.
Suggest to update (ie re-install) your Composer dev environment to the current release v0.15.0 (as of Nov 10th) - there is a new tutorial (its changed from what you saw) and it will use Business network cards for the network deploy (createComposerProfile.sh is no longer needed) - makes life easier. To get the latest version, you will need to install the modules as per the docs -> https://hyperledger.github.io/composer/installing/development-tools.html - this will get the latest release. Make sure you do a full teardown using the scripts you downloaded in fabric-tools (as your CC containers will be 0.14.3 or earlier and thus out of date) and that you then subsequently, do an npm -g uninstall of the same module names eg composer-cli, composer-playground etc and such that they are all at the same level (0.15.0) upon subsequent npm -g install of same composer modules.

Resources