请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

背书策略交易无效问题

已设置背书策略为 “AND(‘Org1.member’,‘Org2.member’,‘Org3.member’)”
已安装并实例化链码到 peer0.org1 peer0.org2 peer0.org3 (打算把这三个节点作为背书节点)
SDK客户端请求代码如下:

//执行链码
func exec (fname string,args [][]byte) (channel.Response,error){
	//生成通道上下文环境
	ctx := sdk.ChannelContext(channelID,fabsdk.WithOrg(org),fabsdk.WithUser(user))

	//实例化客户端
	cli,_:=channel.New(ctx)

	//操作
	//cli.Execute() // peer chaincode invoke -c '{"Args":["setValue","buyer","100"]}'  //只返回操作结果
	//cli.Query() // peer chaincode query  //返回查询内容
	return cli.Execute(channel.Request{
		ChaincodeID:chaincodeID,
		Fcn:fname,
		Args:args,
	},channel.WithTargetEndpoints("peer0.org1.example.com","peer0.org2.example.com","peer0.org3.example.com"))
}

执行后,执行响应状态码为200成功,实际数据未改变
收到响应如下:

{
  "Proposal": {
    "TxnID": "86c3a5777fa9da0561d2127f53a4e2615191c84c4a9c7233ab32c2ca23cac987",
    "header": "CmoIAxoMCKnPh/cFEPa5v7oBIgt0ZXN0Y2hhbm5lbCpAODZjM2E1Nzc3ZmE5ZGEwNTYxZDIxMjdmNTNhNGUyNjE1MTkxYzg0YzRhOWM3MjMzYWIzMmMyY2EyM2NhYzk4NzoJEgcSBWVzaG9wErsGCp4GCgdPcmcxTVNQEpIGLS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNHRENDQWIrZ0F3SUJBZ0lRRUsxUHltaDNPSGYxU2NmV1o2R2lNekFLQmdncWhrak9QUVFEQWpCek1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVpNQmNHQTFVRUNoTVFiM0puTVM1bGVHRnRjR3hsTG1OdmJURWNNQm9HQTFVRUF4TVRZMkV1CmIzSm5NUzVsZUdGdGNHeGxMbU52YlRBZUZ3MHlNREEyTVRFd09EQXhNRGxhRncwek1EQTJNRGt3T0RBeE1EbGEKTUZzeEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxVApZVzRnUm5KaGJtTnBjMk52TVI4d0hRWURWUVFEREJaQlpHMXBia0J2Y21jeExtVjRZVzF3YkdVdVkyOXRNRmt3CkV3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFRkE1a2NTbWcvNlpoQllONXlrT1dKTm5oR3U0UldleTIKdXpDTUFMdHk4a0RDd0duU0toS0NsR29tcFNGUC8zSUd6Ykxkbklxd1R6UHlQRm5aMlVSaWU2Tk5NRXN3RGdZRApWUjBQQVFIL0JBUURBZ2VBTUF3R0ExVWRFd0VCL3dRQ01BQXdLd1lEVlIwakJDUXdJb0FnaXgxV3VpcENDSFRPCk5xOHB0Nzg4YU9zeW81SkJtYUszbmR2dGU0VGp5WVF3Q2dZSUtvWkl6ajBFQXdJRFJ3QXdSQUlnTUFmTXBRbWMKdjRPS1NPTHUxZGRyYlo0emlzRW1peElCZG8zbmVzZEpmeVFDSUJLd1NhNERFOURWNjBKclBuM1I1M1h3NFhBbgpiU0lrUW1wc1RNWXdyWFNnCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KEhgDHMJfC0RtxLYAdBrJQyFpRdoRl4JVnqU=",
    "payload": "CigKJggBEgcSBWVzaG9wGhkKCHNldFZhbHVlCgVidXllcgoGMTUwMDAw"
  },
  "Responses": [
    {
      "Endorser": "localhost:7051",
      "Status": 200,
      "ChaincodeStatus": 200,
      "version": 1,
      "response": {
        "status": 200,
        "message": "OK"
      },
      "payload": "CiClshe/4xHjJ3DnOXkQckIu1kx1QnEQVeOAZfHhe1Q9UBJkCk0SNAoFZXNob3ASKxopCgVidXllchogeyJvd25lciI6ImJ1eWVyIiwidmFsdWUiOjE1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WdJRVR1ZmU3cUJxWUliVHdTb1hwa05FbkMKZjBRVm0razV3L0V6YUcvWjhYWT0KLS0tLS1FTkQgLS0tLS0K",
        "signature": "MEUCIQDkf9pNn4pXtJNJV/UwMeAHjg15uGiH0V75XYSGKu10swIgcL9tp7kISeW9fXXVa/TWJEVeg0VQ5GV2kblCcs4v4jc="
      }
    },
    {
      "Endorser": "localhost:9051",
      "Status": 200,
      "ChaincodeStatus": 200,
      "version": 1,
      "response": {
        "status": 200,
        "message": "OK"
      },
      "payload": "CiClshe/4xHjJ3DnOXkQckIu1kx1QnEQVeOAZfHhe1Q9UBJkCk0SNAoFZXNob3ASKxopCgVidXllchogeyJvd25lciI6ImJ1eWVyIiwidmFsdWUiOjE1MDAwMH0SFQoEbHNjYxINCgsKBWVzaG9wEgIIARoDCMgBIg4SBWVzaG9wGgUxLjAuMA==",
      "endorsement": {
        "endorser": "CgdPcmcyTVNQEoAGLS0tLS1CRUdJTiAtLS0tLQpNSUlDR1RDQ0FiK2dBd0lCQWdJUVpsK0RRZUYxcm5kRFZEODBKb3NSY3pBS0JnZ3Foa2pPUFFRREFqQnpNUXN3CkNRWURWUVFHRXdKVlV6RVRNQkVHQTFVRUNCTUtRMkZzYVdadmNtNXBZVEVXTUJRR0ExVUVCeE1OVTJGdUlFWnkKWVc1amFYTmpiekVaTUJjR0ExVUVDaE1RYjNKbk1pNWxlR0Z0Y0d4bExtTnZiVEVjTUJvR0ExVUVBeE1UWTJFdQpiM0puTWk1bGVHRnRjR3hsTG1OdmJUQWVGdzB5TURBMk1URXdPREF4TURsYUZ3MHpNREEyTURrd09EQXhNRGxhCk1Gc3hDekFKQmdOVkJBWVRBbFZUTVJNd0VRWURWUVFJRXdwRFlXeHBabTl5Ym1saE1SWXdGQVlEVlFRSEV3MVQKWVc0Z1JuSmhibU5wYzJOdk1SOHdIUVlEVlFRREV4WndaV1Z5TUM1dmNtY3lMbVY0WVcxd2JHVXVZMjl0TUZrdwpFd1lIS29aSXpqMENBUVlJS29aSXpqMERBUWNEUWdBRXlFajZCU1lqeWtFRzRHYWR4SVZMYnNpMWptMzV1bno0CkZDbzd2K2lJc1JpMGZ6Mjg1dThkLysxalpnbmowUlRzMUFneGZxREMyUlNuSlE5aXNWcXhwcU5OTUVzd0RnWUQKVlIwUEFRSC9CQVFEQWdlQU1Bd0dBMVVkRXdFQi93UUNNQUF3S3dZRFZSMGpCQ1F3SW9BZ3c1dTV1RGhrcUt6dwpSRTBXVEZpYWdwMkl2U1g5U05hYTJicjVrbnE2RVpNd0NnWUlLb1pJemowRUF3SURTQUF3UlFJaEFQUkNxc2tqCkhndnZ1NHh5cG1tVXRGTG1WcU94RU4wbjVQUXlla29zYWF1dEFpQXNlTk02L0hRTE1JK255dUlwdVJxbWN2ZUoKZWl5RFBMaGVMZGtYK3hYMlBRPT0KLS0tLS1FTkQgLS0tLS0K",
        "signature": "MEUCIQD1/9ONHDtcvdaMi3Vp25Jv9OasXdaTfTh2tnM1Wrh5AgIgKcjE0rSYpH2gQYzkgrxXoG49dFvhBXHwWxlquvVBddg="
      }
    },
    {
      "Endorser": "localhost:11051",
      "Status": 200,
      "ChaincodeStatus": 200,
      "version": 1,
      "response": {
        "status": 200,
        "message": "OK"
      },
      "payload": "CiClshe/4xHjJ3DnOXkQckIu1kx1QnEQVeOAZfHhe1Q9UBJkCk0SNAoFZXNob3ASKxopCgVidXllchogeyJvd25lciI6ImJ1eWVyIiwidmFsdWUiOjE1MDAwMH0SFQoEbHNjYxINCgsKBWVzaG9wEgIIARoDCMgBIg4SBWVzaG9wGgUxLjAuMA==",
      "endorsement": {
        "endorser": "CgdPcmczTVNQEoAGLS0tLS1CRUdJTiAtLS0tLQpNSUlDR1RDQ0FiK2dBd0lCQWdJUUhJVzFnSzlmZTFrWk1uV2k5WjBxM0RBS0JnZ3Foa2pPUFFRREFqQnpNUXN3CkNRWURWUVFHRXdKVlV6RVRNQkVHQTFVRUNCTUtRMkZzYVdadmNtNXBZVEVXTUJRR0ExVUVCeE1OVTJGdUlFWnkKWVc1amFYTmpiekVaTUJjR0ExVUVDaE1RYjNKbk15NWxlR0Z0Y0d4bExtTnZiVEVjTUJvR0ExVUVBeE1UWTJFdQpiM0puTXk1bGVHRnRjR3hsTG1OdmJUQWVGdzB5TURBMk1URXdPREF4TURsYUZ3MHpNREEyTURrd09EQXhNRGxhCk1Gc3hDekFKQmdOVkJBWVRBbFZUTVJNd0VRWURWUVFJRXdwRFlXeHBabTl5Ym1saE1SWXdGQVlEVlFRSEV3MVQKWVc0Z1JuSmhibU5wYzJOdk1SOHdIUVlEVlFRREV4WndaV1Z5TUM1dmNtY3pMbVY0WVcxd2JHVXVZMjl0TUZrdwpFd1lIS29aSXpqMENBUVlJS29aSXpqMERBUWNEUWdBRURvUkpKS1l4SDAxeXRKRm0rOGxMdXpKZU9mbEdncStzCmd0NHE3U3hOclVtdGozVCtFRDVIc3Y0RHRYVnpvVUorQ3k3bkRqOTFMUllhOFUwaENDeWlucU5OTUVzd0RnWUQKVlIwUEFRSC9CQVFEQWdlQU1Bd0dBMVVkRXdFQi93UUNNQUF3S3dZRFZSMGpCQ1F3SW9BZ25EQ3VMWG1Lc3RxdApKaWhMRDlzZjFpUHdVK0JYU1NjWVlVY0s3K09rdnpzd0NnWUlLb1pJemowRUF3SURTQUF3UlFJaEFPNW5GU3V6CldDS3JNdlZSdTFHK0gvaDZ1bzFPb01XSVZqZmdxRjRUWkZYb0FpQlBGRndxZnpseWRWUXM1c2RpU21PcFhSUnQKNzZwRlpZTit4T0dmdTRCUzhRPT0KLS0tLS1FTkQgLS0tLS0K",
        "signature": "MEQCIAgBCrJNy5QQOJ7P6GShr8ezYMX/24LmeWl2mRZTlQwyAiBUiOh2SYjL5t6wA6CuprSddztt2XnjVJlzQuRBaGZfVg=="
      }
    }
  ],
  "TransactionID": "86c3a5777fa9da0561d2127f53a4e2615191c84c4a9c7233ab32c2ca23cac987",
  "TxValidationCode": 10,
  "ChaincodeStatus": 200,
  "Payload": null
}

