A blockchain transaction allocation method and apparatus

By identifying the pilot block and generating the target marker hash in the blockchain network, and assigning target node numbers to transactions, the problems of transaction duplication and monopoly under high concurrency are solved, thereby improving transaction throughput, network security, and fairness.

CN115730009BActive Publication Date: 2026-01-09CHINA UNIONPAY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211450950.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-18
Publication Date
2026-01-09
Estimated Expiration
2042-11-18

AI Technical Summary

Technical Problem

In blockchain networks, the problem of transaction duplication under high concurrency leads to insignificant increases in transaction throughput, and transactions may be filtered or monopolized by specific nodes, affecting network security and fairness.

Method used

By determining the pilot block pointed to by the target block of the transaction to be allocated, a target tag hash is generated, and a target node number is assigned to the transaction based on the consensus member group, ensuring that the transaction is reasonably allocated and processed in the blockchain network and avoiding duplication and monopoly.

Benefits of technology

It significantly enhances the actual transaction processing capacity of the blockchain network, increases transaction throughput, and ensures network security and fairness through dynamic adjustments, preventing transactions from being filtered or monopolized by specific nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115730009B_ABST
    Figure CN115730009B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a blockchain transaction allocation method and device, applied in the field of blockchain technology, comprising: determining a guide block pointed to by a target block of a to-be-allocated transaction, the guide block being a legal block with the largest logical clock monitored by a local node when generating the target block; determining a consensus member group for allocating the target transaction based on the guide block, and generating a target marker hash based on a transaction hash of the target transaction and a block hash of the guide block; allocating a target node number for the target transaction based on the target marker hash and a total number of nodes in the consensus member group; and if the target node number is a node number of the local node, adding the target transaction to the target block. By allocating transactions to target nodes for processing, the problem of transaction duplication in a high-concurrency blockchain system can be effectively solved, and the actual transaction processing capacity of the blockchain network can be significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain transaction allocation method and apparatus. Background Technology

[0002] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm; the blockchain consensus protocol is the key technology of the underlying blockchain platform, which directly determines the security and system performance of the blockchain system.

[0003] Consensus protocols based on a parallel multi-chain architecture can significantly improve block throughput in a blockchain network, i.e., the number of valid blocks uploaded per unit of time. However, since concurrent blocks contain a large number of duplicate transactions, the processing capacity of valid transactions in the blockchain network (i.e., transaction throughput) does not improve effectively when block throughput increases. Summary of the Invention

[0004] This application provides a blockchain transaction allocator and apparatus for allocating transactions in a blockchain network.

[0005] Firstly, embodiments of this application provide a blockchain transaction allocation method, applied to any node in a blockchain system, comprising:

[0006] The pilot block pointed to by the target block of the transaction to be allocated is determined. The pilot block is a valid block with the maximum logical clock value that the local node detects when generating the target block.

[0007] Based on the bootstrap block, a consensus member group for allocating the target transaction is determined, and a target token hash is generated based on the transaction hash of the target transaction and the block hash of the bootstrap block.

[0008] Based on the target token hash and the total number of nodes in the consensus member group, a target node number is assigned to the target transaction;

[0009] If the target node number is the same as the local node number, then the target transaction is added to the target block.

[0010] By distributing transactions to target nodes for processing, the problem of transaction duplication in high-concurrency blockchain systems can be effectively solved, significantly improving the actual transaction processing capacity of the blockchain network and thus increasing the throughput of actual transactions in the blockchain network. In addition, by randomly distributing transactions to nodes of each blockchain, dynamic adjustments can be made based on the latest state of the blocks, effectively preventing transactions from being filtered or monopolized by specific nodes, thereby improving the security and fairness of the entire blockchain network.

[0011] Optionally, the determining the target block pointed by the target block of the transaction to be distributed further comprises: adding the block hash of the guide block to the corresponding field of the target block.

[0012] Optionally, the determining the consensus member group for distributing the target transaction based on the guide block comprises:

[0013] monitoring the latest blocks of the main chains in each sub-block chain;

[0014] if the difference between the logical clocks of any two latest blocks is less than or equal to a preset difference value, or if the difference between the block heights of any two latest blocks is less than or equal to a preset difference value, then determining the consensus member group for distributing the target transaction based on the guide block.

[0015] Optionally, if the difference between the logical clocks of any two latest blocks is greater than a preset difference value, or if the difference between the block heights of any two latest blocks is greater than a preset difference value, then randomly distributing the transaction to the target block or not adding the transaction to the target block.

[0016] Optionally, the determining the consensus member group for distributing the target transaction based on the guide block comprises:

[0017] determining a plurality of historical blocks from the main chains of each sub-block chain that satisfy a preset condition, wherein the preset condition refers to a distance from the logical clock or height of the guide block being greater than or equal to a preset difference value;

[0018] determining the consensus member group based on the plurality of historical blocks.

