背书政策不起作用
Endorsement policy doesn't work
当我使用管理员部署网络时,一个组织包括三个对等点。
我的背书-policy.json如下,无效
{
"identities": [
{
"role": {
"name": "member",
"mspId": "Org1MSP"
}
}
],
"policy": {
"1-of": [
{
"signed-by": 0
}
]
}
}
1.How 我可以设置背书政策吗?
2. 我认为背书节点是唯一的节点,'member' 或 'admin' 是什么意思?
所以,我想让三个节点都成为背书节点,如何配置?
就使您的 JSON 策略文件起作用而言,应该这样做:
{
"identities": [
{
"role": {
"name": "member",
"mspId": "Org1MSP"
}
}
],
"policy": {
"signed-by": 0
}
}
政策 JSON 的定义是 here
背书签名是针对每个组织的,因此如果您有多个组织,则只需在背书策略中添加额外的 "identities"。
让我们从解决您的评论开始:
no.it should be a useage problem.I have three peers in only one org. I need all of three signatures from endorsing peers. When l use docker logs dev-peer*... command to see the log from each peer container .lt get different value by random function.So,the transaction is executed three times. Now,I just want the transaction can’t be submitted. What is the endorsement policy should be
您定义的策略是:
"policy": {
"1-of": [
{
"signed-by": 0
}
]
}
其中 "signed-by": 0
是必须满足此规则的 MSP id 的索引。 IE。一个peer的单一背书基本上满足背书策略,而你需要确保所有执行都是一致的,因此在你的情况下你希望有多个peer来背书你的交易,因此你需要:
{
"identities": [
{
"role": {
"name": "member",
"mspId": "Org1MSP"
}
}
],
"policy": {
"3-of": [
{
"signed-by": 0
},
{
"signed-by": 0
},
{
"signed-by": 0
},
]
}
}
这意味着来自 Org1MSP 的所有 3 个节点都必须签署背书才能批准交易,而由于您使用的是随机函数,它将失败。
1.How can I set the endorsement-policy ?
你可以在实例化你的链码时提供背书策略,语法非常简单:
AND("Org1MSP.member")
基本上说您至少需要 Org1MSP
.
的有效成员的认可
- I think the endorsing peer is the only a peer , what's the meaning of 'member' or 'admin' ?
member
和 admin
是原则,它实际上为您提供了控制权,只要有东西需要由特权实体 (admin
) 或简单的实体背书或签名可能就足够了 (member
)。
So, I want make all of the three peers to be endorsing peers, how to config it ?
endorsing peer是安装了chaincode的peer,因此可以调用它并与之交互,不需要明确的配置就可以让peer成为endorsing peer,你只需要在上面安装chaincode。
Composer 会将交易发送给您 connection.json 文档中的所有 Peer。看起来所有人都在根据您在日志中看到的内容进行评估,但是因为背书只需要 1 个,所以我猜只有第一个响应的才会真正写入分类帐。 (设置 3 个业务网络卡,每个 connection.json 中定义一个对等点 - 然后从每个对等点检索数据应该确认这一点。)
我认为要求来自同一组织的 3 个节点 来背书(签署)交易是不常见的,更典型的情况是您之前尝试使用来自 2 个节点的 2 个节点组织。
当前,此处显示的策略有一个身份数组,其中包含 1 个元素,即角色。通过以下 2 个指向 Fabric Node SDK 文档的链接,我认为您可以指定特定身份而不是角色。因此,如果您真的想要来自同一组织的 3 个对等点,您将在身份数组中拥有对等点(来自 CA)的 3 个特定身份,并且在策略部分中您将拥有:
"policy": {
"3-of": [
{
"signed-by": 0
},
{
"signed-by": 1
},
{
"signed-by": 2
}
]
}
https://fabric-sdk-node.github.io/global.html#Policy
https://fabric-sdk-node.github.io/global.html#Identity
(我没有添加特定身份而不是角色的语法。)
当我使用管理员部署网络时,一个组织包括三个对等点。 我的背书-policy.json如下,无效
{
"identities": [
{
"role": {
"name": "member",
"mspId": "Org1MSP"
}
}
],
"policy": {
"1-of": [
{
"signed-by": 0
}
]
}
}
1.How 我可以设置背书政策吗? 2. 我认为背书节点是唯一的节点,'member' 或 'admin' 是什么意思?
所以,我想让三个节点都成为背书节点,如何配置?
就使您的 JSON 策略文件起作用而言,应该这样做:
{
"identities": [
{
"role": {
"name": "member",
"mspId": "Org1MSP"
}
}
],
"policy": {
"signed-by": 0
}
}
政策 JSON 的定义是 here
背书签名是针对每个组织的,因此如果您有多个组织,则只需在背书策略中添加额外的 "identities"。
让我们从解决您的评论开始:
no.it should be a useage problem.I have three peers in only one org. I need all of three signatures from endorsing peers. When l use docker logs dev-peer*... command to see the log from each peer container .lt get different value by random function.So,the transaction is executed three times. Now,I just want the transaction can’t be submitted. What is the endorsement policy should be
您定义的策略是:
"policy": {
"1-of": [
{
"signed-by": 0
}
]
}
其中 "signed-by": 0
是必须满足此规则的 MSP id 的索引。 IE。一个peer的单一背书基本上满足背书策略,而你需要确保所有执行都是一致的,因此在你的情况下你希望有多个peer来背书你的交易,因此你需要:
{
"identities": [
{
"role": {
"name": "member",
"mspId": "Org1MSP"
}
}
],
"policy": {
"3-of": [
{
"signed-by": 0
},
{
"signed-by": 0
},
{
"signed-by": 0
},
]
}
}
这意味着来自 Org1MSP 的所有 3 个节点都必须签署背书才能批准交易,而由于您使用的是随机函数,它将失败。
1.How can I set the endorsement-policy ?
你可以在实例化你的链码时提供背书策略,语法非常简单:
AND("Org1MSP.member")
基本上说您至少需要 Org1MSP
.
- I think the endorsing peer is the only a peer , what's the meaning of 'member' or 'admin' ?
member
和 admin
是原则,它实际上为您提供了控制权,只要有东西需要由特权实体 (admin
) 或简单的实体背书或签名可能就足够了 (member
)。
So, I want make all of the three peers to be endorsing peers, how to config it ?
endorsing peer是安装了chaincode的peer,因此可以调用它并与之交互,不需要明确的配置就可以让peer成为endorsing peer,你只需要在上面安装chaincode。
Composer 会将交易发送给您 connection.json 文档中的所有 Peer。看起来所有人都在根据您在日志中看到的内容进行评估,但是因为背书只需要 1 个,所以我猜只有第一个响应的才会真正写入分类帐。 (设置 3 个业务网络卡,每个 connection.json 中定义一个对等点 - 然后从每个对等点检索数据应该确认这一点。)
我认为要求来自同一组织的 3 个节点 来背书(签署)交易是不常见的,更典型的情况是您之前尝试使用来自 2 个节点的 2 个节点组织。
当前,此处显示的策略有一个身份数组,其中包含 1 个元素,即角色。通过以下 2 个指向 Fabric Node SDK 文档的链接,我认为您可以指定特定身份而不是角色。因此,如果您真的想要来自同一组织的 3 个对等点,您将在身份数组中拥有对等点(来自 CA)的 3 个特定身份,并且在策略部分中您将拥有:
"policy": {
"3-of": [
{
"signed-by": 0
},
{
"signed-by": 1
},
{
"signed-by": 2
}
]
}
https://fabric-sdk-node.github.io/global.html#Policy https://fabric-sdk-node.github.io/global.html#Identity
(我没有添加特定身份而不是角色的语法。)