Block synchronization method, computer equipment and computer program product

By obtaining the blocks to be synchronized from other nodes in the blockchain and synchronizing according to the verification value, the problem of inefficient block synchronization in the prior art is solved, and more efficient block synchronization is achieved.

CN120179737AInactive Publication Date: 2025-06-20HANGZHOU HIGH-TECH ZONE (BINJIANG) INSTITUTE OF BLOCKCHAIN & DATA SECURITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510672333.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-23
Publication Date
2025-06-20
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing block synchronization method is inefficient, has poor data consistency, and it is difficult to detect abnormalities in a timely manner.

Method used

By obtaining the blocks to be synchronized corresponding to the target block range from other nodes, the root verification value of the block to be synchronized is determined based on the verification value of each block in the blockchain, and synchronizes when the root verification value matches the reference verification value in other nodes.

Benefits of technology

The situation of verifying each block in sequence is reduced, and the efficiency of block synchronization is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179737A_ABST
    Figure CN120179737A_ABST
Patent Text Reader

Abstract

The invention discloses a block synchronization method, computer equipment and a computer program product, and the method comprises the steps: obtaining a to-be-synchronized block corresponding to a target block range from other nodes, determining a root verification value corresponding to the to-be-synchronized block according to a verification value of each block in a block chain, and synchronizing the to-be-synchronized block according to the root verification value. Under the condition that the root verification value is matched with the reference verification value in other nodes, the to-be-synchronized block is synchronized, the root verification value of the to-be-synchronized block only needs to be determined based on the verification value of each block, and the to-be-synchronized block is verified based on the root verification value, so that the condition that each block is verified in sequence is reduced, and the verification efficiency of the to-be-synchronized block is improved. And the block synchronization efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the technical field of data processing, and particularly relates to a method for synchronizing blocks, a computer device, and a computer program product. Background Art

[0002] A blockchain is a distributed ledger that combines data blocks into a specific data structure in a chain-like manner, with characteristics such as decentralization and immutability, ensuring the authenticity and security of data in the blockchain.

[0003] The blockchain can ensure the consistency of data among each node by synchronizing each block. During the block synchronization process, the prior art needs to sequentially traverse each block and verify the legitimacy of each block including the block to be synchronized. Using this synchronization method has low efficiency, poor data consistency, and it is difficult to detect anomalies in a timely manner during synchronization. Summary of the Invention

[0004] Embodiments of this application provide a method for synchronizing blocks, a computer device, and a computer program product, aiming to solve the problem of low efficiency in block synchronization during the existing block synchronization process.

[0005] In a first aspect, embodiments of this application provide a method for synchronizing blocks. The method is applied to a synchronization node in a blockchain, and the method includes: Obtain blocks to be synchronized corresponding to a target block range from other nodes; Determine a root verification value corresponding to the blocks to be synchronized according to the verification values of each block in the blockchain; Synchronize the blocks to be synchronized when the root verification value matches a reference verification value in the other nodes.

[0006] In a possible implementation manner of the above first aspect, before obtaining the blocks to be synchronized corresponding to a target block range from other nodes, the method further includes: Obtain a first block height of the other nodes in the blockchain; When the first block height is greater than a second block height, determine that a block synchronization event is triggered, and execute the step of obtaining the blocks to be synchronized corresponding to a target block range; where the second block height is the block height of the synchronization node.

[0007] In a possible implementation manner of the above first aspect, obtaining the blocks to be synchronized corresponding to a target block range from other nodes includes: When the block synchronization event is triggered, determine a target block range according to the first block height and the second block height; wherein, the target block range is the range from the second block height to the first block height; According to the target block range, obtain the blocks to be synchronized corresponding to the target block range from the other nodes.

[0008] In a possible implementation manner of the first aspect above, before determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain, the method further includes: Determine the verification blocks in the blockchain except the block to be synchronized; Obtain the target verification values corresponding to the verification blocks from the other nodes, so as to execute the step of determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain based on the target verification values; Wherein, the target verification value is determined by the other nodes from a preset verification accumulation tree, the verification accumulation tree includes at least one leaf node and at least one parent node, each leaf node corresponds to each block respectively, and each parent node is calculated and generated by the verification values corresponding to at least one leaf node.

[0009] In a possible implementation manner of the first aspect above, the target verification value includes the verification value of the target parent node and the verification value of the target leaf node in the verification accumulation tree, the target parent node is the parent node generated by the verification block in the verification accumulation tree, and the target leaf node is the leaf node corresponding to the verification block in the verification accumulation tree.

[0010] In a possible implementation manner of the first aspect above, determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain includes: Generate the root verification value corresponding to the block to be synchronized according to the target verification value and the verification value corresponding to the block to be synchronized.

[0011] In a possible implementation manner of the first aspect above, the step of synchronizing the block to be synchronized when the root verification value matches the reference verification value in other nodes includes: Match the root verification value with the reference verification value in other nodes; When the root verification value matches the reference verification value in other nodes, execute the block to be synchronized and submit the executed block to be synchronized to the local ledger.

[0012] In a possible implementation manner of the above first aspect, before determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain, the method further includes: When the number of blocks to be synchronized is greater than a preset number threshold, divide the blocks to be synchronized into at least two sets of blocks to be synchronized; Successively execute the step of determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain for each set of blocks to be synchronized.

[0013] In a second aspect, an embodiment of the present application provides a block synchronization device, which is applied to a synchronization node in a blockchain. The device includes: An acquisition module, configured to acquire blocks to be synchronized corresponding to a target block range from other nodes; A determination module, configured to determine the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain; A synchronization module, configured to synchronize the blocks to be synchronized when the root verification value matches the reference verification value in the other nodes.

[0014] In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the block synchronization method provided in the above first aspect.

[0015] In a fourth aspect, an embodiment of the present application provides a computer program product, including a computer program. When the computer program runs on a computer, it causes the computer to execute the block synchronization method provided in the above first aspect.

[0016] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the block synchronization method provided in the above first aspect.

[0017] It can be understood that the beneficial effects of the above second aspect to fifth aspect can refer to the relevant descriptions in the above first aspect, and will not be repeated here.

