Topics

Fabric 1.4.7 go chaincode install error #fabric-sdk-go #fabric-chaincode #hyperledger-fabric

Jay Chandran
 

Hi,

I am using Hyperledger fabric 1.4.7 and using the fabcar as an example to build a sample network and using the Go sdk. Its the same code base as in the fabric-samples just that I have taken it and setup in a completely new folder structure.

/home/jay/hyperledger/fabcar-network/
drwxr-xr-x 2 jay jay  4096 May 15 00:54 bin
drwxr-xr-x 2 jay jay  4096 May 28 15:12 base
-rw-r--r-- 1 jay jay  8760 May 28 15:22 configtx.yaml
-rw-r--r-- 1 jay jay   487 May 28 15:25 crypto-config.yaml
-rw-r--r-- 1 jay jay  4532 May 28 15:31 docker-compose-couch.yaml
drwxr-xr-x 2 jay jay  4096 May 28 16:51 scripts
drwxrwxr-x 2 jay jay  4096 May 28 20:02 application
-rw-r--r-- 1 jay jay  1857 May 28 20:18 docker-compose-ca.yaml
-rw-r--r-- 1 jay jay  3015 May 28 20:19 docker-compose-e2e-template.yaml
-rwxr-xr-x 1 jay jay 22612 May 28 20:22 network.sh
drwxr-xr-x 2 jay jay  4096 Jun  2 18:35 chaincode
-rw-r--r-- 1 jay jay  3132 Jun  2 20:30 docker-compose-cli.yaml
drwxr-xr-x 4 jay jay  4096 Jun  2 20:31 crypto-config
-rw-r--r-- 1 jay jay  3223 Jun  2 20:31 docker-compose-e2e.yaml
drwxr-xr-x 2 jay jay  4096 Jun  2 20:31 channel-artifacts


In the GOPATH I have the chaincode i.e. 

jay@j-dev:~/hyperledger/fabcar-network$ ls -ltr /home/jay/go/src/github.com/fabcar-network/chaincode/
total 8
-rw-rw-r-- 1 jay jay 5026 May 31 09:28 fabcar.go
jay@j-dev:~/hyperledger/fabcar-network$ 

when the chaincode is being installed, it fails with the following error message:

+ peer chaincode install -n fabcarcc -v 1.0 -l golang -p github.com/fabcar-network/chaincode/
Installing chaincode on peer0.org1...
+ res=1
+ set +x
2020-06-02 15:01:37.165 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-06-02 15:01:37.165 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: error getting chaincode code fabcarcc: error getting chaincode package bytes: Error obtaining dependencies for github.com/hyperledger/fabric-chaincode-go/shim: command <go list -f {{ join .Deps "\n"}} github.com/hyperledger/fabric-chaincode-go/shim>: failed with error: "exit status 1"
can't load package: package github.com/hyperledger/fabric-chaincode-go/shim: cannot find package "github.com/hyperledger/fabric-chaincode-go/shim" in any of:
/opt/go/src/github.com/hyperledger/fabric-chaincode-go/shim (from $GOROOT)
/home/jay/go/src/github.com/hyperledger/fabric-chaincode-go/shim (from $GOPATH)
 
!!!!!!!!!!!!!!! Chaincode installation on peer0.org1 has failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========
 
ERROR !!!! Test failed
But the shim package is available in the GOPATH as shown below:

jay@j-dev:~/hyperledger/fabcar-network$ ls -ltr /home/jay/go/src/github.com/hyperledger/fabric-chaincode-go/shim
total 136
-rw-r--r-- 1 jay jay 21862 May 28 18:25 interfaces.go
-rw-r--r-- 1 jay jay  8026 May 28 18:25 handler_test.go
-rw-r--r-- 1 jay jay 26501 May 28 18:25 handler.go
-rw-r--r-- 1 jay jay  2041 May 28 18:25 chaincodeserver.go
-rw-r--r-- 1 jay jay 18412 May 28 18:25 stub_test.go
-rw-r--r-- 1 jay jay 25070 May 28 18:25 stub.go
-rw-r--r-- 1 jay jay  5545 May 28 18:25 shim_test.go
-rw-r--r-- 1 jay jay  4159 May 28 18:25 shim.go
-rw-r--r-- 1 jay jay   755 May 28 18:25 response.go
drwxr-xr-x 3 jay jay  4096 May 28 18:25 internal
jay@j-dev:~/hyperledger/fabcar-network$ 
 
Can someone please point out what is the mistake I am doing? 

Thanks in advance!
Jay Chandran.

Jay Chandran
 

Snippet of the go code...

package main

import (
"bytes"
"encoding/json"
"fmt"
"strconv"

"github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric-protos-go/peer"
)

// Struct to receive Chaincode shim functions
type SmartContract struct {
}

type Car struct {
Make string `json:"make"`
Model string `json:"model"`
Colour string `json:"colour"`
Owner string `json:"owner"`
}

/*
In particular the Init method is called when a chaincode receives an instantiate or upgrade transaction so that
the chaincode may perform any necessary initialization, including initialization of application state.
*/
func (s *SmartContract) Init(APIstub shim.ChaincodeStubInterface) peer.Response {
return shim.Success(nil)
}

/*
The Invoke method is called in response to receiving an invoke transaction to process transaction proposals.
*/
func (s *SmartContract) Invoke(APIstub shim.ChaincodeStubInterface) peer.Response {
// call APIstub.GetFunctionAndParameters to extract the function name and the parameters to that chaincode application function.
function, args := APIstub.GetFunctionAndParameters()

if function == "queryCar" {
return s.queryCar(APIstub, args)
} else if function == "initLedger" {
return s.initLedger(APIstub)
} else if function == "createCar" {

Santiago Figueroa Lorenzo
 

Hi Jay,

Have you solved the issue? I have the same problem in my case trying to deploy the chaincode using the Caliper tool to perform a performance analysis.

In addition to what you mention, I have tried to create volumes in the docker-compose.yaml, so that package (shim) can be mapped into the containers of each of the peers, but I haven't solved the problem either.

Thanks,

Santiago.

On Tue, Jun 2, 2020 at 5:17 PM Jay Chandran <jaychandran2403@...> wrote:
Hi,

I am using Hyperledger fabric 1.4.7 and using the fabcar as an example to build a sample network and using the Go sdk. Its the same code base as in the fabric-samples just that I have taken it and setup in a completely new folder structure.

/home/jay/hyperledger/fabcar-network/
drwxr-xr-x 2 jay jay  4096 May 15 00:54 bin
drwxr-xr-x 2 jay jay  4096 May 28 15:12 base
-rw-r--r-- 1 jay jay  8760 May 28 15:22 configtx.yaml
-rw-r--r-- 1 jay jay   487 May 28 15:25 crypto-config.yaml
-rw-r--r-- 1 jay jay  4532 May 28 15:31 docker-compose-couch.yaml
drwxr-xr-x 2 jay jay  4096 May 28 16:51 scripts
drwxrwxr-x 2 jay jay  4096 May 28 20:02 application
-rw-r--r-- 1 jay jay  1857 May 28 20:18 docker-compose-ca.yaml
-rw-r--r-- 1 jay jay  3015 May 28 20:19 docker-compose-e2e-template.yaml
-rwxr-xr-x 1 jay jay 22612 May 28 20:22 network.sh
drwxr-xr-x 2 jay jay  4096 Jun  2 18:35 chaincode
-rw-r--r-- 1 jay jay  3132 Jun  2 20:30 docker-compose-cli.yaml
drwxr-xr-x 4 jay jay  4096 Jun  2 20:31 crypto-config
-rw-r--r-- 1 jay jay  3223 Jun  2 20:31 docker-compose-e2e.yaml
drwxr-xr-x 2 jay jay  4096 Jun  2 20:31 channel-artifacts


In the GOPATH I have the chaincode i.e. 

jay@j-dev:~/hyperledger/fabcar-network$ ls -ltr /home/jay/go/src/github.com/fabcar-network/chaincode/
total 8
-rw-rw-r-- 1 jay jay 5026 May 31 09:28 fabcar.go
jay@j-dev:~/hyperledger/fabcar-network$ 

when the chaincode is being installed, it fails with the following error message:

+ peer chaincode install -n fabcarcc -v 1.0 -l golang -p github.com/fabcar-network/chaincode/
Installing chaincode on peer0.org1...
+ res=1
+ set +x
2020-06-02 15:01:37.165 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-06-02 15:01:37.165 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: error getting chaincode code fabcarcc: error getting chaincode package bytes: Error obtaining dependencies for github.com/hyperledger/fabric-chaincode-go/shim: command <go list -f {{ join .Deps "\n"}} github.com/hyperledger/fabric-chaincode-go/shim>: failed with error: "exit status 1"
can't load package: package github.com/hyperledger/fabric-chaincode-go/shim: cannot find package "github.com/hyperledger/fabric-chaincode-go/shim" in any of:
/home/jay/go/src/github.com/hyperledger/fabric-chaincode-go/shim (from $GOPATH)
 
!!!!!!!!!!!!!!! Chaincode installation on peer0.org1 has failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========
 
ERROR !!!! Test failed
But the shim package is available in the GOPATH as shown below:

jay@j-dev:~/hyperledger/fabcar-network$ ls -ltr /home/jay/go/src/github.com/hyperledger/fabric-chaincode-go/shim
total 136
-rw-r--r-- 1 jay jay 21862 May 28 18:25 interfaces.go
-rw-r--r-- 1 jay jay  8026 May 28 18:25 handler_test.go
-rw-r--r-- 1 jay jay 26501 May 28 18:25 handler.go
-rw-r--r-- 1 jay jay  2041 May 28 18:25 chaincodeserver.go
-rw-r--r-- 1 jay jay 18412 May 28 18:25 stub_test.go
-rw-r--r-- 1 jay jay 25070 May 28 18:25 stub.go
-rw-r--r-- 1 jay jay  5545 May 28 18:25 shim_test.go
-rw-r--r-- 1 jay jay  4159 May 28 18:25 shim.go
-rw-r--r-- 1 jay jay   755 May 28 18:25 response.go
drwxr-xr-x 3 jay jay  4096 May 28 18:25 internal
jay@j-dev:~/hyperledger/fabcar-network$ 
 
Can someone please point out what is the mistake I am doing? 

Thanks in advance!
Jay Chandran.

Jay Chandran
 

No Santiago, I have not been able to solve the problem yet.

Santiago Figueroa Lorenzo
 

Thanks, I have found this jira (https://jira.hyperledger.org/browse/FAB-15782), where it is defined the environmental variable CHAINCODE_VENDORSHIM as a possible solution. Maybe it helps you. I am trying to use it.


On Wed, Jun 3, 2020 at 3:43 PM Jay Chandran <jaychandran2403@...> wrote:
No Santiago, I have not been able to solve the problem yet.

Jay Chandran
 

Further update:

When I check via the cli container, only the hyperledger/fabric/peer/ is available. The hyperledger/fabric-chaincode-go/shim/ and the hyperledger/fabric-protos-go/peer dependencies are not available in the cli volume path.
 
The chaincode is available though.

root@077776b644e2:/home/jay/go/src/github.com# ls -ltr
total 8
drwxr-xr-x 3 root root 4096 Jun  3 13:56 hyperledger
drwxr-xr-x 3 root root 4096 Jun  3 13:56 fabcar-network
root@077776b644e2:/home/jay/go/src/github.com# 
 
How do I get the hyperledger/fabric-chaincode-go/shim/ and the hyperledger/fabric-protos-go/peer dependencies into the cli container?

Jay Chandran
 

Santiago,

There was a problem with vendoring and now the chaincode is installed.
 
Installing chaincode on peer0.org1...
+ peer chaincode install -n fabcarcc -v 1.0 -l golang -p github.com/fabcar-network/chaincode/
+ res=0
+ set +x
2020-06-03 17:55:36.483 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-06-03 17:55:36.483 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-06-03 17:55:36.693 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" > 
===================== Chaincode is installed on peer0.org1 ===================== 
==== 

Santiago Figueroa Lorenzo
 

Jay,

Thanks for the advice. From it, I applied the recommendations of FAB-15470 (https://jira.hyperledger.org/browse/FAB-15470) and now it works for me.

On Wed, Jun 3, 2020 at 8:00 PM Jay Chandran <jaychandran2403@...> wrote:
Santiago,

There was a problem with vendoring and now the chaincode is installed.
 
Installing chaincode on peer0.org1...
+ peer chaincode install -n fabcarcc -v 1.0 -l golang -p github.com/fabcar-network/chaincode/
+ res=0
+ set +x
2020-06-03 17:55:36.483 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-06-03 17:55:36.483 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-06-03 17:55:36.693 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" > 
===================== Chaincode is installed on peer0.org1 ===================== 
==== 

Jay Chandran
 

Great thanks Santiago!