A three-level read-write extended blockchain storage method for distributed ledger data

Through the three-level read and write expansion blockchain storage method, the memory, KV database and file database are used to separately store blockchain data, which solves the problems of large blockchain storage space requirements and poor scalability, and achieves efficient data management and scalability. , maintaining data consistency and security.

CN118296083BActive Publication Date: 2024-08-23HEFEI INSTITUTE OF PHYSICAL SCIENCE CHINESE ACADEMY OF SCIENCES +2
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410708644.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-03
Publication Date
2024-08-23
Estimated Expiration
2044-06-03

AI Technical Summary

Technical Problem

Blockchain has large storage space requirements and poor scalability, which leads to high node operating costs, reduced decentralization, security threats, and performance degradation.

Method used

Adopting a three-level read and write extended blockchain storage method, by separating the latest data from non-latest data, cold data from non-cold data, and data reading and writing, memory, KV database and file database are used to store blockchain data respectively. , achieving fast reading and writing of data and scalability.

Benefits of technology

It reduces node storage space consumption, improves data reading and writing efficiency and query complexity, maintains data consistency and security, does not introduce additional load and network overhead, and significantly reduces disk storage overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118296083B
    Figure CN118296083B
Patent Text Reader

Abstract

The present invention discloses a three-level read-write extended blockchain storage method for distributed ledger data. The blockchain ledger data is read and written at three levels by establishing a blockchain storage scalable model. The blockchain storage scalable model includes three dimensions: separation of the latest data from the non-latest data, separation of cold data from the non-cold data, and separation of data reading and writing. The memory and KV database are used to store less latest data and popular ledger data to achieve fast reading and writing of primary data; non-latest data is stored in a relational database, and SQL is used to query associated data to achieve reading and writing of secondary data; cold data is transferred to a local file database for storage, and the storage location of the block is queried through an index file to achieve reading and writing of three-level data. The present invention adopts a suitable storage method for different types of ledger data to improve data reading and writing performance and scalability when data continues to grow.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed ledger storage and blockchain technology, and in particular to a distributed ledger data three-level read-write extended blockchain storage method. Background Art

[0002] Blockchain storage includes the following two aspects:

[0003] (1) Blockchain storage expansion

[0004] Blockchain ledger data is stored in a distributed manner, and generally each full node stores a complete data backup. Therefore, blockchain has the advantages of openness, transparency, high security, and high data availability, but it also brings some new challenges: 1) The operating cost of blockchain nodes increases. Nodes require larger disk space and higher I / O performance. When new nodes join the blockchain, they need to download a large amount of ledger data; 2) The degree of decentralization of the blockchain system decreases. Nodes with limited storage space cannot join the blockchain network, resulting in a reduction in the number of full nodes storing all ledgers in the network; 3) The security of the blockchain is threatened. The reduction in full nodes in the blockchain network will further make the blockchain more vulnerable to attacks; 4) The performance of the blockchain is reduced. Blockchain nodes store a large amount of ledger data, and the reading and writing speed of blockchain ledger data will be reduced, further affecting the increase in the confirmation delay time of blocks and transactions. Therefore, the study of blockchain storage scalability is very important and necessary.

[0005] In order to solve the problem of blockchain storage scalability, many innovative solutions have been proposed. Depending on whether the node stores the full ledger data, the solutions can be divided into two categories: 1) Data storage compression solutions. That is, using data compression algorithms to compress local ledger data, or using databases with better data compression effects to store ledger data. These solutions introduce additional computing loads and increase blockchain latency. 2) More storage expansion solutions use blockchain nodes to store partial ledger data. Nodes obtain ledger data that is not stored locally on the node through the blockchain network. These solutions undermine the integrity of the ledger, increase network overhead, reduce data reading speed, and reduce the security and decentralization of the blockchain.

[0006] (2) Blockchain storage method

[0007] The data layer is one of the important layers in the blockchain architecture. Different blockchain systems use different data storage solutions. Early blockchains (before 2016) generally used KV (key-value) databases, which did not support relational queries. With the needs of blockchain applications and scalability, more and more blockchain systems use relational databases to support relational queries.

[0008] KV database is a NoSQL model, in which data is organized, indexed and stored in the form of key-value pairs, and is often used to store large amounts of unstructured or semi-structured data. It has high scalability, non-fixed data structure and high performance, but does not provide SQL query and does not support complex data query.

[0009] Relational databases are widely used in relational data management systems (RDBMS). They use SQL to manage and maintain data and have the characteristics of structured data models, powerful SQL query capabilities, and strong scalability. However, they have poor flexibility, especially when the data structure changes dynamically.

[0010] In addition, both blockchain and Hyperledger use file databases to store rarely used historical data. File databases allow for custom data structures to be stored and generally take up less disk space.

[0011] Therefore, there is an urgent need to provide a new distributed ledger data blockchain storage method to solve the above problems. Summary of the invention

[0012] The technical problem to be solved by the present invention is to provide a three-level read-write extended blockchain storage method for distributed ledger data, which can solve the problem of continuous expansion of blockchain ledger data and large requirements for blockchain full-node storage space; at the same time, for different types of ledger data, a suitable storage method is adopted to improve data read and write performance and scalability when data continues to grow.

[0013] In order to solve the above technical problems, the first technical solution adopted by the present invention is: to provide a distributed ledger data three-level read and write extended blockchain storage method, by establishing a blockchain storage scalable model to perform three-level reading and writing on the blockchain ledger data, the blockchain storage scalable model includes the separation of the latest data and the non-latest data, the separation of cold data and non-cold data, and the separation of data reading and writing in three dimensions:

[0014] (1) Separation of the latest data from the non-latest data: The m latest block data generated on the blockchain are the latest data, and the block data before the m latest blocks are non-latest data. Memory and KV database are used to store less latest data and popular ledger data, realizing fast reading and writing of primary data;

[0015] (2) Separation of cold data and non-cold data: As new data blocks are continuously generated, the latest data becomes non-latest data. Non-latest data is stored in a relational database, and related data queries are performed through SQL to achieve reading and writing of secondary data. Data that is not read or rarely read is cold data. Cold data is transferred to the local file database for storage. The storage location of the block is queried through the index file to achieve reading and writing of tertiary data.

[0016] (3) Data reading and writing separation: Data writing is mainly completed in the KV database, and data reading is achieved through three-level reading from memory, relational database and file database.

[0017] In a preferred embodiment of the present invention, the first level of data writing is to cache the latest data and hot ledger data into the memory to achieve fast data reading, and to persistently store the latest data and hot ledger data into the KV database to achieve fast data writing.

[0018] In a preferred embodiment of the present invention, when the number of the latest blocks in the first level reaches a set upper limit, they will be transferred to the second level and become non-cold data. This process is performed once when the number of blocks that need to be circulated reaches a certain threshold.

[0019] In a preferred embodiment of the present invention, hot ledger data that is rarely read in the first-level read-write will be converted into non-cold data in the second-level read-write, and non-cold data that is frequently read in the second-level read-write will be converted into hot ledger data in the first-level read-write.

[0020] In a preferred embodiment of the present invention, frequently read second-level non-cold data will be converted to third-level read-write cold data, and frequently read third-level cold data will be converted to second-level read-write non-cold data.

[0021] In a preferred embodiment of the present invention, in a relational database, transaction details and transaction receipts are stored in the same data table, in which the block body is queried based on the block hash or height, and the transaction details and receipt are queried based on the transaction hash.

[0022] In a preferred embodiment of the present invention, when the number of non-latest blocks reaches a set value, the third-level data writing process is automatically executed once.

[0023] In order to solve the above technical problems, the second technical solution adopted by the present invention is: to provide an electronic device, comprising at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any one of the above-mentioned three-level read-write extended blockchain storage methods for distributed ledger data.

