【问题标题】:Error deploying chaincode in Hyperledger Fabric 2在 Hyperledger Fabric 2 中部署链码时出错
【发布时间】:2020-12-09 20:42:11
【问题描述】:

我正在尝试部署链代码:

  • 超级账本结构 2

  • Ubuntu 20.04

    go 版本 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

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

有什么想法吗?

谢谢

【问题讨论】:

    标签: hyperledger-fabric hyperledger-chaincode chaincode


    【解决方案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
    

    【讨论】:

      【解决方案2】:

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

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

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

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

      警告:上面的命令将删除所有容器/卷,而不仅仅是 Fabric 创建的那些

      【讨论】:

        【解决方案3】:

        问题是我使用的是 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

        【讨论】:

        • 需要更准确的分析和解释。问题似乎不是别的,而是 go 语言的一个版本。
        • 特别是,与1.13不同的是,vendering行为与1.14版本不同(>更高),这似乎是由于这个过程造成的问题。
        • 我认为问题不在于 Go 版本,而是安装 Go 的方式(至少在 Ubuntu 中)。
        • 我不知道为什么我说这不是版本问题。我需要一个解释。
        【解决方案4】:

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

        在成功部署该链代码之后。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-11-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多