更改背书政策以要求多个成员,但不确定如何让所有同行背书

Changing endorsement policy to require multiple members, but not sure how to get all peers to endorse

我的链码是使用以下命令实例化的:

peer chaincode instantiate -o orderer1.example.com:7050 --tls true --cafile <cafile> -C mychannel
-n mycc -l java -v 1.0 -c '{"Args":[]}' -P "OR ('Org1MSP.member')"

我想更改背书政策,以便组织中的所有同行都需要背书;目前我有两个同伴,但人数会增加。

我现在做的是以下程序:

第一步:安装具有不同版本名称的相同链代码。

peer chaincode install -n mycc -v <version> -l java -p /opt/gopath/src/github.com/chaincode

第二步:使用以下命令升级链码:

peer chaincode upgrade -o orderer1.example.com:7050 --tls true --cafile <cafile> -C mychannel
-n mycc -l java -v <version> -c '{"Args":[]}' -P "OutOf(2, 'Org1MSP.member')"
-peerAddresses peer1.org1.example.com:7051 -peerAddresses peer2.org1.example.com:7051

但是,我无法达到我想要的结果。在目前的背书政策下,当我使用我的客户端提交交易时,它会在一段时间后提交。在我更改政策后,我的交易不再被自动接受,日志反映了这一点,并显示以下错误消息:

VSCC error: stateBasedValidator.Validate failed, err validation of endorsement policy for chaincode 
mycc in tx 132:0 failed: signature set did not satisfy policy

所以虽然我能够停止自动接受交易,但现在我发现自己无法验证任何交易。

  1. 我修改链码背书策略的流程,是否正确?

  2. 我的背书政策是否符合我的意图?

  3. 为什么我无法再验证交易?


编辑:我将日志记录规范更改为 Jason Yellick 建议的规范。我想我找到了一些可能提供见解的调试:

<time> [cauthdsl] func1 -> DEBU 4bd 0xc0004e4050 gate 1594275943563937246 evaluation starts
<time> [cauthdsl] func2 -> DEBU 4be 0xc0004e4050 signed by 0 principal evaluation starts (used [false])
<time> [cauthdsl] func2 -> DEBU 4bf 0xc0004e4050 processing identity 0 with bytes of 1159660
<time> [cauthdsl] func2 -> DEBU 4c0 0xc0004e4050 principal matched by identity 0
<time> [cauthdsl] func2 -> DEBU 4c1 0xc0004e4050 principal evaluation succeeds for identity 0
<time> [cauthdsl] func2 -> DEBU 4c2 0xc0004e4050 signed by 1 principal evaluation starts (used [true])
<time> [cauthdsl] func2 -> DEBU 4c3 0xc0004e4050 skipping identity 0 because it has already been used
<time> [cauthdsl] func2 -> DEBU 4c4 0xc0004e4050 principal evaluation fails
<time> [cauthdsl] func1 -> DEBU 4c5 0xc0004e4050 gate 1594275943563937246 evaluation fails
<time> [vscc] Validate -> ERRO 4c6 VSCC error: stateBasedValidator.Validate failed, err validation of endorsement policy for chaincode myteacc in tx 140:0 failed: signature set did not satisfy policy
<time> [vscc] Validate -> DEBU 4c7 block 140, namespace: myteacc, tx 0 validation results is: validation of endorsement policy for chaincode myteacc in tx 140:0 failed: signature set did not satisfy policy
<time> [committer.txvalidator] ValidateWithPlugin -> DEBU 4c8 Transaction 1d8f66a10658c3d808ad4ce0feef9fd5c13816187a39fcedc8a32ce91016df0d appears to be invalid: validation of endorsement policy for chaincode myteacc in tx 140:0 failed: signature set did not satisfy policy
<time> [committer.txvalidator] validateTx -> ERRO 4c9 VSCCValidateTx for transaction txId = 1d8f66a10658c3d808ad4ce0feef9fd5c13816187a39fcedc8a32ce91016df0d returned error: validation of endorsement policy for chaincode myteacc in tx 140:0 failed: signature set did not satisfy policy
<time> [committer.txvalidator] validateTx -> DEBU 4ca [isprintchannel] validateTx completes for block 0xc0026306c0 env 0xc00245e190 txn 0

这是政策设置为 AND('Org1MSP.member','Org1MSP.member')

您的背书政策无法满足。在您的升级命令中:

peer chaincode upgrade -o orderer1.example.com:7050 --tls true
--cafile <cafile> -C mychannel -n mycc -l java -v <version>
-c '{"Args":[]}' -P "OutOf(2, 'Org1MSP.member')"
-peerAddresses peer1.org1.example.com:7051 -peerAddresses
peer2.org1.example.com:7051

您可以看到您的政策是:

-P "OutOf(2, 'Org1MSP.member')"

此背书政策要求“1 个身份中有 2 个必须签名”。这永远不会满足,因为签名永远不会超过原则。它本质上是在说“从一件事中选择其中的两件事”,这是一个矛盾。如果你真的想要来自同一个组织的两个同行,那么你会想要写:

-P "OutOf(2, 'Org1MSP.member', 'Org1MSP.member')"

或者,您可以简单地使用 AND 语法:

-P "AND('Org1MSP.member', 'Org1MSP.member')"

我要注意,要求来自同一组织的多个同行背书是不常见的,如果你走这条路,你需要小心你的证书管理。特别是,如果你使用的是fabric-ca,你必须确保peer身份只能注册一次,否则它可以重新注册,现在有两个有效身份,并且能够伪装成两个不同的peer。同样,如果必须重新颁发身份,请注意确保旧证书已被吊销。

您可能会考虑定义第二个逻辑组织并使用这两个不同的逻辑组织编写策略,例如:

-P "AND('Org1MSP.member', 'Org2MSP.member')"

这是一种更为传统的 Fabric 操作方式。