[0024] In order to solve the above technical problems, the third technical solution adopted by the present invention is: providing a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the three-level read-write extended blockchain storage method for distributed ledger data according to any one of the above items.

[0025] In order to solve the above technical problems, the fourth technical solution adopted by the present invention is: to provide a computer program product, including a computer program; when the computer program is executed by a processor, the distributed ledger data three-level read-write extended blockchain storage method described in any one of the above items is implemented.

[0026] The beneficial effects of the present invention are:

[0027] (1) The present invention proposes a blockchain storage scalable model, which is designed from different dimensions of separation of latest / non-latest data, separation of cold / non-cold data, and separation of data reading and writing, so as to improve the scalability of blockchain ledger data storage;

[0028] (2) The three-level read-write blockchain data storage system framework improves the efficiency of blockchain data management. This method uses memory and KV database to store less latest and popular ledger data to achieve fast reading and writing of primary data. In the second level, more non-latest ledger data is stored in a relational database that supports complex related data queries through SQL. The third level uses a file database to store most of the ledger data to reduce storage space consumption;

[0029] (3) The present invention reduces the storage space consumption of nodes, improves the efficiency of data reading, and realizes the query of complex relational data without introducing too much additional load. The consistency, security, decentralization and writing speed of the data will not be affected. All data transmission processes are carried out on the node client, and there is no need to transmit data through the network. Therefore, this method does not bring additional network overhead. In addition, the three-level storage solution significantly reduces the disk storage overhead. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 It is a schematic diagram of the structure of the blockchain storage scalable model;

[0031] Figure 2 It is a schematic diagram of the three-level reading and writing process of the blockchain;

[0032] Figure 3 It is a schematic diagram of the flow of the blockchain data. DETAILED DESCRIPTION

[0033] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present invention.

[0034] See also Figure 1 and Figure 2 , the embodiment of the present invention includes:

[0035] A distributed ledger data three-level read-write extended blockchain storage method, which performs three-level read and write on the blockchain ledger data by establishing a blockchain storage scalable model. The blockchain storage scalable model includes three dimensions: separation of the latest data from the non-latest data, separation of cold data from non-cold data, and separation of data reading and writing:

[0036] (1) Separation of the latest data from the non-latest data: The m latest block data generated on the blockchain are the latest data, and the block data before the m latest blocks are classified as non-latest data. The latest data needs to be written to the database quickly and read frequently. Therefore, the memory is used to cache the latest data, and the KV database is used to persist the latest data;

[0037] (2) Separation of cold data and non-cold data: As new data blocks are continuously generated, the latest data becomes non-latest data. Non-latest data is stored in the relational database to meet the needs of data reading; data that is not read or rarely read is cold data. In order to further reduce data storage space, cold data is transferred to the local file database for storage. In contrast, data that is frequently read is called hot data. This data will also be loaded into the memory to improve reading efficiency and stored persistently in the KV database. In addition to cold data and hot data, all data is non-cold data;

[0038] (3) Data read and write separation: Data writing is mainly completed in the KV database because its writing efficiency is relatively high. Data reading is achieved through three-level reading from memory, relational database and file database.

[0039] like Figure 1 As shown, data block B n-1 and B n The latest data will be quickly written into the memory and KV database. The non-latest data in blocks B0, B1, and B2 are transferred to the relational database for efficient reading. Some cold data that is rarely read is transferred to the file database to reduce the storage space consumption of the node. n-1 and B n Just an example.

[0040] This method uses memory and KV database to store less latest and popular ledger data to achieve fast reading and writing of primary data. In the second-level data reading and writing, more non-latest ledger data is stored in a relational database, which supports complex related data queries through SQL. The third-level data reading and writing uses a file database to store most of the ledger data to reduce storage space consumption. The third-level data reading speed is the slowest. It is read from the file database through data indexes, but this data is rarely read.