[0018] The beneficial effects of the embodiments of the present application compared with the prior art are: In an embodiment of the present application, by obtaining the blocks to be synchronized corresponding to the target block range from other nodes, determining the root verification value corresponding to the blocks to be synchronized according to the verification values of each block in the blockchain, and synchronizing the blocks to be synchronized when the root verification value matches the reference verification value in other nodes, only the verification value of each block needs to be used to determine the root verification value of the blocks to be synchronized, so as to verify the blocks to be synchronized based on the root verification value, reducing the situation of verifying each block in sequence and improving the efficiency of block synchronization. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 is a flowchart of the steps of a method for synchronizing blocks provided in an embodiment of the present application; Figure 2 is a schematic diagram of the distribution of block positions in a node provided in an embodiment of the present application; Figure 3 is a flowchart of the steps of another method for synchronizing blocks provided in an embodiment of the present application; Figure 4 is a schematic diagram of a verification accumulative tree provided in an embodiment of the present application; Figure 5 is a schematic diagram of another verification accumulative tree provided in an embodiment of the present application; Figure 6 is a schematic diagram of the process of block synchronization provided in an embodiment of the present application; Figure 7 is a schematic diagram of the structure of a block synchronization device provided in an embodiment of the present application; Figure 8 is a block diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0020] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0021] A blockchain is a distributed ledger that combines data blocks in a chain-like manner into a specific data structure, and has characteristics such as decentralization and immutability. The blockchain can ensure the authenticity and security of data, and thus transactions can be carried out through the blockchain, significantly improving the transparency and security of transactions.

[0022] Specifically, the blockchain may include multiple nodes, and a local ledger is built in each node to store the data of each block in the blockchain using the local ledger. In order to improve the authenticity and security of the data in the blockchain, it is necessary to ensure that the data stored in the local ledgers of each node is consistent.

[0023] Currently, there will be situations in the blockchain that cause data differences among nodes. For example, there are newly added nodes in the blockchain, or a certain node in the blockchain loses data due to network latency, etc. Based on this, each node in the blockchain will perform block synchronization to ensure data consistency, that is, the node that detects data differences requests to obtain the data of the missing blocks from other nodes.

[0024] During the process of block synchronization, in order to ensure the security of data in the blockchain, it is necessary to verify the legitimacy of the obtained blocks, and then execute and submit the blocks after the verification passes.

[0025] However, since blocks are usually stored in a hash chain structure in nodes, when verifying blocks, it is necessary to verify them sequentially starting from the first block according to the link order of each block in the hash chain structure until all blocks are verified successfully, resulting in the problem of low efficiency of block synchronization.

[0026] Based on this, the present application provides a method for synchronizing blocks, a computer device, and a computer program product. By obtaining the blocks to be synchronized corresponding to the target block range from other nodes, determining the root verification value corresponding to the blocks to be synchronized according to the verification value of each block in the blockchain, and synchronizing the blocks to be synchronized when the root verification value matches the reference verification value in other nodes, it is only necessary to determine the root verification value of the blocks to be synchronized based on the verification value of each block to verify the blocks to be synchronized based on the root verification value, reducing the situation of verifying each block sequentially and improving the efficiency of block synchronization.

[0027] See Figure 1 , Figure 1 shows a flowchart of the steps of a method for synchronizing blocks provided by an embodiment of the present application. This method is applied to a synchronization node in the blockchain. The blockchain may include multiple nodes, and a node may be a device connected to the blockchain, such as a computer, a server, a mobile device, an intelligent device, etc. A node can create blocks, verify the data of the blocks, and broadcast the blocks to all nodes in the blockchain. Then, each node can store the data of all the created blocks. The synchronization node may be a node in the blockchain that needs to perform block synchronization.

[0028] The method may specifically include the following steps: Step 101, obtain the blocks to be synchronized corresponding to the target block range from other nodes.

[0029] Among them, the target block range may be the range of blocks to be synchronized, and the blocks to be synchronized may be the blocks that need to be synchronized.

[0030] In practical applications, each node in the blockchain can detect whether a block synchronization operation needs to be performed, and then can determine that the nodes in the blockchain that need to perform the block synchronization operation are synchronization nodes.

[0031] In a specific implementation, each node in the blockchain can communicate with each other. Then, for each node, when it detects a difference between the data of the blocks stored in the node and the on-chain data in the blockchain, it can determine that the node needs to perform a block synchronization operation and determine that the node is a synchronization node. When no difference is detected, it can determine that the node does not need to perform a block synchronization operation.

[0032] Specifically, the block synchronization operation can be an operation to synchronize the blocks stored in the node. The on-chain data of the blockchain can be a set of block data that has passed consensus verification. The set of block data can include the data of each block in the blockchain. Generally, the on-chain data can include the block height of the blockchain.

[0033] For each synchronization node, it can determine the range of the blocks that the synchronization node needs to synchronize when performing the block synchronization operation, obtain the target block range, and determine other nodes in the blockchain except the synchronization node. Then, it can obtain at least one block corresponding to the target block range from other nodes to obtain the blocks to be synchronized.

[0034] In an embodiment of the present application, before step 101, the following steps may further be included: Obtain the first block height of other nodes in the blockchain. When the first block height is greater than the second block height, determine that a block synchronization event is triggered, and execute the step of obtaining the blocks to be synchronized corresponding to the target block range from other nodes.

[0035] Wherein, the first block height can be the block height of other nodes, and other nodes can be nodes in the blockchain except the synchronization node. The second block height can be the block height of the synchronization node. The block height can be the height from the first block to the last block in the node, and different blocks in the same node can correspond to different heights. The block synchronization event can be an event for performing a block synchronization operation.

[0036] In practical applications, any node in the blockchain can communicate with other nodes in the blockchain. Consequently, any node in the blockchain can obtain the block height of other nodes to get the first block height. After obtaining the first block height, the block height of this node can be determined to get the second block height. Then, the first block height can be compared with the second block height. When the first block height is greater than the second block height, it can be determined that there are differences between the data of the blocks stored by this node and the on-chain data in the blockchain. Specifically, it can be that the number of blocks stored by this node is less than the number of blocks stored by other nodes, indicating that there is a data loss situation for the data stored by this node compared to the data stored by other nodes. Thus, it is necessary to perform a block synchronization operation on this node, that is, it can be determined to trigger a block synchronization event and execute the step of obtaining the blocks to be synchronized corresponding to the target block range.

[0037] As an example, the blockchain can include multiple nodes, which can include node A and node B. The block height of node A can be 5, that is, the height from the first block to the last block in the blocks stored by node A is 5. The block height of node B can be 7, that is, the height from the first block to the last block in the blocks stored by node B is 7. Then, for node A, node A can communicate with node B and obtain the block height of node B as 7. Further, it can be determined that the block height of node B is greater than the block height of node A, that is, the first block height is greater than the second block height, and it is determined that it is necessary to perform a block synchronization operation on node A, that is, node A triggers a block synchronization event.

[0038] In an embodiment of the present application, step 101 may include steps 1011 to 1012: Step 1011, when a block synchronization event is triggered, determine the target block range according to the first block height and the second block height.

[0039] Among them, the target block range may be the range from the second block height to the first block height.

[0040] When a block synchronization event is triggered, the target block range can be determined according to the first block height and the second block height to obtain the range from the second block height to the first block height.

[0041] For example, the block height of the synchronization node can be 4, while the block height of one of the other nodes in the blockchain can be 7. Then, it can be determined that the target block range is the range from height 5 to height 7.

[0042] Step 1012, according to the target block range, obtain the blocks to be synchronized corresponding to the target block range from other nodes.

[0043] After obtaining the target block range, a request for obtaining the blocks to be synchronized can be generated, and the request includes the target block range. Then, the request can be sent to other nodes. After receiving the request, other nodes can determine the blocks to be synchronized corresponding to the target block range, that is, determine the blocks within the target block range as the blocks to be synchronized, and retrieve the blocks to be synchronized, so as to feedback the retrieved blocks to be synchronized to the synchronization node. Thus, the synchronization node can obtain the blocks to be synchronized corresponding to the target block range from other nodes.

[0044] As an example, the target block range can be the range from height 5 to height 7. Then, the synchronization node can generate a request including the target block range and send the request to other nodes. After receiving the request, other nodes can determine the blocks within the target block range as the blocks to be synchronized, that is, determine the blocks within the range from height 5 to height 7 as the blocks to be synchronized, specifically including the block with height 5, the block with height 6, and the block with height 7. Then, the block with height 5, the block with height 6, and the block with height 7 can be feedback to the synchronization node, and the synchronization node can obtain the blocks to be synchronized corresponding to the target block range.

[0045] It should be understood that since each block is published in the blockchain at different times, that is, each block can correspond to different publication times. Then, each block can be stored in the node in the order of the publication time. Thus, the position of the block stored in the node can be represented by the height of the block, and the block at the corresponding position can be retrieved.

[0046] See Figure 2 , Figure 2 shows a schematic diagram of the block position distribution in a node provided by an embodiment of the present application. As Figure 2 shown, block a0 can be the first block stored in the order of the publication time, block a1 can be the second block stored in the order of the publication time. Similarly, block a6 can be the seventh block stored in the order of the publication time. Then, each block can be stored in node A in the order of the publication time. Among them, the height of block a0 can be 1, indicating that block a0 is stored in the first position in node A. The height of block a1 can be 2, indicating that block a2 is stored in the second position in node A. And so on, the height of block a6 can be 7, indicating that block a6 is stored in the seventh position in node A.

[0047] Step 102: Determine the root verification value corresponding to the block to be synchronized according to the verification value of each block in the blockchain.

[0048] Among them, the verification value can be data for verifying the legality of the block, and the root verification value can be data for verifying the legality of all blocks to be synchronized.

[0049] After obtaining the blocks to be synchronized, the verification values of each block in the blockchain can be determined, and then, based on the verification values of each block, the root verification value for verifying all the blocks to be synchronized can be calculated.

[0050] In practical applications, since each node can store the data of all blocks in the blockchain, specifically including the verification values of each block, when requesting from other nodes to obtain the blocks to be synchronized corresponding to the target block range, the verification values of each block can also be requested, so that the root verification value can be calculated based on the verification values of each block.

[0051] As an example, since each node can store the data of all blocks in the blockchain, the data stored in the synchronization node can include the data of all blocks except the blocks to be synchronized. Then, when requesting from other nodes to obtain the verification values of each block, only the verification values of the blocks to be synchronized need to be requested.

[0052] As another example, since each node can store the data of all blocks in the blockchain, the verification value of each block can be calculated based on the data of each block, and the root verification value can be calculated according to the verification values of each block.

[0053] Specifically, the data of the block can include data such as transaction records and contract codes. The hash function can be used to calculate the data of the block to obtain the hash value of each block, which is the verification value.

[0054] In an embodiment of the present application, a block can include a block header and a block body. Among them, the block header can store the verification value of the previous block, and the block body can store transaction data including transaction records and contract codes.

[0055] In practical applications, since the blocks are stored in the order of the release time, when creating a new block, the previous block before creating this block can be determined, and the verification value of the previous block can be calculated, so that the verification value of the previous block can be stored in the block header of this block, so that when the synchronization node requests to obtain the blocks to be synchronized, the verification value can be obtained from the block header of each block.

[0056] For example, block a0 can be the first block stored in the order of the release time, and block a1 can be the second block stored in the order of the release time. Then, the block header of block a1 can store the verification value of block a0, and so on. The block header of each block can store the verification value of the previous block.

[0057] In an embodiment of the present application, before step 102, the following steps may further be included: When the number of blocks to be synchronized is greater than a preset number threshold, divide the blocks to be synchronized into at least two sets of blocks to be synchronized, and sequentially perform the step of determining the root verification value corresponding to the blocks to be synchronized according to the verification values of each block in the blockchain for each set of blocks to be synchronized.

[0058] Among them, the number threshold can be used to determine whether it is necessary to divide the blocks to be synchronized, and the set of blocks to be synchronized can be a set including at least one block to be synchronized.

[0059] Specifically, the number threshold can be user-defined, can be obtained based on experience, or can be determined based on the working performance of the synchronization node.

