Data processing method and device based on block chain, equipment and medium

By using graph databases to store and query blockchain data in blockchain browsers, the problem of inefficient blockchain data query in the existing technology is solved, and efficient query of complex relationships is achieved.

CN120030084APending Publication Date: 2025-05-23TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311574761.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-22
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

In existing blockchain browsers, blockchain data query is inefficient, especially when complex data queries are involved, it is necessary to traverse multiple two-dimensional table joint queries, resulting in the query process time-consuming.

Method used

A graph database is used instead of a traditional key-value pair database or relational database. By determining the business object entity matching the object entity type in the business transaction block, and generating a business data sub-graph, it is added to the graph database, thereby achieving efficient blockchain data query.

Benefits of technology

Through the storage and query mechanism of graph database, the business object entities and their association relationships in blockchain data can be directly stored, the efficiency of complex relationship query is improved, and the query speed of blockchain data can be significantly improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120030084A_ABST
    Figure CN120030084A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data processing method and device based on a block chain, equipment and a medium, and the method comprises the steps: obtaining an attribute relationship between object entity types, and determining an association relationship between business object entities in a business transaction block according to the attribute relationship between the object entity types; taking the business object entities in the business transaction block as nodes, taking the incidence relation between the business object entities in the business transaction block as edges, generating a business data sub-graph, and adding the business data sub-graph to a graph database; nodes, matched with the service types, in the service data sub-graphs are added to a service node set, sub-graph division processing is conducted on the service data sub-graphs according to the incidence relation of the nodes in the service node set in the service data sub-graphs, service screening sub-graphs are obtained, and the service screening sub-graphs are added to candidate data sub-graphs associated with the service types. By implementing the method, the query efficiency of the block chain data can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a blockchain-based data processing method, device, equipment and medium. Background Art

[0002] A blockchain browser is a browser built based on blockchain data as a database. The blockchain browser can store the data in the blockchain (for example, transaction data, etc.) in a unified manner, making it easier for users to query blockchain data. Currently, blockchain data is usually stored in a key-value data storage structure in a blockchain browser. However, this blockchain data storage method requires traversing multiple two-dimensional tables for joint query when complex data queries are involved, which makes the query process of blockchain data very time-consuming, and thus causes low efficiency of blockchain data query. Summary of the invention

[0003] The embodiments of the present application provide a blockchain-based data processing method, device, equipment, and medium, which can improve the query efficiency of blockchain data.

[0004] On the one hand, an embodiment of the present application provides a data processing method based on blockchain, including:

[0005] Obtain a first block height corresponding to the first blockchain node, and obtain a business transaction block according to the first block height;

[0006] Acquire multiple object entity types in the graph database, and determine business object entities matching each object entity type in the business transaction block according to field information corresponding to each object entity type; the graph database is used to store data in the blockchain corresponding to the first blockchain node;

[0007] Obtain the attribute relationship between each object entity type, and determine the association relationship between the business object entities in the business transaction block according to the attribute relationship between each object entity type;

[0008] Generate a business data subgraph using the business object entities in the business transaction block as nodes and the association relationships between the business object entities in the business transaction block as edges, and add the business data subgraph to the graph database;

[0009] Add the nodes in the business data subgraph that match the business type to the business node set, divide the business data subgraph into subgraphs according to the association relationships between the nodes in the business node set in the business data subgraph, and obtain a business screening subgraph. Add the business screening subgraph to the candidate data subgraph associated with the business type; the candidate data subgraph is the data source of the business query task corresponding to the business type.

[0010] On the one hand, an embodiment of the present application provides a data processing device based on blockchain, the device comprising:

[0011] A business transaction block acquisition module, used to obtain a first block height corresponding to a first blockchain node, and obtain a business transaction block according to the first block height;

[0012] A business object entity acquisition module is used to acquire multiple object entity types in the graph database, and determine the business object entities matching each object entity type in the business transaction block according to the field information corresponding to each object entity type; the graph database is used to store the data in the blockchain corresponding to the first blockchain node;

[0013] An association relationship acquisition module is used to acquire the attribute relationship between each object entity type, and determine the association relationship between the business object entities in the business transaction block according to the attribute relationship between each object entity type;

[0014] A business data subgraph generation module is used to generate a business data subgraph using business object entities in a business transaction block as nodes and association relationships between business object entities in a business transaction block as edges, and add the business data subgraph to a graph database;

[0015] The business subgraph screening module is used to add the nodes in the business data subgraph that match the business type to the business node set, and divide the business data subgraph into subgraphs according to the association relationship between the nodes in the business node set in the business data subgraph to obtain a business screening subgraph, and add the business screening subgraph to the candidate data subgraph associated with the business type; the candidate data subgraph is the data source of the business query task corresponding to the business type.

[0016] The business transaction block acquisition module acquires the business transaction block according to the first block height, including:

[0017] Obtaining a second block height corresponding to the second blockchain node; the first blockchain node and the second blockchain node are in the same business blockchain network;

[0018] If the first block height is less than the second block height, a block synchronization request is sent to the second blockchain node, so that the second blockchain node determines the block to be synchronized for the first blockchain node according to the block synchronization request;

[0019] Receive the block to be synchronized returned by the second blockchain node, and determine the block to be synchronized as a business transaction block.

[0020] The business transaction block acquisition module acquires the business transaction block according to the first block height, including:

[0021] Determine the consensus block height according to the first block height, and generate a consensus block corresponding to the consensus block height;

[0022] Broadcasting the consensus block in the business blockchain network corresponding to the first blockchain node, so that the blockchain nodes in the business blockchain network perform consensus processing on the consensus block and obtain the consensus voting result corresponding to the consensus block;

[0023] Obtain the consensus voting results corresponding to each blockchain node in the business blockchain network, and determine the block consensus result corresponding to the consensus block based on the consensus voting results corresponding to each blockchain node; one blockchain node corresponds to one consensus voting result;

[0024] If the block consensus result indicates that the consensus block has reached a consensus, the consensus block will be determined as a business transaction block.

[0025] Among them, the business transaction block acquisition module determines the block consensus result corresponding to the consensus block according to the consensus voting results corresponding to each blockchain node, including:

[0026] In the consensus voting results corresponding to each blockchain node, count the number of votes in favor of the voting results;

[0027] If the number of votes is less than the threshold number of votes, it is determined that the block consensus result corresponding to the block to be agreed upon indicates that the block to be agreed upon has not reached a consensus, and the block to be agreed upon is cleared in the first blockchain node;

[0028] If the number of votes is greater than or equal to the threshold number of votes, the block consensus result is determined to indicate that the consensus block is to be reached.

[0029] The business data subgraph generation module adds the business data subgraph to the graph database, including:

[0030] Obtain M blockchain data subgraphs contained in the graph database, and obtain similarity evaluation values ​​between each blockchain data subgraph and the business data subgraph; M is a positive integer;

[0031] If the similarity evaluation value between the business data subgraph and the i-th blockchain data subgraph among the M blockchain data subgraphs is greater than the similarity threshold, the i-th blockchain data subgraph and the business data subgraph are merged into a business fusion subgraph; i is a positive integer less than or equal to M;

[0032] Update the i-th blockchain data subgraph to the business fusion subgraph in the graph database.

[0033] Wherein, if the similarity evaluation value between the business data subgraph and the i-th blockchain data subgraph among the M blockchain data subgraphs is greater than the similarity threshold, the business data subgraph generation module merges the i-th blockchain data subgraph with the business data subgraph into a business fusion subgraph, including:

[0034] If the similarity evaluation value between the business data subgraph and the i-th blockchain data subgraph among the M blockchain data subgraphs is greater than the similarity threshold, the node in the business data subgraph is combined with the node in the i-th blockchain data subgraph to obtain N data node pairs; a data node pair includes a node in the business data subgraph and a node in the i-th blockchain data subgraph; N is a positive integer;

[0035] If there is an association relationship between the two nodes contained in the jth data node in the N data node pairs, the two nodes contained in the jth data node pair are connected to generate a candidate edge; j is a positive integer less than or equal to N;

[0036] A business fusion subgraph is generated according to the i-th blockchain data subgraph, the business data subgraph, and the candidate edges corresponding to the N data node pairs.

[0037] The business data subgraph generation module generates a business fusion subgraph according to the candidate edges corresponding to the i-th blockchain data subgraph, the business data subgraph, and the N data node pairs, including:

[0038] Merge the i-th blockchain data subgraph, the business data subgraph, and the candidate edges corresponding to the N data node pairs into an initial fusion subgraph;

[0039] If it is detected that the same nodes exist in the initial fusion subgraph, the same nodes are deduplicated in the initial fusion subgraph, and the deduplicated initial fusion subgraph is determined as the service fusion subgraph.

[0040] The business subgraph screening module divides the business data subgraph into subgraphs according to the association relationship between the nodes in the business node set in the business data subgraph to obtain a business screening subgraph, including:

[0041] Obtain an edge set of each node in the business node set in the business data subgraph, and determine a node whose edge number corresponding to the edge set is less than a quantity threshold as an abnormal node;

[0042] Abnormal nodes are removed from the business node set to obtain a candidate node set, and the remaining nodes except the candidate node set in the business data subgraph and the edge sets corresponding to the remaining nodes are deleted to obtain a business screening subgraph.

[0043] Among them, the data processing device based on blockchain also includes:

[0044] A query range determination module, which is configured to receive a service query task corresponding to a service type, determine a service node corresponding to the service query task, and determine a data query range corresponding to the service node according to the service query task;

[0045] A query sub-graph acquisition module, which is configured to traverse and query the nodes included in the candidate data sub-graph, and acquire a service query sub-graph that matches the data query range from the candidate data sub-graph;

[0046] A query result acquisition module, which is configured to encrypt the service query sub-graph through the node public key corresponding to the service node to obtain a data query result corresponding to the service query task, and return the data query result to the service node.

[0047] Among them, the query range determination module determines the data query range corresponding to the service node according to the service query task, including:

[0048] Obtaining the digital signature carried by the service query task, and obtaining the node public key corresponding to the service node;

[0049] Decrypting the digital signature through the node public key to obtain a first digest information, and performing a hashing operation on the service query task according to the hashing algorithm to obtain a second digest information;

[0050] If the first digest information is the same as the second digest information, then obtain the initial query range indicated by the service query task, and obtain the query permission range of the service node in the candidate data sub-graph;

[0051] If the initial query range does not belong to the query permission range, then return a query failure prompt message to the service node;

[0052] If the initial query range belongs to the query permission range, then determine the initial query range as the data query range corresponding to the service node.

[0053] Among them, the query sub-graph acquisition module traverses and queries the nodes included in the candidate data sub-graph, and acquires a service query sub-graph that matches the data query range from the candidate data sub-graph, including:

[0054] Determine a search start node belonging to the data query range in the candidate data sub-graph, and add the neighbor nodes corresponding to the search start node to the first neighbor node set;

[0055] If there are nodes in the first neighbor node set that do not belong to the data query range, then clear the nodes that do not belong to the data query range to obtain a second neighbor node set;

[0056] Adding neighbor nodes corresponding to nodes in the second neighbor node set to the third neighbor node set, removing nodes in the third neighbor node set that do not belong to the data query range, and obtaining a fourth neighbor node set;

[0057] If the nodes in the fourth neighbor node set are all leaf nodes in the candidate data subgraph, a business query subgraph is generated based on the association between the search start node, the nodes in the second neighbor node set, and the nodes in the fourth neighbor node set in the candidate data subgraph.

[0058] On one hand, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method in one aspect of the embodiment of the present application.

[0059] On one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the steps of the method in one aspect of the embodiment of the present application are executed.

[0060] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in various optional modes of the above-mentioned first aspect.

[0061] In an embodiment of the present application, business object entities that match each object entity type can be determined in the business transaction block, and then the business object entities in the business transaction block are used as nodes, and the association relationship between the business object entities in the business transaction block is used as an edge to generate a business data subgraph, and the business data subgraph is added to the graph database to update the graph database. It can be seen that the embodiment of the present application uses a graph database instead of a key-value pair database to store blockchain data. Since the graph database can directly store the business object entities in the blockchain data and the association relationship between the business object entities, the query efficiency of the blockchain data can be improved when querying blockchain data involving complex relationships. In addition, after obtaining the business data subgraph, the business data subgraph can also be divided into subgraphs to obtain a business screening subgraph associated with the business type, and the business screening subgraph is added to the candidate data subgraph associated with the business type, so that business queries can be performed through the candidate data subgraph, thereby further improving the data query efficiency in specific business query scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0063] Figure 1 This is a network architecture diagram provided by an embodiment of the present application;

[0064] Figure 2 This is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application. Figure 1 ;

[0065] Figure 3 It is a schematic diagram of generating a business data subgraph provided in an embodiment of the present application;

[0066] Figure 4 This is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application. Figure 2 ;

[0067] Figure 5 This is a schematic diagram of a sub-graph merging provided in an embodiment of the present application. Figure 1 ;

[0068] Figure 6 This is a schematic diagram of a sub-graph merging provided in an embodiment of the present application. Figure 2 ;

[0069] Figure 7 This is a schematic diagram of a blockchain data query provided by an embodiment of the present application. Figure 1 ;

[0070] Figure 8 This is a schematic diagram of a sub-graph matching provided in an embodiment of the present application. Figure 1 ;

[0071] Fig. 9 This is a schematic diagram of a sub-graph matching provided in an embodiment of the present application. Figure 2 ;

[0072] Fig.10 This is a schematic diagram of a blockchain data query provided by an embodiment of the present application. Figure 2 ;

[0073] Fig.11 It is a structural schematic diagram of a blockchain-based data processing device provided in an embodiment of the present application;

[0074] Fig.12 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0075] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0076] The embodiments of the present application relate to blockchain technology. Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods, each of which contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.

[0077] The underlying blockchain platform can include object management, basic services, smart contracts, and operation management processing modules. Among them, the object management module is responsible for the identity information management of all blockchain participants, including maintaining public and private key generation (address management), key management, and the maintenance of the corresponding relationship between the user's real identity and the blockchain address (authority management), etc., and under authorization, manages and audits the transaction of certain real identities, and provides risk control rule configuration (risk control audit); the basic service module is deployed on all blockchain node devices to verify the validity of business requests, and records valid requests to storage after consensus is reached. For a new business request, the basic service first performs interface adaptation analysis and authentication processing (interface adaptation), and then encrypts the business information through the consensus algorithm (consensus management), and transmits it to the shared ledger in a complete and consistent manner after encryption (network communication), and records and stores it.

[0078] Among them, the smart contract module is responsible for the registration and issuance of contracts, as well as contract triggering and contract execution. Developers can define the contract logic through a certain programming language and publish it to the blockchain (contract registration). According to the logic of the contract terms, the key or other events are called to trigger the execution to complete the contract logic. It also provides the function of contract upgrade and cancellation. The operation management module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation and real-time status visualization output of the product during the product release process, such as alarm, network status detection, node equipment health status detection, etc.

[0079] See also Figure 1 , Figure 11 is a schematic diagram of a network architecture provided in an embodiment of the present application. The network architecture may include a service node 10a and a blockchain network. The service node 10a may refer to a device outside the blockchain network or a device in the blockchain network, and the embodiment of the present application does not limit this.

[0080] A blockchain network can be composed of multiple blockchain nodes. The embodiments of the present application do not limit the number of blockchain nodes included in the blockchain network. Figure 1 Take 6 blockchain nodes as an example. Figure 1 As shown, the blockchain network may include blockchain node 20a, blockchain node 20b, blockchain node 20c, blockchain node 20d, blockchain node 20e and blockchain node 20f, etc. Among them, each blockchain node in the blockchain network is networked in a peer-to-peer network manner, and the nodes can communicate with each other according to the peer-to-peer network protocol. Each node in the blockchain network jointly follows the broadcast mechanism and consensus mechanism to jointly ensure that the data on the blockchain cannot be tampered with or forged, and at the same time realize the decentralization and trustlessness of the blockchain.

[0081] Among them, the business node 10a can interact with each blockchain node in the blockchain network. For example, the business node 10a can initiate a data chain request to the blockchain node 20a in the blockchain network, so that the blockchain node 20a stores the business data generated by the business node 10a in the blockchain. The business node 10a can also initiate a data query request to the blockchain node 20a, so that the blockchain node 20a returns the corresponding data query result to the business node 10a according to the data query request corresponding to the business node 10a. It can be understood that the embodiment of the present application does not limit the connection method between the business node 10a and each blockchain node in the blockchain network, and can be directly or indirectly connected through a wired communication method, or directly or indirectly connected through a wireless communication method.

[0082] The business node 10a and the blockchain node in the blockchain network can be a terminal device, or a server, or a system composed of a terminal device and a server, which is not limited in the embodiment of the present application. The terminal device may include, but is not limited to: a personal computer, a smart phone, a tablet computer, a laptop computer, a PDA, a mobile internet device (MID), a wearable device (such as a smart watch, a smart bracelet, etc.), an intelligent voice interaction device, a smart home appliance (such as a smart TV, etc.), a vehicle-mounted device, an aircraft and other electronic devices, and the embodiment of the present application does not limit the type of the terminal device.

[0083] The server can be an independent physical server or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The embodiments of the present application do not limit the type of backend servers corresponding to business applications.

[0084] A blockchain node in a blockchain network (e.g., blockchain node 20a) may maintain a blockchain browser, wherein the blockchain browser is a browser built based on a database of blockchain data, thereby providing a visualization and query interface for data in the blockchain (e.g., transaction data, block information, etc.) for data query objects.

[0085] At present, blockchain data is usually stored in a key-value pair data storage structure in a blockchain browser. However, this blockchain data storage method, when it comes to complex data queries (for example, the data query range is "transaction hashes with block height A, asset transfer address B, contract C, and no less than two internal transaction data"), needs to traverse multiple two-dimensional tables (for example, block transaction list, address transaction list, transaction hash list, contract address list, etc.) for joint query, which makes the query process of blockchain data very time-consuming, and thus causes low efficiency of blockchain data query.

[0086] In order to cope with complex data queries, the embodiment of the present application uses a graph database as the underlying storage engine of the blockchain browser. Compared with traditional key-value databases or relational databases, graph databases can directly store business object entities in blockchain data and the relationship between business object entities. Therefore, when querying blockchain data involving complex relationships, using a graph database to store blockchain data can improve the query efficiency of blockchain data.

[0087] The following is a detailed description of the storage method of blockchain data involved in the embodiment of the present application. Figure 2 , Figure 2 This is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application. Figure 1 It can be understood that the blockchain-based data processing method can be executed by a first blockchain node, which can be Figure 1 The blockchain node 20a or blockchain node 20b in the blockchain network shown. Figure 2 As shown, the blockchain-based data processing method may include the following steps S101 to S105:

[0088] Step S101: Obtain a first block height corresponding to a first blockchain node, and obtain a business transaction block according to the first block height.

[0089] Among them, the first block height refers to the block height corresponding to the latest transaction block stored in the blockchain corresponding to the first blockchain node. The block height can be regarded as an identifier of the transaction block and can be used to indicate the position of the transaction block in the blockchain.

[0090] Please also see Figure 3 , Figure 3 Schematic diagram of generating a business data subgraph provided by an embodiment of the present application. Figure 3 As shown, the blockchain 30a corresponding to the first blockchain node includes transaction blocks 30e, 30c, 30b, etc. Optionally, the transaction block 30b may be a transaction block newly agreed upon in the business blockchain network corresponding to the first blockchain node. In this case, the transaction block 30b may be determined as a business transaction block.

[0091] Specifically, in the block consensus scenario, the method for obtaining the business transaction block may include: determining the consensus block height according to the first block height, and generating a block to be agreed upon corresponding to the consensus block height; broadcasting the consensus block in the business blockchain network corresponding to the first blockchain node, so that the blockchain nodes in the business blockchain network perform consensus processing on the consensus block, and obtain the consensus voting result corresponding to the block to be agreed upon; and then the consensus voting results corresponding to each blockchain node in the business blockchain network can be obtained, and the block consensus result corresponding to the block to be agreed upon can be determined according to the consensus voting results corresponding to each blockchain node; if the block consensus result indicates that the block to be agreed upon has reached a consensus, the block to be agreed upon is determined as a business transaction block.

[0092] In the embodiment of the present application, the first blockchain node may be the master node in the business blockchain network where it is located; the consensus block height refers to the block height when the transaction block reaches a consensus in the business blockchain network where the first blockchain node is located in the current consensus cycle. Assuming that the first block height is 8, the consensus block height may be 9. At this time, the first blockchain node may generate a consensus block with a consensus block height of 9. For ease of description, the embodiment of the present application takes the transaction block 30b as an example of a consensus block. After generating the transaction block 30b corresponding to the consensus block height, the first blockchain node may broadcast the transaction block 30b in the business blockchain network corresponding to the first blockchain node. Each blockchain node in the business blockchain network may perform consensus processing on the received transaction block 30b through a consensus algorithm. For example, each transaction data contained in the transaction block 30b may be verified, and the first blockchain node that generates the transaction block 30b may be verified.

[0093] After generating the consensus voting result corresponding to the transaction block 30b, each blockchain node in the business blockchain network can broadcast the consensus voting result in the business blockchain network. Further, the first blockchain node can obtain the consensus voting result of each blockchain node in the business blockchain network for the transaction block 30b; wherein, one blockchain node corresponds to one consensus voting result, and the consensus voting result can be a positive voting result or a negative voting result. The positive voting result is used to indicate that the blockchain node's verification result for the transaction block 30b is a passed verification, and the negative voting result is used to indicate that the blockchain node's verification result for the transaction block 30b is a failed verification.

[0094] Further, the first blockchain node can count the number of votes in favor of the voting result in the consensus voting results corresponding to each blockchain node, that is, the number of blockchain nodes in the business blockchain network whose verification result for transaction block 30b is verified. If the number of votes is less than the voting number threshold (the voting number threshold here can be determined according to the consensus algorithm used in the business blockchain network, for example, the voting number threshold can be set to 2 / 3 of the number of consensus nodes included in the blockchain network), it is determined that the block consensus result corresponding to transaction block 30b indicates that transaction block 30b has not reached a consensus, so transaction block 30b can be cleared in the first blockchain node to save data storage space of the first blockchain node. If the number of votes is greater than or equal to the voting number threshold, it can be determined that the block consensus result corresponding to transaction block 30b indicates that transaction block 30b has reached a consensus, and at this time, transaction block 30b can be determined as a business transaction block.

[0095] Among them, the consensus algorithms involved in the embodiments of the present application may include but are not limited to: Proof of Work (PoW) algorithm, Proof of Stake (PoS) algorithm, DPoS algorithm, Practical Byzantine Fault Tolerance (PBFt) algorithm and other consensus algorithms.

[0096] Step S102: Acquire multiple object entity types in the graph database, and determine business object entities matching each object entity type in the business transaction block according to field information corresponding to each object entity type.

[0097] The graph database can be used to store the data in the blockchain corresponding to the first blockchain node. The graph database is a database management system based on graph theory, which uses a graph as a data structure to store and query data. In the embodiment of the present application, since the graph database stores the data in the blockchain corresponding to the first blockchain node, the relationship between the blockchain data in the graph database and the blockchain data is represented in the form of nodes and edges. The nodes represent the business object entities contained in the blockchain data, and the edges represent the association relationship between the various business object entities. In other words, in the embodiment of the present application, the use of the graph database as the underlying storage engine corresponding to the blockchain browser maintained by the first blockchain node can efficiently respond to complex relationship queries, thereby improving the query efficiency of blockchain data.

[0098] The object entity type in the graph database may refer to the type formed by the business object entities with common characteristics stored in the graph database. In the embodiment of the present application, the business object entity refers to the object entity related to the blockchain data. Figure 3 As shown, business object entities may include but are not limited to: block entity, block header entity, transaction data entity, address entity, asset description information entity (used to describe specific information of digital assets, such as the name of digital assets, digital asset identifier, etc.), asset holding entity (used to describe the specific number of digital assets held by asset holding objects), asset operation event entity (used to describe operations such as issuance, transaction, allocation, transfer, etc. of digital assets), etc. Correspondingly, object entity types in the graph database may include but are not limited to: block entity type, transaction data entity type, address entity type, etc.

[0099] The field information corresponding to the object entity type may refer to the identification information of the business object entity associated with the object entity type, and can be used to determine the business object entity corresponding to the object entity type. In the embodiments of the present application, according to the field information corresponding to each object entity type, the business object entities matching each object entity type can be determined in the business transaction block. For example, the field information corresponding to the object entity type of the block entity type may be "block", and the field information corresponding to the object entity type of the transaction data entity type may be "tx". After obtaining the business transaction block, the blockchain data included in the business transaction block can be obtained. For example, the blockchain data may be "block:block 9; tx:tx1,tx2", then the business object entities included in the business transaction block may include a block entity and a transaction data entity. The block entity may specifically include "block 9", and the transaction data entity may include "tx1" and "tx2".

[0100] Step S103: Obtain the attribute relationships between each object entity type, and determine the association relationships between the business object entities in the business transaction block according to the attribute relationships between each object entity type.

[0101] Among them, the attribute relationships between each object entity type can be used to represent the association relationships between each business object entity. For example, the attribute relationship between the object entity type of the block entity type and the object entity type of the block header entity type may be "block height and hash", and the attribute relationship between the block entity type and the transaction data entity type may be "block transaction list"; furthermore, according to the attribute relationship "block height and hash", it can be determined that there is an association relationship between the block entity and the block header entity in the business transaction block, and the association relationship may be "block height and hash"; according to the attribute relationship "block transaction list", it can be determined that there is an association relationship between the block entity and the transaction data entity in the business transaction block, and the association relationship may be "block transaction list".

[0102] Step S104: Use the business object entities in the business transaction block as nodes and the association relationships between the business object entities in the business transaction block as edges to generate a business data subgraph, and add the business data subgraph to the graph database.

[0103] Among them, the business data subgraph may include the association relationships between the blockchain data in the business transaction block. Such as Figure 3As shown, the transaction block 30b (business transaction block) may include object entities such as block entity, block header entity, transaction data entity, address entity, asset description information entity, asset holding entity, asset operation event entity, etc.; wherein, the association relationship between the block entity and the block header entity may be "block height and hash", the association relationship between the block header entity and the transaction data entity may be "block height and hash", the association relationship between the block entity and the transaction data entity may be "block transaction list", the association relationship between the transaction data entity and the address entity may include "transfer-in (from) / transfer-out (to) address" and "address transaction list", the association relationship between the address entity and the asset description information entity may be "contract address", the association relationship between the asset description information entity and the asset holding entity may be "asset address", the association relationship between the asset operation event entity and the address entity may be "transfer-in / transfer-out address", etc.

[0104] like Figure 3 As shown, the business object entities included in the transaction block 30b (business transaction block) can be used as nodes, and the connection relationship between each business object entity can be established according to the association relationship between each business object entity, and the edges between each business object entity can be obtained, thereby generating a business data subgraph 31a. After obtaining the business data subgraph 31a, the business data subgraph 31a can be added to the graph database 31b to complete the storage of blockchain data in the graph database 31b, so that when blockchain data queries involving complex relationships are involved, efficient blockchain data query services can be provided for data query objects.

[0105] It can be understood that the edges contained in the business data subgraph 31a can be directed edges or undirected edges. When the edge between two nodes is a directed edge, the direction of the edge can be determined according to the association relationship between the two nodes. For example, when the association relationship between the transaction data entity and the address entity is "transfer-in / transfer-out address", the direction of the edge between the transaction data entity and the address entity is from the transaction data entity to the address entity; when the association relationship between the transaction data entity and the address entity is "address transaction list", the direction of the edge between the transaction data entity and the address entity is from the address entity to the transaction data entity.

[0106] Step S105: Add the nodes in the business data subgraph that match the business type to the business node set, divide the business data subgraph into subgraphs according to the association relationships between the nodes in the business node set in the business data subgraph, obtain a business screening subgraph, and add the business screening subgraph to the candidate data subgraph associated with the business type.

[0107] In the embodiment of the present application, the business type may refer to the division of business query tasks associated with different business query scenarios. For example, the business type may include query types such as abnormal transaction query, asset transaction detail query, and asset holding query; for example, when the business type is an abnormal transaction query type, the nodes in the business node set mainly involve nodes of address type and transaction data type, then the nodes included in the business screening subgraph are nodes of address type and transaction data type; when the business type is an asset holding query type, the nodes in the business node set mainly involve nodes of address type and asset holding type, then the nodes included in the business screening subgraph are nodes of address type and asset holding type.

[0108] Similarly, the business query tasks corresponding to the business type may include abnormal transaction query tasks, asset transaction details query tasks, asset holdings query tasks, etc. Among them, the candidate data subgraph is a subgraph obtained after preliminary screening of the graph database in combination with the business query scenario. In other words, the candidate data subgraph can be used as a data source for business query tasks corresponding to the business type. For example, when a business query task associated with a business type (for example, an abnormal transaction query task) is received, the business query subgraph corresponding to the business query task can be queried in the candidate data subgraph, thereby further improving the data query efficiency in specific business query scenarios (for example, abnormal transaction query scenarios). The specific query process will be described below and will not be repeated here.

[0109] After obtaining the business data subgraph, a business screening subgraph that matches the business type can be divided from the business data subgraph in combination with the business query scenario. For ease of understanding, the embodiment of the present application takes the business type as an abnormal transaction query type, that is, the business query scenario as an abnormal transaction query scenario as an example to describe the process of obtaining the business screening subgraph. Among them, abnormal transaction query can refer to a query on transaction behaviors that are inconsistent with normal transaction behaviors, such as a query on black market transaction behaviors. It can be understood that the node types mainly involved in abnormal transaction queries are address types and transaction data types, that is, nodes of address types and transaction data types are nodes that match the business type.

[0110] like Figure 3 As shown in FIG. 1 , the node type corresponding to node 32a is the address type, and the node types corresponding to nodes 32b and 32c are the transaction data types. Therefore, nodes 32a, 32b, and 32c in the business data subgraph 31a can be added to the business node set, and the business data subgraph 31a can be divided into subgraphs according to the association relationship among nodes 32a, 32b, and 32c in the business node set in the business data subgraph 31a. Figure 3The business screening sub-graph 31c shown. Further, candidate data sub-graph 31d associated with the abnormal transaction query type can be queried in the graph database 31b, and the business screening sub-graph 31c can be added to the candidate data sub-graph 31d to enrich the data source of the abnormal transaction query task, thereby improving the data query accuracy of the abnormal transaction query task.

[0111] In the embodiments of the present application, business object entities matching each object entity type can be determined in the business transaction block, and then, taking the business object entities in the business transaction block as nodes and the association relationships between the business object entities in the business transaction block as edges, a business data sub-graph is generated, and the business data sub-graph is added to the graph database to update the graph database. It can be seen that the embodiments of the present application use a graph database to store blockchain data instead of a key-value pair database. Since the graph database can directly store the business object entities and the association relationships between the business object entities in the blockchain data, when querying blockchain data involving complex relationships, the query efficiency of the blockchain data can be improved. In addition, after obtaining the business data sub-graph, the business data sub-graph can be divided into sub-graphs to obtain a business screening sub-graph associated with the business type, and the business screening sub-graph is added to the candidate data sub-graph associated with the business type, so as to perform business queries through the candidate data sub-graph, and further improve the data query efficiency in specific business query scenarios.

[0112] Please refer to Figure 4 , Figure 4 is a flowchart of a data processing method based on blockchain provided by the embodiments of the present application. Figure 2 . It can be understood that the data processing method based on blockchain can be executed by the first blockchain node, and the first blockchain node can be Figure 1 the blockchain node 20a or the blockchain node 20b in the blockchain network shown. As Figure 4 shown, the data processing method based on blockchain may include the following steps S201 to step 211:

[0113] Step S201: Obtain the first block height corresponding to the first blockchain node, and obtain the business transaction block according to the first block height.

[0114] In the embodiment of the present application, the business transaction block may be the transaction block most recently synchronized by the first blockchain node. For example, in the block synchronization scenario, the method of obtaining the business transaction block may include: obtaining the second block height corresponding to the second blockchain node; if the first block height is less than the second block height, a block synchronization request may be sent to the second blockchain node, so that the second blockchain node determines the block to be synchronized for the first blockchain node according to the block synchronization request; and then receiving the block to be synchronized returned by the second blockchain node, and determining the block to be synchronized as the business transaction block.

[0115] The second blockchain node may be a blockchain node in the same business blockchain network as the first blockchain node; the second block height refers to the block height corresponding to the latest transaction block stored in the blockchain corresponding to the second blockchain node. The block synchronization request may be used to instruct the second blockchain node to return the transaction block that needs to be synchronized to the first blockchain node.

