我正在尝试学习 HLF 2.0 chaincode 生命周期,我的网络配置如下
按照官方文档安装链码https://hyperledger-fabric.readthedocs.io/en/release-2.0/deploy_chaincode.html
当我尝试提交链代码时出现以下错误
Error: proposal failed with status: 500 - failed to invoke backing implementation of 'CommitChaincodeDefinition': chaincode definition not agreed to by this org (LeftOrgMSP)
但是当我检查提交就绪情况时
{
"approvals": {
"LeftOrgMSP": true,
"RightOrgMSP": false
}
}
我得到了 LeftOrgMSP
为真
更新
批准组织的命令
peer lifecycle chaincode approveformyorg -o orderer1.base.order:7050 --channelID basechannel --name fabcar --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls \
--cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/base.order/orderers/orderer1.base.order/msp/tlscacerts/tlsca.base.order-cert.pem
提交命令
peer lifecycle chaincode commit -o orderer1.base.order:7050 --channelID basechannel \
--name fabcar --version 1.0 \
--sequence 1 --tls true \
--cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/base.order/orderers/orderer1.base.order/msp/tlscacerts/tlsca.base.order-cert.pem \
--peerAddresses peer1.base.left:7051 \
--tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/base.left/peers/peer1.base.left/tls/ca.crt
最佳答案
部署链代码的整个过程分为 4 个步骤:
安装 - 当您安装链代码时,您是否在两个组织上都安装了它?如果是这样,成功安装将返回包标识符 (ID),它是包标签 (fabcar_X) 与链代码包哈希的组合。我假设这就是您存储在 $CC_PACKAGE_ID 中的内容,请确认该值是否准确。
安装成功后,向对等节点查询已安装的链码,看看结果是否匹配。命令是:
peer lifecycle chaincode queryinstalled
批准并检查提交准备情况 - 提交准备情况的目的是帮助您验证是否有足够的 channel 成员批准了链代码定义以满足背书政策(默认情况下为多数),然后才能将定义提交到 channel 。看起来您只批准了 LeftOrg 的链代码,您仍然需要为 RightOrg 批准它(尽管您的日志消息似乎另有说明,所以可能还有更多内容)。我会为 RightOrg 执行批准,然后检查两个组织的提交准备情况以确认。
通过提交跟进
并且,如果提交成功,请确认定义已在两个组织上成功提交
peer lifecycle chaincode querycommitted
我有一个 blog on medium on chaincode deployment如果您需要更多信息。
关于hyperledger-fabric - super 账本结构 2.0 : Chaincode commit fails with the error ' chaincode definition not agreed to by this org' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64461308/