[0019] Optionally, the determining the consensus member group based on the plurality of historical blocks further comprises:

[0020] sorting the plurality of nodes in the consensus member group according to their address information and assigning each node a node number based on the sorting result.

[0021] Optionally, the target node number assigned to the target transaction based on the target marker hash and the total number of nodes in the consensus member group comprises:

[0022] using the target marker hash to take the total number of nodes in the consensus member group as a modulus to obtain a modulus result;

[0023] using the modulus result as the target node number.

[0024] Optionally, if the target node number is not the node number of the local node, then skipping the target transaction.

[0025] Optionally, receiving a to-be-verified block broadcast by another node;

[0026] Verifying a transaction assignment relationship between a historical transaction contained in the to-be-verified block and a node generating the to-be-verified block;

[0027] If the verification passes, determining that the to-be-verified block is a legal block.

[0028] Optionally, the verifying the transaction assignment relationship between the historical transaction contained in the to-be-verified block and the candidate node generating the to-be-verified block comprises:

[0029] Determining a to-be-verified marker hash based on a transaction hash of the historical transaction and a block hash of a leading block corresponding to the to-be-verified block, and determining a historical consensus member group for assigning the historical transaction based on the leading block corresponding to the to-be-verified block;

[0030] Determining a historical node number corresponding to the historical transaction based on the to-be-verified marker hash and a total number of nodes in the historical consensus member group;

[0031] If the historical node number is a node number of a node generating the to-be-verified block, determining that the verification passes.

[0032] In a second aspect, an embodiment of the present application provides a block chain transaction assignment device, any one node in a block chain system, comprising:

[0033] A leading module is configured to determine a leading block to which a target block of a to-be-assigned transaction points, the leading block being a legal block with a largest logical clock monitored by a local node when the local node generates the target block;

[0034] A processing module is configured to determine a consensus member group for assigning a target transaction based on the leading block, and generate a target marker hash based on a transaction hash of the target transaction and a block hash of the leading block;

[0035] A numbering module is configured to assign a target node number for the target transaction based on the target marker hash and a total number of nodes in the consensus member group;

[0036] A matching module is configured to add the target transaction into the target block if the target node number is a node number of the local node.

[0037] By distributing transactions to target nodes for processing, the problem of transaction duplication in a high-concurrency blockchain system can be effectively solved, the actual transaction processing capacity of the blockchain network can be significantly improved, and the throughput capacity of actual transactions in the blockchain network can be improved. In addition, by randomly distributing transactions to nodes of each blockchain, dynamic adjustment can be made according to the latest state of the block, effectively avoiding filtering or monopoly of transactions by a specific node, and improving the security and fairness of the entire blockchain network.

[0038] Optionally, the guiding module is specifically configured to:

[0039] add the block hash of the guiding block to the corresponding field of the target block.

[0040] Optionally, the processing module is specifically configured to:

[0041] monitor the latest block of the main chain in each sub-blockchain;

[0042] if the difference between the logical clocks of any two latest blocks is less than or equal to a preset difference value, or if the difference between the block heights of any two latest blocks is less than or equal to a preset difference value, determine a consensus member group for distributing target transactions based on the guiding block.

[0043] Optionally, the processing module is specifically configured to:

[0044] if the difference between the logical clocks of any two latest blocks is greater than a preset difference value, or if the difference between the block heights of any two latest blocks is greater than a preset difference value, randomly distribute transactions to the target block or do not add transactions to the target block.

[0045] Optionally, the processing module is specifically configured to:

[0046] from the main chain of each sub-blockchain, determine a plurality of historical blocks that satisfy a preset condition, wherein the preset condition refers to a distance from the logical clock or height of the guiding block being greater than or equal to a preset difference value;

[0047] determine the consensus member group based on the plurality of historical blocks.

[0048] Optionally, the processing module is specifically configured to:

[0049] sort the plurality of nodes in the consensus member group according to address information of the plurality of nodes, and assign a node number to each node based on the sorting result.

[0050] Optionally, the numbering module is specifically configured to:

[0051] obtain a remainder result by taking the target marker hash modulo the total number of nodes in the consensus member group.

[0052] the remainder result as the target node number.

[0053] Optionally, the numbering module is specifically configured to:

[0054] If the target node number is not the node number of the local node, the target transaction is skipped.

[0055] Optionally, the processing module is specifically configured to:

[0056] receive a to-be-verified block broadcast by another node;

[0057] verify a transaction allocation relationship between a historical transaction contained in the to-be-verified block and a candidate node generating the to-be-verified block;

[0058] If the verification is passed, the to-be-verified block is determined as a legal block.

[0059] Optionally, the processing module is specifically configured to:

[0060] determine a to-be-verified marker hash based on a transaction hash of the historical transaction and a block hash of a leading block corresponding to the to-be-verified block, and determine a historical consensus member group for allocating the historical transaction based on the leading block corresponding to the to-be-verified block;

