0

我正在尝试部署链代码:

  • 超级账本结构 2

  • Ubuntu 20.04

    去版本 go1.13.8 linux/amd64

我总是收到这个错误:

alex@alex:~/fabric-samples/test-network$ ./network.sh deployCC
deploying chaincode on channel 'mychannel'
executing with the following
- CHANNEL_NAME: mychannel
- CC_NAME: basic
- CC_SRC_PATH: NA
- CC_SRC_LANGUAGE: go
- CC_VERSION: 1.0
- CC_SEQUENCE: 1
- CC_END_POLICY: NA
- CC_COLL_CONFIG: NA
- CC_INIT_FCN: NA
- DELAY: 3
- MAX_RETRY: 5
- VERBOSE: false
Determining the path to the chaincode
asset-transfer-basic
Vendoring Go dependencies at ../asset-transfer-basic/chaincode-go/
~/fabric-samples/asset-transfer-basic/chaincode-go ~/fabric-samples/test-network
~/fabric-samples/test-network
Finished vendoring Go dependencies
+ peer lifecycle chaincode package basic.tar.gz --path ../asset-transfer-basic/chaincode-go/ --lang golang --label basic_1.0
+ res=0
Chaincode is packaged
Installing chaincode on peer0.org1...
Using organization 1
+ peer lifecycle chaincode install basic.tar.gz
+ res=1
Error: chaincode install failed with status: 500 - failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 "go: inconsistent vendoring in /chaincode/input/src:
    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
"
Chaincode installation on peer0.org1 has failed
Deploying chaincode failed

我不知道为什么会发生这个问题。我一直在互联网上阅读,并没有明确的解决方案......

任何想法?

谢谢

4

4 回答 4

1

我把它作为评论留下了,但版本有问题。

In particular, unlike 1.13, the vendering behavior is different from version 1.14 (>higher), and this seems to be a problem due to this process. – myeongkil kim


安装方法有问题是没有意义的。您在问题中说您安装了 go1.13.8 linux/amd64 版本。如果环境变量设置好,官方go可以正常运行,根据安装方式的不同,执行不同是没有意义的。

添加到, I don't think the problem was Go version, but the way of installing Go (at least in Ubuntu). – AlexAcc 如果您认为版本没有问题,我想知道为什么。
您可以非常简单地检查它。这是在同一环境中仅更改版本的方法。

所以我实际上运行了它,我能够确认版本问题是正确的,如下所示:


去 1.13.8

# same environment
wget https://golang.org/dl/go1.13.8.linux-amd64.tar.gz
sudo tar -xvf go1.13.8.linux-amd64.tar.gz
sudo mv go /usr/local
go env
cd $GOPATH/src/github.com/hyperledger/fabric-samples/test-network
./network.sh down
./network.sh up
./network.sh deployCC

Error: chaincode install failed with status: 500 - failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 "go: inconsistent vendoring in /chaincode/input/src:
    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
"
Chaincode installation on peer0.org1 has failed

去 1.15.6

# same environment
wget https://golang.org/dl/go1.15.6.linux-amd64.tar.gz
sudo tar -xvf go1.15.6.linux-amd64.tar.gz
sudo mv go /usr/local
go env
cd $GOPATH/src/github.com/hyperledger/fabric-samples/test-network
./network.sh down
./network.sh up
./network.sh deployCC

2020-12-11 10:45:12.229 KST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nJbasic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad\022\tbasic_1.0" >
2020-12-11 10:45:12.229 KST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad
Chaincode is installed on peer0.org1
于 2020-12-11T01:57:35.807 回答
1

我通过删除容器和卷解决了这个问题:

- 使用以下命令停止容器:docker-compose down.

- 使用以下命令删除所有容器:docker rm -f $(docker ps -a -q)

- 使用以下命令删除所有卷:docker volume rm $(docker volume ls -q)

注意:上面的命令会删除你所有的容器/卷,不仅仅是那些由 Fabric 创建的

于 2021-08-22T19:17:41.827 回答
0

问题是我使用的是 go,安装了:

apt get 

后来有了:

apt install

但是直到我尝试使用 wget 从官方来源下载 go 时它才起作用:

wget https://golang.org/dl/go1.15.6.linux-amd64.tar.gz
sudo tar -xvf go1.15.6.linux-amd64.tar.gz
sudo mv go /usr/local
sudo echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc

此链接帮助:

https://medium.com/@kaigo/installing-golang-on-ubuntu-20-04-68137ea931

于 2020-12-09T21:07:27.180 回答
0

安装较新版本golang并运行命令后: sudo echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc 为了更新$PATH变量,我必须关闭并重新打开wsl命令提示符。

成功部署该链代码之后。

于 2021-10-09T19:19:04.800 回答