A block synchronization method, apparatus, device, storage medium, and product

By obtaining and combining block information with different sequence numbers from different blockchain nodes for recovery processing, the problem of low block synchronization efficiency is solved, and efficient and reliable block synchronization is achieved.

CN117155954BActive Publication Date: 2026-07-24TENCENT CLOUD COMPUTING (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT CLOUD COMPUTING (BEIJING) CO LTD
Filing Date
2022-05-23
Publication Date
2026-07-24

Smart Images

  • Figure CN117155954B_ABST
    Figure CN117155954B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a block synchronization method, device, equipment, storage medium and product. The method comprises: obtaining a target block height of a to-be-synchronized block; obtaining M candidate blocks with the target block height from different block chain nodes, each candidate block comprising N block information, and each block information corresponding to a different serial number; selecting k block information with different serial numbers from the M candidate blocks to converge into a block information group, different block information in the block information group being from different candidate blocks; performing recovery processing on the block information in the block information group; and if the block is successfully recovered, synchronizing the recovered block. It can be seen that the to-be-synchronized block is recovered by obtaining part of the block information of the to-be-synchronized block from different block chain nodes, thereby improving the synchronization efficiency of the block under the premise of ensuring the reliability of the synchronized block.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a block synchronization method, apparatus, device, storage medium, and product. Background Technology

[0002] With advancements in technological research, blockchain technology, with its ability to verify stored data, is widely applied across various industries. The core of blockchain technology lies in the fact that each blockchain node in the network stores blocks. When verification of stored data is required, consensus can be reached based on the blocks stored in each blockchain node to obtain the verification result. The blocks stored in the various blockchain nodes in the network are typically obtained through synchronization. However, practice has shown that ensuring the reliability of synchronized blocks requires significant storage and computing resources during block synchronization, resulting in low synchronization efficiency. Summary of the Invention

[0003] This invention provides a block synchronization method, apparatus, device, and computer-readable storage medium that can improve block synchronization efficiency.

[0004] On the one hand, embodiments of this application provide a block synchronization method, including:

[0005] Get the target block height of the block to be synchronized;

[0006] From different blockchain nodes, obtain M candidate blocks with a block height equal to the target block height. Each candidate block contains N block information, and the N block information correspond to different sequence numbers.

[0007] From M candidate blocks, select k blocks with different sequence numbers and aggregate them into a block information group. The k block information in the block information group comes from the k candidate blocks respectively; k, M, and N are all positive integers, and k is less than or equal to M and less than or equal to N;

[0008] Perform recovery processing on the block information in the block information group;

[0009] If the block recovery is successful, the recovered block will be synchronized.

[0010] In this embodiment, the target block height of the block to be synchronized is obtained; M candidate blocks with a block height equal to the target block height are obtained from different blockchain nodes, each candidate block containing N block information, each N block information corresponding to a different sequence number; k block information with different sequence numbers are selected from the M candidate blocks and aggregated into a block information group, where the k block information in the block information group comes from the k candidate blocks respectively; the block information in the block information group is restored; if the block restoration is successful, the restored block is synchronized. It can be seen that the synchronized block is obtained based on multiple block information; since this block information comes from different blockchain nodes, on the one hand, the reliability of the restored block is ensured, and on the other hand (since there is no need to verify the restored block again), the synchronization efficiency of the block can be improved.

[0011] On the one hand, embodiments of this application provide a node verification method, including:

[0012] Obtain the first block information group and the second block information group. Both the first block information group and the second block information group contain k block information belonging to the target block, and the first block information group and the second block information group include block information with the same sequence number. The target block cannot be recovered based on the block information in the first block information group, but the target block can be recovered based on the block information in the second block information group.

[0013] Based on the differences between the block information with the same sequence number in the first block information group and the second block information group, malicious nodes in the blockchain nodes are identified.

[0014] In this embodiment, a first block information group and a second block information group are obtained. Based on the differences between the first and second block information groups, malicious nodes in the blockchain are identified. Therefore, based on the differences between the block information groups that successfully recovered the target block and those that failed to recover the target block, malicious nodes in the blockchain can be identified, thereby improving the security of the blockchain network.

[0015] On one hand, embodiments of this application provide a block synchronization device, which includes:

[0016] The acquisition unit is used to acquire the target block height of the block to be synchronized.

[0017] The processing unit is used to obtain M candidate blocks with a block height equal to the target block height from different blockchain nodes. Each candidate block contains N block information, and the N block information correspond to different sequence numbers.

[0018] And it is used to select k blocks with different serial numbers from M candidate blocks and aggregate them into a block information group. The k block information in the block information group comes from k candidate blocks respectively; k, M, and N are all positive integers, and k is less than or equal to M and less than or equal to N;

[0019] And it is used to recover block information in the block information group; if the block recovery is successful, the recovered block is synchronized.

[0020] In one embodiment, the processing unit is further configured to:

[0021] If block recovery fails, the block information group will be designated as the first block information group.

[0022] Obtain the second block information group;

[0023] Based on the differences between the first block information group and the second block information group, malicious nodes in the blockchain nodes are identified;

[0024] The first block information group and the second block information group contain block information with the same sequence number. The block can be successfully recovered based on the block information in the second block information group.

[0025] In one implementation, the first block information group and the second block information group include k-1 blocks with the same sequence number; the processing unit is used to determine malicious nodes in the blockchain nodes based on the differences between the first block information group and the second block information group, specifically for:

[0026] If the block information with sequence number i in the first block information group does not match the block information with sequence number i in the second block information group, then the blockchain node associated with the block information with sequence number i in the first block information group will be identified as a malicious node.

[0027] Among them, the block information with sequence number i is any one of the k-1 block information with the same sequence number;

[0028] If the first block information group matches one-to-one with the k-1 blocks with the same sequence number in the second block information group, then the blockchain node associated with the block information with sequence number j in the first block information group is identified as a malicious node.

[0029] Among them, the block information with sequence number j is the block information other than the (k-1) block information with the same sequence number.

[0030] In one implementation, the first block information group and the second block information group include block information with the same sequence number; the processing unit is configured to determine malicious nodes in the blockchain nodes based on the differences between the first block information group and the second block information group, specifically configured to:

[0031] If the block information with the same sequence number included in the first block information group and the second block information group does not match, then the blockchain node associated with that block information is identified as a malicious node.

[0032] If the block information with the same sequence number included in the first block information group and the second block information group matches, then the third block information group is obtained, and the malicious node in the blockchain node is determined based on the difference between the first block information group and the third block information group.

[0033] The first block information group and the third block information group contain block information with the same sequence number. The block can be successfully recovered based on the block information in the third block information group.

[0034] In one implementation, the acquiring unit is used to acquire the second block information group, specifically for:

[0035] Obtain the second block information group from the verification set;

[0036] The verification set includes at least one group of block information, and the block information in each group can be successfully recovered into a block.

[0037] In one implementation, the blockchain nodes belong to a set of trusted nodes; the processing unit is further configured to:

[0038] Remove malicious nodes from the set of trusted nodes.

[0039] In one implementation, the block to be synchronized includes a block header and a block body; the block body consists of N block information, which includes m main information and Nm spare information, where m is a positive integer.

[0040] In one embodiment, the processing unit is configured to perform recovery processing on the block information in the block information group, specifically for:

[0041] The k block information in the block information group are processed to obtain Nk recovery information;

[0042] Block recovery is performed based on k block information and Nk recovery information.

[0043] In one implementation, the acquisition unit is used to acquire the target block height of the block to be synchronized, specifically for:

[0044] Get the maximum height of the synchronized blocks;

[0045] If a blockchain node stores a block to be synchronized that has a height greater than the maximum height, then the height of the block to be synchronized is determined as the target block height.

[0046] On one hand, embodiments of this application provide a node verification device, which includes:

[0047] The acquisition unit is used to acquire a first block information group and a second block information group. Both the first block information group and the second block information group contain k block information belonging to the target block, and the first block information group and the second block information group include block information with the same sequence number. The target block cannot be recovered based on the block information in the first block information group, but the target block can be recovered based on the block information in the second block information group.

[0048] The processing unit is configured to determine the malicious node in the blockchain node based on the difference between the first block information group and the second block information group.

[0049] As an optional embodiment, the first block information group and the second block information group include k-1 blocks with the same sequence number; the processor determines the malicious node in the blockchain node based on the difference between the blocks with the same sequence number in the first block information group and the second block information group. A specific embodiment of this is as follows:

[0050] If the block information with sequence number i in the first block information group does not match the block information with sequence number i in the second block information group, then the blockchain node associated with the block information with sequence number i in the first block information group will be identified as a malicious node.

[0051] Among them, the block information with sequence number i is any one of the k-1 block information with the same sequence number;

[0052] If the first block information group matches one-to-one with the k-1 blocks with the same sequence number in the second block information group, then the blockchain node associated with the block information with sequence number j in the first block information group is identified as a malicious node.

[0053] Among them, the block information with sequence number j is the block information other than the (k-1) block information with the same sequence number.

[0054] As an optional embodiment, the first block information group and the second block information group include a block information with the same sequence number; the processor determines the malicious node in the blockchain node based on the difference between the block information with the same sequence number in the first block information group and the second block information group. A specific embodiment of this is as follows:

[0055] If the block information with the same sequence number included in the first block information group and the second block information group does not match, then the blockchain node associated with that block information is identified as a malicious node.

[0056] If the block information with the same sequence number included in the first block information group and the second block information group matches, then the third block information group is obtained, and the malicious node in the blockchain node is determined based on the difference between the first block information group and the third block information group.

[0057] The first block information group and the third block information group contain block information with the same sequence number. The target block can be successfully recovered based on the block information in the third block information group.

[0058] Accordingly, this application provides a computer device comprising:

[0059] A processor is used to load and execute computer programs;

[0060] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the block synchronization method described above; or implements the node verification method described above.

[0061] Accordingly, this application provides a computer-readable storage medium storing a computer program adapted to be loaded by a processor and executed by the above-described block synchronization method; or to be loaded and executed by the above-described node verification method.

[0062] Accordingly, this application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned block synchronization method or the aforementioned node verification method.

[0063] In this embodiment, the target block height of the block to be synchronized is obtained; M candidate blocks with a block height equal to the target block height are obtained from different blockchain nodes, each candidate block containing N block information, each N block information corresponding to a different sequence number; k block information with different sequence numbers are selected from the M candidate blocks and aggregated into a block information group, where the k block information in the block information group comes from the k candidate blocks respectively; the block information in the block information group is restored; if the block restoration is successful, the restored block is synchronized. It can be seen that the synchronized block is obtained based on multiple block information; since this block information comes from different blockchain nodes, on the one hand, the reliability of the restored block is ensured, and on the other hand (since there is no need to verify the restored block again), the synchronization efficiency of the block can be improved. Attached Figure Description

[0064] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0065] Figure 1a This application provides a schematic diagram of the architecture of a data sharing system.