[0116] Block synchronization is an important part of blockchain, and block synchronization can ensure data consistency in the business blockchain network. In the embodiment of the present application, when the first blockchain node detects that the first block height is equal to the second block height, it means that the block heights of the first blockchain node and the second blockchain node are consistent. At this time, the data status of the first blockchain node does not need to be updated; when the first blockchain node detects that the first block height is greater than the second block height, it means that the data status of the second blockchain node needs to be updated, and the second blockchain node cannot provide the first blockchain node with the latest blockchain data. In the above case, the first blockchain node does not need to send a block synchronization request to the second blockchain node.

[0117] When the first blockchain node detects that the first block height is less than the second block height, it means that the blockchain corresponding to the first blockchain node does not store the latest data in the business blockchain network, and the data status of the first blockchain node needs to be updated. At this time, the first blockchain node can send a block synchronization request to the second blockchain node, and the second blockchain node can respond to the block synchronization request, and then determine the block to be synchronized for the first blockchain node according to the first block height and the second block height. For example, if the first block height is 8 and the second block height is 10, then transaction block 9 and transaction block 10 in the blockchain corresponding to the second blockchain node can be determined as blocks to be synchronized, and the blocks to be synchronized are returned to the first blockchain node. After receiving the blocks to be synchronized returned by the second blockchain node, the first blockchain node can determine the blocks to be synchronized as business transaction blocks.

[0118] Step S202: Acquire multiple object entity types in the graph database, and determine business object entities matching each object entity type in the business transaction block according to field information corresponding to each object entity type.

[0119] Step S203: Acquire the attribute relationship between each object entity type, and determine the association relationship between the business object entities in the business transaction block according to the attribute relationship between each object entity type.

[0120] Step S204: Generate a business data subgraph with the business object entities in the business transaction block as nodes and the association relationships between the business object entities in the business transaction block as edges.

[0121] The specific implementation process of step S202 to step S204 can be referred to Figure 2 The description of steps S102 to S104 is shown and will not be repeated here.

[0122] Step S205: Obtain M blockchain data subgraphs contained in the graph database, and obtain similarity evaluation values ​​between each blockchain data subgraph and the business data subgraph.

[0123] Wherein, M is a positive integer, and the specific value of M can be a positive integer such as 1, 2 or 3. The blockchain data subgraph can refer to a subgraph that has been stored in the graph database to represent the association relationship of blockchain data. The similarity evaluation value can be understood as the subgraph similarity between the blockchain data subgraph and the business data subgraph. The similarity evaluation value can be visualized in the form of a numerical value. For example, the similarity evaluation value can be a numerical value between 0 and 1, or it can also be a numerical value between 0 and 100. The larger the numerical value, the larger the similarity evaluation value, the greater the subgraph similarity between the blockchain data subgraph and the business data subgraph, the stronger the correlation between the blockchain data subgraph and the business data subgraph, and the greater the probability of performing subgraph merging.

[0124] In the embodiment of the present application, the similarity evaluation value between the blockchain data subgraph and the business data subgraph can be characterized by one or more of the cosine similarity and Jaccard similarity between the blockchain data subgraph and the business data subgraph. Among them, the cosine similarity can be calculated by one or more of the algorithms such as Euclidian distance, Manhattan distance, Minkowski distance, and cosine similarity.

[0125] Step S206: If the similarity evaluation value between the business data subgraph and the i-th blockchain data subgraph among the M blockchain data subgraphs is greater than the similarity threshold, the i-th blockchain data subgraph and the business data subgraph are merged into a business fusion subgraph.

[0126] Wherein, i is a positive integer less than or equal to M; the specific value of i may be 1, 2, 3, ..., M. The business fusion subgraph may refer to a subgraph obtained by merging a blockchain data subgraph with a business data subgraph.

[0127] Please also see Figure 5 , Figure 5 This is a schematic diagram of a sub-graph merging provided in an embodiment of the present application. Figure 1 For ease of description, the embodiment of the present application takes the value of M as 2 to describe the merging process of the blockchain data subgraph and the business data subgraph, wherein the i-th blockchain data subgraph can be the blockchain data subgraph 40a or the blockchain data subgraph 40b. Figure 5 As shown, after obtaining the business data subgraph 40c, the blockchain data subgraph 40a and the business data subgraph 40c in the graph database 40d can be combined to obtain the subgraph pair 41a, and the blockchain data subgraph 40b and the business data subgraph 40c in the graph database 40d can be combined to obtain the subgraph pair 41b; and then the similarity evaluation value between the two subgraphs contained in each subgraph pair can be obtained. For example, the similarity evaluation value between the blockchain data subgraph 40a and the business data subgraph 40c in the subgraph pair 41a is calculated to be a similarity evaluation value 1, and the similarity evaluation value between the blockchain data subgraph 40b and the business data subgraph 40c in the subgraph pair 41b is a similarity evaluation value 2.

[0128] Furthermore, the similarity evaluation value 1 and the similarity evaluation value 2 can be compared with the similarity threshold. If there is a similarity evaluation value greater than the similarity threshold, the blockchain data subgraph and the business data subgraph in the subgraph pair corresponding to the similarity evaluation value are merged. The similarity threshold is a limit or restriction value set to measure whether the blockchain data subgraph and the business data subgraph in a subgraph pair are merged. The specific value can be set according to the actual application. Figure 5 As shown, the similarity evaluation value 1 is greater than the similarity threshold, while the similarity evaluation value 2 is less than the similarity threshold. Therefore, the blockchain data subgraph 40a and the business data subgraph 40c in the subgraph pair 41a can be merged to obtain the business fusion subgraph 42a.

[0129] Specifically, the implementation method of subgraph merging may include: combining the nodes in the business data subgraph with the nodes in the i-th blockchain data subgraph to obtain N data node pairs; wherein a data node pair includes a node in the business data subgraph and a node in the i-th blockchain data subgraph; N is a positive integer, and the specific value of N can be a positive integer such as 1, 2 or 3. If there is an association relationship between the two nodes contained in the j-th data node in the N data node pairs, the two nodes contained in the j-th data node pair are connected to generate a candidate edge; j is a positive integer less than or equal to N, and the specific value of j can be 1, 2, 3...N. Further, a business fusion subgraph can be generated based on the candidate edges corresponding to the i-th blockchain data subgraph, the business data subgraph, and the N data node pairs.

[0130] Please also see Figure 6 , Figure 6 This is a schematic diagram of a sub-graph merging provided in an embodiment of the present application. Figure 2 For ease of description, the present application embodiment takes the i-th blockchain data subgraph as Figure 6 The specific merging process of the blockchain data subgraph 50a and the business data subgraph is described as follows. Figure 6 As shown, the blockchain data subgraph 50a may include node 1, node 2, node 3 and node 4, and the business data subgraph 50b may include node 2, node 5, node 6 and node 7. After obtaining the blockchain data subgraph 50a and the business data subgraph 50b, the first blockchain node may combine the nodes in the blockchain data subgraph 50a and the nodes in the business data subgraph 50b to obtain N data node pairs; for example, the generated data node pairs may include: data node pair (1,7), data node pair (2,2), data node pair (4,5) and other data node pairs. Among them, the data node pair (1,7) includes node 1 in the blockchain data subgraph 50a and node 7 in the business data subgraph 50b, the data node pair (2,2) includes node 2 in the blockchain data subgraph 50a and node 2 in the business data subgraph 50b, and the data node pair (4,5) includes node 4 in the blockchain data subgraph 50a and node 5 in the business data subgraph 50b.

[0131] Furthermore, the attribute relationship between the object entity types corresponding to the two nodes contained in each of the N data node pairs can be obtained, and then the attribute relationship can be used to determine whether there is an association relationship between the two nodes contained in each of the N data node pairs; or whether there is an association relationship between the two nodes contained in the data node pair can be determined based on the similarity evaluation value between the two nodes contained in the data node pair. For example, if the similarity evaluation value between the two nodes contained in the data node pair is greater than the similarity threshold, it is determined that there is an association relationship between the two nodes contained in the data node pair; otherwise, there is no association relationship between the two nodes contained in the data node pair. The similarity evaluation value between the two nodes contained in the data node pair can refer to the calculation method of the similarity evaluation value between the two subgraphs mentioned above, which will not be repeated here.

[0132] Assuming that there is an association relationship between the two nodes included in the data node pair (2,2), and there is an association relationship between the two nodes included in the data node pair (4,5), the first blockchain node can connect the two nodes included in the data node pair (2,2) to generate a candidate edge 51a, and can connect the two nodes included in the data node pair (4,5) to generate a candidate edge 51b; further, a business fusion subgraph 52b can be generated based on the blockchain data subgraph 50a, the business data subgraph 50b, and the candidate edge 51a and the candidate edge 51b.

[0133] like Figure 6 As shown, the blockchain data subgraph 50a, the business data subgraph 50b, and the candidate edges 51a and 51b can be merged into the initial fusion subgraph 52a. Further, the same nodes in the initial fusion subgraph 52a can be identified, for example, node 2 is the same node in the initial fusion subgraph 52a. In order to improve the readability and quality of the business fusion subgraph 52b, the same nodes in the initial fusion subgraph 52a need to be deduplicated. Node deduplication refers to deleting the same nodes in the initial fusion subgraph 52a and deleting the candidate edges between the same two nodes, only retaining one of the same nodes in the initial fusion subgraph 52a, and when deduplicating the same nodes in the initial fusion subgraph 52a, the connection relationship between the retained nodes and other nodes is supplemented according to the connection relationship between the nodes to be deduplicated and other nodes in the initial fusion subgraph 52a, so as to ensure that the integrity of the subgraph will not be destroyed after the nodes are deduplicated. In simple terms, node deduplication processing can refer to the process of merging the same nodes in the initial fusion subgraph into one node, canceling the candidate edges between the same nodes, and retaining the connection relationship between the same two nodes and other nodes.

[0134] like Figure 6As shown, the same node in the initial fusion subgraph 52a can be node 2, one node 2 in the initial fusion subgraph 52a can be deleted, and the candidate edge 51a can be deleted, only one node 2 is retained in the initial fusion subgraph 52a, and the connection relationship between node 2 and other nodes in the initial fusion subgraph 52a is completed, thereby completing the node deduplication of the initial fusion subgraph 52a, and the deduplicated initial fusion subgraph 52a is determined as the business fusion subgraph 52b.

[0135] In an embodiment of the present application, by performing node deduplication processing on the initial fusion subgraph, the obtained business fusion subgraph contains all the information in the initial fusion subgraph, but removes duplicate nodes, so that the obtained business fusion subgraph can more clearly express the relationship between blockchain data.

[0136] Step S207: Update the i-th blockchain data subgraph to a business fusion subgraph in the graph database.

[0137] like Figure 5 As shown, after obtaining the business fusion subgraph 42a, the blockchain data subgraph 40a stored in the graph database 40d can be updated to the business fusion subgraph 42a, thereby completing the data update of the graph database 40d. The updated graph database 40d includes the business fusion subgraph 42a and the blockchain data subgraph 40c.

[0138] See also Figure 7 , Figure 7 This is a schematic diagram of a blockchain data query provided by an embodiment of the present application. Figure 1 .like Figure 7 As shown, when the business node has a blockchain data query, it can generate a data query request and send the data query request to the first blockchain node. Accordingly, the first blockchain node can receive the data query request and parse the data query request to obtain the data query conditions and data query parameters carried in the data query request, and determine the data query authority corresponding to the business node according to the data query conditions and data query parameters carried in the data query request. For example, the data query authority can be "the transaction record of address A, the code of contract B, or the block information of block C, etc.

