A consensus transaction tracking method, device, equipment and storage medium

By intercepting GRPC services in blockchain technology and generating Trace data, the problem of difficult tracking of consensus transaction trajectories is solved, and effective supervision and anomaly detection of consensus transactions are achieved.

CN115129554BActive Publication Date: 2025-09-19AGRICULTURAL BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210835635.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-15
Publication Date
2025-09-19
Estimated Expiration
2042-07-15

AI Technical Summary

Technical Problem

Existing blockchain technology lacks effective means of tracking transaction trajectories during the consensus process, making it difficult for regulators to collect and analyze transaction information of node consensus and unable to detect and analyze abnormal data.

Method used

After intercepting the GRPC service in the distributed tracing component, a Span for the GRPC service is created and Trace data is generated. The Jaeger distributed tracing component listens on the port to obtain and display the Trace data, thus tracking the consensus transaction.

Benefits of technology

It achieves effective tracking of consensus transactions, facilitates subsequent abnormal data detection and analysis, and improves the supervision and management capabilities of the blockchain consensus process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115129554B_ABST
    Figure CN115129554B_ABST
Patent Text Reader

Abstract

The present invention discloses a consensus transaction tracking method, apparatus, device, and storage medium. The method comprises: after intercepting a GRPC service through a distributed tracing component, creating a span for the GRPC service; generating trace data based on the span of the GRPC service; obtaining the trace data through a listening port, and displaying the trace data. The technical solution of the present invention enables tracking of consensus transactions, thereby facilitating subsequent in-depth research on abnormal data detection and analysis during the blockchain consensus process based on the tracked node consensus transaction data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a consensus transaction tracking method, apparatus, device, and storage medium. Background Art

[0002] Thanks to blockchain's advantages of transparency, traceability, consensus trust, and decentralization, blockchain technology has gradually penetrated various sectors, including finance, logistics traceability, and education. Consensus is crucial for maintaining the consistency of blockchain ledger states. Tracking the consensus-reaching transaction trajectories across blockchain nodes helps blockchain regulators identify the node consensus topology for different transactions, effectively managing the participants in each transaction. However, the decentralized nature of blockchain technology fragments regulatory bodies, and the anonymity and immutability of blockchains make it difficult to enforce content regulation of on-chain data, making it difficult for blockchain regulators to collect and analyze transaction information reached by different nodes. Furthermore, existing blockchain ledger data analysis tools are insufficient for analyzing the consensus process of a transaction. Most only analyze pre- and post-consensus data, lacking full tracking of the consensus process. Summary of the Invention

[0003] The embodiments of the present invention provide a consensus transaction tracking method, apparatus, device, and storage medium to enable tracking of consensus transactions, thereby facilitating subsequent in-depth research on abnormal data detection and analysis in the blockchain consensus process based on the tracked node consensus transaction data.

[0004] According to one aspect of the present invention, a consensus transaction tracking method is provided, comprising:

[0005] After intercepting the GRPC service through the distributed tracing component, create the Span of the GRPC service;

[0006] Generate Trace data based on the Span of the GRPC service;

[0007] Acquire trace data through the listening port and display the trace data.

[0008] According to another aspect of the present invention, a consensus transaction tracking device is provided, the consensus transaction tracking device comprising:

[0009] Create a module for creating a span for the GRPC service after intercepting it through the distributed tracing component;

[0010] A data generation module is used to generate Trace data according to the Span of the GRPC service;

[0011] The data display module is used to obtain trace data through the monitoring port and display the trace data.

[0012] According to another aspect of the present invention, an electronic device is provided, comprising:

[0013] at least one processor; and

[0014] a memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the consensus transaction tracking method described in any embodiment of the present invention.

[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the consensus transaction tracking method described in any embodiment of the present invention when executed.

[0017] The embodiment of the present invention creates a Span of the GRPC service after intercepting the GRPC service through a distributed tracing component; generates Trace data based on the Span of the GRPC service; obtains the Trace data through a listening port, and displays the Trace data, thereby tracing consensus transactions, thereby facilitating subsequent in-depth research on abnormal data detection and analysis in the blockchain consensus process based on the tracked node consensus transaction data.

[0018] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.

[0020] Figure 1 is a flow chart of a consensus transaction tracking method according to an embodiment of the present invention;

[0021] Figure 2 It is a flowchart illustrating the consensus transaction between nodes in the Hyperledger Fabric consensus process in an embodiment of the present invention;

[0022] Figure 3 This is a flowchart of the working principle of the Jaeger distributed tracing component in an embodiment of the present invention;

[0023] Figure 4 This is a flowchart of a method for tracking node consensus transactions for Hyperledger Fabric in an embodiment of the present invention;

[0024] Figure 5 It is a structural diagram of a consensus transaction tracking device in an embodiment of the present invention;

[0025] Figure 6 It is a structural diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0027] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] Example 1