[0060] After obtaining the blocks to be synchronized, the number of blocks to be synchronized can be determined, and the number of blocks to be synchronized is compared with the preset number threshold. When the number of blocks to be synchronized is greater than the preset number threshold, divide the blocks to be synchronized into at least two sets of blocks to be synchronized, and sequentially perform the step of determining the root verification value corresponding to the blocks to be synchronized according to the verification values of each block in the blockchain for each set of blocks to be synchronized. When the number of blocks to be synchronized is less than or equal to the number threshold, there is no need to divide the blocks to be synchronized and then perform the block synchronization operation.

[0061] As an example, after determining the number of blocks to be synchronized, the number threshold can be determined based on the working performance of the synchronization node. Specifically, the number threshold can be determined based on the working frequency of the synchronization node and the maximum number of processes used to perform the block synchronization operation in the synchronization node.

[0062] Step 103, when the root verification value matches the reference verification value in other nodes, synchronize the blocks to be synchronized.

[0063] Among them, the reference verification value can be data used to verify the root verification value.

[0064] After obtaining the root verification value, the root verification value can be matched with the reference verification value in other nodes. Furthermore, when the root verification value matches the reference verification value, it is determined that the verification is passed, and the blocks to be synchronized are synchronized.

[0065] In practical applications, when the synchronization node requests to obtain the blocks to be synchronized within the target block range from other nodes, it can also request to obtain the reference verification value used to verify the root verification value from other nodes. Furthermore, other nodes can extract the reference verification value stored locally in the node and feedback the extracted reference verification value to the synchronization node.

[0066] Since each node can calculate and store the verification value of each block when creating a block, and then, based on the verification value of each block stored in the node, the reference verification value corresponding to all the blocks stored in the node can be calculated.

[0067] It should be understood that since the reference verification value is calculated based on the verification value of each block in other nodes, and the root verification value is calculated based on the verification value of each block in the synchronization node and the verification value of the blocks to be synchronized fed back by other nodes, by matching the reference verification value with the root verification value, it can be determined whether there are differences between the blocks to be synchronized fed back by other nodes and the blocks stored in other nodes, and whether there are differences between the blocks stored in the synchronization node and the blocks stored in other nodes.

[0068] When the reference verification value matches the root verification value, it can be determined that there are no differences between the blocks stored in the synchronization node and the blocks to be synchronized fed back by other nodes and the blocks stored in other nodes, that is, the blocks stored in the synchronization node and the blocks to be synchronized fed back by other nodes are consistent with the block data stored in other nodes, and there is no data tampering or loss, so it can be determined that the verification passes; while when the reference verification value does not match the root verification value, it can be determined that there are differences between the blocks stored in the synchronization node and the blocks to be synchronized fed back by other nodes and the blocks stored in other nodes, that is, the blocks stored in the synchronization node and the blocks to be synchronized fed back by other nodes are inconsistent with the block data stored in other nodes, and there is data tampering or loss, so it can be determined that the verification fails.

[0069] In a specific implementation, in the case where the root verification value does not match the reference verification value in other nodes, the operation of synchronizing blocks from this other node to this synchronization node is refused, and communication is carried out with another other node to perform steps 101 to 103 based on the other node.

[0070] In the embodiment of the present application, by obtaining the blocks to be synchronized corresponding to the target block range from other nodes, and determining the root verification value corresponding to the blocks to be synchronized according to the verification value of each block in the blockchain, in the case where the root verification value matches the reference verification value in other nodes, the blocks to be synchronized are synchronized. Only based on the verification value of each block to determine the root verification value of the blocks to be synchronized, and to verify the blocks to be synchronized based on the root verification value, reducing the situation of verifying each block in turn and improving the efficiency of block synchronization.

[0071] See Figure 3 , Figure 3 shows a flowchart of the steps of another block synchronization method provided by an embodiment of the present application. This method is applied to a synchronization node in a blockchain and specifically may include the following steps: Step 301: Obtain the blocks to be synchronized corresponding to the target block range from other nodes.

[0072] Step 302: Determine the verification blocks in the blockchain other than the blocks to be synchronized.

[0073] Among them, the verification blocks can be the blocks used to verify the legality of the blocks to be synchronized.

[0074] After determining the blocks to be synchronized, the blocks in the blockchain other than the blocks to be synchronized can be determined as the verification blocks.

[0075] Step 303: Obtain the target verification values corresponding to the verification blocks from other nodes.

[0076] Among them, the target verification values can include the verification values of the target parent nodes and the target leaf nodes in the verification accumulation tree. The target parent nodes can be the parent nodes generated by the verification blocks in the verification accumulation tree, and the target leaf nodes can be the leaf nodes corresponding to the verification blocks in the verification accumulation tree. The verification accumulation tree can be a binary tree used to store the verification values of each block. The binary tree can be a tree-shaped data structure including multiple nodes and each node has at most two subtrees. The verification accumulation tree can include at least one leaf node and at least one parent node. Each leaf node corresponds to each block respectively, and each parent node is calculated and generated from the verification values corresponding to at least one leaf node.

[0077] After determining the verification blocks, while requesting to obtain the blocks to be synchronized in other nodes, the target verification values corresponding to the verification blocks can be requested from other nodes.

[0078] In practical applications, when other nodes receive the request from the synchronization node, they can determine the parent nodes generated by the verification blocks and the leaf nodes corresponding to the verification blocks from the verification accumulation tree set locally in advance according to the verification blocks in the request, obtain the target parent nodes and the target leaf nodes, and then can determine the target verification values corresponding to the verification blocks according to the verification values of the target parent nodes and the target leaf nodes.

[0079] In an embodiment of the present application, for each node in the blockchain, a verification accumulative tree can be generated in advance according to all the blocks stored in the local ledger. Specifically, the verification accumulative tree can be a multi-level tree-shaped data structure. By determining all the blocks stored in the local ledger, the leaf nodes in the verification accumulative tree can be generated, and the verification value of each block can be determined as the value of the leaf node, so as to obtain the first-layer data in the verification accumulative tree. After obtaining the first-layer data, the parent nodes of the second-layer data can be generated in sequence according to every two leaf nodes in the first-layer data, and the value of each parent node in the second-layer data can be calculated based on the values of every two leaf nodes, so as to obtain the second-layer data in the verification accumulative tree. After obtaining the second-layer data, the parent nodes of the third-layer data can be generated in sequence according to every two parent nodes in the second-layer data, and the value of each parent node in the third-layer data can be calculated based on the values of every two parent nodes in the second-layer data, and so on. The data of the (N + 1)-th layer can be calculated based on the data of the N-th layer until there is only one parent node in the (N + 1)-th layer, and this node is determined as the root node of the verification accumulative tree, so as to obtain a multi-level tree-shaped data structure.

[0080] See Figure 4 , Figure 4 FIG. shows a schematic diagram of a verification accumulative tree provided by an embodiment of the present application. As Figure 4 shown, node A can store 5 blocks, specifically including block a0, block a1, block a2, block a3, and block a4. Furthermore, corresponding leaf nodes can be generated based on each block, including node b0, node b1, node b2, node b3, and node b4. Among them, node b0 corresponds to block a0, node b1 corresponds to block a1, and so on. Node b4 corresponds to block a4. The value of node b0 can be the verification value of block a0, the value of node b1 can be the verification value of block a1, and so on. The value of node b4 can be the verification value of block a4, so as to obtain the first-layer data of the verification accumulative tree.

[0081] After obtaining the first-layer data of the verification accumulative tree, the parent nodes can be generated in sequence according to every two leaf nodes. Specifically, the parent node R1 can be generated according to node b0 and node b1, the parent node R2 can be generated according to node b2 and node b3, and the parent node R3 can be generated according to node b4. At the same time, the value of the parent node R1 can be calculated based on the values of node b0 and node b1, the value of the parent node R2 can be calculated based on the values of node b2 and node b3, and the value of node b4 can be determined as the value of the parent node R3, so as to obtain the second-layer data of the verification accumulative tree.

[0082] After obtaining the second-layer data of the verification accumulation tree, the third-layer parent nodes can be generated successively according to every two parent nodes. That is, according to parent node R1 and parent node R2, the third-layer parent node R4 is generated, and according to parent node R3, the third-layer parent node R5 is generated. At the same time, based on the values of parent node R1 and parent node R2, the value of parent node R4 can be calculated, and based on the value of parent node R3, the value of parent node R5 can be calculated, so that the third-layer data of the verification accumulation tree can be obtained.

[0083] After obtaining the third-layer data of the verification accumulation tree, the fourth-layer parent nodes can be generated successively according to every two parent nodes. That is, according to parent node R4 and parent node R5, the fourth-layer parent node R6 is generated. Since there is only one fourth-layer parent node, it can be determined that parent node R6 is the root node of this verification accumulation tree, and the verification accumulation tree is obtained to store the verification values of all blocks in node A through this verification accumulation tree.

[0084] Based on this, each node in the blockchain can determine the verification accumulation tree in the above manner and store the verification values of all blocks in the node based on the verification accumulation tree.

[0085] In a specific implementation, when any node in the blockchain receives a request from a synchronization node, it can determine the parent node generated by the verification block in the verification accumulation tree set locally according to the verification block in the request, and determine the leaf nodes corresponding to the verification block in the verification accumulation tree.

[0086] For example, node A in the blockchain may include block a0, block a1, block a2, block a3, and block a4, while synchronization node B includes block a0 and block a1. Then it can be determined that the blocks to be synchronized are block a2, block a3, and block a4, and the verification blocks for verifying the blocks to be synchronized are block a0 and block a1. For synchronization node B, a request to obtain the blocks to be synchronized can be sent to node A, and the request may include the identifiers of the verification blocks. Furthermore, node A can determine that the verification blocks are block a0 and block a1 based on this request, and determine the parent node R1 generated by block a0 and block a1 in the verification accumulation tree of node A as the target parent node, and determine the leaf nodes b0 and leaf node b1 corresponding to the verification blocks as the target leaf nodes.

[0087] After obtaining the target parent node and the target leaf nodes, the value of the target parent node can be determined as the verification value of the target parent node, and the value of the target leaf nodes can be determined as the verification values of the target leaf nodes, obtaining the target verification values corresponding to the verification blocks.

[0088] As an example, after obtaining the target parent node and the target leaf nodes, it is possible to determine whether there are target leaf nodes in the target leaf nodes for generating the target parent node, and remove the target leaf nodes in all target leaf nodes for generating the target parent node, so as to determine the target verification value based on the values of all target leaf nodes after removal and the value of the target parent node.

[0089] Step 304, generate the root verification value corresponding to the block to be synchronized according to the target verification value and the verification value corresponding to the block to be synchronized.

[0090] After obtaining the target verification value, the root verification value corresponding to the block to be synchronized can be generated according to the target verification value and the verification value corresponding to the block to be synchronized.

[0091] In practical applications, the verification values of the target parent node, the target leaf nodes, and the block to be synchronized can be hashed to obtain the root verification value corresponding to the block to be synchronized.

[0092] See Figure 5 , Figure 5 shows another schematic diagram of a verification accumulative tree provided by an embodiment of the present application. As Figure 5 shown, the verification accumulative tree can be a four-layer tree-shaped data structure. Among them, the first layer of the verification accumulative tree can include 8 leaf nodes, namely node b0, node b1, node b2, node b3, node b4, node b5, node b6, and node b7. The second layer can include 4 parent nodes, namely parent node R1, parent node R2, parent node R3, and parent node R4. The third layer can include 2 parent nodes, namely parent node R5 and parent node R6. The fourth layer can include parent node R7, and parent node R7 can be the root node of the verification accumulative tree.

[0093] Among them, the blocks to be synchronized can be block a5, block a6, and block a7, and the verification blocks can be block a0, block a1, block a2, block a3, and block a4. Furthermore, it can be determined that the target leaf nodes corresponding to the verification blocks include node b0, node b1, node b2, node b3, and node b4, and the target parent nodes generated by the verification blocks can include parent node R1, parent node R2, and parent node R5. Then, the values of node b0, node b1, node b2, node b3, node b4, parent node R1, parent node R2, and parent node R5, as well as the verification value of the block to be synchronized, can be hashed to obtain the root verification value corresponding to the block to be synchronized.

