HFC:CC部署成功,而PEER:“错误构建映像:..." [英] HFC: CC deployment successfull while PEER: "Error building images: ..."
问题描述
TL; DR;转到下面的----编辑部分
我在独立的node.js应用程序中使用 hfc@0.6.5
.
I am using hfc@0.6.5
in a standalone node.js application.
membersvc和peer以docker-compose
开始,其中:
A membersrvc and peer are started with docker-compose
, where:
membersrvc:
container_name: membersrvc
image: hyperledger/fabric-membersrvc:latest
ports:
- "7054:7054"
command: membersrvc
vp0:
container_name: peer
image: hyperledger/fabric-peer:latest
ports:
- "7050:7050"
- "7051:7051"
- "7053:7053"
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ID=vp0
- CORE_SECURITY_ENABLED=true
- CORE_PEER_PKI_ECA_PADDR=172.17.0.2:7054
- CORE_PEER_PKI_TCA_PADDR=172.17.0.2:7054
- CORE_PEER_PKI_TLSCA_PADDR=172.17.0.2:7054
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=noops
[...]
links:
- membersrvc
command: sh -c "sleep 10; peer node start"
node.js应用程序成功注册了新用户,并尝试使用enrolledUser.deploy(deployRequest);
方法部署链码.
The node.js application successfully registers new users and tries to deploy a chaincode using the enrolledUser.deploy(deployRequest);
method.
作为deployRequest.chaincodePath
的值的路径
设置'github.com/asset-chaincode/'
.该目录包含一个链码.go
文件.
As a value of deployRequest.chaincodePath
a path
'github.com/asset-chaincode/'
is set.The directory contains a chaincode .go
file.
deployTx.on('complete', cb)
的回调显示其日志消息:
A callback of deployTx.on('complete', cb)
prints its log message:
SUCCESS: Successfully deployed chaincode [chainCodeId:415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58], deploy request={"fcn":"init","args":[],"confidential":true,"metadata":{"type":"Buffer","data":[48,...155,253,0]},"chaincodePath":"github.com/gvlax/chaincodes/asset-chaincode"}, response={"uuid":"415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58","chaincodeID":"415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58"}
chaincodeId=415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58
但是,当我检查对等控制台的输出时, 我可以看到错误消息
However, when I check an output of a peer console, I can see error messages
-> 此处完整日志 :
peer | 15:40:00.416 [dockercontroller] deployImage -> ERRO 47a Error building images: The command '/bin/sh -c go install build-chaincode && cp src/build-chaincode/vendor/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin && mv $GOPATH/bin/build-chaincode $GOPATH/bin/23991376d1b935790631a448843fd12a9d60f7ab3f0b8b55f629cf0190077436' returned a non-zero code: 1
[...]
peer | ---> Running in 812439684bf7
peer | src/build-chaincode/asset-chaincode.go:25:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of:
peer | /opt/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)
peer | /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOPATH)
peer | src/build-chaincode/asset-chaincode.go:26:2: cannot find package "github.com/hyperledger/fabric/core/crypto/primitives" in any of:
peer | /opt/go/src/github.com/hyperledger/fabric/core/crypto/primitives (from $GOROOT)
peer | /opt/gopath/src/github.com/hyperledger/fabric/core/crypto/primitives (from $GOPATH)
peer | package build-chaincode
peer | imports github.com/hyperledger/fabric/vendor/github.com/op/go-logging: must be imported as github.com/op/go-logging
[...]
似乎有些问题与对等方上的chaincode编译不完全相关. 或者将链码部署到对等点上无法解析链码中的相对导入路径的位置....
It looks like there are some issues not exactly related to the chaincode compilation on the peer. Or the chaincode is deployed to a location on the peer where relative import paths in the chaincode cannot be resolved ....
经过多次尝试和实验,我认为我的问题总是相同的:
在使用方法enrolledUser.deploy(deployRequest)
(hfc@0.6.5)部署到同级后,无论任何有效的链码(本地存储在目录$GOPATH/src/gibhub.com/<mychaincode_dir>
中,且没有错误),结果在目标上始终给出相同的错误节点:
After many attempts and experiments, I think my problem is always the same:
Regardless of any valid chaincode (stored locally in a directory $GOPATH/src/gibhub.com/<mychaincode_dir>
+ building with no errors) after being deployed on a peer with the method enrolledUser.deploy(deployRequest)
(hfc@0.6.5), a result gives always the same errors on the target node:
peer | Step 4 : RUN go install build-chaincode && cp src/build-chaincode/vendor/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin && mv $GOPATH/bin/build-chaincode $GOPATH/bin/0881d0fe8f4528e1369bfe917cd207d919a07758cc098e212ca74f6766c636d4
peer | ---> Running in b0ca2abbe609
peer | src/build-chaincode/asset-chaincode.go:25:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of:
peer | /opt/gopath/src/build-chaincode/vendor/github.com/hyperledger/fabric/core/chaincode/shim (vendor tree)
peer | /opt/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)
同行抱怨的抄送进口是:
The imports of the cc the peer complains about are:
import (
"encoding/base64"
"errors"
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
[...]
此外,当我进入对等CLI时,可以在其中找到垫片...
moreover, when I go to the peer CLI, the shim can be found there ...
$ docker exec -it peer bash
$ find / -name shim
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
$ echo $GOPATH/
/opt/gopath/
织物对等图像没什么问题吗?
Isn't something wrong with the fabric-peer image ???
推荐答案
When you deploy with hfc, you need to "vendor" the fabric chaincode packages - see http://hyperledger-fabric.readthedocs.io/en/v0.6/nodeSDK/node-sdk-indepth/#chaincode-deployment
您还可以查看 https://github.com/IBM-Blockchain/SDK-Demo/tree/master/src/chaincode 也是使用SDK进行此操作的示例
You can also have a look at https://github.com/IBM-Blockchain/SDK-Demo/tree/master/src/chaincode for an example of doing this with the SDK as well
这篇关于HFC:CC部署成功,而PEER:“错误构建映像:..."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!