State data storage method and device in block chain system
By dividing node groups in the blockchain system and deploying storage services, storing the status data after consensus processing, the problem of high storage costs and long-term time-consuming addition of new nodes in the blockchain system is solved, and efficient storage and rapid addition of new nodes is achieved.
Patent Information
- Application Number
- CN202510125517.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-26
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2045-01-26
AI Technical Summary
In the blockchain system, the storage cost is high due to the continuous increase in block data and state data, and it takes a long time to copy the entire amount of data when adding new nodes.
By dividing blockchain nodes into packets and deploying storage services for each packet, the storage service is used to store the Merkle state tree and its root hash value organized into state data corresponding to the blocks passed through node consensus processing.
Deduplication and storage of state data in the blockchain system is realized, reducing storage requirements and costs, and when a new node is added, the root hash value is only needed to adjust, reducing the joining time, and implementing the second-level joining of the new node.
Smart Images

Figure CN120045564A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present application relate to the field of blockchain technology, and in particular, to a method and apparatus for storing state data in a blockchain system. Background Art
[0002] Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus protocol, and encryption algorithms. In a blockchain system, data blocks are combined into a chained data structure in a sequential connection manner according to the time sequence, and a distributed ledger that is tamper-proof and non-forgeable is guaranteed by cryptographic means. Due to the characteristics of decentralization, information immutability, and autonomy of the blockchain, the application of the blockchain is becoming more and more extensive.
[0003] In a blockchain system, the block data and state data on each node need to be consistent, which means that N nodes need to store N copies of full-scale block data and N copies of full-scale state data. As the blockchain system continues to run, the data volumes of the block data and state data will become larger and larger, so the storage cost of the block data will become higher and higher. In addition, if a new node is to be added, it is necessary to copy the full-scale block data and full-scale state data to this node, which usually takes a long time. Summary of the Invention
[0004] One or more embodiments of the present application provide the following technical solutions:
[0005] The present application provides a method for storing state data in a blockchain system; wherein, the blockchain nodes participating in consensus in the blockchain system are divided into at least one blockchain node group; a corresponding storage service is deployed for each blockchain node group by a blockchain service platform corresponding to the blockchain system; the storage space of the storage service is used to store a Merkle state tree formed by state data corresponding to blocks that have been consensus-processed and passed by each blockchain node in the blockchain node group, and a root hash value corresponding to each blockchain node in the blockchain node group; the root hash value is the root hash value of the updated Merkle state tree obtained after adding the state data corresponding to the latest block that has been consensus-processed and passed by the corresponding blockchain node to the Merkle state tree;
[0006] The method is applied to a target storage service corresponding to a target blockchain node group in the blockchain system, and includes:
[0007] Obtain a storage request for first state data corresponding to a first block sent by a target blockchain node in the target blockchain node group in response to passing the consensus processing of the first block;
[0008] In response to the storage request, determine whether the first status data has been added to the Merkle status tree stored in the target storage space of the target storage service;
[0009] If the first status data has not been added to the Merkle status tree, add the first status data to the Merkle status tree stored in the target storage space, and update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle status tree;
[0010] If the first status data has been added to the Merkle status tree, update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle status tree stored in the target storage space.
[0011] This application also provides a status data storage device in a blockchain system; wherein, the blockchain nodes participating in consensus in the blockchain system are divided into at least one blockchain node group; the blockchain service platform corresponding to the blockchain system deploys corresponding storage services for each blockchain node group; the storage space of the storage service is used to store the Merkle status tree organized by the status data corresponding to the blocks that have been consensus-processed and passed by each blockchain node in the blockchain node group, and the root hash value corresponding to each blockchain node in the blockchain node group; the root hash value is the root hash value of the updated Merkle status tree obtained after adding the status data corresponding to the latest block that has been consensus-processed and passed by the corresponding blockchain node to the Merkle status tree;
[0012] The device is applied to the target storage service corresponding to the target blockchain node group in the blockchain system, and includes:
[0013] An acquisition unit, which acquires a storage request for the first status data corresponding to the first block sent by the target blockchain node in the target blockchain node group in response to the consensus processing and passing of the first block;
[0014] A determination unit, which, in response to the storage request, determines whether the first status data has been added to the Merkle status tree stored in the target storage space of the target storage service;
[0015] A storage unit, if the first state data has not been added to the Merkle state tree, add the first state data to the Merkle state tree stored in the target storage space, and update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle state tree;
[0016] An update unit, if the first state data has been added to the Merkle state tree, update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle state tree stored in the target storage space.
[0017] This application also provides an electronic device, including:
[0018] A processor;
[0019] A memory for storing executable instructions of the processor;
[0020] Wherein, the processor realizes the steps of the method as described in any one of the above by running the executable instructions.
[0021] This application also provides a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method as described in any one of the above are realized.
[0022] In the above technical solution, the blockchain nodes participating in consensus in the blockchain system are divided into at least one group of blockchain nodes. The blockchain service platform corresponding to the blockchain system deploys corresponding storage services for each group of blockchain nodes. The storage space of the storage service is used to store the Merkle state tree formed by the state data corresponding to the blocks that have been consensus-processed and passed by each blockchain node in the group of blockchain nodes, and the root hash value corresponding to each blockchain node in the group of blockchain nodes. The root hash value is used to indicate the root hash value of the updated Merkle state tree obtained after the state data corresponding to the latest block that has been consensus-processed and passed is added to the Merkle state tree. When the storage service corresponding to any group of blockchain nodes in the blockchain system stores the state data corresponding to a block that has been consensus-processed and passed by a certain blockchain node in the group of blockchain nodes, it can first determine whether the state data has been added to the Merkle state tree stored in the storage space of the storage service. If the state data has not been added to the Merkle state tree, the state data can be added to the Merkle state tree stored in the storage space, and the root hash value corresponding to the blockchain node stored in the storage space is updated to the root hash value of the updated Merkle state tree. If the state data has been added to the Merkle state tree, the root hash value corresponding to the blockchain node stored in the storage space can be directly updated to the root hash value of the Merkle state tree stored in the storage space.
[0023] By using the above method, the state data in the blockchain system can be stored through the storage services deployed for each group of blockchain nodes, and deduplication processing of the state data stored in the storage space of each storage service is achieved, so that only one copy of the full amount of state data needs to be stored in the storage space of each storage service, instead of storing one copy of the full amount of state data on each blockchain node participating in consensus. If N blockchain nodes are divided into X (1 ≤ X ≤ N) groups of blockchain nodes, then only X copies of the full amount of state data need to be stored, instead of storing N copies of the full amount of state data, that is, the storage requirement can be reduced to X / N of the original. In this way, the storage cost of the state data in the blockchain system can be reduced, and when a new node joins the blockchain system, only the root hash value set for the new node needs to be adjusted, so that the time-consuming for the new node to join the blockchain system can be reduced, and the new node can be joined to the blockchain system within seconds. Description of the Drawings
[0024] The drawings required for the description of the exemplary embodiments will be described below, where:
[0025] Figure 1It is a schematic diagram of a blockchain system shown in an exemplary embodiment of the present application.
[0026] Figure 2 It is a schematic diagram of a deployment architecture of a blockchain storage service shown in an exemplary embodiment of the present application.
[0027] Figure 3 It is a schematic diagram of another deployment architecture of a blockchain storage service shown in an exemplary embodiment of the present application.
[0028] Figure 4 It is a schematic diagram of another deployment architecture of a blockchain storage service shown in an exemplary embodiment of the present application.
[0029] Figure 5 It is a flowchart of a method for storing state data in a blockchain system shown in an exemplary embodiment of the present application.
[0030] Figure 6 It is a schematic diagram of the structure of a device shown in an exemplary embodiment of the present application.
[0031] Figure 7 It is a block diagram of a device for storing state data in a blockchain system shown in an exemplary embodiment of the present application. Detailed Description of the Embodiment
[0032] Here, the exemplary embodiments will be described in detail, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of the present application. On the contrary, they are only examples consistent with some aspects of one or more embodiments of the present application.
[0033] It should be noted that in other embodiments, the steps of the corresponding methods are not necessarily executed in the order shown and described in the present application. In some other embodiments, the steps included in the method may be more or less than those described in the present application. In addition, a single step described in the present application may be decomposed into multiple steps for description in other embodiments; and multiple steps described in the present application may also be combined into a single step for description in other embodiments.
[0034] Blockchains are generally divided into three types: public blockchains, private blockchains, and consortium blockchains. In addition, there can also be combinations of the above multiple types, such as the combination of a private blockchain and a consortium blockchain, the combination of a consortium blockchain and a public blockchain, etc.
[0035] Among the above three types of blockchains, the public blockchain has the highest degree of decentralization. The participants who join the public blockchain (which can also be called nodes in the blockchain) can read the data records on the chain, participate in transactions, compete for the right to record new blocks, etc. Moreover, each node can freely join or exit the network and perform relevant operations.
[0036] On the contrary, for a private blockchain, the write permission of the network is controlled by a certain organization (or entity institution), and the data read permission is subject to the organization's regulations. That is to say, a private blockchain can be regarded as a weakly centralized system, which has strict restrictions on nodes and a small number of nodes. This type of blockchain is more suitable for internal use within a specific institution.
[0037] The consortium blockchain is between the public blockchain and the private blockchain and can achieve "partial decentralization". Each node in the consortium blockchain usually has a corresponding organization (or entity institution); the nodes join the network through authorization and form an interest-related consortium to jointly maintain the operation of the blockchain.
[0038] Please refer to Figure 1 , Figure 1 , which is a schematic diagram of a blockchain system shown in an exemplary embodiment of the present application.
[0039] As Figure 1 shown, the blockchain system can maintain one or more blockchains (for example: public blockchain, private blockchain, consortium blockchain, etc.), and can include multiple nodes for hosting the above one or more blockchains; for example, as Figure 1 shown, nodes such as node 1, node 2, node 3, node 4, node i, etc. can jointly host one or more blockchains. Between the blockchains included in each blockchain system, and between each blockchain system, cross-chain data access can also be performed.
[0040] A node is a logical communication entity; multiple nodes of different types can run on the same physical server or on different physical servers. In an illustrated implementation, a node can be a physical device or a virtual device implemented in a server or a server cluster; for example, a node can be a physical host in a server cluster or a virtual machine created after virtualizing the hardware resources carried by a server or a server cluster based on virtualization technology. Between each node, various types of communication methods (for example: TCP / IP, etc.) can be used to couple them together to form a network to host one or more blockchains.
[0041] Based on the basic characteristics of the blockchain, a blockchain is usually composed of several blocks. Timestamps corresponding to the creation time of the block are respectively recorded in these blocks, and all the blocks strictly form an orderly data chain in time according to the timestamps recorded in the blocks.
[0042] For the data generated outside the blockchain, these data can be constructed into the standard transaction format supported by the blockchain and then published to the blockchain. The nodes participating in consensus in the blockchain system conduct consensus on this transaction and execute this transaction after the consensus is completed, so that this transaction and the execution result can be persistently stored and certified in the blockchain.
[0043] In the blockchain system, different participating parties can establish a distributed blockchain network through the deployed nodes. In practical applications, the connection relationships between each node and different nodes can be regarded as the blockchain network, and the connection relationships, data interactions, etc. between each node and different nodes can be regarded as the blockchain system. Among them, the decentralized (or multi-centered) distributed ledger constructed by the chained block structure is stored on each node (or most nodes, such as consensus nodes) in the distributed blockchain network. Such blockchain systems need to solve the problems of consistency and correctness of the ledger data on each of the decentralized (or multi-centered) multiple nodes. A blockchain program runs on each node in the blockchain system. Under the design with certain fault tolerance requirements, through the consensus protocol, it is ensured that all loyal nodes have the same transactions, so as to ensure that the execution results of the same transactions on all loyal nodes are consistent, and the transactions and execution results are packaged to generate a block.
[0044] The nodes in the blockchain system can generally be divided into two categories: consensus nodes and non-consensus nodes. Among them, the consensus nodes are the nodes that run the consensus protocol. The non-consensus nodes can forward the transactions sent by the client to the consensus nodes. The consensus nodes can propose transactions, attempt to construct blocks, and send the constructed blocks to other nodes, so that both the consensus nodes and the non-consensus nodes can store the block.
[0045] Specifically, the consensus nodes in the blockchain system can conduct consensus on the transactions included in the new block to be connected to the chained block structure based on the consensus protocol, so as to ensure that all consensus nodes reach an agreement on the content and order of the transactions included in this block, thus realizing the construction of this block. After the consensus is completed, the consensus nodes can send the constructed block to other nodes, so that each node executes the transactions included in this block in sequence, and under the condition that the transaction execution results of all nodes are confirmed to be consistent, the finalization of this block is completed. Among them, finalization means that the transactions included in the block are executed and the transaction execution results are recognized by all nodes (or a certain number of nodes, such as two-thirds of the nodes).
[0046] Any consensus node in the blockchain system can broadcast a message after executing the transactions included in a block that has completed consensus. This message can indicate that the consensus for the block has been completed and the included transactions have been executed. Therefore, based on this message, it can be confirmed whether the transaction execution results of each consensus node for the block are consistent, and thus, when the transaction execution results of each consensus node are confirmed to be consistent, the finalization of the block can be completed.
[0047] In a blockchain, the block height is the number of blocks connected in the chained block structure. However, for any block in the blockchain, the block height of the block can be used as an identifier for the block. A block is generally considered to have two identifiers. One identifier is the hash value of the block header, and the other identifier is the block height. Among them, the hash value of the block header is obtained by performing a second hash calculation on the block header using algorithms such as the SHA256 algorithm; the hash value of the block header can uniquely identify a block, and any node in the blockchain system can independently obtain the hash value of the block header by performing a hash calculation on the block header. The block height refers to the position of the block in the blockchain; the block height is not an identifier that uniquely identifies a block. Although a block always has a clear and fixed block height, a block height does not always identify a unique block, and two or more blocks may have the same block height, that is, competing for the same position in the blockchain. Each block in the blockchain is usually connected in the chained block structure in chronological order, that is, the chained block structure is actually a chain that is ordered in time. In this case, the block height is usually set as an increasing value. For example, assuming that the block height of the last finalized block is h, then the block height of the next block to be consensus is h + 1; and so on.
[0048] The consensus protocol in the blockchain system can be implemented in a sliding window manner. For example, a consensus window with a length of L can be set; assuming that the block height of the block currently in the finalization process is h, then the blocks corresponding to the block heights in the block height interval [h + 1, h + L] can be consensus.
[0049] In practical applications, the blockchain data that needs to be stored and maintained usually includes block data and state data. The information included in each block in the blockchain can be referred to as block data, and the current state of the blockchain system at any given time point can be referred to as state data.
[0050] Block data can include a block header and a block body; the block header contains metadata of the block, such as the hash value of the previous block, timestamp, difficulty target, nonce, etc.; the block body contains a transaction list. Block data is the historical record of the blockchain. It is arranged in chronological order, and each new block contains the hash value of the previous block, thus forming a chain. This structure ensures that once data is added to the blockchain, it is very difficult to be tampered with, because any change to the block data will cause the hash values of all subsequent blocks to change.
[0051] State data can include account balances, contract codes, and storage data; contract codes and storage data refer to the running logic of smart contracts and the associated storage information. State data reflects the results of all historical transactions and operations and is a snapshot of the blockchain system at a specific point in time. It has the inherent complexity and security features of blockchain technology. State data is dynamic and will be continuously updated as new transactions are confirmed and added to the blockchain.
[0052] The updates of block data and state data are so close in time that they can be considered to be completed in the same round of operations. Specifically, the update of state data occurs after the block is accepted by the consensus algorithm and is then immediately recorded as part of that block. Therefore, it can be considered that the update of state data follows closely after the update of block data, and the two are closely linked.
[0053] When storing the various blockchain data shown above, the above various blockchain data can usually be organized into a Merkle tree in the form of key-value pairs and stored in a database.
[0054] A Merkle tree, also known as a hash tree, is a tree-shaped data structure. It is a binary tree or multi-way tree structure, where each leaf node contains the hash value of a data block, and non-leaf nodes contain the hash values of the contents of their child nodes. In a Merkle tree, leaf nodes represent the actual stored data blocks, non-leaf nodes are obtained by calculating the contents of their child nodes through a hash function, and the root node, also known as the Merkle root or Root Hash (root hash value), is the topmost node in the Merkle tree structure, which represents the combined hash value of all data in the entire tree.
[0055] In a blockchain system, the block data and state data on each node need to be consistent. This means that N nodes need to store N copies of the full block data and N copies of the full state data. As the blockchain system continues to run, the data volumes of the block data and state data will become larger and larger, so the storage cost of the block data will become higher and higher. In addition, if a new node is to be added, it is necessary to copy the full block data and full state data to this node, which usually takes a long time.
[0056] One or more embodiments of the present application provide a technical solution for implementing the storage of state data in a blockchain system to reduce the storage cost of state data in the blockchain system, and reduce the time-consuming for a new node to join the blockchain system, and achieve the second-level joining of a new node in the blockchain system.
[0057] It should be noted that in the present application, the state data generated after the transactions included in the block that has passed the consensus processing are executed is referred to as the state data corresponding to the block.
[0058] In the above technical solution, the blockchain nodes participating in the consensus in the blockchain system are divided into at least one blockchain node group, and the blockchain service platform corresponding to the blockchain system deploys corresponding storage services for each blockchain node group. The storage space of the storage service is used to store the Merkle state tree organized by the state data corresponding to the blocks that have passed the consensus processing by each blockchain node in the blockchain node group, and the root hash value corresponding to each blockchain node in the blockchain node group. The root hash value is used to indicate the root hash value of the updated Merkle state tree obtained after the state data corresponding to the latest block that has passed the consensus processing is added to the Merkle state tree by the blockchain node. When the storage service corresponding to any blockchain node group in the blockchain system stores the state data corresponding to the block that has passed the consensus processing by a certain blockchain node in the blockchain node group, it can first determine whether the state data has been added to the Merkle state tree stored in the storage space of the storage service. If the state data has not been added to the Merkle state tree, the state data can be added to the Merkle state tree stored in the storage space, and the root hash value corresponding to the blockchain node stored in the storage space is updated to the root hash value of the updated Merkle state tree. If the state data has been added to the Merkle state tree, the root hash value corresponding to the blockchain node stored in the storage space can be directly updated to the root hash value of the Merkle state tree stored in the storage space.
[0059] The basis of the above technical solution is to abstract the state data storage of the blockchain system as a basic capability, which is called blockchain storage service. All blockchain nodes in the blockchain system (the blockchain nodes in this application can be consensus nodes) can be divided into different blockchain node groups (Regions) according to the dimensions of their respective enterprises, institutions or regions. In addition, the blockchain service platform corresponding to the blockchain system can deploy a corresponding storage service for each blockchain node group, and all blockchain nodes in the blockchain node group can share the storage service, and the storage service only provides storage services for state data for the blockchain nodes in the blockchain node group; these storage services together constitute the blockchain storage service corresponding to the blockchain system, and the blockchain storage service can be integrated into the blockchain service platform as a distributed storage service, that is, the computing resources, storage resources and network resources used by the blockchain storage service can be provided by the blockchain service platform. The division of blockchain node groups is determined by actual needs, and the number of blockchain nodes in each blockchain node group can be arbitrary; that is, each blockchain node can be grouped as an independent blockchain node, all blockchain nodes can be grouped as a blockchain node, and different numbers of blockchain nodes can be grouped in different blockchain node groups.
[0060] When each blockchain node is initialized, it can apply for storage space from the storage service deployed in the blockchain node group to which it belongs, and the storage service will divide an independent storage subspace for the blockchain node from its storage space. The blockchain storage service ensures that the storage subspaces corresponding to each blockchain node are isolated from each other. Each blockchain node can only read and write the state data in its own storage subspace, but cannot read and write the state data in the storage subspace corresponding to other blockchain nodes; for example, the isolation of storage subspaces can be achieved through the node identification of the blockchain node, that is, each blockchain node can carry its own node identification in the storage request or read request it initiates, so that the state data is stored in the storage subspace corresponding to the blockchain node, or the state data is read from the storage subspace corresponding to the blockchain node, thereby achieving the isolation of the storage subspaces of different blockchain nodes.
[0061] In the storage space of each storage service, a shared storage subspace can also be partitioned. This shared storage subspace can be shared by all blockchain nodes in the blockchain node group corresponding to the storage service, and the state data corresponding to the blocks that have been consensus-processed and passed by the majority of blockchain nodes in the blockchain system can be stored in this shared storage subspace. Specifically, the state data corresponding to the blocks that have been consensus-processed and passed by the blockchain nodes can first be temporarily stored in the storage subspace of the blockchain nodes. After the majority of blockchain nodes in the blockchain system have passed the consensus processing for the block, the state data corresponding to the block can be submitted to this shared storage subspace for storage. Among them, a set of a certain number of replicas required to ensure the data consistency requirements and fault tolerance requirements of all replicas is generally a set composed of the majority of nodes in a distributed system, that is, the majority (Quorum).
[0062] In addition, within the same storage service, duplicate removal processing can be performed on the state data requested to be stored by each blockchain node in the blockchain node group corresponding to the storage service.
[0063] From the perspective of each blockchain node in the blockchain system, the storage service corresponding to the blockchain node group where the blockchain node is located can be regarded as a storage service that provides state data storage specifically for the blockchain node, and the full amount of state data of the blockchain node is stored through this storage service. The blockchain node is unaware of the state data that has been duplicate-removed within this storage service.
[0064] Moreover, since the above duplicate removal processing is carried out within the storage service, from the perspective outside the blockchain system, it is actually storing or reading state data in the storage space of the blockchain.
[0065] Specifically, according to the characteristics of the state data on each blockchain node in the blockchain system, within the same storage service, duplicate removal processing can be performed on the state data requested to be stored by each blockchain node in the blockchain node group corresponding to the storage service.
[0066] Among them, the characteristics of the state data on each blockchain node in the blockchain system include: the state data on each blockchain node must be the same; if there are different state data, then there must be a fork situation; at a certain moment, the consensus progress of each blockchain node for the block may be inconsistent. For example, the consensus progress of some blockchain nodes for the block is at block 100, while the consensus progress of some blockchain nodes for the block is at block 105.
[0067] Overall, in the above technical solution, only one copy of the full - volume status data is retained inside each storage service. At the same time, for each blockchain node in the blockchain node group corresponding to the storage service, a pointer is maintained to point to the position of the latest block that has been consensus - processed and passed by the blockchain node in the full - volume status data. For a blockchain node in the blockchain node group, after the blockchain node has consensus - processed and passed a block, it can request the storage service to store the status data corresponding to the block. During the process of storing the status data, the storage service can first check whether the same status data has been stored in the storage space of the storage service. If the same status data has not been stored in the storage space of the storage service, the status data obtained from the blockchain node can be stored in the storage space of the storage service to add the status data to the full - volume status data. If the same status data has been stored in the storage space of the storage service, the maintained pointer corresponding to the blockchain node is updated so that the pointer points to the position of the same status data in the full - volume status data, and there is no need to store the status data in the storage space of the storage service anymore. Correspondingly, when the blockchain node reads the status data through the storage service, it only reads within the range of the status data before the position pointed to by the maintained pointer corresponding to the blockchain node.
[0068] By adopting the above method, by deploying corresponding storage services for each blockchain node group to store the status data in the blockchain system and automatically performing deduplication processing of the status data within each storage service, only one copy of the full - volume status data needs to be stored in each storage service, instead of storing one copy of the full - volume status data on each blockchain node. If N blockchain nodes are divided into X (1 ≤ X ≤ N) blockchain node groups, then only X copies of the full - volume status data need to be stored, instead of storing N copies of the full - volume status data, that is, the storage requirement is reduced to X / N of the original. In this way, the storage cost of the status data in the blockchain system can be reduced, and when a new node joins the blockchain system, only the pointer set for the new node needs to be adjusted, thereby reducing the time taken for the new node to join the blockchain system and achieving the second - level joining of the new node in the blockchain system.
[0069] First, the deployment architecture of the blockchain storage service in the technical solution provided by the present application will be described below, and then the method for storing status data in the blockchain system with the blockchain storage service deployed will be specifically described.
[0070] (1) Deployment architecture of the blockchain storage service
[0071] In this application, the storage service corresponding to the blockchain system can be simply referred to as the blockchain storage service. It can be a distributed storage service that provides data storage services for the blockchain system. In practical applications, the blockchain storage service can be a cloud service that relies on a cloud disk to provide data storage services for the blockchain system, that is, uploading blockchain data to the cloud disk for storage; or, the blockchain storage service can also rely on storage media such as mechanical hard disks and solid-state drives to provide data storage services for the blockchain system, that is, storing blockchain data in such storage media.
[0072] There are three possible forms of the deployment architecture of the blockchain storage service:
[0073] In one possible form, all blockchain nodes in a blockchain system can be divided into multiple blockchain node groups, and different blockchain node groups do not trust each other. There can be only one blockchain node in a blockchain node group. At this time, a storage service can be deployed within each blockchain node group, which actually means deploying a storage service for each blockchain node. In the storage space of each storage service, it can include an independent storage subspace divided for a blockchain node in the blockchain node group corresponding to the storage service, and a shared storage subspace. These independent storage services together constitute the blockchain storage service corresponding to the blockchain system.
[0074] For example, as Figure 2 shown, the four blockchain nodes in the blockchain system are divided into four blockchain node groups, and there is only one blockchain node in a blockchain node group. A storage service is deployed within each blockchain node group, that is, a storage service is deployed for each blockchain node. Specifically, the blockchain node 1 in the blockchain node group 1 can use the storage subspace 1 in the storage service 1, and the storage space of the storage service 1 can also include a shared storage subspace; the blockchain node 2 in the blockchain node group 2 can use the storage subspace 1 in the storage service 2, and the storage space of the storage service 2 can also include a shared storage subspace; the blockchain node 3 in the blockchain node group 3 can use the storage subspace 1 in the storage service 3, and the storage space of the storage service 3 can also include a shared storage subspace; the blockchain node 4 in the blockchain node group 4 can use the storage subspace 1 in the storage service 4, and the storage space of the storage service 4 can also include a shared storage subspace; and so on.
[0075] In another possible form, all blockchain nodes in a blockchain system can be divided into a blockchain node group. Therefore, there can be multiple blockchain nodes in a blockchain node group. At this time, a storage service can be deployed within this blockchain node group, and all blockchain nodes can share this storage service. However, it should be noted that the entire storage space used by the storage service deployed within this blockchain node group can be partitioned, and the storage space can be divided into multiple independent storage sub-spaces, so that different blockchain nodes in this blockchain node group can use different storage sub-spaces within this storage service. In addition, the storage space can also include a shared storage sub-space shared by all blockchain nodes in this blockchain node group. This storage service itself constitutes the blockchain storage service corresponding to the blockchain system.
[0076] For example, as Figure 3 shown, four blockchain nodes in the blockchain system are divided into a blockchain node group, and there are a total of four blockchain nodes in this blockchain node group. A storage service is deployed within this blockchain node group, and these four blockchain nodes can share this storage service. Specifically, blockchain node 1 in blockchain node group 1 can use storage sub-space 1 in storage service 1; blockchain node 2 in blockchain node group 1 can use storage sub-space 2 in storage service 1; blockchain node 3 in blockchain node group 1 can use storage sub-space 3 in storage service 1; blockchain node 4 in blockchain node group 1 can use storage sub-space 4 in storage service 1; the storage space of storage service 1 can also include a shared storage sub-space shared by blockchain node 1, blockchain node 2, blockchain node 3, and blockchain node 4 in blockchain node group 1; and so on.
[0077] In yet another possible form, all blockchain nodes in a blockchain system can be divided into multiple groups of blockchain nodes, and there is no trust between different groups of blockchain nodes. There can be only one blockchain node or multiple blockchain nodes in a group of blockchain nodes. At this time, a storage service can be deployed within each group of blockchain nodes, and all blockchain nodes in the same group of blockchain nodes can share the storage service deployed within this group of blockchain nodes. However, it should be noted that the entire storage space used by the storage service deployed within each group of blockchain nodes can be partitioned, and the storage space can be divided into multiple storage sub-spaces, so that different blockchain nodes in the same group of blockchain nodes can use different storage sub-spaces within the storage service deployed within this group of blockchain nodes. In addition, within the storage space of each storage service, there can also be a shared storage sub-space shared by all blockchain nodes in the group of blockchain nodes corresponding to this storage service. These independent storage services together constitute the blockchain storage service corresponding to this blockchain system.
[0078] For example, as Figure 4As shown, the six blockchain nodes in the blockchain system are divided into three blockchain node groups. There is only one blockchain node in blockchain node group 1, a total of four blockchain nodes in blockchain node group 2, and a total of two blockchain nodes in blockchain node group 3. A storage service is deployed within each blockchain node group. That is, a storage service is deployed for one blockchain node in blockchain node group 1; a storage service is deployed for the four blockchain nodes in blockchain node group 2, and these four blockchain nodes can share this storage service; a storage service is deployed for the two blockchain nodes in blockchain node group 3, and these two blockchain nodes can share this storage service. Specifically, blockchain node 1 in blockchain node group 1 can use storage subspace 1 in storage service 1, and the storage space of storage service 1 can also include a shared storage subspace; blockchain node 2 in blockchain node group 2 can use storage subspace 1 in storage service 2, blockchain node 3 in blockchain node group 2 can use storage subspace 2 in storage service 2, blockchain node 4 in blockchain node group 2 can use storage subspace 3 in storage service 2, blockchain node 5 in blockchain node group 2 can use storage subspace 4 in storage service 2, and the storage space of storage service 2 can also include a shared storage subspace shared by blockchain node 2, blockchain node 3, blockchain node 4, and blockchain node 5 in blockchain node group 2; blockchain node 6 in blockchain node group 3 can use storage subspace 1 in storage service 3, blockchain node 7 in blockchain node group 3 can use storage subspace 2 in storage service 3, and the storage space of storage service 3 can also include a shared storage subspace shared by blockchain node 6 and blockchain node 7 in blockchain node group 3; and so on.
[0079] (2) State data storage method in the blockchain system
[0080] Please refer to Figure 5 , Figure 5 which is a flowchart of a state data storage method in a blockchain system shown in an exemplary embodiment of the present application.
[0081] In this embodiment, the blockchain nodes participating in consensus in the above blockchain system (i.e., blockchain nodes) can be divided into at least one blockchain node group.
[0082] For each blockchain node group, the blockchain service platform corresponding to the above blockchain system can deploy a corresponding storage service for this blockchain node group, and all the blockchain nodes in this blockchain node group can share this storage service, that is, each blockchain node in this blockchain node group can use this storage service to store state data into the storage space of this storage service.
[0083] Among them, the above storage space can be used to store a Merkle state tree organized by state data corresponding to blocks that have been consensus-processed and passed by each blockchain node in the above blockchain node group, and root hash values corresponding to each blockchain node in the blockchain node group. For a blockchain node, the root hash value corresponding to the blockchain node can be the root hash value of the updated Merkle state tree after adding the state data corresponding to the latest block that has been consensus-processed and passed to the Merkle state tree to update the Merkle state tree; that is, the root hash value can act as a pointer to the position of the state data corresponding to the latest block that the blockchain node has consensus-processed and passed in the full amount of state data.
[0084] In an illustrated embodiment, the above blockchain service platform can specifically be a BaaS (Blockchain as a Service) platform. BaaS, that is, "blockchain as a service", is a cloud computing service model that allows enterprises and developers to easily create, host, and manage their own blockchain applications, smart contracts, and distributed ledgers through a cloud platform without worrying about the installation and maintenance of underlying hardware and software. In this case, the storage service deployed by the blockchain service platform for each blockchain node group can be a storage cloud service, and the storage space of the storage service is the cloud storage space. Among them, the storage cloud service can be a storage service in the form of a virtual machine, container, microservice, etc.
[0085] The method for storing state data in the above blockchain system can be applied to a storage service (referred to as the target storage service) corresponding to any one blockchain node group (referred to as the target blockchain node group) in the blockchain system. As Figure 5 shown, the method can specifically include the following steps:
[0086] Step 502: Obtain a storage request for first state data corresponding to the first block sent by a target blockchain node in the target blockchain node group in response to passing the consensus processing of the first block.
[0087] In this embodiment, the blockchain nodes in the above blockchain system can perform consensus processing on a new block to be connected to a chained block structure based on a consensus protocol. Among them, the consensus processing can be operations such as verification performed by the blockchain node on the block to be consensus; after most blockchain nodes in the blockchain system pass the consensus processing of the block, it can be considered that the consensus on the block is completed.
[0088] After the blockchain nodes in the above blockchain system pass the consensus processing for a certain block, they can request the storage service corresponding to the blockchain node group to which the blockchain node belongs to store the state data corresponding to the block. For example, a certain blockchain node (which can be called the target blockchain node) in the above target blockchain node group can, in response to the passing of the consensus processing for a certain block (which can be called the first block), send a storage request for the state data corresponding to the first block (which can be called the first state data) to the above target storage service.
[0089] Step 504: In response to the storage request, determine whether the first state data has been added to the Merkle state tree stored in the target storage space of the target storage service.
[0090] In this embodiment, in response to the above storage request, it is first possible to determine whether the first state data has been added to the above Merkle state tree stored in the storage space (which can be called the target storage space) of the above target storage service.
[0091] In practical applications, the Merkle tree has the characteristic that it can quickly verify whether a certain data item belongs to a part of the tree without having to check the entire dataset of the tree. Only by providing the hash values (called Merkle proofs) on a path from the leaf node to the root node can the existence of a specific data item be verified. Based on this, it is possible to quickly verify whether the first state data has been added to the above Merkle state tree stored in the above target storage space.
[0092] Step 506: If the first state data has not been added to the Merkle state tree, add the first state data to the Merkle state tree stored in the target storage space, and update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle state tree.
[0093] In this embodiment, if the first state data has not been added to the above Merkle state tree stored in the above target storage space, the first state data can be added to the Merkle state tree stored in the target storage space to update the Merkle state tree. At the same time, the root hash value corresponding to the above target blockchain node stored in the target storage space can also be updated to the root hash value of the updated Merkle state tree.
[0094] Step 508: If the first state data has been added to the Merkle state tree stored in the target storage space, update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle state tree stored in the target storage space.
[0095] In this embodiment, if the above first state data has been added to the above Merkle state tree stored in the above target storage space, in order to avoid duplicate storage of state data, it is no longer necessary to add the first state data to the Merkle state tree stored in the target storage space. Instead, the root hash value corresponding to the above target blockchain node stored in the target storage space can be directly updated to the root hash value of this Merkle state tree stored in the target storage space.
[0096] In an illustrated implementation, the storage space of the storage service corresponding to each blockchain node group may include a storage subspace (which can be referred to as the first subspace) for storing the Merkle state tree organized by state data, and storage subspaces corresponding to each blockchain node in the blockchain node group (which can be referred to as the second subspace), where the second subspace is used to store the above root hash values corresponding to each blockchain node. Since the root hash values corresponding to each blockchain node are stored in the second subspace corresponding to the blockchain node, the root hash values corresponding to different blockchain nodes can be isolated, facilitating each blockchain node to obtain or update its own root hash value.
[0097] Take the Figure 4 illustrated blockchain system as an example. The shared storage subspace in Storage Service 1, Storage Service 2, and Storage Service 3 is the above first subspace; Storage Subspace 1 in Storage Service 1, Storage Subspace 1, Storage Subspace 2, Storage Subspace 3, and Storage Subspace 4 in Storage Service 2, and Storage Subspace 1 and Storage Subspace 2 in Storage Service 3 are all the above second subspaces.
[0098] In the above case, if the above first state data has not been added to the above Merkle state tree stored in the above target storage space, specifically, the first state data can be added to the Merkle state tree stored in the above first subspace included in the target storage space, and the root hash value corresponding to the target blockchain node stored in the above second subspace corresponding to the target blockchain node included in the target storage space is updated to the root hash value of the updated Merkle state tree.
[0099] If the above first state data has been added to the Merkle state tree stored in the above target storage space, specifically, the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node included in the target storage space can be updated to the root hash value of the Merkle state tree stored in the first subspace included in the target storage space.
[0100] For the storage space corresponding to a blockchain node group, the state data stored in the second subspaces corresponding to the respective blockchain nodes in the blockchain node group included in the storage space can be as shown in Table 1 below:
[0101] Table 1
[0102] blockchain node the Nth block 1 KV1, KV2, KV3 2 KV1, KV2, KV3 3 KV1, KV2, KV3 4 KV1, KV2, KV3
[0103] Among them, KV1, KV2, and KV3 respectively represent three Key-Value key-value pairs, and KV1, KV2, and KV3 together constitute the state data corresponding to the Nth block.
[0104] In an illustrated implementation manner, for a blockchain node group in the above blockchain system, the second subspaces corresponding to the respective blockchain nodes in the blockchain node group included in the storage space of the corresponding storage service can also be used to temporarily store the state data corresponding to the latest block that has been consensus processed by each blockchain node. Further, after the majority of blockchain nodes in the blockchain system have passed the consensus processing for the latest block, the state data corresponding to the latest block can be submitted to the first subspace included in the storage space for long-term storage.
[0105] In the above case, in response to a storage request for the above first state data, specifically, it can be determined whether the above first state data has been added to the Merkle state tree stored in the first subspace included in the above target storage space.
[0106] If the above first state data has been added to the Merkle state tree stored in the first subspace included in the above target storage space, specifically, the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the above target blockchain node included in the target storage space can be updated to the root hash value of the Merkle state tree stored in the first subspace included in the target storage space.
[0107] If the above-mentioned first state data corresponding to the above-mentioned first block is not added to the above-mentioned Merkle state tree stored in the first subspace included in the above-mentioned target storage space, specifically, the first state data can be temporarily stored in the second subspace corresponding to the above-mentioned target blockchain node included in the target storage space, and after the consensus processing of at least the next block (the next block or the next K blocks) of the first block by the target blockchain node is passed, the first state data temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space is added to the Merkle state tree stored in the first subspace included in the target storage space, and at the same time, the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the above-mentioned target blockchain node included in the target storage space is updated to the root hash value of the updated Merkle state tree.
[0108] It should be noted that for a blockchain node, if the blockchain node requests to store the (N + K)-th block (K ≥ 1), it means that the N-th block previously requested to be stored by the blockchain node must be a legal block, that is, a block that has passed the consensus processing of most blockchain nodes in the blockchain system. The reason is that if the N-th block is not a legal block, then the blockchain node cannot perform consensus processing on the (N + K)-th block. Therefore, after the consensus processing of at least the next block of the above-mentioned first block by the above-mentioned target blockchain node is passed, the above-mentioned first state data corresponding to the first block temporarily stored in the second subspace corresponding to the target blockchain node included in the above-mentioned target storage space can be added to the above-mentioned Merkle state tree stored in the first subspace included in the target storage space, so as to ensure that the state data on the Merkle state tree stored in the first subspace are all state data corresponding to legal blocks.
[0109] In an illustrated embodiment, to solve the problem of block fork, for the above-mentioned first state data corresponding to the above-mentioned first block temporarily stored in the second subspace corresponding to the above-mentioned target blockchain node included in the above-mentioned target storage space, the first block at this time can also be compared with the blocks that have passed the consensus processing of at least Quorum blockchain nodes in the above-mentioned blockchain system and have the same block identifier (for example: block height) as the block identifier of the first block, to determine whether the block hash values of the first block and these blocks are all different. If the block hash values of the first block and these blocks are all different, the first block can be determined as a forked block. In this case, the first state data temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space at this time can be marked as the state data corresponding to the forked block.
[0110] For the storage space corresponding to a blockchain node group, the block data stored in the second subspaces corresponding to the respective blockchain nodes in the blockchain node group in this storage space can be as shown in Table 2 below:
[0111] Table 2
[0112] blockchain node the Nth block the (N + 1)th block 1 KV4, KV5 2 KV1’, KV2’, KV3’ (fork block) 3 KV4, KV5 4 KV4, KV5
[0113] Among them, KV1’, KV2’, KV3’, KV4, and KV5 respectively represent five Key-Value key-value pairs. KV1’, KV2’, and KV3’ together constitute the state data corresponding to the forked block, and KV4 and KV5 together constitute the state data corresponding to the (N + 1)-th block.
[0114] It should be noted that the state data corresponding to the forked block temporarily stored in the second subspace is usually not submitted to the first subspace for storage. Moreover, a blockchain node that has temporarily stored the state data corresponding to the forked block in the second subspace can no longer participate in the consensus of subsequent blocks; that is, if this blockchain node has temporarily stored the state data corresponding to the N-th block marked as the forked block in the second subspace, then this blockchain node can no longer perform consensus processing on the (N + K) (K ≥ 1)-th block, and thus will no longer generate the state data corresponding to the (N + K)-th block.
[0115] In an illustrated embodiment, after the consensus processing of at least the next block of the above-mentioned first block by the above-mentioned target blockchain node is passed, it can first be determined whether the above-mentioned first state data corresponding to the first block temporarily stored in the second subspace corresponding to the target blockchain node included in the above-mentioned target storage space is marked as the state data corresponding to the forked block. If the first state data at this time is not marked as the state data corresponding to the forked block, then this first state data can be submitted to the above-mentioned first subspace included in the target storage space.
[0116] Correspondingly, if the above-mentioned first state data at this time is marked as the state data corresponding to the forked block, then this first state data will not be submitted to the above-mentioned first subspace included in the target storage space, but this first state data will be retained in the second subspace corresponding to the target blockchain node included in the target storage space. In this way, it can be ensured that the state data on the Merkle state tree stored in the first subspace included in the target storage space is always the state data corresponding to the legal block.
[0117] More specifically, it is possible to determine whether there is a situation of incorrect update of the Merkle state tree stored in the first subspace included in the target storage space based on the state data corresponding to the forked block by comparing the root hash values corresponding to each blockchain node stored in the second subspaces corresponding to each blockchain node included in the above target storage space with the root hash value of the Merkle state tree stored in the first subspace included in the target storage space.
[0118] In an illustrated implementation manner, for a blockchain node group in the above blockchain system, the second subspaces corresponding to each blockchain node in the blockchain node group included in the storage space of the corresponding storage service can also be used to temporarily store the state data corresponding to the block immediately preceding the latest block that has been consensus-processed by each blockchain node.
[0119] In the case where the above first state data is not added to the Merkle state tree stored in the first subspace included in the target storage space, before adding the first state data to the Merkle state tree stored in the first subspace included in the target storage space and updating the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node included in the target storage space to the root hash value of the updated Merkle state tree, it is possible to first determine whether the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node included in the target storage space is consistent with the root hash value of the Merkle state tree stored in the first subspace included in the target storage space.
[0120] If the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node included in the above target storage space is consistent with the root hash value of the Merkle state tree stored in the first subspace included in the target storage space, it indicates that there is no situation of incorrect update of the Merkle state tree. Therefore, the above first state data can be added to the Merkle state tree stored in the first subspace included in the target storage space, and the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node included in the target storage space can be updated to the root hash value of the updated Merkle state tree.
[0121] However, if the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the above-mentioned target storage space and corresponding to the target blockchain node is inconsistent with the root hash value of the above-mentioned Merkle state tree stored in the first subspace included in the target storage space, it is very likely that there is an incorrect update of the Merkle state tree. In this case, a rollback process can be performed on the Merkle state tree stored in the first subspace included in the target storage space. Specifically, the state data corresponding to the previous block of the above-mentioned first block can be deleted from the Merkle state tree stored in the first subspace included in the target storage space. Also, first, the state data corresponding to the previous block of the first block temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space is added to the Merkle state tree stored in the first subspace included in the target storage space, and the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node included in the target storage space is updated to the root hash value of the updated Merkle state tree. Then, the above-mentioned first state data corresponding to the first block temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space is added to the Merkle state tree stored in the first subspace included in the target storage space, and further, the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node included in the target storage space is updated to the root hash value of the updated Merkle state tree.
[0122] For example, assume that the above-mentioned first block is the Nth block. If the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the above-mentioned target storage space and corresponding to the target blockchain node is inconsistent with the root hash value of the above-mentioned Merkle state tree stored in the first subspace included in the target storage space, then the state data corresponding to the (N - 1)th block can be deleted from the Merkle state tree stored in the first subspace included in the target storage space. Also, first, the state data corresponding to the (N - 1)th block temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space is added to the Merkle state tree stored in the first subspace included in the target storage space, and then the above-mentioned first state data corresponding to the Nth block temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space is added to the Merkle state tree stored in the first subspace included in the target storage space.
[0123] In one of the illustrated embodiments, when the above first state data has been added to the Merkle state tree stored in the first subspace included in the above target storage space, before updating the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node included in the target storage space to the root hash value of the Merkle state tree stored in the first subspace included in the target storage space, it is possible to first determine whether the first state data temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space is consistent with the first state data on the Merkle state tree stored in the first subspace included in the target storage space.
[0124] If the first state data temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space is consistent with the first state data on the Merkle state tree stored in the first subspace included in the target storage space, it indicates that there is no incorrect update of the Merkle state tree. Therefore, it is possible to update the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node included in the target storage space to the root hash value of the Merkle state tree stored in the first subspace included in the target storage space.
[0125] If the first state data temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space is inconsistent with the first state data on the Merkle state tree stored in the first subspace included in the target storage space, it indicates that there is very likely an incorrect update of the Merkle state tree. In this case, it is possible to perform a rollback process on the Merkle state tree stored in the first subspace included in the target storage space. Specifically, it is possible to delete the first state data from the Merkle state tree stored in the first subspace included in the target storage space, and add the first state data temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space to the Merkle state tree stored in the first subspace included in the target storage space, and update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle state tree.
[0126] For example, assume that the above first block is the Nth block. If the first state data temporarily stored in the second subspace corresponding to the target blockchain node included in the above target storage space is inconsistent with the first state data on the Merkle state tree stored in the first subspace included in the target storage space, then the state data corresponding to the Nth block can be deleted from the Merkle state tree stored in the first subspace included in the target storage space, and, the first state data (i.e., the first state data corresponding to the Nth block) temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space can be added to the Merkle state tree stored in the first subspace included in the target storage space, and the root hash value corresponding to the target blockchain node stored in the target storage space can be updated to the root hash value of the updated Merkle state tree.
[0127] In an illustrated embodiment, after storing the state data into the storage space of the storage service deployed within the blockchain node group, each blockchain node in the blockchain node group can also read the state data from the storage space.
[0128] Specifically, the above target blockchain node can respond to a read request for the state data (which can be referred to as the second state data) corresponding to a certain block (which can be referred to as the second block), and read the second block from the above target storage space.
[0129] Further, in an illustrated embodiment, when reading the above second state data from the above target storage space, specifically, it can first be determined whether the second state data has been temporarily stored in the second subspace corresponding to the above target blockchain node included in the target storage space.
[0130] If the second state data has been temporarily stored in the second subspace corresponding to the above target blockchain node included in the above target storage space, then the second state data temporarily stored in the second subspace corresponding to the above target blockchain node included in the above target storage space can be read.
[0131] If the second state data is not stored in the second subspace corresponding to the target blockchain node in the target storage space, the second state data can be read from the Merkle state tree stored in the first subspace of the target storage space. Specifically, it can be further determined whether the second state data has been stored in the Merkle state tree stored in the first subspace of the target storage space; if the second state data has been stored in the Merkle state tree stored in the first subspace of the target storage space, the second state data can be read from the Merkle state tree stored in the first subspace of the target storage space; if the second state data has not been stored in the Merkle state tree stored in the first subspace of the target storage space, a reminder message indicating a failed read can be returned.
[0132] The technical solution provided by this application can be used for storing state data in a blockchain system. In this blockchain system, the blockchain nodes participating in consensus are divided into at least one blockchain node group. The blockchain service platform corresponding to this blockchain system deploys corresponding storage services for each blockchain node group. The storage space of this storage service is used to store the blocks that have been consensus-processed and passed by each blockchain node in the blockchain node group and the indication information corresponding to each blockchain node in the blockchain node group. This indication information is used to indicate the latest block that has been consensus-processed and passed by the blockchain node. When the storage service corresponding to any blockchain node group in this blockchain system stores a block that has been consensus-processed and passed by a certain blockchain node in the blockchain node group, it can first determine whether the block has been stored in the storage space of this storage service. If the block has not been stored in the storage space, the block and the indication information used to indicate that this block is the latest block that has been consensus-processed and passed by the blockchain node can be stored in the storage space. If the block has been stored in the storage space, the indication information corresponding to the blockchain node stored in the storage space can be updated to the indication information used to indicate that this block is the latest block that has been consensus-processed and passed by the blockchain node, and there is no need to store the block in the storage space anymore.
[0133] By adopting the above method, the state data in the blockchain system can be stored through the storage services deployed for each group of blockchain nodes corresponding to them, and duplicate removal processing of the state data stored in the storage space of each storage service is achieved, so that only a full set of state data needs to be stored in the storage space of each storage service, and it is no longer necessary to store a full set of state data on each blockchain node participating in consensus. If N blockchain nodes are divided into X (1≤X≤N) groups of blockchain nodes, then only X full sets of state data need to be stored, and it is no longer necessary to store N full sets of state data, that is, the storage requirement can be reduced to X / N of the original. In this way, the storage cost of the state data in the blockchain system can be reduced, and when a new node joins the blockchain system, only the root hash value set for the new node needs to be adjusted, thereby reducing the time-consuming for the new node to join the blockchain system and achieving the second-level joining of the new node in the blockchain system.
[0134] Corresponding to the embodiment of the method for storing state data in the foregoing blockchain system, the present application also provides an embodiment of a device for storing state data in a blockchain system.
[0135] Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of a device shown in an exemplary embodiment of the present application. At the hardware level, the device includes a processor 602, an internal bus 604, a network interface 606, a memory 608, and a non-volatile memory 610. Of course, other required hardware may also be included. One or more embodiments of the present application can be implemented in a software manner. For example, the processor 602 reads the corresponding computer program from the non-volatile memory 610 into the memory 608 and then runs it. Of course, in addition to the software implementation manner, one or more embodiments of the present application do not exclude other implementation manners, such as a logic device or a combination of software and hardware. That is, the execution subject of the following processing flow is not limited to each logic module, and may also be hardware or a logic device.
[0136] Please refer to Figure 7 , Figure 7 which is a block diagram of a device for storing state data in a blockchain system shown in an exemplary embodiment of the present application.
[0137] The above-mentioned device for storing state data in a blockchain system can be applied to the target storage service corresponding to the target blockchain node group in the blockchain system running on Figure 6 the device shown to implement the technical solution of the present application.
[0138] Among them, the blockchain nodes participating in consensus in the blockchain system are divided into at least one blockchain node group; the blockchain service platform corresponding to the blockchain system deploys corresponding storage services for each blockchain node group; the storage space of the storage service is used to store the Merkle state tree organized by the state data corresponding to the blocks that have been consensus-processed and passed by each blockchain node in the blockchain node group, and the root hash value corresponding to each blockchain node in the blockchain node group; the root hash value is the root hash value of the updated Merkle state tree obtained after adding the state data corresponding to the latest block that has been consensus-processed and passed by its corresponding blockchain node to the Merkle state tree.
[0139] The device includes:
[0140] An acquisition unit 702, which acquires a storage request for first state data corresponding to the first block sent by a target blockchain node in the target blockchain node group in response to the consensus processing and passing of the first block;
[0141] A determination unit 704, which, in response to the storage request, determines whether the first state data has been added to the Merkle state tree stored in the target storage space of the target storage service;
[0142] A storage unit 706, if the first state data has not been added to the Merkle state tree, adds the first state data to the Merkle state tree stored in the target storage space, and updates the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle state tree;
[0143] An update unit 708, if the first state data has been added to the Merkle state tree, updates the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle state tree stored in the target storage space.
[0144] In an illustrated embodiment, the blockchain service platform is a BaaS platform; the storage space is a cloud storage space.
[0145] In an illustrated embodiment, the storage space includes a first subspace for storing the Merkle state tree organized by state data, and a second subspace corresponding to each blockchain node in the blockchain node group; the second subspace is used to store the root hash value corresponding to each blockchain node;
[0146] Add the first state data to the Merkle state tree stored in the target storage space, and update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle state tree, including:
[0147] Add the first state data to the Merkle state tree stored in the target storage space, and update the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node to the root hash value of the updated Merkle state tree;
[0148] Update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle state tree stored in the target storage space, including:
[0149] Update the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node to the root hash value of the Merkle state tree stored in the target storage space.
[0150] In an illustrated embodiment, the second subspaces corresponding to the respective blockchain nodes in the blockchain node group included in the storage space are further used to temporarily store the state data corresponding to the latest block that has been consensus processed by the respective blockchain nodes;
[0151] Add the first state data to the Merkle state tree stored in the target storage space, including:
[0152] Temporarily store the first state data in the second subspace corresponding to the target blockchain node, and after the target blockchain node passes the consensus processing for at least the next block of the first block, add the first state data temporarily stored in the second subspace corresponding to the target blockchain node to the Merkle state tree stored in the first subspace.
[0153] In an illustrated embodiment, add the first state data to the Merkle state tree stored in the target storage space, and update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle state tree, including:
[0154] Determine whether the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node is consistent with the root hash value of the Merkle state tree stored in the first subspace;
[0155] If the two are consistent, add the first state data to the Merkle state tree stored in the first subspace, and update the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node to the root hash value of the updated Merkle state tree.
[0156] In an illustrated embodiment, adding the first state data to the Merkle state tree stored in the target storage space, and updating the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle state tree further includes:
[0157] If the two are inconsistent, delete the state data corresponding to the previous block of the first block from the Merkle state tree stored in the first subspace, and sequentially add the state data corresponding to the previous block of the first block temporarily stored in the second subspace corresponding to the target blockchain node and the first state data to the Merkle state tree stored in the first subspace, and update the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node to the root hash value of the updated Merkle state tree.
[0158] In an illustrated embodiment, updating the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle state tree stored in the target storage space includes:
[0159] Determine whether the first state data temporarily stored in the second subspace corresponding to the target blockchain node is consistent with the first state data on the Merkle state tree stored in the first subspace;
[0160] If the two are consistent, update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle state tree stored in the target storage space.
[0161] In an illustrated embodiment, updating the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle state tree stored in the target storage space further includes:
[0162] If they are inconsistent, delete the first state data from the Merkle state tree stored in the first subspace, add the first state data temporarily stored in the second subspace corresponding to the target blockchain node to the Merkle state tree stored in the first subspace, and update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle state tree.
[0163] In an illustrated embodiment, the apparatus further includes:
[0164] A reading unit, in response to a reading request for second state data corresponding to a second block sent by the target blockchain node, reads the second state data from the target storage space.
[0165] In an illustrated embodiment, reading the second state data from the target storage space includes:
[0166] Determine whether the second state data has been temporarily stored in the second subspace corresponding to the target blockchain node;
[0167] If the second state data has been temporarily stored, read the second state data temporarily stored in the second subspace corresponding to the target blockchain node;
[0168] If the second state data has not been temporarily stored, read the second state data from the Merkle state tree stored in the first subspace.
[0169] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software improvements (improvements to method flows). However, with the development of technology, many method flow improvements today can be regarded as direct improvements to hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement to a method flow cannot be implemented using a hardware entity module. For example, a Programmable Logic Device (PLD) (e.g., a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logical function is determined by the user programming the device. Designers can program themselves to "integrate" a digital system onto a single PLD, without having to ask a chip manufacturer to design and fabricate a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing. The original code before compilation also has to be written in a specific programming language, which is called a Hardware Description Language (HDL), and there is not just one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones currently are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also be aware that by simply performing a little logical programming on the method flow using the above-mentioned several hardware description languages and programming it into an integrated circuit, it is easy to obtain the hardware circuit that implements the logical method flow.
[0170] The controller can be implemented in any suitable manner. For example, the controller can take the form of, for example, a microprocessor or a processor and a computer-readable medium storing computer-readable program code (such as software or firmware) executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of the controller include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, it is entirely possible to make the controller implement the same function in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be regarded as the structures within the hardware component. Or even, the devices for implementing various functions can be regarded as either software modules for implementing the method or the structures within the hardware component.
[0171] The systems, devices, modules, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not exclude that with the development of future computer technologies, the computers for implementing the functions of the above embodiments can be, for example, personal computers, laptop computers, in-vehicle human-machine interaction devices, cellular phones, camera phones, smart phones, personal digital assistants, media players, navigation devices, email devices, game consoles, tablet computers, wearable devices, or any combination of these devices.
[0172] Although one or more embodiments of the present application provide method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiments is only one way among the execution orders of numerous steps and does not represent the only execution order. When the actual device or terminal product is executed, it may be executed in the order shown in the embodiments or the drawings or in parallel (for example, in an environment of parallel processors or multi-threaded processing, or even in a distributed data processing environment). The terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, product or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or also includes elements inherent to such process, method, product or device. Without further limitation, there is no exclusion of additional identical or equivalent elements in the process, method, product or device comprising the said elements. For example, if terms such as first and second are used to denote names, they do not denote any particular order.
[0173] For convenience of description, when describing the above device, it is divided into various modules according to functions and described separately. Of course, when implementing one or more of the present application, the functions of each module may be implemented in the same or multiple software and / or hardware, or the modules implementing the same function may be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the couplings or direct couplings or communication connections shown or discussed with each other may be through some interfaces, and the indirect couplings or communication connections of the devices or units may be in electrical, mechanical or other forms.
[0174] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0175] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction device that implements the functions specified in one or more processes and / or blocks Figure 1 in one or more processes and / or blocks Figure 1 specified in the function.
[0176] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes and / or blocks Figure 1 in one or more processes and / or blocks Figure 1 specified in the function.
[0177] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0178] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
[0179] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology for information storage. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage, graphene storage, or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.
[0180] Those skilled in the art should understand that one or more embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, one or more embodiments of the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, one or more embodiments of the present application can take 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.) that contain computer-usable program code.
[0181] One or more embodiments of the present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present application can also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0182] The various embodiments in the present application are described in a progressive manner. For the same or similar parts among the various embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and reference can be made to the relevant parts of the method embodiments for the related content. In the description of the present application, the description of reference terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present application, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in the present application and the features of different embodiments or examples.
[0183] The above description is only for the embodiments of one or more embodiments of the present application and is not intended to limit one or more embodiments of the present application. For those skilled in the art, one or more embodiments of the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims.
[0184] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data that have been authorized by the user or fully authorized by all parties. Moreover, the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or reject.
Claims
1. A method for storing state data in a blockchain system; wherein: The blockchain nodes participating in the consensus in the blockchain system are divided into at least one blockchain node group; the blockchain service platform corresponding to the blockchain system deploys corresponding storage services for each blockchain node group; the storage space of the storage service is used to store a Merkle state tree organized by state data corresponding to blocks that have been processed by consensus by each blockchain node in the blockchain node group, and a root hash value corresponding to each blockchain node in the blockchain node group; the root hash value is the root hash value of the updated Merkle state tree obtained by the blockchain node corresponding to it after adding the state data corresponding to the latest block that has been processed by consensus to the Merkle state tree; The method is applied to a target storage service corresponding to a target blockchain node group in the blockchain system, including: Obtaining a storage request for first state data corresponding to the first block, sent by a target blockchain node in the target blockchain node group in response to passing a consensus process on the first block; In response to the storage request, determining whether the first state data has been added to the Merkle state tree stored in the target storage space of the target storage service; If the first state data has not been added to the Merkle state tree, add the first state data to the Merkle state tree stored in the target storage space, and update the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle state tree; If the first state data has been added to the Merkle state tree, the root hash value corresponding to the target blockchain node stored in the target storage space is updated to the root hash value of the Merkle state tree stored in the target storage space.
2. According to the method according to claim 1, the blockchain service platform is a BaaS platform; and the storage space is a cloud storage space.
3. The method according to claim 1, wherein the storage space comprises a first subspace for storing a Merkle state tree organized by state data, and a second subspace corresponding to each blockchain node in the blockchain node group; The second subspace is used to store the root hash value corresponding to each blockchain node; Adding the first state data to the Merkle state tree stored in the target storage space, and updating the root hash value corresponding to the target blockchain node stored in the target storage space to the updated root hash value of the Merkle state tree, including: Adding the first state data to the Merkle state tree stored in the target storage space, and updating the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node to the updated root hash value of the Merkle state tree; Updating the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle state tree stored in the target storage space, comprising: Update the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node to the root hash value of the Merkle state tree stored in the target storage space.
4. According to the method of claim 3, the second subspace corresponding to each blockchain node in the blockchain node group contained in the storage space is also used to temporarily store the status data corresponding to the latest block that has been processed by consensus by each blockchain node; Adding the first state data to the Merkle state tree stored in the target storage space includes: The first state data is temporarily stored in the second subspace corresponding to the target blockchain node, and after the target blockchain node passes the consensus processing of at least the next block of the first block, the first state data temporarily stored in the second subspace corresponding to the target blockchain node is added to the Merkle state tree stored in the first subspace.
5. The method according to claim 4, adding the first state data to the Merkle state tree stored in the target storage space, and updating the root hash value corresponding to the target blockchain node stored in the target storage space to the updated root hash value of the Merkle state tree, comprising: Determine whether the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node is consistent with the root hash value of the Merkle state tree stored in the first subspace; If the two are consistent, the first state data is added to the Merkle state tree stored in the first subspace, and the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node is updated to the root hash value of the updated Merkle state tree.
6. The method according to claim 5, further comprising: If the two are inconsistent, the state data corresponding to the previous block of the first block is deleted from the Merkle state tree stored in the first subspace, and the state data corresponding to the previous block of the first block temporarily stored in the second subspace corresponding to the target blockchain node and the first state data are added to the Merkle state tree stored in the first subspace in sequence, and the root hash value corresponding to the target blockchain node stored in the second subspace corresponding to the target blockchain node is updated to the root hash value of the updated Merkle state tree.
7. The method according to claim 4, updating the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle state tree stored in the target storage space, comprising: Determine whether the first state data temporarily stored in the second subspace corresponding to the target blockchain node is consistent with the first state data on the Merkle state tree stored in the first subspace; If the two are consistent, the root hash value corresponding to the target blockchain node stored in the target storage space is updated to the root hash value of the Merkle state tree stored in the target storage space.
8. The method according to claim 7, further comprising: If the two are inconsistent, the first state data is deleted from the Merkle state tree stored in the first subspace, and the first state data temporarily stored in the second subspace corresponding to the target blockchain node is added to the Merkle state tree stored in the first subspace, and the root hash value corresponding to the target blockchain node stored in the target storage space is updated to the root hash value of the updated Merkle state tree.
9. The method according to claim 3, further comprising: In response to a read request sent by the target blockchain node for second state data corresponding to a second block, the second state data is read from the target storage space.
10. The method according to claim 9, reading the second state data from the target storage space comprises: Determining whether the second state data has been temporarily stored in the second subspace corresponding to the target blockchain node; If the second state data has been temporarily stored, read the second state data temporarily stored in the second subspace corresponding to the target blockchain node; If the second state data is not temporarily stored, the second state data is read from the Merkle state tree stored in the first subspace.
11. A state data storage device in a blockchain system; wherein: The blockchain nodes participating in the consensus in the blockchain system are divided into at least one blockchain node group; the blockchain service platform corresponding to the blockchain system deploys corresponding storage services for each blockchain node group; the storage space of the storage service is used to store a Merkle state tree organized by state data corresponding to blocks that have been processed by consensus by each blockchain node in the blockchain node group, and a root hash value corresponding to each blockchain node in the blockchain node group; the root hash value is the root hash value of the updated Merkle state tree obtained by the blockchain node corresponding to it after adding the state data corresponding to the latest block that has been processed by consensus to the Merkle state tree; The device is applied to a target storage service corresponding to a target blockchain node group in the blockchain system, including: An acquiring unit, acquiring a storage request for first state data corresponding to the first block, sent by a target blockchain node in the target blockchain node group in response to consensus processing of the first block being passed; a determining unit, in response to the storage request, determining whether the first state data has been added to the Merkle state tree stored in the target storage space of the target storage service; The storage unit adds the first state data to the Merkle state tree stored in the target storage space if the first state data has not been added to the Merkle state tree, and updates the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the updated Merkle state tree; An updating unit, if the first state data has been added to the Merkle state tree, updates the root hash value corresponding to the target blockchain node stored in the target storage space to the root hash value of the Merkle state tree stored in the target storage space.
12. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 10 by running the executable instructions.
13. A computer-readable storage medium having computer instructions stored thereon, wherein when the instructions are executed by a processor, the method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Shared blockchain data storage
CN111448781A
Block chain state storage method, block chain state verification method and block chain node
CN116049170A
Method and apparatus for storing blockchain state data and electronic device
US20200167345A1
Updating a state merkle tree
US20210067321A1
Document verification
US20210248272A1