[0094] In a specific implementation, since each parent node is generated by leaf nodes, that is, each target parent node can be generated by target leaf nodes, the values of all target leaf nodes can be hashed to obtain the root verification value corresponding to the block to be synchronized.

[0095] Specifically, the following formula can be used for hash calculation: Hash[Hash{Hash(b0 + b1)+Hash(b2 + b3)}+Hash{Hash(b4 + b5)+ Hash(b6 + b7)}] = R7` Wherein, b0, b1, b2, b3, and b4 can be the values of node b0, node b1, node b2, node b3, and node b4, that is, b0, b1, b2, b3, and b4 are all the values of the target leaf nodes. b5, b6, and b7 can be the values of node b5, node b6, and node b7, that is, b5, b6, and b7 are all the values of the block to be synchronized. R7` can be the root verification value, and Hash can be a hash function to perform hash calculation on the values of all target leaf nodes.

[0096] As an example, after obtaining the target parent node and the target leaf nodes, it can be determined that the parent node R1 in the target parent node is generated by node b0 and node b1 in the target leaf nodes, and the parent node R2 in the target parent node is generated by node b2 and node b3 in the target leaf nodes. The target parent node R5 is generated by the target parent node R1 and the target parent node R2. Then, it can be determined that there are target leaf nodes in the target leaf nodes for generating the target parent node, and node b0, node b1, node b2, and node b3 in the target leaf nodes are removed, and the parent node R1 and the parent node R2 in the target parent node are removed. Furthermore, the target verification value can be determined based on the values of all the target leaf nodes and the values of the target parent node after removal, that is, it is determined that the values of the parent node R5 and node b4 are the target verification values. Thus, it is only necessary to perform hash calculation on the values of the parent node R5 and node b4, without performing hash calculation on the values of all nodes, reducing the calculation amount and improving the efficiency of determining the root verification value. At the same time, when other nodes feedback the target verification value to the synchronization node, it is not necessary to feedback the verification values of all blocks, reducing the amount of data to be feedback.

[0097] It should be understood that since the target parent node R1 and the target parent node R2 are the data in the second layer of the verification accumulation tree, and the target parent node R5 is the data in the third layer of the verification accumulation tree. For the data in the third layer, the parent nodes in the second layer can be the leaf nodes of the parent nodes in the third layer, that is, the parent nodes in the Nth layer of the verification accumulation tree can be the leaf nodes of the parent nodes in the (N + 1)th layer.

[0098] Specifically, the following formula can be used for hash calculation: Hash [ R5 + Hash ( b4 + b5)+ Hash ( b6 + b7) ] = R7` Among them, R5 can be the value of the parent node R5, that is, R5 is the value of the target parent node, b4 can be the value of the node b4, that is, b4 is the value of the target leaf node, and b5, b6, and b7 can be the values of the nodes b5, b6, and b7, that is, b5, b6, and b7 are all the values of the blocks to be synchronized. R7` can be the root verification value, and Hash can be a hash function to perform a hash calculation on the values of all target leaf nodes.

[0099] Step 305: Match the root verification value with the reference verification value in other nodes.

[0100] After obtaining the root verification value, the root verification value can be matched with the reference verification value in other nodes.

[0101] Step 306: When the root verification value matches the reference verification value in other nodes, execute the block to be synchronized and submit the executed block to the local ledger.

[0102] Among them, the local ledger can be used to store the data of each block in the blockchain.

[0103] When the root verification value matches the reference verification value in other nodes, it is determined that the verification is passed, and the executed block to be synchronized is submitted to the local ledger to synchronize the block to be synchronized to the synchronization node.

[0104] In practical applications, when the root verification value matches the reference verification value in other nodes, it can be determined that there is no difference between the blocks stored in the synchronization node and the blocks to be synchronized feedback by other nodes and the blocks stored in other nodes, that is, the blocks stored in the synchronization node and the blocks to be synchronized feedback by other nodes are consistent with the block data stored in other nodes, and there is no data tampering or loss, so it can be determined that the verification is passed.

[0105] As an example, the verification value of the block to be synchronized can also be calculated according to the data of the block to be synchronized, and the calculated verification value is matched with the verification value of the block to be synchronized feedback by other nodes. When the calculated verification value matches the verification value of the block to be synchronized feedback by other nodes and the root verification value matches the reference verification value in other nodes, it is determined that the verification is passed.

[0106] In an embodiment of the present application, by obtaining the to-be-synchronized blocks corresponding to the target block range from other nodes, determining the verification blocks in the blockchain except for the to-be-synchronized blocks, obtaining the target verification values corresponding to the verification blocks from other nodes, generating the root verification value corresponding to the to-be-synchronized blocks according to the target verification values and the verification values corresponding to the to-be-synchronized blocks, matching the root verification value with the reference verification value in other nodes, and when the root verification value matches the reference verification value in other nodes, executing the to-be-synchronized blocks and submitting the executed to-be-synchronized blocks to the local ledger, only the root verification value of the to-be-synchronized blocks needs to be determined based on the verification values of each block, so as to verify the to-be-synchronized blocks based on the root verification value, reducing the situation of verifying each block in sequence and improving the efficiency of block synchronization.

[0107] See Figure 6 , Figure 6 FIG. shows a schematic flowchart of a block synchronization provided by an embodiment of the present application, which may specifically include the following steps: Step 601, determine whether any node in the blockchain triggers a block synchronization event. If so, determine this node as the synchronization node and execute step 602. If not, execute step 609.

[0108] In practical applications, each node in the blockchain can communicate with each other. Thus, for each node, when it detects a difference between the data of the blocks stored in this node and the on-chain data in the blockchain, it can determine that this node needs to perform a block synchronization operation, trigger a block synchronization event, and determine this node as the synchronization node. When no difference is detected, it is determined that this node does not need to perform a block synchronization operation, that is, the block synchronization event is not triggered.

[0109] Step 602, the synchronization node generates a request for obtaining the to-be-synchronized blocks, and this request includes the target block range, and sends this request to any other node in the blockchain that includes the to-be-synchronized blocks.