[0029] Figure 1 This is a flowchart of a consensus transaction tracking method provided by an embodiment of the present invention. This embodiment is applicable to the case of consensus transaction tracking. The method can be executed by the consensus transaction tracking device in the embodiment of the present invention. The device can be implemented in software and / or hardware. Figure 1 As shown, the method specifically includes the following steps:

[0030] S110, after intercepting the GRPC service through the distributed tracing component, create a Span of the GRPC service.

[0031] Among them, distributed tracing refers to the technology used to track the process from user-initiated request to returned response in a distributed system. For example, it can be to restore a distributed request into a call link and display it centrally. The display content may include: the time consumption of each service node, where the request is initiated and where it goes, the status of the service node, the parameters carried in the request or response, etc.

[0032] GRPC is a high-performance, open-source RPC framework launched by Google. It's designed and developed based on the HTTP2 protocol standard, uses the Protocol Buffers data serialization protocol by default, and supports development in multiple languages, including Java, Golang, and Python. The internal services involved in the consensus process across different nodes in Hyperledger Fabric are implemented using GRPC.

[0033] Span is a term used in Opentracing to represent the smallest tracing structure in the distributed tracing framework. Specifically, it refers to a logical unit in the system with a start time and execution duration, used to record data for a single call. OpenTracing is a lightweight, standardized layer that provides a set of platform- and vendor-independent APIs. Developers can use these APIs to connect to different distributed link tracing frameworks, thus resolving API incompatibilities between different distributed tracing frameworks.

[0034] Among them, Span includes: transaction information and Span identifier. Span can also include: Trace identifier. For example, if the GRPC service is a request service, then Span includes: transaction information, Span identifier and Trace identifier. If the GRPC service is a response service, then Span includes: transaction information and Span identifier. Among them, the transaction information includes: transaction ID and channel ID.

[0035] Specifically, after intercepting the GRPC service through the distributed tracing component, the Span of the GRPC service can be created by: updating the Hyperledger Fabric source code according to the distributed tracing component package; generating a target image and a target application according to the updated Hyperledger Fabric source code; deploying the Hyperledger Fabric blockchain according to the target image and the target application; intercepting the GRPC service through the distributed tracing component; and creating the Span of the GRPC service. For example, when the Client node requests the endorsement service, a first Span is created; when the Endorser Peer node responds to the endorsement service, a second Span is created; when the Client node requests the broadcast service, a third Span is created; when the Orderer node responds to the broadcast service, a fourth Span is created; when the Leader Peer node requests the Orderer node to obtain the block service, a fifth Span is created; when the Orderer node discovers that a new block has been generated, the Orderer node responds to the Leader Peer node with a block distribution service, thereby creating a sixth Span.

[0036] S120: Generate Trace data according to the Span of the GRPC service.

[0037] Trace data refers to the professional term in Opentracing, which represents the complete execution process of a transaction or process in a distributed system. A trace is a directed acyclic graph composed of multiple spans.

[0038] Specifically, the method for generating Trace data based on the Span of the GRPC service may be: if the GRPC service is a request service, the Span includes: first transaction information, a first Span identifier, and a first Trace identifier, and first Trace data corresponding to the first Trace identifier is generated based on the first transaction information, the first Span identifier, and the first Trace identifier. If the GRPC service is a response service, the Span includes: second transaction information and a second Span identifier, and second Trace data corresponding to the first Trace identifier is generated based on the second transaction information, the first Span identifier, the second Span identifier, and the first Trace identifier.

[0039] S130: Acquire trace data through the monitoring port and display the trace data.

