无法在超级账本结构网络上实例化chaincode

时间:2019-05-08 07:37:55

标签: hyperledger-fabric

我尝试将经过良好测试的链码实例化到我的结构网络上,但问题总结为“无法注册链码”。 没有跟踪代码容器的痕迹。我已经测试了我的链代码,它们通过了所有基本测试,因此代码没有问题。无论我在哪个组织对等方上运行,实例化都会不断失败。

有人可以帮忙吗?

Hyperledger织物版本控制平台提到了相同的错误,但我看不出他们提出了什么解决方案(https://jira.hyperledger.org/browse/FAB-14638)。他们似乎在说节点版本不匹配。

cli日志:

peer chaincode instantiate -o orderer.flightcommand.com:7050 -C flightcommandchannel -l node -n TripCC -v v0 -c '{"Args":["init"]}' -P 'AND ("CapitalcityMSP.member")' 2019-05-08 05:40:55.146 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2019-05-08 05:40:55.150 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc Error: could not assemble transaction, err proposal response was not successful, error code 500, msg chaincode registration failed: container exited with 0**

对等日志:

[flightcommandchannel][97cbe635] Exit chaincode: name:"lscc" (98834ms) 
2019-05-08 05:42:33.897 UTC [endorser] SimulateProposal -> ERRO 18f [flightcommandchannel][97cbe635] failed to invoke chaincode name:"lscc" , error: container exited with 0 
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1 /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:63 runtime.goexit /opt/go/src/runtime/asm_amd64.s:1333 chaincode registration failed
2019-05-08 05:42:33.898 UTC [comm.grpc.server] 1 -> INFO 190 unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=192.168.96.12:38100 grpc.code=OK grpc.call_duration=1m38.836283s

6 个答案:

答案 0 :(得分:1)

我终于找到了问题。我错过了要在对等docker-compose.yaml中指定的ENV变量。

-CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE = network_1.0

其中network_1.0是docker网络的名称。尽管错误消息的描述性不强,但我还是花了些力气并重建了prevoius项目,在该项目中链代码部署确实起作用,并将其与当前项目进行了比较。发现只有这部分丢失了,添加之后,令我惊讶的是,一切正常。

答案 1 :(得分:0)

我修改了对等节点的日志记录级别,发现有些奇怪之处。以下是处于调试模式的链码日志。

2019-05-08 11:21:52.980 UTC [endorser] callChaincode -> INFO 04f [flightcommandchannel][d01daf8c] Entry chaincode: name:"lscc"
2019-05-08 11:21:54.424 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 050
2019-05-08 11:21:54.426 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 051 > trip@1.0.0 start /usr/local/src
2019-05-08 11:21:54.427 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 052 > **NODE_ENV=development node account.js "--peer.address" "peer0.onesky.flightcommand.com:7052"**
2019-05-08 11:21:54.428 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 053
2019-05-08 11:21:55.124 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 054 2019-05-08T11:21:55.118Z debug [lib/chaincode.js]                                 debug: Starting chaincode using options {"_":[],"peer.address":"peer0.onesky.flightcommand.com:7052","chaincodeBuildlevel":"1.4.1-rc1","chaincodeLoggingLevel":"debug","chaincodeLoggingFormat":"%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}","chaincodeIdName":"AccountChaincode:v0","chaincodeLoggingShim":"debug","peerTlsEnabled":"false","grpc.max_send_message_length":-1,"grpc.max_receive_message_length":-1,"grpc.keepalive_time_ms":110000,"grpc.http2.min_time_between_pings_ms":110000,"grpc.keepalive_timeout_ms":20000,"grpc.http2.max_pings_without_data":0,"grpc.keepalive_permit_without_calls":1,"module-path":"/usr/local/src","modulePath":"/usr/local/src","chaincode-id-name":"AccountChaincode:v0","timestamp":"2019-05-08T11:21:55.118Z"}
2019-05-08 11:21:55.128 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 055 2019-05-08T11:21:55.127Z debug [lib/chaincode.js]                                 debug: Peer URL {"0":"g","1":"r","2":"p","3":"c","4":":","5":"/","6":"/","7":"p","8":"e","9":"e","10":"r","11":"0","12":".","13":"o","14":"n","15":"e","16":"s","17":"k","18":"y","19":".","20":"f","21":"l","22":"i","23":"g","24":"h","25":"t","26":"c","27":"o","28":"m","29":"m","30":"a","31":"n","32":"d","33":".","34":"c","35":"o","36":"m","37":":","38":"7","39":"0","40":"5","41":"2","timestamp":"2019-05-08T11:21:55.127Z"}
2019-05-08 11:21:55.135 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 056 2019-05-08T11:21:55.135Z info [lib/chaincode.js]                                  info: Registering with peer peer0.onesky.flightcommand.com:7052 as chaincode "AccountChaincode:v0" {"timestamp":"2019-05-08T11:21:55.135Z"}
2019-05-08 11:21:55.147 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 057 2019-05-08T11:21:55.146Z debug [lib/handler.js]                                   debug: Sending chat message: {"type":1,"payload":{"type":"Buffer","data":[18,19,65,99,99,111,117,110,116,67,104,97,105,110,99,111,100,101,58,118,48]}} {"timestamp":"2019-05-08T11:21:55.146Z"}
2019-05-08 11:21:55.440 UTC [peer.chaincode.dev-peer0.onesky.flightcommand.com-AccountChaincode-v0] func2 -> INFO 058 2019-05-08T11:21:55.437Z error [lib/handler.js]                                   error: Chat stream with peer - on error: "Error: 14 UNAVAILABLE: Name resolution failure\n    at Object.exports.createStatusError (/usr/local/src/node_modules/grpc/src/common.js:91:15)\n    at ClientDuplexStream._emitStatusIfDone (/usr/local/src/node_modules/grpc/src/client.js:233:26)\n    at ClientDuplexStream._receiveStatus (/usr/local/src/node_modules/grpc/src/client.js:211:8)\n    at Object.onReceiveStatus (/usr/local/src/node_modules/grpc/src/client_interceptors.js:1306:15)\n    at InterceptingListener._callNext (/usr/local/src/node_modules/grpc/src/client_interceptors.js:568:42)\n    at InterceptingListener.onReceiveStatus (/usr/local/src/node_modules/grpc/src/client_interceptors.js:618:8)\n    at /usr/local/src/node_modules/grpc/src/client_interceptors.js:1123:18" {"timestamp":"2019-05-08T11:21:55.437Z"}
2019-05-08 11:21:55.617 UTC [dockercontroller] func2 -> INFO 059 Container dev-peer0.onesky.flightcommand.com-AccountChaincode-v0 has closed its IO channel
2019-05-08 11:21:56.091 UTC [endorser] callChaincode -> INFO 05a [flightcommandchannel][d01daf8c] Exit chaincode: name:"lscc"  (3111ms)
2019-05-08 11:21:56.091 UTC [endorser] SimulateProposal -> ERRO 05b [flightcommandchannel][d01daf8c] failed to invoke chaincode name:"lscc" , error: container exited with 0
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1
    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:63
runtime.goexit
    /opt/go/src/runtime/asm_amd64.s:1333
chaincode registration failed
2019-05-08 11:21:56.091 UTC [comm.grpc.server] 1 -> INFO 05c unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=172.25.0.4:59932 grpc.code=OK grpc.call_duration=3.1157286s

这就是问题所在。我的对等方侦听端口7051,而不侦听7052。理想情况下,该命令应看起来像“ NODE_ENV =开发节点account.js“ --peer.address”“ peer0.onesky.flightcommand.com:7051”“。我不知道从哪里获得7052。

P.S。 我添加了以下内容,以便在链码实例化中更好地概述该问题。

  • FABRIC_LOGGING_SPEC = info

  • CORE_CHAINCODE_LOGGING_SHIM =调试

  • CORE_CHAINCODE_LOGGING_LEVEL =调试

core.yaml说

# The endpoint this peer uses to listen for inbound chaincode connections.
# If this is commented-out, the listen address is selected to be
# the peer's address (see below) with port 7052
# chaincodeListenAddress: 0.0.0.0:7052

# The endpoint the chaincode for this peer uses to connect to the peer.
# If this is not specified, the chaincodeListenAddress address is selected.
# And if chaincodeListenAddress is not specified, address is selected from
# peer listenAddress.
# chaincodeAddress: 0.0.0.0:7052

因此,我得出结论,由于两者都已注释,因此将7051用作侦听链码的地址。

答案 2 :(得分:0)

端口7052在这里不太可能成为问题。 (这是来自core.yaml的)关于7052端口的说明。

# The endpoint this peer uses to listen for inbound chaincode connections.
# If this is commented-out, the listen address is selected to be
# the peer's address (see below) with port 7052
# chaincodeListenAddress: 0.0.0.0:7052

在您的调试输出中,我看到"chaincodeBuildlevel":"1.4.1-rc1"

我认为您正在使用1.4.1-rc1的Fabric映像。

我建议删除系统上的Docker映像并替换为1.4.1,然后也使用fabric-shim 1.4.1以获得一致性。这可能会解决问题,但肯定会是继续进行调查的更好的地方。

以下评论已更新

使用Docker Compose,如果您的一组容器是在同一Network Bridge(同一主机/ VM)上启动的,则它们可以解析彼此的地址并在任何端口上进行连接。

docker-compose.yaml文件中的端口映射将端口从主机计算机映射到容器(而不是容器之间)。

端口7053在以前的Fabric版本中曾经用于事件,但在1.4.1中未使用

您现在在注释中显示的错误是名称解析错误,因此与端口无关。也许您的容器不在同一个Docker Bridge上?

答案 3 :(得分:0)

每当尝试实例化链码时,我都会遇到完全相同的问题,但出现此错误

对等日志:

2019-05-09 04:05:38.285 EDT [endorser] SimulateProposal -> ERRO 15c [mychannel][03349c15] failed to invoke chaincode name:"lscc" , error: container exited with 1
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1
/home/alex/go/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:63
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1337
chaincode registration failed

我能够通过更改build.gradle文件来修复它,请确保在您的build.gradle中将Main-Class中的manifest attributes设置为主Java文件。

shadowJar {
    baseName = 'chaincode'
    version = null
    classifier = null

    manifest {
        attributes 'Main-Class': 'org.hyperledger.fabric.chaincode.XXX'
    }
}

XXXXXX.java文件所在的main()文件的位置

不确定如何在节点中完成此操作。但我希望这能给您这个想法。

答案 4 :(得分:0)

我遇到了同样的问题还没有找到任何解决方案。

2021-03-25 04:53:55.840 UTC [endorser] SimulateProposal -> ERRO 046 failed to invoke chaincode bankcc, error: container exited with 0

github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1 /go/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:118

这是我的链码容器日志

Error starting Marbles02 chaincode: ccid must be specified

但我在这里指定了ccid

server := &shim.ChaincodeServer{
    //CCID: ccid,
    CCID:    os.Getenv("CHAINCODE_CCID"),
    Address: os.Getenv("CHAINCODE_ADDRESS"),
    CC:      chaincode,
    TLSProps: shim.TLSProperties{
        Disabled: true,
    },

答案 5 :(得分:0)

我遇到了同样的问题,我通过更改 peer env 解决了这个问题,我认为这个问题是由 CORE_PEER_ADDRESSAUTODETECT 引起的,实际上,我不知道为什么。

我设置了 CORE_PEER_ADDRESSAUTODETECT=true ,评论了 CORE_PEER_CHAINCODEADDRESS 和 CORE_PEER_CHAINCODELISTENADDRESS,这是工作。

我的同行环境是这样的:

CORE_PEER_ADDRESSAUTODETECT=true
#CORE_PEER_CHAINCODEADDRESS=peer0.org1.example.com:30012
#CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:30012