Consensus method in block chain system

By pre-establishing the relationship between consensus nodes and transaction data in the blockchain system, the problem of waste of computing resources caused by repeated transactions in the DAG-based blockchain system is solved, and more efficient data processing is achieved.

CN120047143APending Publication Date: 2025-05-27ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510125522.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-26
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

In a DAG-based blockchain system, when the block yield speed is faster or there are few transactions in the transaction pool, duplicate transactions will occur, resulting in wasted computing resources.

Method used

By establishing an association relationship between the consensus node and the transaction data in advance, the consensus node only retrieves transaction data that has established an association relationship with itself from the transaction pool, and packages and generates a transaction unit, and then initiates a consensus on the transaction unit.

Benefits of technology

It effectively avoids multiple consensuses on repeated transaction data, saves computing resources, and improves the data processing efficiency of blockchain system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120047143A_ABST
    Figure CN120047143A_ABST
Patent Text Reader

Abstract

The invention provides a consensus method in a block chain system, and the method comprises the steps: pre-establishing an association relationship between a consensus node and transaction data, and if the transaction data which establishes the association relationship with different consensus nodes are different, when the consensus node generates a transaction unit and initiates consensus, sending the transaction unit to the block chain system; when the DAG-based block chain system is used, the transaction data associated with the DAG-based block chain system is only fished out from the transaction pool, the transaction data are packaged to generate the transaction unit, and then the consensus is initiated for the transaction unit, so that even if the DAG-based block chain system is relatively high in block output speed or relatively few transactions exist in the transaction pool, the transaction unit can be subjected to consensus; and the transaction units generated by packaging different consensus nodes do not contain repeated transaction data, so that the waste of computing resources caused by performing multiple times of consensus on the repeated transaction data can be effectively avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of blockchain technology, and in particular, to a consensus method in a blockchain system. Background Art

[0002] Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. A blockchain system based on a Directed Acyclic Graph (DAG) can break the bondage that data blocks must be serially chained into a chained data structure in a traditional blockchain system. That is, in a blockchain system based on DAG, a transaction unit can be used as a parent transaction unit and simultaneously be referenced by other transaction units, and a child transaction unit can also reference two or more parent transaction units simultaneously. In this way, parallel consensus in the blockchain system can be achieved, and the data processing efficiency of the blockchain system can be improved.

[0003] However, when the block generation speed is relatively fast or the number of transactions in the transaction pool is small in a blockchain system based on DAG, there will be many duplicate transactions in different transaction units, and subsequent multiple consensus operations need to be performed on these duplicate transactions, wasting computing resources. Summary of the Invention

[0004] In view of this, this specification provides a consensus method in a blockchain system to solve the deficiencies in related technologies.

[0005] Specifically, this specification is implemented through the following technical solutions:

[0006] According to the first aspect of the embodiments of this specification, a consensus method in a blockchain system is provided. The method is applied to any consensus node participating in consensus in a blockchain system based on a Directed Acyclic Graph (DAG), and the method includes:

[0007] The consensus node obtains a number of pending transaction data from the transaction data included in the transaction pool;

[0008] For each obtained pending transaction data, according to the data identifier of the pending transaction data, it is determined whether the pending transaction data is transaction data that has been pre-associated with the consensus node; among them, the transaction data pre-associated with different consensus nodes is different;

[0009] If so, the pending transaction data is used as target transaction data, and a transaction unit to be uploaded to the chain is generated based on each target transaction data;

[0010] Consensus is initiated for the transaction unit to be uploaded to the chain.

[0011] According to the second aspect of the embodiments of the present specification, a consensus device in a blockchain system is provided. The device is applied to any consensus node participating in consensus in a blockchain system based on a directed acyclic graph (DAG). The device includes:

[0012] An acquisition module, configured to acquire a plurality of pending transaction data from the transaction data included in the transaction pool;

[0013] A judgment module, configured to, for each acquired pending transaction data, judge whether the pending transaction data is transaction data that has a pre-established association relationship with the consensus node according to the data identifier of the pending transaction data; wherein, the transaction data pre-associated with different consensus nodes is different;

[0014] A generation module, configured to, when the judgment result of the judgment module is yes, use the pending transaction data as target transaction data, and generate a transaction unit to be chained based on the target transaction data;

[0015] A proposal module, configured to initiate consensus on the transaction unit to be chained.

[0016] According to the third aspect of the embodiments of the present specification, an electronic device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the steps of the method described in the first aspect are implemented.

[0017] According to the fourth aspect of the embodiments of the present specification, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the steps of the method described in the first aspect are implemented.

[0018] According to the fifth aspect of the embodiments of the present specification, a computer program product is provided, including a computer program / instructions. When the computer program / instructions are executed by a processor, the steps of the method described in the first aspect are implemented.

[0019] In the technical solution provided in the present specification, an association relationship between a consensus node and transaction data is pre-established, and the transaction data associated with different consensus nodes is different. Then, when generating a transaction unit and initiating consensus, the consensus node only retrieves the transaction data associated with itself from the transaction pool, packs and generates a transaction unit, and then initiates consensus on the transaction unit. In this way, even if the block generation speed of the DAG-based blockchain system is relatively fast or the transactions in the transaction pool are few, the transaction units packed and generated by different consensus nodes will not contain duplicate transaction data, effectively avoiding wasting computing resources by performing consensus on duplicate transaction data multiple times. Description of the Drawings

[0020] Figure 1It is a schematic diagram of the consensus process in a blockchain system shown in an exemplary embodiment of this specification;

[0021] Figure 2 It is the main chain in a DAG-based blockchain shown in an exemplary embodiment of this specification;

[0022] Figure 3 It is a schematic diagram of the structure of a consensus device in a blockchain system shown in an exemplary embodiment of this specification;

[0023] Figure 4 It is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of this specification. Detailed implementation manners

[0024] In order to enable those skilled in the art to better understand the technical solutions in this specification, the following will clearly and completely describe the technical solutions in the embodiments of this specification with reference to the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this specification.

[0025] Figure 1 It is a schematic diagram of the consensus process in a blockchain system shown in an exemplary embodiment of this specification. As Figure 1 shown, the method may include the following steps:

[0026] Step 102, the consensus node obtains a number of pending transaction data from the transaction data included in the transaction pool.

[0027] The embodiments of this specification are used for any consensus node participating in the consensus in a DAG-based blockchain system, especially for the consensus node participating in the DAG consensus algorithm for the main chain. In the main chain of a DAG-based blockchain, each transaction unit can reference a parent transaction unit, and each transaction unit can be referenced by multiple child transaction units, as Figure 2 shown.

[0028] Figure 2 It is the main chain in a DAG-based blockchain shown in an exemplary embodiment of this specification. Transaction unit B2 is the latest transaction unit uploaded to the main chain, that is, the end-point transaction unit. The parent transaction unit it references is transaction unit B1, and transaction units B3, B3', and B3'' are three pending transaction units to be uploaded, and all these three transaction units can reference transaction unit B2 as the parent transaction unit. In Figure 2In the DAG-based blockchain shown, consensus does not proceed in rounds. As long as the consensus nodes select transaction data from the transaction pool and package the selected transaction data into a transaction unit to be chained, they can initiate consensus on this transaction unit to be chained at any time with the endpoint transaction unit of the main chain as the parent transaction unit. The transaction data in the transaction pool is generated and enters the transaction pool after a transaction is initiated by the client of the blockchain system.

[0029] When a consensus node wants to propose a transaction unit and initiate consensus on it, it can first retrieve transaction data from the above-mentioned transaction pool as pending transaction data.

[0030] Specifically, a consensus node can retrieve several transaction data at once, or retrieve only one transaction data at a time but perform the retrieval step multiple times. It should be noted that different consensus nodes share the same transaction pool.

[0031] Step 104, for each piece of pending transaction data obtained, according to the data identifier of the pending transaction data, determine whether the pending transaction data is transaction data that has been pre-associated with the consensus node. If so, execute step 106; otherwise, execute step 110.

[0032] Among them, the transaction data pre-associated with different consensus nodes is different.

[0033] In the embodiments of this specification, the transaction pool can be pre-bucketed, that is, according to the number of consensus nodes in the above-mentioned DAG-based blockchain system, the transaction pool is divided into that number of subsets. Each consensus node corresponds to a subset, and there is no intersection between each subset. This is equivalent to establishing an association relationship between the consensus node and each piece of transaction data in its corresponding subset.

[0034] When a consensus node proposes a transaction unit, after retrieving pending transaction data from the transaction pool through step 102, it can determine whether the retrieved pending transaction data is in the subset corresponding to the consensus node. If so, the pending transaction data can be packaged into the proposed transaction unit; otherwise, the pending transaction data can be put back into the transaction pool without performing any operation on the pending transaction data.

[0035] Specifically, when establishing an association relationship between a consensus node and transaction data, the number of consensus nodes in the DAG-based blockchain system and the node identifier of the consensus node can be determined first, and then according to the number of consensus nodes and the identifier of the consensus node, a preset hash algorithm is used to determine the hash value set corresponding to the consensus node. The intersection of the hash value sets corresponding to different consensus nodes is empty.

[0036] For example, assume that there are n consensus nodes in the above blockchain system, where n is an integer greater than 1. Node identifiers can be assigned to each consensus node, and the node identifiers can be 1 - n. Assume that the hash algorithm used is SHA256, then the hash values can be divided into n hash value sets: [0, (2 256 - 1) / n], [(2 256 - 1) / n, 2×(2 256 - 1) / n]... [(n - 1)×(2 256 - 1) / n, (2 256 - 1)], corresponding to n consensus nodes with node identifiers 1 - n respectively. Among them, consensus node i corresponds to the hash value set [(i - 1)×(2 256 - 1) / n, i×(2 256 - 1) / n].

[0037] When determining whether a pending transaction data retrieved by consensus node i is the transaction data that has been pre - associated with this consensus node i, the endpoint transaction unit on the main chain in the above DAG - based blockchain can be obtained, and the digest of this endpoint transaction unit can be determined. Then, according to this pending transaction data and the digest of the endpoint transaction unit, the hash value of this pending transaction data can be determined. Finally, according to the hash value of this pending transaction data and the hash value set corresponding to consensus node i, it is judged whether this pending transaction data is the transaction data that has been pre - associated with consensus node i.

[0038] If the hash value of this pending transaction data belongs to the hash value set corresponding to consensus node i, it is determined that this pending transaction data is the transaction data that has been pre - associated with consensus node i, and the subsequent step 106 and step 108 are continued. If the hash value of this pending transaction data does not belong to the hash value set corresponding to consensus node i, it is determined that this pending transaction data is not the transaction data that has been pre - associated with consensus node i, and step 110 is executed.

[0039] Continuing with the above example, assume that when consensus node i makes a proposal, the endpoint transaction unit on the main chain determined is B, the digest of this endpoint transaction unit is d(B), and the pending transaction data retrieved by consensus node i from the transaction pool is t k , then the hash value of this pending transaction data can be determined as hash(t k ∣d(B)). If hash(t k ∣d(B)) belongs to the hash value set [(i - 1)×(2 256 - 1) / n, i×(2 256 - 1) / n] corresponding to consensus node i, then it can be determined that the pending transaction data t k is the transaction data that has been pre - associated with consensus node i. Otherwise, it can be determined that the pending transaction data tk Transaction data that has not been pre-associated with consensus node i.

[0040] Of course, the method for establishing the association relationship between the transaction data in the transaction pool and the consensus nodes described above is only an exemplary one in the embodiments of this specification. Those skilled in the art should understand that any method that can establish the association relationship between the transaction data in the transaction pool and the consensus nodes, and the transaction data associated with different consensus nodes is also different, is within the protection scope of this application.

[0041] Step 106: Use the pending transaction data as target transaction data, and generate a transaction unit to be uploaded to the chain based on each target transaction data.

[0042] Step 108: Initiate consensus on the transaction unit to be uploaded to the chain.

[0043] In the embodiments of this specification, after the consensus node determines that a pending transaction data it retrieves is transaction data that has been pre-associated with the consensus node, the pending transaction data can be added to the transaction set corresponding to the consensus node as target transaction data. Among them, the consensus node can initialize an empty set as the transaction set before proposing a transaction unit. After retrieving each pending transaction data that has been pre-associated with the consensus node, the pending transaction data is added to the transaction set as target transaction data.

[0044] When the target transaction data included in the transaction set meets the specified conditions, the consensus node can generate a transaction unit to be uploaded to the chain based on all the target transaction data included in the transaction set. That is, propose the transaction unit to be uploaded to the chain and initiate consensus verification on it. Among them, the above-mentioned specified conditions can be set as needed. For example, it can be set that the number of target transaction data included in the transaction set reaches a preset number.

[0045] If the transaction unit to be uploaded to the chain passes the consensus subsequently, the transaction set can be cleared, and all the transaction data included in the transaction unit to be uploaded to the chain can be deleted from the transaction pool. On the contrary, if the transaction unit to be uploaded to the chain fails to pass the consensus, the transaction set can also be cleared, and all the transaction data included in the transaction unit to be uploaded to the chain can be put back into the transaction pool, so that these transaction data wait to be retrieved and proposed for consensus again.

[0046] Step 110: Put the pending transaction data back into the transaction pool.

[0047] Through the above method, the association relationship between the consensus nodes and the transaction data is established in advance. Since the transaction data associated with different consensus nodes is different, when generating a transaction unit and initiating a consensus, a consensus node only retrieves the transaction data associated with itself from the transaction pool, packages it to generate a transaction unit, and then initiates a consensus on this transaction unit. In this way, even if the block generation speed of the blockchain system based on DAG is relatively fast or there are fewer transactions in the transaction pool, the transaction units generated and packaged by different consensus nodes will not contain duplicate transaction data, effectively avoiding wasting computing resources by performing multiple consensuses on duplicate transaction data.

[0048] Furthermore, since the method provided in this specification aims to enable different consensus nodes to retrieve different transaction data and propose a consensus, so that the transaction data contained in the transaction units proposed for consensus by different consensus nodes does not repeat. Therefore, when a consensus node performs a consensus verification on the transaction unit proposed for consensus by other consensus nodes, it is necessary to at least verify whether the transaction data contained in the transaction unit proposed for consensus by other consensus nodes is the transaction data that has been pre-associated with the other consensus nodes.

[0049] Specifically, for a consensus node i, in response to a consensus initiated by another consensus node j, the consensus node determines the transaction unit targeted by the other consensus node j for the consensus as the transaction unit to be consensus-verified, and determines whether the transaction unit to be consensus-verified contains transaction data that has not been associated with the consensus node j. If so, it is determined that the consensus initiated by the consensus node j fails, and the transaction unit to be consensus-verified can be directly discarded. Otherwise, it is determined that the consensus initiated by the consensus node j passes, and the transaction unit to be consensus-verified is subjected to an on-chain operation, or the consensus verification required for the transaction unit to be consensus-verified is continued until the consensus result for the transaction unit to be consensus-verified is obtained, and corresponding operations are performed on the transaction unit to be consensus-verified according to the consensus result.

[0050] Figure 3 It is a schematic structural diagram of a consensus device in a blockchain system shown in an exemplary embodiment of this specification. As Figure 3 shown, the device is applied to any consensus node participating in the consensus in a blockchain system based on a directed acyclic graph (DAG). The device includes:

[0051] An acquisition module 301, configured to acquire a number of pending transaction data from the transaction data included in the transaction pool;

[0052] A judgment module 302, configured to, for each acquired pending transaction data, determine whether the pending transaction data is the transaction data that has been pre-associated with the consensus node according to the data identifier of the pending transaction data; wherein, the transaction data pre-associated with different consensus nodes is different;

[0053] A generation module 303, configured to, when the judgment result of the judgment module 302 is yes, use the to-be-determined transaction data as target transaction data, and generate a transaction unit to be uploaded to the blockchain based on each target transaction data;

[0054] A proposal module 304, configured to initiate a consensus on the transaction unit to be uploaded to the blockchain.

[0055] Optionally, the device further includes:

[0056] An association module 305, configured to determine the number of consensus nodes and the node identifiers of the consensus nodes in the DAG-based blockchain system before the judgment module 302 determines whether the to-be-determined transaction data is transaction data that has been pre-associated with the consensus nodes; according to the number and the node identifiers of the consensus nodes, use a preset hash algorithm to determine a set of hash values corresponding to the consensus nodes, where the intersection of the sets of hash values corresponding to different consensus nodes is empty.

[0057] Optionally, the judgment module 302 is specifically configured to obtain an endpoint transaction unit on the main chain in the DAG-based blockchain, and determine the digest of the endpoint transaction unit; according to the to-be-determined transaction data and the digest of the endpoint transaction unit, determine the hash value of the to-be-determined transaction data; according to the hash value of the to-be-determined transaction data and the set of hash values corresponding to the consensus nodes, judge whether the to-be-determined transaction data is transaction data that has been pre-associated with the consensus nodes.

[0058] Optionally, the judgment module 302 is specifically configured to judge whether the hash value of the to-be-determined transaction data belongs to the set of hash values corresponding to the consensus nodes; if so, determine that the to-be-determined transaction data is transaction data that has been pre-associated with the consensus nodes; otherwise, determine that the to-be-determined transaction data is not transaction data that has been pre-associated with the consensus nodes.

[0059] Optionally, the generation module 303 is specifically configured to add the to-be-determined transaction data as target transaction data to the transaction set corresponding to the consensus nodes; when the target transaction data included in the transaction set corresponding to the consensus nodes meets a specified condition, generate a transaction unit to be uploaded to the blockchain based on each target transaction data included in the transaction set.

[0060] Optionally, the device further includes:

[0061] The consensus module 306 is configured to determine, in response to a consensus initiated by other consensus nodes, a transaction unit targeted by the consensus initiated by the other consensus nodes as a to-be-consensus transaction unit; determine whether the to-be-consensus transaction unit contains transaction data that has not established an association relationship with the other consensus nodes; if so, determine that the consensus initiated by the other consensus nodes fails.

[0062] Optionally, the proposal module 304 is further configured to, if the consensus on the to-be-chain-uploaded transaction unit passes, delete the transaction data included in the to-be-chain-uploaded transaction unit from the transaction pool.

[0063] For the implementation processes of the functions and actions of each unit in the above device, please refer to the implementation processes of the corresponding steps in the above method for details, which will not be elaborated here.

[0064] Figure 4 It is a schematic structural diagram of an electronic device in an exemplary embodiment. Please refer to Figure 4 , at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, there may also be other required hardware. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a device for hiding the recipient address or a device for verifying the transaction attribution at the logical level. Of course, in addition to the software implementation manner, this specification does not exclude other implementation manners, such as a logic device or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logical unit, and may also be hardware or a logic device.

[0065] Based on the same concept as the above method, this specification also provides an electronic device, including: a processor; a memory for storing executable instructions that can be executed by the processor; wherein, the processor realizes the steps of the method as described in any of the above embodiments by running the executable instructions.

[0066] Based on the same concept as the above method, this specification also provides a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method as described in any of the above embodiments are realized.

[0067] Based on the same concept as the above method, this specification also provides a computer program product, including a computer program / instructions, and when the computer program / instructions are executed by a processor, the steps of the method as described in any of the above embodiments are realized.

Claims

1. A consensus method in a blockchain system, the method being applied to any consensus node participating in consensus in a blockchain system based on a directed acyclic graph (DAG), the method comprising: The consensus node obtains some pending transaction data from the transaction data contained in the transaction pool; For each pending transaction data, judging whether the pending transaction data is transaction data that has established an association relationship with the consensus node in advance according to the data identifier of the pending transaction data; wherein the transaction data that has established an association relationship with different consensus nodes in advance are different; If yes, the pending transaction data is used as the target transaction data, and a transaction unit to be uploaded to the chain is generated based on each target transaction data; Initiate consensus on the transaction unit to be put on the chain.

2. The method according to claim 1, before determining whether the pending transaction data is transaction data that has established an association relationship with the consensus node in advance, the method further comprises: Determine the number of consensus nodes in the DAG-based blockchain system and the node identifiers of the consensus nodes; According to the number and the node identifier of the consensus node, a preset hash algorithm is used to determine the hash value set corresponding to the consensus node, wherein the intersection of the hash value sets corresponding to different consensus nodes is empty.

3. The method according to claim 2, judging whether the pending transaction data is transaction data that has established an association relationship with the consensus node in advance according to the data identifier of the pending transaction data, specifically comprises: Obtaining an endpoint transaction unit on a main chain in a DAG-based blockchain, and determining a summary of the endpoint transaction unit; Determine a hash value of the pending transaction data according to the pending transaction data and the summary of the endpoint transaction unit; According to the hash value of the pending transaction data and the set of hash values ​​corresponding to the consensus node, it is determined whether the pending transaction data is transaction data that has established an association relationship with the consensus node in advance.

4. The method according to claim 3, judging whether the pending transaction data is transaction data that has established an association relationship with the consensus node in advance according to the hash value of the pending transaction data and the set of hash values ​​corresponding to the consensus node, specifically comprises: Determine whether the hash value of the pending transaction data belongs to the hash value set corresponding to the consensus node; If so, it is determined that the pending transaction data is transaction data that has established an association relationship with the consensus node in advance; Otherwise, it is determined that the pending transaction data is not transaction data that has established an association relationship with the consensus node in advance.

5. The method according to any one of claims 1 to 4, wherein the pending transaction data is used as target transaction data, and a transaction unit to be uploaded to the chain is generated based on each target transaction data, specifically comprising: Add the pending transaction data as target transaction data to the transaction set corresponding to the consensus node; When the target transaction data contained in the transaction set corresponding to the consensus node meets the specified conditions, a transaction unit to be uploaded to the chain is generated based on each target transaction data contained in the transaction set.

6. The method of claim 1, further comprising: In response to the consensus initiated by other consensus nodes, determining the transaction unit for which the other consensus nodes initiate the consensus as the transaction unit to be agreed upon; Determining whether the transaction unit to be agreed upon contains transaction data that has not established an association relationship with the other consensus nodes; If so, it is determined that the consensus initiated by the other consensus nodes fails.

7. The method according to claim 1, after initiating consensus on the transaction unit to be put on the chain, the method further comprises: If the consensus of the transaction unit to be put on the chain is passed, the transaction data contained in the transaction unit to be put on the chain is deleted from the transaction pool.

8. A consensus device in a blockchain system, the device being applied to any consensus node participating in consensus in a blockchain system based on a directed acyclic graph (DAG), the device comprising: An acquisition module is used to acquire a number of pending transaction data from the transaction data contained in the transaction pool; A judgment module is used to obtain each pending transaction data and judge whether the pending transaction data is transaction data that has established an association relationship with the consensus node in advance according to the data identifier of the pending transaction data; wherein the transaction data that has established an association relationship with different consensus nodes in advance are different; A generating module, configured to, when the judgment result of the judging module is yes, use the pending transaction data as target transaction data, and generate a transaction unit to be uploaded to the chain based on each target transaction data; The proposal module is used to initiate consensus on the transaction unit to be put on the chain.

9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the methods of claims 1 to 7 when executing the program.

10. A computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.