[0061] determine a historical node number corresponding to the historical transaction based on the to-be-verified marker hash and a total number of nodes in the historical consensus member group;

[0062] If the historical node number is the node number of the candidate node, it is determined that the verification is passed.

[0063] In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor executes the transaction allocation method of the block chain in any of the first aspect.

[0064] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program executable by a computer device, and when the program is executed on the computer device, the computer device executes the transaction allocation method of the block chain in any of the first aspect. BRIEF DESCRIPTION OF DRAWINGS

[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description only constitute some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.

[0066] Figure 1 A system architecture schematic diagram applicable to the embodiments of the present application;

[0067] Figure 2 A flowchart of a blockchain transaction allocation method provided by the embodiments of the present application;

[0068] Figure 3 A schematic diagram of a parallel multi-chain architecture provided by the embodiments of the present application;

[0069] Figure 4 A schematic diagram of a parallel multi-chain architecture provided by the embodiments of the present application;

[0070] Figure 5 A schematic diagram of a parallel multi-chain architecture provided by the embodiments of the present application;

[0071] Figure 6 A structural schematic diagram of a blockchain transaction allocation device provided by the embodiments of the present application;

[0072] Figure 7 A structural schematic diagram of a computer device provided by the embodiments of the present application. DETAILED DESCRIPTION

[0073] In order to make the purpose, technical solutions and beneficial effects of the present application more clear and explicit, the present application will be further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.

[0074] In order to facilitate understanding, the terms involved in the embodiments of the present application are explained as follows.

[0075] Blockchain: a new application mode of computer technology such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm. Blockchain, in essence, is a decentralized database, which is a series of data blocks associated using cryptography. Each data block contains information about a batch of network transactions, which is used to verify the validity (anti-fake) of the information and generate the next block. Blockchain can include blockchain underlying platform, platform product service layer and application service layer.

[0076] DAG: Directed acyclic graph, a directed acyclic graph. A directed acyclic graph refers to a loop-free directed graph. If there is a non-directed acyclic graph, and A point sets off to B through C to return to A, forming a loop. Change the direction of the edge from C to A to A to C, and it becomes a directed acyclic graph. The number of spanning trees of a directed acyclic graph is equal to the product of the in-degree of the node with non-zero in-degree.

[0077] Genesis block: The first block built earliest is called the genesis block, which has a unique ID number. In addition to the genesis block, each subsequent block contains two ID numbers, one of which is the ID number of the block itself, and the other is the ID number of the previous block. Through the forward and backward pointing relationship between the ID numbers, all blocks are connected in sequence to form a block chain.

[0078] The logical clock of the block is the number of blocks along the logical clock line direction to the genesis block. The blocks include the genesis block and do not include the current block.

[0079] The logical clock line of the block is the linear direction along the path of the leading block in the block to the genesis block.

[0080] The block height is the number of blocks along the sub-block chain to the genesis block (including the current block and the genesis block).

[0081] Figure 1 The architecture diagram of a block chain system provided by the embodiment of the application is shown in Figure 1 As shown in the figure, the block chain system can include N nodes, respectively node 100-1, node 100-2, …, node 100-N, N is a positive integer, any two nodes in the block chain system can be connected in communication, thereby jointly maintaining the block chain system, wherein any two nodes can be connected by a wired manner, or can also be connected by a wireless manner, and the specific limitation is not limited.

[0082] In the embodiment of the application, the nodes in the block chain system can have multiple functions. For example, routing function, transaction function, consensus function, etc. Specifically, the nodes in the block chain system can transmit transaction data and other information transmitted by other nodes to more nodes to realize communication between nodes; or the nodes in the block chain system can be used to record all transactions in history; or the nodes in the block chain system can generate new blocks in the block chain by verifying and recording transactions.

[0083] It should be noted that a node in the block chain system can be a physical machine (server), or a process or a series of processes running in the server, and the application does not specifically limit this.

[0084] As shown in Figure 1As shown, the system architecture can also include a client device 200, which can connect with any node in the blockchain system through access to the blockchain network. In specific embodiments, the client device 200 can send transaction data to any node in the blockchain system, and a certain node in the blockchain system can synchronize the transaction data to other nodes in the blockchain system after receiving the transaction data. The certain node can also store the transaction data in the transaction pool inside the node after receiving the transaction data; accordingly, other nodes can also store the transaction data in the transaction pool inside the other nodes after receiving the transaction data synchronized by the certain node. In this way, if a certain node determines to process multiple pieces of transaction data, it can obtain the multiple pieces of transaction data from the internal transaction pool and then perform subsequent transaction processing and block consensus.

[0085] Based on Figure 1 As shown in the system architecture diagram, the embodiments of the present application provide a flow of a blockchain transaction allocation method, as shown in Figure 2 The flow of the method can be executed by Figure 1 Any node in the blockchain system as shown, including the following steps:

[0086] Step S201, determine the target block of the transaction to be allocated. The target block is a legal block with the largest logical clock monitored by the local node when generating the target block.

[0087] Specifically, a guide block is determined for the target block of the transaction to be allocated, which serves as the pointing block of the target block. Among them, the guide block is a legal block with the largest logical clock detected by the local node when generating the target block. The logical clock of the block is the number of blocks passed along the logical clock path corresponding to the block to the genesis block; and the logical clock path is the path extending to the genesis block in the direction of pointing to the longest clock block with the target block as the starting point. After connecting the target block and the guide block, the target block and the original block structure form a directed acyclic graph.

[0088] Optionally, if the local node has not generated any block, the genesis block is used as the guide block pointed by the target block of the transaction to be allocated.

[0089] In some embodiments, after determining the guide block pointed by the target block of the transaction to be allocated, the block hash of the guide block is added to the corresponding field of the target block.

[0090] Specifically, in each block in the blockchain, the block hash of the current block and the block hash of the previous block are contained, and the block corresponding to the block hash can be found through the block hash. After determining the guide block pointed to by the target block of the transaction to be allocated, the block hash of the guide block is added to the corresponding field of the target block to ensure the connection relationship between the target block and the guide block.

[0091] In step S202, based on the guide block, a consensus member group for allocating the target transaction is determined, and a target marker hash is generated based on the transaction hash of the target transaction and the block hash of the guide block.

[0092] Specifically, after determining the guide block pointed to by the target block of the transaction to be allocated, further determine the allocable node that can process the target transaction, and the number of allocable nodes in the global is at least one, and the local node is included, and the plurality of allocable nodes and the local node together constitute a consensus member group; the transaction hash of the target transaction and the block hash in the guide block are combined and hashed to generate a target marker hash.

[0093] In step S203, based on the target marker hash and the total number of nodes in the consensus member group, the target node number allocated for the target transaction is determined.

[0094] Specifically, the number of nodes included in the consensus member group is counted, and then based on the target marker hash, the target node number allocated for the target transaction is determined, and the target node is one of the nodes in the consensus member group.

[0095] In step S204, if the target node number is the node number of the local node, the target transaction is added to the target block.

[0096] Specifically, if the number allocated for the target node is the node number of the local node, the target transaction is added to the target block, and then the target transaction allocation is completed.

[0097] In some embodiments, if the target node number is not the node number of the local node, the target transaction is skipped.

[0098] Specifically, if the number allocated for the target node is not the node number of the local node, the target transaction is skipped, and the next transaction is determined.

[0099] By allocating transactions to target nodes for processing, the problem of transaction duplication in high-concurrency block systems can be effectively solved, and the actual transaction processing capacity of the blockchain network can be significantly improved, thereby improving the throughput capacity of actual transactions in the blockchain network. In addition, by randomly allocating transactions to nodes of each blockchain, dynamic adjustment can be made according to the latest state of the block, effectively avoiding the filtering or monopoly of transactions by a specific node, and improving the security and fairness of the entire blockchain network.

[0100] In some embodiments, determining the consensus member group for assigning the target transaction based on the guide block further comprises: monitoring the latest blocks of the main chains in each sub-chain; and determining the consensus member group for assigning the target transaction based on the guide block, if a difference between the logical clocks of any two latest blocks is less than or equal to a preset difference value; or if a difference between the block heights of any two latest blocks is less than or equal to the preset difference value.

[0101] Specifically, the preset difference value is a set block interval, denoted as H, which is a preset security parameter and is at least 1. The latest blocks of the main chains in each sub-chain are monitored, and the logical clocks of the latest blocks on the main chains of each sub-chain are determined. The difference between the logical clocks of the latest blocks on the main chains of each two sub-chains is calculated. It is determined that the difference between the logical clocks of the latest blocks on any two sub-chains is less than the number of preset blocks. Alternatively, it is determined that the block height of the latest block on any two sub-chains is less than the number of preset blocks. The block height is the number of blocks (including the current block and the genesis block) passed along the sub-chain to the genesis block.

[0102] For example, referring to Figure 3 A parallel multi-chain architecture is provided for the embodiments of the present application, which includes a sub-chain C0, a sub-chain C1 and a sub-chain C2. The sub-chain C0 includes a genesis block G0, a block C01, a block C02, a block C03, a block C04, a block C05, a block C06, a block C07 and a block C08. The sub-chain C1 includes a genesis block G1, a block C11, a block C12, a block C13 and a block C14. The sub-chain C2 includes a genesis block G2, a block C21 and a block C22. In the sub-chain C0, the latest block is the block C08, the logical clock of the block C08 is 6, and the height of the block C08 is 7. In the sub-chain C1, the latest block is the block C15, the logical clock of the block C15 is 5, and the height of the block C15 is 6. In the sub-chain C2, the latest block is the block C24, the logical clock of the block C24 is 4, and the height of the block C15 is 5.

[0103] The preset difference value is set to 3, and in Figure 3 It can be seen that the difference between the logical clocks of the block C08 and the block C15 is 1, and the difference between the heights is also 1. The difference between the logical clocks of the block C08 and the block C24 is 2, and the difference between the heights is also 2. The difference between the logical clocks of the block C15 and the block C24 is 1, and the difference between the heights is also 1. In summary, the difference between the logical clocks and the height of the latest blocks in any two sub-chains are less than the preset difference value.

[0104] In some embodiments, if the difference between the logical clocks of the two latest blocks is greater than a preset difference value, or if the difference between the block heights of the two latest blocks is greater than a preset difference value, the transaction is randomly assigned to the target block, or the transaction is not added to the target block.

[0105] Specifically, if the difference between the logical clocks of the latest blocks on the main chains of any two sub-chains is greater than a preset number of blocks, or the difference between the block heights of the latest blocks on the main chains of any two sub-chains is greater than a preset number of blocks, the target transaction is not assigned according to the transaction assignment method of the present application. The transaction is randomly assigned to the target block, or the transaction is not added to the target block to generate an empty block, and the target transaction assignment ends.

[0106] In some embodiments, based on the guide block, a consensus member group for assigning the target transaction is determined, including: determining a plurality of historical blocks satisfying a preset condition from the main chains of the respective sub-blockchains, wherein the preset condition refers to a distance from the logical clock or height of the guide block being greater than or equal to a preset difference value; and determining the consensus member group based on the plurality of historical blocks.

[0107] Specifically, in the main chains of the respective sub-blockchains, if the difference between the logical clock or height of a historical block and the logical clock or height of the guide block is greater than or equal to the preset difference value, i.e., a set block interval H, the historical block satisfies the preset condition, which includes the genesis block; and the consensus member group is determined based on the plurality of historical blocks satisfying the preset condition.

[0108] For example, referring to Figure 4 Taking the sub-chain where the target block is located as an example, the logical clock path corresponding to the main chain of the target block is set as: target block→block C09→block C06→block C05→block C04→block C03→block C02→block C01→genesis block G0, and the preset difference value is set as 3. Therefore, the historical blocks having a distance greater than the preset difference value from the guide block (block C09) of the target block are block C03, C02, C01, and the genesis block G0. The consensus member group is determined based on these historical blocks.

[0109] In some embodiments, after determining the consensus member group based on the plurality of historical blocks, the method further includes: sorting the plurality of nodes according to the address information of the nodes in the consensus member group, and assigning a node number to each node based on the sorting result.

[0110] Specifically, the address information of each node in the consensus member group is converted into a binary value, and the nodes are sorted according to the binary size of the address information of each node, and each node is labeled from 0, 1, 2, 3, 4…N-1, N, i.e., each node is assigned a node number. N is the total number of nodes in the consensus member group.

[0111] In some embodiments, the target node number assigned to the target transaction based on the target marker hash and the total number of nodes in the consensus member group comprises: taking the target marker hash, and taking the total number of nodes in the consensus member group as a remainder to obtain a remainder result; and taking the remainder result as the target node number.

[0112] Specifically, the total number of nodes in the consensus member group is N, the total number of nodes N is taken as a remainder by the target marker hash to obtain a remainder result, and the remainder result is taken as the number of the target node.

[0113] In some embodiments, the method further comprises: receiving a to-be-verified block broadcast by another node; verifying a transaction allocation relationship between a historical transaction included in the to-be-verified block and a node generating the to-be-verified block; and determining that the to-be-verified block is a legal block if the verification is passed.

[0114] Specifically, the node generating the new block needs to broadcast to other nodes to reach a verification with other nodes, and the new block is defined as a to-be-verified block. The to-be-verified block is received by broadcasting by other nodes, and the to-be-verified block includes a historical transaction, and the historical transaction has a transaction allocation relationship with the node generating the to-be-verified block. The transaction allocation relationship needs to be verified, and if the verification is passed, the to-be-verified block is determined to be a legal block; if the verification is not passed, the to-be-verified block is determined to be an illegal block, and the to-be-verified block is rejected to be added to the node.

[0115] By verifying the transaction allocation relationship between the block and the node, the security and legality of each sub-chain block can be ensured, and the transaction security of the entire block chain system is also guaranteed.

[0116] In some embodiments, verifying the transaction allocation relationship between the historical transaction included in the to-be-verified block and the node generating the to-be-verified block comprises: determining a to-be-verified marker hash based on a transaction hash of the historical transaction and a block hash of a guide block corresponding to the to-be-verified block; determining a historical consensus member group for allocating the historical transaction based on the guide block corresponding to the to-be-verified block; determining a historical node number corresponding to the historical transaction based on the to-be-verified marker hash and the total number of nodes in the historical consensus member group; and determining that the verification is passed if the historical node number is the node number of the node.

[0117] Specifically, the transaction hash of the historical transaction and the block hash in the leading block of the to-be-verified block are combined and hashed to obtain a to-be-verified marker hash. Based on the logical clock or height of the leading block of the to-be-verified block, a historical consensus member group to which the historical transaction is assigned is determined, the historical assigned nodes in the historical consensus member group are sorted, and the total number of the historical assigned nodes in the historical consensus member group is counted. The to-be-verified marker hash is taken modulo the total number of nodes in the historical consensus member group, and the obtained modulo result is the historical node number corresponding to the historical transaction. If the historical node number is the node number, it is determined that the verification is passed, and the to-be-verified block is a legal block; if the historical node number is not the node number, the verification is failed, and the to-be-verified block is rejected to be added to the node.

[0118] In order to better explain the embodiments of the present application, a block chain transaction distribution method provided by the embodiments of the present application is introduced below in combination with a specific implementation scenario, and the flow of the method can be executed by any one of the nodes in the block chain system as shown in Figure 1 The flow of the method includes the following steps as shown in Figure 5

[0119] Suppose that the to-be-distributed transaction is TX1, the block chain system is composed of three sub-chains, and the block chain simultaneously generates blocks of the three sub-chains, and the generated blocks are randomly distributed to the three sub-chains as shown in Figure 5 ​As shown, the first sub-blockchain includes block C01, block C02, block C03, and block C04; the second sub-blockchain includes block C11, block C12, block C03, block C14, and block C15; and the third sub-blockchain includes block C21, block C22, block C23, and block C24; and the three sub-chains all point to the same genesis block G0. The logical clock line direction of the target block of the current transaction to be allocated is shown by the dashed line as follows: block C04→block C14→block C24→block C23→block C22→block C21→genesis block G0. The preset difference is set to 3. The logical clock path direction of the guide block (block 04) of the target block is advanced by 3 clocks, that is, block C23, and the blocks at the same height as block C23 are block C03 and block C13. The nodes corresponding to block C23, block C03, and block C13 are generated together with the local node to form a consensus member group, and each node address in the consensus member group is sorted according to the binary value corresponding to the node address, and the total number of nodes in the consensus member group is counted. The hash of block C04 and the hash of the current transaction TX1 are taken to generate a target marker hash. The total number of nodes in the consensus member group is taken modulo the target marker hash, and the result is the node number allocated to the current transaction TX1. If the local node number is consistent, the current transaction TX1 is added to the target block. The transaction allocation relationship between the transaction and the corresponding node of the target block is verified. If the verification is passed, the target block is determined to be a legal block, and is added to the local blockchain. Otherwise, the target block is rejected and not added to the local blockchain.

[0120] By allocating transactions to target nodes for processing, the problem of transaction duplication in a high-concurrency blockchain system can be effectively solved, the actual transaction processing capacity of the blockchain network can be significantly improved, and the actual transaction throughput capacity of the blockchain network can be improved. In addition, by randomly allocating transactions to nodes of each blockchain, the latest state of the block can be dynamically adjusted, the transactions can be effectively prevented from being filtered or monopolized by a specific node, and the security and fairness of the entire blockchain network are improved.

[0121] Based on the same technical concept, an embodiment of the present application provides a structural diagram of a blockchain transaction allocation device, which is applied to any node in a blockchain system, such as Figure 6 As shown, the device 600 includes:

[0122] A guide module 601 is configured to determine a guide block pointed to by a target block of a transaction to be allocated, the guide block being a legal block with the largest logical clock monitored by a local node when the target block is generated.

[0123] The processing module 602 is configured to determine a consensus member group for distributing a target transaction based on the guide block, and generate a target marker hash based on a transaction hash of the target transaction and a block hash of the guide block.

[0124] The numbering module 603 is configured to assign a target node number for the target transaction based on the target marker hash and a total number of nodes in the consensus member group.

[0125] The matching module 604 is configured to add the target transaction into the target block if the target node number is the node number of the local node.

[0126] By processing the transaction by assigning it to a target node, the problem of transaction duplication in a high-concurrency blockchain system can be effectively solved, and the actual transaction processing capacity of the blockchain network can be significantly improved, thereby improving the throughput capacity of actual transactions in the blockchain network. In addition, by randomly assigning transactions to nodes of each blockchain, the latest state of the block can be dynamically adjusted to effectively avoid transactions being filtered or monopolized by a specific node, thereby improving the security and fairness of the entire blockchain network.

[0127] Optionally, the guide module 601 is specifically configured to:

[0128] add the block hash of the guide block to a corresponding field of the target block.

[0129] Optionally, the processing module 602 is specifically configured to:

[0130] monitor the latest block of the main chain in each sub-blockchain;

[0131] if the difference between the logical clocks of any two latest blocks is less than or equal to a preset difference value, or if the difference between the block heights of any two latest blocks is less than or equal to a preset difference value, determine a consensus member group for distributing a target transaction based on the guide block.

[0132] Optionally, the processing module 602 is specifically configured to:

[0133] if the difference between the logical clocks of any two latest blocks is greater than a preset difference value, or if the difference between the block heights of any two latest blocks is greater than a preset difference value, randomly assign transactions to the target block or do not add transactions to the target block.

[0134] Optionally, the processing module 602 is specifically configured to:

[0135] determine a plurality of historical blocks that satisfy a preset condition from the main chain of each sub-blockchain, wherein the preset condition refers to a distance from the logical clock or height of the guide block being greater than or equal to a preset difference value.

[0136] determining the consensus member group based on the plurality of historical blocks.

[0137] Optionally, the processing module 602 is specifically configured to:

[0138] sorting the plurality of nodes according to address information of the plurality of nodes in the consensus member group, and assigning a node number to each node based on a sorting result.

[0139] Optionally, the numbering module 603 is specifically configured to:

[0140] obtaining a remainder result by taking the target marker hash as a modulus of a total number of nodes in the consensus member group;

[0141] taking the remainder result as the target node number.

[0142] Optionally, the numbering module 603 is specifically configured to:

[0143] if the target node number is not the node number of the local node, skipping the target transaction.

[0144] Optionally, the processing module 602 is specifically configured to:

[0145] receiving a to-be-verified block broadcasted by another node;

[0146] verifying a transaction assignment relationship between a historical transaction contained in the to-be-verified block and a node generating the to-be-verified block;

[0147] if the verification passes, determining that the to-be-verified block is a legal block.

[0148] Optionally, the processing module 602 is specifically configured to:

[0149] determining a to-be-verified marker hash based on a transaction hash of the historical transaction and a block hash of a leading block corresponding to the to-be-verified block, and determining a historical consensus member group for assigning the historical transaction based on the leading block corresponding to the to-be-verified block;

[0150] determining a historical node number corresponding to the historical transaction based on the to-be-verified marker hash and a total number of nodes in the historical consensus member group;

[0151] if the historical node number is the node number of the local node, determining that the verification passes.

[0152] By distributing the transactions to the target nodes for processing, the problem of transaction duplication in a high-concurrency block system can be effectively solved, and the actual transaction processing capacity of the blockchain network can be significantly improved, thereby improving the throughput capacity of actual transactions in the blockchain network. In addition, by randomly distributing the transactions to the nodes of each blockchain, the latest state of the block can be dynamically adjusted to effectively avoid the filtering or monopoly of transactions by a specific node, thereby improving the security and fairness of the entire blockchain network.

[0153] Based on the same technical concept, an embodiment of the present application provides a computer device, as shown in the accompanying drawings, comprising at least one processor 701 and a memory 702 connected to the at least one processor. In the embodiment of the present application, the specific connection medium between the processor 701 and the memory 702 is not limited. Figure 7 For example, the processor 701 and the memory 702 are connected through a bus. The bus can be divided into an address bus, a data bus, a control bus, etc. Figure 7

[0154] In the embodiment of the present application, the memory 702 stores instructions executable by the at least one processor 701. The at least one processor 701 can execute the steps of the blockchain transaction distribution method by executing the instructions stored in the memory 702.

[0155] The processor 701 is the control center of the computer device, and can connect various parts of the computer device through various interfaces and lines. By running or executing the instructions stored in the memory 702 and calling the data stored in the memory 702, the processor 701 can realize the distribution of the transactions of the blockchain. Optionally, the processor 701 can include one or more processing units. The processor 701 can integrate an application processor and a modem processor. The application processor mainly processes the operating system, user interface, and application programs, etc. The modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 701. In some embodiments, the processor 701 and the memory 702 can be implemented on the same chip, and in some embodiments, they can also be implemented on separate chips respectively.

[0156] ​The processor 701 can be a general processor, such as a central processing unit (CPU), a digital signal processor, an application specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic component, a discrete hardware component, and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as hardware processor execution or executed by a combination of hardware and software modules in the processor.

[0157] The memory 702 is a non-volatile computer readable storage medium, which can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 702 can include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card type memory, random access memory (RAM), static random access memory (SRAM), programmable read only memory (PROM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), magnetic storage, optical disk, etc. The memory 702 is any other medium capable of carrying or storing desired program code in the form of instructions or data structures and capable of being accessed by a computer, but is not limited to this. The memory 702 in the embodiments of the present application can also be a circuit or any other device capable of realizing the storage function, used to store program instructions and / or data.

[0158] Based on the same inventive concept, the embodiments of the present application provide a computer readable storage medium storing a computer program executable by a computer device, which, when the program is running on the computer device, causes the computer device to execute the steps of the blockchain transaction allocation method.

[0159] Those skilled in the art will appreciate that embodiments of the present application can be devised for a variety of other systems which are currently developed or later developed. Therefore, the present application is intended to cover all such modifications and variations of this application that are within the scope of the appended claims and their equivalents. It is intended that each element of claim 1 and 2 is independent of one another. No element of claim 1 and 2, or any other claim, is implied to depend on any other element or limitation of claim 1 and 2 or any other claim except where expressly recited in that claim.

[0160] The present application is described in reference to the flowchart and / or block diagrams of the method, apparatus (system) and computer program product according to this application. It will be understood that each block of the flowchart and / or block diagrams, and combinations of blocks in the flowchart and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.

[0161] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.

[0162] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.

[0163] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.

Claims

1. A method for allocating a blockchain transaction, applied to any node in a blockchain system, characterized in that, The method comprises: determining a guide block to which a target block to which a target transaction is to be assigned points, the guide block being a legal block with the largest logical clock monitored by a local node when the target block is generated; based on the guide block, determining a consensus member group for assigning the target transaction, and generating a target marker hash based on a transaction hash of the target transaction and a block hash of the guide block; based on the target marker hash and the total number of nodes in the consensus member group, assigning a target node number to the target transaction; if the target node number is the node number of the local node, adding the target transaction to the target block.

2. The method of claim 1, wherein, After the determination of the guide block to which the target block to which the target transaction is to be assigned points, the method further comprises: adding the block hash of the guide block to a corresponding field of the target block.

3. The method of claim 1, wherein, The determination of the consensus member group for assigning the target transaction based on the guide block comprises: monitoring the latest blocks of the main chains in each sub-block chain; if the difference between the logical clocks of any two latest blocks is less than or equal to a preset difference value, or if the difference between the block heights of any two latest blocks is less than or equal to a preset difference value, determining the consensus member group for assigning the target transaction based on the guide block.

4. The method of claim 3, wherein, The method further comprises: if the difference between the logical clocks of any two latest blocks is greater than a preset difference value, or if the difference between the block heights of any two latest blocks is greater than a preset difference value, randomly assigning a transaction to the target block or not adding a transaction to the target block. The determination of the consensus member group for assigning the target transaction based on the guide block comprises:

5. The method of claim 1, wherein, determining a plurality of historical blocks from the main chains of each sub-block chain that satisfy a preset condition, wherein the preset condition refers to a distance from the logical clock or height of the guide block being greater than or equal to a preset difference value; based on the plurality of historical blocks, determining the consensus member group. After the determination of the consensus member group based on the plurality of historical blocks, the method further comprises:

6. The method of claim 5, wherein, sorting the plurality of nodes in the consensus member group according to their address information, and assigning a node number to each node based on the sorting result. The assignment of the target node number to the target transaction based on the target marker hash and the total number of nodes in the consensus member group comprises:

7. The method of claim 1, wherein, using the target marker hash to take the total number of nodes in the consensus member group as a remainder to obtain a remainder result; using the remainder result as the target node number. The method further comprises:

8. The method of claim 1, wherein, if the target node number is not the node number of the local node, skipping the target transaction. The method further comprises:

9. The method of any one of claims 1 to 8, wherein, receiving a to-be-verified block broadcast by another node; verifying a transaction assignment relationship between a historical transaction included in the to-be-verified block and a node that generated the to-be-verified block; if the verification is passed, determining that the to-be-verified block is a legal block. The verification of the transaction assignment relationship between the historical transaction included in the to-be-verified block and the node that generated the to-be-verified block comprises:

10. The method of claim 9, wherein, ​ determining a to-be-verified marker hash based on a transaction hash of the historical transaction and a block hash of a leading block corresponding to the to-be-verified block; and determining a historical consensus member group for distributing the historical transaction based on the leading block corresponding to the to-be-verified block; determining a historical node number corresponding to the historical transaction based on the to-be-verified marker hash and a total number of nodes in the historical consensus member group; if the historical node number is a node number of a node generating the to-be-verified block, determining that the verification is passed. 11.A blockchain transaction distribution apparatus applied to any node in a blockchain system, characterized in that, The method comprises the following steps: a leading module is configured to determine a leading block of a target block to which a to-be-distributed transaction is directed, the leading block being a legal block with a largest logical clock monitored by a local node when the target block is generated; a processing module is configured to determine a consensus member group for distributing a target transaction based on the leading block, and to generate a target marker hash based on a transaction hash of the target transaction and a block hash of the leading block; a numbering module is configured to assign a target node number for the target transaction based on the target marker hash and a total number of nodes in the consensus member group; a matching module is configured to add the target transaction into the target block if the target node number is a node number of the local node.

12. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the steps of the method in any one of claims 1-10 when executing the program.

13. A computer-readable storage medium, characterized in that, The computer device stores a computer program executable by the computer device, and when the program runs on the computer device, the computer device is caused to execute the steps of the method in any one of claims 1-10.

Citation Information

Patent Citations

  • Blockchain cross-chain interaction method and device based on smart contract, and computer readable storage medium

    CN113179272A

  • Transaction data processing method, device, equipment, system and storage medium

    CN114338673A