Blockchain multi-version transaction timing method and system based on partial order
By adopting a partially ordered multi-version transaction timing method on the blockchain, multiple transactions are allowed to be successfully put on the chain under the same timing, the problem of multiple transactions being abandoned in the existing technology is solved, and the transaction success rate and service efficiency of the blockchain are improved.
Patent Information
- Application Number
- CN202111443568.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2041-11-30
AI Technical Summary
In the complex blockchain asset scenario, multiple transactions with the same timing number of the same asset are abandoned, resulting in frequent transaction failures, low business success rate, low efficiency, poor user experience, and waste of resources.
The partially ordered blockchain multi-version transaction timing method is adopted, and the transactions under each asset are sorted and serialized, allowing multiple transactions under the same timing to be successfully put on the chain, improving the success rate of concurrent transactions.
It is realized that multiple transactions can be successfully put on the chain under the same time sequence, which improves the success rate of concurrent transactions, reduces the situation of abandonment of transactions, and ensures the consistency and traceability of complex blockchain asset transactions.
Smart Images

Figure CN114331709B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of blockchain, and in particular to a method and system for timing multi-version transactions in a partially ordered blockchain. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] Most existing technologies solve the needs of consistency of asset status, content, timing and asset traceability in complex blockchain asset scenarios by maintaining transaction timing numbers, recent transaction hashes and other timing information for asset accounts. As the application scenarios of complex blockchain assets continue to expand, the scope of business is getting wider and wider, the frequency of business is getting higher and higher, and multiple stakeholders of assets frequently use assets concurrently, resulting in more and more transactions with the same asset and the same timing number. For example, if the same real estate certificate is authorized to multiple government departments, multiple government departments will generate multiple transactions at the same time when handling business for this real estate certificate. These transactions are built based on the same timing number, so the timing numbers of multiple transactions are the same, that is, there are multiple versions of transactions with the same timing number.
[0004] The inventors found that under the background requirements of asset time consistency and traceability, in order to prevent double-spending and replay attacks of assets, the existing technology requires that only one transaction with the same time sequence number can be put on the chain, and all other transactions are abandoned. However, in actual scenarios, multiple transactions initiated simultaneously by multiple stakeholders of an asset often have no state dependency relationship with each other, and the transaction execution does not conflict with each other. The execution order of the transactions will not affect the final consistency and should not be abandoned. This leads to problems such as frequent transaction failures, low business success rate, low efficiency, poor user experience, and waste of resources. Summary of the invention
[0005] In order to solve the technical problems existing in the above-mentioned background technology, the present invention provides a partial-order blockchain multi-version transaction timing method and system, which can realize that multiple transactions in the same timing can be successfully uploaded to the chain, improve the success rate of concurrent transactions, and reduce the situation where concurrent transactions are abandoned.
[0006] In order to achieve the above object, the present invention adopts the following technical solution:
[0007] The first aspect of the present invention provides a method for timing a partial-order blockchain multi-version transaction, which comprises:
[0008] Sort the transactions under each asset according to the transaction sequence number;
[0009] Process the transactions of each time series number of the corresponding asset in order:
[0010] If there is only one transaction under the same time sequence number, the status check is directly performed and added to the serialized transaction list; if there are multiple transactions under the same time sequence number, serialization is performed; after the serialization is completed, the current time sequence number of the asset is updated to the time sequence number of the transaction processed this time;
[0011] The serialization process is as follows: find the largest set of transactions without state conflicts, discard the transactions that do not meet the state verification, sort the remaining transactions by transaction hash, perform state verification in sequence, and add them to the serialized transaction list after the verification is completed. Furthermore, after the remaining transactions are sorted by transaction hash, a temporary preceding transaction index variable is maintained for each transaction, and the state verification is performed in sequence based on the temporary variable.
[0012] Furthermore, the preceding transaction index variable is set to: the transaction hash that precedes the transaction after hash sorting, that is, the latest transaction hash value of the asset account after the preceding transaction is executed.
[0013] Furthermore, when the multi-version transaction verification is executed, the latest transaction sequence number is not updated.
[0014] Furthermore, if multiple transactions under the same time sequence number are added to the serialization queue, the most recent transaction index is updated to the hash code value of the block height.
[0015] Furthermore, when verifying the transaction under the next time sequence number of the asset, if the most recent transaction index points to the hash code value of the block height, the correctness of the reference state is verified by traversing the transactions under the previous time sequence number.
[0016] Furthermore, when tracing the asset transaction history, if the most recent transaction index points to a block, the corresponding transaction is found by traversing the block.
[0017] A second aspect of the present invention provides a partially ordered blockchain multi-version transaction timing system, which includes:
[0018] The transaction sorting module is used to sort the transactions under each asset according to the transaction sequence number.
[0019] The transaction processing module is used to process the transactions of each time sequence number of the corresponding asset in sequence:
[0020] If there is only one transaction under the same time sequence number, the status check is directly performed and added to the serialized transaction list; if there are multiple transactions under the same time sequence number, serialization is performed; after the serialization is completed, the current time sequence number of the asset is updated to the time sequence number of the transaction processed this time;
[0021] The serialization process is as follows: find the largest set of transactions without state conflicts, discard the transactions that do not meet the state verification requirements, sort the remaining transactions by transaction hash, perform state verification in sequence, and add them to the serialized transaction list after the verification is completed.
[0022] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the method for timing partial-order blockchain multi-version transactions as described above.
[0023] A fourth aspect of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the method for timing partial-order blockchain multi-version transactions as described above are implemented.
[0024] Compared with the prior art, the present invention has the following beneficial effects:
[0025] The present invention sorts the transactions under each asset according to the size of the transaction sequence number, and processes the transactions under each sequence number of the corresponding asset in sequence according to the sorting, thereby ensuring that multiple transactions under the same sequence can be successfully uploaded to the chain, improving the success rate of concurrent transactions and reducing the situation where concurrent transactions are abandoned.
[0026] The present invention directly performs status verification and adds the transaction to the serialized transaction list when there is only one transaction under the same time sequence number; serialization is performed when multiple transactions are included under the same time sequence number; while improving the transaction success rate, the consistency and traceability of the complex asset transaction status of the blockchain are ensured. The present invention achieves this effect without changing the data structure, ensuring compatibility with historical data. It is suitable for newly deployed chains and can also be upgraded and deployed on already deployed and running chains.
[0027] The present invention adapts to the scenario requirements of multiple users concurrently using the same asset, solves problems such as business failures caused by frequent transaction failures, low business success rate, low efficiency, poor user experience, waste of time and computing resources, and effectively improves the service efficiency of blockchain.
[0028] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0030] Figure 1It is a blockchain multi-version transaction according to an embodiment of the present invention;
[0031] Figure 2 This is a flow chart of a method for timing blockchain multi-version transactions based on partial order according to an embodiment of the present invention;
[0032] Figure 3 This is the process of obtaining each group of transactions in turn for processing and adding them to the serialized transaction list in the embodiment of the present invention;
[0033] Figure 4 It is the final serial sequence formed in the embodiment of the present invention. DETAILED DESCRIPTION
[0034] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0035] It should be noted that the following detailed descriptions are all illustrative and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0036] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0037] Terminology explanation:
[0038] The blockchain multi-version transaction described in the present invention refers to multiple transactions under the same time sequence number of an asset.
[0039] The prior art maintains a transaction timing information for an asset account. The timing information includes an integer label LRNonce in time order and the most recent transaction index LRHash. LRNonce is used to mark the number of the most recent transaction in the asset account, and LRHash represents the hash of the most recent transaction of the asset. Asset transactions contain LRHash and Nonce. LRHash is used to mark the referenced state, and its value is the most recent transaction index of the asset account when the transaction is constructed; Nonce refers to the timing label of this transaction, and its value is based on the current timing label of the asset account when the transaction is constructed plus 1, which is used to mark the time sequence relationship of the asset transaction. When executing a transaction, it needs to be executed strictly in accordance with the timing relationship sequence, and it is ensured that the referenced state is the most recent transaction of the asset account. For multiple transactions in the same timing state of the asset account, only one can be on the chain to ensure the consistency of the asset transaction. At the same time, through the LRHash maintained in the asset account, the most recent transaction of the asset can be quickly found. Through the LRHash carried in the transaction, the previous transaction of the most recent transaction can be found. By searching forward in sequence, a complete transaction chain of an asset account can be obtained, and efficient traceability of the asset account can be achieved.
[0040] According to the background technology, in order to solve the complex asset scenarios of blockchain, to meet the requirements of consistency in multiple dimensions such as asset status, content, timing, and asset traceability, and to prevent the problem of double spending of assets, when assets are used concurrently, multiple transactions under the same asset timing number can only have one transaction on the chain, resulting in frequent transaction failures, low business success rate, low efficiency, poor user experience, waste of resources and other problems. The present invention provides a blockchain multi-version transaction timing method and system based on partial order.
[0041] Embodiment 1
[0042] Blockchain multi-version transactions, such as Figure 1 As shown in the figure: Multiple transactions under the same time sequence number of the same asset are called multi-version transactions. For example, as shown in the figure, there are multiple transactions of different assets, asset OID γ At the timing mark T α+1 There are multiple transactions. The arrows in the figure point to the previous transaction of this transaction, such as the asset OID γ At the timing mark T α+1 All multi-version transactions at that time point to TX γ_1 , which means that their previous transactions are all TX γ_1 .
[0043] The idea of a partial-order blockchain multi-version transaction timing method of this embodiment is: sort the transactions under each asset according to the size of the transaction timing number; and process the transactions under each timing number of the corresponding asset in sequence according to the sorting. Among them, before sorting according to the transaction timing number, it also includes grouping transactions according to assets. Among them, transactions with the same assets are grouped together.
[0044] like Figure 2 As shown in the figure, the specific steps of the partial order blockchain multi-version transaction timing method are given:
[0045] Step 201: Grouping transactions by asset;
[0046] Step 202: Sort the transactions under each asset according to the transaction sequence number;
[0047] Step 203: Process the transactions of each time sequence number of the corresponding asset in order:
[0048] If there is only one transaction under the same time sequence number, the status check is directly performed and added to the serialized transaction list; if there are multiple transactions under the same time sequence number, serialization is performed; after the serialization is completed, the current time sequence number of the asset is updated to the time sequence number of the transaction processed this time;
[0049] Among them, the latest transaction sequence number is not updated when the multi-version transaction verification is executed.
[0050] Specifically, the serialization process is as follows: find the largest set of transactions without state conflicts, discard the transactions that do not meet the state verification requirements, sort the remaining transactions by transaction hash, perform state verification in sequence, and add them to the serialized transaction list after the verification is completed.
[0051] Among them, after the remaining transactions are sorted according to the transaction hash, a temporary preceding transaction index variable is maintained for each transaction, and the status verification is executed in sequence based on the temporary variable.
[0052] The value of the preceding transaction index variable is: the transaction hash that precedes the transaction after hash sorting, that is, the latest transaction hash value of the asset account after the previous transaction is executed. When the transaction performs a reference status correctness check, the temporary variable is compared with the asset account's current latest transaction hash value to verify the correctness of the reference status.
[0053] It should be noted here that a state-free transaction set refers to transactions in the set, where the states to be changed are all different and do not depend on the state to be changed by any transaction. For example, in a blockchain using a state machine model, two transactions change the quantity of an asset and the text content of an asset respectively. The two states to be changed are different and have no dependency on each other, that is, the change of one state does not affect the other state. In this case, the two transactions are considered to have no state conflict.
[0054] If multiple transactions under the same time sequence number are added to the serialization queue, the most recent transaction index is updated to the hash code value of the block height. When verifying transactions under the next time sequence number of an asset, if the most recent transaction index points to the hash code value of the block height, the correctness of the reference state is verified by traversing the transactions of the previous time sequence number.
[0055] When tracing the asset transaction history, if the most recent transaction index points to a block, the corresponding transaction is found by traversing the block.
[0056] In the specific implementation, Figure 3 As shown, the specific steps of step 203 include:
[0057] Step 2031: Obtain all transactions of the asset under the time sequence number in order of the time sequence number;
[0058] Step 2032: determine whether there are multiple transactions under the time sequence number, if yes, go to step 2033, otherwise go to step 2039;
[0059] Step 2033: Find the largest set of transactions without state conflicts, and discard the transactions that do not meet the state verification requirements;
[0060] Step 2034: The remaining transactions are sorted by transaction hash;
[0061] Step 2035: According to the sorted order, a temporary preceding transaction index variable is maintained for each transaction for status verification;
[0062] Step 2036: perform status verification in sequence, and add the verification to the serialized transaction list after completion. The transaction sequence number of the asset account is not updated during execution;
[0063] Step 2037: After all transactions selected under the time sequence number are executed, update the asset account transaction time sequence number to the time sequence number;
[0064] Step 2038: If there are multiple transactions added to the serialization sequence under this time sequence number, update the most recent transaction index value to the hash value generated by the block height encoding. When the first transaction under the next time sequence number is checked and executed, if the current most recent transaction index value of the asset account is the hash value generated by the block height encoding, traverse the transactions under the previous time sequence number to find out whether there is a transaction pointed to by the LRHash of this transaction to verify whether the transaction chain is correct.
[0065] Step 2039: Perform status verification on the transaction and add it to the serialized transaction list.
[0066] like Figure 4 As shown, Figure 1 The asset OID shown γ After step 203, the transaction partial order graph is added to the serialization sequence. In the figure, hash(bn) represents the hash value generated by encoding the current block height bn; LRNonce represents the current asset account time sequence number, and LRHash represents the current asset's most recent transaction hash; the transaction TX in the figure γ_2 and TX γ_3 The states do not conflict with each other, TX γ_4 and TX γ_2 TX γ_3 There is a state conflict, TX γ_5 and TX γ_7 The states do not conflict with each other; among them:
[0067] T α There is only one transaction TX γ_1 , after the direct verification is passed, it is added to the queue and LRNonce and LRHash are updated to (α, TX γ_1 );
[0068] T α+1 There are 3 transactions under this, and the largest stateless conflict transaction set {TX γ_2 TX γ_3}, abandoned TX γ_4 , TX γ_2 TX γ_3 All have passed the status verification, and after transaction hash sorting, TX γ_2 The temporary preceding transaction index variable is TX γ_3 , let TX γ_2 The previous transaction points to TX γ_3 . Execute TX first γ_3 , LRHash is updated to TX γ_3 , and then execute TX γ_2 After execution, LRhash is updated to TX γ_2;After the execution is completed, update LRNonce and LRHash to (α+1, hash(bn));
[0069] T α+2 TX γ_6 TX γ_8 The referenced status is TX γ_4 , resulting in the state check failing and being abandoned, TX γ_5 TX γ_7 The states do not conflict with each other. After sorting, TX γ_7 The temporary preceding transaction index variable is TX γ_5 , let TX γ_7 The previous transaction points to TX γ_5 . Execute TX first γ_5 , LRHash is updated to TX γ_5 , and then execute TX γ_7 , LRHash is updated to TX γ_7 ; After the execution is completed, update LRNonce and LRHash to (α+2, hash(bn))
[0070] T α+3 , there is only one transaction, following TX γ_7 Then execute the verification, TX γ_9 During verification, the value of LRHash is hash(bn), which is obtained by traversing the previous time sequence number T α+2 Transaction judgment TX γ_9 Pre-transaction TX γ_5 If it exists, after the execution, LRNonce and LRHash are (α+3, TX γ_9 ).
[0071] Finally, TX γ_1 →TX γ_3 →TX γ_2 →TX γ_5 →TX γ_7 →TX γ_9 The serial sequence passes the verification and is executed on the chain.
[0072] Embodiment 2
[0073] This embodiment provides a partial-order blockchain multi-version transaction timing system, which specifically includes the following modules:
[0074] The transaction sorting module is used to sort the transactions under each asset according to the transaction sequence number.
[0075] The transaction processing module is used to process the transactions of each time sequence number of the corresponding asset in sequence:
[0076] If there is only one transaction under the same time sequence number, the status check is directly performed and added to the serialized transaction list; if there are multiple transactions under the same time sequence number, serialization is performed; after the serialization is completed, the current time sequence number of the asset is updated to the time sequence number of the transaction processed this time;
[0077] The serialization process is as follows: find the largest set of transactions without state conflicts, discard the transactions that do not meet the state verification requirements, sort the remaining transactions by transaction hash, perform state verification in sequence, and add them to the serialized transaction list after the verification is completed.
[0078] It should be noted that the various modules in this embodiment correspond one-to-one to the various steps in the first embodiment, and the specific implementation process is the same, which will not be repeated here.
[0079] Embodiment 3
[0080] This embodiment provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the method for timing partial-order blockchain multi-version transactions as described above.
[0081] Embodiment 4
[0082] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the method for timing partial-order blockchain multi-version transactions as described above are implemented.
[0083] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products of the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram and the combination of the processes and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0084] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for timing multi-version transactions in a partially ordered blockchain, characterized in that: include: Sort the transactions under each asset according to the transaction sequence number; Process the transactions of each time series number of the corresponding asset in order: If there is only one transaction under the same time sequence number, the status check is directly performed and added to the serialized transaction list; if there are multiple transactions under the same time sequence number, serialization is performed; after the serialization is completed, the current time sequence number of the asset is updated to the time sequence number of the transaction processed this time; The serialization process is as follows: find the largest transaction set without state conflicts, discard the transactions that do not meet the state verification, sort the remaining transactions according to the transaction hash, perform the state verification in sequence, and add them to the serialized transaction list after the verification is completed; after the remaining transactions are sorted according to the hash, a temporary preceding transaction index variable is maintained for each transaction, and the state verification is performed in sequence based on the temporary preceding transaction index variable.
2. The method for timing partial-order blockchain multi-version transactions as claimed in claim 1, characterized in that: The preceding transaction index variable is set to: the transaction hash that precedes the transaction after hash sorting, that is, the latest transaction hash value of the asset account after the preceding transaction is executed.
3. The method for timing partial-order blockchain multi-version transactions as claimed in claim 1, characterized in that: When executing multi-version transaction verification, the latest transaction sequence number is not updated.
4. The method for timing partial-order blockchain multi-version transactions as claimed in claim 1, characterized in that: If multiple transactions with the same time sequence number are added to the serialization queue, the most recent transaction index is updated to the hash code value of the block height.
5. The method for timing partial-order blockchain multi-version transactions as claimed in claim 1, characterized in that: When verifying the transactions under the next time series number of an asset, if the most recent transaction index points to the hash code value of the block height, the correctness of the reference state is verified by traversing the transactions of the previous time series number.
6. The method for timing partial-order blockchain multi-version transactions as claimed in claim 1, characterized in that: When tracing the asset transaction history, if the most recent transaction index points to a block, the corresponding transaction is found by traversing the block.
7. A partial-order blockchain multi-version transaction timing system, characterized in that: include: The transaction sorting module is used to sort the transactions under each asset according to the transaction sequence number. The transaction processing module is used to process the transactions of each time sequence number of the corresponding asset in sequence: If there is only one transaction under the same time sequence number, the status check is directly performed and added to the serialized transaction list; if there are multiple transactions under the same time sequence number, serialization is performed; after the serialization is completed, the current time sequence number of the asset is updated to the time sequence number of the transaction processed this time; The serialization process is as follows: find the largest transaction set without state conflicts, discard the transactions that do not meet the state verification, sort the remaining transactions according to the transaction hash, perform the state verification in sequence, and add them to the serialized transaction list after the verification is completed; after the remaining transactions are sorted according to the hash, a temporary preceding transaction index variable is maintained for each transaction, and the state verification is performed in sequence based on the temporary preceding transaction index variable.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps in the method for timing partial-order blockchain multi-version transactions as described in any one of claims 1 to 6 are implemented.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps in the partial-order blockchain multi-version transaction timing method as described in any one of claims 1-6 are implemented.
Citation Information
Patent Citations
Method and device for sorting transaction queue
CN108512775A
Block chain transaction execution method, block chain node and control device
CN113064730A