I am working on the hyperledger fabric v2.0 and after I have set up the network, created the channels I am not able to set the chaincode.
The Linux command: ./network.sh deployCC was not working.
So it says i should use the ollowing valid call example:
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
If I use this command, I recieve the following error:
Error: failed to normalize chaincode path: 'go list' failed with: go: inconsistent vendoring in /home/akosua/fabric-samples/asset-transfer-basic/chaincode-go:
github.com/golang/protobuf#v1.3.2: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
github.com/hyperledger/fabric-chaincode-go#v0.0.0-20200424173110-d7076418f212: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
github.com/hyperledger/fabric-contract-api-go#v1.1.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
github.com/hyperledger/fabric-protos-go#v0.0.0-20200424173316-dd554ba3746e: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
github.com/stretchr/testify#v1.5.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory: exit status 1
Chaincode packaging has failed
Deploying chaincode failed
I updated the current golang (v1.15)
Thank you for helping me!
After I reproduced your situation, I solved it through the method below.
To install the smart contract dependencies, run the following command
fabric-docs/chaincode
cd $GOPATH/src/github.com/hyperledger/fabric-samples
cd asset-transfer-basic/chaincode-go && \
GO111MODULE=on go mod vendor
run deployCC command in test-network
cd test-network && \
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
[EDIT]
After checking your answer, I reproduced your situation again. I wrote the order as it was.
first assumtion
1-1. I thought that apt update had no effect at all, and it was solved by deleting the previously incorrectly created/installed file from ./network.sh down.
1-2. Therefore, after installing the wrong vendor, I artificially executed and executed the command, and produced the same error.
1-3. However, in the ./network.sh down command, the vendor was not cleared, and in the up command, the method suggested in the above answer was executed in the script.
1-4. The error was not resolved, and I had to find another problem.
The other assumption
While analyzing the ./network.sh down script, it was confirmed that the docker volume was cleared.
It was assumed that the problem occurred because a package containing the wrong vendor remained on the docker volume.
2-1. As in the initial assumption, the deployCC command was executed based on the wrong vendor.
2-2. After the same error occurred, the network was shut down without clearing the volume of the docker network.
2-3. After replacing the chaincode with the correct vendor, reloading the network, and executing the deployCC command.
2-4. The same error occurred, and the remaining volume was confirmed to have an effect.
2-5. The entire network was evaporated through the -v option. In addition, all unnecessary volumes were evaporated through the docker volume prune.
2-6. After that, the network was reloaded and the deployCC command was executed, and it was confirmed that it was working normally.
In other words, the file related to the previous wrong chaincode remained in the dokcer volume, and it seems to have been resolved as it was deleted by a script that evaporates the volume in ./network.sh down together.
docker rm -f $(docker ps -aq) # This is a dangerous command because all containers are erased.
docker volume prune
I found my mistake/solution now.
First I checked for updates again: sudo apt update
Then I put the network down and up:
./network.sh down and than open it again by ./network.sh up
Afterwards I could continue without errors
Related
I was following the tutorial of hyperledger fabric "Using the Fabric Test Network", ang upon deploying the chaincode to the channel I encountered errors that I don't know what's the problem with it. I tried everything I have searched so far but no luck on fixing it. I tried uninstalling everything, and starting from the beginning of the installation but again no luck. I am new to this blockchain platform and is an aspiring developer for it. Anyone Please help.
Here is the result upon running the chaincode deployment :
Please do note that I tried installing golang (go1.13.x versions, go1.18.x and go1.19.x)but none solved the problem, anybody please help.
The screenshot shows that you don't have golang on the path. You need to ensure your $PATH variable includes the directory where the go binary is installed. However a further issue is you must ensure that the correct version of Go is installed that matches the version of Hyperledger Fabric you are using. Refer to the release notes of Hyperledger Fabric found here https://github.com/hyperledger/fabric/releases for your version to determine the appropriate version of golang to use.
A simpler option would be to install the javascript chaincode rather than the Go chaincode as this doesn't require any language support to be installed
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript -ccl javascript
I see this error in your screenshot:
go: command not found
Check you can run go from your shell:
go version
You likely need to add the go executable to your shell's PATH, as described in the Go installation instructions.
I have done basic setup in Hyperledger Fabric 1.4.7 and made all peer's to join the channel. After exploring chaincode in golang, I started trying chaincode install command and I was facing issue's in this step.
error
Error: error getting chaincode code mycc: path to chaincode does not exist: /home/user899/go/src/chaincode
When I just ran go run chaincode.go
error
chaincode.go:7:2: cannot find package "github.com/hyperledger/fabric-chaincode-go/shim" in any of:
/usr/lib/go-1.14/src/github.com/hyperledger/fabric-chaincode-go/shim (from $GOROOT)
/home/user899/go/src/github.com/hyperledger/fabric-chaincode-go/shim (from $GOPATH)
chaincode.go:8:2: cannot find package "github.com/hyperledger/fabric-protos-go/peer" in any of:
/usr/lib/go-1.14/src/github.com/hyperledger/fabric-protos-go/peer (from $GOROOT)
/home/user899/go/src/github.com/hyperledger/fabric-protos-go/peer (from $GOPATH)
Environments
echo $GOPATH
/home/user899/go
Chaincode location
/home/user899/SoloNetwork/chaincode
Can anyone help.
Thanks
I'm answering my own question. Here is the solution, I was not aware of the directory structure that need's to be followed in Go.
So first, I checked my GOPATH(usually the workspace where we can write all our go files) using go env in the terminal it was located under home/dev/go
And coming about the directory structure it should be followed as following :-
$GOPATH + /src/github.com/chaincode, So the final structure will be home/dev/go/src/github.com/chaincode inside chaincode. I can place all Go files.
So after getting chaincode file from here, I have placed in the above location and executed the following commands
go mod init
go mod tidy
Then, I was able to execute peer chaincode install commad
peer chaincode install -n mycc -p "github.com/chaincode" -v 1.0
Here in the command -p "github.com/chaincode" is the folder name that I have created.
So finally chaincode path is created by these : $GOPATH + src + -p flag
If anyone is facing, go binary related issue's set your GOROOT path to the bin location where go is intalled.
I trying to follow tutorials and develope on Ubuntu. Then get an error when comes to "Bring up the test network" part. I successfully run the following command to print the script help text of the test network.
./network.sh -h
When I want to run the next command to bring up the network
./network.sh up
I get the message as follow
Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
ERROR! Peer binary and configuration files not found..
May somebody tells me what's happened? Kindly helps.
I had the same issue, looks like you need to fetch system specific binaries:
https://hyperledger-fabric.readthedocs.io/en/release-2.2/test_network.html
I ran the curl command in the root dir without specifying the versions.
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s
Make sure you add the ./bin to .gitignore
Be sure to use
./network.sh up
from the test network folder and that test network folder is contained in fabric samples, because it could use binaries from different directories contained inside fabric samples and moving it could cause your error.
Also try to set this environment variable
FABRIC_CFG_PATH=$PWD
to force Fabric to be launched in your test network folder
first bring down the network to clean up
cd test-network
./network.sh down
start the network agian
./network.sh up
Before you can deploy the test network, you need to follow the instructions to Install the Samples, Binaries and Docker Images in the Hyperledger Fabric documentation.
When I deploy a chaincode on Hyperledger Fabric Platform, the compilation process is carried out by the Fabric core system, via a shell script. The input to that shell script is the source code.
Is there a provision in Hyperledger fabric to deploy a binary v chaincode (i.e. already compiled one like a .exe)?
Is the chaincode source code logged anywhere?
Searched official documentation but no luck so far.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp" cli peer chaincode install -n mychaincode-v 1.0 -p "$CC_SRC_PATH" -l "$CC_RUNTIME_LANGUAGE"
Thanks.
Answer to 1: No,officially there is no way to do that.
For Q. 2: Chaincode has to be installed in at least one peer, and then has to be instantiated with a transaction that has to be approved according to the policy, so the answer depends on what you mean by anywhere.
while I am running this command from my terminal
sudo ./byfn.sh -m up
I am getting below error:
Starting with channel 'my-channel' and CLI timeout of '10' seconds
and CLI delay of '3' seconds Continue (y/n)? y proceeding ...
Pulling orderer.example.com (hyper-ledger/fabric-orderer:latest)...
ERROR: manifest for hyper-ledger/fabric-orderer:latest not found
ERROR !!!! Unable to start network Error response from daemon: No
such container: cli
How do I resolve this please?
You need to download platform specific binaries, please see how to do it here in the following tutorial. Please also make sure you have all per-requisites, you can find more about what needed here.
Ideally, you should download the platform binaries and images as given in the Fabric documentation - Install Binaries and Docker Images
Or
You should make sure that your terminal has internet access & not behind any corporate proxy. Whatever is needed would be pulled by docker anyway. I am guessing that hyperledger/fabric-baseos image is not pulled by the script above.
If you don't find hyperledger/fabric-baseos:latest,then either docker pull hyperledger/fabric-baseos:tag depends on the fabric version on your own
Or, the chaincode instantiate process in byfn- end to end CLI would do it for you.
I had the same issue. Turns out it was just a broken docker-compose installation. I simply figured it out typing docker-compose in my terminal, and I ran into ImportError: No module named ssl_match_hostname
With a clean docker compose install, I got it to work.