Hyperledger Endorsement Failure when Invoking chaincode - failed: signature set did not satisfy policy

家住魔仙堡 提交于 2019-12-08 03:47:35

问题


I am using balance transfer application with custom chaincode, when I use endorsement policy '1-of':[{ 'signed-by': 0 }, { 'signed-by': 1 }] then every thing works fine however if I use '2-of':[{ 'signed-by': 0 }, { 'signed-by': 1 }] invoke transaction fails with below error:

Fabric Peer Error log:

Validate -> ERRO 078 VSCC error: stateBasedValidator.Validate failed, err validation of endorsement policy for chaincode mycc in tx 4:0 failed: signature set did not satisfy policy 2019-01-02 07:24:40.782 UTC [committer.txvalidator] validateTx -> ERRO 079 VSCCValidateTx for transaction txId = 815553b7cabb383f59d4abd3c2bdc3deda5b74169048e3b3b837f46adbd85099 returned error: validation of endorsement policy for chaincode mycc in tx 4:0 failed: signature set did not satisfy policy

Node-SDK logs show the following

[2019-01-02 02:24:40.826] [ERROR] invoke-chaincode - The invoke chaincode transaction was invalid, code:ENDORSEMENT_POLICY_FAILURE [2019-01-02 02:24:40.827] [ERROR] invoke-chaincode - Error: The invoke chaincode transaction was invalid, code:ENDORSEMENT_POLICY_FAILURE

Any help in resolving this will be very helpful


回答1:


I ran the environment on my own system and determined that it is not an issue with the chaincode, but rather an issue with the invoke requests that is being sent.

So the invoke request being made in testAPI.sh and testInvoke.sh is

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"]
}')

What we can see is that the endorsements are being sent to both peers in org 1 and none in org 2. However, the 2-of policy is not saying that it needs 2 signature from any peers in org 1 and org 2, but instead that it needs a signature from a peers in org 1 and org 2. We can see this from the documentation for endorsement policies, https://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html#endorsement-policy-syntax.

Similarly, OutOf(2, 'Org1.member', 'Org2.member') is equivalent to AND('Org1.member', 'Org2.member')

So if you change your request to

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"]
}')

it will work.



来源:https://stackoverflow.com/questions/54033274/hyperledger-endorsement-failure-when-invoking-chaincode-failed-signature-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!