当前位置: 首页 > 知识库问答 >
问题:

来自hyperledger fabric JAVA SDK的多个组织的认可

甄华清
2023-03-14

为了与网络通信,我使用JAVA SDK V1.4.1。我能够注册,创建高频客户机和渠道等,也能够创建用户和查询(读取)区块链没有任何问题。

我面临的问题是当试图使用'invoke'函数更新区块链时。

下面是我在JAVA端看到的stacktrace

2019-07-17 23:34:41,811 INFO  [http-nio-8080-exec-6] com.invincible.ngi.service.UtilityService: New channel initialized:mychannel
2019-07-17 23:34:41,812 INFO  [http-nio-8080-exec-6] com.invincible.ngi.service.UtilityService: Order added to the channel:orderer.example.com
2019-07-17 23:34:41,813 INFO  [http-nio-8080-exec-6] com.invincible.ngi.service.UtilityService: Peer added to the channel:peer0.org1.example.com
2019-07-17 23:34:43,570 INFO  [http-nio-8080-exec-6] org.hyperledger.fabric.sdk.Channel: Channel Channel{id: 6, name: mychannel} eventThread started shutdown: false  thread: null 
2019-07-17 23:34:46,696 ERROR [http-nio-8080-exec-6] com.invincible.ngi.service.QueryService: org.hyperledger.fabric.sdk.exception.TransactionEventException: Received invalid transaction event. Transaction ID 753436574ea481148f9d2da7d793f0ff1630c0c4b3106995240cf8b73aa1f1db status 10
java.util.concurrent.ExecutionException: org.hyperledger.fabric.sdk.exception.TransactionEventException: Received invalid transaction event. Transaction ID 753436574ea481148f9d2da7d793f0ff1630c0c4b3106995240cf8b73aa1f1db status 10
    at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
    at com.invincible.ngi.service.QueryService.updateBlockChain(QueryService.java:56)
    at com.invincible.ngi.resource.QueryResource.updateQuery(QueryResource.java:44)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.hyperledger.fabric.sdk.exception.TransactionEventException: Received invalid transaction event. Transaction ID 753436574ea481148f9d2da7d793f0ff1630c0c4b3106995240cf8b73aa1f1db status 10
    at org.hyperledger.fabric.sdk.Channel$TL.lambda$fire$2(Channel.java:6227)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    ... 1 common frames omitted
2019-07-17 23:34:46,703 ERROR [http-nio-8080-exec-6] org.apache.juli.logging.DirectJDKLog: Servlet.service() for servlet [dispatcherServlet] in context with path [/api] threw exception [Request processing failed; nested exception is java.util.concurrent.ExecutionException: org.hyperledger.fabric.sdk.exception.TransactionEventException: Received invalid transaction event. Transaction ID 753436574ea481148f9d2da7d793f0ff1630c0c4b3106995240cf8b73aa1f1db status 10] with root cause
org.hyperledger.fabric.sdk.exception.TransactionEventException: Received invalid transaction event. Transaction ID 753436574ea481148f9d2da7d793f0ff1630c0c4b3106995240cf8b73aa1f1db status 10
    at org.hyperledger.fabric.sdk.Channel$TL.lambda$fire$2(Channel.java:6227)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
    Channel channel = client.newChannel(ngiProperties.getChannel());
    logger.info("New channel initialized:" + ngiProperties.getChannel());
    Properties ordererProperties = new Properties();
    ordererProperties.setProperty("pemFile", ngiProperties.getOrdererServerCert());
    ordererProperties.setProperty("trustServerCertificate", ngiProperties.getOrdererTrustServerCertificate());
    ordererProperties.setProperty("hostnameOverride", ngiProperties.getOrdererHostnameOverride());
    ordererProperties.setProperty("sslProvider", ngiProperties.getOrdererSslProvider());
    ordererProperties.setProperty("negotiationType", ngiProperties.getOrdererNegotiationType());
    ordererProperties.put("grpc.NettyChannelBuilderOption.keepAliveTime", new Object[]{ngiProperties.getOrdererKeepAliveTime(), TimeUnit.MINUTES});
    ordererProperties.put("grpc.NettyChannelBuilderOption.keepAliveTimeout", new Object[]{ngiProperties.getOrdererKeepAliveTimeout(), TimeUnit.SECONDS});
    channel.addOrderer(client.newOrderer(ngiProperties.getOrdererHost(), ngiProperties.getOrdererGrpc(), ordererProperties));
    logger.info("Order added to the channel:" + ngiProperties.getOrdererHost()); // orderer.example.com
    Properties peerProperties = new Properties();
    peerProperties.setProperty("pemFile", ngiProperties.getPeerAServerCert());
    peerProperties.setProperty("trustServerCertificate", ngiProperties.getPeerATrustServerCertificate());
    peerProperties.setProperty("hostnameOverride", ngiProperties.getPeerAHostnameOverride());
    peerProperties.setProperty("sslProvider", ngiProperties.getPeerASslProvider());
    peerProperties.setProperty("negotiationType", ngiProperties.getPeerANegotiationType());
    channel.addPeer(client.newPeer(ngiProperties.getPeerAHost(), ngiProperties.getPeerAGrpc(), peerProperties));
    logger.info("Peer added to the channel:" + ngiProperties.getPeerAHost()); // peer0.org1.example.com
    channel.initialize();
    peerProperties = new Properties();
    peerProperties.setProperty("pemFile", ngiProperties.getPeerCServerCert());
    peerProperties.setProperty("trustServerCertificate", ngiProperties.getPeerCTrustServerCertificate());
    peerProperties.setProperty("hostnameOverride", ngiProperties.getPeerCHostnameOverride());
    peerProperties.setProperty("sslProvider", ngiProperties.getPeerCSslProvider());
    peerProperties.setProperty("negotiationType", ngiProperties.getPeerCNegotiationType());
    channel.addPeer(client.newPeer(ngiProperties.getPeerCHost(), ngiProperties.getPeerCGrpc(), peerProperties));
    logger.info("Peer added to the channel:" + ngiProperties.getPeerCHost()); // peer0.org2.example.com