[0066] Figure 1b A schematic diagram of a blockchain structure is provided as an embodiment of this application;

[0067] Figure 1c A schematic diagram of a block generation process provided for an embodiment of this application;

[0068] Figure 1d An architecture diagram of a block synchronization system provided in this application embodiment;

[0069] Figure 2 A flowchart illustrating a block synchronization method provided in this application embodiment;

[0070] Figure 3 A block structure diagram provided for an embodiment of this application;

[0071] Figure 4 A flowchart illustrating another block synchronization method provided in this application embodiment;

[0072] Figure 5a A flowchart for determining a malicious node is provided in an embodiment of this application;

[0073] Figure 5b This application provides a schematic diagram of a block synchronization process.

[0074] Figure 6 A flowchart illustrating a node verification method provided in this application embodiment;

[0075] Figure 7 This is a schematic diagram of the structure of a block synchronization device provided in an embodiment of this application;

[0076] Figure 8 This is a schematic diagram of the structure of a node verification device provided in an embodiment of this application;

[0077] Figure 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0078] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0079] This application relates to blockchain technology. The following is a brief introduction to the relevant terms and concepts of blockchain technology:

[0080] Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. Essentially, it is a decentralized database, a chain of data blocks linked using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying platform, a platform product service layer, and an application service layer.

[0081] A blockchain network can be understood as a data sharing system 100, which can refer to a system for sharing data between nodes. An exemplary structure of the data sharing system 100 can be found here. Figure 1a ;like Figure 1a As shown, the data sharing system 100 refers to a system for data sharing between nodes. This data sharing system may include multiple nodes 1001, which can refer to various clients within the system. Each node 1001, during normal operation, can receive input information and maintain shared data within the system based on this information. To ensure information exchange within the data sharing system, information connections can exist between each node, allowing for information transmission. For example, when any node in the data sharing system receives input information, other nodes in the system obtain this input information according to a consensus algorithm and store it as part of the shared data, ensuring consistency of data stored on all nodes in the system.

[0082] Each node in the data sharing system has a corresponding node identifier. Furthermore, each node can store the node identifiers of other nodes in the data sharing system, so that the generated block can be broadcast to other nodes in the system based on their node identifiers. Each node can maintain a node identifier list as shown in the table below, storing the node name and node identifier in this list. The node identifier can be an IP (Internet Protocol) address or any other information that can be used to identify the node; for example, the node identifier can also be a binary sequence code (such as 110001110). Table 1 only uses IP addresses as an example.

[0083] Table 1

[0084] Node 1 117.114.151.174 Node 2 117.116.189.145 … … Node X (X is a positive integer) xx.xxx.xxx.xxx

[0085] Each node in the data-sharing system stores the same blockchain. A blockchain consists of multiple blocks; see [link to blockchain documentation]. Figure 1b A blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores input information feature values, version number, timestamp, and difficulty value, while the block body stores the input information. The next block after the genesis block takes the genesis block as its parent block. The next block also includes a block header and a block body. The block header stores the input information feature values ​​of the current block, the block header feature values ​​of the parent block, version number, timestamp, and difficulty value, and so on. This ensures that the block data stored in each block is related to the block data stored in the parent block, guaranteeing the security of the input information in the blocks.

[0086] When generating the individual blocks in the blockchain, see Figure 1c When a node in the blockchain receives input information, it verifies the input information. After verification, it stores the input information in a memory pool and updates its hash tree used to record the input information. Then, it updates the timestamp to the time the input information was received and tries different random numbers multiple times to calculate the feature value, ensuring that the calculated feature value satisfies the following formula:

[0087] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x)) <TARGET

[0088] Wherein, SHA256 is the feature value algorithm used to calculate the feature value; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header feature value of the parent block of the current block; merkle_root is the feature value of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, which is a fixed value for a period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the feature value threshold, which can be determined based on nbits.

[0089] Thus, when a random number satisfying the above formula is calculated, the information can be stored accordingly, generating a block header and a block body to obtain the current block. Subsequently, the node where the blockchain resides broadcasts the newly generated block to other nodes in its data sharing system based on the node identifiers of other nodes in the data sharing system. The other nodes then perform consensus verification on the newly generated block and add it to their stored blockchain after completing the consensus verification.

[0090] Based on the foregoing description of the blockchain network structure involved in the embodiments of this application, the following is a brief introduction to the block synchronization scheme proposed in this application based on the aforementioned blockchain network structure, which can significantly improve the convenience of subscribing to target transaction data. Please refer to... Figure 1d , Figure 1d This is an architecture diagram of a block synchronization system provided in an embodiment of this application. Figure 1d As shown, the block synchronization system may include a request node 101 and a blockchain node 102. The block synchronization method provided in this embodiment can be executed by the request node 101. The request node 101 and the blockchain node 102 may specifically be terminal devices or servers; wherein, terminal devices include, but are not limited to, smartphones (such as Android phones, iOS phones, etc.), tablet computers, portable personal computers, mobile internet devices (MIDs), vehicle terminals, and other intelligent devices, and this embodiment does not limit this. The server may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, and this embodiment does not limit this.