[0041] Combination Figure 2 ,Data writing involves three levels of processes: The first level of data writing is the process of caching data into memory for fast data reading, and persistently storing data into the KV database for fast data writing (step ①, including 1.1 and 1.2). The latest data and hot data are synchronized in real time in the memory and KV database (steps ④ and ⑤). The non-latest data is transferred to the relational database for complex data association queries, which is completed in the second level of data writing (step ②). To reduce data storage space, the third level of data writing transfers cold data to the file database (step ③).

[0042] Similarly, data reading (step ⑥) also includes three levels: reading the latest hot data from the memory is the fastest, which is the first-level data reading (step 6.1). Secondary data reading is reading data from the relational database, so complex data association queries can be performed (step 6.2). Cold data that is rarely queried is obtained from the file database, which is implemented in the third-level data reading (step 6.3).

[0043] Specifically, the first-level data reading and writing: The objects of the first-level reading and writing are the latest data and hot data, which are stored in the memory and KV database. The first-level reading can quickly retrieve the data in the memory. The latest data refers to the data of the most recent m blocks, and the hot data also refers to the x blocks of data most frequently used by the current node client. The number and size of these data are fixed, so the storage space occupied is not large and is certain. In order to achieve fast reading and writing of data, data in memory is written and read first. When new block data is written to the node memory, it will be persisted to the KV database at the same time. When the node is restarted, the latest data and hot data will be read from the KV database and loaded into the memory. In other words, the latest data and hot data in the memory are consistent with the data in the KV database.

[0044] Second-level data reading and writing: As the latest blocks are continuously generated, the previous non-latest block data will be transferred to the secondary storage and stored in the relational database. In the relational database, transaction details and transaction receipts are stored in the same data table, which helps to reduce the duplication of some field data, such as transaction hash, block hash and other basic transaction information. On the other hand, from the data table, you can query the block body based on the block hash or height, or query the transaction details and receipts based on the transaction hash, meeting the user's needs for complex association queries between transactions and blocks.

[0045] Level 3 data reading and writing: In order to further reduce the storage space of blockchain data, level 3 data writing will transfer some rarely used cold data to the local file database. Necessary index files are used to improve the efficiency of data query. When the number of non-latest blocks reaches the set value, the level 3 data writing process will be automatically executed once. Among the data blocks with a long reading time, the set proportion of data (the proportion of this part of data is set in the blockchain configuration item) will be retained in the relational database, and the other data will be written to the file database in the order of data block height. The index file records the storage location of each block in the file database, which is convenient for users to quickly locate the storage location and obtain the required block data.

[0046] Generally speaking, the data of a blockchain is fixed after being stored. However, in this method, data needs to be transferred between the first, second, and third levels, which brings additional overhead to the blockchain system. The data flow is shown in Figure 3. There are several cases of data flow: (1) When the number of the latest blocks in the first level reaches the set upper limit, it will be transferred to the second level and become non-cold data. In order to reduce the frequency of this process, it is only executed once when the number of blocks that need to be transferred reaches a certain threshold. (2) Hot data that is rarely read in the first level will be converted to non-cold data in the second level, and non-cold data that is frequently read in the second level will be converted to hot data in the first level. These two processes are performed together regularly. (3) Non-cold data in the second level that is frequently read will be converted to cold data in the third level, and cold data in the third level that is frequently read will be converted to non-cold data in the second level. These two processes are also performed together frequently. Therefore, data transmission is not a high-frequency event and will bring some additional I / O overhead to the node client, but it is not significant.

[0047] All data transmission processes are carried out on the node client, and no data needs to be transmitted over the network. Therefore, this method does not bring additional network overhead. In addition, the three-level storage solution significantly reduces disk storage overhead.

[0048] The present invention proposes a blockchain storage scalable model, which is designed from different dimensions of latest / non-latest data separation, cold / non-cold data separation, and data read-write separation to improve the scalability of blockchain ledger data storage. The three-level read-write blockchain data storage system framework also improves the efficiency of blockchain data management.

[0049] An embodiment of the present invention also provides an electronic device, comprising at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned distributed ledger data three-level read-write extended blockchain storage method.

[0050] An embodiment of the present invention also provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the three-level read-write extended blockchain storage method for distributed ledger data as described above.

[0051] An embodiment of the present invention also provides a computer program product, including a computer program; when the computer program is executed by a processor, the above-mentioned distributed ledger data three-level read-write extended blockchain storage method is implemented.

[0052] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0053] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 generate 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.

[0054] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0055] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0056] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A distributed ledger data three-level read-write extended blockchain storage method, characterized in that: By establishing a scalable blockchain storage model, blockchain ledger data is read and written at three levels. The scalable blockchain storage model includes three dimensions: separation of the latest data from the latest data, separation of cold data from the non-cold data, and separation of data reading and writing: (1) Separation of the latest data from the non-latest data: The m latest block data generated on the blockchain are the latest data, and the block data before the m latest blocks are non-latest data. Memory and KV database are used to store less latest data and popular ledger data, realizing fast reading and writing of primary data; (2) Separation of cold data and non-cold data: As new data blocks are continuously generated, the latest data becomes non-latest data. Non-latest data is stored in a relational database, and related data queries are performed through SQL to achieve reading and writing of secondary data. Data that is not read or rarely read is cold data. Cold data is transferred to the local file database for storage. The storage location of the block is queried through the index file to achieve reading and writing of tertiary data. (3) Data read and write separation: Data writing is completed in the KV database and memory, and data reading is achieved through three-level reading from memory, relational database and file database.

2. The distributed ledger data three-level read-write extended blockchain storage method according to claim 1 is characterized in that: The first level of data writing is to cache the latest data and popular ledger data into memory for fast data reading, and to persist the latest data and popular ledger data into the KV database for fast data writing.

3. The distributed ledger data three-level read-write extended blockchain storage method according to claim 1 is characterized in that: When the number of the latest blocks on the first level reaches the set upper limit, they will be transferred to the second level and become non-cold data. This process is performed once when the number of blocks that need to be circulated reaches a certain threshold.

4. The distributed ledger data three-level read-write extended blockchain storage method according to claim 1 is characterized in that: Hot ledger data that is rarely read in the first-level read and write will be converted to non-cold data in the second-level read and write, while non-cold data that is frequently read in the second-level read and write will be converted to hot ledger data in the first-level read and write.

5. The distributed ledger data three-level read-write extended blockchain storage method according to claim 1 is characterized in that: The second-level non-cold data that is rarely read will be converted to the third-level cold data that is read and written, and the third-level cold data that is frequently read will be converted to the second-level non-cold data that is read and written.

6. The distributed ledger data three-level read-write extended blockchain storage method according to claim 1, characterized in that: In a relational database, transaction details and transaction receipts are stored in the same data table. In this data table, the block body is queried based on the block hash or height, and the transaction details and receipts are queried based on the transaction hash.

7. The distributed ledger data three-level read-write extended blockchain storage method according to claim 1 is characterized in that: When the number of non-latest blocks reaches the set value, the third-level data writing process is automatically executed once.

8. An electronic device, characterized in that: It includes at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the three-level read-write extended blockchain storage method for distributed ledger data according to any one of claims 1 to 7.

9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: in, The computer instructions are used to enable the computer to execute the distributed ledger data three-level read-write extended blockchain storage method according to any one of claims 1-7.

10. A computer program product, comprising a computer program; characterized in that When the computer program is executed by a processor, the computer program implements the distributed ledger data three-level read-write extended blockchain storage method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Multilevel storage method and apparatus for block chain data

    CN109144414A

  • Block chain node data separate storage method and device

    CN111858520A

  • Efficient data query implementation method based on block chain electronic transaction

    CN112487027A

  • Block chain-based transaction database construction method and system, and electronic equipment

    CN112860712A

  • Stepped data storage method and system capable of reducing block chain storage overhead

    CN112988073A