[0110] In practical applications, before generating a request for obtaining the to-be-synchronized blocks, the number of to-be-synchronized blocks can be compared with a preset number threshold. Thus, when the number of to-be-synchronized blocks is greater than the number threshold, the to-be-synchronized blocks are divided into at least two to-be-synchronized block sets, and for each to-be-synchronized block set, a request for obtaining the to-be-synchronized blocks in this to-be-synchronized block set is generated in sequence, so as to obtain the requests corresponding to each to-be-synchronized block set, and each request is sent to other nodes in sequence.

[0111] In a specific implementation, after sending the request corresponding to any set of blocks to be synchronized to other nodes, it is necessary to send the request corresponding to the next set of blocks to be synchronized to other nodes after the execution of this request is completed, so that the requests corresponding to each set of blocks to be synchronized can be sent to other nodes in sequence.

[0112] As an example, after obtaining the requests corresponding to all sets of blocks to be synchronized, all or part of the requests corresponding to the sets of blocks to be synchronized can also be sent to other nodes in parallel, and after receiving the requests corresponding to all sets of blocks to be synchronized, other nodes can respond to the requests corresponding to each set of blocks to be synchronized in sequence.

[0113] Step 603: After receiving the request sent by the synchronization node, according to the target block range in the request, retrieve the blocks to be synchronized, and retrieve the target verification value from the verification accumulation tree, and feedback the blocks to be synchronized, the target verification value, and the reference verification value in other nodes to the synchronization node.

[0114] Step 604: After receiving the data fed back by other nodes, the synchronization node generates the root verification value corresponding to the blocks to be synchronized according to the target verification value and the verification value corresponding to the blocks to be synchronized.

[0115] Step 605: Determine whether the root verification value matches the reference verification value in other nodes. If so, execute Step 606; if not, execute Step 607.

[0116] Step 606: In the case where the root verification value matches the reference verification value in other nodes, execute the blocks to be synchronized and submit the executed blocks to be synchronized to the local ledger.

[0117] Step 607: In the case where the root verification value does not match the reference verification value in other nodes, send the request for obtaining the blocks to be synchronized to another other node in the blockchain that includes the blocks to be synchronized, and execute Step 603.

[0118] Step 608: Determine whether the synchronization is completed. If so, execute Step 609; if not, execute Step 602.

[0119] In practical applications, since the synchronization node can generate corresponding requests for each set of blocks to be synchronized, after submitting the blocks to be synchronized to the local ledger, it can determine that the execution of the request for obtaining the blocks to be synchronized is completed, and determine whether the requests corresponding to each set of blocks to be synchronized have all been executed. If it is determined that there is at least one request corresponding to a set of blocks to be synchronized that has not been executed, it can be determined that the synchronization has not been completed. If it is determined that the requests corresponding to each set of synchronized blocks have all been executed, it can be determined that the synchronization is completed.

[0120] Step 609: The process ends.

[0121] In an embodiment of the present application, by determining whether any node in the blockchain triggers a block synchronization event, and in the case of triggering a block synchronization event, determining that the node is a synchronization node. The synchronization node can generate a request for obtaining the block to be synchronized, and the request includes a target block range, and sends the request to any other node in the blockchain that includes the block to be synchronized. After receiving the request sent by the synchronization node, other nodes retrieve the block to be synchronized according to the target block range in the request, and retrieve the target verification value from the verification accumulative tree, and feedback the block to be synchronized, the target verification value, and the reference verification value in other nodes to the synchronization node. After receiving the data fed back by other nodes, the synchronization node generates a root verification value corresponding to the block to be synchronized according to the target verification value and the verification value corresponding to the block to be synchronized, and determines whether the root verification value matches the reference verification value in other nodes. In the case where the root verification value matches the reference verification value in other nodes, execute the block to be synchronized, and then submit the executed block to be synchronized to the local ledger, or in the case where the root verification value does not match the reference verification value in other nodes, send the request for obtaining the block to be synchronized to another other node in the blockchain that includes the block to be synchronized, and determine whether the synchronization is completed. In the case where the synchronization is not completed, send the request corresponding to the next set of blocks to be synchronized to other nodes to synchronize the blocks to be synchronized in the next set of blocks to be synchronized until all the blocks to be synchronized are completed, and end the process, thereby reducing the situation of verifying each block in sequence and improving the efficiency of block synchronization.

[0122] Refer to Figure 7 , Figure 7 shows a schematic structural diagram of a block synchronization device provided by an embodiment of the present application. The device is applied to a synchronization node in the blockchain and may specifically include the following modules: An obtaining module 701, configured to obtain the block to be synchronized corresponding to the target block range from other nodes; A determining module 702, configured to determine a root verification value corresponding to the block to be synchronized according to the verification value of each block in the blockchain; A synchronization module 703, configured to synchronize the block to be synchronized in the case where the root verification value matches the reference verification value in other nodes.

[0123] In one implementation manner, the above obtaining module 701 is further configured to: Before obtaining the block to be synchronized corresponding to the target block range from other nodes, obtain the first block height of other nodes in the blockchain; In one implementation manner, the above determining module 702 is further configured to: Before obtaining the blocks to be synchronized corresponding to the target block range from other nodes and when the first block height is greater than the second block height, determine to trigger a block synchronization event and execute the step of obtaining the blocks to be synchronized corresponding to the target block range from other nodes; where the second block height is the block height of the synchronization node.

[0124] In one implementation, the above-mentioned obtaining module 701 is further configured to: When triggering a block synchronization event, determine the target block range according to the first block height and the second block height; where the target block range is the range from the second block height to the first block height; According to the target block range, obtain the blocks to be synchronized corresponding to the target block range from other nodes.

[0125] In one implementation, the above-mentioned determining module 702 is further configured to: Before determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain, determine the verification blocks in the blockchain other than the block to be synchronized; In one implementation, the above-mentioned obtaining module 701 is further configured to: Before determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain, obtain the target verification value corresponding to the verification block from other nodes, so as to execute the step of determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain based on the target verification value; Where the target verification value is determined by other nodes from a preset verification accumulation tree, and the verification accumulation tree includes at least one leaf node and at least one parent node, each leaf node corresponds to each block respectively, and each parent node is calculated and generated from the verification values corresponding to at least one leaf node.

