Block data storage method and apparatus in a blockchain system
By grouping blockchain nodes and deploying storage services in each group, deduplication of block data in the blockchain system is achieved, reducing storage costs and accelerating the addition of new nodes, thus solving the problem of low storage efficiency in the blockchain system.
Patent Information
- Application Number
- CN202510125525.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-26
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-01-26
AI Technical Summary
The high cost of storing block data and state data in blockchain systems, coupled with the long time required for new nodes to join, results in low storage efficiency.
The blockchain nodes are divided into groups, and a storage service is deployed for each group. The storage service performs deduplication internally, storing only one copy of the full block data in each storage service, and maintaining a pointer to the latest block for each blockchain node, thus reducing redundant storage.
This reduces the storage cost of the blockchain system, and new nodes can join the system within seconds, improving storage efficiency and the speed at which new nodes can join.
Smart Images

Figure CN119967003B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] One or more embodiments of the present application relate to the field of blockchain technology, in particular to a block data storage method and device in a blockchain system. BACKGROUND
[0002] Blockchain is a new application mode of distributed data storage, peer-to-peer transmission, consensus protocol, and encryption algorithm. In a blockchain system, data blocks are combined into a chain-like data structure in a sequential manner according to time sequence, and a distributed ledger is ensured to be tamper-proof and unforgeable by means of cryptography. Due to the characteristics of decentralization, information tamper-proofing, and autonomy, the application of blockchain is becoming more and more widespread.
[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 block data and N copies of full state data. As the blockchain system continues to run, the data volume of block data and state data will become larger and larger, so the storage cost of block data will also become higher and higher. In addition, if a new node is to be added, the full block data and full state data need to be copied to the node, which usually takes a long time. SUMMARY
[0004] One or more embodiments of the present application provide technical solutions as follows:
[0005] The present application provides a block data storage method 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 blockchain service platform corresponding to the blockchain system deploys a corresponding storage service for each blockchain node group; the storage space of the storage service is used to store the blocks that have passed consensus processing of each blockchain node in the blockchain node group, and the indication information corresponding to each blockchain node in the blockchain node group; the indication information is used to indicate the latest block that has passed consensus processing of the corresponding blockchain node;
[0006] The method is applied to a target storage service corresponding to a target blockchain node group in the blockchain system, and includes:
[0007] Obtaining a storage request corresponding to a first block sent by a target blockchain node in the target blockchain node group in response to passing consensus processing of the first block;
[0008] In response to the storage request, determining whether the first block has been stored in the target storage space of the target storage service;
[0009] if the first block is not stored in the target storage space, storing the first block and indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node into the target storage space;
[0010] if the first block is stored in the target storage space, updating the indication information corresponding to the target blockchain node and stored in the target storage space to indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node.
[0011] The application further provides a block 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; a blockchain service platform corresponding to the blockchain system deploys a corresponding storage service for each blockchain node group; the storage space of the storage service is used to store the blocks that have passed the consensus processing of each blockchain node in the blockchain node group, and indication information corresponding to each blockchain node in the blockchain node group; the indication information is used to indicate the latest block that has passed the consensus processing of the corresponding blockchain node;
[0012] The device is applied to a target storage service corresponding to a target blockchain node group in the blockchain system, and comprises:
[0013] an obtaining unit that obtains a storage request 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;
[0014] a determination unit that determines whether the first block has been stored in a target storage space of the target storage service in response to the storage request;
[0015] a storage unit that, if the first block is not stored in the target storage space, stores the first block and indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node into the target storage space;
[0016] an updating unit that, if the first block is stored in the target storage space, updates the indication information corresponding to the target blockchain node and stored in the target storage space to indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node.
[0017] The application further provides an electronic device, comprising:
[0018] a processor;
[0019] a memory for storing processor-executable instructions;
[0020] wherein the processor implements the steps of the method of any of the above by executing the executable instructions.
[0021] The application also provides a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method of any of the above.
[0022] In the above technical solution, the blockchain nodes participating in 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 a corresponding storage service for each blockchain node group, the storage space of the storage service is used to store the blocks that have passed consensus processing of each blockchain node in the blockchain node group and the indication information corresponding to each blockchain node in the blockchain node group, and the indication information is used to indicate the latest block that has passed consensus processing of the blockchain node; when storing the block that has passed consensus processing of a certain blockchain node in the blockchain node group, the storage service corresponding to any blockchain node group in the blockchain system can first determine whether the block has been stored in the storage space of the storage service, if the block has not been stored in the storage space, the block and the indication information indicating that the block is the latest block that has passed consensus processing of the blockchain node can be stored in the storage space, and 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 indicating that the block is the latest block that has passed consensus processing of the blockchain node, and the block does not need to be stored in the storage space any more.
[0023] In the above manner, the block data in the blockchain system can be stored through the storage service corresponding to each blockchain node group, and the deduplication processing of the block data stored in the storage space of each storage service is implemented, so that only one full amount of block data needs to be stored in the storage space of each storage service, and one full amount of block data does not need to be stored on each blockchain node participating in consensus. If N blockchain nodes are divided into X (1≤X≤N) blockchain node groups, only X full amounts of block data need to be stored, and N full amounts of block data do not need to be stored, that is, the storage demand can be reduced to X / N of the original. In this way, the storage cost of the block data in the blockchain system can be reduced, and when a new node joins the blockchain system, only the indication information set for the new node needs to be adjusted, so that the time consumption of the new node joining the blockchain system can be reduced, and the new node can be added to the blockchain system in seconds. BRIEF DESCRIPTION OF DRAWINGS
[0024] The following will be described in the description of the exemplary embodiments using the accompanying drawings needed, in which:
[0025] Figure 1 is a schematic diagram of a blockchain system according to an exemplary embodiment of the present application.
[0026] Figure 2 is a schematic diagram of a deployment architecture of a blockchain storage service according to an exemplary embodiment of the present application.
[0027] Figure 3 is a schematic diagram of another deployment architecture of a blockchain storage service according to an exemplary embodiment of the present application.
[0028] Figure 4 is a schematic diagram of another deployment architecture of a blockchain storage service according to an exemplary embodiment of the present application.
[0029] Figure 5 is a flowchart of a method for storing block data in a blockchain system according to an exemplary embodiment of the present application.
[0030] Figure 6 is a schematic diagram of a structure of an apparatus according to an exemplary embodiment of the present application.
[0031] Figure 7 is a block diagram of a block data storage device in a blockchain system according to an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0032] The exemplary embodiments will be described in detail below with reference to the accompanying drawings. In the following description, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments represent merely examples consistent with the present application and do not represent all implementations consistent with the present application. Rather, they merely attempt to provide a full and enabling disclosure of some aspects of the present application.
[0033] It is noted that the steps of the methods in other embodiments are not necessarily performed in the order shown and described in the present application. In some other embodiments, the steps included in the methods can be more or less than those described in the present application. Furthermore, a single step described in the present application can be broken down into multiple steps in other embodiments; and multiple steps described in the present application can be combined into a single step in other embodiments.
[0034] Blockchain is generally divided into three types: public blockchain, private blockchain and consortium blockchain. In addition, there can be a combination of the above types, such as a combination of private blockchain and consortium blockchain, a combination of consortium blockchain and public blockchain, etc.
[0035] Among the above three types of blockchains, the public blockchain has the highest degree of decentralization. Participants (also known as nodes in the blockchain) who join the public blockchain can read 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 related operations.
[0036] On the contrary, the private blockchain has its write permissions controlled by an organization (or an entity) and its data read permissions regulated by the organization. That is, the private blockchain can be regarded as a weakly centralized system with strict restrictions on nodes and a small number of nodes. This type of blockchain is more suitable for use within a specific organization.
[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); the nodes join the network by authorization and form an interest-related consortium to jointly maintain the operation of the blockchain.
[0038] Please refer to Figure 1 , Figure 1 is a schematic diagram of a blockchain system according to an example embodiment of the present application.
[0039] As shown in Figure 1 , the blockchain system can maintain one or more blockchains (e.g., public blockchain, private blockchain, consortium blockchain, etc.) and can include multiple nodes for carrying the one or more blockchains; for example, nodes 1, 2, 3, 4, i, etc. as shown in Figure 1 may jointly carry one or more blockchains. Cross-chain data access can also be performed between the blockchains included in each blockchain system and between the blockchain systems.
[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 embodiment shown, 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 hardware resources of a server or a server cluster based on virtualization technology. Each node can be coupled together to form a network through various types of communication methods (e.g., TCP / IP, etc.) to carry one or more blockchains.
[0041] Based on the basic characteristics of a blockchain, a blockchain is usually composed of a plurality of blocks. In these blocks, there are respectively recorded timestamps corresponding to the time when the block is created. All blocks strictly form a chronological data chain according to the timestamps recorded in the blocks.
[0042] For data generated outside the blockchain, the data can be structured into a standard transaction format supported by the blockchain, and then published to the blockchain. The nodes participating in consensus in the blockchain system perform consensus on the transaction, and execute the transaction after the consensus is completed, so that the transaction and the execution result can be persisted in the blockchain.
[0043] In a blockchain system, different participants can establish a distributed blockchain network through the nodes deployed by the participants. In actual applications, the connection relationship between each node and different nodes can be regarded as a blockchain network, and the connection relationship, data interaction, etc. between each node and different nodes can be regarded as a blockchain system. A decentralized (or multi-centralized) distributed ledger constructed by a chain structure is stored on each node (or most nodes, such as consensus nodes) in the distributed blockchain network. Such a blockchain system needs to solve the consistency and correctness of the ledger data on each node of the decentralized (or multi-centralized) nodes. Each node in the blockchain system runs a blockchain program, and under a certain fault tolerance requirement, the consensus protocol is used to ensure that all loyal nodes have the same transaction, so that the execution results of the same transaction by all loyal nodes are consistent, and the transaction and the execution result are packaged to generate a block.
[0044] The nodes in the blockchain system can usually be divided into consensus nodes and non-consensus nodes. The consensus nodes are nodes running a consensus protocol. The non-consensus nodes can forward the transactions received from 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 the consensus nodes and the non-consensus nodes can store the blocks.
[0045] Specifically, the consensus nodes in the blockchain system can reach consensus on the transactions contained in a new block to be connected to the chain structure based on a consensus protocol, so as to ensure that the consensus nodes reach consensus on the transactions contained in the block in terms of content and order, thereby realizing the construction of the block. After the consensus is completed, the consensus nodes can send the constructed block to other nodes, so that each node executes the transactions contained in the block in order, and completes the finalization of the block in the case that the transaction execution results of each node are consistent. The finalization refers to that the transactions contained 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] After each consensus node in the blockchain system executes the transactions contained in a block that has completed consensus, it can broadcast a message, which can indicate that the block has completed consensus and the transactions contained in the block have been executed. Therefore, according to the message, it can be determined whether the transaction execution results of each consensus node for the block are consistent, so that the finalization of the block can be completed in the case that the transaction execution results of each consensus node are consistent.
[0047] In the blockchain, the block height is the number of blocks connected in the chain structure. However, for any block in the blockchain, the block height of the block can be used as an identifier of the block. A block is usually considered to have two identifiers, one of which is the hash value of the block header, and the other of which is the block height. The hash value of the block header is obtained by performing a secondary hash calculation on the block header by using the SHA256 algorithm or the like; 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 definite and fixed block height, but a block height does not always identify a unique block, and two or more blocks can have the same block height, i.e., compete for the same position in the blockchain. The blocks in the blockchain are usually connected in the chain structure in time sequence, i.e., the chain structure is actually a chain in time order. In this case, the block height is usually set to an increasing value. For example, assuming that the block height of the last block that has completed finalization 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, the blocks with block heights in the interval [h+1, h+L] can be consensused.
[0049] In practical applications, the blockchain data that needs to be stored and maintained usually includes block data and state data. The information contained 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] The block data can include block header and block body; the block header contains the metadata of the block, such as the hash value of the previous block, the timestamp, the difficulty target, the random number, etc.; the block body contains the transaction list. The block data is the history record of the blockchain, which is arranged in chronological order, and each new block contains the hash value of the previous block, thereby forming a chain. This structure ensures that it is very difficult to tamper with the data once it is added to the blockchain, because any change to the block data will cause the hash value of all subsequent blocks to change.
[0051] The state data can include account balance, contract code and storage data; the contract code and storage data refer to the running logic of the smart contract and the storage information related thereto. The state data reflects the results of all historical transactions and operations, and is a snapshot of the blockchain system at a specific time point. It has the inherent complexity and security features of blockchain technology. The state data is dynamic and will be updated as new transactions are confirmed and added to the blockchain.
[0052] The update of the block data and the state data is very close in time, so it can be considered that it is completed in the same round of operation. Specifically, the update of the state data occurs after the block is accepted by the consensus algorithm, and then it is recorded as part of the block. Therefore, it can be considered that the update of the state data follows the update of the block data, and the two are closely connected.
[0053] In the blockchain system, the block data and the state data on each node need to be consistent, which 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 volume of the block data and the state data will become larger and larger, so the storage cost of the block data will also become higher and higher. In addition, if a new node is to be added, the full block data and the full state data need to be copied to the node, which usually takes a long time.
[0054] One or more embodiments of the present application provide a technical solution for implementing block data storage in a blockchain system to reduce the storage cost of block data in the blockchain system and reduce the time consumption of a new node joining the blockchain system, and realize the second-level joining of the new node in the blockchain system.
[0055] In the above technical solution, the blockchain nodes participating in 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 a corresponding storage service for each blockchain node group. The storage space of the storage service is used to store the blocks that have passed the consensus processing of each blockchain node in the blockchain node group and the indication information corresponding to each blockchain node in the blockchain node group. The indication information is used to indicate the latest block that has passed the consensus processing of the blockchain node. When the storage service corresponding to any blockchain node group in the blockchain system stores the block that has passed the consensus processing of a certain blockchain node in the blockchain node group, it can first determine whether the block has been stored in the storage space of the storage service. If the block is not stored in the storage space, the block and the indication information indicating that the block is the latest block that has passed the consensus processing of 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 indicating that the block is the latest block that has passed the consensus processing of the blockchain node, and the block no longer needs to be stored in the storage space.
[0056] The technical solution is based on abstracting the block data storage of the blockchain system as a basic capability, referred to as a blockchain storage service. All blockchain nodes (in this application, the blockchain nodes can be consensus nodes) in the blockchain system can be divided into different blockchain node groups (Regions) according to the dimensions of enterprises, institutions or regions to which they belong. And the blockchain service platform corresponding to the blockchain system can deploy a corresponding storage service for each blockchain node group. All blockchain nodes in the blockchain node group can share the storage service, and the storage service only provides block data storage services for the blockchain nodes in the blockchain node group. These storage services together form a blockchain storage service corresponding to the blockchain system, which 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 the blockchain node group is determined by the actual demand, and the number of blockchain nodes in each blockchain node group can be arbitrary. That is, each blockchain node can be regarded as an independent blockchain node group, all blockchain nodes can be regarded as a blockchain node group, or different blockchain node groups can have different numbers of blockchain nodes.
[0057] Each blockchain node can apply for storage space from the storage service deployed in the blockchain node group to which it belongs when initializing, and the storage service can divide an independent storage subspace for the blockchain node from its storage space. The blockchain storage service ensures that the storage subspace corresponding to each blockchain node is isolated from each other, and each blockchain node can only read and write block data in its own storage subspace, but cannot read and write block data in the storage subspace corresponding to other blockchain nodes. For example, the isolation of the storage subspace can be realized through the node identifier of the blockchain node, that is, each blockchain node can carry its own node identifier in the storage request or read request it initiates, so that the block data is stored in the storage subspace corresponding to the blockchain node, or the block data is read from the storage subspace corresponding to the blockchain node, thereby realizing the isolation of the storage subspace of different blockchain nodes.
[0058] In the storage space of each storage service, a shared storage sub-space can also be divided. The shared storage sub-space can be shared by all blockchain nodes in the blockchain node group corresponding to the storage service, and the block data that has been consensus-processed by the majority of blockchain nodes in the blockchain system can be stored in the shared storage sub-space. Specifically, the block data that has been consensus-processed by the blockchain nodes can be first stored in the storage sub-space of the blockchain node, and after the consensus processing of the majority of blockchain nodes in the blockchain system is passed, the block data can be submitted to the shared storage sub-space for storage. Wherein, the set of a certain number of replicas required to ensure the data consistency requirement and fault tolerance requirement of all replicas is generally a set of the majority of nodes in the distributed system, that is, the Quorum.
[0059] In addition, within the same storage service, the block data requested to be stored by each blockchain node in the blockchain node group corresponding to the storage service can be de-duplicated.
[0060] From the perspective of each blockchain node in the blockchain system, the storage service corresponding to the blockchain node group in which the blockchain node is located can be regarded as a storage service that provides the blockchain node with block data alone, and the storage service stores the full amount of block data of the blockchain node, and the blockchain node has no awareness of the block data that has been de-duplicated within the storage service.
[0061] Moreover, since the above de-duplication processing is performed within the storage service, from the perspective of the outside of the blockchain system, it is actually the storage or reading of block data in the storage space of the blockchain.
[0062] Specifically, according to the characteristics of the block data on each blockchain node in the blockchain system, within the same storage service, the block data requested to be stored by each blockchain node in the blockchain node group corresponding to the storage service can be de-duplicated.
[0063] Wherein, the characteristics of the block data on each blockchain node in the blockchain system include: the block data on each blockchain node must be the same; if there is different block data, it must be a fork; at a certain moment, the consensus progress of the block data of each blockchain node can be inconsistent, for example, the consensus progress of the block data of some blockchain nodes is at the 100th block, and the consensus progress of the block data of some blockchain nodes is at the 105th block.
[0064] Overall, the above technical solution is to keep only one full block data in each storage service; at the same time, a pointer is maintained for each blockchain node in the blockchain node group corresponding to the storage service, pointing to the location of the latest block that the blockchain node has consensus processed in the full block data. For a blockchain node in the blockchain node group, the blockchain node can request the storage service to store the block data after the block is processed by consensus. In the process of storing the block data, the storage service can first check whether the same block data has been stored in the storage space of the storage service. If the same block data has not been stored in the storage space of the storage service, the storage service can obtain the block data from the blockchain node and store the block data in the storage space of the storage service to add the block data to the full block data; if the same block data has been stored in the storage space of the storage service, the pointer corresponding to the blockchain node is updated so that the pointer points to the location of the same block data in the full block data, and the block data does not need to be stored in the storage space of the storage service or obtained from the blockchain node. Correspondingly, the blockchain node only reads the block data in the range before the location pointed to by the pointer corresponding to the blockchain node when reading the block data through the storage service.
[0065] In the above manner, the block data in the blockchain system is stored by deploying corresponding storage services for each blockchain node group, and the deduplication of the block data is automatically performed in each storage service, so that only one full block data needs to be stored in each storage service, and one full block data no longer needs to be stored on each blockchain node. If N blockchain nodes are divided into X(1≤X≤N) blockchain node groups, only X full block data needs to be stored, and N full block data no longer needs to be stored, i.e., the storage demand is reduced to X / N of the original. In this way, the storage cost of the block data in the blockchain system can be reduced, and when a new node joins the blockchain system, only the indication information set for the new node needs to be adjusted, thereby reducing the time consumption of the new node joining the blockchain system, and realizing the second-level joining of the new node in the blockchain system.
[0066] The deployment architecture of the blockchain storage service in the technical solution provided by the present application will be described first, and then the block data storage method in the blockchain system in which the blockchain storage service is deployed will be described in detail.
[0067] (1) Deployment architecture of blockchain storage service
[0068] In this application, the storage service corresponding to the blockchain system can be simply referred to as a blockchain storage service, which can be a distributed storage service providing data storage services for the blockchain system. In actual application, the blockchain storage service can be a cloud service relying on a cloud disk to provide data storage services for the blockchain system, that is, uploading the blockchain data to the cloud disk for storage; or the blockchain storage service can also rely on a mechanical hard disk, a solid state disk or other storage media to provide data storage services for the blockchain system, that is, storing the blockchain data in such storage media.
[0069] There are three possible forms of deployment architecture of the blockchain storage service:
[0070] In one possible form, all the blockchain nodes in a blockchain system can be divided into a plurality of 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 in each blockchain node group, and this actually means that a storage service is deployed for each blockchain node. In the storage space of each storage service, there can be an independent storage sub-space divided for a blockchain node in the blockchain node group corresponding to the storage service, and a shared storage sub-space. These independent storage services collectively constitute the blockchain storage service corresponding to the blockchain system.
[0071] For example, as shown in Figure 2 , four blockchain nodes in a blockchain system are divided into four blockchain node groups, and there is only one blockchain node in each blockchain node group. A storage service is deployed in 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 sub-space 1 in the storage service 1, and the storage space of the storage service 1 can also include a shared storage sub-space; the blockchain node 2 in the blockchain node group 2 can use the storage sub-space 1 in the storage service 2, and the storage space of the storage service 2 can also include a shared storage sub-space; the blockchain node 3 in the blockchain node group 3 can use the storage sub-space 1 in the storage service 3, and the storage space of the storage service 3 can also include a shared storage sub-space; the blockchain node 4 in the blockchain node group 4 can use the storage sub-space 1 in the storage service 4, and the storage space of the storage service 4 can also include a shared storage sub-space; and so on.
[0072] In another possible scenario, all blockchain nodes in a blockchain system can be divided into a blockchain node group. Therefore, a blockchain node group can contain multiple blockchain nodes. In this case, 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 into multiple independent storage subspaces, allowing different blockchain nodes within the group to use different storage subspaces within this storage service. Furthermore, this storage space can also include a shared storage subspace shared by all blockchain nodes in the group. This storage service itself constitutes the blockchain storage service corresponding to that blockchain system.
[0073] For example, such as Figure 3 As shown, the four blockchain nodes in the blockchain system are divided into a blockchain node group, which contains a total of four blockchain nodes. 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 subspace 1 within storage service 1; blockchain node 2 in blockchain node group 1 can use storage subspace 2 within storage service 1; blockchain node 3 in blockchain node group 1 can use storage subspace 3 within storage service 1; blockchain node 4 in blockchain node group 1 can use storage subspace 4 within storage service 1; the storage space of storage service 1 can also include a shared storage subspace shared by blockchain nodes 1, 2, 3, and 4 in blockchain node group 1; and so on.
[0074] In still another possible form, all blockchain nodes in a blockchain system can be divided into a plurality of 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, or there can be a plurality of blockchain nodes in a blockchain node group. At this time, a storage service can be deployed in each blockchain node group, and all blockchain nodes in the same blockchain node group can share the storage service deployed in the blockchain node group. However, it should be noted that the entire storage space used by the storage service deployed in each blockchain node group can be partitioned to divide the storage space into a plurality of storage subspaces, so that different blockchain nodes in the same blockchain node group can use different storage subspaces in the storage service deployed in the blockchain node group. In addition, in the storage space of each storage service, there can also be a shared storage subspace shared by all blockchain nodes in the blockchain node group corresponding to the storage service. These independent storage services collectively constitute the blockchain storage service corresponding to the blockchain system.
[0075] 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 the blockchain node group 1, there are four blockchain nodes in the blockchain node group 2, and there are two blockchain nodes in the blockchain node group 3. A storage service is deployed in each blockchain node group. That is, one storage service is deployed for the one blockchain node in the blockchain node group 1; one storage service is deployed for the four blockchain nodes in the blockchain node group 2, and the four blockchain nodes can share the storage service; one storage service is deployed for the two blockchain nodes in the blockchain node group 3, and the two blockchain nodes can share the storage service. 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 further 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, the blockchain node 3 in the blockchain node group 2 can use the storage subspace 2 in the storage service 2, the blockchain node 4 in the blockchain node group 2 can use the storage subspace 3 in the storage service 2, the blockchain node 5 in the blockchain node group 2 can use the storage subspace 4 in the storage service 2, and the storage space of the storage service 2 can further include a shared storage subspace shared by the blockchain node 2, the blockchain node 3, the blockchain node 4, and the blockchain node 5 in the blockchain node group 2; the blockchain node 6 in the blockchain node group 3 can use the storage subspace 1 in the storage service 3, the blockchain node 7 in the blockchain node group 3 can use the storage subspace 2 in the storage service 3, and the storage space of the storage service 3 can further include a shared storage subspace shared by the blockchain node 6 and the blockchain node 7 in the blockchain node group 3; and so on.
[0076] (2) Block data storage method in a blockchain system
[0077] Please refer to Figure 5 , Figure 5 is a flowchart of a block data storage method in a blockchain system according to an example embodiment of the present application.
[0078] In this embodiment, the blockchain nodes participating in consensus in the blockchain system (i.e., the blockchain nodes) can be divided into at least one blockchain node group.
[0079] For each blockchain node group, the blockchain service platform corresponding to the blockchain system can deploy a corresponding storage service for the blockchain node group, and all the blockchain nodes in the blockchain node group share the storage service, i.e., each blockchain node in the blockchain node group can use the storage service to store block data to the storage space of the storage service.
[0080] The storage space can be used to store blocks that have been consensus processed by each blockchain node in the blockchain node group, and indication information corresponding to each blockchain node in the blockchain node group. For a blockchain node, the indication information corresponding to the blockchain node can be used to indicate the latest block that has been consensus processed by the blockchain node; that is, the indication information can serve as a pointer to the location of the latest block that has been consensus processed by the blockchain node in the full block data.
[0081] In an embodiment shown, since the block height can serve as an identifier of a block, and the block height is usually set to an increasing value, for a blockchain node, the indication information corresponding to the blockchain node can include the block height of the latest block that has been consensus processed by the blockchain node. Alternatively, in actual applications, the indication information corresponding to the blockchain node can also include the location of the latest block that has been consensus processed by the blockchain node in the storage space.
[0082] In an embodiment shown, the blockchain service platform can be a BaaS (Blockchain as a Service) platform. BaaS, which stands for “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 can be a cloud storage space. The storage cloud service can be a virtual machine, a container, a microservice, etc.
[0083] The block data storage method in the blockchain system can be applied to a storage service (which can be referred to as a target storage service) corresponding to any one of the blockchain node groups (which can be referred to as a target blockchain node group) in the blockchain system. As shown in the embodiment, the method can specifically include the following steps: Figure 5
[0084] Step 502: Obtain a storage request corresponding to a first block sent by a target blockchain node in the target blockchain node group in response to consensus processing of the first block.
[0085] In this embodiment, the blockchain nodes in the blockchain system can perform consensus processing on a new block to be connected to the chain structure based on a consensus protocol. The consensus processing can be a verification operation performed by the blockchain nodes on the block to be consensus. After the consensus processing of the majority of the blockchain nodes in the blockchain system on the block is passed, the consensus on the block is considered to be completed.
[0086] After the consensus processing of the blockchain nodes in the blockchain system on a certain block is passed, the blockchain nodes can request the storage service corresponding to the blockchain node group to which the blockchain node belongs to store the block. For example, a certain blockchain node (which can be referred to as a target blockchain node) in the target blockchain node group can send a storage request corresponding to the first block to the target storage service in response to the consensus processing of a certain block (which can be referred to as a first block) being passed.
[0087] Step 504: In response to the storage request, it is determined whether the first block has been stored in the target storage space of the target storage service.
[0088] In this embodiment, in response to the storage request, it is first determined whether a block identical to the first block is stored in the storage space (which can be referred to as a target storage space) of the target storage service, that is, it is determined whether the first block is stored.
[0089] It should be noted that the block identical to the first block can be a block whose block identifier (for example, block height) is identical to that of the first block and whose block hash value is identical to that of the first block.
[0090] Step 506: If the first block is not stored in the target storage space, the first block and the indication information indicating that the first block is the latest block consensus processed by the target blockchain node are stored in the target storage space.
[0091] In this embodiment, if the first block is not stored in the target storage space, the first block can be stored in the target storage space. At the same time, the indication information indicating that the first block is the latest block consensus processed by the target blockchain node can also be stored in the target storage space, that is, the indication information corresponding to the target blockchain node stored in the target storage space is updated to the indication information indicating that the first block is the latest block consensus processed by the target blockchain node.
[0092] Step 508: If the first block has been stored in the target storage space, update the indication information corresponding to the target blockchain node stored in the target storage space as the indication information used for indicating that the first block is the latest block which has been consensus processed by the target blockchain node.
[0093] In the embodiment, if the target storage space has stored the first block, in order to avoid repeated storage of block data, the first block does not need to be stored into the target storage space any more, but the indication information corresponding to the target blockchain node stored in the target storage space can be directly updated as the indication information used for indicating that the first block is the latest block which has been consensus processed by the target blockchain node.
[0094] It should be noted that, in order to reduce the amount of data transmitted between the blockchain node and the storage service, the storage request can only contain the block identifier and the block hash value of the first block, and does not contain the block data itself. In the case where it is determined that the target storage space does not store the first block, the target blockchain node can send the first block to the target storage service; and in the case where it is determined that the target storage space has stored the first block, the target blockchain node does not need to send the first block to the target storage service.
[0095] In an embodiment, the storage space of the storage service corresponding to each blockchain node group can include a storage sub-space (which can be referred to as a first sub-space) used for storing blocks, and a storage sub-space (which can be referred to as a second sub-space) corresponding to each blockchain node in the blockchain node group, wherein the second sub-space is used for storing the indication information corresponding to each blockchain node. Since the indication information used for indicating the latest block which has been consensus processed by each blockchain node is stored in the second sub-space corresponding to the blockchain node, the indication information corresponding to different blockchain nodes can be isolated, and each blockchain node can obtain or update its own indication information.
[0096] For example, as shown in the blockchain system Figure 4 , the shared storage sub-spaces in the storage service 1, the storage service 2 and the storage service 3 are the first sub-spaces; the storage sub-space 1 in the storage service 1, the storage sub-spaces 1, 2, 3 and 4 in the storage service 2, and the storage sub-spaces 1 and 2 in the storage service 3 are the second sub-spaces.
[0097] In the above case, if the first block is not stored in the target storage space, the first block can be specifically stored in the first subspace included in the target storage space, and the indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node can be stored in the second subspace included in the target storage space and corresponding to the target blockchain node.
[0098] If the first block is stored in the target storage space, the indication information corresponding to the target blockchain node and stored in the second subspace included in the target storage space and corresponding to the target blockchain node can be specifically updated to the indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node.
[0099] In an embodiment shown, for a group of blockchain nodes in the blockchain system, the second subspace included in the storage space of the storage service corresponding to the group of blockchain nodes and corresponding to each blockchain node in the group of blockchain nodes can also be used to temporarily store the latest block that has passed the consensus processing of each blockchain node. Further, after the consensus processing of the majority of blockchain nodes in the blockchain system passes the latest block, the latest block can be submitted to the first subspace included in the storage space for long-term storage.
[0100] In the above case, in response to a storage request corresponding to the first block, it can be specifically determined whether the first block is stored in the first subspace included in the target storage space.
[0101] If the first block is stored in the first subspace included in the target storage space, the indication information corresponding to the target blockchain node and stored in the second subspace included in the target storage space and corresponding to the target blockchain node can be specifically updated to the indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node.
[0102] If the first block is not stored in the first subspace included in the target storage space, the first block can be specifically temporarily stored in the second subspace included in the target storage space and corresponding to the target blockchain node, and after the consensus processing of at least the next block (the next block or the next K blocks) of the target blockchain node passes the first block, the first block temporarily stored in the second subspace included in the target storage space and corresponding to the target blockchain node can be submitted to the first subspace included in the target storage space, and the indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node can be stored in the second subspace included in the target storage space and corresponding to the target blockchain node.
[0103] It should be noted that, for a blockchain node, if the blockchain node requests to store the N+K (K≥1) thblock, it means that the N thblock previously requested to be stored by the blockchain node must be a legal block, i.e., a block that has been consensus processed by the majority of blockchain nodes in the blockchain system. The reason is that if the N thblock is not a legal block, the blockchain node cannot further perform consensus processing on the N+K thblock. Therefore, after the consensus processing of the target blockchain node on at least the next block of the first block is passed, the first block temporarily stored in the second subspace corresponding to the target blockchain node in the target storage space can be submitted to the first subspace in the target storage space, so as to ensure that the blocks submitted to the first subspace are all legal blocks.
[0104] In an embodiment shown, in order to reduce the amount of data stored in the second subspace and reduce the storage requirement as much as possible, a deduplication process can also be performed on the block data stored in the second subspace.
[0105] Specifically, in the case where the first block is not stored in the first subspace in the target storage space, the first block is not directly temporarily stored in the second subspace corresponding to the target blockchain node in the target storage space, but it can be determined whether the same block as the first block has been temporarily stored in the second subspace corresponding to other blockchain nodes in the target storage space, i.e., whether the first block is stored.
[0106] If the first block is not temporarily stored, the first block can be temporarily stored in the second subspace corresponding to the target blockchain node in the target storage space.
[0107] If the first block is temporarily stored, a link pointing to the first block temporarily stored in the second subspace corresponding to other blockchain nodes in the target storage space can be generated, and the link can be temporarily stored in the second subspace corresponding to the target blockchain node in the target storage space.
[0108] For the storage space corresponding to a blockchain node group, the block data stored in the second subspace corresponding to each blockchain node in the blockchain node group in the storage space can be as shown in Table 1:
[0109] Table 1
[0110] Blockchain node Nth block 1 Link→Data1 2 Link→Data1 3 Data1 4 Link→Data1
[0111] The blockchain node 3 first stores the block containing Data1 in the second subspace, and the blockchain node 1, the blockchain node 2 and the blockchain node 4 will not store the block containing Data1 in the second subspace, but can generate a link pointing to the block containing Data1 stored in the second subspace, and store the link in the second subspace.
[0112] In the illustrated embodiment, in order to solve the problem of block bifurcation, for the first block stored in the second subspace corresponding to the target blockchain node included in the target storage space, the first block at this time can also be compared with blocks with the same block identifier as the first block which have been consensus processed by at least Quorum blockchain nodes in the blockchain system, to determine whether the block hash values of the first block and the blocks are all different. If the block hash values of the first block and the blocks are all different, the first block can be marked as a bifurcation block; that is, the first block stored in the second subspace corresponding to the target blockchain node included in the target storage space can be marked as a bifurcation block.
[0113] For the storage space corresponding to a blockchain node group, the block data stored in the second subspace corresponding to each blockchain node in the blockchain node group included in the storage space can be as shown in Table 2:
[0114] Table 2
[0115] Blockchain node Nth block N+1th block 1 Link→Data2 2 Data1'(forked block) 3 Data2 4 Link→Data2
[0116] The blockchain node 3 first stores the block containing Data2 in the second subspace, and the blockchain node 1 and the blockchain node 4 will not store the block containing Data2 in the second subspace, but can generate a link pointing to the block containing Data2 stored in the second subspace, and store the link in the second subspace; the block containing Data1' stored in the second subspace by the blockchain node 2 is confirmed as a bifurcation block, and the block containing Data1' stored in the second subspace by the blockchain node 2 can be marked as a bifurcation block.
[0117] It should be noted that the bifurcation block stored in the second subspace will not be submitted to the first subspace for storage. Moreover, the blockchain node which stores the bifurcation block in the second subspace can no longer participate in the consensus of subsequent blocks; that is, if the blockchain node stores the Nth block marked as a bifurcation block in the second subspace, the blockchain node cannot perform consensus processing on the N+K (K≥1) th block.
[0118] In an embodiment shown, after the consensus processing of the target blockchain node on at least the next block of the first block is passed, it can be determined whether the first block temporarily stored in the second subspace corresponding to the target blockchain node in the target storage space is marked as a fork block. If the first block is not marked as a fork block, the first block can be submitted to the first subspace in the target storage space.
[0119] Correspondingly, if the first block is marked as a fork block, the fork block will not be submitted to the first subspace in the target storage space, but will be retained in the second subspace corresponding to the target blockchain node in the target storage space. In this way, it can be ensured that the blocks stored in the first subspace in the target storage space are always legal blocks.
[0120] In an embodiment shown, after storing the block data into the storage space of the storage service deployed in the group of blockchain nodes, each blockchain node in the group of blockchain nodes can also read the block data from the storage space.
[0121] Specifically, the target blockchain node can determine whether a certain block (which can be referred to as a second block) is a block that has been passed by the consensus processing of the target blockchain node based on the indication information corresponding to the target blockchain node stored in the target storage space in response to a read request for the second block. Since the indication information can be used to indicate the latest block that has been passed by the consensus processing of the target blockchain node, if the second block is a block that is located before the block indicated by the indication information in time, or the second block is the block indicated by the indication information itself, it can be determined that the second block is a block that has been passed by the consensus processing of the target blockchain node. For example, the indication information can be specifically the block height of the latest block that has been passed by the consensus processing of the target blockchain node, and if the block height of the second block is less than or equal to the block height represented by the indication information, it can be determined that the second block is a block that has been passed by the consensus processing of the target blockchain node.
[0122] If the second block is a block that has been passed by the consensus processing of the target blockchain node, the second block can be read from the target storage space.
[0123] Further, in an embodiment shown, when reading the second block from the target storage space, it can be determined whether the second subspace corresponding to the target blockchain node in the target storage space has temporarily stored the second block. For example, it can be determined whether the block identifier of the block temporarily stored in the second subspace corresponding to the target blockchain node in the target storage space is the same as the block identifier of the second block.
[0124] If the target storage space contains a second sub-space corresponding to the target blockchain node, and the second sub-space has temporarily stored the second block, the second block temporarily stored in the second sub-space corresponding to the target blockchain node in the target storage space can be read.
[0125] If the target storage space contains a second sub-space corresponding to the target blockchain node, and the second sub-space has not temporarily stored the second block, the second block stored in the first sub-space of the target storage space can be read. Specifically, it can be further determined whether the second block has been stored in the first sub-space of the target storage space; if the second block has been stored in the first sub-space of the target storage space, the second block stored in the first sub-space of the target storage space can be read; if the second block has not been stored in the first sub-space of the target storage space, a prompt message indicating that the reading fails can be returned.
[0126] In an embodiment shown, the data structure of the full amount of block data stored in the first sub-space can refer to the chain block structure on the actual blockchain. That is, in the first sub-space, the blocks can be stored in a chain structure. Specifically, in the first sub-space, each block can be linked in time sequence on the chain structure, so that the chain structure forms a chain in time order.
[0127] The technical scheme provided in the present application can be used for block data storage in a blockchain system. In the blockchain system, the blockchain nodes participating in consensus are divided into at least one blockchain node group, and a blockchain service platform corresponding to the blockchain system deploys a corresponding storage service for each blockchain node group. The storage space of the storage service is used to store the blocks that have been consensus-processed by each blockchain node in the blockchain node group and the indication information corresponding to each blockchain node in the blockchain node group, and the indication information is used to indicate the latest block that has been consensus-processed by the blockchain node. When the storage service corresponding to any blockchain node group in the blockchain system stores the block that has been consensus-processed by a certain blockchain node in the blockchain node group, it can first determine whether the storage space of the storage service has stored the block. If the storage space has not stored the block, the block and the indication information indicating that the block is the latest block that has been consensus-processed by the blockchain node can be stored in the storage space. If the storage space has stored the block, the indication information corresponding to the blockchain node stored in the storage space can be updated to the indication information indicating that the block is the latest block that has been consensus-processed by the blockchain node, and the block does not need to be stored in the storage space.
[0128] In the foregoing manner, the block data in the blockchain system can be stored by the storage service corresponding to each blockchain node deployed in a group, and the deduplication processing of the block data stored in the storage space of each storage service is implemented, so that only one full amount of block data needs to be stored in the storage space of each storage service, and one full amount of block data no longer needs to be stored on each blockchain node participating in consensus. If the N blockchain nodes are divided into X (1≤X≤N) blockchain node groups, then only X full amounts of block data need to be stored, and N full amounts of block data no longer need to be stored, that is, the storage demand can be reduced to X / N of the original. In this way, the storage cost of the block data in the blockchain system can be reduced, and when a new node joins the blockchain system, only the indication information set for the new node needs to be adjusted, so that the time consumption of the new node joining the blockchain system can be reduced, and the new node can be added to the blockchain system in seconds.
[0129] Corresponding to the embodiments of the block data storage method in the blockchain system described above, the present application also provides embodiments of a block data storage device in a blockchain system.
[0130] Please refer to Figure 6 , Figure 6 is a structural schematic diagram of a device according to an example 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, and of course can also include other required hardware. One or more embodiments of the present application can be implemented in a software manner, such as reading a corresponding computer program from the non-volatile memory 610 into the memory 608 by the processor 602 and then running. Of course, in addition to the software implementation, 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, etc., that is, the execution subject of the following processing flow is not limited to each logic module, but can also be hardware or a logic device.
[0131] Please refer to Figure 7 , Figure 7 is a block diagram of a block data storage device in a blockchain system according to an example embodiment of the present application.
[0132] The block data storage device in the blockchain system described above can be applied to a target storage service corresponding to a target blockchain node group in the blockchain system running on the device shown in Figure 6 to implement the technical solutions of the present application.
[0133] The blockchain nodes participating in consensus in the blockchain system are divided into at least one blockchain node group; a blockchain service platform corresponding to the blockchain system deploys a corresponding storage service for each blockchain node group; a storage space of the storage service is used to store blocks that have passed consensus processing of each blockchain node in the blockchain node group, and indication information corresponding to each blockchain node in the blockchain node group; the indication information is used to indicate the latest block that has passed consensus processing of the corresponding blockchain node.
[0134] The apparatus comprises:
[0135] The acquisition unit 702 acquires a storage request corresponding to the first block sent by a target blockchain node in the target blockchain node group in response to passing of consensus processing of the first block;
[0136] The determination unit 704 determines whether the first block has been stored in a target storage space of the target storage service in response to the storage request;
[0137] The storage unit 706 stores the first block and indication information indicating that the first block is the latest block that has passed consensus processing of the target blockchain node to the target storage space if the first block has not been stored in the target storage space;
[0138] The update unit 708 updates the indication information corresponding to the target blockchain node stored in the target storage space to indication information indicating that the first block is the latest block that has passed consensus processing of the target blockchain node if the first block has been stored in the target storage space.
[0139] In an embodiment shown, the blockchain service platform is a BaaS platform; and the storage space is a cloud storage space.
[0140] In an embodiment shown, the storage space comprises a first subspace for storing blocks, and a second subspace corresponding to each blockchain node in the blockchain node group; and the second subspace is used to store the indication information corresponding to the each blockchain node;
[0141] Storing the first block and the indication information indicating that the first block is the latest block that has passed consensus processing of the target blockchain node to the target storage space comprises:
[0142] storing the first block to the first subspace included in the target storage space, and storing indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node to the second subspace corresponding to the target blockchain node included in the target storage space;
[0143] updating the indication information corresponding to the target blockchain node stored in the target storage space to the indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node, comprises:
[0144] updating the indication information 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 indication information indicating that the first block is the latest block that has passed the consensus processing of the target blockchain node.
[0145] In an embodiment shown, the second subspace corresponding to each blockchain node in the group of blockchain nodes included in the storage space is further used for temporarily storing the latest block that has passed the consensus processing of each blockchain node;
[0146] determining whether the first block has been stored in the target storage space, comprises:
[0147] determining whether the first block has been stored in the first subspace included in the target storage space;
[0148] storing the first block to the first subspace included in the target storage space, comprises:
[0149] temporarily storing the first block to the second subspace corresponding to the target blockchain node included in the target storage space, and after the consensus processing of at least a next block of the first block by the target blockchain node, submitting the first block temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space to the first subspace included in the target storage space.
[0150] In an embodiment shown, temporarily storing the first block to the second subspace corresponding to the target blockchain node included in the target storage space, comprises:
[0151] determining whether the first block has been temporarily stored in the second subspace corresponding to other blockchain nodes included in the target storage space;
[0152] if the first block has not been temporarily stored, temporarily storing the first block to the second subspace corresponding to the target blockchain node included in the target storage space.
[0153] If the first block has been temporarily stored, generating a link pointing to the first block temporarily stored in the second subspace corresponding to other blockchain nodes included in the target storage space, and temporarily storing the link in the second subspace corresponding to the target blockchain node included in the target storage space.
[0154] In an embodiment shown, determining whether the first block has been temporarily stored in the second subspace corresponding to other blockchain nodes included in the target storage space comprises:
[0155] Determining whether a block having a block identifier same as the block identifier of the first block and a block hash value same as the block hash value of the first block has been temporarily stored in the second subspace corresponding to other blockchain nodes included in the target storage space.
[0156] In an embodiment shown, the apparatus further comprises:
[0157] The marking unit determines whether the block hash value of the first block temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space is different from the block hash value of a block having a block identifier same as the block identifier of the first block and having been consensus-processed by at least Quorum blockchain nodes in the blockchain system; if so, marking the first block temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space as a forked block.
[0158] In an embodiment shown, after the consensus processing of at least the next block of the first block by the target blockchain node is passed, submitting the first block temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space to the first subspace included in the target storage space comprises:
[0159] After the consensus processing of at least the next block of the first block by the target blockchain node is passed, determining whether the first block temporarily stored in the second subspace corresponding to the target blockchain node included in the target storage space is marked as a forked block.
[0160] If the first block is not marked as a forked block, submitting the first block to the first subspace included in the target storage space.
[0161] In an embodiment shown, the first subspace included in the storage space stores blocks in a chain structure.
[0162] In an embodiment shown, the apparatus further comprises:
[0163] The reading unit, in response to a read request corresponding to a second block sent by the target blockchain node, determines whether the second block is a block that has been consensus processed by the target blockchain node based on the indication information corresponding to the target blockchain node stored in the target storage space; and reads the second block from the target storage space if the second block is a block that has been consensus processed by the target blockchain node.
[0164] In an embodiment shown, reading the second block from the target storage space comprises:
[0165] Determining whether the second block has been temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space;
[0166] If the second block has been temporarily stored, reading the second block temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space;
[0167] If the second block has not been temporarily stored, reading the second block stored in the first subspace contained in the target storage space.
[0168] In an embodiment shown, the indication information comprises a block height of the latest block that has been consensus processed by the blockchain node corresponding thereto.
[0169] In the 1990s, it was relatively easy to distinguish whether an improvement in a technology was a hardware improvement (e.g., an improvement in the circuit structure of a diode, transistor, switch, etc.) or a software improvement (an improvement in a method flow). However, as technology has evolved, many improvements in method flows today can be considered as direct improvements in hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structures by programming the improved method flows into hardware circuits. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using hardware entity modules. For example, a programmable logic device (PLD) (e.g., a field programmable gate array (FPGA)) is an integrated circuit whose logic function is determined by user programming of the device. A digital system is "integrated" on a PLD by the designer programming the PLD, rather than by ordering a chip manufacturer to design and fabricate a custom integrated circuit chip. Moreover, instead of manually fabricating integrated circuit chips, this programming is now mostly implemented using "logic compiler" software, which is similar to software compilers used in program development, and the original code to be compiled is written in a specific programming language, which is called a hardware description language (HDL), and there are many such languages, 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., and the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should be aware that, as long as the method flow is logically programmed in the above-mentioned hardware description languages and programmed into an integrated circuit, a hardware circuit implementing the logical method flow can be easily obtained.
[0170] The controller can be implemented in any suitable way, for example, the controller can take the form of, for example, a microprocessor or 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 which 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. The skilled person will also appreciate that, in addition to implementing the controller in pure computer readable program code, it is possible to implement the controller in the form of logic gates, switches, an application specific integrated circuit, a programmable logic controller and an embedded microcontroller, etc. to perform the same functions by logically programming the method steps. Such a controller can therefore be considered to be a hardware component, and the means included therein to perform the various functions can also be considered to be structures within the hardware component. Alternatively, or even additionally, the means to perform the various functions can be considered to be both a software module implementing the method and a structure within a hardware component.
[0171] The systems, apparatuses, modules or units illustrated by 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, the present application does not rule out that with the development of future computer technologies, computers implementing the functions of the above embodiments can be personal computers, laptop computers, vehicle human-computer interaction devices, cellular phones, camera phones, smart phones, personal digital assistants, media players, navigation devices, email devices, game consoles, tablet computers, wearable devices, or combinations of any of these devices.
[0172] Although the one or more embodiments of the present application provide method operation steps as described in the embodiments or flowcharts, more or less operation steps can be included based on conventional or non-inventive means. The order of steps listed in the embodiments is only one of the many execution orders of the steps, and does not represent the only execution order. In actual device or terminal product execution, the method order shown in the embodiments or the drawings can be executed in sequence or in parallel (for example, in a parallel processor or multi-thread processing environment, or even in a distributed data processing environment). The terms "comprise", "contain" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, product or equipment including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, product or equipment. Without more limitations, it does not exclude the presence of other same or equivalent elements in the process, method, product or equipment including the elements. For example, if the first, second, etc. terms are used to represent names, they do not represent any particular order.
[0173] For the convenience of description, the above device is described as various modules described in function. Of course, when implementing one or more of the present application, the functions of each module can be implemented in the same or more software and / or hardware, or modules implementing the same function can be implemented by a combination of multiple sub-modules or sub-units. The above described device embodiments are only illustrative, for example, the division of the units is only a logical function division, and actual implementation can have another division method, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the coupling or direct coupling or communication connection between the displayed or discussed each other can be through some interface, indirect coupling or communication connection between devices or units, which can be electrical, mechanical or other forms.
[0174] The present application is described with reference to flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams 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 produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices produce a device for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 The device for implementing the functions specified in one flow or multiple flows and / or blocks. Figure 1 The device for implementing the functions specified in one flow or multiple flows and / or 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 apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.
[0176] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.
[0177] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0178] The memory can include non-persistent memory and / or volatile memory, such as random access memory (RAM) and / or cache memory, non-volatile memory, such as read-only memory (ROM), EPROM, and / or flash memory, etc. The memory is an example of computer readable media.
[0179] Computer readable media includes permanent and non-permanent, removable and non-removable media implemented in any method or technology for storage of information such as 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 technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD), or other optical storage, magnetic cassettes, magnetic tapes, magnetic disk storage, graphene storage, or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to computing devices. According to the definition herein, computer readable media does not include transitory media, such as modulated data signals and carrier waves.
[0180] As will be appreciated by one skilled in the art, aspects of the present application can be embodied as a method, system, or computer program product. Accordingly, aspects of the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, aspects of the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, and the like) having computer-usable program code embodied in the medium.
[0181] One or more embodiments of the application can be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more embodiments of the application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including memory storage devices.
[0182] Embodiments in the application are described with progressive manner, and the same or similar parts among the embodiments can be referred to each other. Each embodiment focuses on the difference from other embodiments. Especially, the system embodiments are described simply because they are basically similar to the method embodiments. In the description of the application, the description of the terms "one embodiment", "some embodiments", "an example", "a 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 application. The illustrative representations of the above terms in the application are not necessarily for the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any suitable manner in one or more embodiments or examples. In addition, the person skilled in the art can combine and combine the different embodiments or examples described in the application and the features of the different embodiments or examples without contradiction.
[0183] The above descriptions merely illustrate one or more embodiments of the application and are not intended to limit the one or more embodiments of the application. The one or more embodiments of the application can have various changes and modifications for those skilled in the art. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the application should be included in the scope of the claims.
[0184] The user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are information and data authorized by the user or authorized by all parties, and the collection, use and processing of the related data need to comply with the relevant laws, regulations and standards of the country and region, and provide corresponding operation entrances for the user to choose authorization or refusal.
Claims
1. A method for storing block 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; 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 blocks that have been processed by consensus by each blockchain node in the blockchain node group, as well as the indication information corresponding to each blockchain node in the blockchain node group. The indication information is used to indicate the latest block that has been processed through consensus by the corresponding blockchain node; The method is applied to a target storage service corresponding to a target blockchain node group in the blockchain system, including: Obtain the storage request corresponding to the first block sent by the target blockchain node in the target blockchain node group in response to the consensus processing of the first block; In response to the storage request, determine whether the first block has already been stored in the target storage space of the target storage service; If the first block is not stored in the target storage space, the first block and the indication information indicating that the first block is the latest block that has been processed by consensus by the target blockchain node are stored in the target storage space; If the first block is already stored in the target storage space, the indication information corresponding to the target blockchain node stored in the target storage space is updated to indicate that the first block is the latest block that has been processed by consensus by the target blockchain node.
2. The method according to claim 1, wherein the blockchain service platform is a BaaS platform; and the storage space is cloud storage space.
3. The method according to claim 1, wherein the storage space comprises a first subspace for storing blocks, and a second subspace corresponding to each blockchain node in the blockchain node group; The second subspace is used to store the indication information corresponding to each of the blockchain nodes; Storing the first block and the latest block indicating that the first block is the one that has been consensus-processed and passed by the target blockchain node into the target storage space includes: The first block is stored in the first subspace contained in the target storage space, and the indication information used to indicate that the first block is the latest block that has been processed by consensus by the target blockchain node is stored in the second subspace contained in the target storage space corresponding to the target blockchain node. The indication information stored in the target storage space corresponding to the target blockchain node is updated to indication information indicating that the first block is the latest block that has been consensus-processed and passed by the target blockchain node, including: The indication information corresponding to the target blockchain node stored in the second subspace contained in the target storage space is updated to indication information indicating that the first block is the latest block that has been processed by consensus by the target blockchain node.
4. The method according to claim 3, wherein the storage space includes a second subspace corresponding to each blockchain node in the blockchain node group, which is further used to temporarily store the latest block that has been processed by consensus by each blockchain node; Determining whether the first block has already been stored in the target storage space includes: Determine whether the first block has been stored in the first subspace contained in the target storage space; Storing the first block into the first subspace contained in the target storage space includes: The first block is temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space. After the consensus processing of at least the next block of the first block by the target blockchain node is passed, the first block temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space is submitted to the first subspace contained in the target storage space.
5. The method according to claim 4, wherein temporarily storing the first block in the second subspace corresponding to the target blockchain node contained in the target storage space, comprises: Determine whether the first block has been temporarily stored in the second subspace corresponding to other blockchain nodes contained in the target storage space; If the first block is not temporarily stored, the first block will be temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space; If the first block has been temporarily stored, a link is generated pointing to the first block temporarily stored in the second subspace corresponding to other blockchain nodes contained in the target storage space, and the link is temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space.
6. The method according to claim 5, determining whether the first block has been temporarily stored in the second subspace corresponding to other blockchain nodes contained in the target storage space, includes: Determine whether the second subspace, which is included in the target storage space and corresponds to other blockchain nodes, has already temporarily stored a block whose block identifier is the same as the block identifier of the first block and whose block hash value is the same as the block hash value of the first block.
7. The method according to claim 6, further comprising: Determine whether the block hash value of the first block temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space is different from the block hash value of the block whose block identifier is the same as the block identifier of the first block and has been consensus-processed by at least Quorum blockchain nodes in the blockchain system. If so, mark the first block temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space as a fork block.
8. The method according to claim 7, wherein after the consensus processing of at least the next block of the first block by the target blockchain node is passed, the first block temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space is submitted to the first subspace contained in the target storage space, comprising: After the consensus processing of at least the next block of the first block by the target blockchain node is completed, it is determined whether the first block temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space is marked as a fork block. If the first block is not marked as a fork block, the first block is committed to the first subspace contained in the target storage space.
9. The method according to claim 3, wherein the storage space includes first subspaces containing blocks stored in a chained structure.
10. The method according to claim 3, further comprising: In response to the read request sent by the target blockchain node corresponding to the second block, based on the indication information stored in the target storage space corresponding to the target blockchain node, it is determined whether the second block is a block that has been processed by consensus by the target blockchain node; If the second block is a block that has been processed through consensus by the target blockchain node, the second block is read from the target storage space.
11. The method of claim 10, wherein reading the second block from the target storage space comprises: Determine whether the second block has been temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space; If the second block has been temporarily stored, read the second block temporarily stored in the second subspace corresponding to the target blockchain node contained in the target storage space; If the second block is not temporarily stored, read the second block stored in the first subspace contained in the target storage space.
12. The method according to claim 1, wherein the indication information includes the block height of the latest block that has been consensus-processed by the corresponding blockchain node.
13. A block 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 blocks that have been processed by consensus by each blockchain node in the blockchain node group, as well as the indication information corresponding to each blockchain node in the blockchain node group. The indication information is used to indicate the latest block that has been processed through consensus by the corresponding blockchain node; The device is used for a target storage service corresponding to a target blockchain node group in the blockchain system, including: The acquisition unit acquires the storage request corresponding to the first block sent by the target blockchain node in the target blockchain node group in response to the consensus processing of the first block being passed. The determining unit, in response to the storage request, determines whether the first block has already been stored in the target storage space of the target storage service; If the first block is not stored in the target storage space, the storage unit stores the first block and the indication information indicating that the first block is the latest block that has been processed by consensus by the target blockchain node into the target storage space. The updating unit, if the first block has already been stored in the target storage space, updates the indication information corresponding to the target blockchain node stored in the target storage space to indication information indicating that the first block is the latest block that has been processed by consensus by the target blockchain node.
14. An electronic device comprising: processor; Memory used to store processor-executable instructions; The processor implements the method as described in any one of claims 1 to 12 by executing the executable instructions.
15. A computer-readable storage medium having stored thereon computer instructions that, when executed by a processor, implement the method as described in any one of claims 1 to 12.
Citation Information
Patent Citations
Data storage method, transaction storage method and device
CN111177277A
Data storage and acquisition method and device applied to block chain
CN111339089A