[0091] It should be noted that request node 101 itself can also be a blockchain node. Figure 1dThe request node 101 and the blockchain node 102 can be directly or indirectly connected via wired or wireless communication, and this application does not impose any limitations on this. The number of request nodes and blockchain nodes is for illustrative purposes only and does not constitute an actual limitation of this application.

[0092] It is understood that in the specific implementation of this application, block synchronization is involved. When the above embodiments of this application are applied to specific products or technologies, it is necessary to obtain the corresponding block synchronization permission (such as the requesting node being a blockchain node with block synchronization permission), and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0093] The basic principle of the block synchronization scheme is as follows:

[0094] (1) Request node 101 to obtain the target block height of the block to be synchronized. In one implementation, request node 101 obtains the maximum height h of the synchronized blocks. If blockchain node 102 stores a block with a height greater than h that request node 101 has not yet synchronized, then the block is identified as the block to be synchronized, and the height of the block to be synchronized (e.g., h+1) is determined as the target block height; h is a positive integer.

[0095] (2) Request node 101 obtains M candidate blocks with a block height equal to the target block height from different blockchain nodes 102. That is, request node 101 obtains M candidate blocks with a block height equal to the target block height from M blockchain nodes 102. Each candidate block contains N block information, and the N block information corresponds to different sequence numbers.

[0096] (3) Request node 101 selects k blocks with different sequence numbers from M candidate blocks and aggregates them into a block information group; the k blocks in the block information group come from k candidate blocks obtained from different blockchain nodes; k, M, and N are all positive integers, and k is less than or equal to M and less than or equal to N. For example, request node 101 selects block information with sequence number 2 from the first candidate block, selects block information with sequence number 5 from the second candidate block, and so on, aggregating the selected k blocks with different sequence numbers into the block information group.

[0097] (4) Request node 101 to perform recovery processing on the block information in the block information group. In one embodiment, the block to be synchronized includes a block header and a block body; the block body consists of N block information, which includes m main information and Nm backup information, where m is a positive integer. Among them, the main information is evidence information (such as transaction data), and the backup information can be used to calculate the main information; request node 101 performs calculation processing on k block information in the block information group to obtain Nk recovery information, and performs block recovery based on the k block information and Nk recovery information; for example, let the main information be D1, D2, D3; the backup information be B1; and B1 = D1 + D2 + D3; then when D1 is missing, D1 can be calculated using B1, D2, and D3, and the block can be recovered.

[0098] (5) If the block is successfully restored, then request node 101 to synchronize the restored block.

[0099] In this embodiment, the target block height of the block to be synchronized is obtained; M candidate blocks with a block height equal to the target block height are obtained from different blockchain nodes, each candidate block containing N block information, each N block information corresponding to a different sequence number; k block information with different sequence numbers are selected from the M candidate blocks and aggregated into a block information group, where the k block information in the block information group comes from the k candidate blocks respectively; the block information in the block information group is restored; if the block restoration is successful, the restored block is synchronized. It can be seen that the synchronized block is obtained based on multiple block information; since this block information comes from different blockchain nodes, on the one hand, the reliability of the restored block is ensured, and on the other hand (since there is no need to verify the restored block again), the synchronization efficiency of the block can be improved.

[0100] Based on the above block synchronization scheme, this application proposes a more detailed block synchronization method. The data transmission method proposed in this application will be described in detail below with reference to the accompanying drawings.

[0101] Please see Figure 2 , Figure 2 This is a flowchart illustrating a block synchronization method provided in an embodiment of this application. This block synchronization method can be executed by a computer device, specifically, a computer device that can be... Figure 1d The request node 101 is shown in the image. Figure 2 As shown, the block synchronization method may include the following steps S201-S205:

[0102] S201. Obtain the target block height of the block to be synchronized.

[0103] The computer device determines the target block height for the block to be synchronized based on the height of its own synchronized blocks and the heights of the blocks stored in each blockchain node in the blockchain network. Specifically, the computer device obtains the maximum height h among the synchronized blocks. If a blockchain node stores a block with a height greater than h that the computer device has not yet synchronized, then that block is identified as the block to be synchronized, and its height (e.g., h+1) is set as the target block height; h is a positive integer.

[0104] S202. Obtain M candidate blocks with a block height equal to the target block height from different blockchain nodes.

[0105] Each candidate block contains N block information entries, each corresponding to a different sequence number, where M and N are both positive integers. For example, the sequence number corresponding to the first block information entry is 1, the sequence number corresponding to the second block information entry is 2, and so on, with the sequence number corresponding to the i-th block information entry being i. This block information can be used to recover the blocks.

[0106] In one implementation, the computer device can obtain partial block information of a block with a height equal to the target block height from different blockchain nodes. In other words, the computer device does not need to obtain a complete block with a block height equal to the target block height from each blockchain node. For example, the computer device obtains the block information with sequence number 1 from the first blockchain node and the block information with sequence number 3 from the second blockchain node.

[0107] Optionally, these blockchain nodes all belong to a set of trusted nodes, which includes multiple blockchain nodes. To the computer device, the blockchain nodes in this set are considered trustworthy. Furthermore, the computer device can update this set of trusted nodes based on the reliability of the blocks provided by these blockchain nodes (if the block information in the provided block can be used to recover the block, it is reliable; if the block information in the provided block cannot be used to recover the block, it is unreliable).

[0108] S203. Select k blocks with different serial numbers from the M candidate blocks and aggregate them into a block information group.

[0109] The k block information pieces in the block information group come from k candidate blocks obtained from different blockchain nodes. That is, different block information pieces come from different candidate blocks; k is a positive integer, less than or equal to M and less than or equal to N. The computer device can either select a block information piece and aggregate it into the block information group, or select k block information pieces first and then aggregate these k block information pieces into the block information group.

[0110] In one implementation, k is less than N; that is, the block information group at this time only contains part of the block information in the block to be synchronized, and the block to be synchronized cannot be directly restored. In order to obtain a reliable and complete block to be synchronized, the computer device needs to perform recovery processing on the block information in the block information group, as detailed in step S204.

[0111] In another implementation, k equals N; that is, the computer device can directly reconstruct the block to be synchronized based on the block information contained in the block information group. In one implementation, the computer device can verify another part of the block information based on a portion of the block information group to ensure that the reconstructed block to be synchronized is reliable. In other words, the computer device can select 'a' block information to verify another Na block information, where 'a' is an integer greater than 1; for example, let N = 5, a = 3, where block information 1 to block information 5 are represented as Q1 to Q5 respectively; and let Q4 = Q1 + Q2 + Q3, Q5 = Q1 + 2Q2 + 4Q3; then the computer device selects any 3 block information according to the above relationship to verify the other two block information to ensure that the reconstructed block to be synchronized is reliable.

[0112] S204. Perform recovery processing on the block information in the block information group.

[0113] The computer device recovers the blocks based on the information of k blocks in the block information group.

[0114] Figure 3 A block structure diagram provided for an embodiment of this application, such as Figure 3 As shown, a block includes a block header and a block body; the block body consists of N block information segments, which include m main information segments and Nm spare information segments, where m is a positive integer. The main information segments are evidence-based information (such as transaction data), and the spare information segments are used to calculate the main information. Figure 3 As can be seen, blocks do not need to include a Quorum Certificate (QC). Compared to blocks that include a Quorum Certificate (QC), blocks consume less storage and transmission resources.

[0115] The process of a computer device recovering a block includes: processing k block information pieces from a block information group to obtain Nk recovery information pieces; and then performing block recovery based on the k block information pieces and the Nk recovery information pieces. For example, suppose N = 4, k = 3, where the main information is D1, D2, and D3; and the backup information is B1; let B1 = D1 + D2 + D3; then after obtaining 3 block information pieces, if the computer device obtains B1, D2, and D3, it can calculate D1 using B1, D2, and D3, and recover the block. For example, suppose N = 5, k = 3, where the main information is D1, D2, D3; and the backup information is B1, B2; let B1 = D1 + D2 + D3, B2 = D1 + 2D2 + 4D3; then after the computer device obtains the information of 3 blocks, if it obtains B1, D2, and D3, it can calculate D1 and B2 from B1, D2, and D3, and recover the blocks.

[0116] S205. If the block recovery is successful, then synchronize the recovered block.

[0117] A successfully recovered block is a reliable block to be synchronized. The computer device stores the successfully recovered block; for example, the computer device writes the successfully recovered block into the blockchain ledger it maintains.

[0118] Understandably, since a block can be successfully recovered based on k block information from the block information group, and these k block information are extracted from candidate blocks provided by different blockchain nodes, both the recovered block and these k block information are reliable. In other words, the successfully recovered block does not require additional verification (such as verifying the hash value in the block header).

[0119] In this embodiment, the target block height of the block to be synchronized is obtained; M candidate blocks with a block height equal to the target block height are obtained from different blockchain nodes, each candidate block containing N block information, each N block information corresponding to a different sequence number; k block information with different sequence numbers are selected from the M candidate blocks and aggregated into a block information group, where the k block information in the block information group comes from the k candidate blocks respectively; the block information in the block information group is restored; if the block restoration is successful, the restored block is synchronized. It can be seen that the synchronized block is obtained based on multiple block information; since this block information comes from different blockchain nodes, on the one hand, the reliability of the restored block is ensured, and on the other hand (since there is no need to verify the restored block again), the synchronization efficiency of the block can be improved.

[0120] Please see Figure 4 , Figure 4 This is a flowchart illustrating another block synchronization method provided in an embodiment of this application. This block synchronization method can be executed by a computer device, specifically, the computer device may be... Figure 1d The request node 101 is shown in the image. Figure 4 As shown, the block synchronization method may include the following steps S401-S410:

[0121] S401. Obtain the target block height of the block to be synchronized.

[0122] For a detailed implementation of step S401, please refer to Figure 2 The implementation method of step S201 will not be described in detail here.

[0123] S402. Obtain M candidate blocks with a block height equal to the target block height from different blockchain nodes.

[0124] In one implementation, the computer device can broadcast requests to various blockchain nodes within the blockchain network, requesting a block with a height equal to the target block height. The request carries the target block height. Further, if M blockchain nodes respond to the block request, the computer device retrieves candidate blocks returned by these M nodes that have a height equal to the target block height. These candidate blocks are alternatives to the blocks to be synchronized; specifically, since the computer device has not yet determined whether the block with the target block height retrieved from the blockchain nodes is reliable, it first uses this block as a candidate for the blocks to be synchronized, to assist in the recovery and verification of the blocks to be synchronized.

[0125] Optionally, during block synchronization, the computer device can maintain a set of trusted nodes. The blockchain nodes in this set can be blockchain nodes that have not provided the computer device with erroneous blocks. When block synchronization is required, the computer device can send a block retrieval request to the blockchain nodes in the set of trusted nodes to improve the reliability of the retrieved candidate blocks.

[0126] S403. Select k blocks with different serial numbers from the M candidate blocks and aggregate them into a block information group.

[0127] The computer device selects k block information from any k candidate blocks out of M candidate blocks. Each candidate block selects one block information, and these k block information pieces have different sequence numbers. In practice, the computer device can either add each selected block information piece to a block information group until the block information group contains k blocks, or it can add the k blocks to the block information group after selecting all k blocks.

[0128] In one implementation, if the computer device only needs to synchronize the blocks to be synchronized, the computer device selects k blocks with different sequence numbers from M candidate blocks each time and aggregates them into a block information group. If the block information group can successfully recover the blocks, then the recovered blocks can be synchronized.

[0129] In another implementation, if the computer device needs to filter malicious nodes among blockchain nodes providing M candidate blocks, the computer device can combine the block information from the M candidate blocks in C(M,k) possible combinations. After obtaining C(M,k) block information groups, the computer device can perform recovery processing on the block information in each block information group. If a block can be recovered from the target block information group, the target block information group is added to the verification set; if a block cannot be recovered from the target block information group, the target block information group is added to the failure set. The target block information group is any one of the C(M,k) block information groups. Furthermore, the computer device can verify the block information groups in the failure set based on the block information groups in the verification set to determine problematic block information in the failure set, thereby identifying malicious nodes.

[0130] S404. Perform recovery processing on the block information in the block information group.

[0131] For a detailed implementation of step S404, please refer to [link / reference]. Figure 2 The implementation method of step S204 will not be described in detail here.

[0132] S405. Determine whether the block has been successfully restored.

[0133] In one implementation, the recovery process involves constructing a k-variable linear equation from the k block information to solve for the remaining Nk block information contained in the block. If the k-variable linear equation has no solution, it indicates that the block recovery has failed, and step S407 is executed; if the k-variable linear equation has a unique solution, it indicates that the block recovery has succeeded, and step S406 is executed.

[0134] Optionally, if a linear equation in k variables has multiple solutions, the computer device can further verify the results based on the signatures in the candidate blocks.

[0135] S406. Synchronize the recovered blocks.

[0136] For a detailed implementation of step S406, please refer to Figure 2 The implementation method of step S205 will not be described in detail here.

[0137] S407. The block information group is designated as the first block information group.

[0138] The first block information group is the block information group of the failed block recovery. In one implementation, the computer device can add the first block information group to the failure set, and the block information groups in the failure set can be used to identify malicious nodes in the blockchain.

[0139] S408, Obtain the second block information group.

[0140] The second block information group is the block information group from which the recovered block was successfully recovered. Both the first and second block information groups include block information with the same sequence number. In one implementation, the second block information group is obtained by the computer device from a verification set, which includes at least one set of block information groups, each of which can successfully recover a block.

[0141] S409. Based on the differences between the first block information group and the second block information group, identify the malicious nodes in the blockchain nodes.

[0142] When it is necessary to identify malicious nodes, the computer device compares the second block information group in the verification set with the first block information group in the failure set, and determines the malicious nodes in the blockchain nodes based on the difference between the first block information group and the second block information group.

[0143] In one implementation, the second block information group is an adjacent block information group of the first block information group. An adjacent block information group refers to a group in which the first and second block information groups include k-1 blocks with the same sequence number. For example, if the first block information group includes blocks with sequence numbers {1, 2, 3, 5}, its adjacent block information groups can include blocks with sequence numbers {1, 2, 3, 4}, {1, 3, 4, 5}, {2, 3, 4, 5}, or {1, 2, 4, 5}.

[0144] The computer device compares whether blocks with the same sequence number in the first and second block information groups match. Specifically, if the block with sequence number i in the first block information group does not match the block with sequence number i in the second block information group, the blockchain node associated with the block with sequence number i in the first block information group is identified as a malicious node. Here, the block with sequence number i is any one of the k-1 blocks with the same sequence number. For example, suppose the first block information group includes blocks with sequence numbers {1, 2, 3, 5}, and the second block information group includes blocks with sequence numbers {1, 2, 4, 5}, and the block with sequence number 1 in the first block information group does not match the block with sequence number 1 in the second block information group, then the computer device identifies the blockchain node associated with the block with sequence number 1 as a malicious node.

[0145] If the first block information group matches one-to-one with the k-1 blocks with the same sequence number in the second block information group, the computer device will identify the blockchain node associated with the block information with sequence number j in the first block information group as a malicious node. Here, the block information with sequence number j refers to all blocks except the k-1 blocks with the same sequence number. For example, if the sequence numbers of the blocks in the first block information group are {1, 2, 3, 5}, and the sequence numbers of the blocks in the second block information group are {1, 2, 4, 5}, then the block information with sequence number j in the first block information group refers to the block information with sequence number 3. If the blocks with sequence numbers 1, 2, and 5 in the first and second block information groups match one-to-one, the computer device will identify the blockchain node associated with the block information with sequence number 3 as a malicious node.

[0146] In another implementation, the first block information group and the second block information group include a block information with the same sequence number. The computer device compares whether the block information with the same sequence number in the first and second block information groups matches. If the block information with the same sequence number in the first and second block information groups does not match, the blockchain node associated with that block information is identified as a malicious node. For example, suppose the sequence numbers of the blocks in the first block information group are {1, 2, 3, 5}, and the sequence numbers of the blocks in the second block information group are {1, 4, 6, 7}, and the block information with sequence number 1 in the first block information group does not match the block information with sequence number 1 in the second block information group, then the computer device identifies the blockchain node associated with the block information with sequence number 1 as a malicious node. The computer device can also continue to obtain a block information group containing at least one of the blocks with sequence numbers 2, 3, and 5 from the verification set to further verify the first block information group.

[0147] If the first and second block information groups contain blocks with the same sequence number, then the third block information group is obtained. Based on the differences between the first and third block information groups, malicious nodes in the blockchain are identified. Specifically, if the first and third block information groups contain blocks with the same sequence number, the block can be successfully recovered based on the block information in the third block information group. For detailed implementation methods, please refer to the implementation method of determining malicious nodes in the blockchain based on the differences between the first and second block information groups using computer equipment; it will not be elaborated upon here.

[0148] Figure 5a This is a flowchart illustrating how to determine a malicious node, as provided in an embodiment of this application. Figure 5aAs shown, the computer device receives response information from M blockchain nodes regarding block retrieval requests. The response information carries candidate blocks with a block height equal to the target block height. Each candidate block includes N block information entries, each corresponding to a different sequence number; alternatively, the response information carries the block information entry for the candidate block with sequence number i. The computer device selects k block information entries with different sequence numbers each time to form a block information group, resulting in C(M,k) block information groups. Based on the block information in each block information group, it performs block recovery. If the current block information group successfully recovers the block, it adds the current block information group to the verification set; if the current block information group fails to successfully recover the block, it adds the current block information group to the failure set. After performing block recovery on the block information in all block information groups, the computer device can obtain the first block information group from the failure set and the second block information group related to the first block information group in the failure set from the verification set; wherein, the first block information group can be any block information group in the failure set, and the second block information group and the first block information group contain at least one block information with the same sequence number. The computer device determines whether the second block information group matches the block information with the same sequence number in the first block information group. If the block information with sequence number i in the first block information group does not match the block information with sequence number i in the second block information group, the blockchain node associated with the block information with sequence number i is identified as a malicious node. If the block information with sequence number i in the first block information group matches the block information with sequence number i in the second block information group, the device continues to determine whether the block information with sequence number i+1 in the first block information group matches the block information with sequence number i+1 in the second block information group. Alternatively, a third block information group is obtained from the verification set, and the block information with other sequence numbers (except for sequence number i) in the first block information group is verified in a similar manner until all the block information in the first block information group has been verified. Repeating the above steps can filter out all malicious nodes.

[0149] S410. Remove malicious nodes from the set of trusted nodes.

[0150] The trusted node set includes blockchain nodes that have not provided erroneous blocks to the computer device. Removing a malicious node can be permanent or within a preset time period. For example, the computer device can add the target blockchain node back to the trusted node set 30 days after removing it. Furthermore, the computer device can also broadcast the identifier of malicious nodes within the blockchain network.

[0151] Figure 5b This is a schematic diagram of a block synchronization process provided in an embodiment of this application. Figure 5bAs shown, the computer device first obtains the block height h of the block to be synchronized and sends a block retrieval request to the blockchain nodes; for example, the computer device can send a block retrieval request to a blockchain node in the trusted node set. In one implementation, the block retrieval request is used to request the retrieval of a block with block height h, and the block retrieval request carries the block height h. After receiving the block retrieval request, the blockchain node (such as a consensus node) determines the block required by the computer device (requesting node) from the stored blocks based on the block height h, and returns the block to the computer device. In another implementation, the block retrieval request is used to request the retrieval of block information with sequence number i contained in the block with block height h, and the block retrieval request carries the block height h and sequence number i. After receiving the block retrieval request, the blockchain node (such as a consensus node) determines the block required by the computer device from the stored blocks based on the block height h, performs sequence number processing on the block, and returns the block information with sequence number i in the block to the computer device. The computer device aggregates block information with different sequence numbers into a block information group. When the number of blocks in the block information group reaches a recovery threshold k, block recovery is performed based on the k blocks in the block information group. If block recovery fails, the computer device adds the current block information group to a failure set. The failure set includes one or more block information groups that failed to recover. These block information groups can be used to identify malicious nodes. For specific implementation details, please refer to [link to implementation details]. Figure 5a This will not be elaborated further here. Furthermore, after identifying a malicious node, the computer device can remove it from the trusted node set. If block recovery is successful, the computer device can write the successfully recovered block into the ledger, completing block synchronization. In addition, the computer device can add the current block information group to the verification set. The verification set includes one or more block information groups that have successfully recovered. These block information groups can be compared with block information groups in the failed set, and malicious nodes can be identified based on the differences between the two block information groups. For detailed implementation methods, please refer to [link to implementation details]. Figure 5a This will not be elaborated upon here.

[0152] In this embodiment, the target block height of the block to be synchronized is obtained; M candidate blocks with a block height equal to the target block height are obtained from different blockchain nodes, each candidate block containing N block information, each N block information corresponding to a different sequence number; k block information with different sequence numbers are selected from the M candidate blocks and aggregated into a block information group, where the k block information in the block information group comes from the k candidate blocks respectively; the block information in the block information group is restored; if the block restoration is successful, the restored block is synchronized. It can be seen that the synchronized block is obtained based on multiple block information; since this block information comes from different blockchain nodes, on the one hand, the reliability of the restored block is ensured, and on the other hand (since there is no need to verify the restored block again), the synchronization efficiency of the block can be improved.

[0153] Please see Figure 6 , Figure 6 This is a flowchart illustrating a node verification method provided in an embodiment of this application. The block synchronization method can be executed by a computer device, specifically, the computer device may be... Figure 1d The request node 101 is shown in the image. Figure 6 As shown, the block synchronization method may include the following steps S601-S602:

[0154] S601, Obtain the first block information group and the second block information group.

[0155] Both the first and second block information groups contain k block information belonging to the target block, and both groups include blocks with the same sequence number. The computer device cannot recover the target block based on the block information in the first block information group, but can recover the target block based on the block information in the second block information group.

[0156] In one implementation, the first block information group may be obtained by the computer device from a failure set, which contains at least one set of block information groups from which the target block cannot be recovered. These block information groups may be recorded by the computer device when the target block recovery fails. The second block information group may be obtained by the computer device from a success set, which contains at least one set of block information groups from which the target block can be recovered. These block information groups may be recorded by the computer device when the target block recovery is successful.

[0157] S602. Based on the differences between the block information with the same sequence number in the first block information group and the second block information group, determine the malicious nodes in the blockchain nodes.

[0158] For a detailed implementation of step S602, please refer to Figure 4 The implementation method in step S409 will not be described in detail here.

[0159] In this embodiment, a first block information group and a second block information group are obtained. Based on the differences between the first and second block information groups, malicious nodes in the blockchain are identified. Therefore, based on the differences between the block information groups that successfully recovered the target block and those that failed to recover the target block, malicious nodes in the blockchain can be identified, thereby improving the security of the blockchain network.

[0160] The methods of the embodiments of this application have been described in detail above. In order to facilitate better implementation of the above solutions of the embodiments of this application, the apparatus of the embodiments of this application is provided below.

[0161] Please see Figure 7 , Figure 7 This is a schematic diagram of a block synchronization device provided in an embodiment of this application. The device can be mounted on a computer device, which can specifically be... Figure 1d The requested node is shown as 101. Figure 7 The block synchronization device shown can be used to perform the above. Figure 2 and Figure 4 Some or all of the functionality described in the method embodiments. Please refer to [link / reference]. Figure 7 The detailed descriptions of each unit are as follows:

[0162] Acquisition unit 701 is used to acquire the target block height of the block to be synchronized;

[0163] The processing unit 702 is used to obtain M candidate blocks with a block height equal to the target block height from different blockchain nodes. Each candidate block contains N block information, and the N block information correspond to different sequence numbers.

[0164] And it is used to select k blocks with different serial numbers from M candidate blocks and aggregate them into a block information group. The k block information in the block information group comes from k candidate blocks respectively; k, M, and N are all positive integers, and k is less than or equal to M and less than or equal to N;

[0165] And it is used to recover block information in the block information group; if the block recovery is successful, the recovered block is synchronized.

[0166] In one embodiment, the processing unit 702 is further configured to:

[0167] If block recovery fails, the block information group will be designated as the first block information group.

[0168] Obtain the second block information group;

[0169] Based on the differences between the first block information group and the second block information group, malicious nodes in the blockchain nodes are identified;

[0170] The first block information group and the second block information group contain block information with the same sequence number. The block can be successfully recovered based on the block information in the second block information group.

[0171] In one implementation, the first block information group and the second block information group include k-1 blocks with the same sequence number; the processing unit 702 is used to determine malicious nodes in the blockchain nodes based on the differences between the first block information group and the second block information group, specifically for:

[0172] If the block information with sequence number i in the first block information group does not match the block information with sequence number i in the second block information group, then the blockchain node associated with the block information with sequence number i in the first block information group will be identified as a malicious node.

[0173] Among them, the block information with sequence number i is any one of the k-1 block information with the same sequence number;

[0174] If the first block information group matches one-to-one with the k-1 blocks with the same sequence number in the second block information group, then the blockchain node associated with the block information with sequence number j in the first block information group is identified as a malicious node.

[0175] Among them, the block information with sequence number j is the block information other than the (k-1) block information with the same sequence number.

[0176] In one implementation, the first block information group and the second block information group include block information with the same sequence number; the processing unit 702 is used to determine malicious nodes in the blockchain nodes based on the differences between the first block information group and the second block information group, specifically for:

[0177] If the block information with the same sequence number included in the first block information group and the second block information group does not match, then the blockchain node associated with that block information is identified as a malicious node.

[0178] If the block information with the same sequence number included in the first block information group and the second block information group matches, then the third block information group is obtained, and the malicious node in the blockchain node is determined based on the difference between the first block information group and the third block information group.

[0179] The first block information group and the third block information group contain block information with the same sequence number. The block can be successfully recovered based on the block information in the third block information group.

[0180] In one embodiment, the acquisition unit 701 is used to acquire the second block information group, specifically for:

[0181] Obtain the second block information group from the verification set;

[0182] The verification set includes at least one group of block information, and the block information in each group can be successfully recovered into a block.

[0183] In one implementation, the blockchain nodes belong to a set of trusted nodes; the processing unit 702 is further configured to:

[0184] Remove malicious nodes from the set of trusted nodes.

[0185] In one implementation, the block to be synchronized includes a block header and a block body; the block body consists of N block information, which includes m main information and Nm spare information, where m is a positive integer.

[0186] In one embodiment, the processing unit 702 is configured to perform recovery processing on the block information in the block information group, specifically for:

[0187] The k block information in the block information group are processed to obtain Nk recovery information;

[0188] Block recovery is performed based on k block information and Nk recovery information.

[0189] In one implementation, the acquisition unit 701 is used to acquire the target block height of the block to be synchronized, specifically for:

[0190] Get the maximum height of the synchronized blocks;

[0191] If a blockchain node stores a block to be synchronized that has a height greater than the maximum height, then the height of the block to be synchronized is determined as the target block height.

[0192] According to one embodiment of this application, Figure 2 and Figure 4 The block synchronization method shown can be partially implemented by... Figure 7 The block synchronization device shown is executed by each unit. For example, Figure 2 Step S201 shown can be performed by Figure 7 The acquisition unit 701 shown is executed, and steps S202-S205 can be performed by... Figure 7 The processing unit 702 shown executes the operation; Figure 4 Steps S401 and S408 shown can be derived from... Figure 7 The acquisition unit 701 shown executes steps S402-S407, S409, and S410, which can be performed by... Figure 7 The processing unit 702 shown is executed. Figure 7 The units in the block synchronization device shown can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effects of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the block synchronization device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.

[0193] According to another embodiment of this application, the following can be executed by running on a general-purpose computing device, such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM). Figure 2 and Figure 4 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 7 The block synchronization apparatus shown herein, and the block synchronization method for implementing embodiments of this application, are described. A computer program may be recorded on, for example, a computer-readable recording medium, loaded onto the aforementioned computing device via the computer-readable recording medium, and executed therein.

[0194] Based on the same inventive concept, the principle and beneficial effects of the block synchronization device provided in the embodiments of this application are similar to the principle and beneficial effects of the block synchronization method in the embodiments of this application. For details, please refer to the principle and beneficial effects of the method implementation. For the sake of brevity, these will not be repeated here.

[0195] Please see Figure 8 , Figure 8 This is a schematic diagram of a node verification device provided in an embodiment of this application. The device can be mounted on a computer device, specifically... Figure 1d The requested node is shown as 101. Figure 8 The node verification device shown can be used to perform the above. Figure 6 Some or all of the functionality described in the method embodiments. Please refer to [link / reference]. Figure 8 The detailed descriptions of each unit are as follows:

[0196] The acquisition unit 801 is used to acquire a first block information group and a second block information group. Both the first block information group and the second block information group contain k block information belonging to the target block, and the first block information group and the second block information group include block information with the same sequence number. The target block cannot be recovered based on the block information in the first block information group, but the target block can be recovered based on the block information in the second block information group.

[0197] Processing unit 802 is used to determine malicious nodes in the blockchain based on the differences between the block information with the same sequence number in the first block information group and the second block information group.

[0198] In one implementation, the first block information group and the second block information group include k-1 blocks with the same sequence number; the processing unit 802 is used to determine malicious nodes in the blockchain nodes based on the differences between the blocks with the same sequence number in the first block information group and the second block information group, specifically for:

[0199] If the block information with sequence number i in the first block information group does not match the block information with sequence number i in the second block information group, then the blockchain node associated with the block information with sequence number i in the first block information group will be identified as a malicious node.

[0200] Among them, the block information with sequence number i is any one of the k-1 block information with the same sequence number;

[0201] If the first block information group matches one-to-one with the k-1 blocks with the same sequence number in the second block information group, then the blockchain node associated with the block information with sequence number j in the first block information group is identified as a malicious node.

[0202] Among them, the block information with sequence number j is the block information other than the (k-1) block information with the same sequence number.

[0203] In one implementation, the first block information group and the second block information group include block information with the same sequence number; the processing unit 802 is used to determine malicious nodes in the blockchain nodes based on the differences between the block information with the same sequence number in the first block information group and the second block information group, specifically for:

[0204] If the block information with the same sequence number included in the first block information group and the second block information group does not match, then the blockchain node associated with that block information is identified as a malicious node.

[0205] If the block information with the same sequence number included in the first block information group and the second block information group matches, then the third block information group is obtained, and the malicious node in the blockchain node is determined based on the difference between the first block information group and the third block information group.

[0206] The first block information group and the third block information group contain block information with the same sequence number. The target block can be successfully recovered based on the block information in the third block information group.

[0207] According to one embodiment of this application, Figure 6 The node verification method shown can be partially implemented by... Figure 8 The node verification device shown is executed by each unit. For example, Figure 6 Step S601 shown can be performed by Figure 8 The acquisition unit 801 shown is executed, and step S602 can be performed by... Figure 8 The processing unit 802 shown executes. Figure 8 The nodes in the node verification device shown can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effects of the embodiments of this application. The above-mentioned units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the node verification device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.

[0208] According to another embodiment of this application, the following can be executed by running on a general-purpose computing device, such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM). Figure 6 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 8 The node verification apparatus shown herein, and the node verification method for implementing the embodiments of this application, are described. A computer program may be recorded on, for example, a computer-readable recording medium, loaded onto the aforementioned computing device via the computer-readable recording medium, and run therein.

[0209] Based on the same inventive concept, the principle and beneficial effects of the node verification device provided in the embodiments of this application are similar to the principle and beneficial effects of the node verification method in the embodiments of this application. For details, please refer to the principle and beneficial effects of the method implementation. For the sake of brevity, these will not be repeated here.

[0210] Please see Figure 9 , Figure 9 This application provides a schematic diagram of the structure of a computer device, as shown in the embodiment of the present application. Figure 9As shown, the computer device includes at least a processor 901, a communication interface 902, and a memory 903. The processor 901, communication interface 902, and memory 903 can be connected via a bus or other means. The processor 901 (or Central Processing Unit, CPU) is the computing and control core of the terminal. It can parse various instructions within the terminal and process various types of data. For example, the CPU can parse power-on / off commands sent by the user to the terminal and control the terminal to perform power-on / off operations; it can also transmit various interactive data between internal structures within the terminal, and so on. The communication interface 902 can optionally include standard wired interfaces and wireless interfaces (such as Wi-Fi, mobile communication interfaces, etc.), and can be used to send and receive data under the control of the processor 901; the communication interface 902 can also be used for data transmission and interaction within the terminal. The memory 903 is the memory device in the terminal, used to store programs and data. It can be understood that the memory 903 here can include the terminal's built-in memory, or it can include extended memory supported by the terminal. The memory 903 provides storage space for storing the terminal's operating system, which may include, but is not limited to, Android, iOS, Windows Phone, etc. This application does not limit this.

[0211] This application embodiment also provides a computer-readable storage medium (Memory), which is a memory device in a terminal for storing programs and data. It is understood that the computer-readable storage medium here can include both the built-in storage medium in the terminal and extended storage media supported by the terminal. The computer-readable storage medium provides storage space that stores the terminal's processing system. Furthermore, the storage space also stores one or more instructions suitable for loading and execution by the processor 901, which can be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be high-speed RAM or non-volatile memory, such as at least one disk storage device; optionally, it can also be at least one computer-readable storage medium located remotely from the aforementioned processor.

[0212] In one embodiment, the computer device may specifically be Figure 1d The requested node 101 is shown. Processor 901 performs the following operations by running the executable program code in memory 903:

[0213] Get the target block height of the block to be synchronized;

[0214] From different blockchain nodes, obtain M candidate blocks with a block height equal to the target block height. Each candidate block contains N block information, and the N block information correspond to different sequence numbers.

[0215] From M candidate blocks, select k blocks with different sequence numbers and aggregate them into a block information group. The k block information in the block information group comes from the k candidate blocks respectively; k, M, and N are all positive integers, and k is less than or equal to M and less than or equal to N;

[0216] Perform recovery processing on the block information in the block information group;

[0217] If the block recovery is successful, the recovered block will be synchronized.

[0218] As an optional embodiment, the processor 901, by running executable program code in the memory 903, also performs the following operations:

[0219] If block recovery fails, the block information group will be designated as the first block information group.

[0220] Obtain the second block information group;

[0221] Based on the differences between the first block information group and the second block information group, malicious nodes in the blockchain nodes are identified;

[0222] The first block information group and the second block information group contain block information with the same sequence number. The block can be successfully recovered based on the block information in the second block information group.

[0223] As an optional embodiment, the first block information group and the second block information group include k-1 blocks with the same sequence number; the processor 901 determines the malicious nodes in the blockchain nodes based on the differences between the first block information group and the second block information group. A specific embodiment of this is as follows:

[0224] If the block information with sequence number i in the first block information group does not match the block information with sequence number i in the second block information group, then the blockchain node associated with the block information with sequence number i in the first block information group will be identified as a malicious node.

[0225] Among them, the block information with sequence number i is any one of the k-1 block information with the same sequence number;

[0226] If the first block information group matches one-to-one with the k-1 blocks with the same sequence number in the second block information group, then the blockchain node associated with the block information with sequence number j in the first block information group is identified as a malicious node.

[0227] Among them, the block information with sequence number j is the block information other than the (k-1) block information with the same sequence number.

[0228] As an optional embodiment, the first block information group and the second block information group include block information with the same sequence number; the processor 901 determines the malicious node in the blockchain node based on the difference between the first block information group and the second block information group. A specific embodiment of this is as follows:

[0229] If the block information with the same sequence number included in the first block information group and the second block information group does not match, then the blockchain node associated with that block information is identified as a malicious node.

[0230] If the block information with the same sequence number included in the first block information group and the second block information group matches, then the third block information group is obtained, and the malicious node in the blockchain node is determined based on the difference between the first block information group and the third block information group.

[0231] The first block information group and the third block information group contain block information with the same sequence number. The block can be successfully recovered based on the block information in the third block information group.

[0232] As an optional embodiment, the specific embodiment in which the processor 901 obtains the second block information group is as follows:

[0233] Obtain the second block information group from the verification set;

[0234] The verification set includes at least one group of block information, and the block information in each group can be successfully recovered into a block.

[0235] As an optional embodiment, the blockchain node belongs to a set of trusted nodes; the processor 901, by running the executable program code in the memory 903, also performs the following operations:

[0236] Remove malicious nodes from the set of trusted nodes.

[0237] As an optional implementation, the block to be synchronized includes a block header and a block body; the block body consists of N block information, which includes m main information and Nm spare information, where m is a positive integer.

[0238] As an optional embodiment, the processor 901 performs recovery processing on the block information in the block information group as follows:

[0239] The k block information in the block information group are processed to obtain Nk recovery information;

[0240] Block recovery is performed based on k block information and Nk recovery information.

[0241] As an optional embodiment, the processor 901 obtains the target block height of the block to be synchronized in the following specific embodiment:

[0242] Get the maximum height of the synchronized blocks;

[0243] If a blockchain node stores a block to be synchronized that has a height greater than the maximum height, then the height of the block to be synchronized is determined as the target block height.

[0244] In another embodiment, the computer device may specifically be Figure 1d The requested node 101 is shown. Processor 1001 performs the following operations by running executable program code in memory 1003:

[0245] Obtain the first block information group and the second block information group. Both the first block information group and the second block information group contain k block information belonging to the target block, and the first block information group and the second block information group include block information with the same sequence number. The target block cannot be recovered based on the block information in the first block information group, but the target block can be recovered based on the block information in the second block information group.

[0246] Based on the differences between the block information with the same sequence number in the first block information group and the second block information group, malicious nodes in the blockchain nodes are identified.

[0247] As an optional embodiment, the first block information group and the second block information group include k-1 blocks with the same sequence number; the processor 1001 determines the malicious node in the blockchain node based on the difference between the blocks with the same sequence number in the first block information group and the second block information group. A specific embodiment of this is as follows:

[0248] If the block information with sequence number i in the first block information group does not match the block information with sequence number i in the second block information group, then the blockchain node associated with the block information with sequence number i in the first block information group will be identified as a malicious node.

[0249] Among them, the block information with sequence number i is any one of the k-1 block information with the same sequence number;

[0250] If the first block information group matches one-to-one with the k-1 blocks with the same sequence number in the second block information group, then the blockchain node associated with the block information with sequence number j in the first block information group is identified as a malicious node.

[0251] Among them, the block information with sequence number j is the block information other than the (k-1) block information with the same sequence number.

[0252] As an optional embodiment, the first block information group and the second block information group include a block information with the same sequence number; the processor 1001 determines the malicious node in the blockchain node based on the difference between the block information with the same sequence number in the first block information group and the second block information group. A specific embodiment of this is as follows:

[0253] If the block information with the same sequence number included in the first block information group and the second block information group does not match, then the blockchain node associated with that block information is identified as a malicious node.

[0254] If the block information with the same sequence number included in the first block information group and the second block information group matches, then the third block information group is obtained, and the malicious node in the blockchain node is determined based on the difference between the first block information group and the third block information group.

[0255] The first block information group and the third block information group contain block information with the same sequence number. The target block can be successfully recovered based on the block information in the third block information group.

[0256] Based on the same inventive concept, the principle and beneficial effects of the computer device provided in the embodiments of this application in solving the problem are similar to the principle and beneficial effects of the block synchronization method in the method embodiments of this application in solving the problem. For the sake of brevity, the principle and beneficial effects of the method implementation can be referred to.

[0257] This application also provides a computer-readable storage medium storing one or more instructions adapted for a processor to load and execute the block synchronization method of the above-described method embodiments.

[0258] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to execute the block synchronization method described in the above method embodiments.

[0259] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the block synchronization method described above.

[0260] The steps in the method of this application embodiment can be adjusted, combined, or deleted according to actual needs.

[0261] The modules in the device of this application embodiment can be merged, divided, and deleted according to actual needs.

[0262] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc.

[0263] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Those skilled in the art will understand that all or part of the processes for implementing the above embodiments and equivalent variations made in accordance with the claims of this application are still within the scope of this application.

Claims

1. A block synchronization method, characterized in that, The method includes: Get the target block height of the block to be synchronized; From different blockchain nodes, obtain M candidate blocks with a block height equal to the target block height. Each candidate block contains N block information, and the N block information corresponds to different sequence numbers. From the M candidate blocks, k blocks with different sequence numbers are selected and aggregated into a block information group. The k block information in the block information group comes from the k candidate blocks respectively. k, M, and N are all positive integers, and k is less than or equal to M and less than or equal to N. The block information in the block information group is restored. If the block recovery is successful, the recovered block will be synchronized; if the block recovery fails, the block information group will be designated as the first block information group. Obtain the second block information group; determine the malicious nodes in the blockchain nodes based on the differences between the first block information group and the second block information group; The first block information group and the second block information group include block information with the same sequence number, and the block can be successfully recovered based on the block information in the second block information group.

2. The method as described in claim 1, characterized in that, The first block information group and the second block information group include k-1 blocks with the same sequence number; the step of determining malicious nodes in the blockchain nodes based on the differences between the first block information group and the second block information group includes: If the block information with sequence number i in the first block information group does not match the block information with sequence number i in the second block information group, then the blockchain node associated with the block information with sequence number i in the first block information group is identified as a malicious node. Among them, the block information with sequence number i is any one of the k-1 block information with the same sequence number; If the first block information group matches one-to-one with the k-1 blocks with the same sequence number in the second block information group, then the blockchain node associated with the block information with sequence number j in the first block information group is identified as a malicious node. Among them, the block information with sequence number j is the block information other than the k-1 blocks with the same sequence number.

3. The method as described in claim 1, characterized in that, The first block information group and the second block information group include a block information with the same sequence number; the step of determining the malicious node in the blockchain node based on the difference between the first block information group and the second block information group includes: If the block information with the same sequence number included in the first block information group and the second block information group does not match, then the blockchain node associated with that block information is determined to be a malicious node. If the first block information group and the second block information group contain block information with the same sequence number, then the third block information group is obtained, and the malicious node in the blockchain node is determined based on the difference between the first block information group and the third block information group. The first block information group and the third block information group include block information with the same sequence number, and the block can be successfully recovered based on the block information in the third block information group.

4. The method as described in claim 1, characterized in that, The acquisition of the second block information group includes: Obtain the second block information group from the verification set; The verification set includes at least one group of block information, and the block information in each group can be successfully recovered into a block.

5. The method as described in claim 1, characterized in that, The blockchain node belongs to a set of trusted nodes; the method further includes: Remove the malicious node from the set of trusted nodes.

6. The method as described in claim 1, characterized in that, The block to be synchronized includes a block header and a block body; the block body is composed of the N block information, which includes m main information and Nm spare information, where m is a positive integer.

7. The method as described in claim 6, characterized in that, The process of restoring the block information in the block information group includes: The k block information in the block information group are processed to obtain Nk recovery information; Block recovery is performed based on the k block information and the Nk recovery information.

8. The method as described in claim 1, characterized in that, The process of obtaining the target block height of the block to be synchronized includes: Get the maximum height of the synchronized blocks; If a blockchain node stores a block to be synchronized with a height greater than the maximum height, then the height of the block to be synchronized is determined as the target block height.

9. A node verification method, characterized in that, The method includes: Obtain a first block information group and a second block information group. Both the first and second block information groups contain k block information belonging to the target block, and both groups include block information with the same sequence number. The target block cannot be recovered based on the block information in the first block information group, but can be recovered based on the block information in the second block information group. Then, synchronize the recovered target block. Based on the differences between the block information with the same sequence number in the first block information group and the second block information group, malicious nodes in the blockchain nodes are identified; The block information group is formed by: obtaining M candidate blocks with a block height equal to the target block height from different blockchain nodes, each candidate block containing N block information, and the N block information corresponding to different sequence numbers; selecting k block information with different sequence numbers from the M candidate blocks and aggregating them to form the block information group, wherein the k block information in the block information group comes from the k candidate blocks respectively, and k, M, and N are all positive integers, and k is less than or equal to M and less than or equal to N.

10. The method as described in claim 9, characterized in that, The first block information group and the second block information group include k-1 blocks with the same sequence number; the step of determining malicious nodes in the blockchain nodes based on the differences between the blocks with the same sequence number in the first block information group and the second block information group includes: If the block information with sequence number i in the first block information group does not match the block information with sequence number i in the second block information group, then the blockchain node associated with the block information with sequence number i in the first block information group is identified as a malicious node. Among them, the block information with sequence number i is any one of the k-1 block information with the same sequence number; If the first block information group matches one-to-one with the k-1 blocks with the same sequence number in the second block information group, then the blockchain node associated with the block information with sequence number j in the first block information group is identified as a malicious node. Among them, the block information with sequence number j is the block information other than the k-1 blocks with the same sequence number.

11. The method as described in claim 9, characterized in that, The first block information group and the second block information group include a block information with the same sequence number; the step of determining the malicious node in the blockchain node based on the difference between the block information with the same sequence number in the first block information group and the second block information group includes: If the block information with the same sequence number included in the first block information group and the second block information group does not match, then the blockchain node associated with that block information is determined to be a malicious node. If the first block information group and the second block information group contain block information with the same sequence number, then the third block information group is obtained, and the malicious node in the blockchain node is determined based on the difference between the first block information group and the third block information group. The first block information group and the third block information group include block information with the same sequence number. The target block can be successfully recovered based on the block information in the third block information group.

12. A block synchronization device, characterized in that, The block synchronization device includes: The acquisition unit is used to acquire the target block height of the block to be synchronized. The processing unit is used to obtain M candidate blocks with a block height equal to the target block height from different blockchain nodes. Each candidate block contains N block information, and the N block information corresponds to different sequence numbers. And for selecting k blocks with different sequence numbers from the M candidate blocks and aggregating them into a block information group, wherein the k block information in the block information group comes from the k candidate blocks respectively; k, M, and N are all positive integers, and k is less than or equal to M and less than or equal to N; And for restoring block information in the block information group; if the block restoration is successful, the restored block is synchronized; if the block restoration fails, the block information group is determined as the first block information group. And for obtaining the second block information group; based on the difference between the first block information group and the second block information group, determine the malicious nodes in the blockchain nodes; The first block information group and the second block information group include block information with the same sequence number, and the block can be successfully recovered based on the block information in the second block information group.

13. A node verification device, characterized in that, The node verification device includes: An acquisition unit is configured to acquire a first block information group and a second block information group, both of which contain k block information belonging to the target block, and both the first and second block information groups include block information with the same sequence number; the target block cannot be recovered based on the block information in the first block information group, but can be recovered based on the block information in the second block information group, and the recovered target block is synchronized; The processing unit is used to determine malicious nodes in the blockchain nodes based on the differences between the first block information group and the second block information group; The block information group is formed by: obtaining M candidate blocks with a block height equal to the target block height from different blockchain nodes, each candidate block containing N block information, and the N block information corresponding to different sequence numbers; selecting k block information with different sequence numbers from the M candidate blocks and aggregating them to form the block information group, wherein the k block information in the block information group comes from the k candidate blocks respectively, and k, M, and N are all positive integers, and k is less than or equal to M and less than or equal to N.

14. A computer device, characterized in that, include: Storage devices and processors; A memory, wherein a computer program is stored; A processor is configured to load the computer program to implement the block synchronization method as described in any one of claims 1-8; or to load the computer program to implement the node verification method as described in any one of claims 9-11.

15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded by a processor and executed as the block synchronization method as described in any one of claims 1-8; or loaded and executed as the node verification method as described in any one of claims 9-11.

16. A computer program product, characterized in that, The computer program product includes a computer program adapted to be loaded by a processor and execute the block synchronization method as described in any one of claims 1-8; or to be loaded and execute the node verification method as described in any one of claims 9-11.