[0040] Specifically, the method of obtaining Trace data by listening to the port and displaying the Trace data can be: obtaining Trace data by listening to the UDP port and displaying the Trace data. Taking the Jaeger distributed tracing component as an example: obtaining Trace data sent by the jaeger-client package by listening to the UDP port, and regularly sending the collected Trace data batches to the jaeger-collector according to the set sampling frequency. The jaeger-collector is used to receive data from the jaeger-agent and process the received data through the pipeline, such as verifying the Trace data, creating indexes, etc., and finally storing the converted Trace data in the data source. The jaeger-query is used to query Trace data from the data source, and the jaeger-ui is used to visualize Trace information. The Trace contains Span information, call relationships, etc.

[0041] Optionally, when the service type of the GRPC service is a request service, the Span of the GRPC service includes: first transaction information, a first Span identifier, and a first Trace identifier, and the first transaction information includes: a first transaction ID and a first channel ID;

[0042] Correspondingly, Trace data is generated according to the Span of the GRPC service, including: generating first Trace data corresponding to the first Trace identifier according to the first transaction information, the first Span identifier and the first Trace identifier, and injecting the Span of the GRPC service into the HTTP Header.

[0043] The GRPC service includes at least one of: a request endorsement service, a response endorsement service, a request broadcast service, a response broadcast service, a request block distribution service, a response block distribution service, a message forwarding service, and a message processing service.

[0044] Among them, if the GRPC service is any one of the request endorsement service, request broadcast service, request block distribution service and message forwarding service, the service type of the GRPC service is request service.

[0045] Specifically, the method of generating the trace data corresponding to the first trace identifier according to the first transaction information, the first span identifier and the first trace identifier can be: storing the first transaction information and the first span identifier in the area corresponding to the first trace identifier to obtain the trace data corresponding to the first trace identifier.

[0046] Optionally, when the service type of the GRPC service is a response service, the Span of the GRPC service includes: second transaction information and a second Span identifier, and the second transaction information includes: a first transaction ID and a first channel ID;

[0047] Accordingly, trace data is generated based on the span of the GRPC service, including:

[0048] Get the Span of the request service corresponding to the GRPC service from the HTTP Header;

[0049] Second trace data corresponding to the first trace identifier is generated according to the second transaction information, the second span identifier, the first span identifier, and the first trace identifier.

[0050] Among them, if the GRPC service is any one of the response endorsement service, response broadcast service, response block distribution service and message processing service, the service type of the GRPC service is response service.

[0051] Optionally, generating second trace data corresponding to the first trace identifier according to the second transaction information, the second span identifier, the first span identifier, and the first trace identifier includes:

[0052] Determine the first Span identifier as the parent identifier of the second Span identifier;

[0053] Second trace data corresponding to the first trace identifier is generated according to the parent identifier of the second span identifier, the second span identifier, the first trace identifier, and the second transaction information.

[0054] It should be noted that if Figure 2 As shown in the figure, the consensus transaction process between nodes in the Hyperledger Fabric consensus process and the working principle of gRPC are as follows:

[0055] (1) The Endorser Peer node initiates a transaction proposal request for endorsement via the command line or the SDK provided by Hyperledger Fabric. This endorsement request is a gRPC service. When the Endorser Peer node receives the request, it starts the chaincode container to simulate the transaction execution, signs the simulation execution result, and returns it to the Client node.

[0056] (2) After the Client node collects enough endorsement results returned by the Endorser Peer node according to the endorsement strategy, it will initiate a gRPC call. Specifically, it submits the transaction to the Orderer node through the broadcast service to request that the transaction be sorted.

[0057] (3) The Orderer node sorts transactions according to the configured block rules, packages a batch of transaction information and constructs new block data, and then calls the gRPC service. Specifically, the block distribution service distributes the packaged block data to the Leader Peer nodes of each organization.

[0058] (4) The Leader Peer node of each organization uses the Gossip protocol and calls the gRPC service to synchronize the blocks to the Ordinary Peer node of the corresponding organization, that is, other nodes of the same organization except the Leader Peer node, until the ledger data remains consistent.

[0059] The above four steps outline the general flow of a Hyperledger Fabric consensus transaction. The endorsement service, broadcast service, block distribution service, and block synchronization service all communicate using gRPC services. Therefore, leveraging the concept of distributed chain tracing, gRPC interceptors can be introduced during gRPC calls. These interceptors intercept incoming requests and responses and establish the order and call relationships between services. Specifically, each intercepted request or response is encapsulated into a span, which carries information such as the parent ID, the span's own ID, and the service invoked by the request or response. The span is then injected into an HTTP header and sent over the network to the recipient. The recipient retrieves the span from the HTTP header and establishes a correspondence between the parent and child IDs on the recipient's side. This allows the recipient to correlate the sender's span information, forming a call chain from the sender to the receiver. Therefore, any component that conforms to the distributed chain tracing concept of maintaining spans, such as Zipkin and Jaeger, can be used.

[0060] The specific process of the consensus transaction tracking method is as follows:

[0061] When the client node requests the endorsement service, a first span is created, where the first span includes: first transaction information, a first span identifier, and a first trace identifier;

[0062] Generate first trace data corresponding to the first trace identifier according to the first transaction information, the first span identifier, and the first trace identifier, and inject the first trace data into an HTTP header;

[0063] When the Endorser Peer node responds to the endorsement service, a second Span is created, wherein the second Span includes: second transaction information and a second Span identifier;

[0064] Get the first span from the HTTP header;

[0065] generating second trace data corresponding to the first trace identifier according to the second transaction information, the first span identifier, the second span identifier, and the first trace identifier, wherein the transaction ID and the channel ID in the first transaction information are the same as the transaction ID and the channel ID in the second transaction information;

[0066] When the client node requests the broadcast service, a third span is created, where the third span includes: third transaction information, a third span identifier, and a second trace identifier;

[0067] Generate third trace data corresponding to the second trace identifier according to the third transaction information, the third span identifier, and the second trace identifier, and inject the third trace data into the HTTP header;

[0068] When the Orderer node responds to the broadcast service, a fourth Span is created, where the fourth Span includes: fourth transaction information and a fourth Span identifier;

[0069] Get the third Span from the HTTP Header;

[0070] generating fourth trace data corresponding to the second trace identifier based on the fourth transaction information, the third span identifier, the fourth span identifier, and the second trace identifier, wherein the transaction ID and the channel ID in the third transaction information are the same as the transaction ID and the channel ID in the fourth transaction information;

[0071] When the Leader Peer node requests the Orderer node to obtain block services, a fifth Span is created, wherein the fifth Span includes: fifth transaction information, a fifth Span identifier, and a third Trace identifier;

[0072] generating fifth trace data corresponding to the third trace identifier according to the fifth transaction information, the fifth span identifier, and the third trace identifier, and injecting the fifth trace data into an HTTP header;

[0073] When the Orderer node discovers that a new block is generated, the Orderer node responds to the Leader Peer node for block distribution service and creates a sixth Span, wherein the sixth Span includes: sixth transaction information and a sixth Span identifier;

[0074] Get the fifth Span from the HTTP Header;

[0075] generating sixth trace data corresponding to the third trace identifier based on the sixth transaction information, the fifth span identifier, the sixth span identifier, and the third trace identifier, wherein the transaction ID and the channel ID in the fifth transaction information are the same as the transaction ID and the channel ID in the sixth transaction information;

[0076] After the Leader Peer node receives the block data, it creates the seventh Span when forwarding the block data to the Committer Peer node through the Gossip protocol. The seventh Span includes: the seventh transaction information, the seventh Span identifier, and the fourth Trace identifier.

[0077] Generate seventh trace data corresponding to the fourth trace identifier according to the seventh transaction information, the seventh span identifier, and the fourth trace identifier, and inject the seventh trace data into the HTTP header;

[0078] After receiving the Goosip message, the Committer Peer node creates an eighth span when synchronizing the block to its respective ledger. The eighth span includes: the eighth transaction information and the eighth span identifier.

[0079] Get the seventh span from the HTTP Header;

[0080] Eighth trace data corresponding to the fourth trace identifier is generated according to the eighth transaction information, the seventh span identifier, the eighth trace identifier, and the fourth trace identifier, wherein the transaction ID and the channel ID in the seventh transaction information are the same as the transaction ID and the channel ID in the eighth transaction information.

[0081] It should be noted that the transaction ID and channel ID in the first transaction information, the second transaction information, the third transaction information, the fourth transaction information, the fifth transaction information, the sixth transaction information, the seventh transaction information, and the eighth transaction information are all the same.

[0082] The client node refers to the client node that interacts with the Hyperledger Fabric network. It can interact with the Hyperledger Fabric network by calling the API or SDK provided by Hyperledger Fabric, or directly through the CLI command line terminal.

[0083] Among them, the Endorser Peer node refers to the Peer node that serves as an endorsement in the Hyperledger Fabric network.

[0084] The Orderer node refers to the Orderer node used for sorting in the Hyperledger Fabric network.

[0085] The Leader Peer node is the primary / leading peer node set up in the Hyperledger Fabric network. It is mainly used to relieve the pressure on the Orderer node in distributing blocks. By setting up the Leader Peer node, the Orderer node does not need to distribute blocks to all peer nodes in the specified channel, but only to the Leader Peer node.

[0086] A committer peer node is a peer node in the Hyperledger Fabric network that keeps accounts. A committer peer node extracts block data from gossip messages, verifies the validity of the block data, and commits the block to the local ledger after verification.

[0087] Optionally, before intercepting the GRPC service through the distributed tracing component, the following is also included:

[0088] Update the Hyperledger Fabric source code according to the distributed tracing component package;

[0089] Generate the target image and target application based on the updated Hyperledger Fabric source code;

[0090] Deploy the Hyperledger Fabric blockchain based on the target image and target application.

[0091] The method for updating the Hyperledger Fabric source code according to the distributed tracing component package may be: adding a distributed link tracing component package to the Hyperledger Fabric source code.

[0092] It's important to note that due to Golang's limited access to different packages, the client package for distributed link tracing must be imported into a location that can access Hyperledger Fabric's gRPC public library. For example, in Hyperledger Fabric V2.0, the public library related to gRPC services is located in the fabric / internal / pkg / comm package. The Hyperledger Fabric gRPC public library is modified. A target image and target application are generated based on the modified Hyperledger Fabric gRPC public library. The Hyperledger Fabric blockchain is then deployed using these target images and applications.

[0093] Optionally, the GRPC service includes at least one of: a request endorsement service, a response endorsement service, a request broadcast service, a response broadcast service, a request block distribution service, a response block distribution service, a message forwarding service, and a message processing service.

[0094] The "endorsement service" in this embodiment of the present invention refers to the endorsement service provided by Hyperledger Fabric. Specifically, it is the "ProcessProposal" gRPC service in the peer / peer.proto path in the fabric-proto project. The client of this service is the Client node, and the server is the Peer node. Upon startup, the Peer node registers the endorsement service with the local gRPC server. The endorsement service receives endorsement requests from the Client node, then launches the user chaincode to simulate the transaction execution, and finally signs the simulated execution results and returns them to the Client node.

[0095] The "broadcast service" in this embodiment refers to the broadcast service provided by Hyperledger Fabric. Specifically, it is the "Broadcast" gRPC service in the / orderer / ab.proto path in the fabric-proto project. This service's client is the Client node, and its server is the Orderer node. Upon startup, the Orderer node registers the broadcast service with the local gRPC server. The broadcast service receives transaction sorting requests from the Client node, which are then sorted and generated into blocks by the Orderer node.

[0096] The "block distribution service" in this embodiment of the present invention refers to the block distribution service provided by Hyperledger Fabric. Specifically, it is the "Deliver" gRPC service in the / orderer / ab.proto path in the fabric-proto project. The client of this service is the Leader Peer node, and the server is the Orderer node. When the Orderer node starts, it will register the block distribution service with the local gRPC server. Through the block distribution service, the Orderer node can distribute newly generated blocks to the Leader Peer node. The Leader Peer node then receives the blocks and disseminates them to other Peer nodes in the same organization through Gossip messages to ensure data synchronization.