[0126] In one implementation, the target verification value includes the verification value of the target parent node and the verification value of the target leaf node in the verification accumulation tree, the target parent node is the parent node generated by the verification block in the verification accumulation tree, and the target leaf node is the leaf node corresponding to the verification block in the verification accumulation tree.

[0127] In one implementation, the above-mentioned determining module 702 is further configured to: Generate the root verification value corresponding to the block to be synchronized according to the target verification value and the verification value corresponding to the block to be synchronized.

[0128] In one implementation, the above-mentioned synchronization module 703 is further configured to: Match the root verification value with the reference verification value in other nodes; In the case where the root verification value matches the reference verification value in other nodes, execute the block to be synchronized, and submit the executed block to be synchronized to the local ledger.

[0129] In one implementation, the apparatus further includes the following modules: A division module, configured to, before determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain, when the number of blocks to be synchronized is greater than a preset number threshold, divide the blocks to be synchronized into at least two sets of blocks to be synchronized; and sequentially execute the step of determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain for each set of blocks to be synchronized.

[0130] In the embodiments of the present application, by obtaining the blocks to be synchronized corresponding to the target block range from other nodes, determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain, and synchronizing the block to be synchronized in the case where the root verification value matches the reference verification value in other nodes, only need to determine the root verification value of the block to be synchronized based on the verification value of each block, so as to verify the block to be synchronized based on the root verification value, reduce the situation of verifying each block in sequence, and improve the efficiency of block synchronization.

[0131] It should be noted that, for the information interaction, execution process, etc. between the above-mentioned apparatuses, since they are based on the same concept as the method embodiments of the present application, their specific functions and the technical effects brought thereby can be specifically referred to the method embodiment part, and will not be elaborated here.

[0132] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the above-mentioned division of each functional unit and module is used as an example for illustration. In practical applications, the above-mentioned functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of the present application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the foregoing method embodiments, and will not be elaborated here.

[0133] Refer to Figure 8 , Figure 8 shows a structural block diagram of a computer device provided by an embodiment of the present application, as Figure 8As shown in the figure, an embodiment of the present application further provides a computer device 81, which includes: at least one processor 811, a memory 812, and a computer program 8121 stored in the memory 812 and executable on the at least one processor 811. When the processor 811 executes the computer program 8121, the steps in any of the above method embodiments are implemented.

[0134] An embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps in any one of the above method embodiments can be implemented.

[0135] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can be made to execute the steps in the above method embodiments.

[0136] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above embodiment methods of the present application, a computer program can be used to instruct relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps in the above method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can at least include: any entity or device capable of carrying the computer program code to the device / computer device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium.

[0137] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for synchronizing blocks, characterized in that, The method is applied to a synchronization node in a blockchain. The method includes: Obtain the to-be-synchronized blocks corresponding to a target block range from other nodes; Determine the root verification value corresponding to the to-be-synchronized blocks according to the verification values of each block in the blockchain; Synchronize the to-be-synchronized blocks when the root verification value matches the reference verification value in the other nodes.

2. The method for synchronizing blocks according to claim 1, characterized in that, Before obtaining the to-be-synchronized blocks corresponding to a target block range from other nodes, the method further includes: Obtain the first block height of the other nodes in the blockchain; When the first block height is greater than the second block height, determine that a block synchronization event is triggered, and execute the step of obtaining the to-be-synchronized blocks corresponding to a target block range from other nodes; wherein, the second block height is the block height of the synchronization node.

3. The method for synchronizing blocks according to claim 2, characterized in that, The obtaining the to-be-synchronized blocks corresponding to a target block range from other nodes includes: When the block synchronization event is triggered, determine the target block range according to the first block height and the second block height; wherein, the target block range is the range from the second block height to the first block height; Obtain the to-be-synchronized blocks corresponding to the target block range from the other nodes according to the target block range.

4. The method for synchronizing blocks according to any one of claims 1 to 3, characterized in that, Before determining the root verification value corresponding to the to-be-synchronized blocks according to the verification values of each block in the blockchain, the method further includes: Determine the verification blocks in the blockchain except the to-be-synchronized blocks; Obtain the target verification values corresponding to the verification blocks from the other nodes, so as to execute the step of determining the root verification value corresponding to the to-be-synchronized blocks according to the verification values of each block in the blockchain based on the target verification values; Wherein, the target verification values are determined by the other nodes from a preset verification accumulation tree, the verification accumulation tree includes at least one leaf node and at least one parent node, each leaf node corresponds to each block respectively, and each parent node is calculated and generated by the verification values corresponding to at least one leaf node.

5. The method for synchronizing blocks according to claim 4, characterized in that, The target verification values include the verification value of the target parent node and the verification value of the target leaf node in the verification accumulation tree, the target parent node is the parent node generated by the verification block in the verification accumulation tree, and the target leaf node is the leaf node corresponding to the verification block in the verification accumulation tree.

6. The method for synchronizing blocks according to claim 5, characterized in that, The determining the root verification value corresponding to the to-be-synchronized blocks according to the verification values of each block in the blockchain includes: Generate the root verification value corresponding to the to-be-synchronized blocks according to the target verification values and the verification value corresponding to the to-be-synchronized blocks.

7. The method for synchronizing blocks according to claim 4, characterized in that, The synchronizing the to-be-synchronized blocks when the root verification value matches the reference verification value in other nodes includes: Match the root verification value with the reference verification value in other nodes; When the root verification value matches the reference verification value in other nodes, execute the to-be-synchronized blocks, and submit the executed to-be-synchronized blocks to the local ledger.

8. The method for synchronizing blocks according to any one of claims 1 to 3 or 5 to 7, characterized in that, Before determining the root verification value corresponding to the block to be synchronized according to the verification values of each block in the blockchain, the method further includes: When the number of blocks to be synchronized is greater than a preset number threshold, dividing the blocks to be synchronized into at least two sets of blocks to be synchronized; Sequentially performing the step of determining the root verification value corresponding to the block to be synchronized according to the verification values of each of the blocks in the blockchain for each set of blocks to be synchronized.

9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.

10. A computer program product, the computer program product comprising a computer program, characterized in that, When the computer program runs on a computer, the computer is caused to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data synchronization method and device of block chain, computer equipment and storage medium

    CN113886496A