[0139] Further, the data query permission can be generated into a graph data query statement corresponding to the graph database. For example, when the graph database is Cypher or SPARQL, the graph data query statement can be a corresponding query language such as Cypher or SPARQL. Then, the data storage engine can be accessed through the graph data query statement, wherein the data storage engine can be a graph database, and the data on the chain is stored in the graph database. The data storage engine is mainly responsible for converting different types of blockchain data such as transactions, blocks, addresses, and contracts into the form of nodes and edges for storage. The data storage engine can also involve the update and synchronization of on-chain data to ensure that the data in the graph database is synchronized with the on-chain data. In order to improve the data query performance, a query optimizer can also be configured in the data storage engine, which can be responsible for calling the query algorithm to optimize the data query performance of the data storage engine, thereby improving the response speed and throughput of the data storage engine, reducing the query time and reducing resource consumption. Among them, the query algorithm can include but is not limited to: depth first search algorithm (Depth First Search, DFS), breadth first search algorithm (Breadth First Search, BFS) and other query algorithms.

[0140] Step S208: Add the nodes in the business data subgraph that match the business type to the business node set, divide the business data subgraph into subgraphs according to the association relationships between the nodes in the business node set in the business data subgraph, obtain a business screening subgraph, and add the business screening subgraph to the candidate data subgraph associated with the business type.

[0141] After obtaining the business data subgraph, query algorithms such as depth-first search algorithm and breadth-first search algorithm can be used to traverse and query the nodes contained in the business data subgraph, so as to filter out the nodes in the business data subgraph that match the business type, and add these nodes to the business node set. Optionally, the nodes in the business node set can be further screened to remove irrelevant nodes with weak associations with other nodes or poor business type relevance, so that the business screening subgraph obtained by division is more in line with the business query requirements, thereby improving the business query efficiency. For example, the probability that transaction data with a small asset transaction value (for example, an asset transaction value less than 50) belongs to an abnormal transaction is very low. When the business type is an abnormal transaction query type, it can be considered that the transaction data node with a small asset transaction value is an irrelevant node with poor business type relevance, so the transaction data node with a small asset transaction value can be removed from the business node set.

[0142] Optionally, nodes with weak associations with other nodes are also removed from the business node set. For example, the strength of the association between nodes can be characterized by the number of edges corresponding to the edge set of the node. The edge set of a node refers to the set of edges connecting the node with other nodes. The more edges the edge set of a node corresponds to, the stronger the association between the node and other nodes. Conversely, the fewer edges the edge set of a node corresponds to, the weaker the association between the node and other nodes, and the greater the probability that the node is an irrelevant node.

[0143] Specifically, the edge set of each node in the business node set in the business data subgraph can be obtained, and the node whose edge number corresponding to the edge set is less than the quantity threshold (a pre-set parameter) is determined as an abnormal node; then the abnormal nodes in the business node set are removed to obtain a candidate node set, and the remaining nodes in the business data subgraph except the candidate node set and the edge sets corresponding to the remaining nodes are deleted to obtain a business screening subgraph.

[0144] like Figure 6 As shown, assuming that nodes 1, 2, 4 and 5 in the business data subgraph 52b are nodes that match the business type, nodes 1, 2, 4 and 5 can be added to the business node set. For node 4, the edge set of node 4 in the business data subgraph 52b includes edge 51b and edge 51c, so the number of edges corresponding to the edge set of node 4 is 2; similarly, it can be determined that the number of edges corresponding to the edge set of node 1 is 1, the number of edges corresponding to the edge set of node 2 is 4, and the number of edges corresponding to the edge set of node 5 is 2. For ease of understanding, the embodiment of the present application is described with a value of 2 for the quantity threshold, and it can be determined that the number of edges corresponding to the edge set of node 1 in the business node set is less than the quantity threshold, so node 1 can be determined as an abnormal node. Further, node 1 can be removed from the business node set to obtain a candidate node set, and the nodes included in the candidate node set include node 2, node 4 and node 5. After obtaining the candidate node set, the remaining nodes (including node 1, node 3, node 6 and node 7) in the business data subgraph 52b except the candidate node set, and the edge sets corresponding to the remaining nodes can be deleted to obtain the business screening subgraph.

[0145] After obtaining the business screening subgraph, the business screening subgraph can be directly added to the candidate data subgraph in the graph database. At this time, the candidate data subgraph can contain multiple subgraphs including the business screening subgraph; or the business screening subgraph can be merged with the subgraph contained in the candidate data subgraph, and then the candidate data subgraph is updated according to the merged subgraph. At this time, the candidate data subgraph can include one or more subgraphs; the method of subgraph merging can refer to the description above, which will not be repeated here. Optionally, algorithms such as depth-first search or breadth-first search algorithms can also be used to convert the graph structure in the candidate data subgraph into a tree structure. The tree structure can clearly express the hierarchical relationship of the blockchain data in the candidate data subgraph, thereby improving the query efficiency of the data.

[0146] The embodiment of the present application uses a graph database as the underlying storage engine for blockchain data, and preliminarily screens out candidate data subgraphs that meet the business type in the graph database, and then uses the candidate data subgraphs as the data source for the business query tasks corresponding to the business type. It can be seen that the candidate data subgraphs obtained by screening according to the business type are particularly suitable for scenarios that deal with complex queries on blockchain data, such as community queries of chain relationships, abnormal transaction queries (for example, finding transactions or addresses with black market behavior), asset transaction details queries, asset holdings queries, and other query scenarios. The following is a detailed description of the query method for blockchain data involved in the embodiment of the present application, and specific reference may be made to steps S209 to S211 described below.

[0147] Step S209: receiving a business query task corresponding to the business type, determining a business node corresponding to the business query task, and determining a data query range corresponding to the business node according to the business query task.

[0148] The business query task is used to instruct the graph database to execute the blockchain data query request associated with the business type, where the business query task may include but is not limited to: the specific business type, the node identification information corresponding to the business node, the request query parameters (for example, the block height is A, the address of the initiated transaction address is B, the contract is C, and the transaction hash of no less than two internal transaction data), the accessed graph database identifier, the accessed candidate data subgraph identifier, the node public key corresponding to the business node, the digital signature generated according to the node private key corresponding to the business node, and other information.

[0149] Specifically, after receiving the business query task corresponding to the business type, the first blockchain node can determine the business node corresponding to the business query task according to the node identification information carried by the business query task; can obtain the digital signature carried by the business query task, and obtain the node public key corresponding to the business node; then decrypt the digital signature through the node public key to obtain the first summary information, and perform a hash operation on the business query task according to the hash algorithm used by the business node (consistent with the hash algorithm used when generating the digital signature) to obtain the second summary information. Among them, the hash algorithm can specifically include but is not limited to: SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512 algorithms.

[0150] Furthermore, the first summary information can be compared with the second summary information, and the request verification result can be determined according to the summary information comparison result. If the first summary information is different from the second summary information, it means that the digital signature carried in the business query task is invalid, and the business query task may have been tampered with during the transmission process. In this case, it can be determined that the request verification result corresponding to the business query task is verification failure. When the request verification result corresponding to the business query task indicates that the verification fails, the first blockchain node can send a request retransmission prompt message to the business node to instruct the business node to resend the business query task.

[0151] If the first summary information is the same as the second summary information, it indicates that the digital signature carried in the business query task is valid, that is, the business query task has not been tampered with during the transmission process, and at this time, it can be determined that the request verification result corresponding to the business query task is verified to be passed. In this case, the initial query range indicated by the business query task can be obtained, as well as the query authority range of the business node in the graph database; then the initial query range is compared with the query authority range to obtain the query range comparison result, and then the data query range corresponding to the business node is determined based on the query range comparison result.

[0152] Among them, the initial query scope may refer to the query scope determined according to the query parameters carried by the business query task. For example, the query parameters carried by the business query task are "business type is abnormal transaction query type, asset transfer address is address B, and asset transaction value is greater than 10,000 transaction data", then the initial query scope may be "business type is abnormal transaction query type, asset transfer address is address B, and asset transaction value is greater than 10,000 transaction data"; the query authority scope corresponding to the business node may refer to the query scope determined for the business node in the graph database according to the specific business needs and authority management strategies of the business node; the data query scope corresponding to the business node may refer to the query scope determined by the business node when initiating the business query task this time.

[0153] For example, the initial query scope may be "transaction data with business type of abnormal transaction query type, asset transfer address of address B, and asset transaction value greater than 10,000", and the query authority scope corresponding to the business node may be "block height of A, asset transfer address of address D". In this case, the initial query scope does not belong to the query authority scope, indicating that the business node does not have the query authority for blockchain data related to "asset transfer address of address D". At this time, the first blockchain node can return a query failure prompt message to the business node so that the business node can re-enter the query parameters according to the query failure prompt message.

[0154] Assuming that the initial query scope can be "business type is abnormal transaction query type, asset transfer address is address B, and asset transaction value is greater than 10,000 transaction data", the query authority scope corresponding to the business node can be "block height is A, asset transfer address is address B and address D, and asset transfer address is address B and address D transaction data", in this case, the initial query scope belongs to the query authority scope, and the initial query scope "business type is abnormal transaction query type, asset transfer address is address B, and asset transaction value is greater than 10,000 transaction data" can be determined as the data query range "business type is abnormal transaction query type, asset transfer address is address B, and asset transaction value is greater than 10,000 transaction data".

[0155] Step S210: perform a traversal query on the nodes included in the candidate data subgraph, and obtain a business query subgraph that matches the data query range from the candidate data subgraph.

[0156] In an embodiment of the present application, the first blockchain node can obtain a candidate data subgraph associated with a business type (for example, an abnormal transaction query type) from a graph database according to a business query task, and then traverse and query the nodes contained in the candidate data subgraph one by one, match each node with the data query range, and add the nodes that match the data query range to the candidate node set, and then generate a business query subgraph based on the association relationship between the nodes in the candidate node set in the candidate data subgraph.

[0157] Specifically, the search start node that belongs to the data query range can be determined in the candidate data subgraph, and the neighbor nodes corresponding to the search start node are added to the first neighbor node set; if there are nodes that do not belong to the data query range in the first neighbor node set, the nodes that do not belong to the data query range are cleared to obtain the second neighbor node set; the neighbor nodes corresponding to the nodes in the second neighbor node set are added to the third neighbor node set, and the nodes that do not belong to the data query range in the third neighbor node set are cleared to obtain the fourth neighbor node set; if the nodes in the fourth neighbor node set are all leaf nodes in the candidate data subgraph, a query subgraph is generated based on the association relationship between the search start node, the nodes in the second neighbor node set, and the nodes in the fourth neighbor node set in the candidate data subgraph. In the embodiment of the present application, the candidate data subgraph is a subgraph associated with the business type in the graph database. By expanding and traversing the nodes in the candidate data subgraph layer by layer, the business query subgraph associated with the business query task can be quickly found, thereby improving the data query efficiency in specific business query scenarios.

[0158] Please also see Figure 8 , Figure 8 This is a schematic diagram of a sub-graph matching provided in an embodiment of the present application. Figure 1 .like Figure 8 As shown, the graph database 60c may include multiple candidate data subgraphs, for example, candidate data subgraph 60a and candidate data subgraph 60b. Candidate data subgraph 60a and candidate data subgraph 60b may contain subgraph tags, and the subgraph tags are used to describe the business type associated with the corresponding candidate data subgraph. For example, the subgraph tag corresponding to candidate data subgraph 60a may be "abnormal transaction query type", then candidate data subgraph 60a may be a candidate data subgraph associated with the business type corresponding to the abnormal transaction query type. It can be understood that the query efficiency of blockchain data can be improved by adding subgraph tags to candidate data subgraphs. After determining the data query range corresponding to the business node, the first blockchain node can determine the blockchain subgraphs whose subgraph tags belong to the data query range in blockchain data subgraph 60a and blockchain data subgraph 60b as candidate data subgraphs. For example, the subgraph tag corresponding to blockchain data subgraph 60a belongs to the "abnormal transaction query type" indicated by the data query range, then blockchain data subgraph 60a can be determined as a candidate data subgraph associated with the business query task.

[0159] like Figure 8As shown, any node in the candidate data subgraph 60a that belongs to the data query range can be used as the search starting node of the candidate data subgraph 60a. For example, if node 1 in the candidate data subgraph 60a belongs to the data query range, node 1 can be determined as the search starting node of the candidate data subgraph 60a. Then, the neighbor nodes of node 1 in the candidate data subgraph 60a can be obtained, and the neighbor nodes corresponding to node 1 (including node 2, node 3, node 4, node 5 and node 6) are added to the first neighbor node set 61a; the nodes in the first neighbor node set 61a are compared with the data query range. If there are nodes in the first neighbor node set 61a that do not belong to the data query range, the nodes that do not belong to the data query range are cleared to obtain the second neighbor node set 61b; for example, if node 2 and node 3 in the first neighbor node set 61a do not belong to the data query range, node 2 and node 3 can be cleared from the first neighbor node set 61a, and the cleared first neighbor node set is determined as the second neighbor node set 61b; the nodes in the second neighbor node set 61b include node 4, node 5 and node 6.

[0160] Similarly, the neighbor nodes of the nodes in the second neighbor node set 61b in the candidate data subgraph 60a can be obtained, and the neighbor nodes corresponding to the nodes in the second neighbor node set 61b (including node 7 and node 8) are added to the third neighbor node set 61c; the nodes in the third neighbor node set 61c are compared with the data query range. If there are nodes in the third neighbor node set 61c that do not belong to the data query range, the nodes that do not belong to the data query range are cleared to obtain the fourth neighbor node set 61d; for example, if node 7 in the third neighbor node set 61c does not belong to the data query range, node 7 can be cleared from the third neighbor node set 61c, and the cleared third neighbor node set is determined as the fourth neighbor node set 61d; the nodes in the fourth neighbor node set 61d include node 8. Repeat the above process until all nodes in a certain neighbor node set belong to the data query range and are all leaf nodes in the candidate data subgraph 60a, then stop traversing. Figure 8 As shown, the fourth neighbor node set 61d includes node 8, which is a leaf node in the candidate data subgraph 60a. At this time, the traversal can be stopped, and the following is generated based on the association between the search start node (node ​​1), the nodes in the second neighbor node set 61b (node ​​4, node 5 and node 6), and the node in the fourth neighbor node set 61d (node ​​8) in the candidate data subgraph 60a. Figure 8 Business query subgraph 62a is shown.

[0161] Optionally, the traversal of the nodes in the candidate data subgraph 60a can also be achieved through a queue (following the first-in-first-out principle), and the nodes in the queue represent the nodes in the candidate data subgraph 60a that have been traversed. Specifically, the starting search node (node ​​1) in the candidate data subgraph 60a can be added to the queue, indicating that node 1 has been traversed. If node 1 belongs to the data query range, node 1 is removed from the queue, that is, the node removed from the queue is the node that belongs to the data query range; then the neighbor nodes corresponding to node 1 (including node 2, node 3, node 4, node 5 and node 6) can be added to the queue, and the nodes in the above nodes that belong to the data query range are removed from the queue. Repeat the above process until all nodes in the candidate data subgraph 60a have been added to the queue, and the nodes removed from the queue are associated with the candidate data subgraph 60a to generate a query subgraph. Optionally, the nodes that have been traversed in the candidate data subgraph 60a may be visually labeled. For example, different colors or labels may be added to the nodes that have been traversed and the nodes that have not been traversed in the candidate data subgraph 60a.

[0162] Optionally, you can also use a stack (following the first-in, last-out principle) to implement traversal of nodes in the candidate data subgraph. The nodes in the stack represent the nodes in the candidate data subgraph that have been traversed. For details, see Fig. 9 , Fig. 9 This is a schematic diagram of a sub-graph matching provided in an embodiment of the present application. Figure 2 .like Fig. 9 As shown in FIG. 1 , node 2 in the candidate data subgraph 70a belongs to the data query range, so node 2 can be determined as the starting search node of the candidate data subgraph 70a, and node 2 is added to the stack. Assume that when traversing the nodes in the candidate data subgraph 70a, the nodes of the left branch are traversed first. Fig. 9 As shown, the neighbor node of node 2 belonging to the left branch, that is, node 12, can be added to the stack, and it is determined whether node 12 belongs to the data query range. Assuming that node 12 belongs to the data query range, node 13 can be added to the stack.

[0163] Similarly, determine whether node 13 belongs to the data query range. Assuming that node 13 does not belong to the data query range, node 13 is removed from the stack. At this time, the nodes in the stack include node 2 and node 12. Since node 13 does not belong to the data query range, node backtracking is required at this time, that is, node 14 is no longer added to the stack at this time, but the neighboring nodes that node 12 has not traversed, such as node 4, are searched, and node 4 is added to the stack. Node 4 is compared with the data query range to determine that node 4 belongs to the data query range.

[0164] like Fig. 9As shown, node 4 is a leaf node in the candidate data subgraph 70a. Therefore, node 4 has no neighbor nodes other than node 12 in the candidate data subgraph 70a, and node 4 needs to be removed from the stack. At this time, the nodes in the stack include node 2 and node 12. Since the neighbor nodes of node 12 have been traversed, node 12 can be removed from the stack, and node 11 can be added to the stack. If node 11 belongs to the data query range, node 11 is removed from the stack, and node 2 has no untraversed neighbor nodes, node 2 is removed from the stack. At this time, the stack is empty, indicating that the traversal of the candidate data subgraph 70a is completed, and then the nodes in the candidate data subgraph 70a that belong to the data query range (including node 2, node 12, node 4 and node 11) can be quickly determined, and based on the nodes 2, node 12, node 4 and node 11 in the candidate data subgraph 70a, the following is generated. Fig. 9 Business query subgraph 70b is shown.

[0165] Optionally, after obtaining the candidate data subgraph associated with the business query task in the graph database, the candidate data subgraph can be queried in parallel through computing engines such as Apache Spark, MapReduce, and Hadoop, and the business query subgraph associated with the business query task can be quickly queried from the candidate data subgraph. For example, a resilient distributed dataset (RDD) corresponding to the candidate data subgraph can be created through ApacheSpark, and then the resilient distributed dataset corresponding to the candidate data subgraph can be calculated in parallel, and then the business query subgraph matching the data query range corresponding to the business query task can be queried in the candidate data subgraph through aggregation operations.

[0166] It can be seen that when using the candidate data subgraph as the data source for business query tasks, parallel querying of nodes in the candidate data subgraph through streaming computing frameworks such as Apache Spark can further improve business query efficiency.

[0167] Step S211: encrypt the business query subgraph using the node public key corresponding to the business node, obtain the data query result corresponding to the business query task, and return the data query result to the business node.

[0168] In order to improve the data security of the business query subgraph and prevent it from being leaked during transmission, after obtaining the business query subgraph, the first blockchain node can encrypt the business query subgraph through the node public key corresponding to the business node, determine the encrypted business query subgraph as the data query result corresponding to the business query task, and send the data query result to the business node. Correspondingly, after receiving the data query result, the business node can decrypt the data query result through its own node private key to obtain the business query subgraph, so as to use the business query subgraph to complete business processing.

[0169] See also Fig.10 , Fig.10 This is a schematic diagram of a blockchain data query provided by an embodiment of the present application. Figure 2 .like Fig.10 As shown, the blockchain node can call the query interface service (e.g., Web3proxy) to detect whether there are transaction blocks that need to be synchronized in the blockchain. For example, a block height query request can be sent to other blockchain nodes in the blockchain network through the query interface service, and the block detection component is responsible for detecting the on-chain block height of other blockchain nodes in the blockchain network. When the local block height is less than the on-chain block height, the transaction block that needs to be synchronized (referred to as the synchronized transaction block) is obtained, and the synchronized transaction block is stored through the block cache component.

[0170] like Fig.10 As shown, the synchronous transaction block can be parsed through the block parsing component to obtain the block header corresponding to the synchronous transaction block, and the block header corresponding to the synchronous transaction block is used as a node; then the block transaction list corresponding to the synchronous transaction block is obtained, and the transaction data corresponding to each transaction hash in the block transaction list is obtained, and each transaction data is used as a node, and the edge between the synchronous transaction block and the transaction data is established according to the block transaction list. Further, each transaction data is parsed, and the on-chain transaction address corresponding to each transaction data is obtained, and the address information and contract information corresponding to the transaction data are obtained according to the on-chain transaction address, and the address information and contract information corresponding to the transaction data are used as nodes, and the edge between the transaction data and the address is established according to the on-chain transaction address, thereby generating a business data subgraph, and the business data subgraph is passed into the graph database through the graph database interface to complete the data update of the graph database. When the business node has a blockchain data query demand, the graph database interface can be called to read the data in the graph database, and the blockchain data required by the business node can be quickly found in the graph database.

[0171] In an embodiment of the present application, business object entities that match each object entity type can be determined in the business transaction block, and then the business object entities in the business transaction block are used as nodes, and the association relationship between the business object entities in the business transaction block is used as an edge to generate a business data subgraph, and the business data subgraph is added to the graph database to update the graph database. It can be seen that the embodiment of the present application uses a graph database instead of a key-value pair database to store blockchain data. Since the graph database can directly store the business object entities in the blockchain data and the association relationship between the business object entities, the query efficiency of the blockchain data can be improved when querying blockchain data involving complex relationships. In addition, after obtaining the business data subgraph, the business data subgraph can also be divided into subgraphs to obtain a business screening subgraph associated with the business type, and the business screening subgraph is added to the candidate data subgraph associated with the business type, so that business queries can be performed through the candidate data subgraph, thereby further improving the data query efficiency in specific business query scenarios.

