CN117155954A - Block synchronization method, device, equipment, storage medium and product - Google Patents
Block synchronization method, device, equipment, storage medium and product Download PDFInfo
- Publication number
- CN117155954A CN117155954A CN202210565934.4A CN202210565934A CN117155954A CN 117155954 A CN117155954 A CN 117155954A CN 202210565934 A CN202210565934 A CN 202210565934A CN 117155954 A CN117155954 A CN 117155954A
- Authority
- CN
- China
- Prior art keywords
- block
- block information
- group
- information group
- pieces
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 93
- 230000001360 synchronised effect Effects 0.000 claims abstract description 68
- 238000011084 recovery Methods 0.000 claims abstract description 56
- 238000012545 processing Methods 0.000 claims description 40
- 238000012795 verification Methods 0.000 claims description 22
- 238000004590 computer program Methods 0.000 claims description 20
- 230000006870 function Effects 0.000 description 13
- 238000010586 diagram Methods 0.000 description 12
- 238000004891 communication Methods 0.000 description 7
- 230000009286 beneficial effect Effects 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 6
- 230000008569 process Effects 0.000 description 5
- 230000005540 biological transmission Effects 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 3
- 230000004044 response Effects 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000013500 data storage Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/32—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
- H04L9/3236—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
- H04L9/3239—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Computing Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the application discloses a block synchronization method, a device, equipment, a storage medium and a product. The method comprises the following steps: acquiring the target block height of a block to be synchronized; obtaining M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and each block information corresponds to different serial numbers; k pieces of block information with different sequence numbers are selected from M pieces of alternative blocks and are converged into a block information group, and different block information in the block information group comes from different alternative blocks; restoring the block information in the block information group; and if the block recovery is successful, synchronizing the recovered block. Therefore, the block to be synchronized is recovered by acquiring part of block information of the block to be synchronized from different block chain nodes, and the synchronization efficiency of the block is improved on the premise of ensuring the reliability of the synchronized block.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a block synchronization method, apparatus, device, storage medium, and product.
Background
With the progress of scientific research, the blockchain technology is widely applied to various industries by the characteristic of checking the certification data. The core of the blockchain technique is that each blockchain node in the blockchain network stores blocks. When the stored data needs to be verified, the stored data can be commonly recognized based on the blocks stored in each block chain node, so that a verification result is obtained. The blocks stored in the various blockchain nodes in the blockchain network are typically obtained by synchronization. It has been found in practice that in order to ensure that synchronized blocks are reliable, a significant amount of memory and computing resources are consumed during the synchronization of the blocks, and the synchronization of the blocks is inefficient.
Disclosure of Invention
The embodiment of the application provides a block synchronization method, a device, equipment and a computer readable storage medium, which can improve the synchronization efficiency of blocks.
In one aspect, an embodiment of the present application provides a block synchronization method, including:
acquiring the target block height of a block to be synchronized;
obtaining M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and the N block information corresponds to different serial numbers respectively;
K pieces of block information with different sequence numbers are selected from M pieces of candidate blocks and converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; k. m, N are positive integers, and k is less than or equal to M and less than or equal to N;
restoring the block information in the block information group;
and if the block recovery is successful, synchronizing the recovered block.
In the embodiment of the application, the target block height of the block to be synchronized is obtained; obtaining M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and the N block information corresponds to different serial numbers respectively; k pieces of block information with different sequence numbers are selected from M pieces of candidate blocks and converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; restoring the block information in the block information group; and if the block recovery is successful, synchronizing the recovered block. It can be seen that the synchronized block is derived based on a plurality of block information; since the block information comes from different blockchain nodes, on one hand, the reliability of the restored block is ensured, and on the other hand (since the restored block is not required to be checked any more), the synchronization efficiency of the block can be improved.
In one aspect, an embodiment of the present application provides a node verification method, including:
acquiring a first block information group and a second block information group, wherein the first block information group and the second block information group both comprise k block information belonging to a target block, and the first block information group and the second block information group comprise block information with the same serial number; the target block cannot be recovered based on the block information in the first block information group, and the target block can be recovered based on the block information in the second block information group;
and determining malicious nodes in the block chain nodes according to the difference between the block information with the same serial numbers in the first block information group and the second block information group.
In the embodiment of the application, a first block information set and a second block information set are acquired, and malicious nodes in the block chain nodes are determined according to the difference between the first block information set and the second block information set. Therefore, based on the difference between the block information group of the target block which is successfully recovered and the block information group of the target block which is not successfully recovered, the malicious node in the block chain node can be determined, and the safety of the block chain network is further improved.
In one aspect, an embodiment of the present application provides a block synchronization device, including:
the acquisition unit is used for acquiring the target block height of the block to be synchronized;
the processing unit is used for acquiring M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and the N block information corresponds to different serial numbers respectively;
k pieces of block information with different sequence numbers are selected from M pieces of candidate blocks and are converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; k. m, N are positive integers, and k is less than or equal to M and less than or equal to N;
and the method is used for recovering the block information in the block information group; and if the block recovery is successful, synchronizing the recovered block.
In one embodiment, the processing unit is further configured to:
if the block recovery fails, determining the block information group as a first block information group;
acquiring a second block information set;
determining malicious nodes in the blockchain nodes according to the difference between the first block information group and the second block information group;
the first block information group and the second block information group comprise block information with the same serial number, and the blocks can be successfully recovered based on the block information in the second block information group.
In one embodiment, the first block information group and the second block information group comprise k-1 block information with the same serial number; the processing unit is configured to determine a malicious node in the blockchain node according to a difference between the first blockinformation group and the second blockinformation group, and is specifically configured to:
if the block information with the sequence number i in the first block information group is not matched with the block information with the sequence number i in the second block information group, determining a block chain link point associated with the block information with the sequence number i in the first block information group as a malicious node;
wherein, the block information with the sequence number i is any one of k-1 block information with the same sequence number;
if the first block information group is matched with the k-1 block information with the same serial number in the second block information group, determining a block chain link point associated with the block information with the serial number j in the first block information group as a malicious node;
wherein the block information with the sequence number j is the block information except the k-1 block information with the same sequence number.
In one embodiment, the first block information group and the second block information group include a block information with the same serial number; the processing unit is configured to determine a malicious node in the blockchain node according to a difference between the first blockinformation group and the second blockinformation group, and is specifically configured to:
If the block information with the same serial number contained in the first block information group and the second block information group is not matched, determining a block link point associated with the block information as a malicious node;
if the block information with the same serial number included in the first block information group and the second block information group are matched, a third block information group is obtained, and malicious nodes in the block chain nodes are determined according to 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 comprise block information with the same serial number, and the blocks can be successfully recovered based on the block information in the third block information group.
In one embodiment, the obtaining unit is configured to obtain the second block information set, specifically configured to:
acquiring a second block information group from the check set;
the check set includes at least one group of block information groups, and the block information in each group of block information groups can successfully recover the block.
In one embodiment, the block link points belong to a set of trusted nodes; the processing unit is further configured to:
malicious nodes are removed from the set of trusted nodes.
In one embodiment, the block to be synchronized includes a block header and a block body; the block is composed of N pieces of block information including m pieces of main information and N-m pieces of spare information, m being a positive integer.
In one embodiment, the processing unit is configured to perform recovery processing on the block information in the block information group, specifically configured to:
performing operation processing on k pieces of block information in the block information group to obtain N-k pieces of recovery information;
block recovery is performed based on the k pieces of block information and the N-k pieces of recovery information.
In one embodiment, the obtaining unit is configured to obtain a target block height of a block to be synchronized, specifically configured to:
obtaining the maximum height in the synchronized blocks;
and if the block chain node stores the blocks to be synchronized with the height larger than the maximum height, determining the height of the blocks to be synchronized as the target block height.
In one aspect, an embodiment of the present application provides a node verification apparatus, including:
an obtaining unit, configured to obtain a first block information group and a second block information group, where the first block information group and the second block information group each include k pieces of block information belonging to a 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, and the target block can be recovered based on the block information in the second block information group;
And the processing unit is used for determining malicious nodes in the blockchain nodes according to the difference between the first block information group and the second block information group.
As an alternative embodiment, the first block information group and the second block information group include k-1 block information with the same serial number; the processor determines that the specific embodiment of the malicious node in the blockchain node is as follows according to the difference between the block information with the same serial number in the first block information group and the second block information group:
if the block information with the sequence number i in the first block information group is not matched with the block information with the sequence number i in the second block information group, determining a block chain link point associated with the block information with the sequence number i in the first block information group as a malicious node;
wherein, the block information with the sequence number i is any one of k-1 block information with the same sequence number;
if the first block information group is matched with the k-1 block information with the same serial number in the second block information group, determining a block chain link point associated with the block information with the serial number j in the first block information group as a malicious node;
wherein the block information with the sequence number j is the block information except the k-1 block information with the same sequence number.
As an alternative embodiment, the first block information group and the second block information group include a block information with the same serial number; the processor determines that the specific embodiment of the malicious node in the blockchain node is as follows according to the difference between the block information with the same serial number in the first block information group and the second block information group:
if the block information with the same serial number contained in the first block information group and the second block information group is not matched, determining a block link point associated with the block information as a malicious node;
if the block information with the same serial number included in the first block information group and the second block information group are matched, a third block information group is obtained, and malicious nodes in the block chain nodes are determined according to 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 comprise block information with the same serial number, and the target block can be successfully recovered based on the block information in the third block information group.
Accordingly, the present application provides a computer device comprising:
a processor for loading and executing the computer program;
a computer readable storage medium having a computer program stored therein, which when executed by a processor, implements the above-described block synchronization method; or the node verification method is realized.
Accordingly, the present application provides a computer readable storage medium storing a computer program adapted to be loaded by a processor and to perform the above-described block synchronization method; or load and execute the node verification method described above.
Accordingly, the present application provides a computer program product or computer program comprising 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, the processor executing the computer instructions to cause the computer device to perform the block synchronization method described above; or performing the node verification method described above.
In the embodiment of the application, the target block height of the block to be synchronized is obtained; obtaining M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and the N block information corresponds to different serial numbers respectively; k pieces of block information with different sequence numbers are selected from M pieces of candidate blocks and converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; restoring the block information in the block information group; and if the block recovery is successful, synchronizing the recovered block. It can be seen that the synchronized block is derived based on a plurality of block information; since the block information comes from different blockchain nodes, on one hand, the reliability of the restored block is ensured, and on the other hand (since the restored block is not required to be checked any more), the synchronization efficiency of the block can be improved.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1a is a schematic diagram of a data sharing system according to an embodiment of the present application;
FIG. 1b is a block chain architecture diagram according to an embodiment of the present application;
FIG. 1c is a schematic flow chart of a block generation method according to an embodiment of the present application;
FIG. 1d is a block diagram of a block synchronization system according to an embodiment of the present application;
fig. 2 is a flowchart of a block synchronization method according to an embodiment of the present application;
FIG. 3 is a block diagram of an embodiment of the present application;
FIG. 4 is a flowchart of another block synchronization method according to an embodiment of the present application;
FIG. 5a is a flowchart for determining malicious nodes according to an embodiment of the present application;
fig. 5b is a schematic block synchronization flow chart according to an embodiment of the present application;
FIG. 6 is a flowchart of a node verification method according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a block synchronization device according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a node verification device according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Embodiments of the present application relate to blockchain technology and related terms and concepts of blockchain technology are briefly described below:
blockchain (Blockchain) is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The method is characterized in that the method is a decentralised database, which is a series of data blocks generated by correlation of a cryptography method, and each data block contains information of a batch of network transactions and is used for checking the validity (anti-counterfeiting) of the information and generating a next block. The blockchain may include a blockchain underlying platform, a platform product services layer, and an application services layer.
A blockchain network may be understood as a data sharing system 100, the data sharing system 100 may refer to a system for sharing data between nodes, and an exemplary architecture of the data sharing system 100 may be seen in fig. 1a; as shown in fig. 1a, a data sharing system 100 refers to a system for performing data sharing between nodes, where a plurality of nodes 1001 may be included in the data sharing system, and the plurality of nodes 1001 may be respective clients in the data sharing system. Each node 1001 may receive input information while operating normally and maintain shared data within the data sharing system based on the received input information. In order to ensure the information intercommunication in the data sharing system, information connection can exist between each node in the data sharing system, and the nodes can transmit information through the information connection. For example, when any node in the data sharing system receives input information, other nodes in the data sharing system acquire the input information according to a consensus algorithm, and store the input information as data in the shared data, so that the data stored on all nodes in the data sharing system are consistent.
Each node in the data sharing system has a node identifier corresponding to the node identifier, and each node in the data sharing system 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 data sharing system according to the node identifiers of the other nodes. Each node can maintain a node identification list shown in the following table, and the node names and the node identifications are correspondingly stored in the node identification list. Wherein the node identity may be an IP (Internet Protocol, protocol for interconnection between networks) address and any other information that can be used to identify the node; for example, the node identifier may also be a binary sequence code (e.g., 110001110), and table 1 is only illustrated by taking an IP address as an example:
TABLE 1
Node name | Node identification |
Node 1 | 117.114.151.174 |
Node 2 | 117.116.189.145 |
… | … |
Node X (X is a positive integer) | xx.xxx.xxx.xxx |
Each node in the data sharing system stores one and the same blockchain. The blockchain is composed of a plurality of blocks, see fig. 1b, the blockchain is composed of a plurality of blocks, the starting block comprises a block head and a block main body, the block head stores an input information characteristic value, a version number, a time stamp and a difficulty value, and the block main body stores input information; the next block of the starting block takes the starting block as a father block, the next block also comprises a block head and a block main body, the block head stores the input information characteristic value of the current block, the block head characteristic value of the father block, the version number, the timestamp and the difficulty value, and the like, so that the block data stored in each block in the block chain are associated with the block data stored in the father block, and the safety of the input information in the block is ensured.
When each block in the blockchain is generated, referring to fig. 1c, when the node where the blockchain is located receives input information, checking the input information, after the checking is completed, storing the input information into a memory pool, and updating a hash tree used for recording the input information; then, updating the update time stamp to the time of receiving the input information, trying different random numbers, and calculating the characteristic value for a plurality of times, so that the calculated characteristic value can meet the following formula:
SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET
wherein SHA256 is a eigenvalue algorithm used to calculate eigenvalues; version (version number) is version information of the related block protocol in the block chain; the prev_hash is the block header characteristic value of the parent block of the current block; the merkle_root is a characteristic value of input information; ntime is the update time of the update timestamp; the nbits is the current difficulty, is a fixed value in a period of time, and is determined again after exceeding a fixed period of time; x is a random number; TARGET is a eigenvalue threshold that can be determined from nbits.
Thus, when the random number meeting the formula is calculated, the information can be correspondingly stored to generate the block head and the block main body, and the current block is obtained. And then, broadcasting the newly generated block to other nodes in the data sharing system according to the node identification of other nodes in the data sharing system by the node in which the block chain is positioned, performing common check on the newly generated block by the other nodes, and adding the newly generated block into the stored block chain after the common check is finished.
Based on the above description of the blockchain network structure related to the embodiment of the present application, the following description simply describes the blocksynchronization scheme provided by the embodiment of the present application based on the blockchain network structure, which can better promote convenience of subscribing to target transaction data. Referring to fig. 1d, fig. 1d is a block synchronization system architecture diagram according to an embodiment of the present application. As shown in fig. 1d, the block synchronization system may include: a requesting node 101 and a blockchain node 102. The block synchronization method provided by the embodiment of the present application may be performed by the requesting node 101. The requesting node 101 and the blockchain node 102 may specifically be terminal devices, or servers; wherein the terminal device includes, but is not limited to: smart phones (such as Android phones, IOS phones, etc.), tablet computers, portable personal computers, mobile internet devices (MID for short), vehicle terminals, etc., which are not limited in the embodiment of the present application. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing 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 ), basic cloud computing services such as big data and an artificial intelligent platform, which is not limited in the embodiment of the present application.
It should be noted that, the requesting node 101 may be a blockchain node, and the requesting node 101 and the blockchain node 102 in fig. 1d may be directly or indirectly connected through a wired communication or a wireless communication, which is not limited herein. The number of requesting nodes and blockchain nodes is for example only and does not constitute a practical limitation of the present application.
It will be appreciated that in the detailed description of the present application, regarding block synchronization, when the above embodiments of the present application are applied to a specific product or technology, corresponding block synchronization rights (e.g., the requesting node is a blockchain node and has block synchronization rights) need to be obtained, and the collection, use and processing of relevant data need to comply with relevant laws and regulations and standards of relevant countries and regions.
The general principle of the block synchronization scheme is as follows:
(1) The requesting node 101 acquires the target block height of the block to be synchronized. In one embodiment, the requesting node 101 obtains the maximum height h of the synchronized blocks, and if the block chain node 102 stores a block with a height greater than h and the requesting node 101 has not synchronized, determines the block as a block to be synchronized, and determines the height of the block to be synchronized (e.g., h+1) as a target block height; h is a positive integer.
(2) The requesting node 101 obtains M candidate blocks with the block height being the target block height from the different blockchain nodes 102, i.e. the requesting node 101 obtains M candidate blocks with the block height being the target block height from the M blockchain nodes 102. Each candidate block comprises N pieces of block information, and the N pieces of block information correspond to different serial numbers respectively.
(3) The request node 101 selects k pieces of block information with different sequence numbers from M pieces of candidate blocks to be converged into a block information group; k block information in the block information group is respectively from k candidate blocks acquired from different block chain nodes; k. m, N are positive integers, and k is less than or equal to M and less than or equal to N. For example, the requesting node 101 selects block information of sequence number 2 from the first candidate block, selects block information … of sequence number 5 from the second candidate block, and aggregates k pieces of block information having different sequence numbers into a block information group.
(4) The requesting node 101 performs recovery processing for 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 is composed of N pieces of block information including m pieces of main information and N-m pieces of spare information, m being a positive integer. The main information is evidence storage information (such as transaction data), and the standby information can be used for calculating the main information; the request node 101 performs operation processing on k pieces of block information in the block information group to obtain N-k pieces of recovery information, and performs block recovery based on the k pieces of block information and the N-k pieces of recovery information; for example, let the body information be D1, D2, D3; the standby information is B1; and b1=d1+d2+d3; then when D1 is missing, D1 can be calculated by B1, D2 and D3 and the block restored.
(5) If the block recovery is successful, the requesting node 101 synchronizes the recovered block.
In the embodiment of the application, the target block height of the block to be synchronized is obtained; obtaining M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and the N block information corresponds to different serial numbers respectively; k pieces of block information with different sequence numbers are selected from M pieces of candidate blocks and converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; restoring the block information in the block information group; and if the block recovery is successful, synchronizing the recovered block. It can be seen that the synchronized block is derived based on a plurality of block information; since the block information comes from different blockchain nodes, on one hand, the reliability of the restored block is ensured, and on the other hand (since the restored block is not required to be checked any more), the synchronization efficiency of the block can be improved.
Based on the above-mentioned block synchronization scheme, the embodiment of the present application proposes a more detailed block synchronization method, and the data transmission method proposed by the embodiment of the present application will be described in detail with reference to the accompanying drawings.
Referring to fig. 2, fig. 2 is a flowchart of a block synchronization method according to an embodiment of the present application, where the block synchronization method may be performed by a computer device, and the computer device may specifically be the requesting node 101 shown in fig. 1 d. As shown in fig. 2, the block synchronization method may include the following steps S201 to S205:
s201, obtaining the target block height of the block to be synchronized.
The computer equipment determines the target block height of the blocks to be synchronized according to the heights of the blocks synchronized by the computer equipment and the heights of the blocks stored in each block chain node in the block chain network. Specifically, please the computer device obtain the maximum height h in the synchronized block, if the block chain node stores a block with a height greater than h and the computer device is not synchronized yet, determining the block as the block to be synchronized, and determining the height (e.g., h+1) of the block to be synchronized as the target block height; h is a positive integer.
S202, obtaining M candidate blocks with the block height being the target block height from different block chain nodes.
Each candidate block comprises N pieces of block information, the N pieces of block information respectively correspond to different serial numbers, and M and N are positive integers; for example, the first block information corresponds to a sequence number of 1, the second block information corresponds to a sequence number of 2 …, and the i block information corresponds to a sequence number of i. The block information may be used to recover the block.
In one embodiment, the computer device may obtain partial block information of a block with a height of the target block height from different block chain nodes, that is, the computer device does not need to obtain a complete block with a block height of the target block height from each block chain node; for example, the computer device obtains the block information with the sequence number 1 from the first blockchain node and obtains the block information with the sequence number 3 from the second blockchain node.
Optionally, the blockchain nodes belong to a trusted node set, wherein the trusted node set comprises a plurality of blockchain nodes, and the blockchain nodes in the trusted node set are trusted for the computer device. Further, the computer device may update the set of trusted nodes based on whether the blocks provided by the block link points are reliable (reliable if the block information in the provided blocks can recover the blocks, unreliable if the block information in the provided blocks cannot recover the blocks).
S203, k pieces of block information with different sequence numbers are selected from M pieces of alternative blocks and are converged into a block information group.
K pieces of block information in the block information group are respectively from k alternative blocks acquired from different block chain nodes, namely, different block information is from different alternative blocks; k is a positive integer, and k is less than or equal to M and less than or equal to N. The computer device may aggregate the block information into a block information group every time one block information is selected, or may aggregate k block information into a block information group after k block information is selected.
In one embodiment, k is less than N; that is, the block information set only includes 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 set, see step S204 in detail.
In another embodiment, k is equal to N; that is, at this time the computer device may be based on the block information setThe included block information is directly restored to the block to be synchronized. In one implementation, the computer device may verify a portion of the block information in the set of block information based on another portion of the block information to ensure that the restored blocks to be synchronized are reliable. In other words, the computer device may select a pieces of block information to perform checking of the other N-a pieces of block information, a being an integer greater than 1; for example, let n=5, a=3, wherein block information 1 to block information 5 are denoted as Q1 to Q5, respectively; is provided with Q in parallel 4 =Q 1 +Q 2 +Q 3 ,Q 5 =Q 1 +2Q 2 +4Q 3 The method comprises the steps of carrying out a first treatment on the surface of the The computer device selects any 3 pieces of block information according to the relation to verify the other two pieces of block information so as to ensure that the restored blocks to be synchronized are reliable.
S204, recovering the block information in the block information group.
The computer device restores the block based on k pieces of block information in the block information group.
FIG. 3 is a block diagram of the embodiment of the present application, wherein the block includes a block header and a block body as shown in FIG. 3; the block is composed of N pieces of block information including m pieces of main information and N-m pieces of spare information, m being a positive integer. The main information is certification information (such as transaction data), and the standby information can be used for calculating the main information. As can be seen from fig. 3, the blocks do not need to include the node number certificates (Quorum Certificate, QC), and the blocks occupy less storage resources and transmission resources than the blocks including the node number certificates (Quorum Certificate, QC).
The process of restoring the block by the computer equipment comprises the following steps: the computer device performs operation processing on k pieces of block information in the block information group to obtain N-k pieces of recovery information, and performs block recovery based on the k pieces of block information and the N-k pieces of recovery information. For example, let n=4, k=3, where the body information is D 1 ,D 2 ,D 3 The method comprises the steps of carrying out a first treatment on the surface of the The standby information is B 1 The method comprises the steps of carrying out a first treatment on the surface of the Let B 1 =D 1 +D 2 +D 3 The method comprises the steps of carrying out a first treatment on the surface of the After the computer device acquires 3 pieces of block information, e.g. acquire Get B 1 ,D 2 And D 3 Can pass through B 1 ,D 2 And D 3 Calculation D 1 And restoring the block. For another example, let n=5, k=3, where the body information is D 1 ,D 2 ,D 3 The method comprises the steps of carrying out a first treatment on the surface of the The standby information is B 1 ,B 2 The method comprises the steps of carrying out a first treatment on the surface of the Let B 1 =D 1 +D 2 +D 3 ,B 2 =D 1 +2D 2 +4D 3 The method comprises the steps of carrying out a first treatment on the surface of the The computer device, after acquiring 3 pieces of block information, e.g. B 1 ,D 2 And D 3 Can pass through B 1 ,D 2 And D 3 Calculation D 1 And B 2 And restoring the block.
S205, if the block recovery is successful, the recovered block is synchronized.
The successfully recovered block is the reliable block to be synchronized. The computer device stores the restored block, e.g., the computer device writes the restored block into a self-maintained blockchain ledger.
It will be appreciated that since a block can be successfully restored based on k pieces of block information in the block information group, and the k pieces of block information are extracted from alternative blocks provided by different block chain nodes, both the restored block and the k pieces of block information are reliable. That is, the successfully recovered block does not need to be subjected to additional verification (e.g., verifying the hash value in the block header, etc.).
In the embodiment of the application, the target block height of the block to be synchronized is obtained; obtaining M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and the N block information corresponds to different serial numbers respectively; k pieces of block information with different sequence numbers are selected from M pieces of candidate blocks and converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; restoring the block information in the block information group; and if the block recovery is successful, synchronizing the recovered block. It can be seen that the synchronized block is derived based on a plurality of block information; since the block information comes from different blockchain nodes, on one hand, the reliability of the restored block is ensured, and on the other hand (since the restored block is not required to be checked any more), the synchronization efficiency of the block can be improved.
Referring to fig. 4, fig. 4 is a flowchart of another block synchronization method according to an embodiment of the present application, where the block synchronization method may be performed by a computer device, and the computer device may specifically be the requesting node 101 shown in fig. 1 d. As shown in fig. 4, the block synchronization method may include the following steps S401 to S410:
s401, obtaining the target block height of the block to be synchronized.
The specific embodiment of step S401 may refer to the embodiment of step S201 in fig. 2, and will not be described herein.
S402, obtaining M candidate blocks with the block heights being the target block heights from different block chain nodes.
In one embodiment, the computer device may broadcast in the blockchain network to send a blockacquisition request to each blockchain node, the blockacquisition request requesting to acquire a block with a blockheight that is the target blockheight, the blockacquisition request carrying the target blockheight. Further, if M blockchain nodes are provided to respond to the block acquisition request, the computer device acquires the block height returned by the M blockchain nodes as an alternative block of the target block height. The alternative block is an alternative of the block to be synchronized; specifically, since the computer device has not yet determined whether the block acquired from the blockchain node and having the height of the target block is reliable, the block is first used as an alternative to the block to be synchronized to assist in recovering and checking the block to be synchronized.
Optionally, in the block synchronization process, the computer device may maintain a trusted node set, where the blockchain nodes in the trusted node set may be blockchain nodes that have not provided the computer device with the error blocks, and when the block synchronization needs to be performed, the computer device may send a block acquisition request to the blockchain nodes in the trusted node set, so as to improve reliability of the acquired candidate blocks.
S403, k pieces of block information with different sequence numbers are selected from M pieces of alternative blocks and are converged into a block information group.
The computer apparatus selects k pieces of block information from any k pieces of block information among the M pieces of block information, one block information is selected for each block information, and the serial numbers of the k pieces of block information are different. In a specific implementation process, the computing device may add each piece of block information to the block information set until the number of pieces of block information included in the block information set is k; after k pieces of block information are selected, the k pieces of block information may be added to the block information group.
In one embodiment, if the computer device only needs to synchronize the blocks to be synchronized, the computer device selects k pieces of block information with different sequence numbers from the M pieces of candidate blocks each time to aggregate the k pieces of block information into the block information group, and if the block information group can successfully recover the block, the computer device synchronizes the recovered block.
In another embodiment, if the computer device needs to screen malicious nodes in the blockchain nodes providing the M candidate blocks, the computer device may combine the blockinformation in the M candidate blocks, the combination mode is C (M, k) and after obtaining the C (M, k) blockinformation sets, the computer device may restore the blockinformation in the blockinformation sets one by one, and if the target blockinformation set can restore the blocks, the target blockinformation set is added to the check set; if the target block information set cannot recover the block, the target block information set is added to the failure set. Wherein the target block information set is any one of C (M, k) block information sets. Further, the computer device may verify the block information set in the failure set based on the block information set in the verification set, determine block information having a problem in the block information set in the failure set, and further determine the malicious node.
S404, recovering the block information in the block information group.
The specific embodiment of step S404 can refer to the embodiment of step S204 in fig. 2, and will not be described herein.
S405, judging whether the block is successfully recovered.
In one embodiment, the recovery process is to construct a k-ary once equation from k pieces of block information to solve the remaining N-k pieces of block information contained in the block. If the k-element one-time equation is not solved, the block recovery is failed, and the step S407 is continuously executed; if the k-element one-time equation has a unique solution, it indicates that the block recovery is successful, and the step S406 is continued.
Alternatively, if there are multiple solutions to the k-element once equation, the computer device may further verify the results based on the signatures in the candidate block.
S406, synchronizing the restored blocks.
The specific embodiment of step S406 can refer to the embodiment of step S205 in fig. 2, and will not be described herein.
S407, determining the block information group as the first block information group.
The first block information set is a block information set in which recovering a block fails. In one embodiment, a computer device may add a first set of block information to a failure set, the set of block information in the failure set being usable to determine malicious nodes in a blockchain node.
S408, a second block information set is acquired.
The second block information set is a block information set for which the recovery block is successful. The first block information group and the second block information group comprise block information with the same serial number. In one embodiment, the second set of block information is obtained by the computer device from a check set, where the check set includes at least one set of block information, and each set of block information is capable of successfully recovering a block.
S409, determining malicious nodes in the blockchain nodes according to the difference between the first block information group and the second block information group.
When a malicious node needs to be determined, the computer device compares a second set of block information in the check set with a first set of block information in the failure set, and determines a malicious node in the blockchain node based on a difference between the first set of block information and the second set of block information.
In one embodiment, the second set of block information is a set of block information adjacent to the first set of block information. The adjacent block information group means: the first block information group and the second block information group comprise k-1 block information with the same serial number; for example, the sequence numbers of the block information included in the first block information group are {1,2,3,5}, respectively, and the sequence numbers of the block information included in its neighboring block information group may be {1,2,3,4}, {1,3,4,5}, {2,3,4,5}, {1,2,4,5}.
The computer equipment compares whether the block information with the same serial number in the first block information group and the second block information group are matched. Specifically, if the block information with the sequence number i in the first block information group is not matched with the block information with the sequence number i in the second block information group, determining a block link point associated with the block information with the sequence number i in the first block information group as a malicious node; wherein, the block information with the sequence number i is any one of k-1 block information with the same sequence number; for example, let the serial numbers of the block information included in the first block information group be {1,2,3,5}, the serial numbers of the block information included in the second block information group be {1,2,4,5}, and the block information with serial number 1 in the first block information group is not matched with the block information with serial number 1 in the second block information group, the computer device determines the blockchain node associated with the block information with serial number 1 as a malicious node.
If the first block information group is matched with k-1 block information with the same serial number in the second block information group, the computer equipment determines a block chain link point associated with block information with the serial number j in the first block information group as a malicious node; wherein the block information with the sequence number j is the block information except the k-1 block information with the same sequence number; for example, if the serial numbers of the block information included in the first block information group are {1,2,3,5}, and the serial numbers of the block information included in the second block information group are {1,2,4,5}, then in the first block information group, the block information with the serial number j refers to the block information with the serial number 3; if the block information with the sequence numbers of 1,2 and 5 in the first block information group and the second block information group are matched one by one, the computer equipment determines the block chain node associated with the block information with the sequence number of 3 as a malicious node.
In another embodiment, the first block information set and the second block information set include a block information with the same sequence number. The computer equipment compares whether the block information with the same serial number in the first block information group and the second block information group are matched. If the block information with the same serial number contained in the first block information group and the second block information group is not matched, determining a block link point associated with the block information as a malicious node; for example, let the serial numbers of the block information included in the first block information group be {1,2,3,5}, the serial numbers of the block information included in the second block information group be {1,4,6,7}, and the block information with serial number 1 in the first block information group is not matched with the block information with serial number 1 in the second block information group, the computer device determines the blockchain node associated with the block information with serial number 1 as a malicious node. The computer device may further obtain a block information set including at least one of the block information of sequence number 2, sequence number 3, and sequence number 5 from the check set, to further check the first block information set.
If the block information with the same serial number included in the first block information group and the second block information group are matched, a third block information group is obtained, and malicious nodes in the block chain nodes are determined according to 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 comprise block information with the same serial number, and the blocks can be successfully recovered based on the block information in the third block information group. The specific embodiments may refer to the computer device for determining the embodiment of the malicious node in the blockchain node according to the difference between the first blockinformation set and the second blockinformation set, which is not described herein.
Fig. 5a is a flowchart for determining a malicious node according to an embodiment of the present application. As shown in fig. 5a, the computer device obtains response information of M blockchain nodes for a block obtaining request, where the response information carries candidate blocks with block heights being target block heights, each candidate block includes N pieces of block information, and the N pieces of block information correspond to different serial numbers; or the response information carries the block information with the sequence number i in the alternative block. The computer equipment selects k block information with different serial numbers each time to form a block information group to obtain C (M, k) block information groups, and performs block recovery based on the block information in each block information group. If the current block information constitutes a successful recovery block, the current block information set is added to the check set, and if the current block information set does not successfully recover the block, the current block information set is added to the failure set. After performing block recovery on the block information in all the block information groups, the computer equipment can acquire a first block information group from the failure set, and acquire a second block information group related to the first block information group in the failure set from the check set; the first block information set may be any block information set in the failure set, and the second block information set and the first block information set have at least one block information with the same serial number. The computer equipment judges whether the second block information group is matched with the block information with the same serial number in the first block information group; if the block information with the sequence number i in the first block information group is not matched with the block information with the sequence number i in the second block information group, determining a block link point associated with the block information with the sequence number i as a malicious node; if the block information with the sequence number i in the first block information group is matched with the block information with the sequence number i in the second block information group, continuing to judge whether the block information with the sequence number i+1 in the first block information group is matched with the block information with the sequence number i+1 in the second block information group or acquiring a third block information group from a checking set, continuing to check the block information with other sequence numbers (except the sequence number i) in the first block information group according to a similar method until all the block information in the first block information group is checked, and repeating the steps to screen out all malicious nodes.
S410, removing the malicious node from the trusted node set.
The set of trusted nodes includes blockchain nodes that have not provided the computer device with the erroneous blocks. Removal of a malicious node may be a permanent removal, may be a removal within a preset period of time, for example, the computer device may rejoin the target blockchain node to the set of trusted nodes 30 days after removal of the target blockchain node from the set of trusted nodes. Further, the computer device may also broadcast the identity of the malicious node in the blockchain network.
Fig. 5b is a schematic block synchronization flow chart according to an embodiment of the present application. As shown in fig. 5b, the computer device first obtains the block height h of the blocks to be synchronized, and sends a block obtaining request to the blockchain node; for example, the computer device may send a block acquisition request to a blockchain node in the set of trusted nodes. In one embodiment, the block acquisition request is for requesting to acquire a block having a block height h, and the block acquisition request carries the block height h. After acquiring the block acquisition request, the blockchain node (such as a consensus node) determines a block required by the computer device (request node) from the stored blocks based on the block height h, and returns the block to the computer device. In another embodiment, the block acquisition request is used for requesting to acquire block information with a sequence number i included in a block with a block height h, and the block acquisition request carries the block height h and the sequence number i. After the block acquisition request is acquired, the block chain node (such as a consensus node) determines a block required by the computer equipment from the stored blocks based on the block height h, and processes the serial number of the block, and block information with the serial number of i in the block is returned to the computer equipment. The computer equipment gathers the block information with different serial numbers into a block information group, and when the quantity of the block information in the block information group reaches a recovery threshold k, block recovery is carried out based on k block information in the block information group. If the block recovery fails, the computer device adds the current block information set to a failure set, where the failure set includes one or more block information sets that fail the block recovery, and the block information sets may be used to determine malicious nodes, and detailed description of the embodiment may be omitted herein with reference to fig. 5 a. Further, the computer device may also remove the malicious node from the set of trusted nodes after determining the malicious node. If the block recovery is successful, the computer device can write the successfully recovered block into the account book to complete the block synchronization. In addition, the computer device may further add the current block information set to a check set, where the check set includes one or more block information sets that are successfully recovered, where the block information sets may be used to compare with the block information sets in the failure set, and determine malicious nodes based on a difference between the two block information sets, which is described in detail with reference to fig. 5 a.
In the embodiment of the application, the target block height of the block to be synchronized is obtained; obtaining M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and the N block information corresponds to different serial numbers respectively; k pieces of block information with different sequence numbers are selected from M pieces of candidate blocks and converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; restoring the block information in the block information group; and if the block recovery is successful, synchronizing the recovered block. It can be seen that the synchronized block is derived based on a plurality of block information; since the block information comes from different blockchain nodes, on one hand, the reliability of the restored block is ensured, and on the other hand (since the restored block is not required to be checked any more), the synchronization efficiency of the block can be improved.
Referring to fig. 6, fig. 6 is a flowchart of a node verification method according to an embodiment of the present application, where the block synchronization method may be performed by a computer device, and the computer device may specifically be the requesting node 101 shown in fig. 1 d. As shown in fig. 6, the block synchronization method may include the following steps S601 to S602:
S601, a first block information group and a second block information group are acquired.
The first block information group and the second block information group both comprise k block information belonging to the target block, and the first block information group and the second block information group comprise block information with the same serial number. The computer device can not recover the target block based on the block information in the first block information group, and can recover the target block based on the block information in the second block information group.
In one embodiment, the first block information set may be obtained from a failure set by the computer device, where the failure set includes at least one set of block information sets that cannot recover the target block, and the block information sets may be recorded by the computer device when the recovery of the target block fails. The second block information set may be obtained from a successful set by the computer device, where the successful set includes at least one set of block information sets capable of recovering the target block, and the block information sets may be recorded by the computer device when the recovery of the target block is successful.
S602, determining malicious nodes in the block chain nodes according to differences between the block information with the same serial numbers in the first block information group and the second block information group.
The specific embodiment of step S602 may refer to the embodiment of step S409 in fig. 4, and will not be described herein.
In the embodiment of the application, a first block information set and a second block information set are acquired, and malicious nodes in the block chain nodes are determined according to the difference between the first block information set and the second block information set. Therefore, based on the difference between the block information group of the target block which is successfully recovered and the block information group of the target block which is not successfully recovered, the malicious node in the block chain node can be determined, and the safety of the block chain network is further improved.
The foregoing details of the method of embodiments of the present application are provided for the purpose of better implementing the foregoing aspects of embodiments of the present application, and accordingly, the following provides an apparatus of embodiments of the present application.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a block synchronization apparatus according to an embodiment of the present application, where the apparatus may be mounted on a computer device, and the computer device may specifically be the requesting node 101 shown in fig. 1 d. The block synchronization device shown in fig. 7 may be used to perform some or all of the functions described above in the method embodiments described in fig. 2 and 4. Referring to fig. 7, the detailed descriptions of the respective units are as follows:
An obtaining unit 701, configured to obtain a target block height of a block to be synchronized;
the processing unit 702 is configured to obtain M candidate blocks with block heights being the target block heights from different block chain nodes, where each candidate block includes N pieces of block information, and the N pieces of block information respectively correspond to different serial numbers;
k pieces of block information with different sequence numbers are selected from M pieces of candidate blocks and are converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; k. m, N are positive integers, and k is less than or equal to M and less than or equal to N;
and the method is used for recovering the block information in the block information group; and if the block recovery is successful, synchronizing the recovered block.
In one embodiment, the processing unit 702 is further configured to:
if the block recovery fails, determining the block information group as a first block information group;
acquiring a second block information set;
determining malicious nodes in the blockchain nodes according to the difference between the first block information group and the second block information group;
the first block information group and the second block information group comprise block information with the same serial number, and the blocks can be successfully recovered based on the block information in the second block information group.
In one embodiment, the first block information group and the second block information group comprise k-1 block information with the same serial number; the processing unit 702 is configured to determine a malicious node in the blockchain node according to a difference between the first blockinformation group and the second blockinformation group, and is specifically configured to:
if the block information with the sequence number i in the first block information group is not matched with the block information with the sequence number i in the second block information group, determining a block chain link point associated with the block information with the sequence number i in the first block information group as a malicious node;
wherein, the block information with the sequence number i is any one of k-1 block information with the same sequence number;
if the first block information group is matched with the k-1 block information with the same serial number in the second block information group, determining a block chain link point associated with the block information with the serial number j in the first block information group as a malicious node;
wherein the block information with the sequence number j is the block information except the k-1 block information with the same sequence number.
In one embodiment, the first block information group and the second block information group include a block information with the same serial number; the processing unit 702 is configured to determine a malicious node in the blockchain node according to a difference between the first blockinformation group and the second blockinformation group, and is specifically configured to:
If the block information with the same serial number contained in the first block information group and the second block information group is not matched, determining a block link point associated with the block information as a malicious node;
if the block information with the same serial number included in the first block information group and the second block information group are matched, a third block information group is obtained, and malicious nodes in the block chain nodes are determined according to 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 comprise block information with the same serial number, and the blocks can be successfully recovered based on the block information in the third block information group.
In one embodiment, the obtaining unit 701 is configured to obtain the second block information set, specifically configured to:
acquiring a second block information group from the check set;
the check set includes at least one group of block information groups, and the block information in each group of block information groups can successfully recover the block.
In one embodiment, the block link points belong to a set of trusted nodes; the processing unit 702 is further configured to:
malicious nodes are removed from the set of trusted nodes.
In one embodiment, the block to be synchronized includes a block header and a block body; the block is composed of N pieces of block information including m pieces of main information and N-m pieces of spare information, m being a positive integer.
In one embodiment, the processing unit 702 is configured to perform recovery processing on the block information in the block information group, specifically configured to:
performing operation processing on k pieces of block information in the block information group to obtain N-k pieces of recovery information;
block recovery is performed based on the k pieces of block information and the N-k pieces of recovery information.
In one embodiment, the obtaining unit 701 is configured to obtain a target block height of a block to be synchronized, specifically:
obtaining the maximum height in the synchronized blocks;
and if the block chain node stores the blocks to be synchronized with the height larger than the maximum height, determining the height of the blocks to be synchronized as the target block height.
According to one embodiment of the present application, some of the steps involved in the block synchronization method shown in fig. 2 and 4 may be performed by various units in the block synchronization device shown in fig. 7. For example, step S201 shown in fig. 2 may be performed by the acquisition unit 701 shown in fig. 7, and steps S202 to S205 may be performed by the processing unit 702 shown in fig. 7; step S401 and step S408 shown in fig. 4 may be performed by the acquisition unit 701 shown in fig. 7, step S402 to step S407, and step S409 and step S410 may be performed by the processing unit 702 shown in fig. 7. The respective units in the block synchronization apparatus shown in fig. 7 may be combined into one or several additional units separately or all, or some (some) of the units may be further split into a plurality of units with smaller functions, which may achieve the same operation without affecting the achievement of the technical effects of the embodiments of the present application. The above units are divided based on logic functions, and in practical applications, the functions of one unit may be implemented by a plurality of units, or the functions of a plurality of units may be implemented by one unit. In other embodiments of the present application, the block synchronization device may also include other units, and in practical applications, these functions may also be implemented with assistance from other units, and may be implemented by cooperation of multiple units.
According to another embodiment of the present application, a block synchronization device as shown in fig. 7 may be constructed by running a computer program (including program code) capable of executing the steps involved in the respective methods as shown in fig. 2 and 4 on a general-purpose computing device such as a computer including a processing element such as a Central Processing Unit (CPU), a random access storage medium (RAM), a read only storage medium (ROM), and the like, and a storage element, and implementing the block synchronization method of the embodiment of the present application. The computer program may be recorded on, for example, a computer-readable recording medium, and loaded into and run in the above-described computing device through the computer-readable recording medium.
Based on the same inventive concept, the principle and beneficial effects of the block synchronization device provided in the embodiments of the present application are similar to those of the block synchronization method in the embodiments of the present application, and may refer to the principle and beneficial effects of implementation of the method, which are not described herein for brevity.
Referring to fig. 8, fig. 8 is a schematic structural diagram of a node verification apparatus according to an embodiment of the present application, where the apparatus may be mounted on a computer device, and the computer device may specifically be the requesting node 101 shown in fig. 1 d. The node verification device shown in fig. 8 may be used to perform some or all of the functions described above in the method embodiment depicted in fig. 6. Referring to fig. 8, the detailed descriptions of the respective units are as follows:
An obtaining unit 801, configured to obtain a first block information group and a second block information group, where the first block information group and the second block information group each include k pieces of block information belonging to a 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, and the target block can be recovered based on the block information in the second block information group;
the processing unit 802 is configured to determine a malicious node in the blockchain node according to a difference between the blockinformation with the same sequence number in the first blockinformation group and the second blockinformation group.
In one embodiment, the first block information group and the second block information group comprise k-1 block information with the same serial number; the processing unit 802 is configured to determine a malicious node in the blockchain node according to a difference between the blockinformation with the same sequence numbers in the first blockinformation group and the second blockinformation group, and is specifically configured to:
if the block information with the sequence number i in the first block information group is not matched with the block information with the sequence number i in the second block information group, determining a block chain link point associated with the block information with the sequence number i in the first block information group as a malicious node;
Wherein, the block information with the sequence number i is any one of k-1 block information with the same sequence number;
if the first block information group is matched with the k-1 block information with the same serial number in the second block information group, determining a block chain link point associated with the block information with the serial number j in the first block information group as a malicious node;
wherein the block information with the sequence number j is the block information except the k-1 block information with the same sequence number.
In one embodiment, the first block information group and the second block information group include a block information with the same serial number; the processing unit 802 is configured to determine a malicious node in the blockchain node according to a difference between the blockinformation with the same sequence numbers in the first blockinformation group and the second blockinformation group, and is specifically configured to:
if the block information with the same serial number contained in the first block information group and the second block information group is not matched, determining a block link point associated with the block information as a malicious node;
if the block information with the same serial number included in the first block information group and the second block information group are matched, a third block information group is obtained, and malicious nodes in the block chain nodes are determined according to 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 comprise block information with the same serial number, and the target block can be successfully recovered based on the block information in the third block information group.
According to one embodiment of the present application, part of the steps involved in the node verification method shown in fig. 6 may be performed by respective units in the node verification apparatus shown in fig. 8. For example, step S601 shown in fig. 6 may be performed by the acquisition unit 801 shown in fig. 8, and step S602 may be performed by the processing unit 802 shown in fig. 8. The respective units in the node verification apparatus shown in fig. 8 may be combined into one or several additional units separately or all, or some (some) of the units may be further split into a plurality of units with smaller functions to form the same, which may achieve the same operation without affecting the achievement of the technical effects of the embodiments of the present application. The above units are divided based on logic functions, and in practical applications, the functions of one unit may be implemented by a plurality of units, or the functions of a plurality of units may be implemented by one unit. In other embodiments of the present application, the node verification device may also include other units, and in practical applications, these functions may also be implemented with assistance from other units, and may be implemented by cooperation of multiple units.
According to another embodiment of the present application, a node authentication apparatus as shown in fig. 8 may be constructed by running a computer program (including program code) capable of executing the steps involved in the respective methods as shown in fig. 6 on a general-purpose computing apparatus such as a computer including a processing element such as a Central Processing Unit (CPU), a random access storage medium (RAM), a read only storage medium (ROM), and the like, and a storage element, and implementing the node authentication method of the embodiment of the present application. The computer program may be recorded on, for example, a computer-readable recording medium, and loaded into and run in the above-described computing device through the computer-readable recording medium.
Based on the same inventive concept, the principle and beneficial effects of the node verification device provided in the embodiment of the present application for solving the problem are similar to those of the node verification method in the embodiment of the present application, and may refer to the principle and beneficial effects of implementation of the method, which are not described herein for brevity.
Referring to fig. 9, fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application, and as shown in fig. 9, the computer device at least includes a processor 901, a communication interface 902 and a memory 903. Wherein the processor 901, the communication interface 902, and the memory 903 may be connected by a bus or other means. The processor 901 (or called central processing unit (Central Processing Unit, CPU)) is a computing core and a control core of the terminal, which can parse various instructions in the terminal and process various data of the terminal, for example: the CPU can be used for analyzing a startup and shutdown instruction sent by a user to the terminal and controlling the terminal to perform startup and shutdown operation; and the following steps: the CPU can transmit various kinds of interactive data between the internal structures of the terminal, and so on. Communication interface 902 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI, mobile communication interface, etc.), and may be controlled by processor 901 to receive and transmit data; the communication interface 902 may also be used for transmission and interaction of data inside the terminal. The Memory 903 (Memory) is a Memory device in the terminal for storing programs and data. It will be appreciated that the memory 903 here may include both the internal memory of the terminal and the expansion memory supported by the terminal. The memory 903 provides storage space that stores the operating system of the terminal, which may include, but is not limited to: android systems, iOS systems, windows Phone systems, etc., the application is not limited in this regard.
The embodiment of the application also provides a computer readable storage medium (Memory), which is a Memory device in the terminal and is used for storing programs and data. It will be appreciated that the computer readable storage medium herein may include both a built-in storage medium in the terminal and an extended storage medium supported by the terminal. The computer readable storage medium provides a storage space that stores a processing system of the terminal. Also stored in this memory space are one or more instructions, which may be one or more computer programs (including program code), adapted to be loaded and executed by the processor 901. Note that the computer readable storage medium can be either a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one magnetic disk memory; alternatively, it may be at least one computer-readable storage medium located remotely from the aforementioned processor.
In one embodiment, the computer device may specifically be the requesting node 101 shown in FIG. 1 d. The processor 901 performs the following operations by executing executable program code in the memory 903:
Acquiring the target block height of a block to be synchronized;
obtaining M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and the N block information corresponds to different serial numbers respectively;
k pieces of block information with different sequence numbers are selected from M pieces of candidate blocks and converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; k. m, N are positive integers, and k is less than or equal to M and less than or equal to N;
restoring the block information in the block information group;
and if the block recovery is successful, synchronizing the recovered block.
As an alternative embodiment, processor 901, by executing executable program code in memory 903, also performs the following operations:
if the block recovery fails, determining the block information group as a first block information group;
acquiring a second block information set;
determining malicious nodes in the blockchain nodes according to the difference between the first block information group and the second block information group;
the first block information group and the second block information group comprise block information with the same serial number, and the blocks can be successfully recovered based on the block information in the second block information group.
As an alternative embodiment, the first block information group and the second block information group include k-1 block information with the same serial number; the processor 901 determines, according to the difference between the first set of block information and the second set of block information, that a malicious node in the blockchain node is:
if the block information with the sequence number i in the first block information group is not matched with the block information with the sequence number i in the second block information group, determining a block chain link point associated with the block information with the sequence number i in the first block information group as a malicious node;
wherein, the block information with the sequence number i is any one of k-1 block information with the same sequence number;
if the first block information group is matched with the k-1 block information with the same serial number in the second block information group, determining a block chain link point associated with the block information with the serial number j in the first block information group as a malicious node;
wherein the block information with the sequence number j is the block information except the k-1 block information with the same sequence number.
As an alternative embodiment, the first block information group and the second block information group include a block information with the same serial number; the processor 901 determines, according to the difference between the first set of block information and the second set of block information, that a malicious node in the blockchain node is:
If the block information with the same serial number contained in the first block information group and the second block information group is not matched, determining a block link point associated with the block information as a malicious node;
if the block information with the same serial number included in the first block information group and the second block information group are matched, a third block information group is obtained, and malicious nodes in the block chain nodes are determined according to 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 comprise block information with the same serial number, and the blocks can be successfully recovered based on the block information in the third block information group.
As an alternative embodiment, the specific embodiment of the processor 901 obtaining the second block information group is:
acquiring a second block information group from the check set;
the check set includes at least one group of block information groups, and the block information in each group of block information groups can successfully recover the block.
As an alternative embodiment, the block link points belong to a set of trusted nodes; the processor 901, by executing executable program code in the memory 903, also performs the following operations:
Malicious nodes are removed from the set of trusted nodes.
As an alternative embodiment, the block to be synchronized includes a block header and a block body; the block is composed of N pieces of block information including m pieces of main information and N-m pieces of spare information, m being a positive integer.
As an alternative embodiment, the specific embodiment of the recovery processing of the block information in the block information group by the processor 901 is:
performing operation processing on k pieces of block information in the block information group to obtain N-k pieces of recovery information;
block recovery is performed based on the k pieces of block information and the N-k pieces of recovery information.
As an alternative embodiment, the specific embodiment of the processor 901 obtaining the target block height of the block to be synchronized is:
obtaining the maximum height in the synchronized blocks;
and if the block chain node stores the blocks to be synchronized with the height larger than the maximum height, determining the height of the blocks to be synchronized as the target block height.
In another embodiment, the computer device may specifically be the requesting node 101 shown in fig. 1 d. The processor 1001 performs the following operations by executing executable program code in the memory 1003:
acquiring a first block information group and a second block information group, wherein the first block information group and the second block information group both comprise k block information belonging to a target block, and the first block information group and the second block information group comprise block information with the same serial number; the target block cannot be recovered based on the block information in the first block information group, and the target block can be recovered based on the block information in the second block information group;
And determining malicious nodes in the block chain nodes according to the difference between the block information with the same serial numbers in the first block information group and the second block information group.
As an alternative embodiment, the first block information group and the second block information group include k-1 block information with the same serial number; the processor 1001 determines, according to the difference between the block information with the same sequence number in the first block information set and the second block information set, that a malicious node in the blockchain node is:
if the block information with the sequence number i in the first block information group is not matched with the block information with the sequence number i in the second block information group, determining a block chain link point associated with the block information with the sequence number i in the first block information group as a malicious node;
wherein, the block information with the sequence number i is any one of k-1 block information with the same sequence number;
if the first block information group is matched with the k-1 block information with the same serial number in the second block information group, determining a block chain link point associated with the block information with the serial number j in the first block information group as a malicious node;
wherein the block information with the sequence number j is the block information except the k-1 block information with the same sequence number.
As an alternative embodiment, the first block information group and the second block information group include a block information with the same serial number; the processor 1001 determines, according to the difference between the block information with the same sequence number in the first block information set and the second block information set, that a malicious node in the blockchain node is:
if the block information with the same serial number contained in the first block information group and the second block information group is not matched, determining a block link point associated with the block information as a malicious node;
if the block information with the same serial number included in the first block information group and the second block information group are matched, a third block information group is obtained, and malicious nodes in the block chain nodes are determined according to 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 comprise block information with the same serial number, and the target block can be successfully recovered based on the block information in the third block information group.
Based on the same inventive concept, the principle and beneficial effects of the computer device provided in the embodiments of the present application are similar to those of the block synchronization method in the embodiments of the present application, and may refer to the principle and beneficial effects of implementation of the method, which are not described herein for brevity.
The embodiment of the application also provides a computer readable storage medium, wherein one or more instructions are stored in the computer readable storage medium, and the one or more instructions are suitable for being loaded by a processor and executing the block synchronization method of the method embodiment.
The embodiment of the application also provides a computer program product containing instructions, which when run on a computer, cause the computer to execute the block synchronization method of the above method embodiment.
Embodiments of the present application also provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device performs the block synchronization method described above.
The steps in the method of the embodiment of the application can be sequentially adjusted, combined and deleted according to actual needs.
The modules in the device of the embodiment of the application can be combined, divided and deleted according to actual needs.
Those of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be implemented by a program to instruct related hardware, the program may be stored in a computer readable storage medium, and the readable storage medium may include: flash disk, read-Only Memory (ROM), random-access Memory (Random Access Memory, RAM), magnetic or optical disk, and the like.
The above disclosure is illustrative of a preferred embodiment of the present application, and it is not to be construed as limiting the scope of the application, but rather as providing for the full or partial flow of the solution to the above-described embodiment, and equivalent variations according to the appended claims, will be apparent to those skilled in the art.
Claims (17)
1. A method of block synchronization, the method comprising:
acquiring the target block height of a block to be synchronized;
obtaining M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and the N block information respectively corresponds to different serial numbers;
k pieces of block information with different sequence numbers are selected from the M pieces of candidate blocks and are converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; k. m, N are positive integers, and k is less than or equal to M and less than or equal to N;
restoring the block information in the block information group;
and if the block recovery is successful, synchronizing the recovered block.
2. The method of claim 1, wherein the method further comprises:
If the block recovery fails, determining the block information group as a first block information group;
acquiring a second block information set;
determining malicious nodes in the blockchain nodes according to the difference between the first block information group and the second block information group;
the first block information group and the second block information group comprise block information with the same serial number, and blocks can be successfully recovered based on the block information in the second block information group.
3. The method of claim 2, wherein the first set of block information and the second set of block information include k-1 pieces of block information having the same sequence number; the determining a malicious node in the blockchain node according to the difference between the first blockinformation group and the second blockinformation group includes:
if the block information with the sequence number i in the first block information group is not matched with the block information with the sequence number i in the second block information group, determining a block chain link point associated with the block information with the sequence number i in the first block information group as a malicious node;
wherein, the block information with the sequence number i is any one of the k-1 block information with the same sequence number;
If the first block information group is matched with the k-1 block information with the same serial number in the second block information group, determining a block chain link point associated with the block information with the serial number j in the first block information group as a malicious node;
wherein the block information with the sequence number j is the block information except the k-1 block information with the same sequence number.
4. The method of claim 2, wherein the first set of block information and the second set of block information include a block information having a same sequence number; the determining a malicious node in the blockchain node according to the difference between the first blockinformation group and the second blockinformation group includes:
if the block information with the same serial number included in the first block information group and the second block information group is not matched, determining a block link point associated with the block information as a malicious node;
if the block information with the same serial number included in the first block information group and the second block information group are matched, a third block information group is obtained, and malicious nodes in the block chain nodes are determined according to 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 comprise block information with the same serial number, and blocks can be successfully recovered based on the block information in the third block information group.
5. The method of claim 2, wherein the acquiring the second set of block information comprises:
acquiring a second block information group from the check set;
the check set comprises at least one group of block information groups, and the block information in each group of block information groups can be successfully recovered.
6. The method of claim 2, wherein the block link points belong to a set of trusted nodes; the method further comprises the steps of:
the malicious node is removed from the set of trusted nodes.
7. The method of claim 1, wherein the block to be synchronized includes a block header and a block body; the block body is composed of the N pieces of block information, the N pieces of block information comprise m pieces of main body information and N-m pieces of standby information, and m is a positive integer.
8. The method of claim 7, wherein the recovering the block information in the block information group comprises:
Performing operation processing on k pieces of block information in the block information group to obtain N-k pieces of recovery information;
and performing block recovery based on the k pieces of block information and the N-k pieces of recovery information.
9. The method of claim 1, wherein the obtaining the target block height of the block to be synchronized comprises:
obtaining the maximum height in the synchronized blocks;
and if the block chain node stores the blocks to be synchronized with the height larger than the maximum height, determining the height of the blocks to be synchronized as the target block height.
10. A method of node authentication, the method comprising:
acquiring a first block information group and a second block information group, wherein the first block information group and the second block information group both comprise k block information belonging to a target block, and the first block information group and the second block information group comprise block information with the same serial number; the target block cannot be recovered based on the block information in the first block information group, and the target block can be recovered based on the block information in the second block information group;
and determining malicious nodes in the block chain nodes according to the difference between the block information with the same serial numbers in the first block information group and the second block information group.
11. The method of claim 10, wherein the first set of block information and the second set of block information include k-1 pieces of block information having the same sequence number; the determining a malicious node in the blockchain node according to the difference between the blockinformation with the same serial numbers in the first blockinformation group and the second blockinformation group comprises:
if the block information with the sequence number i in the first block information group is not matched with the block information with the sequence number i in the second block information group, determining a block chain link point associated with the block information with the sequence number i in the first block information group as a malicious node;
wherein, the block information with the sequence number i is any one of the k-1 block information with the same sequence number;
if the first block information group is matched with the k-1 block information with the same serial number in the second block information group, determining a block chain link point associated with the block information with the serial number j in the first block information group as a malicious node;
wherein the block information with the sequence number j is the block information except the k-1 block information with the same sequence number.
12. The method of claim 10, wherein the first set of block information and the second set of block information include a block information having a same sequence number; the determining a malicious node in the blockchain node according to the difference between the blockinformation with the same serial numbers in the first blockinformation group and the second blockinformation group comprises:
If the block information with the same serial number included in the first block information group and the second block information group is not matched, determining a block link point associated with the block information as a malicious node;
if the block information with the same serial number included in the first block information group and the second block information group are matched, a third block information group is obtained, and malicious nodes in the block chain nodes are determined according to the difference between the first block information group and the third block information group;
the first block information set and the third block information set include block information with the same serial number, and the target block can be successfully recovered based on the block information in the third block information set.
13. A block synchronization device, the block synchronization device comprising:
the acquisition unit is used for acquiring the target block height of the block to be synchronized;
the processing unit is used for acquiring M candidate blocks with the block height being the target block height from different block chain nodes, wherein each candidate block comprises N block information, and the N block information respectively corresponds to different serial numbers;
k pieces of block information with different sequence numbers are selected from the M pieces of candidate blocks and are converged into a block information group, wherein the k pieces of block information in the block information group are respectively from the k pieces of candidate blocks; k. m, N are positive integers, and k is less than or equal to M and less than or equal to N;
And the block information recovery unit is used for recovering the block information in the block information group; and if the block recovery is successful, synchronizing the recovered block.
14. A node authentication apparatus, characterized in that the node authentication apparatus comprises:
an obtaining unit, configured to obtain a first block information group and a second block information group, where the first block information group and the second block information group each include k pieces of block information belonging to a 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, and the target block can be recovered based on the block information in the second block information group;
and the processing unit is used for determining malicious nodes in the blockchain nodes according to the difference between the first block information group and the second block information group.
15. A computer device, comprising: a memory device and a processor;
a memory in which a computer program is stored;
a processor for loading the computer program to implement the block synchronization method of any one of claims 1-9; or for loading said computer program for implementing a node verification method according to any one of claims 10-12.
16. 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 to perform the block synchronization method according to any of claims 1-9; or load and execute the node verification method of any one of claims 10-12.
17. A computer program product, characterized in that the computer program product comprises a computer program adapted to be loaded by a processor and to perform the block synchronization method according to any of claims 1-9; or load and execute the node verification method of any one of claims 10-12.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210565934.4A CN117155954A (en) | 2022-05-23 | 2022-05-23 | Block synchronization method, device, equipment, storage medium and product |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210565934.4A CN117155954A (en) | 2022-05-23 | 2022-05-23 | Block synchronization method, device, equipment, storage medium and product |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117155954A true CN117155954A (en) | 2023-12-01 |
Family
ID=88899403
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210565934.4A Pending CN117155954A (en) | 2022-05-23 | 2022-05-23 | Block synchronization method, device, equipment, storage medium and product |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117155954A (en) |
-
2022
- 2022-05-23 CN CN202210565934.4A patent/CN117155954A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110912707B (en) | Block chain-based digital certificate processing method, device, equipment and storage medium | |
US11675677B2 (en) | Byzantine agreement using communications having linear complexity | |
CN107819828B (en) | Data transmission method and device, computer equipment and storage medium | |
CN110990408B (en) | Business information collaboration method based on block chain, business system and alliance chain | |
CN107396360B (en) | Block verification method and device | |
CN110175840B (en) | Method, client, alliance chain and system for realizing light wallet mechanism in alliance chain | |
CN109189751B (en) | Data synchronization method based on block chain and terminal equipment | |
CN113395363B (en) | Data processing method, device and equipment based on block chain and storage medium | |
US20230037932A1 (en) | Data processing method and apparatus based on blockchain network, and computer device | |
CN110690974B (en) | Block chain based data verification method, device, equipment and readable storage medium | |
CN111698315B (en) | Data processing method and device for block and computer equipment | |
CN109408521A (en) | A kind of method and device thereof for more new block chain global data state | |
CN110730081B (en) | Block chain network-based certificate revocation method, related equipment and medium | |
CN113157450B (en) | Method and apparatus for executing blocks in a blockchain system | |
CN112182113B (en) | Block chain consensus method, system, electronic equipment and storage medium | |
CN114862397B (en) | Double-decoupling block chain distributed method based on double-chain structure | |
CN114584326B (en) | Block chain data processing method and device, electronic equipment and storage medium | |
CN117155954A (en) | Block synchronization method, device, equipment, storage medium and product | |
CN108882230B (en) | Call record management method, device and system | |
CN112559546B (en) | Database synchronization method, database synchronization device, computer equipment and readable storage medium | |
CN113760519B (en) | Distributed transaction processing method, device, system and electronic equipment | |
CN117010889A (en) | Data processing method, device, equipment, medium and product | |
CN111339189A (en) | Data processing method and device and computer readable storage medium | |
CN117056131B (en) | Data processing method based on block chain network and related equipment | |
CN115375304A (en) | Data processing method, device, equipment and medium based on block chain |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |