CN116610670A - State data storage method and device based on block chain - Google Patents
State data storage method and device based on block chain Download PDFInfo
- Publication number
- CN116610670A CN116610670A CN202310467504.3A CN202310467504A CN116610670A CN 116610670 A CN116610670 A CN 116610670A CN 202310467504 A CN202310467504 A CN 202310467504A CN 116610670 A CN116610670 A CN 116610670A
- Authority
- CN
- China
- Prior art keywords
- data
- state
- tree
- state data
- merkle
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 39
- 238000013500 data storage Methods 0.000 title claims abstract description 30
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 claims abstract description 20
- 239000012634 fragment Substances 0.000 claims abstract description 19
- 238000004364 calculation method Methods 0.000 claims description 14
- 238000012795 verification Methods 0.000 claims description 12
- 230000008569 process Effects 0.000 claims description 10
- 238000012545 processing Methods 0.000 claims description 8
- 230000002688 persistence Effects 0.000 claims description 7
- 230000009466 transformation Effects 0.000 claims description 7
- 238000013507 mapping Methods 0.000 claims description 6
- 238000013508 migration Methods 0.000 claims description 4
- 230000005012 migration Effects 0.000 claims description 4
- 238000003780 insertion Methods 0.000 claims description 3
- 230000037431 insertion Effects 0.000 claims description 3
- 230000002085 persistent effect Effects 0.000 claims description 3
- 230000007704 transition Effects 0.000 claims description 3
- 238000005457 optimization Methods 0.000 abstract description 2
- 238000004140 cleaning Methods 0.000 abstract 1
- 230000015556 catabolic process Effects 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000006731 degradation reaction Methods 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013524 data verification Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000006698 induction Effects 0.000 description 1
- 238000013138 pruning Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2246—Trees, e.g. B+trees
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/219—Managing data history or versioning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2308—Concurrency control
- G06F16/2315—Optimistic concurrency control
- G06F16/2329—Optimistic concurrency control using versioning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application discloses a state data storage method and equipment based on a block chain, wherein a water line and version number matching mode is introduced in the method, and concurrent state data requests are processed; cleaning old state data every N versions, and maintaining the size of the state tree within a reasonable size; recording a Merkle balance tree and a state Merkle tree of the world state in a memory through a layered Merkle balance tree, and permanently updating data into a disk in an asynchronous mode; the device comprises: a host server and a fragment server; the host server is used for recording the Merkle balance tree of the total world state and recording the index account state information; at least one of the slicing servers is used for recording data information. The application combines the comprehensive advantages of the block chain and the data storage, improves the storage speed of the state data and the verifiability of the data through the hierarchical optimization of the water line, the version number and the Merkle tree, and provides longer stable state data storage for the block chain system.
Description
Technical Field
The present application relates to the field of blockchain and data storage, and in particular, to a blockchain-based state data storage method and apparatus.
Background
Each chunk on the blockchain records some transaction data, a timestamp, and a hash value of its previous chunk. The blockchain may be considered a public ledger that records transaction data. The data on the blockchain may be divided into block data and state data. The block data records each transaction occurring on the blockchain; the status data is generated by executing transactions in the block that records the current status of each account or smart contract on the blockchain, such as account, account asset, business contract data, etc.
However, the ever-increasing state data on blockchain, and the manner in which the data is stored redundantly, causes blockchain systems to gradually degrade in performance during operation. This places increasing demands on the storage capacity and performance of the individual ledger databases, increasing the threshold and cost of blockchain system operation.
The current common data processing mode is to delete historical data or to save data as little as possible to alleviate the problem of performance degradation of data storage. But this has an impact on the verifiability of the state data.
Disclosure of Invention
Aiming at the problem of performance degradation of a blockchain system in the running process caused by the increase of state data, the application provides a blockchain-based state data storage method and equipment, which are realized by the following technical scheme:
a state data storage method based on a block chain specifically comprises the following steps:
step one: writing the data of the current block into a pre-write log, judging whether the data processing of the current block can be performed or not in a mode of combining a water line and version numbers, wherein the water line is the minimum value of the version numbers corresponding to the incomplete and durable state data, and performing the next step if the version number of the current state data is smaller than the version numbers of N versions after the water line; otherwise, the state data after waiting for the water line and before the version number N versions of the current state data is blocked to finish persistence;
step two: updating the version state number, namely adding one to the version number of the current state data, checking the state data before N versions, releasing the space occupied by the outdated state data, and marking the space as an idle page for inserting the subsequent data;
step three: inserting the state data into the Merkle tree, judging whether the size of a state data node reaches a data page threshold value, if so, updating the cache data of the Merkle tree after splitting the data page, and if not, directly updating the cache data of the Merkle tree;
in the third step, a world Merkle balance tree is maintained in a memory and is used for recording the whole world state of the current blockchain; the world Merkle balance tree provides a mapping of the total world state and the state Merkle tree of each account space; the state Merkle tree of each account space records different information in a layered manner, only leaf nodes truly record disk position mapping of data storage, other nodes do not store real data conditions, and only index paths to the leaf nodes;
step four: the updated Merkle tree is subjected to persistent updating of data to a disk in an asynchronous mode;
step five: in the process of persistence, according to the updated cache data of the Merkle tree, updating the state data of the next version number, namely repeating the steps one to four until all data request processing of the current system is completed by N versions higher than the water line;
in the fourth step, the actual state data is stored on the disk in a distributed manner through a consistent hash calculation mode; if the disk space of the current node is fully written, dynamic expansion is supported, and migration reconstruction of the Merkle tree is not involved.
Further, in the third step, the state data are inserted into the Merkle tree in batch, the insertion is the concurrent operation of writing by taking the node update path as a unit, and when all the state data are inserted into the Merkle tree, the Merkle tree performs tree transformation to reach the balanced state again, and the hash value of the root node is calculated.
Further, the version of the state data can support rapid state transition through skip list recording; supporting state data rollback within a prescribed version; the number of the versions is configured according to the data requirements when the user actually uses, and the specific calculation formula of the number of the stored versions is as follows:
version number n= (number of server nodes x size of storage space available for each server)/(number of accounts x)
Status data size) -1.
Further, for the data stored in the blockchain-based state data storage method, verification is performed by the following method:
(1) Receiving a verification request, wherein the verification request comprises a Key value, and verifying a parameter of the request;
(2) Finding the name of the sub tree in the world Merkle balance tree according to the Key value in the total world state, namely obtaining the name of the account in which the current Key is located;
(3) Establishing an access iterator of the Merkle tree corresponding to the state data according to the Key value;
(4) Comparing the Key value with the page number by using the access iterator, and performing hierarchical traversal according to the Key until the access to the leaf node is finished;
(5) Finding out the disk position corresponding to the data in the record information of the leaf node, namely, page reference, and reading the data corresponding to the Key;
(6) Performing hash calculation on the data obtained in the step (5), and constructing a structure body for returning the proving value;
(7) According to the leaf node in the step (5), tracing upwards, finding out brother nodes and father nodes, calculating state path process hash until tracing back to the index node;
(8) And returning the final hash values of all paths as proof.
Further, the information stored in the leaf nodes of the Merkle tree storing the total world state is the value of the Merkle tree of the account state corresponding to the current Key value; the information stored by the leaf nodes of the Merkle tree of the account state is the position where the current Key is actually stored on the disk; because the bottom layer structure of the Merkle tree is a B+ tree, all data information is stored in a disk in the form of files, one file corresponds to one leaf node, and the size of the leaf node is set according to actual use; the leaf nodes of the Merkle tree recording the account state only store the position index information pointing to the disk and do not store data; one file stores data information of a plurality of Key values, and when the data file corresponding to the Key values is found, the actual data is found according to the offset of the file.
Further, the total world state and the account state are stored separately, and the storage of the state data is completed by using a plurality of Merkle trees.
An apparatus, the apparatus comprising: a host server and a fragment server; the host server is used for recording the Merkle tree of the total world state and recording index information; at least one of the slicing servers is used for recording data information; the host server maintains the routing state information of all the fragment servers, and each fragment server is responsible for storing a certain range of data after hash calculation; the slicing server can be automatically expanded, and each write request can be relatively independently processed; and if the current fragment server storage reaches the extremum, applying for a new fragment server to perform space expansion.
Further, the host server maintains its own context to manage all Merkle tree leaf nodes that need to be updated; the updated node recalculates the hash value, and backtracking splitting is performed concurrently when the message is verified, so that the transformation speed of the tree structure is improved.
Further, the device is not only used as an independent state database, but also used for replacing the fragment server with other key value type databases to record state data.
The beneficial effects of the application are as follows:
(1) The application combines the blockchain technology, balances between limited version control and performance requirements, combines the comprehensive advantages of the blockchain and the account database, and improves the storage speed of state data and the verifiability of the data by means of a water line and a version number.
(2) The application optimizes the structure of the Merkle tree, provides a concept of hierarchically balancing the Merkle tree, and improves the performance and the stability of the block chain system with low cost.
Drawings
FIG. 1 is a flow chart of a blockchain-based state data storage method.
FIG. 2 is a flow chart of a blockchain-based state data verification method.
Detailed Description
The objects and effects of the present application will become more apparent from the following detailed description of the preferred embodiments and the accompanying drawings, in which the present application is further described in detail. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
Aiming at the problem of performance degradation of a blockchain system in the running process caused by the increase of state data, the application provides a blockchain-based state data storage method which combines Merkle trees and optimizes the structure of the Merkle trees. Merkle tree is a hash binary tree widely used in blockchain systems, and the Merkle tree adds a node hash calculation process based on a B+ tree, can be used for carrying out induction and quick search on transaction data, and provides integrity check. In many researches in the industry, the Merkle tree is subjected to structural optimization, such as combination with a base tree, but reconstruction and migration work of the Merkle tree are required under the condition of large data volume, so that high-efficiency verifiability is affected. Since the blockchain is non-tamper-evident, state data that has been persisted to disk for history can be archived, supporting the storage of more data. The hierarchical Merkle balance tree can support the addition of a plurality of fragment servers, so that a single node also has expandability, and more state data on a high-efficiency storage chain are stored.
It should be noted that the state data storage method based on the blockchain provided by the application is only suitable for a scene that the state data is required to carry out transaction verification to provide verifiable data. If the data is not state data, the data storage mode can simply store key value pair type data and perform simple data insertion and modification operation.
As shown in fig. 1, the state data storage method based on the blockchain refers to version numbers, and cleans up old state data every N versions, and maintains the size of the hierarchical Merkle balance tree within a reasonable size; processing concurrent status data requests using a water line; recording a total world state tree and an index tree in a memory through a layered Merkle balance tree, and storing data into a disk in a distributed manner through hash calculation; the method specifically comprises the following steps:
step one: writing the current block data into a pre-write log, judging whether the data processing of the current block can be performed or not in a mode of combining a water line and version numbers, wherein the water line is the minimum value of the version numbers corresponding to the incomplete persistent state data, comparing the version numbers of the current state data with the version numbers of N versions after the water line, and performing the next step if the version numbers of the current state data are smaller than the version numbers of the N versions after the water line; otherwise, waiting for the state data after the water line and before the version number N versions of the current state data to complete persistence.
Step two: updating the version state number, namely adding one to the version number of the current state data, checking the state data before N versions, releasing the space occupied by the outdated state data, and marking the space as an idle page for inserting the subsequent data.
The state data can record the current version number of the state data, pruning of the state tree is carried out according to the version number, namely, the space of the outdated data is released. The version of the state data is recorded by the skip list, so that the rapid state transition can be supported. The application supports state data rollback in specified versions, and the number of the versions can be configured according to the data requirements when the user actually uses the application. The method is suitable for state storage of the number of the accounts of hundred million levels, and the specific calculation formula of the number of the recommended stored versions is as follows:
version number n= (number of server nodes x size of storage space available for each server)/(number of accounts x)
Status data size) -1.
Step three: and inserting the state data into the Merkle tree, judging whether the size of the state data node reaches a data page threshold value, if so, updating the cache data of the Merkle tree after splitting the data page, and if not, directly updating the cache data of the Merkle tree.
The method comprises the steps of inserting state data into a Merkle tree in batches, performing concurrent operation of writing by taking a node update path as a unit, performing tree transformation on the Merkle tree after all the state data are inserted into the Merkle tree, and calculating the hash value of a root node after the state data reach an equilibrium state again.
Maintaining a world Merkle balance tree in a memory, wherein the world Merkle balance tree is used for recording the whole world state of the current blockchain; the world Merkle balance tree provides a mapping of the total world state and the state Merkle tree of the respective account space (i.e., the Merkle tree into which the state data is inserted); the Merkle tree of the state of each account space is hierarchically recorded, and only the leaf nodes truly record the disk position mapping of the data storage, and other nodes do not store the real data condition, but only the index paths to the leaf nodes. The total world state and each account state are stored separately, and the storage of state data is completed by using a plurality of Merkle trees.
Step four: and (5) permanently updating the updated Merkle tree to a disk in an asynchronous mode.
Step five: and in the persistence process, according to the updated cache data of the Merkle tree, updating the state data of the next version number, namely repeating the steps one to four until the version is higher than N versions of the water line, and completing all data request processing of the current system.
The actual state data is stored on the disk in a distributed manner by means of consistent hash computation; if the disk space of the current node is fully written, dynamic expansion is supported, and migration reconstruction of the Merkle tree is not involved.
In summary, in the data writing process, before the data starts to operate, the previous N versions of data are required to be subjected to persistence, then the version numbers belonging to the previous N versions are acquired, the data are inserted, and Key and Value data in the block are inserted into the corresponding Merkle tree; after the Merkle tree is inserted, recursion is started from the root node, page allocation, node splitting and rebalancing are carried out on each updated node, and after tree transformation is finished, hash calculation is carried out on the whole tree.
As shown in fig. 2, for the data stored by the above-described storage method, verification (i.e., reading) is performed by:
(1) And receiving a verification request, wherein the verification request comprises a Key value, and verifying the parameter of the request.
(2) And finding the name of the sub tree in the world Merkle balance tree in the total world state according to the Key value, namely acquiring the name of the account in which the current Key is located.
(3) And establishing an access iterator of the Merkle tree corresponding to the state data according to the Key value, so that traversing and searching are facilitated.
(4) And comparing the Key value with the page number (pid) through an access iterator, and performing hierarchical traversal according to the Key until the access to the leaf node is finished.
(5) And finding out the disk position corresponding to the data in the record information of the leaf node, namely, page reference, and reading the data corresponding to the Key.
(6) Performing hash calculation on the data obtained in the step (5), and then constructing a structure body for returning the certification value.
(7) And (5) tracing back upwards according to the leaf node in the step, finding out the brother node and the father node, and calculating the hash of the state path process until tracing back to the index node.
(8) And returning the final hash values of all paths as proof.
The providing mode of the state verification and the data storage are reversed, the data can be used as a single database to provide state data, and the data can be accessed into a LevelDB or a TiDB for data storage at a later stage.
The information stored by the leaf nodes of the Merkle tree storing the total world state is the value of the Merkle tree of the account state corresponding to the current Key value. The information stored by the leaf nodes of the Merkle tree of account status is the location where the current Key is actually stored on disk. Because the bottom layer structure of the Merkle tree is a B+ tree, all data information is stored in a disk in the form of files, one file corresponds to one leaf node, and the size of the leaf node can be set according to actual use; the leaf nodes of the Merkle tree recording the account state only store the position index information pointing to the disk and do not store data; one file stores data information of a plurality of Key values. After the data file corresponding to the Key value is found, the actual data is found according to the offset of the file.
The state data storage method and the verification method based on the blockchain can be realized by equipment, and the equipment comprises the following steps: a host server and a fragment server; the host server is used for recording the Merkle tree of the total world state and recording index information; at least one of the slicing servers is used for recording data information.
The host server maintains the routing state information of all the fragment servers, and each fragment server is responsible for storing a certain range of data after hash calculation; the slicing server can be automatically expanded, and each write request can be relatively independently processed; if the current fragment server storage reaches the extremum, a new fragment server can be applied for space expansion.
The host server maintains the context environment of the host server to manage all Merkle tree leaf nodes needing to be updated, so that the updated nodes recalculate the hash value, and the trace back splitting can be performed concurrently when the message verification is provided, thereby improving the transformation speed of the tree structure.
The device can be used as an independent state database, and can also replace a fragment server with other key value type databases to record state data, such as a LevelDB or a TiDB for data storage.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other manners. For example, the apparatus/terminal device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
It will be appreciated by persons skilled in the art that the foregoing description is a preferred embodiment of the application, and is not intended to limit the application, but rather to limit the application to the specific embodiments described, and that modifications may be made to the technical solutions described in the foregoing embodiments, or equivalents may be substituted for elements thereof, for the purposes of those skilled in the art. Modifications, equivalents, and alternatives falling within the spirit and principles of the application are intended to be included within the scope of the application.
Claims (9)
1. A state data storage method based on a block chain is characterized by comprising the following steps:
step one: writing the data of the current block into a pre-write log, judging whether the data processing of the current block can be performed or not in a mode of combining a water line and version numbers, wherein the water line is the minimum value of the version numbers corresponding to the incomplete and durable state data, and performing the next step if the version number of the current state data is smaller than the version numbers of N versions after the water line; otherwise, the state data after waiting for the water line and before the version number N versions of the current state data is blocked to finish persistence;
step two: updating the version state number, namely adding one to the version number of the current state data, checking the state data before N versions, releasing the space occupied by the outdated state data, and marking the space as an idle page for inserting the subsequent data;
step three: inserting the state data into the Merkle tree, judging whether the size of a state data node reaches a data page threshold value, if so, updating the cache data of the Merkle tree after splitting the data page, and if not, directly updating the cache data of the Merkle tree;
in the third step, a world Merkle balance tree is maintained in a memory and is used for recording the whole world state of the current blockchain; the world Merkle balance tree provides a mapping of the total world state and the state Merkle tree of each account space; the state Merkle tree of each account space records different information in a layered manner, only leaf nodes truly record disk position mapping of data storage, other nodes do not store real data conditions, and only index paths to the leaf nodes;
step four: the updated Merkle tree is subjected to persistent updating of data to a disk in an asynchronous mode;
step five: in the process of persistence, according to the updated cache data of the Merkle tree, updating the state data of the next version number, namely repeating the steps one to four until all data request processing of the current system is completed by N versions higher than the water line;
in the fourth step, the actual state data is stored on the disk in a distributed manner through a consistent hash calculation mode; if the disk space of the current node is fully written, dynamic expansion is supported, and migration reconstruction of the Merkle tree is not involved.
2. The method for storing state data based on blockchain as in claim 1, wherein in the step three, the state data is inserted into the Merkle tree in batch, the insertion is concurrent operation of writing in the unit of the update path of the node, and when all the state data is inserted into the Merkle tree, the Merkle tree performs tree transformation, reaches the equilibrium state again, and calculates the hash value of the root node.
3. The blockchain-based state data storage method of claim 1, wherein the version of the state data is recorded by a skip list, which can support a fast state transition; supporting state data rollback within a prescribed version; the number of the versions is configured according to the data requirements when the user actually uses, and the specific calculation formula of the number of the stored versions is as follows:
version number N number of server nodes x amount of available storage space per server)/(number of accounts x
Status data size) -1.
4. The blockchain-based state data storage method of claim 1, wherein the data stored in the blockchain-based state data storage method is verified by:
(1) Receiving a verification request, wherein the verification request comprises a Key value, and verifying a parameter of the request;
(2) Finding the name of the sub tree in the world Merkle balance tree according to the Key value in the total world state, namely obtaining the name of the account in which the current Key is located;
(3) Establishing an access iterator of the Merkle tree corresponding to the state data according to the Key value;
(4) Comparing the Key value with the page number by using the access iterator, and performing hierarchical traversal according to the Key until the access to the leaf node is finished;
(5) Finding out the disk position corresponding to the data in the record information of the leaf node, namely, page reference, and reading the data corresponding to the Key;
(6) Performing hash calculation on the data obtained in the step (5), and constructing a structure body for returning the proving value;
(7) According to the leaf node in the step (5), tracing upwards, finding out brother nodes and father nodes, calculating state path process hash until tracing back to the index node;
(8) And returning the final hash values of all paths as proof.
5. The blockchain-based state data storage method of claim 4, wherein the information stored by leaf nodes of the Merkle tree storing the total world state is a value of the Merkle tree of the account state corresponding to the current Key value; the information stored by the leaf nodes of the Merkle tree of the account state is the position where the current Key is actually stored on the disk; because the bottom layer structure of the Merkle tree is a B+ tree, all data information is stored in a disk in the form of files, one file corresponds to one leaf node, and the size of the leaf node is set according to actual use; the leaf nodes of the Merkle tree recording the account state only store the position index information pointing to the disk and do not store data; one file stores data information of a plurality of Key values, and when the data file corresponding to the Key values is found, the actual data is found according to the offset of the file.
6. The blockchain-based state data storage method of claim 1, wherein the total world state and account state are stored separately, and wherein storing of state data is accomplished using a plurality of Merkle trees.
7. An apparatus for performing the blockchain-based state data storage method of any of claims 1-6, the apparatus comprising: a host server and a fragment server; the host server is used for recording the Merkle tree of the total world state and recording index information; at least one of the slicing servers is used for recording data information; the host server maintains the routing state information of all the fragment servers, and each fragment server is responsible for storing a certain range of data after hash calculation; the slicing server can be automatically expanded, and each write request can be relatively independently processed; and if the current fragment server storage reaches the extremum, applying for a new fragment server to perform space expansion.
8. The apparatus of claim 7, wherein the host server maintains its own context to manage all Merkle tree leaf nodes that need to be updated; the updated node recalculates the hash value, and backtracking splitting is performed concurrently when the message is verified, so that the transformation speed of the tree structure is improved.
9. The apparatus of claim 7, wherein the apparatus is used not only as a stand alone status database, but also for recording status data by replacing a sharded server with another key-value type database.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310467504.3A CN116610670A (en) | 2023-04-27 | 2023-04-27 | State data storage method and device based on block chain |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310467504.3A CN116610670A (en) | 2023-04-27 | 2023-04-27 | State data storage method and device based on block chain |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116610670A true CN116610670A (en) | 2023-08-18 |
Family
ID=87679093
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310467504.3A Pending CN116610670A (en) | 2023-04-27 | 2023-04-27 | State data storage method and device based on block chain |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116610670A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117743651A (en) * | 2024-02-20 | 2024-03-22 | 建信金融科技有限责任公司 | Address book loading optimization method and device |
-
2023
- 2023-04-27 CN CN202310467504.3A patent/CN116610670A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117743651A (en) * | 2024-02-20 | 2024-03-22 | 建信金融科技有限责任公司 | Address book loading optimization method and device |
CN117743651B (en) * | 2024-02-20 | 2024-05-17 | 建信金融科技有限责任公司 | Address book loading optimization method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103136243B (en) | File system duplicate removal method based on cloud storage and device | |
US8762353B2 (en) | Elimination of duplicate objects in storage clusters | |
US20100161565A1 (en) | Cluster data management system and method for data restoration using shared redo log in cluster data management system | |
CN108804031A (en) | Best titime is searched | |
CN105468473A (en) | Data migration method and data migration apparatus | |
CN108021717B (en) | Method for implementing lightweight embedded file system | |
CN103902623A (en) | Method and system for accessing files on a storage system | |
CN107003814A (en) | Effective metadata in storage system | |
CN110109873B (en) | File management method for message queue | |
CN111177143B (en) | Key value data storage method and device, storage medium and electronic equipment | |
US11151081B1 (en) | Data tiering service with cold tier indexing | |
CN113535670B (en) | Virtual resource mirror image storage system and implementation method thereof | |
CN109558453B (en) | Block chain data network storage and relocation method | |
CN106980665A (en) | Data dictionary implementation method, device and data dictionary management system | |
CN109407985B (en) | Data management method and related device | |
CN116610670A (en) | State data storage method and device based on block chain | |
CN111680019B (en) | Block chain data expansion method and device | |
CN105468623A (en) | Data processing method and apparatus | |
CN115454994A (en) | Metadata storage method and device based on distributed key value database | |
CN114840487A (en) | Metadata management method and device for distributed file system | |
CN114721594A (en) | Distributed storage method, device, equipment and machine readable storage medium | |
CN102890651B (en) | The method of testing of a kind of contextual data and device | |
CN104166649A (en) | Caching method and device for search engine | |
CN117520278A (en) | Multi-client high-precision directory quota control method for distributed file system | |
WO2024119797A1 (en) | Data processing method and system, device, and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |