【问题标题】:Hyperledger Endorsement Failure when Invoking chaincode - failed: signature set did not satisfy policy调用链码时 Hyperledger 背书失败 - 失败:签名集不满足策略
【发布时间】:2019-01-04 04:50:57
【问题描述】:

我正在使用带有自定义链码的余额转移应用程序,当我使用背书策略 '1-of':[{ 'signed-by': 0 }, { 'signed-by': 1 }] 时一切正常,但是如果我使用 '2-of':[{ 'signed-by': 0 }, { 'signed-by': 1 }] 调用事务失败并出现以下错误:

Fabric Peer 错误日志:

验证 -> ERRO 078 VSCC 错误:stateBasedValidator.Validate 失败, tx 4:0 中链码 mycc 的背书策略验证错误 失败:签名集不满足策略 2019-01-02 07:24:40.782 UTC [committer.txvalidator] validateTx -> ERRO 079 VSCCValidateTx for 交易 txId = 815553b7cabb383f59d4abd3c2bdc3deda5b74169048e3b3b837f46adbd85099 返回错误:验证链码 mycc 的背书策略 tx 4:0 失败:签名集不满足策略

Node-SDK 日志显示以下内容

[2019-01-02 02:24:40.826] [错误] 调用链代码 - 调用 链码交易无效,代码:ENDORSEMENT_POLICY_FAILURE [2019-01-02 02:24:40.827] [错误] 调用链码 - 错误:调用 链码交易无效,代码:ENDORSEMENT_POLICY_FAILURE

任何解决这个问题的帮助都会非常有帮助

【问题讨论】:

  • 您是否向两个组织的同行提交请求建议?我相信余额转移只需要来自一个组织的同行的认可,而不是来自两个组织。
  • 嗨 Gari Singh,这就是我的请求的外观 Invoke Transaction: localhost:4000/channels/mychannel/chaincodes/mycc \ -H "authorization: Bearer $ORG1_TOKEN" \ -H "content-type: application/json" \ -d ' { "peers": ["peer0.org1.example.com","peer1.org2.example.com"], "fcn":"invoke", "operation":"commit", "args": ["commit ","true","a","b","c"] }') 所以本质上我正在向两个组织的对等方发送请求。我将一次只尝试一个组织并分享响应。谢谢
  • 嗨 Gari Singh 我尝试向一个组织的对等方发送请求,但仍然是同样的问题。 ENDORSEMENT FAILURE 这里是默认的背书策略 'endorsement-policy': { identities: [ { role: { name: 'member', mspId: 'Org1MSP' }}, { role: { name: 'member', mspId: ' Org2MSP' }} ],策略:{ '2-of':[{ 'signed-by': 0 }, { 'signed-by': 1 }] } }
  • 嗨 @GariSingh 我已将代码上传到 github link
  • 嗨@GariSingh 我正在使用的代码在这里上传github.com/psanket/balance-transfer-modified

标签: hyperledger-fabric hyperledger-fabric-sdk-js


【解决方案1】:

我在自己的系统上运行环境并确定这不是链代码的问题,而是正在发送的调用请求的问题。

所以在 testAPI.sh 和 testInvoke.sh 中发出的调用请求是

TRX_ID=$(curl -s -X POST \
  http://localhost:4000/channels/mychannel/chaincodes/mycc \
  -H "authorization: Bearer $ORG1_TOKEN" \
  -H "content-type: application/json" \
  -d '{
    "peers":  **["peer0.org1.example.com","peer1.org1.example.com"]**,
    "fcn":"invoke",
    "operation":"commit",
    "args": ["commitPrivate","uuid3","uuid2-Owner"]
}')

我们可以看到,背书被发送到组织 1 中的两个对等方,而组织 2 中没有。但是,2-of 策略并不是说它需要来自组织 1 和组织 2 中的任何对等方的 2 个签名,但它需要来自 org 1 和 org 2 中的同行的签名。我们可以从背书政策的文档中看到这一点,https://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html#endorsement-policy-syntax

同样,OutOf(2, 'Org1.member', 'Org2.member') 等价于 AND('Org1.member', 'Org2.member')

因此,如果您将请求更改为

TRX_ID=$(curl -s -X POST \
  http://localhost:4000/channels/mychannel/chaincodes/mycc \
  -H "authorization: Bearer $ORG1_TOKEN" \
  -H "content-type: application/json" \
  -d '{
    "peers":  **["peer0.org1.example.com","peer1.org2.example.com"]**,
    "fcn":"invoke",
    "operation":"commit",
    "args": ["commitPrivate","uuid3","uuid2-Owner"]
}')

它会起作用的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-01
    • 1970-01-01
    • 2015-04-30
    相关资源
    最近更新 更多