【问题标题】:Error in committed chaincode invoke/query with hyperledger fabric 2.0使用超级账本结构 2.0 提交的链码调用/查询时出错
【发布时间】:2020-06-08 23:57:15
【问题描述】:

我已经使用命令成功提交了链码:

./peer lifecycle chaincode commit -o orderer.example.org:7050 --channelID mychannel --name emp_chaincode --version v1 --sequence 1 --init-required --tls --cafile ./crypto-config/ordererOrganizations/example.org/orderers/orderer.example.org/msp/tlscacerts/tlsca.example.org-cert.pem

现在,当我尝试调用/查询链代码时,出现此错误:

Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction f490a9e7bca41ad10f68306decae2fdd73e09a9d5f81da7c9ee5cdc3811b3f27: invalid invocation: chaincode 'emp_chaincode' has not been initialized for this version, must call as init first"

在链码容器日志中,它显示:

+ CHAINCODE_DIR=/usr/local/src

+ cd /usr/local/src

+ npm start -- --peer.address peer0.org1.example.org:7052


> employee@1.0.0 start /usr/local/src

> node emp_chaincode.js "--peer.address" "peer0.org1.example.org:7052"

2020-02-25T09:28:16.743Z info [c-api:lib/chaincode.js] Registering with peer peer0.org1.example.org:7052 as chaincode "emp_chaincodev1:5bcbed31afc58894912eb4c66d63adcec7eab029e2b911887412b119ef5cf319"

2020-02-25T09:28:16.761Z error [c-api:lib/handler.js] Chat stream with peer - on error: %j "Error: 14 UNAVAILABLE: failed to connect to all addresses\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:1311: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:1127:18"

请告诉我如何解决它。

更新:

在 R Thatcher 建议添加标志之后,我现在得到的错误是:

Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction 038b5c303dfdd98db2c2fc0d2eac6146d7221691cbbed7a78227f5a76a31a240: could not launch chaincode emp_chaincodev1:5bcbed31afc58894912eb4c66d63adcec7eab029e2b911887412b119ef5cf319: chaincode registration failed: container exited with 0"

【问题讨论】:

  • 请分享您的提交命令。
  • @AdityaArora 添加了有问题的命令

标签: docker hyperledger-fabric hyperledger hyperledger-chaincode


【解决方案1】:

在错误结束时,您必须首先调用 init

我认为您使用了带有标志--init-requiredpeer chaincode lifecycle approveformyorg 命令。这意味着新链码的第一次调用必须使用 --isInit 标志,例如peer chaincode invoke -C tradechannel -n trade --isInit ...。在第一次“特殊”调用之后,其他调用和查询就可以了。

【讨论】:

  • 随着您的更新,我收到此错误:Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction 038b5c303dfdd98db2c2fc0d2eac6146d7221691cbbed7a78227f5a76a31a240: could not launch chaincode emp_chaincodev1:5bcbed31afc58894912eb4c66d63adcec7eab029e2b911887412b119ef5cf319: chaincode registration failed: container exited with 0"
  • 链码日志Error: 14 UNAVAILABLE: failed to connect的错误提示连接到peer有网络问题,或者peer可能没有启动?您有多少个组织和同行?
  • 一个组织中有 2 个同行,他们都在运行
  • 我用goleveldb检查过一切正常,问题似乎与couchdb有关。 @r-thatcher 你知道那里有什么问题吗?
  • 实际上错误与 Mac 上的 docker 有关,在 Ubuntu 上一切正常。所以你的回答解决了我与init相关的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-08-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多