A method for synchronizing block states in a blockchain and a blockchain system
By setting the first and second storage devices in the blockchain nodes, the block state data is directly synchronized from the corresponding storage devices, and the problems of low synchronization efficiency and high bandwidth pressure under the state sharding architecture are solved, and more efficient block state synchronization is achieved.
Patent Information
- Application Number
- CN202210462513.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-04-28
AI Technical Summary
Under the state sharding architecture of blockchain, the block state synchronization efficiency is low and the bandwidth pressure is high, and the existing technology cannot effectively solve it.
By setting the first storage device and the second storage device in the nodes of the blockchain, the partial state data of the block is directly point-to-point synchronized from the corresponding third storage device and the fourth storage device, respectively, to achieve fast block state synchronization.
The bandwidth pressure of each node in the blockchain is reduced and the synchronization efficiency of block state data is improved.
Smart Images

Figure CN114996350B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification belong to the technical field of blockchain, and particularly relate to a method for synchronizing block states in a blockchain and a blockchain system. Background Art
[0002] Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithms. In a blockchain system, data blocks are combined into a chain data structure in chronological order and connected in sequence, and it is a distributed ledger that is guaranteed to be tamper-proof and non-forgeable by cryptographic means. Due to the characteristics of blockchain such as decentralization, information immutability, and autonomy, blockchain has received more and more attention and applications. Summary of the Invention
[0003] The purpose of the present invention is to provide a method for synchronizing block states in a blockchain and a blockchain system, so as to achieve direct peer-to-peer synchronization of nodes for block state synchronization through their storage devices under a state sharding architecture, reducing bandwidth pressure.
[0004] According to a first aspect, there is provided a method for synchronizing block states in a blockchain, which is executed by a first node in the blockchain. The first node includes a first storage device and a second storage device for storing block state data. The blockchain further includes a plurality of second nodes, and each second node includes a third storage device and a fourth storage device for storing block state data. Among them, the first storage device corresponds to the third storage device, and the second storage device corresponds to the fourth storage device. The method includes:
[0005] The first storage device obtains first partial state data of a first block to be synchronized from the third storage device;
[0006] The second storage device obtains second partial state data of the first block from the fourth storage device.
[0007] According to a second aspect, there is provided a blockchain system. The blockchain system includes a first node. The first node includes a first storage device and a second storage device for storing block state data. The blockchain system further includes a plurality of second nodes, and each second node includes a third storage device and a fourth storage device for storing block state data. Among them, the first storage device corresponds to the third storage device, and the second storage device corresponds to the fourth storage device. The system includes:
[0008] The first storage device is configured to obtain first partial state data of a first block to be synchronized from the third storage device;
[0009] The second storage device is configured to obtain the second part of the status data of the first block from the fourth storage device.
[0010] According to a third aspect, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed on a computer, causes the computer to execute the method according to the first aspect.
[0011] According to a fourth aspect, there is provided a computing device including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to the first aspect is implemented.
[0012] In the above embodiments, the blockchain is a blockchain under a state sharding architecture. The first node in the blockchain includes a first storage device and a second storage device for storing block status data. The blockchain further includes a plurality of second nodes, and each second node includes a third storage device and a fourth storage device for storing block status data. Among them, the first storage device corresponds to the third storage device, and the second storage device corresponds to the fourth storage device. During the process of block status synchronization, the first storage device obtains the first part of the status data of the first block to be synchronized from the third storage device; the second storage device obtains the second part of the status data of the first block from the fourth storage device, so as to realize that in the state sharding architecture, the first node for block status synchronization directly performs block status synchronization point-to-point through its storage device, reducing the bandwidth pressure of each blockchain node in the blockchain and improving the synchronization efficiency of the block status data. Description of the Drawings
[0013] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments recorded in this specification. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0014] Figure 1 is a blockchain architecture diagram shown according to an exemplary embodiment of this specification;
[0015] Figure 2 is a schematic diagram of an implementation framework shown according to an embodiment of this specification;
[0016] Figure 3 is a schematic flowchart of a method for block status synchronization in a blockchain according to an embodiment of this specification;
[0017] Figure 4 is a schematic flowchart of a method for block status synchronization in a blockchain according to an embodiment of this specification;
[0018] Figure 5 It is a schematic structural diagram of the first node in the blockchain in an embodiment of this specification. Detailed implementation manners
[0019] In order to enable those skilled in the art of this technology to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this specification.
[0020] Currently, a very important factor restricting the large-scale implementation and application of blockchain technology is performance, mainly including throughput. Regarding the problem of improving the throughput of blocks, the sharding technology is an effective solution. The concept of sharding originated from the database field and originally referred to the horizontal partitioning of data in a database (dividing different rows of a table into different partitions), and each shard is stored on a separate database server instance to disperse the load.
[0021] The sharding technology can be divided into three types according to different sharding mechanisms: network sharding, transaction sharding, and state sharding. Network sharding is the most basic sharding method, which is to divide the entire blockchain network into multiple sub-networks, that is, multiple shards. In this way, multiple shards in the blockchain network can process different transactions in the network in parallel. Transaction sharding is to allocate transactions to different shards according to certain rules to achieve the purpose of parallel processing. Among all the sharding mechanisms, state sharding is the most challenging sharding method. The key to state sharding is to separate the entire storage area, so that different shards store different parts, and each node only stores its own shard data instead of storing the complete blockchain state. The state sharding solution can reduce the storage, communication, and computing overheads in the blockchain, thereby improving the performance of the blockchain.
[0022] Transactions in the blockchain field can refer to task units that are executed and recorded in the blockchain. A transaction usually includes a sending field (From), a receiving field (To), and a data field (Data). Among them, in the case of a transfer transaction, the From field represents the account address that initiates the transaction (i.e., initiates the transfer task to another account), the To field represents the account address that receives the transaction (i.e., receives the transfer), and the Data field includes the transfer amount. In the case where a transaction invokes a smart contract in the blockchain, the From field represents the account address that initiates the transaction, the To field represents the account address of the contract invoked by the transaction, and the Data field includes data such as the function name in the invoked contract and the input parameters for the function, so as to obtain the code of the function from the blockchain and execute the code of the function when the transaction is executed.
[0023] Figure 1 This is the blockchain architecture diagram provided by an embodiment of this specification.
[0024] As Figure 1 shown, assume that the blockchain includes nodes A, B, C, and D, and the blockchain includes three shards (shard 1, shard 2, and shard 3). Each node includes a control device and a storage device for each shard (which can also be called a shard node). Taking node A as an example, as Figure 1 shown, node A includes control device A, storage device 1A, storage device 2A, and storage device 3A. Among them, storage device 1A, storage device 2A, and storage device 3A are respectively a device in shard 1, shard 2, and shard 3. Each node of the blockchain corresponds to, for example, a consortium party (or member party) of the blockchain, or multiple devices in the node are mutually trustworthy. For example, the first institution, the second institution, and the third institution form a blockchain, and each institution provides four servers to form a node in the blockchain, and these four servers are respectively used as the control device and the storage devices for each shard in the node of the blockchain. That is to say, multiple devices in the node of the blockchain form a trusted domain, and each device in the node trusts each other, so they can communicate directly. For example, in node A, control device A, storage device 1A, storage device 2A, and storage device 3A can communicate directly.
[0025] Each control device can receive transactions from user terminals and perform consensus on the received transactions to determine multiple transactions in the block to be executed. After consensus, each control device distributes the multiple transactions to the storage devices of different shards according to the account or variable status involved in each transaction. Among them, the above storage devices and control devices can be implemented as any device, server, or device cluster with computing and processing capabilities.
[0026] It can be understood thatFigure 1 Only three shards and four blockchain nodes are exemplarily shown. The embodiments of this specification are not limited thereto. In fact, the blockchain may include other numbers of shards and nodes. It should be noted that the embodiments of this specification are not limited to being applied to Figure 1 the shown blockchain system architecture, but may be applied to any blockchain system architecture. For example, the blockchain may include a control device or may not include a control device. If the blockchain does not include a control device, any one or more storage devices in the blockchain can replace the control device to perform the operations carried out by the control device.
[0027] In the related art, when a node in the blockchain performs block state synchronization, the control device of the node needs to obtain the transactions stored in the block to be synchronized from other nodes and distribute them to each storage device included therein. Each storage device executes the obtained transactions and updates the sub-state root (i.e., state data) of its sub-state tree. In this process, the control device needs to obtain all the transactions stored in the block to be synchronized, and then distribute them to each storage device for execution to update the sub-state roots of the sub-state trees of each storage device, resulting in slow block state synchronization efficiency and high bandwidth pressure on the nodes of the blockchain.
[0028] In view of this, the embodiments of this specification provide a method for block state synchronization in a blockchain, Figure 2 showing a schematic diagram of an implementation framework according to an embodiment disclosed in this specification. As Figure 2 shown, this method can be executed by any one node in the blockchain (for example Figure 2 node A therein), where the architecture of the blockchain is a state sharding architecture, that is, the blockchain is a blockchain under the state sharding architecture, and this node needs to perform block state synchronization.
[0029] Specifically, as Figure 2 shown, node A includes storage device 1A, storage device 2A, and storage device 3A for storing block state data. Storage device 1A, storage device 2A, and storage device 3A each belong to different shards and manage different accounts. Among them, storage device 1A, storage device 2A, and storage device 3A have state data of different accounts. For example, storage device 1A stores state data of accounts a, b, and c, storage device 2A stores state data of accounts d and e, and storage device 3A stores state data of account f.
[0030] The blockchain further includes multiple second nodes. As Figure 2 shown, the multiple second nodes include node B, node C, and node D. Each second node includes multiple storage devices for storing block state data. For example, as Figure 2As shown, node B includes storage device 1B, storage device 2B, and storage device 3B, node C includes storage device 1C, storage device 2C, and storage device 3C, and node D includes storage device 1D, storage device 2D, and storage device 3D. Among them, storage device 1A corresponds to storage device 1B, storage device 1C, and storage device 1D, belongs to the same shard, and stores the status data of the same account, such as the status data of account a, account b, and account c; storage device 2A corresponds to storage device 2B, storage device 2C, and storage device 2D, belongs to the same shard, and stores the status data of the same account, such as the status data of account d and account e; storage device 3A corresponds to storage device 3B, storage device 3C, and storage device 3D, belongs to the same shard, and stores the status data of the same account, such as the status data of account f.
[0031] In a blockchain, it is inevitable that the progress of each node (such as Figure 2 nodes A, B, C, and D shown) in executing transactions is different, that is, the generated current block height (i.e., block height) is different. In one case, each node in the blockchain can broadcast its block height information (i.e., the current highest block height) to other nodes periodically or aperiodically. Subsequently, it can receive the block height information of other nodes broadcast by other nodes.
[0032] In one implementation, each node in the blockchain can also include a control device, such as Figure 2 as shown, node A includes control device A, node B includes control device B, node C includes control device C, and node D includes control device D. Each node in the blockchain can broadcast its block height information through its control device and can receive the block height information broadcast by other nodes through its control device.
[0033] At a certain node in the blockchain, for example, node A determines, based on the block height information of a plurality of second nodes (such as Figure 2 nodes B - D shown) it receives, that the block heights of the first preset number of nodes among the plurality of second nodes are higher than its own block height, and when the minimum block height among the first preset number of nodes is higher than its own (node A) block height by a second preset number, then node A needs to perform fast block status synchronization.
[0034] Correspondingly, for node A to perform fast block status synchronization, it may first determine the first block to be synchronized based on its own block height and the block heights of the first preset number of nodes, where the block height of the first block is not greater than the minimum block height among the first preset number of nodes. Then, storage device 1A obtains the first part of the status data a of the first block from storage device 1B (or storage device 1C or storage device 1D); storage device 2A obtains the second part of the status data b of the first block from storage device 2B (or storage device 2C or storage device 2D), and storage device 3A obtains the third part of the status data c of the first block from storage device 3B (or storage device 3C or storage device 3D). In this way, in the state sharding architecture, node A for block status synchronization can directly obtain the partial status data of the first block to be synchronized from the corresponding storage devices of other nodes through its storage device, achieving fast synchronization of the block status. This process reduces the bandwidth pressure on each node in the blockchain and improves the efficiency of block status synchronization.
[0035] In one implementation, as Figure 2 shown, node A can obtain the partial status data of the first block from the corresponding storage devices of different second nodes. As Figure 2 shown, storage device 1A obtains the first part of the status data of the first block from storage device 1B, storage device 2A obtains the second part of the status data of the first block from storage device 2C, and storage device 3A obtains the third part of the status data of the first block from storage device 3D. In this way, node A that needs to synchronize the block status can pull data of different shards at the same block height from multiple second nodes simultaneously, that is, it can synchronize the block status data of the same block height (the first block) from the storage devices of different second nodes, better accelerating the synchronization efficiency.
[0036] The method for synchronizing the block status in the blockchain provided in this specification will be described in detail below.
[0037] Figure 3 The flowchart showing the method for synchronizing the block status in the blockchain in an embodiment of this specification, where the method is executed by the first node in the blockchain (such as Figure 2 node A shown in Figure 2 ), the first node includes a first storage device for storing block status data (such as storage device 1A shown in Figure 2 ), and a second storage device (such as storage device 2A shown in Figure 2 ), and the blockchain further includes multiple second nodes (such as including Figure 2the storage devices 1B, 1C, and 1D shown in [FIGURE] and a fourth storage device (e.g., including Figure 2 the storage devices 2B, 2C, and 2D shown in [FIGURE], where the first storage device corresponds to the third storage device, and the second storage device corresponds to the fourth storage device. The method includes:
[0038] Step S310, the first storage device obtains the first partial status data of the first block to be synchronized from the third storage device.
[0039] Step S320, the second storage device obtains the second partial status data of the first block from the fourth storage device.
[0040] It can be understood that the blockchain is a blockchain based on a state sharding architecture. The first node (for the sake of clear description, hereinafter replaced by Figure 2 node A in [FIGURE]) can be any node in the blockchain. Among them, the first storage device (for the sake of clear description, hereinafter replaced by Figure 2 storage device 1A in [FIGURE]) corresponds to the third storage device of each second node (for the sake of clear description, hereinafter replaced by Figure 2 storage devices 1B, 1C, and 1D in [FIGURE]), that is, there is a corresponding relationship. That is, storage device 1A and storage devices 1B, 1C, and 1D belong to the same shard, that is, they store the status data of the same account. For example, they all store the status data of the aforementioned accounts a to c. The second storage device (for the sake of clear description, hereinafter replaced by Figure 2 storage device 2A in [FIGURE]) corresponds to the fourth storage device of each second node (for the sake of clear description, hereinafter replaced by Figure 2 storage devices 2B, 2C, and 2D in [FIGURE]), that is, storage device 2A and storage devices 2B, 2C, and 2D belong to the same shard, that is, they store the status data of the same account. For example, they all store the status data of the aforementioned accounts d and e.
[0041] Subsequently, when there is a situation where the progress of executing transactions between nodes in the blockchain is different, that is, the generated current block height (i.e., block height) is different. For example, when the current block height of node A lags behind the current block heights of a specified number of nodes (i.e., the fifth nodes of the first preset number) among multiple second nodes (i.e., node B, node C, and node D), in view of the corresponding relationship existing between the foregoing storage devices, storage device 1A can synchronize (i.e., obtain) the first part of the state data of the first block to be synchronized from the corresponding storage device (storage device 1B, storage device 1C, or storage device 1D) of any one of the specified number of nodes among the multiple second nodes. Storage device 2A can synchronize the second part of the state data of the first block from the corresponding storage device (storage device 2B, storage device 2C, or storage device 2D) of any one of the specified number of nodes among the multiple second nodes.
[0042] Among them, the blocks of node A lagging behind a specified number of nodes among the multiple second nodes at least include the first block. For example, the block height of node A is M (i.e., the highest block is block M), and the block height of the i-th node among the specified number of nodes among the multiple second nodes is Ni (i.e., the highest block of the i-th node is block Ni). The value range of i is an integer in [1, q], and q is the specified number (i.e., the first preset number). Assuming that Nt is the minimum block height of the specified number of nodes among the multiple second nodes, correspondingly, the first block can include all the blocks from block M + 1 to block Nt, or can include some of the blocks from block M + 1 to block Nt. It can be understood that the block height of the first block is not greater than the minimum block height of the specified number of nodes among the multiple second nodes, that is, the block height of the first block is not greater than the minimum block height of the fifth nodes of the first preset number.
[0043] In one embodiment, node A can synchronize the state data of the first block from different storage devices of the same second node. For example, the storage devices that provide the partial state data of the first block to each storage device of node A belong to the same node (for example, all belong to data node B, or all belong to node C, or all belong to node D). In another embodiment, in order to better improve the block synchronization efficiency, node A can obtain the corresponding partial state data of different storage devices from different nodes. For example, the storage devices that provide the partial state data of the first block to each storage device of node A belong to different nodes respectively. Specifically, among the multiple second nodes, there can be at least a third node (such as Figure 2 the node B shown) and a fourth node (such as Figure 2 the node C shown);
[0044] In step S310, it is specifically set that the first storage device (i.e., Figure 2The storage device 1A shown in [Figure X] obtains the first part of the status data of the first block to be synchronized from the third storage device of the third node (i.e., storage device 1B).
[0045] In step S320, specifically, the second storage device (i.e., Figure 2 the storage device 2A shown in [Figure X]) obtains the second part of the status data of the first block from the fourth storage device of the fourth node (i.e., storage device 2C).
[0046] In this process, node A that needs to synchronize the block status can pull data of different shards at the same block height from multiple nodes (i.e., multiple second nodes) simultaneously. That is, it can synchronize the block status data of the same block height (the first block) from the storage devices of different nodes, which can better improve the synchronization efficiency and speed up the synchronization speed.
[0047] It can be understood that to ensure the normal operation of the blockchain, each node in the blockchain can broadcast its block height information (i.e., the current highest block height of the blockchain node itself) periodically or aperiodically. In this way, each node in the blockchain can know the transaction execution progress of other nodes and determine whether its own transaction execution progress lags behind that of other nodes, that is, determine whether its own block height lags behind the block heights of other nodes. In the case where it is determined that its own block height lags behind the block heights of other nodes, it is necessary to catch up with the block height. In one implementation, each node in the blockchain may further include a control device, and the block height information of each node is broadcast through its control device.
[0048] Specifically, as Figure 4 shown, in step S401, the control device A broadcasts the block height information of node A periodically or aperiodically, and the control devices of each second node (node B, node C, and node D) broadcast the block height information of their respective nodes periodically or aperiodically. The block height information includes the current highest block height of the corresponding node.
[0049] Then, in step S402, the control device A obtains from the control devices of multiple second nodes (such as Figure 2The control devices B, C, and D) shown receive block height information. Specifically, when the control device A receives the block height information of each second node, it compares the received block height information with the block height information of node A itself. When the control device A determines that the block heights of the first preset number of nodes (also referred to as the fifth nodes) among the multiple second nodes are greater than the block height of node A, it determines the minimum block height from the block heights of the first preset number of nodes, and continues to determine whether the minimum block height of the first preset number of nodes is greater than the block height of node A by a second preset number. If the determination result is yes, that is, the minimum block height of the first preset number of nodes is greater than the block height of node A by the second preset number, then step S403 is executed. Among them, the first preset number can be set according to actual requirements and the actual number of nodes in the blockchain, and the second preset number can be set according to actual requirements. For example, it can be set to 1000, and the embodiments of this specification do not limit its specific value.
[0050] In another implementation, if the minimum block height of the first preset number of nodes is not greater than the block height of node A by the second preset number, the control device A can synchronize the status data of node A by gradually replaying transactions. Specifically, the control device A, for example, obtains the target transaction from other nodes and distributes the obtained target transaction to its respective storage devices. Each storage device executes the corresponding target transaction and updates its status data, where the target transaction is the transaction stored in the next block after the latest block of node A (for example, the block after block M mentioned above, block M + 1) to the target block to be synchronized (for example, block Nt mentioned above).
[0051] When the control device A determines that the block heights of the first preset number of nodes among the multiple second nodes are greater than the block height of node A, and the minimum block height among the first preset number of nodes is greater than the block height of node A by the second preset number, in step S403, it broadcasts a block synchronization request, and the block synchronization request includes a status synchronization request for the first block. In one case, the control device A can first determine the first block based on the block height of node A and the minimum block height of the first preset number of nodes, where the block height of the first block is not greater than the minimum block height of the first preset number of nodes. For example, assume that the block height of node A is M and the minimum block height of the first preset number of nodes is Nt. The control device A can determine that the first block includes all blocks from block M + 1 to block Nt, that is, the block height of the first block is equal to the minimum block height of the first preset number of nodes, or it can include some blocks from block M + 1 to block Nt, that is, the block height of the first block is less than the minimum block height of the first preset number of nodes. For example, it includes blocks from block M + 1 to block X, where block X is a certain block between block M + 1 and block Nt.
[0052] In one case, the block synchronization request may carry the block height of node A and the block height of the first block. For example, in the case where the first block includes all blocks from block M + 1 to block Nt, the block synchronization request may carry the block height M of node A and the block height Nt of block Nt. Among them, the block synchronization request may be expressed as <request_fast_sync, M, Nt>, indicating the status data of synchronizing all blocks from block M + 1 to block Nt.
[0053] Next, after control device A broadcasts the block synchronization request, it can wait to receive feedback from the second node. Specifically, after the control device of any node (such as Figure 2 node B in it) receives the block synchronization request broadcast by control device A, if it determines that its block height (i.e., the block height of node B) is not less than the block height of the first block, it can give feedback to node A for this block synchronization request, that is, send a block synchronization reply to node A. Among them, the block synchronization reply may at least include the connection information of the storage device of node B itself for node A to synchronize the status data of the first block.
[0054] In one case, to ensure the security and normal operation of node A, the block synchronization reply may further include the block header information of the first block. For example, in the case where the first block includes all blocks from block M + 1 to block Nt, the block header information may at least include the state root (which can also be called the block hash) of block Nt. In another case, the block synchronization reply may further include the sub-state roots of the corresponding partial status data of the first block stored in each storage device of node B.
[0055] In one case, the block synchronization reply may be expressed as <response_fast_sync, Nt, Nt_block_header, [shard_address, sub_state_root]>, where Nt_block_header represents the block header information of block Nt, and [shard_address, sub_state_root] represents the connection information of each storage device of node B and the sub-state roots of the corresponding partial status data of the first block. Among them, the block header information of the first block and the sub-state roots of the corresponding partial status data of the first block stored in each storage device of node B can be used to verify the block status synchronization result of node A. For the sake of clear layout, the specific verification process will be introduced later.
[0056] Subsequently, in one embodiment, node A can synchronize status data from the corresponding storage devices of different second nodes, such as Figure 4As shown, in step S404, control device A receives connection information of storage device 1B (the third storage device) in node B from control device B (i.e., the second control device), including address information of storage device 1B, such as an IP address. Then, in step S405, control device A instructs storage device 1A to synchronize the first part of the status data from storage device 1B in node B according to the connection information. Specifically, control device A may send a first synchronization instruction to storage device 1A, and the first synchronization instruction includes the connection information of storage device 1B in node B. Subsequently, after storage device 1A obtains the first synchronization instruction, in step S310, it is configured to (i.e., in step S406), storage device 1A synchronizes the first part of the status data from storage device 1B in node B according to the connection information.
[0057] Similarly, in step S407, control device A may also receive connection information of storage device 2C (i.e., the fourth storage device) in node C from control device C (i.e., the third control device), including address information of storage device 2C, such as an IP address; then, in step S408, control device A instructs storage device 2A to synchronize the second part of the status data from storage device 2C in node C according to the connection information of storage device 2C in node C. Specifically, control device A may send a second synchronization instruction to storage device 2A, and the second synchronization instruction includes the connection information of storage device 2C in node C. Subsequently, after storage device 2A obtains the second synchronization instruction, in step S320, it is configured to (i.e., in step S409), storage device 2A synchronizes the second part of the status data from storage device 2C in node C according to the connection information of storage device 2C in node C.
[0058] It can be understood that control device A may also receive connection information of storage device 3D in node D from control device D. Furthermore, control device A instructs storage device 3A to synchronize the third part of the status data of the first block from storage device 3D in node D according to the connection information of storage device 3D in node D, so as to realize the synchronization of the block status of node A.
[0059] In one embodiment, step S404 is specifically configured such that control device A receives connection information of multiple storage devices in node B from control device B, including connection information of storage device 1B in node B, and also including connection information of storage device 2B and storage device 3B. Subsequently, control device A selects one or more storage devices from the multiple storage devices in node B for synchronizing the currently unsynchronized part of the status data of the first block. Among them, the selected one or more storage devices at least include storage device 1B in node B (i.e., the third storage device), so that storage device 1A can synchronize at least the first part of the status data from storage device 1B in node B.
[0060] Understandably, in one embodiment, after the control device A receives the connection information of the storage device sent by each second node, it selects one or more storage devices from the storage devices of the second node for synchronizing the currently unsynchronized partial status data of the first block. In one implementation, to improve the block status synchronization efficiency, the control device A can first determine a target number based on the number of storage devices of node A (referred to as the first number) and the number of multiple second nodes in the blockchain (the second number), and then select the target number (one or more) of storage devices from the storage devices of each second node for synchronizing the currently unsynchronized partial status data of the first block.
[0061] Among them, in one case, to reduce the pressure on the data transmission bandwidth and balance the bandwidth pressure of each blockchain node during the block status synchronization process, the target number can be equal to the ratio of the first number to the second number. In another case, considering that it is possible that some second nodes in the blockchain do not receive the block synchronization request broadcast by node A, and / or node A may not receive the connection information of some second nodes, the control device A can preset a node fault tolerance probability, and the target number can be equal to A / (B * c%), where A represents the first number, B represents the second number, and c% represents the node fault tolerance probability.
[0062] As Figure 2 shown, the first number is 3, the second number is 3, and assuming the node fault tolerance probability is 0, it is considered that all nodes B, C, and D in the blockchain are operating normally. After the control device A receives the connection information of the storage device of node B, it selects one storage device from the three storage devices of node B, such as selecting storage device 1B, for synchronizing the currently unsynchronized partial status data of the first block; after the control device A receives the connection information of the storage device of node C, it selects one storage device from the three storage devices of node C, such as selecting storage device 2C, for synchronizing the currently unsynchronized partial status data of the first block; after the control device A receives the connection information of the storage device of node D, it selects one storage device from the three storage devices of node D, such as selecting storage device 3D, for synchronizing the currently unsynchronized partial status data of the first block.
[0063] For another example, assume that the number of storage devices of the node (i.e., the first node) for synchronizing the block state is 50, the number of multiple second nodes in the blockchain is 20, and the node fault tolerance probability is 50%. Then, the node for synchronizing the block state allows 50% of the other nodes to have problems. The control device of the node for synchronizing the block state can synchronize partial state data of the storage devices of 50 nodes for synchronizing the block state from the storage devices of 10 (20 * 50%) second nodes. Among them, in order to improve the block state synchronization efficiency and reduce the pressure on the data transmission bandwidth, specifically, based on the connection information of the storage devices of the earliest received 10 second nodes (for the sake of clear description, called the second target nodes), 5 storage devices are selected from the storage devices of each second target node to synchronize the currently unsynchronized partial state data of the block to be synchronized.
[0064] In one embodiment, the first partial state data is the difference data between the state data of multiple first accounts in the state data of the first block and the state data of multiple first accounts in the state data of the previous block of the first block. That is to say, for example, the block height of the first node A is M, that is, the current latest block of the first node A is block M. The state data of the first block that it needs to synchronize includes the state data from block M + 1 to block Nt, that is, the difference data between the state data of block Nt and the state data of block M. Correspondingly, the first partial state data is: the difference data between the state data of multiple first accounts in the state data of block Nt and the state data of multiple first accounts in the state data of block M. The first partial state data may specifically include: the difference data of the state data of multiple first accounts between block M + 1 and block M, the difference data of the state data of multiple first accounts between block M + 2 and block M + 1, and so on, the difference data of the state data of multiple first accounts between block Nt and block Nt - 1.
[0065] Similarly, the second partial state data is the difference data between the state data of multiple second accounts in the state data of the first block and the state data of multiple second accounts in the state data of the previous block of the first block. The second partial state data may specifically include: the difference data of the state data of multiple second accounts between block M + 1 and block M, the difference data of the state data of multiple second accounts between block M + 2 and block M + 1, and so on, the difference data of the state data of multiple second accounts between block Nt and block Nt - 1. Among them, the first accounts are different from the second accounts. The multiple first accounts may be, for example, the aforementioned accounts a to c, and the multiple second accounts may be, for example, the aforementioned accounts d and e.
[0066] In the above embodiments, only the differential data of the status data of the first block and the status data of the previous block of the first block are synchronized. While ensuring the synchronization of the block status, the data transmission volume in this process is effectively controlled, and to a certain extent, the efficiency of block synchronization can be better improved.
[0067] To ensure the security and normal operation of the first node, after the respective storage devices of node A complete the synchronization of part of the status data of the first block, it is also necessary to verify the synchronization result. Correspondingly, in one embodiment, the method may further include: in step 01, the control device A receives the block header information of the first block and the first sub-state root of the first part of the status data from the control device B.
[0068] In step 02, the control device A receives the block header information of the first block and the second sub-state root of the second part of the status data from the control device C.
[0069] In step 03, the control device A verifies the first part of the status data and the second part of the status data based on the block header information of the first block, the first sub-state root, and the second sub-state root.
[0070] Wherein, the block header information includes the state root of the first block. For example, when the first block includes all blocks from block M + 1 to block Nt, the block header information includes the state root of block Nt. It can be understood that the state root in the block header information of the first block received from the control device B is the same as the state root in the block header information of the first block received from the control device C.
[0071] In one implementation, the control device A can simultaneously receive the block header information of the first block and the first sub-state root of the first part of the status data from the control device B, as well as the connection information of the respective storage devices of node B, for example, all included in the block synchronization reply of the control device B for the block synchronization request. Similarly, the control device A can also simultaneously receive the block header information of the first block and the second sub-state root of the second part of the status data from the control device C, as well as the connection information of the respective storage devices of node C.
[0072] It can be understood that the above step 01 can be executed before step 02, or after step 02, or in parallel with step 02.
[0073] After the control device A receives the block header information of the first block and the first sub-state root of the first part of the status data from the control device B, and receives the block header information of the first block and the second sub-state root of the second part of the status data from the control device C, it can verify the first part of the status data and the second part of the status data based on the block header information of the first block, the first sub-state root, and the second sub-state root.
[0074] In one embodiment, after each storage device of node A synchronizes its corresponding partial status data, it is necessary to notify control device A that the synchronization is completed, and send the sub-status root of the sub-status tree including the corresponding partial status data generated after the synchronization to control device A. Control device A performs corresponding verification based on the received sub-status roots.
[0075] Specifically, step 03 is specifically set as: verifying whether the third sub-status root of the sub-status tree including the first partial status data is equal to the first sub-status root; verifying whether the fourth sub-status root of the sub-status tree including the second partial status data is equal to the second sub-status root; verifying the third sub-status root and the fourth sub-status root based on the status root in the block header information.
[0076] It can be understood that after each storage device of node A, namely storage device 1A, storage device 2A, and storage device 3A, synchronizes the corresponding partial status data of the first block, it will generate the sub-status root of the sub-status tree including the corresponding partial status data. Among them, the sub-status root generated by storage device 1A is called the third sub-status root, and the sub-status root generated by storage device 2A is called the fourth sub-status root. Storage device 3A synchronizes the third partial status data of the first block from storage device 3D of node D. Correspondingly, control device A also receives the block header information of the first block and the sub-status root (called the fifth sub-status root) of the third partial status data from control device D, and the sub-status root generated by storage device 3A is called the sixth sub-status root. Among them, the status root in the block header information of the first block received from control device D is the same as the status roots of the block header information of the first block received from control device B and control device C.
[0077] After that, control device A can directly compare whether the third sub-status root is equal to the first sub-status root, whether the fourth sub-status root is equal to the second sub-status root, and whether the sixth sub-status root is equal to the fifth sub-status root.
[0078] In one case, if the third sub-status root is equal to the first sub-status root, it can be considered that the first partial status data is correct and there is no abnormality in the synchronization process of storage device 1A. If the fourth sub-status root is equal to the second sub-status root, it can be considered that the second partial status data is correct and there is no abnormality in the synchronization process of storage device 2A. If the sixth sub-status root is equal to the fifth sub-status root, it can be considered that the third partial status data is correct and there is no abnormality in the synchronization process of storage device 3A.
[0079] In another case, to better ensure the security of nodes in the blockchain, after the control device A determines that the third sub-state root is equal to the first sub-state root, the fourth sub-state root is equal to the second sub-state root, and the sixth sub-state root is equal to the fifth sub-state root, the control device A also needs to verify the third sub-state root, the fourth sub-state root, and the sixth sub-state root based on the state root in the block header information of the received first block. Specifically, after the control device A obtains the sub-state roots (including the third sub-state root, the fourth sub-state root, and the sixth sub-state root) of the sub-state trees of each storage device of node A, which include the corresponding partial state data, the control device A performs a summary calculation on the obtained sub-state roots to determine the summary state root. The summary state root is compared with the state root in the block header information of the first block. If the summary state root is equal to the state root in the block header information of the first block, it is determined that the first part of the state data is correct and there is no abnormality in the synchronization process of storage device 1A, the second part of the state data is correct and there is no abnormality in the synchronization process of storage device 2A, and the third part of the state data is correct and there is no abnormality in the synchronization process of storage device 3A.
[0080] In another implementation, the control device A can also directly verify the third sub-state root, the fourth sub-state root, and the sixth sub-state root based on the state root in the block header information. After the control device A obtains the sub-state roots of the sub-state trees of each storage device of node A, which include the corresponding partial state data, the control device A can directly perform a summary calculation on the obtained sub-state roots to determine the summary state root. After determining that the summary state root is equal to the state root in the block header information of the first block, it is directly determined that the partial state data of the first block synchronized by each storage device of the first node A is correct, and there is no abnormality in the synchronization process of each storage device.
[0081] It can be understood that Figure 2 The illustrated embodiment only exemplarily shows that node A includes three storage devices and synchronizes the partial state data of the first block from three second nodes. The embodiments of the present specification are not limited thereto. In fact, node A may also include other storage devices in addition to storage device 1A, storage device 2A, and storage device 3A, and the blockchain may also include other nodes in addition to node A, node B, node C, and node D. Correspondingly, in addition to synchronizing the partial state data of the first block from node B, node C, and node D, node A may also synchronize the state data of the first block from other nodes included in the blockchain.
[0082] Corresponding to the above method embodiments, an embodiment of this specification further provides a blockchain system. The blockchain system includes a first node 500, and the first node 500 includes a first storage device 510 and a second storage device 520 for storing block status data. The blockchain system further includes a plurality of second nodes, and each second node includes a third storage device and a fourth storage device for storing block status data. Among them, the first storage device corresponds to the third storage device, and the second storage device corresponds to the fourth storage device. Its schematic block diagram is as shown in Figure 5 shown and includes:
[0083] The first storage device 510 is configured to obtain the first part of the status data of the first block to be synchronized from the third storage device;
[0084] The second storage device 520 is configured to obtain the second part of the status data of the first block from the fourth storage device.
[0085] In an optional implementation manner, among the plurality of second nodes, there are a third node and a fourth node;
[0086] The first storage device 510 is specifically configured to obtain the first part of the status data of the first block to be synchronized from the third storage device of the third node;
[0087] The second storage device 520 is specifically configured to obtain the second part of the status data of the first block from the fourth storage device of the fourth node.
[0088] In an optional implementation manner, as shown in Figure 5 shown, the first node further includes a first control device 530. The first control device is configured to receive block height information from the control devices of the plurality of nodes; when it is determined that the block heights of the first preset number of fifth nodes among the plurality of second nodes are greater than the block height of the first node, and the minimum block height among the first preset number of fifth nodes is greater than the block height of the first node by a second preset number, a block synchronization request is broadcast to the plurality of second nodes, and the block synchronization request includes a status synchronization request for the first block.
[0089] In an optional implementation manner, the block height of the first block is not greater than the minimum block height among the first preset number of fifth nodes.
[0090] In an optional implementation manner, the first part of the status data is the difference data between the status data of a plurality of first accounts in the status data of the first block and the status data of the plurality of first accounts in the status data of the previous block of the first block.
[0091] In an alternative embodiment, the first node further includes a first control device 530, and the third node further includes a second control device; the first control device 530 is configured to receive connection information of a third storage device in the third node from the second control device; and instruct the first storage device to synchronize the first part of the status data from the third storage device of the third node according to the connection information.
[0092] In an alternative embodiment, the first control device 530 is specifically configured to receive connection information of a plurality of storage devices in the third node from the second control device, including the connection information of the third storage device in the third node;
[0093] The first control device 530 is further configured to select one or more storage devices from the plurality of storage devices of the third node for synchronizing the currently unsynchronized part of the status data of the first block.
[0094] In an alternative embodiment, the fourth node further includes a third control device, and the first control device 530 is further configured to receive the block header information of the first block and the first sub-state root of the first part of the status data from the second control device; receive the block header information of the first block and the second sub-state root of the second part of the status data from the third control device; and verify the first part of the status data and the second part of the status data based on the block header information of the first block, the first sub-state root, and the second sub-state root.
[0095] In an alternative embodiment, the first control device 530 is specifically configured to verify whether a third sub-state root of a sub-state tree including the first part of the status data is equal to the first sub-state root;
[0096] Verify whether a fourth sub-state root of a sub-state tree including the second part of the status data is equal to the second sub-state root;
[0097] Verify the third sub-state root and the fourth sub-state root based on the status root in the block header information.
[0098] According to an embodiment of another aspect, there is also provided a computer-readable storage medium, on which a computer program is stored. When the computer program is executed on a computer, the computer is made to execute the method for synchronizing the status of blocks in the blockchain.
[0099] According to an embodiment of still another aspect, there is also provided a computing device, including a memory and a processor, characterized in that an executable code is stored in the memory, and when the processor executes the executable code, the method for synchronizing the status of blocks in the blockchain is implemented.
[0100] In the 1990s, it was obvious to distinguish whether an improvement to a technology was a hardware improvement (e.g., improvement to the circuit structure of diodes, transistors, switches, etc.) or a software improvement (improvement to the method flow). However, with the development of technology, many improvements to method flows today can be regarded as direct improvements to the hardware circuit structure. Almost all designers obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement to a method flow cannot be implemented with a hardware entity module. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logical function is determined by the user programming the device. The designer can program by himself to "integrate" a digital system on a single PLD, without having to ask the chip manufacturer to design and fabricate a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing. The original code before compilation also has to be written in a specific programming language, which is called a Hardware Description Language (HDL). And there is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. Currently, the most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also be aware that as long as the method flow is slightly logically programmed with the above-mentioned several hardware description languages and programmed into the integrated circuit, it is easy to obtain the hardware circuit that implements the logical method flow.
[0101] The controller can be implemented in any suitable manner. For example, the controller can take the form of, for example, a microprocessor or a processor and a computer-readable medium storing computer-readable program code (such as software or firmware) executable by the (micro)processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of the controller include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, it is entirely possible to logically program the method steps to enable the controller to be implemented in the form of logic gates, switches, ASICs, programmable logic controllers, embedded microcontrollers, etc. to achieve the same function. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be regarded as the structures within the hardware component. Or even, the devices for implementing various functions can be regarded as either software modules for implementing the method or the structures within the hardware component.
[0102] The systems, devices, modules, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not exclude that with the development of future computer technologies, the computers for implementing the functions of the above embodiments can be, for example, personal computers, laptop computers, in-vehicle human-machine interaction devices, cellular phones, camera phones, smart phones, personal digital assistants, media players, navigation devices, email devices, game consoles, tablet computers, wearable devices, or any combination of these devices.
[0103] Although one or more embodiments of this specification provide method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiments is only one way among many execution orders of steps and does not represent the only execution order. When the actual device or terminal product is executed, it may be executed in the order of the method shown in the embodiments or the drawings or in parallel (for example, in a parallel processor or multi-threaded processing environment, or even in a distributed data processing environment). The term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, product or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, product or device. Without further limitation, there is no exclusion of additional identical or equivalent elements in the process, method, product or device comprising the said elements. For example, if terms such as first and second are used to denote names, they do not denote any particular order.
[0104] For convenience of description, when describing the above device, it is divided into various modules according to functions for separate description. Of course, when implementing one or more of this specification, the functions of each module can be implemented in the same or multiple software and / or hardware, or the modules implementing the same function can be realized by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in electrical, mechanical or other forms.
[0105] The present invention is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing device generate a device for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0106] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction device that implements the functions specified in one or more processes and / or blocks Figure 1 in one or more processes and / or blocks Figure 1 specified in the block or blocks.
[0107] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operational steps are performed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes and / or blocks Figure 1 in one or more processes and / or blocks Figure 1 specified in the block or blocks.
[0108] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0109] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM) and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
[0110] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology for information storage. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.
[0111] Those skilled in the art should understand that one or more embodiments of this specification can be provided as a method, a system, or a computer program product. Therefore, one or more embodiments of this specification can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, one or more embodiments of this specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0112] One or more embodiments of this specification can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of this specification can also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0113] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and reference can be made to the corresponding parts of the method embodiments for related content. In the description of this specification, the description with reference to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of this specification. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0114] The above is only the embodiment of one or more embodiments of this specification and is not used to limit one or more embodiments of this specification. For those skilled in the art, one or more embodiments of this specification can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification should be included within the scope of the claims.
Claims
1. A method for synchronizing block states in a blockchain, which is executed by a first node in the blockchain. The first node includes a first storage device and a second storage device that belong to different shards and are used to store block state data. The blockchain also includes multiple second nodes, and each second node includes a third storage device and a fourth storage device that are used to store block state data. Among them, The first storage device corresponds to the third storage device and belongs to the same shard. The second storage device corresponds to the fourth storage device and belongs to the same shard. The method includes: The first storage device obtains the first partial status data of the first block to be synchronized from the third storage device; The second storage device obtains the second partial status data of the first block from the fourth storage device.
2. The method according to claim 1, wherein Among the multiple second nodes, there are a third node and a fourth node; The first storage device obtaining the first partial status data of the first block to be synchronized from the third storage device includes: the first storage device obtains the first partial status data of the first block to be synchronized from the third storage device of the third node; The second storage device obtaining the second partial status data of the first block from the fourth storage device includes: the second storage device obtains the second partial status data of the first block from the fourth storage device of the fourth node.
3. The method according to claim 1 or 2, wherein the first node further includes a first control device, and the method further includes: The first control device receives block height information from the control devices of the multiple second nodes; When the first control device determines that the block heights of a first preset number of fifth nodes among the multiple second nodes are greater than the block height of the first node, and the minimum block height among the first preset number of fifth nodes is greater than the block height of the first node by a second preset number, the first control device broadcasts a block synchronization request to the multiple second nodes, and the block synchronization request includes a status synchronization request for the first block.
4. The method according to claim 3, wherein the block height of the first block is not greater than the minimum block height among the first preset number of fifth nodes.
5. The method according to claim 1 or 2, wherein the first partial status data is the difference data between the status data of multiple first accounts in the status data of the first block and the status data of the multiple first accounts in the status data of the previous block of the first block.
6. According to the method of claim 1 or 2, the first node includes a first control device, and the third node included in the second node includes a second control device; the method further includes: The first control device receives connection information of the third storage device in the third node from the second control device; The first control device instructs the first storage device to synchronize the first partial status data from the third storage device of the third node according to the connection information.
7. The method according to claim 6, wherein the first control device receiving the connection information of the third storage device in the third node from the second control device includes: The first control device receives connection information of multiple storage devices in the third node from the second control device, including the connection information of the third storage device in the third node; The method further includes: The first control device selects one or more storage devices from the multiple storage devices of the third node for synchronizing the currently unsynchronized partial status data of the first block.
8. The method according to claim 6, wherein the fourth node included in the second node includes a third control device, and the method further includes: The first control device receives the block header information of the first block and the first sub-state root of the first part of the state data from the second control device; The first control device receives the block header information of the first block and the second sub-state root of the second part of the state data from the third control device; The first control device verifies the first part of the state data and the second part of the state data based on the block header information of the first block, the first sub-state root, and the second sub-state root.
9. The method according to claim 8, wherein the verifying the first part of the state data and the second part of the state data based on the block header information of the first block, the first sub-state root, and the second sub-state root includes: Verifying whether a third sub-state root of a sub-state tree including the first part of the state data is equal to the first sub-state root; Verifying whether a fourth sub-state root of a sub-state tree including the second part of the state data is equal to the second sub-state root; Verifying the third sub-state root and the fourth sub-state root based on the state root in the block header information.
10. A blockchain system, the blockchain system includes a first node, the first node includes a first storage device and a second storage device that belong to different shards and are used to store block status data, the blockchain system further includes a plurality of second nodes, and each second node includes a third storage device and a fourth storage device that are used to store block status data, wherein, The first storage device corresponds to the third storage device and belongs to the same shard, and the second storage device corresponds to the fourth storage device and belongs to the same shard, including: The first storage device is configured to obtain the first part of the state data of the first block to be synchronized from the third storage device; The second storage device is configured to obtain the second part of the state data of the first block from the fourth storage device.
11. The blockchain system according to claim 10, wherein, The plurality of second nodes include a third node and a fourth node; The first storage device is specifically configured to obtain the first part of the state data of the first block to be synchronized from the third storage device of the third node; The second storage device is specifically configured to obtain the second part of the state data of the first block from the fourth storage device of the fourth node.
12. The blockchain system according to claim 10 or 11, wherein the first node further includes a first control device, and the first control device is configured to receive block height information from the control devices of the plurality of second nodes; when it is determined that the block heights of a first preset number of fifth nodes among the plurality of second nodes are greater than the block height of the first node, and the minimum block height among the first preset number of fifth nodes is greater than the block height of the first node by a second preset number, broadcast a block synchronization request to the plurality of second nodes, and the block synchronization request includes a state synchronization request for the first block.
13. The blockchain system according to claim 12, wherein the block height of the first block is not greater than the minimum block height among the first preset number of fifth nodes.
14. The blockchain system according to claim 10 or 11, wherein the first part of the state data is the difference data between the state data of a plurality of first accounts in the state data of the first block and the state data of the plurality of first accounts in the state data of the previous block of the first block.
15. The blockchain system according to claim 10 or 11, wherein the first node further includes a first control device, and the third node included in the second node further includes a second control device; the first control device is configured to receive connection information of a third storage device in the third node from the second control device; and instruct the first storage device to synchronize the first part of the status data from the third storage device of the third node according to the connection information.
16. The blockchain system according to claim 15, wherein the first control device is specifically configured to receive connection information of a plurality of storage devices in the third node from the second control device, including the connection information of the third storage device in the third node; The first control device is further configured to select one or more storage devices from the plurality of storage devices of the third node for synchronizing the currently unsynchronized part of the status data of the first block.
17. The blockchain system according to claim 15, wherein the fourth node included in the second node further includes a third control device, and the first control device is further configured to receive the block header information of the first block and the first sub-state root of the first part of the status data from the second control device; receive the block header information of the first block and the second sub-state root of the second part of the status data from the third control device; and verify the first part of the status data and the second part of the status data based on the block header information of the first block, the first sub-state root, and the second sub-state root.
18. The blockchain system according to claim 17, wherein the first control device is specifically configured to verify whether a third sub-state root of a sub-state tree including the first part of the status data is equal to the first sub-state root; Verify whether a fourth sub-state root of a sub-state tree including the second part of the status data is equal to the second sub-state root; Verify the third sub-state root and the fourth sub-state root based on the status root in the block header information.
19. A computer-readable storage medium, on which a computer program is stored, and when the computer program is executed in a computer, the computer is made to execute the method according to any one of claims 1-9.
20. A computing device, including a memory and a processor, wherein an executable code is stored in the memory, and when the processor executes the executable code, the method according to any one of claims 1-9 is implemented.
Citation Information
Patent Citations
Method and device for executing block in block chain system
CN113064764A
Fragment storage device oriented to graph block chain
CN113553375A