[0172] It is understandable that in the specific implementation of this application, user-related information (for example, the user's business query, login information, etc.) may be involved. When the above embodiments of this application are applied to specific products or technologies, the user's permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards in the relevant regions.

[0173] See also Fig.11 , Fig.11 1 is a schematic diagram of a data processing device based on blockchain provided in an embodiment of the present application. It can be understood that the data processing device 1 based on blockchain can be applied in the first blockchain node. Fig.11 As shown, the blockchain-based data processing device 1 may include a business transaction block acquisition module 11, a business object entity acquisition module 12, an association relationship acquisition module 13, a business data subgraph generation module 14, and a business subgraph screening module 15, wherein:

[0174] The business transaction block acquisition module 11 is used to obtain the first block height corresponding to the first blockchain node, and obtain the business transaction block according to the first block height;

[0175] The business object entity acquisition module 12 is used to acquire multiple object entity types in the graph database, and determine the business object entities matching each object entity type in the business transaction block according to the field information corresponding to each object entity type; the graph database is used to store the data in the blockchain corresponding to the first blockchain node;

[0176] The association relationship acquisition module 13 is used to acquire the attribute relationship between each object entity type, and determine the association relationship between the business object entities in the business transaction block according to the attribute relationship between each object entity type;

[0177] A business data subgraph generation module 14 is used to generate a business data subgraph using business object entities in a business transaction block as nodes and association relationships between business object entities in the business transaction block as edges, and add the business data subgraph to a graph database;

[0178] The business subgraph screening module 15 is used to add the nodes in the business data subgraph that match the business type to the business node set, and to perform subgraph division processing on the business data subgraph according to the association relationship between the nodes in the business node set in the business data subgraph to obtain a business screening subgraph, and to add the business screening subgraph to the candidate data subgraph associated with the business type; the candidate data subgraph is the data source of the business query task corresponding to the business type.

[0179] In a possible implementation, the business transaction block acquisition module 11 acquires the business transaction block according to the first block height, including:

[0180] Obtaining a second block height corresponding to the second blockchain node; the first blockchain node and the second blockchain node are in the same business blockchain network;

[0181] If the first block height is less than the second block height, a block synchronization request is sent to the second blockchain node, so that the second blockchain node determines the block to be synchronized for the first blockchain node according to the block synchronization request;

[0182] Receive the block to be synchronized returned by the second blockchain node, and determine the block to be synchronized as a business transaction block.

[0183] In a possible implementation, the business transaction block acquisition module 11 acquires the business transaction block according to the first block height, including:

[0184] Determine the consensus block height according to the first block height, and generate a consensus block corresponding to the consensus block height;

[0185] Broadcasting the consensus block in the business blockchain network corresponding to the first blockchain node, so that the blockchain nodes in the business blockchain network perform consensus processing on the consensus block and obtain the consensus voting result corresponding to the consensus block;

[0186] Obtain the consensus voting results corresponding to each blockchain node in the business blockchain network, and determine the block consensus result corresponding to the consensus block based on the consensus voting results corresponding to each blockchain node; one blockchain node corresponds to one consensus voting result;

[0187] If the block consensus result indicates that the consensus block has reached a consensus, the consensus block will be determined as a business transaction block.

[0188] In a possible implementation, the business transaction block acquisition module 11 determines the block consensus result corresponding to the block to be agreed upon according to the consensus voting results corresponding to each blockchain node, including:

[0189] In the consensus voting results corresponding to each blockchain node, count the number of votes in favor of the voting results;

[0190] If the number of votes is less than the threshold number of votes, it is determined that the block consensus result corresponding to the block to be agreed upon indicates that the block to be agreed upon has not reached a consensus, and the block to be agreed upon is cleared from the first blockchain node;

[0191] If the number of votes is greater than or equal to the threshold number of votes, the block consensus result is determined to indicate that the consensus block is to be reached.

[0192] In a possible implementation, the business data subgraph generation module 14 adds the business data subgraph to the graph database, including:

[0193] Obtain M blockchain data subgraphs contained in the graph database, and obtain similarity evaluation values ​​between each blockchain data subgraph and the business data subgraph; M is a positive integer;

[0194] If the similarity evaluation value between the business data subgraph and the i-th blockchain data subgraph among the M blockchain data subgraphs is greater than the similarity threshold, the i-th blockchain data subgraph and the business data subgraph are merged into a business fusion subgraph; i is a positive integer less than or equal to M;

[0195] Update the i-th blockchain data subgraph to the business fusion subgraph in the graph database.

[0196] In a possible implementation, if the similarity evaluation value between the business data subgraph and the i-th blockchain data subgraph among the M blockchain data subgraphs is greater than the similarity threshold, the business data subgraph generation module 14 merges the i-th blockchain data subgraph with the business data subgraph into a business fusion subgraph, including:

[0197] If the similarity evaluation value between the business data subgraph and the i-th blockchain data subgraph among the M blockchain data subgraphs is greater than the similarity threshold, the node in the business data subgraph is combined with the node in the i-th blockchain data subgraph to obtain N data node pairs; a data node pair includes a node in the business data subgraph and a node in the i-th blockchain data subgraph; N is a positive integer;

[0198] If there is an association relationship between the two nodes contained in the jth data node in the N data node pairs, the two nodes contained in the jth data node pair are connected to generate a candidate edge; j is a positive integer less than or equal to N;

[0199] A business fusion subgraph is generated according to the i-th blockchain data subgraph, the business data subgraph, and the candidate edges corresponding to the N data node pairs.

[0200] In a possible implementation, the business data subgraph generation module 14 generates a business fusion subgraph according to the i-th blockchain data subgraph, the business data subgraph, and the candidate edges corresponding to the N data node pairs, including:

[0201] Merge the i-th blockchain data subgraph, the business data subgraph, and the candidate edges corresponding to the N data node pairs into an initial fusion subgraph;

[0202] If it is detected that the same nodes exist in the initial fusion subgraph, the same nodes are deduplicated in the initial fusion subgraph, and the deduplicated initial fusion subgraph is determined as the service fusion subgraph.

[0203] In a possible implementation, the business subgraph screening module 15 performs subgraph partitioning processing on the business data subgraph according to the association relationship between the nodes in the business node set in the business data subgraph to obtain a business screening subgraph, including:

[0204] Obtain an edge set of each node in the business node set in the business data subgraph, and determine a node whose edge number corresponding to the edge set is less than a quantity threshold as an abnormal node;

[0205] Abnormal nodes are removed from the business node set to obtain a candidate node set, and the remaining nodes except the candidate node set in the business data subgraph and the edge sets corresponding to the remaining nodes are deleted to obtain a business screening subgraph.

[0206] In a possible implementation, the blockchain-based data processing device 1 further includes: a query range determination module 16, a query subgraph acquisition module 17, and a query result acquisition module 18, wherein:

[0207] A query range determination module 16 is used to receive a business query task corresponding to a business type, determine a business node corresponding to the business query task, and determine a data query range corresponding to the business node according to the business query task;

[0208] The query subgraph acquisition module 17 is used to perform a traversal query on the nodes included in the candidate data subgraph, and obtain a business query subgraph that matches the data query range from the candidate data subgraph;

[0209] The query result acquisition module 18 is used to encrypt the business query subgraph through the node public key corresponding to the business node, obtain the data query result corresponding to the business query task, and return the data query result to the business node.

[0210] In a possible implementation, the query scope determination module 16 determines the data query scope corresponding to the service node according to the service query task, including:

[0211] Obtain the digital signature carried by the business query task, and obtain the node public key corresponding to the business node;

[0212] The digital signature is decrypted by the node public key to obtain the first summary information, and the business query task is hashed according to the hash algorithm to obtain the second summary information;

[0213] If the first summary information is the same as the second summary information, then obtaining the initial query scope indicated by the business query task, and obtaining the query authority scope of the business node in the candidate data subgraph;

[0214] If the initial query scope does not fall within the query authority scope, a query failure prompt message is returned to the business node;

[0215] If the initial query scope belongs to the query authority scope, the initial query scope is determined as the data query scope corresponding to the business node.

[0216] In a possible implementation, the query subgraph acquisition module 17 performs a traversal query on the nodes included in the candidate data subgraph, and acquires a business query subgraph matching the data query range from the candidate data subgraph, including:

[0217] Determine a search start node that belongs to the data query range in the candidate data subgraph, and add neighbor nodes corresponding to the search start node to the first neighbor node set;

[0218] If there are nodes that do not belong to the data query range in the first neighbor node set, then the nodes that do not belong to the data query range are removed to obtain a second neighbor node set;

[0219] Adding neighbor nodes corresponding to nodes in the second neighbor node set to the third neighbor node set, removing nodes in the third neighbor node set that do not belong to the data query range, and obtaining a fourth neighbor node set;

[0220] If the nodes in the fourth neighbor node set are all leaf nodes in the candidate data subgraph, a business query subgraph is generated based on the association between the search start node, the nodes in the second neighbor node set, and the nodes in the fourth neighbor node set in the candidate data subgraph.

[0221] According to an embodiment of the present application, the above Figure 2 and Figure 4 The steps involved in the data processing method shown can be represented by Fig.11 The various modules in the blockchain-based data processing device 1 shown are executed. For example, Figure 2 Step S101 shown can be performed by Fig.11 The business transaction block acquisition module 11 is executed, Figure 2 Step S102 shown can be performed by Fig.11 The business object entity acquisition module 12 shown is executed. Figure 2 Step S103 shown can be performed by Figure 2 The association relationship acquisition module 13 shown is used to execute, Figure 2 Step S104 shown can be performed by Fig.11 The business data subgraph generation module 14 shown, Figure 2 Step 105 shown may be performed by Fig.11 The business subgraph screening module 15 shown is used to perform the above operations.

[0222] According to one embodiment of the present application, Fig.11 The various modules in the blockchain-based data processing device 1 shown can be separately or completely combined into one or several units to constitute, or one (some) of the units can be further divided into at least two functionally smaller sub-units, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In practical applications, the functions of one module can also be implemented by at least two units, or the functions of at least two modules can be implemented by one unit. In other embodiments of the present application, the blockchain-based data processing device 1 may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by at least two units in collaboration.

[0223] In an embodiment of the present application, business object entities that match each object entity type can be determined in the business transaction block, and then the business object entities in the business transaction block are used as nodes, and the association relationship between the business object entities in the business transaction block is used as an edge to generate a business data subgraph, and the business data subgraph is added to the graph database to update the graph database. It can be seen that the embodiment of the present application uses a graph database instead of a key-value pair database to store blockchain data. Since the graph database can directly store the business object entities in the blockchain data and the association relationship between the business object entities, the query efficiency of the blockchain data can be improved when querying blockchain data involving complex relationships. In addition, after obtaining the business data subgraph, the business data subgraph can also be divided into subgraphs to obtain a business screening subgraph associated with the business type, and the business screening subgraph is added to the candidate data subgraph associated with the business type, so that business queries can be performed through the candidate data subgraph, thereby further improving the data query efficiency in specific business query scenarios.

[0224] See also Fig.12 , Fig.12 Schematic diagram of the structure of a computer device provided in an embodiment of the present application. Fig.12 As shown, the computer device 1000 can be a terminal device or a server, which will not be limited here. For ease of understanding, this application takes the computer device as a terminal device as an example. The computer device 1000 may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the computer device 1000 may also include: a user interface 1003, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, the user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and optionally, the user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may also be optionally at least one storage device located away from the aforementioned processor 1001. As Fig.12 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.

[0225] Among them, Fig.12In the computer device 1000 shown, the network interface 1004 can provide a network communication function; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:

[0226] Obtain a first block height corresponding to the first blockchain node, and obtain a business transaction block according to the first block height;

[0227] Acquire multiple object entity types in the graph database, and determine business object entities matching each object entity type in the business transaction block according to field information corresponding to each object entity type; the graph database is used to store data in the blockchain corresponding to the first blockchain node;

[0228] Obtain the attribute relationship between each object entity type, and determine the association relationship between the business object entities in the business transaction block according to the attribute relationship between each object entity type;

[0229] Generate a business data subgraph using the business object entities in the business transaction block as nodes and the association relationships between the business object entities in the business transaction block as edges, and add the business data subgraph to the graph database;

[0230] Add the nodes in the business data subgraph that match the business type to the business node set, divide the business data subgraph into subgraphs according to the association relationships between the nodes in the business node set in the business data subgraph, and obtain a business screening subgraph. Add the business screening subgraph to the candidate data subgraph associated with the business type; the candidate data subgraph is the data source of the business query task corresponding to the business type.

[0231] It should be understood that the computer device 1000 described in the embodiment of the present application can execute the above Figure 2 and Figure 4 The description of the data processing method based on blockchain in the corresponding embodiment can also be performed as described above. Fig.11 The description of the data processing device based on blockchain in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here.

[0232] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the blockchain-based data processing device 1 mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the above Figure 2 and Figure 4The description of the data processing method based on blockchain in any corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application. As an example, program instructions can be deployed on a computer device for execution, or on multiple computer devices located at one location, or on multiple computer devices distributed at multiple locations and interconnected by a communication network. Multiple computer devices distributed at multiple locations and interconnected by a communication network can constitute a blockchain system.

[0233] In addition, it should be noted that: the embodiment of the present application also provides a computer program product or a computer program, which may include computer instructions, and the computer instructions may be stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor may execute the computer instructions, so that the computer device executes the above Figure 2 and Figure 4 The description of the data processing method based on blockchain in any corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer program product or computer program embodiment involved in this application, please refer to the description of the method embodiment of this application.

[0234] It should be noted that, for the above-mentioned various method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.

[0235] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.

[0236] The modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.

[0237] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0238] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A data processing method based on blockchain, It is characterized in that include: Obtaining a first block height corresponding to a first blockchain node, and obtaining a business transaction block according to the first block height; Acquire multiple object entity types in a graph database, and determine business object entities matching each object entity type in the business transaction block according to field information corresponding to each object entity type; the graph database is used to store data in the blockchain corresponding to the first blockchain node; Acquire the attribute relationship between each object entity type, and determine the association relationship between the business object entities in the business transaction block according to the attribute relationship between each object entity type; Generate a business data subgraph using the business object entities in the business transaction block as nodes and the association relationships between the business object entities in the business transaction block as edges, and add the business data subgraph to the graph database; Add the nodes in the business data subgraph that match the business type to the business node set, divide the business data subgraph into subgraphs according to the association relationships between the nodes in the business node set in the business data subgraph to obtain a business screening subgraph, and add the business screening subgraph to the candidate data subgraph associated with the business type; the candidate data subgraph is the data source of the business query task corresponding to the business type.

2. The method according to claim 1, It is characterized in that The obtaining of the business transaction block according to the first block height includes: Obtaining a second block height corresponding to a second blockchain node; the first blockchain node and the second blockchain node are in the same business blockchain network; If the first block height is less than the second block height, sending a block synchronization request to the second blockchain node, so that the second blockchain node determines a block to be synchronized for the first blockchain node according to the block synchronization request; Receive the block to be synchronized returned by the second blockchain node, and determine the block to be synchronized as the business transaction block.

3. The method according to claim 1, It is characterized in that The obtaining of the business transaction block according to the first block height includes: Determine the consensus block height according to the first block height, and generate a consensus block corresponding to the consensus block height; Broadcasting the block to be agreed upon in the business blockchain network corresponding to the first blockchain node, so that the blockchain nodes in the business blockchain network perform consensus processing on the block to be agreed upon, and obtaining a consensus voting result corresponding to the block to be agreed upon; Obtain the consensus voting results corresponding to each blockchain node in the business blockchain network, and determine the block consensus result corresponding to the block to be agreed upon according to the consensus voting results corresponding to each blockchain node; one blockchain node corresponds to one consensus voting result; If the block consensus result indicates that the block to be agreed upon has reached a consensus, the block to be agreed upon is determined as the business transaction block.

4. The method according to claim 3, It is characterized in that Determining the block consensus result corresponding to the block to be consensus according to the consensus voting results corresponding to each blockchain node includes: In the consensus voting results corresponding to each blockchain node, count the number of votes in favor of the voting results; If the number of votes is less than the threshold number of votes, determining that the block consensus result corresponding to the block to be agreed upon indicates that the block to be agreed upon has not reached a consensus, and clearing the block to be agreed upon in the first blockchain node; If the number of votes is greater than or equal to the vote number threshold, it is determined that the block consensus result indicates that the block to be agreed upon has reached a consensus.

5. The method according to claim 1, It is characterized in that The adding the business data subgraph to the graph database comprises: Obtain M blockchain data subgraphs contained in the graph database, and obtain similarity evaluation values ​​between each blockchain data subgraph and the business data subgraph; M is a positive integer; If the similarity evaluation value between the business data subgraph and the i-th blockchain data subgraph among the M blockchain data subgraphs is greater than the similarity threshold, the i-th blockchain data subgraph and the business data subgraph are merged into a business fusion subgraph; i is a positive integer less than or equal to M; In the graph database, the i-th blockchain data subgraph is updated to the business fusion subgraph.

6. The method according to claim 5, It is characterized in that If the similarity evaluation value between the business data subgraph and the i-th blockchain data subgraph among the M blockchain data subgraphs is greater than a similarity threshold, merging the i-th blockchain data subgraph and the business data subgraph into a business fusion subgraph, including: If the similarity evaluation value between the business data subgraph and the i-th blockchain data subgraph among the M blockchain data subgraphs is greater than the similarity threshold, the nodes in the business data subgraph are combined with the nodes in the i-th blockchain data subgraph to obtain N data node pairs; a data node pair includes a node in the business data subgraph and a node in the i-th blockchain data subgraph; N is a positive integer; If there is an association relationship between the two nodes included in the j-th data node in the N data node pairs, the two nodes included in the j-th data node pair are connected to generate a candidate edge; j is a positive integer less than or equal to N; The business fusion subgraph is generated according to the i-th blockchain data subgraph, the business data subgraph, and the candidate edges corresponding to the N data node pairs.

7. The method according to claim 6, It is characterized in that The generating the business fusion subgraph according to the i-th blockchain data subgraph, the business data subgraph, and the candidate edges corresponding to the N data node pairs includes: Merge the i-th blockchain data subgraph, the business data subgraph, and the candidate edges corresponding to the N data node pairs into an initial fusion subgraph; If it is detected that the same nodes exist in the initial fusion subgraph, the same nodes are deduplicated in the initial fusion subgraph, and the deduplicated initial fusion subgraph is determined as the service fusion subgraph.

8. The method according to claim 1, It is characterized in that The subgraph division process is performed on the business data subgraph according to the association relationship of the nodes in the business node set in the business data subgraph to obtain the business screening subgraph, including: Obtaining an edge set of each node in the business node set in the business data subgraph, and determining a node whose edge quantity corresponding to the edge set is less than a quantity threshold as an abnormal node; The abnormal nodes are removed from the business node set to obtain a candidate node set, and the remaining nodes in the business data subgraph except the candidate node set and the edge sets corresponding to the remaining nodes are deleted to obtain a business screening subgraph.

9. The method according to claim 1, It is characterized in that The method further comprises: receiving a business query task corresponding to the business type, determining a business node corresponding to the business query task, and determining a data query range corresponding to the business node according to the business query task; Performing a traversal query on the nodes included in the candidate data subgraph, and obtaining a business query subgraph matching the data query range from the candidate data subgraph; The business query subgraph is encrypted by using the node public key corresponding to the business node to obtain the business query result corresponding to the business query task, and the business query result is returned to the business node.

10. The method according to claim 9, It is characterized in that The determining the data query range corresponding to the business node according to the business query task includes: Obtaining the digital signature carried by the business query task, and obtaining the node public key corresponding to the business node; Decrypting the digital signature by using the node public key to obtain first summary information, and performing a hash operation on the business query task according to a hash algorithm to obtain second summary information; If the first summary information is the same as the second summary information, obtaining an initial query scope indicated by the business query task, and obtaining a query authority scope of the business node in the candidate data subgraph; If the initial query scope does not belong to the query authority scope, returning query failure prompt information to the service node; If the initial query scope belongs to the query authority scope, the initial query scope is determined as the data query scope corresponding to the business node.

11. The method according to claim 9, It is characterized in that The traversing query of the nodes included in the candidate data subgraph to obtain a business query subgraph matching the data query range from the candidate data subgraph includes: Determine a search start node that belongs to the data query range in the candidate data subgraph, and add neighbor nodes corresponding to the search start node to a first neighbor node set; If there are nodes in the first neighbor node set that do not belong to the data query range, then remove the nodes that do not belong to the data query range to obtain a second neighbor node set; Adding neighbor nodes corresponding to nodes in the second neighbor node set to a third neighbor node set, removing nodes in the third neighbor node set that do not belong to the data query range, and obtaining a fourth neighbor node set; If the nodes in the fourth neighbor node set are all leaf nodes in the candidate data subgraph, the business query subgraph is generated according to the association relationship between the search start node, the nodes in the second neighbor node set, and the nodes in the fourth neighbor node set in the candidate data subgraph.

12. A data processing device based on blockchain, It is characterized in that include: A business transaction block acquisition module, used to acquire a first block height corresponding to a first blockchain node, and acquire a business transaction block according to the first block height; A business object entity acquisition module, used to acquire multiple object entity types in a graph database, and determine business object entities matching each object entity type in the business transaction block according to field information corresponding to each object entity type; the graph database is used to store data in the blockchain corresponding to the first blockchain node; An association relationship acquisition module, used to acquire the attribute relationship between each object entity type, and determine the association relationship between the business object entities in the business transaction block according to the attribute relationship between each object entity type; A business data subgraph generation module, used to generate a business data subgraph using the business object entities in the business transaction block as nodes and the association relationships between the business object entities in the business transaction block as edges, and add the business data subgraph to the graph database; A business subgraph screening module is used to add the nodes in the business data subgraph that match the business type to the business node set, and to perform subgraph division processing on the business data subgraph according to the association relationship between the nodes in the business node set in the business data subgraph to obtain a business screening subgraph, and to add the business screening subgraph to the candidate data subgraph associated with the business type; the candidate data subgraph is the data source of the business query task corresponding to the business type.

13. A computer device, It is characterized in that including memory and processor; The memory is connected to the processor, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method according to any one of claims 1 to 11.

14. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 11.

15. A computer program product, It is characterized in that The method comprises a computer program / instruction, which implements the method according to any one of claims 1 to 11 when executed by a processor.