【问题标题】:Hyperledger-fabric fails to instantiate chaincodeHyperledger-fabric 无法实例化链码
【发布时间】:2018-09-27 13:15:11
【问题描述】:

我无法在 Hyperledge Fabric 中实例化链码。

执行时:

peer chaincode instantiate -o orderer -n test_cc -C test-channel -v 0.1 -c '{"Args":["initLedger"]}'

我得到错误:

peer0       | 2018-04-17 13:02:11.097 UTC [dockercontroller] Start -> ERRO 046 start-could not start container: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}

在网上搜索时,错误信息与 [OCI Runtimer Error when installing Hyperledger Chaincode via Java-SDK 和 [OCI runtime error when sending Hyperledger Fabric's chaincode instantiation request to peers 的原始帖子相同,但这些帖子上的 cmets 并没有引导我找到解决方案。

我正在使用以下软件版本: 超级账本 1.1.0 Docker 版本 18.03.0-ce(Linux 上),Hyperledger Docker 镜像:x86_64-1.1.0

以下步骤成功:

  • 构建链码。代码编译没有错误。除了两个必需的“github.com/hyperledger/fabric/core/chaincode/shim”和 "github.com/hyperledger/fabric/protos/peer"
  • 打包链码。
  • 签署链码。
  • 安装链码(它最终在对等方的 /var/hyperledger/production/chaincodes/test_cc.0.1 中。

(根据 Hyperledger 文档的步骤:[http://hyperledger-fabric-docs.readthedocs.io/en/latest/chaincode4noah.html]

在 CLI Docker 容器中,文件位于目录 /opt/gopath/src/chaincode/go/test_cc/,其中有 4 个文件:test_cc, test_cc.go, test_cc_pack.out, test_cc_signed_pack.out(二进制文件、源文件、打包文件和签名包文件)。

orderer和peer的完整输出为:

orderer    | 2018-04-17 13:29:43.617 UTC [orderer/common/server] Broadcast -> DEBU 167 Starting new Broadcast handler
orderer    | 2018-04-17 13:29:43.617 UTC [orderer/common/broadcast] Handle -> DEBU 168 Starting new broadcast loop for 172.18.0.6:41228
couchdb    | [notice] 2018-04-17T13:29:43.624931Z nonode@nohost <0.16042.3> b5d38cd27d couchdb:5984 172.18.0.5 undefined GET /test-channel_lscc/test_cc?attachments=true 404 ok 2
peer       | 2018-04-17 13:29:44.416 UTC [dockercontroller] Start -> ERRO 04a start-could not start container: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer       | 2018-04-17 13:29:44.647 UTC [chaincode] Launch -> ERRO 04b launchAndWaitForRegister failed: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer       | 
peer       | error starting container
peer       | 2018-04-17 13:29:44.647 UTC [endorser] simulateProposal -> ERRO 04c [test-channel][39e4414a] failed to invoke chaincode name:"lscc" , error: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer       | 
peer       | error starting container
orderer    | 2018-04-17 13:29:44.648 UTC [orderer/common/broadcast] Handle -> DEBU 169 Received EOF from 172.18.0.6:41228, hangup
orderer    | 2018-04-17 13:29:44.648 UTC [orderer/common/server] func1 -> DEBU 16a Closing Broadcast stream

看起来有一些路径问题,但是创建链码容器的过程以及影响这个过程的变量。

我在这个问题上搞砸了几天(!),尝试了所有路径组合,例如将文件放在/opt/gopath/bin 等,但无济于事。

有人可以阐明这个问题吗?或者知道正确的路径是什么以及它们在哪里,或者应该在哪里定义它们?

谢谢

【问题讨论】:

  • 你能分享你安装链码的命令吗?
  • peer chaincode install chaincode/go/test_cc/test_cc_signed_pack.out 我从 /opt/gopath/src 运行它(在 CLI 上)。
  • 你能分享一下你用来打包链码的命令吗?
  • peer chaincode package -n test_cc -p chaincode/go/test_cc -v 0.1 -s -S chaincode/go/test_cc/test_cc_pack.out 也在 CLI 上从 /opt/gopath/src 运行它。签名:peer chaincode signpackage chaincode/go/test_cc/test_cc_pack.out chaincode/go/test_cc/test_cc_signed_pack.out

标签: go hyperledger-fabric hyperledger


【解决方案1】:

问题是在 Go 源文件中我使用了“package test_package”,它在构建时不会创建一个可执行文件,而是一个可链接的目标文件。

在我的 Go 文件中包含“主包”,然后重新构建和重新打包,使“对等链代码安装”和“对等链代码实例化”命令按预期工作。

【讨论】:

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