Transaction method and device based on directed acyclic graph, equipment, storage medium and program product

By publishing the credible unit to record the transaction sequence in the DAG structure and executing the transactions in the order, the problem of unreliable transaction time sequence in the DAG structure is solved, and the reliability and security of the transaction sequence are achieved, reducing verification costs.

CN119494730APending Publication Date: 2025-02-21CHINA UNIONPAY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411618620.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

In the traditional DAG structure, asynchronous release and verification between transactions lead to unreliable and unverified transaction timing, making it difficult to effectively use smart contracts on the DAG structure.

Method used

A credible unit is published in a pre-constructed directed acyclic graph, which is used to record the order of each transaction related to the contract, and execute each transaction in the order in the credible unit. At the same time, preset verification rules are used to publish transactions to prevent unordered reference verification by lazy nodes.

Benefits of technology

Through consensus sorting, the reliability of transaction order in the network is improved, the disordered reference verification of lazy nodes is prevented, the verification cost is reduced, and network security is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119494730A_ABST
    Figure CN119494730A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a transaction method and device based on a directed acyclic graph, equipment, a storage medium and a program product. The method comprises the following steps: publishing a public trust unit in a pre-constructed directed acyclic graph; wherein the public trust unit is used for recording the sequence of transactions related to the contract; for any node receiving the public trust unit in the directed acyclic graph, when transactions related to the contract are executed, according to the sequence in the public trust unit, sequentially executing all transactions from front to back; wherein the transaction related to the contract is published to the directed acyclic graph according to a preset verification rule. The method is used for conducting consensus sorting on common transactions in the directed acyclic graph, and the reliability of the transaction sequence in the network is improved. Meanwhile, the transaction related to the contract is published to the directed acyclic graph according to the preset verification rule, so that disordered reference verification of lazy nodes can be prevented, and the verification cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to blockchain technology, and in particular to a transaction method, device, equipment, storage medium and program product based on a directed acyclic graph. Background Art

[0002] DAG (Directed Acyclic Graph) is a graph data structure. If a directed graph cannot return to any vertex through several edges, then this graph is a DAG. In the DAG structure, each transaction references two previous transactions, forming a complex network structure, because all reference pointers point in the same direction, and the reference path of any transaction will not return to the same transaction, forming a non-cyclic structure, so the edges and vertices formed by pointers and transactions constitute a directed graph.

[0003] In the traditional DAG structure, asynchronous publishing and verification between transactions ensures high throughput of the entire system, but it also makes the time sequence between transactions unreliable and unverifiable, which makes it difficult to use smart contracts on the DAG structure. Summary of the invention

[0004] The embodiments of the present application provide a transaction method, apparatus, device, storage medium and program product based on a directed acyclic graph, so as to solve the problem that the time sequence between transactions is unreliable and unverifiable.

[0005] In a first aspect, an embodiment of the present application provides a transaction method based on a directed acyclic graph, comprising:

[0006] Publishing a credibility unit in a pre-built directed acyclic graph; wherein the credibility unit is used to record the order of transactions related to the contract;

[0007] For any node in the directed acyclic graph that receives the credibility unit, when executing transactions related to the contract, the transactions are executed in sequence from the front to the back according to the order in the credibility unit;

[0008] Among them, transactions related to the contract are published on the directed acyclic graph according to preset verification rules.

[0009] In a possible implementation, the credibility unit records the order of transactions related to the contract, including:

[0010] The credibility unit refers to the hash value of each transaction related to the contract, and determines and records the order of each transaction according to each hash value.

[0011] In a possible implementation, the method further includes:

[0012] For a previous transaction verified and cited by the public trust unit, the status of the previous transaction is determined so that it cannot be cited again by a new transaction.

[0013] In one possible implementation, transactions in the directed acyclic graph are created and published by any node;

[0014] The judgment method that meets the preset verification rules includes:

[0015] For a transaction to be published, the initiator of the transaction needs to verify multiple unverified previous transactions before it is allowed to be published;

[0016] When a node creates more than one transaction, the newly released transaction of the node must reference all the previous transactions it released before to form the transaction sequence path of the node.

[0017] In a possible implementation manner, the determination method that complies with the preset verification rule further includes:

[0018] For a transaction to be published, a pre-built hash function is used to calculate the hash value corresponding to the transaction to be published;

[0019] If the hash value corresponding to the transaction to be published meets the first preset condition, the initiator of the transaction to be published is allowed to select a preceding transaction for verification.

[0020] In a possible implementation manner, the determination method that meets the first preset condition includes:

[0021] If there is an adjustable value such that the hash value corresponding to the transaction to be published is less than or equal to the first hash threshold, it is considered to meet the first preset condition, and its expression is:

[0022] H(tx,nonce)≤a

[0023] Among them, H() represents a hash function; tx represents a transaction to be published; nonce represents an adjustable value used to adjust the hash value of tx; a represents the first hash value threshold.

[0024] In a possible implementation, the initiator of the transaction to be issued selects a previous transaction for verification, including:

[0025] A preset number of preceding transactions are selected, and if the hash values ​​corresponding to the selected preceding transactions meet the second preset condition, the selected preceding transactions are referenced and verified.

[0026] In a possible implementation manner, the determination method for meeting the second preset condition includes:

[0027] A pre-built hash function is used to calculate the hash values ​​corresponding to the selected previous transactions, and the hash values ​​corresponding to the previous transactions are randomly combined to obtain multiple sets to be selected;

[0028] For a candidate set, a pre-built hash function is used to calculate the hash value of the candidate set;

[0029] If there is an adjustable value such that the hash value of the candidate set is less than or equal to the second hash threshold, it is considered to meet the second preset condition, and its expression is:

[0030] H(H(txN1),H(txN2),…H(txNi),nonce)≤b

[0031] Among them, txNi represents a selected previous transaction; nonce represents an adjustable value used to adjust the hash value of the selected set; b represents the second hash value threshold, and the second hash value threshold is greater than or equal to the first hash value threshold.

[0032] In one possible implementation, the method further comprises failing to:

[0033] When the hash value corresponding to the selected preceding transaction does not meet the second preset condition, the preset quantity is adjusted to the updated quantity;

[0034] Select the updated number of previous transactions, and determine whether the hash value corresponding to the reselected previous transaction meets the second preset condition. If so, reference and verify the reselected previous transaction.

[0035] In a possible implementation, the method further includes:

[0036] Compare the transaction difficulty value with the preset difficulty threshold;

[0037] When the transaction difficulty value is greater than or equal to the preset difficulty threshold, a difficulty adjustment prompt message is generated to enable the service provider to adjust the difficulty coefficient to reduce the verification cost;

[0038] The transaction difficulty value is associated with the verification cost of a newly released transaction.

[0039] In a possible implementation, the transaction difficulty value is the sum of the previous verification cost and the local verification cost;

[0040] The previous verification cost represents the overall computational workload of the transaction initiator in verifying the previous transaction; and the local verification cost represents the overall computational workload of the transaction initiator in verifying the current transaction.

[0041] In a second aspect, an embodiment of the present application provides a transaction device based on a directed acyclic graph, including:

[0042] A publishing module, used to publish a credibility unit in a pre-built directed acyclic graph; wherein the credibility unit is used to record the order of each transaction related to the contract;

[0043] An execution module is used to execute each transaction in sequence from front to back according to the order in the credibility unit for any node in the directed acyclic graph that receives the credibility unit when executing transactions related to the contract; wherein the transactions related to the contract are published to the directed acyclic graph according to preset verification rules.

[0044] In a third aspect, an embodiment of the present application provides a computer device, including: a memory, a processor;

[0045] The memory stores computer-executable instructions;

[0046] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.

[0047] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.

[0048] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.

[0049] The transaction method, device, equipment, storage medium and program product based on the directed acyclic graph provided by the embodiment of the present application are through publishing a credibility unit in a pre-constructed directed acyclic graph; wherein the credibility unit is used to record the order of each transaction related to the contract; for any node in the directed acyclic graph that receives the credibility unit, when executing transactions related to the contract, each transaction is executed in sequence from front to back based on the order in the credibility unit, thereby consensus sorting of ordinary transactions in the directed acyclic graph is performed to improve the reliability of the transaction order in the network. At the same time, the transactions related to the contract of the present application are published to the directed acyclic graph according to preset verification rules, which can prevent the disordered reference verification of lazy nodes and reduce the verification cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0051] Figure 1A schematic diagram of a scenario of a transaction method based on a directed acyclic graph in an embodiment;

[0052] Figure 2 A schematic diagram of a process flow of a transaction method based on a directed acyclic graph in one embodiment;

[0053] Figure 3 A schematic diagram of a flow chart of a step of determining a preset verification rule in an embodiment;

[0054] Figure 4 is a schematic diagram of the structure of a transaction device based on a directed acyclic graph in one embodiment;

[0055] Figure 5 FIG. 1 is a schematic diagram of the structure of a computer device in an embodiment.

[0056] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0057] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0058] The transaction method based on directed acyclic graph provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers.

[0059] Among them, the user can create and publish a public trust unit to the DAG network on the server 104 at the node through the terminal 102, wherein the public trust unit is used to record the order of each transaction related to the contract. For any node in the DAG network that receives the public trust unit, when executing transactions related to the contract, each transaction is executed in sequence from front to back according to the order in the public trust unit; wherein the transactions related to the contract are published to the directed acyclic graph according to the preset verification rules. In this way, the server 104 feeds back the transaction execution results to the terminal 102.

[0060] The above-mentioned transaction method based on directed acyclic graph is to publish a credibility unit in a pre-constructed directed acyclic graph; wherein the credibility unit is used to record the order of each transaction related to the contract; for any node in the directed acyclic graph that receives the credibility unit, when executing transactions related to the contract, each transaction is executed in sequence from front to back based on the order in the credibility unit, thereby performing consensus sorting on ordinary transactions in the directed acyclic graph and improving the reliability of the transaction order in the network. At the same time, the transactions related to the contract in this application are published to the directed acyclic graph according to the preset verification rules, which can prevent the disordered reference verification of lazy nodes and reduce the verification cost.

[0061] The terminal 102 may be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0062] It should be noted that the network communication between the terminal 102 and the server 104 is applicable to different network standards, for example, it can be applicable to global system of mobile communication (GSM), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time division synchronous code division multiple access (TD-SCDMA), long term evolution (LTE) system and future 5G and other network standards. Optionally, the above communication system can be a system in the scenario of ultra-reliable and low latency communications (URLLC) transmission in a 5G communication system.

[0063] Therefore, optionally, the above-mentioned base station can be a base station (Base Transceiver Station, referred to as BTS) and / or a base station controller in GSM or CDMA, or a base station (NodeB, referred to as NB) and / or a radio network controller (Radio Network Controller, referred to as RNC) in WCDMA, or an evolved base station (EvolutionalNode B, referred to as eNB or eNodeB) in LTE, or a relay station or access point, or a base station (gNB) in the future 5G network, etc., and the present application is not limited here.

[0064] The terminal 102 can be a wireless terminal or a wired terminal. A wireless terminal can be a device that provides voice and / or other service data connectivity to a user, a handheld device with a wireless connection function, or other processing devices connected to a wireless modem. A wireless terminal can communicate with one or more core network devices via a radio access network (Radio Access Network, referred to as RAN). A wireless terminal can be a mobile terminal, such as a mobile phone (or "cellular" phone) and a computer with a mobile terminal, for example, a portable, pocket-sized, handheld, computer-built-in or vehicle-mounted mobile device, which exchanges language and / or data with a radio access network. For another example, a wireless terminal can also be a personal communication service (Personal Communication Service, referred to as PCS) phone, a cordless phone, a Session Initiation Protocol (Session Initiation Protocol, referred to as SIP) phone, a wireless local loop (Wireless Local Loop, referred to as WLL) station, a personal digital assistant (Personal Digital Assistant, referred to as PDA) and other devices. A wireless terminal may also be referred to as a system, a subscriber unit, a subscriber station, a mobile station, a mobile station, a remote station, a remote terminal, an access terminal, a user terminal, a user agent, or a user device or user equipment, without limitation herein.

[0065] In one embodiment, a transaction method based on a directed acyclic graph is provided. This embodiment uses the method applied to the server 104 as an example. Figure 2As shown, the directed acyclic graph-based transaction method includes:

[0066] Step 202: Publish a credibility unit in a pre-built directed acyclic graph; wherein the credibility unit is used to record the order of transactions related to the contract.

[0067] Specifically, the structure of the directed acyclic graph (DAG) is constructed in advance by the service provider according to the design requirements, and a software environment such as an operating system and a database is built on the server 104, and then the constructed DAG structure is deployed on the server 104 to form a DAG network.

[0068] In a DAG network, a transaction (Tx) is created and published by any node. A node usually refers to a device or entity that has the ability to verify transactions. Specifically, in a server cluster or distributed system, a node usually refers to an independent server. Each server node has its own processor, memory, storage, and network interface, and can independently perform specific tasks.

[0069] Contracts usually refer to smart contracts, which are self-executing codes running on the blockchain that can automatically execute agreements according to preset conditions. Transactions belonging to the same contract have an association relationship. When a node publishes a new transaction, the contract to which the transaction belongs and other related transactions can be known through the association relationship.

[0070] In this embodiment, the credibility unit is a special transaction, which operates in the DAG network in the same way as ordinary transactions. It can refer to previous transactions and be referenced by new transactions. It needs to be fixed in the network after sufficient transaction verification. The difference between the two is that transactions can be created and published by any node, while the publisher of the credibility unit is a node with credibility. Among them, the credibility node refers to the node that is elected or designated in the DAG network through a consensus mechanism, such as PoW, PoS or DPoS, and is responsible for verifying transactions, building a trust network, and helping the network reach a consensus. Furthermore, the main content of ordinary transactions is the addresses of the two parties to the transfer and the amount of the transfer, while the credibility unit does not carry the transfer information of ordinary transactions, but records the order of transactions related to the selected contract.

[0071] Exemplarily, a credibility node in the DAG network publishes a credibility unit Order1 based on the current transaction and contract-related information. Order1 records the order of all previous transactions related to the contract. Other nodes in the DAG network receive the credibility unit Order1, first verify the legitimacy of Order1, and then put the previous transaction referenced in Order1 into the local transaction pool. Furthermore, the credibility node monitors transaction activities in the DAG network in real time or at regular intervals. When a new contract-related transaction is released, the credibility node will create and publish a new credibility unit Order2. Order2 references Order1, and Order2 also records the order of the above-mentioned new transactions related to the contract. These new transactions are also placed in the local transaction pools of other nodes.

[0072] Step 204: For any node in the directed acyclic graph that receives the public trust unit, when executing transactions related to the contract, the transactions are executed in order from front to back according to the order in the public trust unit. The transactions related to the contract are published to the directed acyclic graph according to the preset verification rules.

[0073] Specifically, the nodes that execute transactions related to the contract in this embodiment refer to nodes with execution capabilities in the DAG network. After receiving the credibility unit published by the credibility node to the DAG network, these nodes store the credibility unit and the transactions referenced by the credibility unit.

[0074] Furthermore, before each transaction is allowed to be published to the DAG network, it needs to verify multiple previous transactions, and the number of previous transactions depends on the specific rules of the DAG network. This verification mechanism allows the DAG network to asynchronously and concurrently write many transactions, and ultimately form a topological tree structure, greatly improving the scalability and transaction speed of the system.

[0075] Furthermore, verifying multiple previous transactions under the constraints of preset verification rules can ensure that the transaction initiator strictly executes the transaction in accordance with the set requirements, while also avoiding the same address sending a large number of transactions in a short period of time, thereby effectively reducing the verification cost.

[0076] The above-mentioned transaction method based on directed acyclic graph is to publish a credibility unit in a pre-constructed directed acyclic graph; wherein the credibility unit is used to record the order of each transaction related to the contract; for any node in the directed acyclic graph that receives the credibility unit, when executing transactions related to the contract, each transaction is executed in sequence from front to back based on the order in the credibility unit, thereby performing consensus sorting on ordinary transactions in the directed acyclic graph and improving the reliability of the transaction order in the network. At the same time, the transactions related to the contract in this application are published to the directed acyclic graph according to the preset verification rules, which can prevent the disordered reference verification of lazy nodes and reduce the verification cost.

[0077] Optionally, the trust unit records the order of transactions related to the contract, including:

[0078] The credibility unit references the hash value of each transaction related to the contract, and determines and records the order of transactions based on each hash value.

[0079] Specifically, each transaction in the DAG network generates a corresponding hash value when it is created, and the hash value is the unique identifier of the transaction. For a selected contract, the credibility unit regularly collects transactions related to the contract from the DAG network, and sorts each transaction based on the hash value of each contract according to the pre-agreed rules. Exemplarily, a preliminary sorting can be performed according to the natural order of the string or number of the hash value, and then sorted according to the reference relationship of each transaction; in addition, if there are some transactions that are generated at the same time and have close hash values, the sorting can be further refined by the timestamp of the transaction. For example, a group of transactions Tx1, Tx2, Tx3, and Tx4 belonging to the same contract have the following reference relationships in the DAG network: Tx3 references Tx1, and Tx4 references Tx2 and Tx3; each transaction has a unique hash value H(Tx1), H(Tx2), H(Tx3), and H(Tx4). First, perform a preliminary sorting in the natural order of the hash values. For example, the preliminary sorting order is H(Tx1), H(Tx2), H(Tx3), H(Tx4). Then, based on the reference relationship of each transaction, ensure that Tx3 is executed after Tx1, and Tx4 is executed after Tx2 and Tx3. The final order is Tx1, Tx3, Tx2, Tx4. In this way, when the node executes the above transactions, Tx1, Tx3, Tx2, Tx4 can be executed in the order in the public trust unit.

[0080] The above-mentioned transaction method based on directed acyclic graph publishes a credibility unit in the DAG network. The credibility unit determines the execution order of each transaction by referencing the hash value of each transaction related to the contract. When any node receives the credibility unit and executes the contract, it can execute each transaction in sequence according to the execution order recorded in the credibility unit, helping the DAG network to sort common transactions by consensus and improving the reliability of the transaction order in the network.

[0081] Optionally, the directed acyclic graph-based transaction method of the embodiment of the present application further includes:

[0082] For the previous transaction that has been verified and referenced by the public trust unit, the status of the previous transaction is determined so that it cannot be referenced again by a new transaction.

[0083] Specifically, when a new credibility unit is created, in addition to recording the execution order of each transaction related to the contract, it will also verify the previous transaction or other credibility units through the consensus mechanism with other nodes in the network to ensure the legitimacy and validity of these transactions. When a previous unit is referenced by a new credibility unit, the state of the previous unit will be immediately locked to prevent it from being changed or rolled back, reducing the possibility of parasitic chain attacks on the DAG network and enhancing network security.

[0084] In the above-mentioned transaction method based on directed acyclic graph, the status of the previous unit verified and referenced by the credibility unit will be immediately determined and cannot be overturned. By determining the network status in the above-mentioned way, the network is prevented from being rolled back by the parasitic chain, reducing the risk of being attacked.

[0085] Optionally, the transaction in this embodiment can be created and published by any node, and the node must meet the preset verification rules before publishing the transaction, wherein the judgment method of meeting the preset verification rules includes:

[0086] For a transaction to be published, the initiator of the transaction needs to verify multiple unverified previous transactions before being allowed to publish. In this embodiment, the verification number i≥2, and the specific number can be set as needed.

[0087] When a node creates more than one transaction, the newly released transaction of the node refers to all the previous transactions released by it to form the transaction sequence path of the node. Here, the newly released transaction refers to all the previous transactions released by it, which means that the newly released transaction can directly or indirectly refer to all the previous transactions released by it. Exemplarily, a node releases transactions Tx1, Tx2, Tx3, and Tx4 in sequence, where Tx4 is a newly released transaction, Tx1, Tx2, and Tx3 are previous transactions, Tx4 refers to Tx3, and Tx3 refers to Tx1 and Tx2. Then the newly released transaction of the node refers to all previous transactions; at the same time, since Tx1 and Tx2 have been referenced by Tx3, the newly released transaction Tx4 can only reference Tx3, but not Tx1 and Tx2.

[0088] See also Figure 3 Optionally, the judgment method that meets the preset verification rules also includes:

[0089] Step 302: For a transaction to be published, a pre-built hash function is used to calculate a hash value corresponding to the transaction to be published.

[0090] Step 304: If the hash value corresponding to the transaction to be published meets the first preset condition, the initiator of the transaction to be published is allowed to select a previous transaction for verification.

[0091] Specifically, the first preset condition is used to verify the validity of the current transaction. Setting the first preset condition can prevent unauthorized initiators from forging transaction actions. The first preset condition ensures that the transaction initiator who requests to establish a transaction unit must have the correct computing power and consume a certain amount of computing resources before requesting to establish a transaction unit. To a certain extent, it prevents unauthorized initiators from initiating a large number of requests to establish transaction units in a short period of time. Unauthorized initiators refer to those who do not have the right to establish transaction units at the service provider.

[0092] For example, before issuing a transaction A, the transaction initiator first constructs the transaction content of transaction A, including the transaction amount, sender and receiver, etc. Then, the pre-constructed hash function H(string) is used to calculate the hash value of transaction A so that it meets certain difficulty requirements. Among them, the judgment method that meets the first preset condition includes:

[0093] If there is an adjustable value such that the hash value corresponding to the transaction to be published is less than or equal to the first hash threshold, it is considered to meet the first preset condition, and its expression is:

[0094] H(tx,nonce)≤a

[0095] Wherein, H() represents a hash function; tx represents a transaction to be published; nonce represents an adjustable value used to adjust the hash value of tx; a represents the first hash value threshold.

[0096] Combine the content of transaction A with a random number nonce, and continuously adjust the value of nonce until a suitable value is found so that the calculated hash value is less than or equal to a. Once a nonce that meets the conditions is found, transaction A can prove its legitimacy and scarcity through proof of work.

[0097] Optionally, the initiator of the transaction to be published selects a previous transaction for verification, including:

[0098] A preset number of preceding transactions are selected, and if the hash values ​​corresponding to the selected preceding transactions meet the second preset condition, the selected preceding transactions are referenced and verified.

[0099] Specifically, the initiator of the transaction needs to select a set of previous transactions from the existing transaction pool. These previous transactions are the dependent objects of the initiator and are used to ensure that the verification chain of the transaction to be published is valid. Among them, the judgment method that meets the second preset condition includes:

[0100] A pre-built hash function is used to calculate the hash values ​​corresponding to the selected previous transactions, and the hash values ​​corresponding to the previous transactions are randomly combined to obtain multiple sets to be selected;

[0101] For a candidate set, a pre-built hash function is used to calculate the hash value of the candidate set;

[0102] If there is an adjustable value such that the hash value of the candidate set is less than or equal to the second hash threshold, it is considered to meet the second preset condition, and its expression is:

[0103] H(H(txN1),H(txN2),…H(txNi),nonce)≤b

[0104] Among them, txNi represents a selected previous transaction; nonce represents an adjustable value used to adjust the hash value of the selected set; b represents the second hash value threshold, and the second hash value threshold is greater than or equal to the first hash value threshold.

[0105] Combine the hash values ​​of all previous transactions associated with transaction A and a random number nonc e Combined with the continuous adjustment of nonc e until a suitable value is found so that the calculated hash value is less than or equal to b. Once a nonc that meets the conditions is found e, the initiator can prove that transaction A depends on a set of verified previous transactions and meets the verification requirements of the network. This is also to prevent network attacks and maintain the security and consistency of the entire network.

[0106] Optionally, the directed acyclic graph-based transaction method of the embodiment of the present application further includes: if the hash value corresponding to the selected preceding transaction does not meet the second preset condition, adjusting the preset quantity to the updated quantity;

[0107] Select the updated number of previous transactions, and determine whether the hash value corresponding to the reselected previous transaction meets the second preset condition. If so, reference and verify the reselected previous transaction.

[0108] Specifically, if a previous transaction that meets the second preset condition cannot be selected, that is, the transaction initiator cannot select a qualified parent unit txNi from the current unreferenced transaction, then adjust the value of the preset number, select more or fewer previous transactions, recalculate the hash value of each previous transaction, and traverse the transactions that meet the second preset condition after combining them.

[0109] Optionally, the directed acyclic graph-based transaction method of the embodiment of the present application further includes:

[0110] Compare the transaction difficulty value with the preset difficulty threshold.

[0111] When the transaction difficulty value is greater than or equal to the preset difficulty threshold, a difficulty adjustment prompt message is generated to enable the service provider to adjust the difficulty coefficient and reduce the verification cost.

[0112] Among them, the transaction difficulty value is related to the verification cost of newly released transactions.

[0113] Specifically, most transactions in the DAG network do not have a strong causal relationship, and each transaction is written independently in an asynchronous and concurrent manner. Before a new transaction A is released to the DAG network, the initiator of transaction A needs to verify at least two previous transactions to verify the legitimacy of transaction A. Each previous transaction has its own verification cost, which represents the computing resources or proof of work required to verify the transaction. The overall computing workload constituted by all previous transactions verified by transaction A is recorded as the previous verification cost. In addition, before verifying the previous transaction, the initiator of transaction A also needs to perform a proof of work on transaction A. The overall computing workload in the proof process constitutes the local verification cost. Then the overall verification cost of transaction A is the sum of the previous verification cost and the local verification cost. Its value is recorded as the transaction difficulty value, and its expression is:

[0114] F=f1+f2

[0115]

[0116] Among them, f1 represents the previous verification cost, f2 represents the local verification cost; verify j represents the verification cost associated with the jth previous transaction, then f1 is the sum of the verification costs of all previous transactions; is the preset difficulty threshold, which is used to represent the target value of the proof of work; H(txN i ) represents the hash value of the previous transaction i referenced by the new transaction.

[0117] By adopting the above scheme, when the transaction difficulty value reaches the preset difficulty threshold, a difficulty adjustment prompt message is generated and fed back to the business provider, so that the business provider can adjust the above second preset condition to reduce the difficulty coefficient of establishing a reference relationship between the new transaction and the previous transaction, thereby realizing dynamic adjustment of the construction speed of new transactions in the business provider.

[0118] The above-mentioned transaction method based on directed acyclic graph, by publishing a credibility unit in a pre-constructed directed acyclic graph; wherein the credibility unit is used to record the order of each transaction related to the contract; for any node in the directed acyclic graph that receives the credibility unit, when executing transactions related to the contract, each transaction is executed in sequence from front to back based on the order in the credibility unit, thereby performing consensus sorting on ordinary transactions in the directed acyclic graph and improving the reliability of the transaction order in the network. At the same time, the status of the previous transaction verified and referenced by the credibility unit is locked, which reduces the possibility of parasitic chain attacks on the DAG network and enhances network security. Furthermore, the transactions related to the contract in this application are published to the directed acyclic graph according to preset verification rules, which can prevent the disordered reference verification of lazy nodes and reduce verification costs.

[0119] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0120] Based on the same inventive concept, the embodiment of the present application also provides a directed acyclic graph-based trading device for implementing the directed acyclic graph-based trading method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the directed acyclic graph-based trading method above, so the specific limitations in one or more device embodiments provided below can refer to the limitations of the directed acyclic graph-based trading method above, and will not be repeated here.

[0121] See also Figure 4 In one embodiment, a transaction device based on a directed acyclic graph is provided, including: a publishing module and an execution module.

[0122] A publishing module, used to publish a credibility unit in a pre-built directed acyclic graph; wherein the credibility unit is used to record the order of transactions related to the contract;

[0123] The execution module is used to execute each transaction in sequence from front to back according to the order in the credibility unit when executing transactions related to the contract for any node in the directed acyclic graph that receives the credibility unit.

[0124] Optionally, the credibility unit published by the publishing module records the order of transactions related to the contract, including: the credibility unit references the hash value of each transaction related to the contract, and determines and records the order of each transaction according to each hash value.

[0125] Optionally, the directed acyclic graph-based transaction device of the present application further includes: a state locking module.

[0126] The state locking module is used to determine the state of the previous transaction that has been verified and referenced by the public trust unit so that it cannot be referenced again by a new transaction.

[0127] Optionally, the directed acyclic graph-based transaction device of the present application further includes: a verification module.

[0128] The verification module is used to publish the contract-related transactions to the directed acyclic graph after verifying multiple previous transactions according to the preset verification rules. Among them, the judgment methods that meet the preset verification rules include:

[0129] For a transaction to be published, the initiator of the transaction needs to verify multiple unverified previous transactions before being allowed to publish. In this embodiment, the verification number i≥2, and the specific number can be set as needed.

[0130] When a node creates more than one transaction, the newly released transaction of the node refers to all the previous transactions released by it to form the transaction sequence path of the node. Here, the newly released transaction refers to all the previous transactions released by it, which means that the newly released transaction can directly or indirectly refer to all the previous transactions released by it.

[0131] Optionally, the judgment method that meets the preset verification rules also includes: for a transaction to be published, using a pre-built hash function to calculate the hash value corresponding to the transaction to be published; if the hash value corresponding to the transaction to be published meets the first preset condition, the initiator of the transaction to be published is allowed to select the previous transaction for verification. Among them, the judgment method that meets the first preset condition includes:

[0132] If there is an adjustable value such that the hash value corresponding to the transaction to be published is less than or equal to the first hash threshold, it is considered to meet the first preset condition, and its expression is:

[0133] H(tx,nonce)≤a

[0134] Wherein, H() represents a hash function; tx represents a transaction to be published; nonce represents an adjustable value used to adjust the hash value of tx; a represents the first hash value threshold.

[0135] Optionally, the initiator of the transaction to be published selects a previous transaction for verification, including: selecting a preset number of previous transactions, and if the hash value corresponding to the selected previous transaction meets the second preset condition, then referencing and verifying the selected previous transaction. Among them, the judgment method of meeting the second preset condition includes: using a pre-constructed hash function to calculate the hash value corresponding to each selected previous transaction, and randomly combining the hash values ​​corresponding to each previous transaction to obtain multiple sets to be selected; for a set to be selected, using a pre-constructed hash function to calculate the hash value of the set to be selected; if there is an adjustable value so that the hash value of the set to be selected is less than or equal to the second hash threshold, it is considered to meet the second preset condition, and its expression is:

[0136] H(H(txN1),H(txN2),…H(txNi),nonce)≤b

[0137] Among them, txNi represents a selected previous transaction; nonce represents an adjustable value used to adjust the hash value of the selected set; b represents the second hash value threshold, and the second hash value threshold is greater than or equal to the first hash value threshold.

[0138] Optionally, the verification module is also used to adjust the preset quantity to the updated quantity when the hash value corresponding to the selected predecessor transaction does not meet the second preset condition; select the predecessor transaction with the updated quantity, and determine whether the hash value corresponding to the reselected predecessor transaction meets the second preset condition; if so, reference and verify the reselected predecessor transaction.

[0139] Optionally, the directed acyclic graph-based trading device of the present application further includes: a difficulty coefficient adjustment module.

[0140] The difficulty coefficient adjustment module is used to compare the transaction difficulty value with the preset difficulty threshold; when the transaction difficulty value is greater than or equal to the preset difficulty threshold, a difficulty adjustment prompt message is generated to enable the service provider to adjust the difficulty coefficient and reduce the verification cost; wherein, the transaction difficulty value is associated with the verification cost of the newly released transaction. The transaction difficulty value expression is:

[0141] F=f1+f2

[0142]

[0143] Among them, f1 represents the previous verification cost, f2 represents the local verification cost; verify j represents the verification cost associated with the jth previous transaction, then f1 is the sum of the verification costs of all previous transactions; is the preset difficulty threshold, which is used to represent the target value of the proof of work; H(txN i ) represents the hash value of the previous transaction i referenced by the new transaction.

[0144] The above-mentioned transaction device based on directed acyclic graph, by publishing a credibility unit in a pre-constructed directed acyclic graph; wherein the credibility unit is used to record the order of each transaction related to the contract; for any node in the directed acyclic graph that receives the credibility unit, when executing transactions related to the contract, each transaction is executed in sequence from front to back based on the order in the credibility unit, thereby performing consensus sorting on ordinary transactions in the directed acyclic graph and improving the reliability of the transaction order in the network. At the same time, the status of the previous transaction verified and referenced by the credibility unit is locked, which reduces the possibility of parasitic chain attacks on the DAG network and enhances network security. Furthermore, the transactions related to the contract in this application are published to the directed acyclic graph according to preset verification rules, which can prevent the disorderly reference verification of lazy nodes and reduce verification costs.

[0145] Each module in the above device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.

[0146] See also Figure 5 , Figure 5 The figure is a schematic diagram of the structure of the computer device provided by the present application. The computer device 50 provided in this embodiment includes: at least one processor 501 and a memory 502. Optionally, the computer device 50 also includes a communication component 503. The processor 501, the memory 502 and the communication component 503 are connected via a bus.

[0147] In a specific implementation process, at least one processor 501 executes the computer-executable instructions stored in the memory 502, so that at least one processor 501 executes the above method.

[0148] The specific implementation process of the processor 501 can refer to the above-mentioned transaction method embodiment based on the directed acyclic graph. The implementation principle and technical effect are similar, and this embodiment will not be repeated here.

[0149] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0150] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.

[0151] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0152] The present application also provides a computer program product, including a computer program, which implements the above-mentioned directed acyclic graph-based transaction method when executed by a processor.

[0153] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above-mentioned directed acyclic graph-based transaction method is implemented.

[0154] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.

[0155] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.

[0156] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.

[0157] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0158] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0159] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0160] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0161] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A transaction method based on a directed acyclic graph, characterized in that: The method comprises: Publishing a credibility unit in a pre-built directed acyclic graph; wherein the credibility unit is used to record the order of transactions related to the contract; For any node in the directed acyclic graph that receives the credibility unit, when executing transactions related to the contract, the transactions are executed in sequence from the front to the back according to the order in the credibility unit; Among them, transactions related to the contract are published on the directed acyclic graph according to preset verification rules.

2. The method according to claim 1, characterized in that The credibility unit records the order of transactions related to the contract, including: The credibility unit refers to the hash value of each transaction related to the contract, and determines and records the order of each transaction according to each hash value.

3. The method according to claim 1, characterized in that The method further comprises: For a previous transaction verified and cited by the public trust unit, the status of the previous transaction is determined so that it cannot be cited again by a new transaction.

4. The method according to claim 1, characterized in that: Transactions in a directed acyclic graph are created and published by any node; The judgment method that meets the preset verification rules includes: For a transaction to be published, the initiator of the transaction needs to verify multiple unverified previous transactions before it is allowed to be published; When a node creates more than one transaction, the newly released transaction of the node must reference all the previous transactions it released before to form the transaction sequence path of the node.

5. The method according to claim 4, characterized in that The judgment method that complies with the preset verification rules also includes: For a transaction to be published, a pre-built hash function is used to calculate the hash value corresponding to the transaction to be published; If the hash value corresponding to the transaction to be published meets the first preset condition, the initiator of the transaction to be published is allowed to select a preceding transaction for verification.

6. The method according to claim 5, characterized in that The judgment method that meets the first preset condition includes: If there is an adjustable value such that the hash value corresponding to the transaction to be published is less than or equal to the first hash threshold, it is considered to meet the first preset condition, and its expression is: H(tx, nonce)≤a Among them, H() represents a hash function; tx represents a transaction to be published; nonce represents an adjustable value used to adjust the hash value of tx; a represents the first hash value threshold.

7. The method according to claim 5, characterized in that The initiator of the transaction to be published selects the previous transaction for verification, including: A preset number of preceding transactions are selected, and if the hash values ​​corresponding to the selected preceding transactions meet the second preset condition, the selected preceding transactions are referenced and verified.

8. The method according to claim 7, characterized in that The judgment method that meets the second preset condition includes: A pre-built hash function is used to calculate the hash values ​​corresponding to the selected previous transactions, and the hash values ​​corresponding to the previous transactions are randomly combined to obtain multiple sets to be selected; For a candidate set, a pre-built hash function is used to calculate the hash value of the candidate set; If there is an adjustable value such that the hash value of the candidate set is less than or equal to the second hash threshold, it is considered to meet the second preset condition, and its expression is: H(H(txN1), H(txN2),...H(txNi), nonce)≤b Among them, txNi represents a selected previous transaction; nonce represents an adjustable value used to adjust the hash value of the selected set; b represents the second hash value threshold, and the second hash value threshold is greater than or equal to the first hash value threshold.

9. The method according to claim 7, characterized in that: The method also includes failing to: When the hash value corresponding to the selected preceding transaction does not meet the second preset condition, the preset quantity is adjusted to the updated quantity; Select the updated number of previous transactions, and determine whether the hash value corresponding to the reselected previous transaction meets the second preset condition. If so, reference and verify the reselected previous transaction.

10. The method according to claim 1, characterized in that The method further comprises: Compare the transaction difficulty value with the preset difficulty threshold; When the transaction difficulty value is greater than or equal to the preset difficulty threshold, a difficulty adjustment prompt message is generated to enable the service provider to adjust the difficulty coefficient to reduce the verification cost; The transaction difficulty value is associated with the verification cost of a newly released transaction.

11. The method according to claim 10, characterized in that: The transaction difficulty value is the sum of the previous verification cost and the local verification cost; The previous verification cost represents the overall computational workload of the transaction initiator in verifying the previous transaction; and the local verification cost represents the overall computational workload of the transaction initiator in verifying the current transaction.

12. A trading device based on a directed acyclic graph, characterized in that: include: A publishing module, used to publish a credibility unit in a pre-built directed acyclic graph; wherein the credibility unit is used to record the order of each transaction related to the contract; An execution module is used to execute each transaction in sequence from front to back according to the order in the credibility unit for any node in the directed acyclic graph that receives the credibility unit when executing transactions related to the contract; wherein the transactions related to the contract are published to the directed acyclic graph according to preset verification rules.

13. A computer device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 11 when executed by a processor.

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