[0097] In a specific example, Figure 3 The following figure takes the Jaeger distributed tracing component as an example (Jaeger refers to Uber's open source distributed tracing system, which follows the OpenTracing API standard and is used to monitor and diagnose the call information of distributed system requests and responses). The relationship between the client package of the distributed link tracing component, the server side of the component, the gRPC interceptor, the OpenTracing API, and the UI component is explained. The working principle process is as follows:

[0098] (1) A new distributed link tracing component, the jaeger-client package, has been added to the Hyperledger Fabric source code. Jaeger-client is a Jaeger client library based on the OpenTracing API. It collects trace data from associated applications and asynchronously reports the data to the jaeger-agent via UDP. Because Hyperledger Fabric is developed using the Golang language, the jaeger-client-go library needs to be introduced into the source code of the Hyperledger Fabric consensus transaction process. The source code of the Peer and Orderer nodes needs to be modified, so jaeger-client is somewhat coupled with Hyperledger Fabric.

[0099] (2) Deploy the Jaeger server and allow the Hyperledger Fabric node container to access the Jaeger port so that the jaeger-client package can send the intercepted call information to the Jaeger server. The Jaeger server consists of several parts, namely jaeger-agent, jaeger-collector, jaeger--query and jaeger-ui. The node container refers to the Peer and Orderer node containers started in the Hyperledger Fabric network.

[0100] (3) jaeger-agent is a network daemon process that obtains trace data sent by jaeger-client packages by listening to the UDP port, and regularly sends the collected trace data batches to jaeger-collector according to the set sampling frequency.

[0101] (4) Jaeger-collector is used to receive data from Jaeger-agent and process the received data through the pipeline, such as verifying the trace data, creating indexes, etc., and finally storing the converted trace data in the data source.

[0102] (5) jaeger-query is used to query Trace data from the data source, and jaeger-ui is used to visualize Trace information. Trace includes Span information, call relationships, etc.

[0103] (6) The gRPC public library of Hyperledger Fabric is modified. The main purpose is to embed gRPC interceptors. There are many interceptor implementations. It is necessary to select an interceptor that supports intercepting Unary RPC services and Streaming RPC services. Because the process involved in Hyperledger Fabric node consensus transactions includes these two types of gRPC services, it is necessary to track the calls of these two types of gRPC services in order to completely restore the call relationship of node consensus transactions. Among them, Unary RPC service refers to the unary RPC service provided by gRPC. Specifically, it means that the client sends a single request and receives a response from the server, and this service ends; Streaming RPC service refers to the streaming RPC service provided by gRPC. Specifically, it includes client streaming service, server streaming service and bidirectional streaming service. When the corresponding streaming service is selected, the client or server needs to wait until all messages are received before responding. The broadcast service and block distribution service involved in the Hyperledger Fabric consensus process both use bidirectional streaming services for communication.

[0104] (7) By adding custom spans to the source code of Hyperledger Fabric's endorsement service, broadcast service, block distribution service, and linking them to Trace, you can track multiple different services.

[0105] (8) Finally, the modified Hyperledger Fabric source code is compiled and a new image and application are generated. The Hyperledger Fabric network is deployed using the new image and application. When the client or Hyperledger FabricSDK initiates a consensus transaction, jaeger-client sends the trace data obtained by the gRPC interceptor to the Jaeger server. The Jaeger server indexes the trace data and then stores the trace data on the data source. The trace data is then queried and visualized by jaeger-query and jaeger-ui, thereby tracking the node consensus transactions of Hyperledger Fabric.

[0106] The above example uses the Jaeger distributed link tracing component to illustrate the principle of combining distributed link tracing technology with Hyperledger Fabric to achieve the purpose of tracking node consensus transactions. Other distributed link tracing components that comply with the OpenTracing API, such as Zipkin, can also be applied. You can also customize the distributed link tracing component according to the OpenTracing API interface specification.

[0107] In another specific example, Figure 4 As shown, the following steps are included:

[0108] S210. Introduce the client package of the distributed link tracking component in Hyperledger Fabric.

[0109] Because of the access scope restrictions of different Golang language packages, the location where the distributed link tracking component's Client package is introduced must be able to access Hyperledger Fabric's gRPC public library. Taking Hyperledger Fabric V2.0 as an example, the public library related to gRPC is under the fabric / internal / pkg / comm package.

[0110] S220, Modify Hyperledger Fabric's gRPC public library and introduce gRPC interceptor;

[0111] The step S220 further includes:

[0112] New Unary service client interceptors and Streaming service client interceptors have been added to the gRPC client common library. For Hyperledger Fabric V2.0, the client common library is located in the fabric / internal / pkg / comm package, with the key source code corresponding to the client.go file. gRPC interceptors, such as the OpenTracingClientInterceptor and OpenTracingStreamClientInterceptor interceptors in the otgrpc package, need to be included in the NewConnection(address string, tlsOptions...TLSOption) method.

[0113] New Unary and Streaming service server interceptors have been added to the gRPC server public library. For Hyperledger Fabric V2.0, the client public library is located in the fabric / internal / pkg / comm package, with the key source code corresponding to the server.go file. gRPC interceptors, such as the OpenTracingStreamServerInterceptor and OpenTracingServerInterceptor interceptors in the otgrpc package, need to be included in the NewGRPCServerFromListener(listennet.Listener, s ServerConfig) method.

[0114] S230. Create a custom span in the service involved in the Hyperledger Fabric node consensus transaction;

[0115] The step S230 further includes:

[0116] When a client node requests an endorsement service, it creates a custom span representing the endorsement service request and injects the current transaction's channel ID and transaction ID into the span as key-value pairs. This allows the client to subsequently view the custom span created by the service using the channel ID and transaction ID combination. Furthermore, this custom span must be associated with the trace.

[0117] When the Endorser peer responds to an endorsement service, it creates a custom span representing the endorsement service and injects the current transaction's channel ID and transaction ID into the span as key-value pairs. This allows the custom span created by the corresponding service to be viewed later using the channel ID and transaction ID combination. This custom span must also be associated with the trace.

[0118] When a client node requests a broadcast service, it creates a custom span representing the request and injects the channel ID and transaction ID of the current transaction into the span as a key-value pair. This allows the client to subsequently view the custom span created by the corresponding service using the channel ID and transaction ID combination. Furthermore, this custom span must be associated with the trace.

[0119] When the orderer node responds to a broadcast service, it creates a custom span representing the service and injects the channel ID and transaction ID of the current transaction into the span as a key-value pair. This allows you to subsequently view the custom span created by the corresponding service using the channel ID and transaction ID combination. This custom span must also be associated with the trace.

[0120] When the Orderer node discovers a new block has been generated, it responds to the block distribution service of the Leader Peer node, creates a custom Span representing the response block distribution service, and injects the channel ID and transaction ID of the current transaction into the Span as a key-value pair. This allows the custom Span created by the corresponding service to be viewed later using the channel ID and transaction ID combination. At the same time, this custom Span must also be associated with the Trace.

[0121] After receiving block data, the Leader Peer node forwards the block data to the Committer Peer node via the Gossip protocol. A custom Span is created to represent the Gossip message forwarding process. The channel ID and transaction ID of the current transaction are injected into the Span as key-value pairs. This allows the user to subsequently view the custom Span created by the corresponding service using the channel ID and transaction ID combination. This custom Span must also be associated with the Trace.

[0122] After receiving a Gossip message, the committer peer node synchronizes the block to its own ledger. It creates a custom span representing the Gossip message processing and injects the channel ID and transaction ID of the current transaction into the span as a key-value pair. This allows the user to subsequently view the custom span created by the corresponding service using the channel ID and transaction ID combination. This custom span must also be associated with the trace.

[0123] S240: The client package of the distributed link tracing component sends the trace data to the server of the distributed link tracing component.

[0124] The server side of the distributed link tracking component collects trace data sent by different nodes of Hyperledger Fabric. These trace data are attached with Span objects of different levels, which include the calling process of the consensus transaction of the Hyperledger Fabric node.

[0125] S250. Use the UI page provided by the distributed link tracking component to display the Span call topology information.

[0126] The technical solution of this embodiment is to create a Span of the GRPC service after intercepting the GRPC service through a distributed tracing component; generate Trace data based on the Span of the GRPC service; obtain the Trace data through a listening port, and display the Trace data, so as to track the consensus transaction, thereby facilitating subsequent in-depth research on abnormal data detection and analysis in the blockchain consensus process based on the tracked node consensus transaction data.

[0127] Example 2

[0128] Figure 5 This is a schematic diagram of the structure of a consensus transaction tracking device provided by an embodiment of the present invention. This embodiment is applicable to the case of consensus transaction tracking. The device can be implemented in software and / or hardware. The consensus transaction tracking device can be integrated into any device that provides consensus transaction tracking function, such as Figure 5 As shown, the consensus transaction tracking device specifically includes: a creation module 510, a data generation module 520 and a data display module 530.

[0129] Among them, the creation module is used to create the Span of the GRPC service after intercepting the GRPC service through the distributed tracing component;

[0130] A data generation module is used to generate Trace data according to the Span of the GRPC service;

[0131] The data display module is used to obtain trace data through the monitoring port and display the trace data.

[0132] The above-mentioned product can execute the method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0133] The technical solution of this embodiment is to create a Span of the GRPC service after intercepting the GRPC service through a distributed tracing component; generate Trace data based on the Span of the GRPC service; obtain the Trace data through a listening port, and display the Trace data, so as to track the consensus transaction, thereby facilitating subsequent in-depth research on abnormal data detection and analysis in the blockchain consensus process based on the tracked node consensus transaction data.

[0134] Example 3

[0135] Figure 6 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0136] like Figure 6 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0137] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0138] Processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any other suitable processor, controller, microcontroller, etc. Processor 11 executes the various methods and processes described above, such as the consensus transaction tracking method.

[0139] In some embodiments, the consensus transaction tracking method can be implemented as a computer program that is tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the consensus transaction tracking method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the consensus transaction tracking method in any other appropriate manner (e.g., by means of firmware).

[0140] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0141] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0142] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0143] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0144] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0145] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.

[0146] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.

[0147] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A consensus transaction tracking method, characterized in that: include: After intercepting the GRPC service through the distributed tracing component, create the Span of the GRPC service; The Span is a logical unit in the system with a start time and execution duration; Trace data is generated according to the Span of the GRPC service; Acquire trace data through the listening port and display the trace data; Before intercepting the GRPC service through the distributed tracing component, it also includes: Updating the Hyperledger Fabric source code according to the distributed tracing component package; wherein the method of updating the Hyperledger Fabric source code according to the distributed tracing component package is: adding a distributed link tracing component package to the Hyperledger Fabric source code; Generate the target image and target application based on the updated Hyperledger Fabric source code; Deploy the Hyperledger Fabric blockchain based on the target image and target application.

2. The method according to claim 1, characterized in that When the service type of the GRPC service is a request service, the Span of the GRPC service includes: first transaction information, a first Span identifier, and a first Trace identifier, and the first transaction information includes: a first transaction ID and a first channel ID; Correspondingly, Trace data is generated according to the Span of the GRPC service, including: generating first Trace data corresponding to the first Trace identifier according to the first transaction information, the first Span identifier and the first Trace identifier, and injecting the Span of the GRPC service into the HTTP Header.

3. The method according to claim 2, characterized in that When the service type of the GRPC service is a response service, the Span of the GRPC service includes: second transaction information and a second Span identifier, and the second transaction information includes: a first transaction ID and a first channel ID; Accordingly, trace data is generated based on the span of the GRPC service, including: Get the Span of the request service corresponding to the GRPC service from the HTTP Header; Second trace data corresponding to the first trace identifier is generated according to the second transaction information, the second span identifier, the first span identifier, and the first trace identifier.

4. The method according to claim 3, characterized in that Generating second trace data corresponding to the first trace identifier according to the second transaction information, the second span identifier, the first span identifier, and the first trace identifier includes: Determine the first Span identifier as the parent identifier of the second Span identifier; Second trace data corresponding to the first trace identifier is generated according to the parent identifier of the second span identifier, the second span identifier, the first trace identifier, and the second transaction information.

5. The method according to claim 1, wherein The GRPC service includes at least one of: a request endorsement service, a response endorsement service, a request broadcast service, a response broadcast service, a request block distribution service, a response block distribution service, a message forwarding service, and a message processing service.

6. A consensus transaction tracking device, characterized in that: include: Create a module for creating a span for the GRPC service after intercepting it through the distributed tracing component; The Span is a logical unit in the system with a start time and execution duration; A data generation module is used to generate Trace data according to the Span of the GRPC service; The data display module is used to obtain trace data through the monitoring port and display the trace data; Before intercepting the GRPC service through the distributed tracing component, it also includes: Updating the Hyperledger Fabric source code according to the distributed tracing component package; wherein the method of updating the Hyperledger Fabric source code according to the distributed tracing component package is: adding a distributed link tracing component package to the Hyperledger Fabric source code; Generate the target image and target application based on the updated Hyperledger Fabric source code; Deploy the Hyperledger Fabric blockchain based on the target image and target application.

7. The device according to claim 6, characterized in that When the service type of the GRPC service is a request service, the Span of the GRPC service includes: first transaction information, a first Span identifier, and a first Trace identifier, and the first transaction information includes: a first transaction ID and a first channel ID; Correspondingly, the data generation module is specifically used to: generate first trace data corresponding to the first trace identifier according to the first transaction information, the first span identifier and the first trace identifier, and inject the span of the GRPC service into the HTTP header.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the consensus transaction tracking method according to any one of claims 1 to 5.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the consensus transaction tracking method according to any one of claims 1 to 5 when executed.

Citation Information

Patent Citations

  • Consensus transaction track visual tracking method, system and equipment

    CN114296964A