可以看到,分别收到来自三个背书节点的响应,并具有相同多endorser和各自多signature
但TxValidationCode为10,交易验证失败
状态码10代表什么含义?
应当如何解决?

感谢指导

正在回答 回答被采纳积分+3

3回答

自游蜗牛 2020-06-20 21:58:09

https://git.imooc.com/coding-268/coding-268/src/release-1.0/protos/peer/transaction.pb.go#L30

TxValidationCode_ENDORSEMENT_POLICY_FAILURE   TxValidationCode = 10

10 的意思是不满足背书策略。

我的推断:

你生成cli的时候使用的ctx是用的同一个org以及同一个user。那么这三个提案就相当于1个org的user在三个组织的节点进行了交易。

看官方文档:

A principal is described in terms of the MSP that is tasked to validate the identity of the signer and of the role that the signer has within that MSP. Four roles are supported: member, admin, client, and peer. Principals are described as MSP.ROLE, where MSP is the MSP ID that is required, and ROLE is one of the four strings member, admin, client and peer. Examples of valid principals are 'Org0.admin' (any administrator of the Org0 MSP) or 'Org1.member' (any member of the Org1 MSP), 'Org1.client' (any client of the Org1 MSP), and 'Org1.peer' (any peer of the Org1 MSP).

对Member的定义是user或者admin。是用户证书。


那么你这里其实是用了同一个org的member三次。并不满足你定义的三个组织的member这个policy。所以交易报错了。你可以试着改成peer类型的背书策略。

0 回复 有任何疑惑可以回复我~
自游蜗牛 2020-06-11 22:42:11

把其他的都删了吧,我在这里回答

0 回复 有任何疑惑可以回复我~
自游蜗牛 2020-06-11 22:41:14

你中病毒了吗?

0 回复 有任何疑惑可以回复我~
  • 提问者 酒醉一斤半 #1
    老师好。因为提问内容被检测出敏感词,需要系统审核。和客服沟通的过程中进行了多次提交测试。已联系慕课网后台人员,将于明早删除多余提问。打扰了
    回复 有任何疑惑可以回复我~ 2020-06-11 22:50:49
  • 自游蜗牛 回复 提问者 酒醉一斤半 #2
    嗯,这个我周末看一下,最近有些忙。
    回复 有任何疑惑可以回复我~ 2020-06-11 22:52:22
  • 提问者 酒醉一斤半 回复 自游蜗牛 #3
    辛苦了
    回复 有任何疑惑可以回复我~ 2020-06-11 22:54:06
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信