我有几个问题

  1. 如果交易的有效性仅仅通过在通道初始化中添加所需的背书对等方来实现,那么实施背书规则的意义何在?如果org1设法获得了org2的对等详细信息,那么org1可以提交事务而无需得到org2的同意?
  2. 设置向HFClient提交事务的用户有什么意义?fabric在事务处理过程中在何处以及如何验证用户上下文及其注册?
  3. 理想情况下,如果我有和('org1msp.peer','org2msp.peer')作为认可策略,并且有一个UI来提交事务,那么HFClient中的用户上下文集应该有'org1msp.peer'签名,并且应该通知org2中具有'org2msp.peer'的用户提交了转换。只有当具有签名'org2msp.peer'的任何用户签名时,才应该提交事务。所有这些都应该发生,而不管我使用了多少对等点来初始化信道。我的期望有效吗?如果是,如何用fabric JAVA SDK实现它?

共有1个答案

尚阳炎
2023-03-14

如果仅仅通过在通道初始化中添加所需的背书对等方来实现事务的有效性,那么实施背书规则的意义何在?如果org1设法获得了org2的对等细节,org1可以提交事务而不需要org2的同意?

>

  • 认可对等点是安装链码的对等点。现在,当您的客户发送交易提案以进行背书时,它首先在fabric运行时检查背书策略。在您的示例中,它是和('org1msp.peer','org2msp.peer'),这意味着两个代言者都应该返回建议响应,但通道上只有一个对等点,因此它在第一步本身失败,因为它不符合代言策略规则。**背书政策的实施提供了一种方法来管理由一个同行和双重支出篡改数据。**这里有一个非常详细的概述。

    由于网络是html" target="_blank">分布式的,我几乎不认为任何组织可以访问任何其他组织的证书。

    P.S.交易签署是一个自动化的过程,没有组织会让人手动签署交易。

    希望这能有所帮助。

    设置向HFClient提交事务的用户有什么意义?在事务处理过程中,fabric在哪里以及如何验证用户上下文及其注册?

    例如,当org1想要改变汽车的所有权时,当数据提交时,将知道是谁改变了汽车的所有权。

  •  类似资料:
    • 如果数据集返回或为空,那么按顺序分配变量的最干净方法是什么?我在Java工作。 伪代码: 我知道。包含地图存在的;我使用的真正代码不是地图,但这应该是一个不错的例子。 我可以这样分解,当然,但看起来还是不太好: 有没有更干净的方法?有真正的大脑打嗝。

    • 我有一个类实现了多个具有相同默认方法的接口。我想知道如何从所有接口合成默认方法。例如: 复合模式也相当可观。但是我想用default方法作为mixin来给类不同的行为,而复合模式在这里没有给我静态类型检查。复合模式还引入了额外的内存占用。

    • 问题内容: 如何从MySQL的多个表中选择COUNT(*)? 如: 编辑: 目标是返回此: 问题答案: 您可以通过使用子查询来实现,每个tableCount一个子查询:

    • 我正在尝试使用火花 JDBC 从 SAS IOM 读取数据。问题是SAS JDBC驱动程序有点奇怪,所以我需要创建自己的方言: 然而,这还不够。SAS区分了列标签(=人类可读的名称)和列名称(=您在SQL查询中使用的名称),但似乎Spark在模式发现中使用列标签而不是名称,请参阅下面的JdbcUtils摘录: https://github.com/apache/spark/blob/master/

    • 部署Hyperledger Composer网络到多组织Fabric 原文:Deploying a Hyperledger Composer blockchain business network to Hyperledger Fabric (multiple organizations) 这个教程示范了在多组织场景下的管理员部署一个区块链业务网络到某Hyperledger Fabric实例必须执

    • 我正在学习关于将Hyperledger Composer区块链业务网络部署到Hyperledger Fabric(多个组织)的官方教程。我能够使用提供程序Org1和Org2示例来启动网络。现在我想将组织自定义为我自己的组织。但是在执行。/byfn.sh-m up-s couchdb-a命令时。我得到以下错误;我检查了所有的yaml文件,但我无法找到错误的可能根本原因。我只是真的需要帮助。谢谢你。