CN111444206B - Synchronous processing method, device, equipment and medium - Google Patents

Synchronous processing method, device, equipment and medium Download PDF

Info

Publication number
CN111444206B
CN111444206B CN202010212986.4A CN202010212986A CN111444206B CN 111444206 B CN111444206 B CN 111444206B CN 202010212986 A CN202010212986 A CN 202010212986A CN 111444206 B CN111444206 B CN 111444206B
Authority
CN
China
Prior art keywords
blocks
block
node device
node
hash value
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.)
Active
Application number
CN202010212986.4A
Other languages
Chinese (zh)
Other versions
CN111444206A (en
Inventor
李茂材
王宗友
张劲松
周开班
时一防
黄焕坤
刘区城
刘攀
蓝虎
杨常青
朱耿良
孔利
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010212986.4A priority Critical patent/CN111444206B/en
Publication of CN111444206A publication Critical patent/CN111444206A/en
Application granted granted Critical
Publication of CN111444206B publication Critical patent/CN111444206B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Abstract

The embodiment of the application provides a synchronous processing method, a device, equipment and a medium, wherein the method is executed by first node equipment in a block chain network, the block chain network further comprises second node equipment, and the first node equipment is connected with the second node equipment, and the method comprises the following steps: acquiring a target skeleton, wherein the target skeleton comprises N data units, the N data units are used for storing N blocks to be synchronized of first node equipment, the N blocks correspond to the N data units one by one, and N is a positive integer; acquiring calibration data corresponding to a target skeleton; when N blocks synchronized by the second node equipment are received, verifying the N blocks by adopting the verification data; and if the verification is successful, filling the N blocks into the N data units of the target skeleton. The method and the device can effectively improve the efficiency of synchronous processing and the efficiency of verification of the blocks.

Description

Synchronous processing method, device, equipment and medium
Technical Field
The present invention relates to the field of block chain technology, and in particular, to the field of data processing based on block chains, and more particularly, to a synchronization processing method, a synchronization processing apparatus, a synchronization processing device, and a computer storage medium.
Background
In the prior art, when a certain node device in a blockchain network performs synchronization processing of a blockchain, required blocks are acquired one by one from other node devices (such as common node devices or synchronous node devices) in the blockchain network, and then the acquired blocks are checked one by one, which is too cumbersome and inefficient in synchronization.
Disclosure of Invention
Embodiments of the present application provide a synchronization processing method, apparatus, device, and medium, which can effectively improve synchronization processing efficiency and block verification efficiency.
In one aspect, an embodiment of the present application provides a synchronization processing method, where the method is performed by a first node device in a blockchain network, the blockchain network further includes a second node device, and the first node device is connected to the second node device, and the method includes:
acquiring a target skeleton, wherein the target skeleton comprises N data units, the N data units are used for storing N blocks to be synchronized of first node equipment, the N blocks correspond to the N data units one by one, and N is a positive integer;
acquiring calibration data corresponding to a target skeleton;
when N blocks synchronized by the second node equipment are received, verifying the N blocks by adopting the verification data;
and if the verification is successful, filling the N blocks into the N data units of the target skeleton.
In one aspect, an embodiment of the present application provides a synchronization processing apparatus, where the synchronization processing apparatus is disposed in a first node device in a blockchain network, the blockchain network further includes a second node device, the first node device is connected to the second node device, and the synchronization processing apparatus includes:
the device comprises an acquisition unit, a synchronization unit and a synchronization unit, wherein the acquisition unit is used for acquiring a target skeleton, the target skeleton comprises N data units, the N data units are used for storing N blocks to be synchronized of first node equipment, the N blocks correspond to the N data units one by one, and N is a positive integer; the system comprises a target framework, a data acquisition module, a data processing module and a data processing module, wherein the data acquisition module is used for acquiring calibration data corresponding to the target framework;
the processing unit is used for verifying the N blocks by adopting the check data when the N synchronous blocks of the second node equipment are received; and if the verification is successful, filling the N blocks into the N data units of the target skeleton.
In an embodiment, the obtaining unit is specifically configured to:
determining a reference block corresponding to a first block of the N blocks on a reference block chain in a block chain network, and determining a key block corresponding to a last block of the N blocks on the reference block chain;
acquiring a hash value of a reference block and a hash value of a key block;
sending a query request to the second node device, wherein the query request comprises the hash value of the reference block and the hash value of the key block; the query request is used for requesting the second node equipment to query whether the second node equipment stores N blocks or not according to the hash value of the reference block and the hash value of the key block;
and if a successful query response of the second node equipment is received, sending a target synchronization task to the second node equipment, wherein the target synchronization task is used for indicating the second node equipment to return the N blocks.
In one embodiment, the check data is a hash value of the reference chunk; the processing unit is specifically configured to:
obtaining a hash value to be checked of a first block in N blocks synchronized by second node equipment;
if the hash value to be checked is the same as the hash value of the reference block, detecting whether the N blocks are continuous or not according to the hash value of the reference block;
if the verification is continuous, the verification of the N blocks is confirmed to be successful.
In one embodiment, the check data is a hash value of a parent block of the reference block; the processing unit is specifically configured to:
obtaining a hash value to be checked of a first block in N blocks synchronized by second node equipment;
verifying whether the first block and the parent block of the reference block have a parent-child relationship or not according to the hash value to be verified and the hash value of the parent block of the reference block;
if the hash value has a parent-child relationship, detecting whether the N blocks are continuous or not according to the hash value to be verified;
if the verification is continuous, the verification of the N blocks is confirmed to be successful.
In an embodiment, the obtaining unit is specifically configured to:
acquiring the block height of a reference block chain in a block chain network, and acquiring the block height of a first block chain locally stored by first node equipment;
determining N blocks between the block height of the reference block chain and the block height of the first block chain as blocks to be synchronized by the first node device;
and constructing a target skeleton according to the N blocks.
In one embodiment, the blockchain network includes a candidate node set, the candidate node set includes a plurality of candidate node devices connected to the first node device, and the second node device is any one of the candidate node devices selected from the candidate node set; the processing unit is further configured to:
and if the verification fails, selecting one alternative node device from the alternative node set again to determine the alternative node device as the second node device.
In one embodiment, the obtaining unit is further configured to:
if the verification of the blocks returned by all the alternative node devices in the alternative node set fails, acquiring the verification data corresponding to the target skeleton again; or to retrieve a new target skeleton.
In one embodiment, the processing unit is further configured to:
and reading N blocks stored in sequence by N data units from the target skeleton, and adding the read N blocks to a first block chain locally stored by the first node device.
In one aspect, an embodiment of the present application provides a synchronous processing device, where the synchronous processing device is a first node device in a blockchain network, the blockchain network further includes a second node device, the first node device is connected to the second node device, the synchronous processing device includes an input device and an output device, and further includes:
a processor adapted to implement one or more instructions; and the number of the first and second groups,
a computer storage medium having stored thereon one or more instructions adapted to be loaded by a processor and to execute the above-described synchronization processing method.
In one aspect, embodiments of the present application provide a computer storage medium, where one or more instructions are stored, and the one or more instructions are adapted to be loaded by a processor and execute the above-mentioned synchronization processing method.
In the embodiment of the application, when the first node device performs synchronization processing, the target skeleton and the check data corresponding to the target skeleton are obtained, when N blocks required by the target skeleton synchronized by the second node device are received, the first node device verifies the N blocks by using the check data corresponding to the target skeleton, and after the verification is successful, the N blocks are filled into the target skeleton, so that the synchronization of the N blocks is completed. By the synchronous processing mode of framework filling, a plurality of blocks can be synchronized at one time based on one synchronous task corresponding to one framework, and the synchronous processing efficiency is effectively improved; and moreover, for the synchronously obtained blocks, the check data corresponding to the framework is adopted for quick check, so that the check efficiency is improved, and the efficiency of synchronous processing is further improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 illustrates a basic architecture diagram of a blockchain provided by an exemplary embodiment of the present application;
FIG. 2 illustrates a block chain structure provided by an exemplary embodiment of the present application;
fig. 3 is a block chain network architecture diagram according to an exemplary embodiment of the present application;
FIG. 4 illustrates a structural schematic of a skeletal framework provided by an exemplary embodiment of the present application;
FIG. 5 is a flow chart illustrating a method of synchronization processing provided by an exemplary embodiment of the present application;
FIG. 6 is a flow chart illustrating a method of synchronization processing provided by another exemplary embodiment of the present application;
fig. 7 is a schematic structural diagram illustrating a synchronous processing device according to an exemplary embodiment of the present application;
fig. 8 is a schematic structural diagram illustrating a synchronous processing device according to an exemplary embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Embodiments of the present application relate to blockchain techniques. The block chain is a set of decentralized infrastructure with distributed storage characteristics, and particularly is a data structure formed by data blocks in a linked list-like manner according to a time sequence, so that data which are in a sequential relationship and can be verified in a system can be safely stored, and the data cannot be tampered and counterfeited in a cryptographic manner.
FIG. 1 illustrates a basic architecture diagram of a blockchain provided by an exemplary embodiment of the present application; as shown in fig. 1, the block chain infrastructure mainly includes 5 hierarchies of 101-105 in bottom-to-top order.
Wherein:
(1) the informational data and Merkle (Merkle) tree are located at the bottom level 101. The information data here refers to original data that is requested to be issued to the blockchain network but has not yet formed blocks, and may be, for example, business data, transaction data, and the like. These raw data need further processing (e.g., authentication of each node in the blockchain network, hashing, etc.) to be written into the blocks. The Merkle tree is an important component of the blockchain technology, the blockchain does not directly store the plaintext original data, and the original data needs to be hashed and stored in the form of a hash value. The merkel tree is used for organizing hash values formed by hashing a plurality of original data according to a binary tree structure and storing the hash values in a block of blocks.
(2) The blocks are located at level 102. Blocks, i.e. data blocks, into which the information data of the bottom layer 101 is written after further processing. The blocks are connected in sequence to form a chain structure, namely, a block chain is formed, and in the chain structure, a previous block and an adjacent next block have a parent-child relationship. FIG. 2 illustrates a block chain structure provided by an exemplary embodiment of the present application; as shown in FIG. 2, blocks i-1(i is a positive integer), block i and block i +1 are connected in sequence in a chain structure. The block i is divided into a block header and a block body, wherein the block header includes the digest value of the previous block i-1 and the digest value of the current block i (i.e., the merkel root of the current block). The block body contains the complete data of the block i and is organized together in the form of a Merkle tree. Block i-1 has a parent-child relationship with block i, i.e., block i-1 is the parent block of block i, and block i is the child block of block i-1. Similarly, block i is a parent block of block i +1, and block i +1 is a child block of block i.
(3) The protocols and mechanisms followed by the blockchain are located at level 103. These protocols may include: P2P (Peer-to-Peer) protocol; mechanisms may include, but are not limited to: broadcast mechanism, consensus mechanism (including core mechanisms such as PoW (Proof Of Work) mechanism, POS (Proof Of rights) mechanism, etc.).
(4) The blockchain network is located at level 104. The block chain network consists of a plurality of node devices; node devices may include, but are not limited to: a PC (Personal Computer), a server, an ore machine for bitcoin excavation design, a smart phone, a tablet Computer, a mobile Computer, and the like. Each node device in the block chain network is networked in a P2P mode, and the node devices are communicated with each other according to a P2P protocol; all the node devices jointly follow a broadcasting mechanism and a consensus mechanism (including core mechanisms such as a PoW mechanism and a POS mechanism), so that the data on the block chain can be ensured to be not tampered and forged, and meanwhile, the characteristics of decentralized and trust-removed block chains are realized.
(5) The smart contracts are located at upper layer 105. An intelligent contract is a set of scenarios-a countermeasure-type of programmed rules and logic, which is decentralized, information-shareable program code deployed on a blockchain. Each party signing the contract agrees on the contract content, and the contract is deployed in the block chain in the form of an intelligent contract, so that the contract can be automatically executed on behalf of each signing party without any central authority.
Types of blockchains may include: public chain (Public Blockchain), Private chain (Private Blockchain), and federation chain (Consortium Blockchain). The public chain is disclosed externally, and anyone can join and access the block chain; the block on the public chain can be viewed by anyone, and the person can also initiate transaction on the public chain and participate in the consensus process of the public chain at any time. The private chain is only used in the private organization, and the read-write authority and the accounting participation authority on the block chain are formulated according to the private organization rule; typically for data management, auditing, etc. within an enterprise. The alliance chain is limited to the participation of alliance members, and the read-write authority and the participation accounting authority on the block chain are formulated according to the alliance rule; generally used in the scenes of trading, settlement or clearing among institutions. The basic architecture of the blockchain shown in fig. 1 is a development basis of various types of blockchains, and it can be understood that there are some differences in the networking manner of the blockchain network corresponding to different types of blockchains. Due to the characteristics of decentralized, distributed storage, data non-falsification and non-falsification, more and more business activities (such as loan activities and financial transaction activities) are spread based on the blockchain technology, so as to ensure the fairness and the openness of the business activities by using the characteristics of the blockchain.
Fig. 3 is a block chain network architecture diagram according to an exemplary embodiment of the present application; the blockchain network comprises a plurality of node devices (7 node devices are taken as an example in the figure for illustration); as shown in fig. 4, the node apparatus 1 and the node apparatus 2 are common node apparatuses, and the node apparatuses 3 to 7 are all synchronous node apparatuses. The consensus node device is a node device which can not only execute the block synchronization process, but also participate in the block consensus process; the synchronization node device is a node device that can only perform the block synchronization process and cannot participate in the block consensus process.
The block chain is a distributed application mode, and each node device in the block chain network stores one block chain; specifically, the method comprises the following steps: in the blockchain network shown in fig. 3, the node device 1 stores the blockchain 1 in the storage space of the node device 1, the node device 2 stores the blockchain 2 in the storage space of the node device 2, the node device 3 stores the blockchain 3 in the storage space of the node device 3, and so on. Due to differences in network connection performance, processing performance, time difference of joining the blockchain network, and the like, differences occur between blockchains stored by node devices in the blockchain network, and each node device in the blockchain network needs to maintain consistency between blockchains stored by each node device through means of synchronization and the like. For example: n (n is a positive integer) node devices already exist in the blockchain network, a certain node device n +1 is newly added into the blockchain network, for the node device n +1, no block is stored in the storage space, the block height of the blockchain n +1 of the node device n +1 is 0, and for the node device n already existing in the blockchain network, 10001 blocks may have been stored, the block height of the blockchain n stored in the storage space of the node device n may be 10000, then the node device n +1 lags behind the node device n, and the node device n +1 needs to perform a block synchronization process to acquire all the blocks between the block height 0 and the block height 10000 to update the blockchain n +1 thereof to catch up with the node device n. In practical application, a new block generated in a block chain network needs to be identified by a common node device, after successful identification, the common node device adds the new block to a block chain locally stored by the common node device, and a synchronization node device in the block chain network acquires the new block from the common node device and adds the new block to the block chain locally stored by the synchronization node device, thereby completing a block synchronization process. Based on this, it is generally accepted that the blockchain stored in the common node device is the longest (or most complete) blockchain in the blockchain network, and the blockchain stored in the common node device can be used as a reference blockchain in the synchronization process.
Based on the architecture of the block chain network shown in fig. 3, an embodiment of the present application proposes a synchronization processing scheme, which introduces a concept of a Framework (Framework). FIG. 4 illustrates a structural schematic of a skeletal framework provided by an exemplary embodiment of the present application; a skeleton is a data structure. A skeleton contains a plurality of data units 401, each for storing a block. Referring to the example shown in fig. 4, if any node device in the blockchain network (assumed to be the node device 3 shown in fig. 3) needs 100 blocks of sync blocks 1 to 100, the synchronization processing flow of the node device 3 may include the following steps (1) to (4):
(1) and constructing a skeleton set according to the blocks to be synchronized, wherein the skeleton set comprises one or more skeletons.
As shown in fig. 4, it is assumed that the skeleton set includes 10 skeletons in total, each skeleton includes 10 data units 401, and the data units 401 are reserved to store the synchronization blocks after the node device 3 acquires the synchronization blocks; taking the framework 1 as an example: the skeleton 1 includes 10 data units 401, which are arranged in sequence, the first data unit for storing block 1, the second data unit for storing block 2, and so on. In the skeleton set, the number of data units included in each skeleton may be the same, and each skeleton may include 10 data units as shown in fig. 4; of course, the number of data units included in each of the skeletons may also be different, for example, in fig. 4, skeleton 1 may include 10 data units, skeleton 2 may include 5 data units, skeleton 3 may include 15 data units, and so on. The node device 3 may set the number of skeletons and the number of data units included in the skeletons according to practical situations, which may include but are not limited to: the number and processing power of node devices in the alternative node set, the actual concurrent processing power of node device 3, etc.
(2) Creating a synchronous task set for the skeleton set, wherein the synchronous task set comprises one or more synchronous tasks; one skeleton corresponds to one synchronization task.
As shown in fig. 4, the skeleton 1 corresponds to the synchronous task 1, the skeleton 2 corresponds to the synchronous task 2, the skeleton 3 corresponds to the synchronous task 3, and so on. The synchronization task corresponding to each skeleton is used to indicate a plurality of blocks returned to the skeleton for storage, for example: the synchronous task 1 corresponding to the skeleton 1 is used for indicating to return blocks 1-10 used for storage of the skeleton 1 to the node equipment 3; the following steps are repeated: the synchronization task 2 corresponding to the skeleton 2 is used to instruct the node apparatus 3 to return the blocks 11-20 of the skeleton 2 for storage. It is understood that the synchronization task carries indication information, where the indication information may include an index of a chunk corresponding to the first and last two data units in the skeleton, where the index may be a hash value of the chunk, or a generation timestamp of the chunk, or a chunk height corresponding to the chunk. Thus, after receiving the synchronization task, the other node device returns the two blocks and all blocks between the two blocks in the skeleton to the node device 3 according to the indexes of the two blocks in the indication information. The indication information may also include indexes of all blocks used by the skeleton for storage, so that after receiving the synchronization task, other node devices return all required blocks to the node device 3 according to the indexes of all required blocks.
(3) An alternate node device to perform the synchronization task is selected.
First, a candidate node set is determined, and candidate node devices directly connected to the node device 3 are included in the candidate node set. As shown in fig. 3, the node device 3 includes node device 1, node device 4, and node device 7 in the node device candidate set. Since the node device 1 is a consensus node device and needs to execute a consensus task, in order to avoid processing load on the node device 1 and to improve synchronization efficiency, the node devices 4 to 7 may be selected from the candidate node set as candidate node devices for executing a synchronization task. Secondly, matching corresponding alternative node equipment for each synchronization task, wherein the matching mainly comprises the following strategies:
strategy one: and matching according to the storage condition. Matching the synchronization task to the alternative node equipment in which the corresponding block is stored; for example: the synchronous task 1 requires synchronous blocks 1-10, then the alternative node equipment storing the blocks 1-10 is selected to execute the synchronous task 1; the following steps are repeated: synchronization task 2 requires synchronization blocks 81-90, then the alternate node device storing blocks 81-90 is selected to perform synchronization task 2.
And (2) strategy two: matching according to processing performance. An alternate node device may be selected from the set of alternate nodes to perform a synchronization task in accordance with processing performance. For example: the processing performance of the node apparatus 4 is better than that of the node apparatus 5, and the node apparatus 4 can be selected to execute the synchronization task 1. Processing performance includes, but is not limited to, CPU processing speed, concurrent throughput, network bandwidth resources, and the like. The higher the processing performance, the higher the execution degree, and the faster the execution of the synchronization task.
Strategy three: and matching according to the confidence degree. The trust level refers to information describing the trustworthiness of the node device, and a higher trust level indicates a higher trustworthiness of the node device, and generally, the trust level of the node device used by an official authority is higher than that of the node device used by an unofficial authority. In one embodiment, confidence may be expressed as a score, for example, a confidence score range comprising [0, 10], with higher confidence values indicating higher trustworthiness. In another embodiment, the confidence level may be represented by a hierarchy, for example, the confidence level includes three levels, i.e., high, medium, and low, whose trustworthiness decreases in turn. An alternate node device may be selected from the set of alternate nodes to perform a synchronization task according to the degree of trust. For example: node device 4 is more trusted than node device 5 and node device 4 may be selected to perform synchronization task 1.
One synchronization task is performed by one node device, and one node device may perform a plurality of synchronization tasks. It is to be understood that the above strategies are not exhaustive, and embodiments of the present application may also be applicable to other strategies, such as: a random matching strategy, namely, one alternative node device can be randomly selected from the alternative node set to execute a certain synchronization task; the following steps are repeated: the weighted average policy may set weights for the plurality of influence factors (the storage condition factor, the confidence factor, and the processing performance factor), and select one candidate node device from the candidate node set according to a weighted average manner to execute the synchronization task. In addition, in the above policy two and policy three, if the candidate node device selected for executing a certain synchronization task does not store the to-be-synchronized block indicated by the synchronization task itself, the candidate node device may obtain the block from other node devices (such as a common node device) in the blockchain network and return the block to the first node device, for example: the synchronization task 1 requires the synchronization of the blocks 1-10, and the node device 4 is selected by the policy two or the policy three to execute the synchronization task 1, but the node device 4 does not store the blocks 1-10, so the node device 4 can obtain the blocks 1-10 from the common node device and return the blocks 1-10 to the first node device.
(4) And a plurality of synchronous tasks are concurrent, and the synchronous tasks are executed by the alternative node devices which select to be synchronous.
Taking the example shown in fig. 4 as an example, it is assumed that the synchronization task 1 and the synchronization task 3 are executed by the node device 4, the synchronization task 2, the synchronization task 4, and the synchronization task 6 are executed by the node device 5, the synchronization task 6, and the synchronization task 9 are executed by the node device 6, and the synchronization task 7, the synchronization task 8, and the synchronization task 10 are executed by the node device 7. Then, node device 3 may concurrently perform these 10 synchronization tasks at a time, and these alternative node devices performing synchronization (i.e. node device 4, node device 5, node device 6, and node device 7) may perform these synchronization tasks internally in serial or parallel manner, and return the blocks required by node device 3 to node device 3, so that node device 3 can obtain the blocks required for synchronization by a one-time synchronization process.
(5) The received block is verified.
After receiving blocks returned by the alternative node device executing the synchronization task, the first node device verifies the blocks, and the purpose of verification is to ensure the accuracy and the safety of the blocks. In a blockchain network, a conventional authentication procedure performed by a first node device for a received block includes: when a certain candidate node device synchronizes a block to a first node device, the candidate node device signs the block by using a private key stored by the candidate node device, and the first node device checks the block by using a public key issued to a block chain network by the candidate node device after receiving the block, which is a process of checking the received block. The verification process for the received block in this embodiment of the present application refers to an irregular verification process, which may be performed after the first node device successfully verifies the received block, and the irregular verification process may be described in detail in the following embodiments.
(6) The blocks that are verified successfully are filled into the data units of the corresponding skeleton.
Through the above (1) to (6), the first node device completes a synchronization process. It should be noted that, the first node device is further provided with an exception handling mechanism, which is used to handle some exception situations, including but not limited to: a case where a certain synchronization task is not matched to a node device that is executed correspondingly, for example, no node device in the alternative node set completely stores a block required by a certain skeleton; then, the skeleton may not be reasonably constructed, so the processing mechanism for the abnormal condition may be to reconstruct the skeleton and update the synchronization task again; of course, the processing mechanism for the abnormal situation may also be compatible with the existing synchronization method, and synchronize the blocks required by the skeleton corresponding to the synchronization task that are not matched to the node device one by one.
The framework filling synchronous processing scheme provided by the embodiment of the application can synchronize a plurality of blocks at one time based on one synchronous task corresponding to one framework, so that the synchronous processing efficiency is effectively improved; furthermore, synchronous tasks corresponding to a plurality of skeletons can be simultaneously sent in one synchronous processing process, so that more blocks can be synchronized at one time based on the skeletons, and the efficiency of synchronous processing is further improved. And moreover, for the synchronously obtained blocks, the check data corresponding to the framework is adopted for quick check, so that the check efficiency is improved, and the efficiency of synchronous processing is further improved.
FIG. 5 is a flow chart illustrating a method of synchronization processing provided by an exemplary embodiment of the present application; the method is executed by a first node device in a blockchain network, where the first node device may be any node device in the blockchain network, and the following embodiments of the present application take the example that the first node device is a node device 3 in the blockchain network shown in fig. 3 as an example. The blockchain network further comprises a second node device, the second node device refers to any node device except the first node device in the blockchain network, and the first node device is connected with the second node device. The method comprises the following steps S501-S504:
s501, a target skeleton is obtained, wherein the target skeleton comprises N data units, the N data units are used for storing N blocks to be synchronized of the first node device, the N blocks correspond to the N data units one by one, and N is a positive integer.
N data units in the target skeleton are arranged in sequence, and N blocks are continuous blocks in a block chain network; the ith data unit in the N data units is used for storing the ith block in the N blocks; i is a positive integer and is more than or equal to 1 and less than or equal to N. The target skeleton may be any one of the foregoing skeleton sets, and referring to the example shown in fig. 4, the target skeleton may be any one of skeletons 1-10, taking the target skeleton as skeleton 1 as an example, where N is 10, a first data unit of the target skeleton is used for storing block 1, a second data unit of the target skeleton is used for storing block 2, and so on.
And S502, acquiring the calibration data corresponding to the target skeleton.
The verification data corresponding to the target skeleton is used for verifying the N blocks to be stored of the target skeleton, and the verification aims to ensure the accuracy and the safety of the N blocks to be stored of the target skeleton.
S503, when receiving the N blocks synchronized by the second node device, verifying the N blocks by using the verification data.
S504, if the verification is successful, filling the N blocks into the N data units of the target skeleton.
In steps S503-S504, the first node device may send a target synchronization task to the second node device according to the N blocks required by the target skeleton, and the second node device executes the target synchronization task and returns the synchronized N blocks to the first node device; the first node device verifies the N blocks by adopting the check data corresponding to the target skeleton. If the verification is successful, which indicates that the N blocks synchronized by the second node device are the correct and untampered blocks, and the N blocks can be trusted, the first node device may fill the N blocks into the N data units of the target skeleton. Conversely, if the verification fails, which indicates that the N blocks synchronized by the second node device have been tampered with and are erroneous and untrusted blocks, the first node device cannot fill the N blocks into the target skeleton, and the first node device may discard the N untrusted blocks and perform synchronization based on the target skeleton again.
The padding process refers to a process of storing the block into the corresponding data unit. Taking the target skeleton as the skeleton 1 shown in fig. 4 as an example, the filling process includes: in blocks 1-10 of the second node device synchronization, block 1 is stored in the first data unit of the target skeleton, block 2 is stored in the second data unit of the target skeleton, and so on.
It can be understood that, in the embodiment of the present application, the sequential arrangement of the data units of the target skeleton is only an example, and the data units of the target skeleton may not be sequential; of course, the N blocks stored in the target skeleton may not be consecutive blocks; alternatively, the data units in the target skeleton may not store N blocks in sequence; in this case, the indication information included in the target synchronization task may include indexes of N blocks.
In the embodiment of the application, when the first node device performs synchronization processing, the target skeleton and the check data corresponding to the target skeleton are obtained, when N blocks required by the target skeleton synchronized by the second node device are received, the first node device verifies the N blocks by using the check data corresponding to the target skeleton, and after the verification is successful, the N blocks are filled into the target skeleton, so that the synchronization of the N blocks is completed. By the synchronous processing mode of framework filling, a plurality of blocks can be synchronized at one time based on one synchronous task corresponding to one framework, and the synchronous processing efficiency is effectively improved; and moreover, for the synchronously obtained blocks, the check data corresponding to the framework is adopted for quick check, so that the check efficiency is improved, and the efficiency of synchronous processing is further improved.
FIG. 6 is a flow chart illustrating a method of synchronization processing provided by another exemplary embodiment of the present application; the method is executed by a first node device in a blockchain network, where the first node device may be any node device in the blockchain network, and the following embodiments of the present application take the example that the first node device is a node device 3 in the blockchain network shown in fig. 3 as an example. The blockchain network further comprises a second node device, the second node device refers to any node device except the first node device in the blockchain network, and the first node device is connected with the second node device. The method comprises the following steps S601-S608:
s601, obtaining a block height of a reference block chain in a block chain network, and obtaining a block height of a first block chain locally stored in a first node device.
The reference blockchain refers to the longest (or most complete) blockchain in the blockchains stored by the respective node devices in the blockchain network, and generally refers to the blockchains stored by the common node devices. The block height is used to indicate the number of blocks connected on the block chain. The block height is an identifier of the block, which can be used to indicate the position of the block in the block chain; the block height of the starting block in the block chain is default to 0, the block height of the first block after the starting block is 1 (the first block is simply referred to as block 1), the block height of the second block after the starting block is 2 (the second block is simply referred to as block 2), and so on. For example, the block height of the current block of the reference block chain is 100 (this current block may be simply referred to as block 100), which means that 100 blocks have been stacked above the starting block, i.e., the number of blocks on the reference block chain formed from the starting block to block 100 is 101.
S602, determining N blocks between the block height of the reference block chain and the block height of the first block chain as the blocks to be synchronized by the first node device.
S603, constructing a target skeleton according to the N blocks.
In steps S602 to S603, assuming that the block height of the reference block chain is 200 and the block height of the first block chain is 100, the 100 blocks that are different from each other include blocks 101 to 200, and the 100 blocks that are different from each other are blocks to be synchronized of the first node device, a target skeleton may be constructed according to N consecutive blocks in the blocks to be synchronized, where the target skeleton may be any one of the skeletons shown in fig. 4, and a data structure of the target skeleton may also be shown in fig. 4, which is not described herein.
And S604, acquiring the calibration data corresponding to the target skeleton.
The verification data corresponding to the target skeleton is used for verifying the N blocks to be stored of the target skeleton, and the verification aims to ensure the accuracy and the safety of the N blocks to be stored of the target skeleton.
S605, determine a reference block corresponding to a first block of the N blocks on a reference block chain in the block chain network, and a key block corresponding to a last block of the N blocks on the reference block chain.
The correspondence between the first block of the N blocks and the reference block is: the block height of the first block in the N blocks on the second block chain stored by the second node device is consistent with the block height of the reference block on the reference block chain; for example: the first block of the N blocks is block 1 on the second chain of blocks stored by the second node device, then the reference block is block 1 on the reference chain of blocks. Similarly, the correspondence between the last block of the N blocks and the key block is: the block height of the last block in the N blocks on the second block chain stored by the second node device is consistent with the block height of the key block on the reference block chain; for example: the last block of the N blocks is block 100 on the second blockchain stored by the second node device, then the key block is block 100 on the reference blockchain; in this example, if the block to be synchronized by the first node device is block 1-block 100 of the reference block chain, it is necessary to detect whether the second node device has the block 1-block 100.
S606, obtain the hash value of the reference block and the hash value of the key block.
S607, sending a query request to the second node device, wherein the query request comprises the hash value of the reference block and the hash value of the key block; the query request is used for requesting the second node device to query whether the second node device stores N blocks according to the hash value of the reference block and the hash value of the key block.
In one embodiment, N blocks are consecutive blocks in the blockchain network, and then in steps S606-S607, the hash value of the reference block and the hash value of the key block may be carried in a query request to the second node device, and the second node device may self-check whether it has stored the reference block to N blocks between the key blocks. According to the above example, if N blocks to be synchronized by the first node device are blocks 1 to 100, the first node device may send an inquiry request to the second node device, where the inquiry request carries the hash value of block 1 and the hash value of block 100, and then the second node device may inquire whether itself stores blocks 1 to 100 according to the inquiry request; if the query is successful, namely the second node device confirms that the second node device completely stores the blocks 1-100, the second node device returns a query success response to the first node device; if the query fails, i.e., the second node device confirms that it does not store or store the blocks 1-100 completely (e.g., only the blocks 1-40 are stored, but the blocks 41-100 are absent), the second node device returns a query failure response to the first node device.
S608, if a successful query response of the second node device is received, sending a target synchronization task to the second node device, where the target synchronization task is used to instruct the second node device to return N blocks.
And S609, when N blocks synchronized by the second node equipment are received, verifying the N blocks by adopting the verification data.
The block to be synchronized by the first node device is a block that is missing by the first node device but exists on the reference block chain, and according to the above example, the block to be synchronized by the first node device is set to be block 1-block 100, and these blocks are synchronized to the first node device by the second node device, then the first node device needs to detect whether these blocks synchronized by the second node device are block 1-block 100 on the reference block chain, and the verification process is to achieve the above detection purpose.
In one embodiment, the check data refers to a hash value of the reference chunk; the verification process of step S609 may include the following steps S11-S13:
s11, obtaining the hash value to be verified of the first block of the N blocks synchronized by the second node device.
s12, if the hash value to be verified is the same as the hash value of the reference block, detecting whether the N blocks are consecutive according to the hash value of the reference block.
s13, if they are consecutive, the verification of the N blocks is confirmed to be successful.
In steps s11-s13, the second node device is checked to determine whether the hash value of the first block of the N blocks synchronized with the reference block is the same as the hash value of the reference block. If the two are the same, it indicates that the first block of the N blocks synchronized by the second node device is the same block as the reference block, and indicates that the first block of the N blocks stored in the second node device is the correct block. And further detecting whether the N blocks returned by the second node device are continuous blocks according to the characteristics of the continuous blocks, namely the sub-blocks store the hash values of the parent blocks, and if the N blocks returned by the second node device are continuous blocks, confirming that the verification of the N blocks returned by the second node device is successful, namely, if the verification is successful, indicating that the N blocks synchronized by the second node device are correct, untampered and trustable blocks. On the contrary, if the hash value to be verified is different from the hash value of the reference chunk, or the N chunks are not consecutive, the verification fails, indicating that the N chunks synchronized by the second node device are untrustworthy.
In another embodiment, the check data is a hash value of a parent block of the reference block; the verification process of step S609 may include the following steps S21-S24:
s21, obtaining the hash value to be verified of the first block of the N blocks synchronized by the second node device.
s22, verifying whether the first block and the parent block of the reference block have a parent-child relationship according to the hash value to be verified and the hash value of the parent block of the reference block.
s23, if there is a parent-child relationship, it is detected whether the N blocks are consecutive according to the hash value to be verified.
s24, if they are consecutive, the verification of the N blocks is confirmed to be successful.
In steps s21-s24, in this embodiment, the hash value of the parent block of the reference block is obtained, and since there is an association between the hash value of the child block in the block chain and the hash value of the parent block, it can be determined whether the first block of the N blocks returned by the second node device has a parent-child relationship with the parent block of the reference block according to whether the association exists between the hash value to be verified and the hash value of the parent block of the reference block, and if the association exists, it indicates that the first block of the N blocks stored in the second node device is a correct block. And further detecting whether the N blocks returned by the second node device are continuous blocks according to the characteristics of the continuous blocks, namely the sub-blocks store the hash values of the parent blocks, and if the N blocks returned by the second node device are continuous blocks, confirming that the verification of the N blocks returned by the second node device is successful, namely, if the verification is successful, indicating that the N blocks synchronized by the second node device are correct, untampered and trustable blocks. On the contrary, if the hash value to be verified is different from the hash value of the reference chunk, or the N chunks are not consecutive, the verification fails, indicating that the N chunks synchronized by the second node device are untrustworthy.
S610, if the verification is successful, filling the N blocks into the N data units of the target skeleton.
S611, reading N blocks stored in sequence by the N data units from the target skeleton, and adding the read N blocks to a first block chain locally stored in the first node device.
The framework is a data structure, after N blocks are stored in the target framework, the N blocks are sequentially read and sequentially added to a first block chain locally stored in the first node device, and therefore the N blocks are successfully updated on the first block chain.
And S612, if the verification fails, selecting one candidate node device from the candidate node set again to determine as a second node device.
S613, if the verification of the blocks returned by all the candidate node devices in the candidate node set fails, acquiring the verification data corresponding to the target skeleton again; or to retrieve a new target skeleton.
Steps S612 to S613 represent an exception handling mechanism in the first node device, where the exception handling mechanism is configured to handle an exception condition; the abnormal condition includes two cases, namely, the case that verification data is adopted to verify the N blocks synchronized by the second node device, but the verification fails. If the exception is caused by the fact that the N blocks stored by the second node device are incorrect, or the second node device is a malicious device, the processing policy for such exception may be: a second node device is reselected, i.e. a node device is replaced to resynchronize the N blocks. Another abnormal situation is: if verification fails for the N blocks returned by all the alternative node devices in the alternative node set, that is, all the alternative node devices in the alternative node set cannot provide the correct N blocks required by the target skeleton; the reason causing the abnormal situation may be that the target skeleton is not reasonably constructed, or the check data obtained from the common node equipment is wrong, so the processing strategy aiming at the abnormal situation may be to reconstruct the target skeleton and renew the synchronization task; or, the check data corresponding to the target skeleton is obtained again, for example, the check data is obtained by replacing a common node device. After the exception handling process (i.e., replacing the second node device, reconstructing the target skeleton, or retrieving the verification data) is completed, steps S601-S613 are executed again.
In the embodiment of the application, when the first node device performs synchronization processing, the target skeleton and the check data corresponding to the target skeleton are obtained, when N blocks required by the target skeleton synchronized by the second node device are received, the first node device verifies the N blocks by using the check data corresponding to the target skeleton, and after the verification is successful, the N blocks are filled into the target skeleton, so that the synchronization of the N blocks is completed. By the synchronous processing mode of framework filling, a plurality of blocks can be synchronized at one time based on one synchronous task corresponding to one framework, and the synchronous processing efficiency is effectively improved; and moreover, for the synchronously obtained blocks, the verification data corresponding to the framework is adopted for quick verification, so that the verification efficiency is improved, and the efficiency of synchronous processing is further improved. In addition, the first node device is also provided with an exception handling mechanism, so that the exception condition in the synchronous handling process can be effectively solved.
Fig. 7 is a schematic structural diagram illustrating a synchronous processing device according to an exemplary embodiment of the present application; the synchronization processing apparatus is provided in a first node device in the blockchain network, and specifically, the synchronization processing apparatus may be a computer program (including program code) running in the first node device, for example, the synchronization processing apparatus may be an application software in the first node device; the synchronization processing means may be adapted to perform the corresponding steps in the methods shown in fig. 5-6. The first node device may be any node device in the blockchain network, for example, the first node device is a node device in the blockchain network shown in fig. 3. The blockchain network further comprises a second node device, and the first node device is connected with the second node device. As shown in fig. 7, the synchronization processing apparatus includes:
an obtaining unit 701, configured to obtain a target skeleton, where the target skeleton includes N data units, the N data units are used to store N blocks to be synchronized of a first node device, the N blocks are in one-to-one correspondence with the N data units, and N is a positive integer; the system comprises a target framework, a data acquisition module, a data processing module and a data processing module, wherein the data acquisition module is used for acquiring calibration data corresponding to the target framework;
a processing unit 702, configured to verify, when receiving N blocks synchronized by the second node device, the N blocks by using the check data; and if the verification is successful, filling the N blocks into the N data units of the target skeleton.
In one embodiment, N data units in the target skeleton are arranged in sequence, and N blocks are consecutive blocks in the block chain network; the ith data unit in the N data units is used for storing the ith block in the N blocks; i is a positive integer and is more than or equal to 1 and less than or equal to N.
In an embodiment, the obtaining unit 701 is specifically configured to:
determining a reference block corresponding to a first block of the N blocks on a reference block chain in a block chain network, and determining a key block corresponding to a last block of the N blocks on the reference block chain;
acquiring a hash value of a reference block and a hash value of a key block;
sending a query request to the second node device, wherein the query request comprises the hash value of the reference block and the hash value of the key block; the query request is used for requesting the second node equipment to query whether the second node equipment stores N blocks or not according to the hash value of the reference block and the hash value of the key block;
and if a successful query response of the second node equipment is received, sending a target synchronization task to the second node equipment, wherein the target synchronization task is used for indicating the second node equipment to return the N blocks.
In one embodiment, the check data is a hash value of the reference chunk; the processing unit 702 is specifically configured to:
obtaining a hash value to be checked of a first block in N blocks synchronized by second node equipment;
if the hash value to be checked is the same as the hash value of the reference block, detecting whether the N blocks are continuous or not according to the hash value of the reference block;
if the verification is continuous, the verification of the N blocks is confirmed to be successful.
In one embodiment, the check data is a hash value of a parent block of the reference block; the processing unit 702 is specifically configured to:
obtaining a hash value to be checked of a first block in N blocks synchronized by second node equipment;
verifying whether the first block and the parent block of the reference block have a parent-child relationship or not according to the hash value to be verified and the hash value of the parent block of the reference block;
if the hash value has a parent-child relationship, detecting whether the N blocks are continuous or not according to the hash value to be verified;
if the verification is continuous, the verification of the N blocks is confirmed to be successful.
In an embodiment, the obtaining unit 701 is specifically configured to:
acquiring the block height of a reference block chain in a block chain network, and acquiring the block height of a first block chain locally stored by first node equipment;
determining N blocks between the block height of the reference block chain and the block height of the first block chain as blocks to be synchronized by the first node device;
and constructing a target skeleton according to the N blocks.
In one embodiment, the blockchain network includes a candidate node set, the candidate node set includes a plurality of candidate node devices connected to the first node device, and the second node device is any one of the candidate node devices selected from the candidate node set; the processing unit 702 is further configured to:
and if the verification fails, selecting one alternative node device from the alternative node set again to determine the alternative node device as the second node device.
In an embodiment, the obtaining unit 701 is further configured to:
if the verification of the blocks returned by all the alternative node devices in the alternative node set fails, acquiring the verification data corresponding to the target skeleton again; or to retrieve a new target skeleton.
In one embodiment, the processing unit 702 is further configured to:
and reading N blocks stored in sequence by N data units from the target skeleton, and adding the read N blocks to a first block chain locally stored by the first node device.
According to an embodiment of the present application, the units in the synchronization processing apparatus shown in fig. 7 may be respectively or entirely combined into one or several other units to form the synchronization processing apparatus, or some unit(s) thereof may be further split into multiple functionally smaller units to form the synchronization processing apparatus, which may achieve the same operation without affecting the achievement of the technical effect of the embodiment of the present application. The units are divided based on logic functions, and in practical application, the functions of one unit can be realized by a plurality of units, or the functions of a plurality of units can be realized by one unit. In other embodiments of the present application, the synchronization processing apparatus may also include other units, and in practical applications, these functions may also be implemented by being assisted by other units, and may be implemented by cooperation of multiple units. According to another embodiment of the present application, the synchronous processing apparatus as shown in fig. 7 may be constructed by running a computer program (including program codes) capable of executing the steps involved in the respective methods shown in fig. 5 to 6 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 a storage element, and the synchronous processing method of the embodiment of the present application may be implemented. The computer program may be recorded on a computer-readable recording medium, for example, and loaded and executed in the above-described computing apparatus via the computer-readable recording medium.
In the embodiment of the application, when the first node device performs synchronization processing, the target skeleton and the check data corresponding to the target skeleton are obtained, when N blocks required by the target skeleton synchronized by the second node device are received, the first node device verifies the N blocks by using the check data corresponding to the target skeleton, and after the verification is successful, the N blocks are filled into the target skeleton, so that the synchronization of the N blocks is completed. By the synchronous processing mode of framework filling, a plurality of blocks can be synchronized at one time based on one synchronous task corresponding to one framework, and the synchronous processing efficiency is effectively improved; and moreover, for the synchronously obtained blocks, the verification data corresponding to the framework is adopted for quick verification, so that the verification efficiency is improved, and the efficiency of synchronous processing is further improved. In addition, the first node device is also provided with an exception handling mechanism, so that the exception condition in the synchronous handling process can be effectively solved.
Fig. 8 is a schematic structural diagram illustrating a synchronous processing device according to an exemplary embodiment of the present application. The synchronization processing device is a first node device in the blockchain network, and the first node device may be any node device in the blockchain network, for example, the first node device is a node device in the blockchain network shown in fig. 3. The blockchain network further comprises a second node device, and the first node device is connected with the second node device. As shown in fig. 8, the synchronous processing device includes at least a processor 801, an input device 802, an output device 803, and a computer storage medium 804. The processor 801, the input device 802, the output device 803, and the computer storage medium 804 may be connected by a bus or other means. A computer storage medium 804 may be stored in the memory of the synchronous processing device, the computer storage medium 804 being for storing a computer program comprising program instructions, the processor 801 being for executing the program instructions stored by the computer storage medium 804. The processor 801 (or CPU) is a computing core and a control core of the synchronous Processing device, and is adapted to implement one or more instructions, and specifically, adapted to load and execute one or more instructions so as to implement a corresponding method flow or a corresponding function.
An embodiment of the present application further provides a computer storage medium (Memory), which is a Memory device in the synchronous processing device and is used for storing programs and data. It is understood that the computer storage medium herein may include a built-in storage medium in the synchronous processing device, and may also include an extended storage medium supported by the synchronous processing device. The computer storage medium provides a storage space that stores an operating system of the synchronous processing device. Also stored in the memory space are one or more instructions, which may be one or more computer programs (including program code), suitable for loading and execution by the processor 801. The computer storage medium may be a high-speed RAM memory, or may be a non-volatile memory (non-volatile memory), such as at least one disk memory; and optionally at least one computer storage medium located remotely from the processor.
The computer storage medium having stored therein one or more instructions; one or more instructions stored in the computer storage medium are loaded and executed by the processor 801 to implement the corresponding steps in the above-described synchronous processing method embodiments; in particular implementations, one or more instructions in the computer storage medium are loaded and executed by the processor 801 to perform the steps of:
acquiring a target skeleton, wherein the target skeleton comprises N data units, the N data units are used for storing N blocks to be synchronized of first node equipment, the N blocks correspond to the N data units one by one, and N is a positive integer;
acquiring calibration data corresponding to a target skeleton;
when N blocks synchronized by the second node equipment are received, verifying the N blocks by adopting the verification data;
and if the verification is successful, filling the N blocks into the N data units of the target skeleton.
In one embodiment, N data units in the target skeleton are arranged in sequence, and N blocks are consecutive blocks in the block chain network;
the ith data unit in the N data units is used for storing the ith block in the N blocks; i is a positive integer and is more than or equal to 1 and less than or equal to N.
In one embodiment, one or more instructions in a computer storage medium are loaded by processor 801 and further perform the steps of:
determining a reference block corresponding to a first block of the N blocks on a reference block chain in a block chain network, and determining a key block corresponding to a last block of the N blocks on the reference block chain;
acquiring a hash value of a reference block and a hash value of a key block;
sending a query request to the second node device, wherein the query request comprises the hash value of the reference block and the hash value of the key block; the query request is used for requesting the second node equipment to query whether the second node equipment stores N blocks or not according to the hash value of the reference block and the hash value of the key block;
and if a successful query response of the second node equipment is received, sending a target synchronization task to the second node equipment, wherein the target synchronization task is used for indicating the second node equipment to return the N blocks.
In one embodiment, the check data is a hash value of the reference chunk; when one or more instructions in the computer storage medium are loaded by the processor 801 and the step of verifying the N blocks with the check data is performed, the following steps are specifically performed:
obtaining a hash value to be checked of a first block in N blocks synchronized by second node equipment;
if the hash value to be checked is the same as the hash value of the reference block, detecting whether the N blocks are continuous or not according to the hash value of the reference block;
if the verification is continuous, the verification of the N blocks is confirmed to be successful.
In one embodiment, the check data is a hash value of a parent block of the reference block; when one or more instructions in the computer storage medium are loaded by the processor 801 and the step of verifying the N blocks with the check data is performed, the following steps are specifically performed:
obtaining a hash value to be checked of a first block in N blocks synchronized by second node equipment;
verifying whether the first block and the parent block of the reference block have a parent-child relationship or not according to the hash value to be verified and the hash value of the parent block of the reference block;
if the hash value has a parent-child relationship, detecting whether the N blocks are continuous or not according to the hash value to be verified;
if the verification is continuous, the verification of the N blocks is confirmed to be successful.
In one embodiment, when one or more instructions in the computer storage medium are loaded by the processor 801 and the step of obtaining the target skeleton is executed, the following steps are specifically executed:
acquiring the block height of a reference block chain in a block chain network, and acquiring the block height of a first block chain locally stored by first node equipment;
determining N blocks between the block height of the reference block chain and the block height of the first block chain as blocks to be synchronized by the first node device;
and constructing a target skeleton according to the N blocks.
In one embodiment, the blockchain network includes a candidate node set, the candidate node set includes a plurality of candidate node devices connected to the first node device, and the second node device is any one of the candidate node devices selected from the candidate node set; one or more instructions in the computer storage medium are loaded by the processor 801 and further perform the steps of:
and if the verification fails, selecting one alternative node device from the alternative node set again to determine the alternative node device as the second node device.
In one embodiment, one or more instructions in a computer storage medium are loaded by processor 801 and further perform the steps of:
if the verification of the blocks returned by all the alternative node devices in the alternative node set fails, acquiring the verification data corresponding to the target skeleton again; or to retrieve a new target skeleton.
In one embodiment, one or more instructions in a computer storage medium are loaded by processor 801 and further perform the steps of:
and reading N blocks stored in sequence by N data units from the target skeleton, and adding the read N blocks to a first block chain locally stored by the first node device.
In the embodiment of the application, when the first node device performs synchronization processing, the target skeleton and the check data corresponding to the target skeleton are obtained, when N blocks required by the target skeleton synchronized by the second node device are received, the first node device verifies the N blocks by using the check data corresponding to the target skeleton, and after the verification is successful, the N blocks are filled into the target skeleton, so that the synchronization of the N blocks is completed. By the synchronous processing mode of framework filling, a plurality of blocks can be synchronized at one time based on one synchronous task corresponding to one framework, and the synchronous processing efficiency is effectively improved; and moreover, for the synchronously obtained blocks, the verification data corresponding to the framework is adopted for quick verification, so that the verification efficiency is improved, and the efficiency of synchronous processing is further improved. In addition, the first node device is also provided with an exception handling mechanism, so that the exception condition in the synchronous handling process can be effectively solved.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention, and it is therefore to be understood that the invention is not limited by the scope of the appended claims.

Claims (11)

1. A synchronization processing method performed by a first node device in a blockchain network, the blockchain network further including a second node device, the first node device being connected to the second node device, the method comprising:
acquiring a target skeleton, wherein the target skeleton comprises N data units, the N data units are used for storing N blocks to be synchronized of the first node equipment, the N blocks correspond to the N data units one by one, and N is a positive integer; n data units in the target skeleton are arranged in sequence, and the N blocks are continuous blocks in the block chain network;
acquiring calibration data corresponding to the target skeleton;
determining a reference block corresponding to a first block of the N blocks on a reference block chain in the block chain network and a key block corresponding to a last block of the N blocks on the reference block chain;
acquiring the hash value of the reference block and the hash value of the key block;
sending a query request to the second node device, wherein the query request comprises the hash value of the reference block and the hash value of the key block; the query request is used for requesting the second node device to query whether the second node device stores the N blocks according to the hash value of the reference block and the hash value of the key block;
if a query success response of the second node device is received, sending a target synchronization task to the second node device, wherein the target synchronization task is used for indicating the second node device to return the N blocks;
when the N blocks synchronized by the second node equipment are received, verifying the N blocks by adopting the check data;
and if the verification is successful, filling the N blocks into N data units of the target skeleton.
2. The method of claim 1, wherein an ith data unit of the N data units is used to store an ith block of the N blocks; i is a positive integer and is more than or equal to 1 and less than or equal to N.
3. The method of claim 1, wherein the check data is a hash value of the reference chunk; the verifying the N blocks with the check data includes:
obtaining a hash value to be checked of a first block of the N blocks synchronized by the second node device;
if the hash value to be checked is the same as the hash value of the reference block, detecting whether the N blocks are continuous or not according to the hash value of the reference block;
and if the verification is continuous, the verification of the N blocks is confirmed to be successful.
4. The method of claim 1, wherein the check data is a hash value of a parent block of the reference block; the verifying the N blocks with the check data includes:
obtaining a hash value to be checked of a first block of the N blocks synchronized by the second node device;
verifying whether the first block and the parent block of the reference block have a parent-child relationship according to the hash value to be verified and the hash value of the parent block of the reference block;
if the hash value has a parent-child relationship, detecting whether the N blocks are continuous or not according to the hash value to be checked;
and if the verification is continuous, the verification of the N blocks is confirmed to be successful.
5. The method of claim 1, wherein the obtaining the target skeleton comprises:
acquiring the block height of a reference block chain in the block chain network, and acquiring the block height of a first block chain locally stored by the first node device;
determining N blocks between a block height of the reference block chain and a block height of the first block chain as blocks to be synchronized by the first node device;
and constructing the target skeleton according to the N blocks.
6. The method according to claim 1, wherein the blockchain network includes an alternative node set, the alternative node set includes a plurality of alternative node devices connected to the first node device, and the second node device is any one of the alternative node devices selected from the alternative node set; the method further comprises the following steps:
and if the verification fails, selecting one candidate node device from the candidate node set again to determine the candidate node device as the second node device.
7. The method of claim 6, wherein the method further comprises:
if the verification of the blocks returned by all the candidate node devices in the candidate node set fails, acquiring the verification data corresponding to the target skeleton again; or to retrieve a new target skeleton.
8. The method of claim 1, wherein after the padding the N blocks into the N data units of the target skeleton, further comprising:
and reading the N blocks stored in sequence in the N data units from the target skeleton, and adding the read N blocks to a first block chain locally stored in the first node device.
9. A synchronous processing device is characterized in that the synchronous processing device is arranged in a first node device in a block chain network, the block chain network further comprises a second node device, the first node device is connected with the second node device, and the synchronous processing device comprises:
the acquisition unit is used for acquiring a target skeleton, the target skeleton comprises N data units, the N data units are used for storing N blocks to be synchronized of the first node equipment, the N blocks correspond to the N data units one by one, and N is a positive integer; the system is used for acquiring calibration data corresponding to the target skeleton; n data units in the target skeleton are arranged in sequence, and the N blocks are continuous blocks in the block chain network;
the obtaining unit is further configured to determine a reference block corresponding to a first block of the N blocks on a reference block chain in the block chain network, and a key block corresponding to a last block of the N blocks on the reference block chain; acquiring a hash value of a reference block and a hash value of a key block; sending a query request to the second node device, wherein the query request comprises the hash value of the reference block and the hash value of the key block; the query request is used for requesting the second node equipment to query whether the second node equipment stores N blocks or not according to the hash value of the reference block and the hash value of the key block; if a successful query response of the second node equipment is received, sending a target synchronization task to the second node equipment, wherein the target synchronization task is used for indicating the second node equipment to return N blocks;
the processing unit is used for verifying the N blocks by adopting the check data when the N blocks synchronized by the second node equipment are received; and if the verification is successful, filling the N blocks into N data units of the target skeleton.
10. A synchronous processing device, wherein the synchronous processing device is a first node device in a blockchain network, the blockchain network further includes a second node device, the first node device is connected to the second node device, the synchronous processing device includes an input device and an output device, and further includes:
a processor adapted to implement one or more instructions; and the number of the first and second groups,
computer storage medium storing one or more instructions adapted to be loaded by the processor and to perform a synchronization processing method according to any of claims 1-8.
11. A computer storage medium having stored thereon one or more instructions adapted to be loaded by a processor and to perform a method of synchronization processing according to any of claims 1-8.
CN202010212986.4A 2020-03-24 2020-03-24 Synchronous processing method, device, equipment and medium Active CN111444206B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010212986.4A CN111444206B (en) 2020-03-24 2020-03-24 Synchronous processing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010212986.4A CN111444206B (en) 2020-03-24 2020-03-24 Synchronous processing method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN111444206A CN111444206A (en) 2020-07-24
CN111444206B true CN111444206B (en) 2021-10-15

Family

ID=71649017

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010212986.4A Active CN111444206B (en) 2020-03-24 2020-03-24 Synchronous processing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN111444206B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113626260B (en) * 2021-10-11 2022-02-22 腾讯科技(深圳)有限公司 Data processing method, device, equipment and storage medium of block chain network
CN115086350B (en) * 2022-06-13 2024-01-19 亿度科创(深圳)有限公司 Block chain node data synchronization method, equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109274754A (en) * 2018-10-11 2019-01-25 上海保险交易所股份有限公司 For the method for synchrodata, equipment and storage medium in block chain network
CN110059089A (en) * 2019-03-27 2019-07-26 深圳前海达闼云端智能科技有限公司 Data synchronization method and device, storage medium and electronic equipment
WO2020010270A1 (en) * 2018-07-04 2020-01-09 Neji, Inc. Dynamic routing using a distributed hash table

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020010270A1 (en) * 2018-07-04 2020-01-09 Neji, Inc. Dynamic routing using a distributed hash table
CN109274754A (en) * 2018-10-11 2019-01-25 上海保险交易所股份有限公司 For the method for synchrodata, equipment and storage medium in block chain network
CN110059089A (en) * 2019-03-27 2019-07-26 深圳前海达闼云端智能科技有限公司 Data synchronization method and device, storage medium and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
区块链技术在数据同步与交换应用研究;王梓桦等;《第六届中国指挥控制大会论文集(下册)》;20180702;全文 *

Also Published As

Publication number Publication date
CN111444206A (en) 2020-07-24

Similar Documents

Publication Publication Date Title
EP3693886B1 (en) Optimizations for verification of interactions system and method
US10747721B2 (en) File management/search system and file management/search method based on block chain
CN111061769B (en) Consensus method of block chain system and related equipment
CN110175840B (en) Method, client, alliance chain and system for realizing light wallet mechanism in alliance chain
Matzutt et al. How to securely prune bitcoin’s blockchain
JP2023506634A (en) partially ordered blockchain
CN112287034B (en) Data synchronization method, equipment and computer readable storage medium
CN111444203B (en) Synchronous processing method, device, equipment and medium
CN111444206B (en) Synchronous processing method, device, equipment and medium
CN111444204B (en) Synchronous processing method, device, equipment and medium
CN110941676B (en) Configuration method, device, equipment and medium
Guo et al. RNS-based adaptive compression scheme for the block data in the blockchain for IIoT
CN111899019A (en) Method and system for cross validation and sharing of blacklist and multiple parties
Sohrabi et al. ZyConChain: A scalable blockchain for general applications
CN111639080A (en) Data processing method and device, node equipment and storage medium
CN111292190A (en) Transaction generation method, block creation method, related device and equipment
Han et al. Analysing and improving shard allocation protocols for sharded blockchains
CN113409047B (en) Data processing method, device and equipment based on block chain and readable storage medium
Yao et al. Sok: A taxonomy for critical analysis of consensus mechanisms in consortium blockchain
CN117010889A (en) Data processing method, device, equipment, medium and product
CN116777631B (en) Transaction uplink method and device based on blockchain, equipment and medium
CN117155953A (en) Data processing method, device, computer equipment and readable storage medium
GB2571927A (en) Resource management system and method of operation thereof
US20230138816A1 (en) System and method to reach consensus in a multi-chain iot environment
Xie et al. Research on Improved Blockchain Broadcasting Mechanism Based on DHT

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40026367

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant