Transaction information storage method and device, equipment and medium
By selecting storage nodes in the blockchain system and storing transaction information in the nodes of both parties, combined with data structures such as Merkle trees, the problem of low UTXO data storage efficiency in the blockchain system is solved and the storage efficiency is reduced. The effect of consuming and improving consensus efficiency.
Patent Information
- Application Number
- CN202311469543.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-06
- Publication Date
- 2024-10-18
AI Technical Summary
The existing blockchain system uses UTXO accounting, which requires all nodes to store complete UTXO data, resulting in huge storage consumption and low computing and storage efficiency.
By selecting n nodes from the blockchain system as storage nodes, when an asset transaction occurs, the transaction information is stored in the nodes of the transaction initiator and the receiver respectively, and the transaction information is summarized and stored in the storage every preset time In the node, data structures such as Merkel trees are used to ensure the integrity and security of transaction information.
It effectively reduces the burden of storing complete transaction data on all nodes, reduces the storage pressure of the blockchain system, and improves storage efficiency and consensus efficiency.
Smart Images

Figure CN118799069A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a transaction information storage method, device, equipment and medium. Background Art
[0002] The blockchain system is a distributed database technology that connects data blocks in an orderly manner and uses cryptography to ensure that they cannot be tampered with or forged. The existing blockchain system uses the Unspent Transaction Output (UTXO) method to record accounts, and all nodes in the blockchain need to store complete UTXO data. In fact, the scale of UTXO data is huge, which includes all transactions or balances of all accounts, and the computing and storage consumption of each blockchain node is huge. Summary of the invention
[0003] The present application provides a transaction information storage method, device, equipment and medium, which can reduce the storage consumption of the blockchain system.
[0004] In a first aspect, an embodiment of the present application provides a transaction information storage method, which is applied to a blockchain system, and the method includes:
[0005] Select n nodes from the blockchain system and determine them as storage nodes, where n is a positive integer greater than or equal to 1;
[0006] When an asset transaction occurs in the blockchain system, obtain the transaction information corresponding to the asset transaction, which includes the transaction initiator and the transaction recipient;
[0007] The transaction information is stored in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver respectively;
[0008] At preset intervals, the transaction information corresponding to all asset transactions occurring within the preset time is stored in the storage node.
[0009] In a second aspect, the present application provides a transaction information storage device, which is applied to a blockchain system, and the device includes:
[0010] A selection module, used to select n nodes from the blockchain system and determine them as storage nodes, where n is a positive integer greater than or equal to 1;
[0011] An acquisition module is used to obtain transaction information corresponding to an asset transaction when an asset transaction occurs in the blockchain system. The transaction information includes the transaction initiator and the transaction receiver;
[0012] A first storage module is used to store the transaction information in an initiating node corresponding to a transaction initiator and a target node corresponding to a transaction receiver respectively;
[0013] The second storage module is used to store the transaction information corresponding to all asset transactions occurring within the preset time in the storage node at every preset time.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a processor and a memory storing computer program instructions;
[0015] When the processor executes the computer program instructions, it implements the transaction information storage method in any one of the embodiments of the first aspect.
[0016] In a fourth aspect, an embodiment of the present application provides a computer storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, a transaction information storage method as in any one of the embodiments in the first aspect is implemented.
[0017] In a fifth aspect, an embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes a transaction information storage method as in any one of the embodiments in the first aspect above.
[0018] In a transaction information storage method, device, equipment and medium provided in an embodiment of the present application, n nodes are selected from the blockchain system to be determined as storage nodes, where n is a positive integer greater than or equal to 1; in the case of an asset transaction in the blockchain system, the transaction information corresponding to the asset transaction is obtained, and the transaction information includes the transaction initiator and the transaction receiver; the transaction information is stored in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver respectively; at preset intervals, the transaction information corresponding to all asset transactions occurring within the preset time is stored in the storage node. In the above method, the transaction information is stored in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver respectively. This method stores the transaction information in the nodes corresponding to the transaction parties, effectively reducing the burden of all nodes storing complete transaction data, and regularly aggregates and stores the transaction information corresponding to all asset transactions occurring within the preset time in the storage node, effectively reducing the burden of all nodes storing complete UTXO data, while reducing the pressure of full node storage of the blockchain system, thereby reducing the storage consumption of the blockchain system. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0020] Figure 1It is a schematic diagram of the transaction process of the existing blockchain system;
[0021] Figure 2 It is a flowchart of a transaction information storage method provided by an embodiment of the present application;
[0022] Figure 3 This is a schematic diagram of ClientTree chain data provided by an embodiment of the present application;
[0023] Figure 4 This is a schematic diagram of a TXTree chain data provided by an embodiment of the present application;
[0024] Figure 5 It is a structural diagram of a transaction information storage device provided in an embodiment of the present application;
[0025] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0027] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0028] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0029] The existing blockchain system uses the UTXO method to record accounts, and all nodes of the blockchain need to store complete UTXO data. In fact, the scale of UTXO data is huge, which includes all transactions or balances of all accounts, and the computing and storage consumption of each blockchain node is huge. At present, the storage space of each blockchain node has expanded to 270GB and will continue to increase. The consensus efficiency is inefficient on such a large storage. Therefore, how to improve the consensus efficiency of the blockchain under massive storage data is one of the important issues facing the blockchain system.
[0030] In order to solve the problems existing in the prior art, the embodiments of the present application provide a transaction information storage method, device, equipment and medium.
[0031] The present application embodiment provides a transaction information storage method, device, equipment and medium. The transaction information storage method provided by the present application embodiment is first introduced below. Figure 2 As shown, the method is applied to a blockchain system, and the method specifically includes the following steps:
[0032] S100, selecting n nodes from the blockchain system and determining them as storage nodes, where n is a positive integer greater than or equal to 1.
[0033] Optionally, in an embodiment of the present application, n nodes can be selected from the blockchain system in a variety of ways, for example, the blockchain system can allow network participants to voluntarily become storage nodes. This means that anyone can choose to become a storage node as long as they meet some basic requirements, such as having sufficient computing resources and storage capacity. For example, the blockchain system can set up an election mechanism to allow network nodes to vote for storage nodes. This can be an election based on reputation, contribution, or other factors. In addition, consensus rules can define which nodes are eligible to become storage nodes, for example, the running time and performance of the nodes. Alternatively, the blockchain system can use a random selection method to randomly select storage nodes from the network. This helps to ensure decentralization and prevent centralization issues. It can also be a mixture of different rules and strategies to ensure the stability and security of the network.
[0034] Optionally, in the embodiments of the present application, the method of selecting storage nodes will vary according to the specific blockchain project and consensus algorithm. Specifically, it can ensure that the selected nodes have sufficient technical capabilities and resources to effectively perform storage tasks to support the normal operation of the network. In addition, to ensure the decentralized nature of the network, appropriate strategies should be adopted to balance the distribution of storage nodes.
[0035] S200, when an asset transaction occurs in the blockchain system, obtain transaction information corresponding to the asset transaction, where the transaction information includes the transaction initiator and the transaction recipient.
[0036] Optionally, in a feasible implementation of the present application, the application programming interface (API) of the blockchain can be accessed by writing a program or using a monitoring tool to obtain the latest transaction information, including the transaction initiator and the recipient. For another example, some blockchain platforms provide subscription services, so that notifications of specific addresses or transaction types can be subscribed through these services. When a transaction related to the subscription occurs, a notification will be received, thereby obtaining the transaction information.
[0037] For example, there are some third-party blockchain monitoring tools and platforms that can help monitor transactions on the blockchain in real time. In these optional embodiments, real-time monitoring of transactions on the blockchain will be able to obtain transaction information, including the transaction initiator and recipient. This is very useful for tracking the flow of assets and conducting real-time audits.
[0038] S300, storing the transaction information in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver respectively.
[0039] Optionally, in a feasible implementation of the present application, the transaction information is stored in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver respectively, and a Merkle tree can be used for storage.
[0040] Specifically, first, generate a data structure containing transaction information. This data structure should include the initiator, recipient, transaction amount, and other relevant information of the transaction. Each transaction should have a unique identifier, such as a transaction hash value, which can be used to verify the uniqueness and integrity of the transaction. The hash value of each transaction should correspond to the stored transaction information. For transaction information, a Merkle tree can be used to build a data structure to efficiently store and verify transaction information. A Merkle tree is a binary tree in which leaf nodes contain the original data (here, transaction information), and non-leaf nodes contain the hash values of the leaf nodes.
[0041] Subsequently, the transaction information is stored in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver. Each node maintains its own Merkle tree, which contains the transaction information related to it. It should be noted that in order to verify the integrity of the transaction information, each node should calculate the root hash value of its own Merkle tree. This can be achieved by calculating the hash values of non-leaf nodes layer by layer. In the end, each node knows its own root hash value. When the transaction information needs to be verified, the receiver of the transaction can obtain the relevant Merkle tree root hash value from the initiator, as well as the required leaf node data. The receiver can use this information to verify the integrity of the transaction information. This way can ensure the integrity and security of the transaction information during storage and transmission. Each node has its own Merkle tree to verify its transaction information, and can verify and collaborate with other nodes. This helps to ensure the credibility and security of the transaction.
[0042] Optionally, in an embodiment of the present application, a Merkle tree is a data structure used to verify and ensure the integrity of a large amount of data. The Merkle tree consists of leaf nodes, non-leaf nodes, and a root node.
[0043] Leaf nodes: Leaf nodes are the bottom-level nodes in the Merkle tree, and they contain actual data or information blocks. In blockchain, leaf nodes usually contain transaction data or other raw information. Each leaf node has a unique identifier, usually a hash of the data.
[0044] Non-leaf nodes: Non-leaf nodes are intermediate nodes in the Merkle tree. They do not contain actual data, but rather the hash value of a leaf node. The hash value of a non-leaf node is calculated from the hash values of its child nodes. The role of a non-leaf node is to aggregate the hash values of the leaf nodes below into a higher-level hash value.
[0045] Root node: The root node is the topmost node of the Merkle tree. It is the final hash value of all leaf nodes and non-leaf nodes. The hash value of the root node represents the integrity of the entire data set. In the blockchain, the hash value of the root node is usually used to verify the integrity of the transaction data of the entire block.
[0046] In these optional embodiments, the Merkle tree provides an efficient method to verify the integrity of data. By comparing the hash value of the root node, it can be determined whether the data has been tampered with. If the data of any leaf node changes, the hash value of the root node will change, thereby detecting the inconsistency of the data.
[0047] S400, at every preset time, storing the transaction information corresponding to all asset transactions occurring within the preset time in the storage node.
[0048] Optionally, in an embodiment of the present application, at the end of each preset time interval, relevant information of all asset transactions occurring during this period is collected, including the transaction initiator, the transaction recipient, the transaction amount, etc. Subsequently, these transaction information are constructed into TXTree chain data. The structure of TXTree should include block size, block version number, hash value of parent transaction ID, root hash value of Merkle tree, block creation time, transaction initiator and transaction recipient. This information will be used to verify and trace the validity of the transaction. The constructed TXTree chain data is then stored in the storage node. It should be noted that it can be ensured that this process is automatically triggered at the end of each preset time interval to collect and store the latest transaction information. This process will ensure that all asset transaction information is stored in the TXTree chain data within each preset time interval, and its validity can be verified at any time. This helps to ensure the integrity and traceability of the data while reducing the cost of storing and maintaining data.
[0049] In a transaction information storage method provided in an embodiment of the present application, n nodes are selected from the blockchain system and determined as storage nodes, where n is a positive integer greater than or equal to 1; in the case of an asset transaction in the blockchain system, the transaction information corresponding to the asset transaction is obtained, and the transaction information includes the transaction initiator and the transaction receiver; the transaction information is stored in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver respectively; at preset intervals, the transaction information corresponding to all asset transactions occurring within the preset time is stored in the storage node. In the above method, the transaction information is stored in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver respectively. This method stores the transaction information in the nodes corresponding to the transaction parties, effectively reducing the burden of all nodes storing complete transaction data, and regularly aggregates and stores the transaction information corresponding to all asset transactions occurring within the preset time in the storage node, which helps to ensure the traceability and security of historical transaction information, while reducing the pressure on the storage of all nodes in the blockchain system, thereby reducing the storage consumption of the blockchain system.
[0050] In one embodiment, the transaction information also includes the transaction time and the transaction amount; the above step 300 may specifically perform the following steps:
[0051] S310, converting the transaction information into a first hash binary tree, wherein the first hash binary tree includes a first fork and a second fork, the first fork is used to record the transaction hash value of the transaction information, and the second fork is used to record the transaction details corresponding to the asset transaction, the transaction details include the identity of the transaction initiator, the identity of the transaction recipient, and the transaction information;
[0052] S320, store the first hash binary tree in the initiating node and the target node respectively.
[0053] Optionally, in a possible implementation of the present application, first, the transaction information is constructed into a binary tree structure. The left branch (first fork) of this tree is used to record the transaction hash value of the transaction information, and the right branch (second fork) is used to record the transaction details corresponding to the asset transaction. In order to fill the first fork, the transaction information needs to be hashed. The information of each transaction is used as a leaf node, their hash values are calculated, and the hash values are added to the tree along the path of the first fork in sequence until the root node of the tree. This ensures that the hash value of each transaction is included in the first hash binary tree. In the second fork, the detailed information of each asset transaction is recorded, including the identity of the transaction initiator, the identity of the transaction recipient, and the transaction information. Subsequently, the root node of the first hash binary tree is stored in the initiator node corresponding to the initiator of the transaction and the target node corresponding to the target party of the asset transaction. The root node of the first hash binary tree can be used to verify the validity and integrity of the transaction.
[0054] Optionally, the existing blockchain system block generation method is to ensure the tamper-proof nature of the blockchain system. Each blockchain node records all blockchain user transaction data. This storage method occupies too much storage space for each node. In order to ensure the security of the system, the system's storage and computing efficiency are lost. In the embodiment of the present application, in order to address the problem of low storage efficiency of the existing blockchain system, the ClientTree chain storage method is adopted. The ClientTree chain data generation method is as follows:
[0055] (1) When a transaction occurs, only the two parties involved in the transaction and the TXTree node (i.e., storage node) record the transaction information. For example, when a transfer is required from user A to user B, only the ClientTree chain of user A and user B needs to be recorded, and the on-chain information of the entire transaction is recorded in the TXTree node.
[0056] (2) Figure 3 As shown, the transaction information of both parties in the ClientTree chain is recorded in the form of a left Merkle tree. The right leaf node of the ClientTree chain is the transaction information of both parties. The specific format is:
[0057] Table 1 ClientTree right leaf node format
[0058]
[0059]
[0060] The left leaf node value of the left Merkle tree is the hash value of the two child nodes of the node;
[0061] The right leaf node of the ClientTree chain = hash (parent ID of the left leaf node of the ClientTree chain, transaction initiator, transaction receiver, transaction time, transaction amount). For example Figure 3 In the example, the parent node of the child node of "transaction id1" and the child node of "transaction detail message 1" is "transaction id2: Hash (transaction id1, transaction detail message 1)".
[0062] Optionally, in the embodiment of the present application, the ClientTree storage structure proposed in the present application implements ClientTree to store only information related to its own transaction, so as to greatly save storage space and improve resource utilization. When tracing transaction details, it is only necessary to verify the TXTree chain data and the ClientTree data of both parties to the transaction to prove the validity of the transaction and improve consensus efficiency.
[0063] In these optional embodiments, the transaction information and the hash value and transaction details related thereto are converted into a first hash binary tree and stored in the initiating node and the target node to ensure the security and traceability of the transaction. By combining the transaction information with its hash value, the security and integrity of the transaction are ensured. If the transaction information is tampered with, its hash value will change, thereby triggering an alarm. The first hash binary tree is stored in the initiating node and the target node respectively, realizing distributed storage. This reduces the storage burden and reduces the pressure on a single storage node. And because the key part of the transaction information is stored on the nodes of the transaction initiator and the recipient, instead of each node storing the complete information, the network transmission burden is reduced and the transaction confirmation and verification process is accelerated.
[0064] In one embodiment, the above step 400 may specifically perform the following steps:
[0065] S410, for each preset time period, based on a preset hash function, performing a hash operation on first transaction information corresponding to all asset transactions occurring in the blockchain system within the preset time period to obtain a first hash value corresponding to each first transaction information;
[0066] S420, constructing a second hash binary tree based on the first hash value corresponding to each first transaction information, the second hash binary tree including leaf nodes and a root node, one leaf node corresponding to one first hash value, the root node including a root node hash value, and the root node hash value is obtained based on a combination of the first hash values corresponding to each leaf node;
[0067] S430, storing the second hash binary tree generated in each preset time period in a storage node.
[0068] Optionally, in a specific implementation of the present application, as Figure 4As shown, this application adopts a design method of generating a section and a block every 10 minutes. The generation method of TXTree chain data adopts the full Merkel tree method. The main function of using this storage structure is that when the traditional blockchain system reaches a consensus, all nodes of the blockchain system need to reach a consensus. The TXTree chain randomly selects N nodes from the entire blockchain system for record verification. This method can greatly improve the storage efficiency and consensus efficiency of the data on the chain. At the same time, the corresponding transfer-out ID and transfer-in ID in the ClientTree chain are introduced into the blockchain message. When tracing the blockchain, the corresponding transaction ID in the ClientTree can be quickly found, so that the TXTree chain data and the ClientTree chain data can be quickly mapped, saving storage space while improving consensus efficiency.
[0069] Optionally, in another implementation of the present application, at the end of each preset time period, the first transaction information of all asset transactions occurring in the blockchain system is traversed. Then, a preset hash function is applied to each first transaction information to obtain the first hash value corresponding to each first transaction information. And a leaf node is created for each first hash value. These leaf nodes constitute the bottom of the second hash binary tree. The leaf nodes are combined in pairs, and then the hash function is applied to their hash values to obtain the hash value of their parent node. This process continues until there is only one node, the root node. The hash value of the root node is obtained based on the combination of the first hash values of all leaf nodes. Subsequently, the second hash binary tree generated in each preset time period is stored in the storage node. This can adopt a distributed storage method to ensure that multiple nodes back up the same data.
[0070] In these optional embodiments, by constructing a second hash binary tree, it helps to provide security and auditability of transaction information, while reducing storage burden and network burden. The TXTree storage structure proposed in this application corresponds the TXTree chain data to the TXTree section data, generates a block in a Merkle tree manner every 10 minutes, records the current 10-minute transaction details, and is used for traceable history. Through this semi-centralized storage method, the original blockchain system stores all transaction details, and is changed to N nodes for storage, which greatly improves the consensus efficiency at the time of consensus.
[0071] In one embodiment, after the above step 430, the method may further specifically perform the following steps:
[0072] S431, for each preset time period, obtaining the real-time account balances of all accounts in the blockchain system at each moment in the preset time period;
[0073] S432, obtaining the current account balances of all accounts in the blockchain system corresponding to the last moment in a preset time period;
[0074] S433, creating a record block in the storage node, wherein one record block is created in a preset time period;
[0075] S434, the real-time account balance, the current account balance, and the second hash binary tree are stored in a record block, and one record block corresponds to one hash binary tree.
[0076] Optionally, in a specific implementation of the present application, in a blockchain cluster, a TXTree node (i.e., storage node) cluster with N nodes is randomly selected to form, and three data structure types of data are stored in the TXTree, namely, TXTree historical section data (i.e., current account balance), TXTree real-time section data (i.e., real-time account balance), and TXTree on-chain data (i.e., the second hash binary tree).
[0077] First, generate TXTree historical section data. The main function of TXTree historical section data is to generate a section every 10 minutes. The section data saves the final data of each account in the section, which is used for later blockchain system reconciliation and verification. Saving this type of data can be used for rapid verification. The historical section data is shown in Table 2, and the specific field definitions are as follows:
[0078] User: indicates a user who has registered in the blockchain;
[0079] User balance: the balance amount of the user;
[0080] Section time: one section every 10 minutes, indicating the current section time;
[0081] Table 2 Example of TXTree historical section data
[0082] Serial number user User Balance Section time 1 User A 100 2022.1.31 20:00:00 2 User B 300 2022.1.31 20:00:00 3 User C 200 2022.1.31 20:00:00 4 ... ... ... 5 User A 200 2022.1.31 21:10:00 6 User B 300 2022.1.31 21:10:00 7 User C 100 2022.1.31 21:10:00 8 ... ... ...
[0083] Subsequently, the TXTree real-time cross-section data is generated. The main function of the TXTree real-time cross-section data is to quickly query the real-time data of the account through the latest real-time cross-section data table. The traditional blockchain system uses UTXO calculation, and the real-time query efficiency is low. In some scenarios where traceability is not required, the real-time data can be quickly queried through this table to improve the query efficiency. The real-time cross-section data format is as shown in Table 3:
[0084] Table 3 TXTree real-time cross-section data example
[0085]
[0086]
[0087] Optionally, in the embodiment of the present application, the TXTree historical section data update cycle is once every 10 minutes. The TXTree real-time section data update cycle is real-time. The TXTree on-chain data update cycle is real-time. The ClientTree chain data update cycle is real-time, and each storage node generates a new TXTree chain every 10 minutes.
[0088] Optionally, in another feasible implementation of the present application, within each preset time period, the node can monitor or record the balance changes of each account at different time points. Specifically, it can be implemented through the internal mechanism of the blockchain system to monitor the changes in account balances. After each preset time period, the node can query or record the current balance of each account. Specifically, it can be implemented by calculating the account balance, and the current balance is calculated based on the transaction history and unconfirmed transactions of the account. At the end of each preset time period, the system can create a record block to record the data within the period. In the record block, the real-time account balance, the current account balance and the second hash binary tree can all be stored. These data can be stored through the standard data structure and storage mechanism of the blockchain system. In each record block, a hash binary tree is included to record the transaction information within the time period. It should be noted that the entire process needs to be closely integrated into the internal data structure of the blockchain system to ensure the accuracy and integrity of the real-time balance and hash binary tree data. After each preset time period, a new record block is generated, which includes the data within the corresponding time period. This helps to provide fast access to account balances and transaction data and historical records.
[0089] In these optional embodiments, by storing the real-time account balance, the current account balance and the second hash binary tree in the record block, the system can achieve archiving and fast access to data. This helps to provide fast retrieval of account balances and transaction history while ensuring the security and immutability of the data.
[0090] In one embodiment, the above step 433 may specifically perform the following steps:
[0091] S4331, obtaining the transaction size of all asset transactions occurring in the blockchain system within a preset time period, the number of all asset transactions occurring in the blockchain system within the preset time period, the second hash binary tree generated within the preset time period, and the version number of the blockchain system;
[0092] S4332, based on a preset combination rule, the transaction size of all asset transactions that occurred in the blockchain system within a preset time period, the number of all asset transactions that occurred in the blockchain system within the preset time period, the second hash binary tree generated in the preset time period, and the version number of the blockchain system are combined to obtain a block identifier of the record block.
[0093] Optionally, in the embodiment of the present application, the block generation rule is mainly composed of the block size, block version number, hash value of the parent transaction ID, root ID of the Merkle tree, block creation time, transaction initiator, and transaction receiver. The specific calculation formula is as follows:
[0094] Block ID = hash (transaction size, block version number, parent block ID, Merkle tree root ID, block creation time, consensus initiator node ID, number of transactions in the block).
[0095] The block size indicates the physical size of the block, usually in bytes. It indicates the total size of the data contained in the block. The block version number is a numerical value used to identify the version of the blockchain system. It helps to determine the version of the blockchain protocol to ensure that nodes of different versions can be compatible with each other. The hash value of the parent transaction ID refers to the hash value of the transaction ID of the previous block. Each block usually includes the hash value of the previous block to build an ordered chain of the blockchain. The root hash value of the Merkle tree represents the root node of a hash tree used to verify whether the transactions contained in the block are valid. This root hash value is the top hash of the Merkle tree and can be used to quickly verify the transactions in the block. The block creation time refers to the timestamp when the block is created or added to the blockchain. It helps to determine the time order of transactions. The transaction initiator represents the user or account that initiates the asset transaction. In the blockchain system, the transaction initiator usually includes some identity information or keys to prove that they have the right to conduct the transaction. The transaction recipient represents the user or account that receives the asset. This is the final destination of the asset in the transaction. These fields are key elements used to describe and identify transactions and blocks in the blockchain system. The core of blockchain technology is to store and maintain data in these fields to ensure the security and integrity of transactions.
[0096] In these optional embodiments, the block identifier can be used to verify the integrity of the record block to ensure that the data therein has not been tampered with. And the block identifier can be used to quickly retrieve and locate the record block within a specific time period to obtain the data therein, which is very helpful for auditing and querying data.
[0097] In one embodiment, after the above step 433, the method may further specifically perform the following steps:
[0098] S434 generates a transaction message corresponding to each asset transaction in the blockchain system based on the record block and the first hash binary tree, wherein the transaction message includes the transaction size, the version number of the blockchain system, the root node hash value, the block creation time of the record block, the transaction initiator, and the transaction receiver.
[0099] Optionally, in the embodiment of the present application, the format of each transaction message is as shown in Table 4 below:
[0100] Table 3 Blockchain transaction message format
[0101] Serial number Fields describe 1 Transaction size The size of this transaction, in kb 2 Block version number Identifies the version number of this blockchain system 3 The hash value of the parent transaction ID The hash value of the parent transaction ID 4 Merkle tree root ID The root ID of the Merkle tree of the current block 5 Block creation time The creation time of this block 6 Transaction Initiator Corresponding ID in the ClientTree of the transferred user 7 Transaction Receiver Transfer to the corresponding ID in the user ClientTree
[0102] In these optional embodiments, by creating transaction messages, it is ensured that each asset transaction has a corresponding transaction message, which improves the traceability, accuracy and security of the transaction and helps to better manage and maintain the blockchain system. This has a positive impact on the compliance, performance and stability of the blockchain system.
[0103] In one embodiment, after the above step 433, the method may further specifically perform the following steps:
[0104] S435, for any first node among the n storage nodes, compare the data consistency between the first real-time account balance, the first current account balance, and the target second hash binary tree stored in the first node to obtain a first result, where the first result is used to indicate whether the first real-time account balance, the first current account balance, and the target second hash binary tree are consistent;
[0105] S436, when the first result indicates that the first real-time account balance, the first current account balance, and the target second hash binary tree are consistent, verify the consistency between the first hash binary tree stored in the initiating node and the first hash binary tree stored in the target node, and obtain a second result, the second result is used to indicate whether the first hash binary tree stored in the initiating node is consistent with the first hash binary tree stored in the target node;
[0106] S437, when the second result indicates that the first hash binary tree stored in the initiating node is consistent with the first hash binary tree stored in the target node, it is determined that the blockchain system is valid.
[0107] Optionally, in a specific implementation of the present application, when the blockchain system verifies the accuracy of transaction data for traceability, first, the accuracy of the transaction is verified on the TXTree chain data, and the consistency of the TXTree chain data, TXTree historical section data, and TXTree real-time data is verified to determine whether it has been tampered with. If it has been tampered with, the blockchain system reaches a new consensus. If the data on the TXTree chain has not been tampered with, then find the corresponding record in the ClientTree chain data of both parties to the transaction. If both parties to the transaction pass the verification, it means that the data has not been tampered with and the transaction is passed. If the data of one party is inconsistent with the data of the other two parties, it means that the data has been tampered with, and the data is replaced with the correct transaction blocks of the other two parties to regenerate the corresponding value.
[0108] In these optional embodiments, by comparing the first real-time account balance, the first current account balance and the target second hash binary tree, it is ensured that the data of the storage node is consistent. This helps to discover data tampering or errors and maintain the data integrity of the blockchain system.
[0109] Optionally, in an embodiment of the present application, a new blockchain storage architecture based on TXTree and ClientTree improves consensus efficiency, and TXTree section data and TXTree chain data are stored through the TXTree storage structure. The TXTree section data is a section every 10 minutes, and the final data of the historical 10-minute section of each user is stored; the TXTree chain data corresponds to the TXTree section data, and a block is generated in a Merkle tree manner every 10 minutes to record the current 10-minute transaction details for traceable history; the ClientTree storage structure only saves information related to its own transactions, each client saves an independent ClientTree, and each ClientTree is only saved by both parties involved in the transaction. The underlying storage structure is a Merkle tree that only includes the left half leaf node, the left leaf node of the Merkle tree stores the transaction ID, and the right leaf node stores the transaction details. Each parent node is the hash value of the two child nodes of the node, and ClientTree is generated by this method. When tracing the transaction details, it is only necessary to verify the TXTree chain data and the ClientTree data of both parties to the transaction. If the verification is passed, it means that the transaction is valid, otherwise it is invalid. .
[0110] Alternatively, the existing blockchain system uses the UTXO method to record accounts, because it includes all transactions or balances of all accounts, and each node must store all UTXO transactions, the data scale is huge, and the storage consumption of each blockchain node is huge. This application aims to solve the problems of low storage efficiency and large data storage volume of the existing blockchain system, and proposes a new blockchain storage architecture method based on TXTree and ClientTree. The transaction information storage method provided by this application can effectively improve the storage efficiency and consensus efficiency of the blockchain system.
[0111] Figure 5 A schematic diagram of the structure of a transaction information storage device provided in another embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0112] Reference Figure 5 , the device is applied to a blockchain system, and the transaction information storage device may include:
[0113] A selection module 501 is used to select n nodes from the blockchain system and determine them as storage nodes, where n is a positive integer greater than or equal to 1;
[0114] The acquisition module 502 is used to acquire transaction information corresponding to the asset transaction when an asset transaction occurs in the blockchain system, and the transaction information includes the transaction initiator and the transaction recipient;
[0115] The first storage module 503 is used to store the transaction information in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver respectively;
[0116] The second storage module 504 is used to store the transaction information corresponding to all asset transactions occurring within the preset time in the storage node at every preset time.
[0117] In one embodiment, the transaction information also includes the transaction time and the transaction amount; the first storage module 503 may include:
[0118] A first conversion submodule is used to convert the transaction information into a first hash binary tree, wherein the first hash binary tree includes a first fork and a second fork, the first fork is used to record the transaction hash value of the transaction information, and the second fork is used to record the transaction details corresponding to the asset transaction, and the transaction details include the identity of the transaction initiator, the identity of the transaction recipient, and the transaction information;
[0119] The first storage submodule is used to store the first hash binary tree in the initiating node and the target node respectively.
[0120] In one embodiment, the second storage module 504 may include:
[0121] A calculation submodule, configured to perform a hash operation on first transaction information corresponding to all asset transactions occurring in the blockchain system within each preset time period based on a preset hash function, to obtain a first hash value corresponding to each first transaction information;
[0122] A first construction submodule is used to construct a second hash binary tree based on the first hash value corresponding to each first transaction information, the second hash binary tree includes leaf nodes and root nodes, one leaf node corresponds to one first hash value, the root node includes a root node hash value, and the root node hash value is obtained based on the combination of the first hash values corresponding to each leaf node;
[0123] The second storage submodule is used to store the second hash binary tree generated in each preset time period in the storage node.
[0124] In one embodiment, the transaction information storage device may further include:
[0125] The second acquisition module is used to obtain the real-time account balances of all accounts in the blockchain system at each moment in the preset time period for each preset time period;
[0126] The third acquisition module is used to obtain the current account balances of all accounts in the blockchain system corresponding to the last moment in a preset time period;
[0127] A first creation module is used to create a record block in a storage node, wherein one record block is created in a preset time period;
[0128] The third storage module is used to store the real-time account balance, the current account balance, and the second hash binary tree in the record block, and one record block corresponds to one hash binary tree.
[0129] In one embodiment, the first creation module may include:
[0130] A first acquisition submodule is used to acquire the transaction size of all asset transactions occurring in the blockchain system within a preset time period, the number of all asset transactions occurring in the blockchain system within the preset time period, the second hash binary tree generated within the preset time period, and the version number of the blockchain system;
[0131] The first combination module is used to combine, based on a preset combination rule, the transaction size of all asset transactions that occurred in the blockchain system within a preset time period, the number of all asset transactions that occurred in the blockchain system within the preset time period, the second hash binary tree generated in the preset time period, and the version number of the blockchain system to obtain a block identifier of the record block.
[0132] In one embodiment, the transaction information storage device may further include:
[0133] A generation module is used to generate a transaction message corresponding to each asset transaction in the blockchain system based on the record block and the first hash binary tree, wherein the transaction message includes the transaction size, the version number of the blockchain system, the root node hash value, the block creation time of the record block, the transaction initiator and the transaction receiver.
[0134] In one embodiment, the transaction information storage device may further include:
[0135] A comparison module is used to compare the data consistency between the first real-time account balance, the first current account balance, and the target second hash binary tree stored in any first node of the n storage nodes to obtain a first result, wherein the first result is used to indicate whether the first real-time account balance, the first current account balance, and the target second hash binary tree are consistent;
[0136] A verification module, used to verify the consistency between the first hash binary tree stored in the initiating node and the first hash binary tree stored in the target node when the first result indicates that the first real-time account balance, the first current account balance, and the target second hash binary tree are consistent, and obtain a second result, the second result is used to indicate whether the first hash binary tree stored in the initiating node is consistent with the first hash binary tree stored in the target node;
[0137] A determination module is used to determine that the blockchain system is valid when the second result indicates that the first hash binary tree stored in the initiating node is consistent with the first hash binary tree stored in the target node.
[0138] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application, and are devices corresponding to the above-mentioned battery thermal runaway warning method. All implementation methods in the above-mentioned method embodiment are applicable to the embodiments of the device. Its specific functions and technical effects can be found in the method embodiment part, which will not be repeated here.
[0139] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0140] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.
[0141] The device may include a processor 601 and a memory 602 storing program instructions.
[0142] When the processor 601 executes the program, the steps in any of the above method embodiments are implemented.
[0143] Exemplarily, the program may be divided into one or more modules / units, one or more modules / units are stored in the memory 602 and executed by the processor 601 to complete the present application. One or more modules / units may be a series of program instruction segments capable of completing a specific function, and the instruction segments are used to describe the execution process of the program in the device.
[0144] Specifically, the processor 601 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0145] The memory 602 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 602 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 602 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 602 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 602 is a non-volatile solid-state memory.
[0146] The memory may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical or other physical / tangible memory storage devices. Thus, typically, the memory includes one or more tangible (non-transitory) readable storage media (e.g., memory devices) encoded with software including computer executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0147] The processor 601 implements any one of the methods in the above embodiments by reading and executing program instructions stored in the memory 602 .
[0148] In one example, the electronic device may further include a communication interface 603 and a bus 610. The processor 601, the memory 602, and the communication interface 603 are connected via the bus 610 and communicate with each other.
[0149] The communication interface 603 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0150] Bus 610 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-end bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 610 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.
[0151] In addition, in combination with the method in the above embodiment, the embodiment of the present application can provide a storage medium for implementation. The storage medium stores program instructions; when the program instructions are executed by a processor, any one of the methods in the above embodiment is implemented.
[0152] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0153] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0154] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0155] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0156] The functional modules shown in the above block diagram can be implemented as hardware, software, firmware or their combination. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), suitable firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. Programs or code segments can be stored in machine-readable media, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable media" can include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. Code segments can be downloaded via computer grids such as the Internet, intranets, etc.
[0157] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0158] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0159] The above are only specific implementation methods of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A transaction information storage method, It is characterized in that Applied to a blockchain system, the method includes: Select n nodes from the blockchain system and determine them as storage nodes, where n is a positive integer greater than or equal to 1; In the case where an asset transaction occurs in the blockchain system, obtaining transaction information corresponding to the asset transaction, wherein the transaction information includes a transaction initiator and a transaction recipient; The transaction information is stored in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver respectively; At every preset time, the transaction information corresponding to all asset transactions occurring within the preset time is stored in the storage node.
2. The method according to claim 1, It is characterized in that The transaction information also includes transaction time and transaction amount; The storing the transaction information in the initiating node corresponding to the transaction initiator and the target node corresponding to the transaction receiver respectively includes: Convert the transaction information into a first hash binary tree, wherein the first hash binary tree includes a first fork and a second fork, the first fork is used to record the transaction hash value of the transaction information, and the second fork is used to record the transaction details corresponding to the asset transaction, the transaction details include the identity of the transaction initiator, the identity of the transaction recipient and the transaction information; The first hash binary tree is stored in the initiating node and the target node respectively.
3. The method according to claim 2, It is characterized in that The storing, at every preset time interval, transaction information corresponding to all asset transactions occurring within the preset time in the storage node includes: For each preset time period, based on a preset hash function, a hash operation is performed on the first transaction information corresponding to all asset transactions occurring in the blockchain system within the preset time period to obtain a first hash value corresponding to each first transaction information; Based on the first hash value corresponding to each of the first transaction information, construct a second hash binary tree, wherein the second hash binary tree includes leaf nodes and a root node, wherein one leaf node corresponds to one first hash value, and the root node includes a root node hash value, and the root node hash value is obtained by combining the first hash values corresponding to each leaf node; The second hash binary tree generated within each of the preset time periods is stored in the storage node.
4. The method according to claim 3, It is characterized in that After storing the second hash binary tree generated in each of the preset time periods in the storage node, the method further includes: For each preset time period, obtain the real-time account balances of all accounts in the blockchain system at each moment in the preset time period; Obtain the current account balances of all accounts in the blockchain system corresponding to the last moment in the preset time period; Creating a record block in the storage node, wherein one record block is created in a preset time period; The real-time account balance, the current account balance, and the second hash binary tree are stored in the record block, and one record block corresponds to one hash binary tree.
5. The method according to claim 4, It is characterized in that The step of creating a record block in the storage node includes: Obtaining the transaction size of all asset transactions occurring in the blockchain system within a preset time period, the number of all asset transactions occurring in the blockchain system within the preset time period, the second hash binary tree generated in the preset time period, and the version number of the blockchain system; Based on a preset combination rule, the transaction size of all asset transactions occurring in the blockchain system within a preset time period, the number of all asset transactions occurring in the blockchain system within the preset time period, the second hash binary tree generated in the preset time period, and the version number of the blockchain system are combined to obtain the block identifier of the record block.
6. The method according to claim 4, It is characterized in that After storing the real-time account balance, the current account balance, and the second hash binary tree in the record block, the method further includes: Based on the record block and the first hash binary tree, a transaction message corresponding to each asset transaction in the blockchain system is generated, wherein the transaction message includes the transaction size, the version number of the blockchain system, the root node hash value, the block creation time of the record block, the transaction initiator and the transaction receiver.
7. The method according to claim 4, It is characterized in that After storing the real-time account balance, the current account balance, and the second hash binary tree in the record block, the method further includes: For any first node among the n storage nodes, compare the data consistency between the first real-time account balance, the first current account balance, and the target second hash binary tree stored in the first node to obtain a first result, where the first result is used to indicate whether the first real-time account balance, the first current account balance, and the target second hash binary tree are consistent; In a case where the first result indicates that the first real-time account balance, the first current account balance, and the target second hash binary tree are consistent, verifying the consistency between the first hash binary tree stored in the initiating node and the first hash binary tree stored in the target node to obtain a second result, wherein the second result is used to indicate whether the first hash binary tree stored in the initiating node is consistent with the first hash binary tree stored in the target node; When the second result indicates that the first hash binary tree stored in the initiating node is consistent with the first hash binary tree stored in the target node, it is determined that the blockchain system is valid.
8. A transaction information storage device, It is characterized in that Applied to a blockchain system, the device comprises: A selection module, used to select n nodes from the blockchain system and determine them as storage nodes, where n is a positive integer greater than or equal to 1; An acquisition module, used to acquire transaction information corresponding to an asset transaction when an asset transaction occurs in the blockchain system, wherein the transaction information includes a transaction initiator and a transaction recipient; A first storage module, used to store the transaction information in an initiating node corresponding to the transaction initiator and a target node corresponding to the transaction receiver respectively; The second storage module is used to store the transaction information corresponding to all asset transactions occurring within the preset time in the storage node at every preset time.
9. An electronic device, It is characterized in that The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the transaction information storage method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the transaction information storage method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Aggregate storage method of transaction data, electronic equipment and computer readable medium
CN121599768A
