WO2021190179A1 - 一种同步处理方法和相关装置 - Google Patents

一种同步处理方法和相关装置 Download PDF

Info

Publication number
WO2021190179A1
WO2021190179A1 PCT/CN2021/075370 CN2021075370W WO2021190179A1 WO 2021190179 A1 WO2021190179 A1 WO 2021190179A1 CN 2021075370 W CN2021075370 W CN 2021075370W WO 2021190179 A1 WO2021190179 A1 WO 2021190179A1
Authority
WO
WIPO (PCT)
Prior art keywords
node device
synchronization
skeleton
blocks
candidate
Prior art date
Application number
PCT/CN2021/075370
Other languages
English (en)
French (fr)
Inventor
李茂材
王宗友
张劲松
周开班
时一防
黄焕坤
刘区城
刘攀
蓝虎
杨常青
朱耿良
孔利
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Priority to EP21774939.9A priority Critical patent/EP4016323A4/en
Priority to JP2022523680A priority patent/JP2022553963A/ja
Publication of WO2021190179A1 publication Critical patent/WO2021190179A1/zh
Priority to US17/721,231 priority patent/US20220237153A1/en

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/21Design, administration or maintenance of databases
    • G06F16/211Schema design and management
    • G06F16/212Schema design and management with details for data modelling support
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees
    • 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
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • 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/02Banking, e.g. interest calculation or account maintenance
    • 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
    • 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
    • G06Q2220/00Business processing using cryptography

Definitions

  • This application relates to the field of blockchain technology, and specifically to blockchain-based synchronization processing.
  • a node device in the blockchain network When a node device in the blockchain network is performing blockchain synchronization processing, it will obtain the required zones one by one from other node devices in the blockchain network (such as consensus node devices or synchronization node devices). Piece.
  • the embodiments of the present application provide a synchronization processing method and related devices, which can effectively improve synchronization processing efficiency.
  • an embodiment of the present application provides a synchronization processing method, which is executed by a first node device in a blockchain network.
  • the blockchain network includes a set of candidate nodes.
  • the candidate node device connected to the device, the method includes:
  • the skeleton set is used to store M blocks to be synchronized by the first node device; the skeleton set includes P skeletons, and the synchronization task set includes P synchronization tasks.
  • the P synchronization tasks have a one-to-one correspondence; where M and P are both positive integers;
  • an embodiment of the present application provides a synchronization processing device.
  • the synchronization processing device is set in a first node device in a blockchain network.
  • the blockchain network includes a set of candidate nodes.
  • a candidate node device connected to a node device, the synchronization processing device includes:
  • the obtaining unit is used to obtain a skeleton set and a synchronization task set.
  • the skeleton set is used to store M blocks to be synchronized by the first node device; the skeleton set includes P skeletons, and the synchronization task set includes P synchronization tasks.
  • the P skeletons correspond to the P synchronization tasks in a one-to-one correspondence; wherein M and P are both positive integers;
  • the processing unit is configured to select a second node device from the set of candidate nodes, where the second node device is at least one candidate node device in the set of candidate nodes; concurrently send synchronization tasks in the set of synchronization tasks to the second node device to make the second node device
  • the two-node device executes the synchronization task and returns M blocks; and fills the M blocks into each skeleton in the skeleton set.
  • an embodiment of the present application provides a synchronization processing device.
  • the synchronization processing device is the first node device in a blockchain network.
  • the blockchain network includes a set of candidate nodes.
  • the candidate node device connected to the node device; the synchronization processing device includes an input device and an output device, and also includes:
  • the computer storage medium stores one or more instructions, and one or more instructions are suitable for being loaded by a processor and executed by the synchronization processing method of the foregoing aspects.
  • an embodiment of the present application provides a computer storage medium that stores one or more instructions, and the one or more instructions are suitable for being loaded by a processor and executing the synchronization processing method of the foregoing aspect.
  • the embodiments of the present application provide a computer program product including instructions, which when run on a computer, cause the computer to execute the synchronization processing method in the above aspect.
  • the first node device obtains a skeleton set and a synchronization task set when performing synchronization processing.
  • the skeleton set is used to store the M blocks to be synchronized by the first node device;
  • the second node is selected from the set of candidate nodes.
  • the first node device then fills M blocks into each skeleton in the skeleton set.
  • synchronization tasks corresponding to multiple skeletons can be concurrently processed in one synchronization process, so that more blocks can be synchronized at one time based on multiple skeletons, which improves the efficiency of synchronization processing.
  • Fig. 1 shows a block chain infrastructure diagram provided by an exemplary embodiment of the present application
  • Figure 2 shows a schematic structural diagram of a blockchain provided by an exemplary embodiment of the present application
  • FIG. 3 shows a schematic diagram of the architecture of a blockchain network provided by an exemplary embodiment of the present application
  • Fig. 4 shows a schematic structural diagram of a skeleton provided by an exemplary embodiment of the present application
  • Fig. 5 shows a flowchart of a synchronization processing method provided by an exemplary embodiment of the present application
  • Fig. 6 shows a flowchart of another synchronization processing method provided by an exemplary embodiment of the present application
  • FIG. 7 shows a schematic structural diagram of a synchronization processing apparatus provided by an exemplary embodiment of the present application.
  • Fig. 8 shows a schematic structural diagram of another synchronization processing device provided by an exemplary embodiment of the present application.
  • Blockchain refers to a set of decentralized infrastructure with distributed storage characteristics. Specifically, it is a data structure composed of data blocks in a chronological order in a manner similar to a linked list. The data is verified in the system, and the data cannot be tampered with or forged by means of cryptography.
  • Fig. 1 shows a block chain infrastructure diagram provided by an exemplary embodiment of the present application; as shown in Fig. 1, the block chain infrastructure mainly includes 5 hierarchical structures 101-105 in a bottom-up order . in:
  • Information data and Merkle trees are located at the bottom 101.
  • the information data here refers to the original data that is requested to be published to the blockchain network, but has not yet formed a block, for example, it can be business data, transaction data, and so on. These raw data need to be further processed (for example, verified by each node in the blockchain network, hashed, etc.) before it can be written into the block.
  • Merkle tree is an important part of blockchain technology.
  • the blockchain does not directly store the original data in plaintext.
  • the original data needs to be hashed and stored in the form of hash values.
  • the Merkel tree is used to organize the hash value formed by the hash operation of multiple original data in a binary tree structure and store it in the block body.
  • FIG. 2 shows a schematic structural diagram of a block chain provided by an exemplary embodiment of the present application; as shown in Figure 2, block i-1 (i is a positive integer), block i and block i+1 in sequence Connected into a chain structure. Among them, block i is divided into two parts: block header and block body.
  • the block header contains the digest value of the previous block i-1 and the digest value of this block i (that is, the Merkle root of this block). ).
  • the block body contains the complete data of this block i and is organized in the form of a Merkle tree.
  • Block i-1 and block i have a parent-child relationship, that is, 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 the parent block of block i+1, and block i+1 is the child block of block i.
  • the protocols and mechanisms followed by the blockchain are located at level 103. These protocols may include: P2P (Peer-to-Peer, peer-to-peer network) protocols; mechanisms may include, but are not limited to: broadcast mechanisms, consensus mechanisms (including PoW (Proof Of Work, proof of work) mechanism, POS (Proof Of Work) Stake, equity proof) mechanism and other core mechanisms).
  • P2P Peer-to-Peer, peer-to-peer network
  • mechanisms may include, but are not limited to: broadcast mechanisms, consensus mechanisms (including PoW (Proof Of Work, proof of work) mechanism, POS (Proof Of Work) Stake, equity proof) mechanism and other core mechanisms).
  • the blockchain network is located at level 104.
  • the blockchain network is composed of multiple node devices; the node devices can be computer devices, including but not limited to: PC (Personal Computer), servers, mining machines, smart phones, tablet computers, mobile computers, and so on.
  • Each node device in the blockchain network is networked in P2P mode, and the node device and node device communicate with each other according to the P2P protocol; each node device jointly follows the broadcast mechanism and consensus mechanism (including PoW mechanism, POS mechanism and other core mechanisms), Jointly ensure that the data on the blockchain cannot be tampered with and cannot be forged, and at the same time realize the decentralization and trustlessness of the blockchain.
  • PC Personal Computer
  • consensus mechanism including PoW mechanism, POS mechanism and other core mechanisms
  • the smart contract is located at the upper layer 105.
  • a smart contract is a set of scenario-responsive procedural rules and logic, and it is a decentralized, information-sharing program code deployed on the blockchain.
  • the parties who signed the contract reached an agreement on the content of the contract and deployed it in the blockchain in the form of a smart contract, which meant that they could automatically execute the contract on behalf of each signatory without relying on any central agency.
  • the types of blockchain can include: Public Blockchain, Private Blockchain, and Consortium Blockchain.
  • the public chain is open to the outside world, and anyone can join and access the blockchain; the blocks on the public chain can be viewed by anyone, anyone can initiate transactions on the public chain, and can participate in the consensus process of the public chain at any time.
  • Private chains are only used inside private organizations.
  • the read and write permissions and the permissions to participate in accounting on the blockchain are set according to the rules of the private organization; they are usually used for internal data management, auditing, and so on.
  • the alliance chain is limited to the participation of alliance members.
  • the read and write permissions and the permission to participate in accounting on the blockchain are determined according to the rules of the alliance; it is generally used in scenarios such as inter-institutional transactions, settlement or clearing.
  • the basic structure of the blockchain shown in Figure 1 is the basis for the development of various types of blockchains. It is understandable that there will be some differences in the networking methods of the blockchain networks corresponding to different types of blockchains. Because the blockchain has the characteristics of decentralization, distributed storage, and non-tampering and unforgeability of data, more and more business activities (such as lending activities, financial transaction activities) are based on blockchain technology to make use of blocks The characteristics of the chain to ensure the fairness and openness of business activities.
  • Figure 3 shows a schematic diagram of the architecture of a blockchain network provided by an exemplary embodiment of the present application; the blockchain network includes multiple node devices (in the figure, 7 node devices are taken as an example for illustration); As shown in 4, node device 1 and node device 2 are consensus node devices, and node device 3 to node device 7 are all synchronous node devices.
  • the consensus node device refers to a node device that can not only perform 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.
  • Blockchain is a distributed application mode.
  • Each node device in the blockchain network stores a blockchain; specifically: in the blockchain network shown in Figure 3, node device 1 is The storage space of the node device 1 stores the blockchain 1, the node device 2 stores the blockchain 2 in the storage space of the node device 2, and 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 differences, and time differences in joining the blockchain network, there will be differences between the blockchains stored by the node devices in the blockchain network, and each node in the blockchain network Devices need to use synchronization and other means to maintain consistency between the blockchains stored by each node device.
  • n is a positive integer
  • node device n+1 there are already n (n is a positive integer) node devices in the blockchain network, and a certain node device n+1 is newly added to the blockchain network.
  • this node device n+1 its storage space No block has been saved, the block height of the block chain n+1 of the node device n+1 is 0, and the node device n that already exists in the blockchain network may have stored 10001 blocks.
  • the block height of the block chain n stored in the storage space of the node device n may be 10000.
  • the node device n+1 lags behind the node device n, and the node device n+1 needs to perform the block synchronization process to obtain the area All blocks between block height 0 and block height 10000 update their own blockchain n+1 to catch up with node device n.
  • the new block generated in the blockchain network needs to be agreed by the consensus node device first. After the consensus is successful, the consensus node device adds the new block to the blockchain stored locally by the consensus node device. The synchronization node device in the network then obtains the new block from the consensus node device and adds it to the blockchain stored locally by the synchronization node device to complete the block synchronization process. Based on this, it is generally recognized that the blockchain stored in the consensus node device is the longest (or most complete) blockchain in the blockchain network, and the blockchain stored in the consensus node device can be used as a reference area in the synchronization process Block chain.
  • a synchronization processing solution which introduces the concept of a framework (Framework).
  • Fig. 4 shows a schematic structural diagram of a skeleton provided by an exemplary embodiment of the present application; the skeleton is a data structure.
  • a skeleton contains multiple data units 401, and each data unit is used to store a block.
  • any node device in the blockchain network (assuming it is the node device 3 shown in Figure 3) needs to synchronize 100 blocks from block 1 to block 100, then the node device
  • the synchronization processing flow of 3 may include the following steps (1)-(4):
  • skeleton set includes a total of 10 skeletons, and each skeleton includes 10 data units 401. These data units 401 are reserved for storing these data units after the node device 3 obtains the synchronization block.
  • Synchronization block Take skeleton 1 as an example: skeleton 1 includes 10 data units 401, these data units are arranged in order, the first data unit is used to store block 1, and the second data unit is used to store block 2. And so on.
  • each skeleton can include 10 data units; of course, the number of data units included in each skeleton can also be different, for example, the skeleton in Figure 4 1 can include 10 data units, skeleton 2 can include 5 data units, skeleton 3 can include 15 data units, and so on.
  • the node device 3 can set the number of skeletons and the number of data units included in the skeleton according to the actual situation.
  • the actual situation here may include, but is not limited to: the number and processing capacity of the node devices in the candidate node set, and the actual situation of the node device 3. Concurrent processing capabilities and so on.
  • the synchronization task set contains one or more synchronization tasks; one skeleton corresponds to one synchronization task.
  • skeleton 1 corresponds to synchronization task 1
  • skeleton 2 corresponds to synchronization task 2
  • skeleton 3 corresponds to synchronization task 3, and so on.
  • the synchronization task corresponding to each skeleton is used to instruct to return multiple blocks of the skeleton for storage, for example: the synchronization task 1 corresponding to skeleton 1 is used to instruct to return to the node device 3 the block 1-zone of the skeleton 1 for storage Block 10; another example: the synchronization task 2 corresponding to the skeleton 2 is used to instruct the node device 3 to return to the node device 3 the block 11-block 20 of the skeleton 2 for storage. It is understandable that the synchronization task carries instruction information.
  • the instruction information may include the index of the block corresponding to the first and last two data units in the skeleton, where the index may be the hash value of the block, or the generation of the block Timestamp, or the block height corresponding to the block.
  • the index may be the hash value of the block, or the generation of the block Timestamp, or the block height corresponding to the block.
  • the indication information may also include the indexes of all blocks used by the skeleton for storage, so that when other node devices receive the synchronization task, they will return all the blocks needed to the node device 3 according to the indexes of all the blocks needed. Piece.
  • the second node device refers to at least one node device connected to the first node device in the blockchain network and used to perform synchronization tasks.
  • the candidate node set includes candidate node devices directly connected to the node device 3. As shown in FIG. 3, the candidate node set of node device 3 includes node device 1, node device 4-node device 7. Since node device 1 is a consensus node device, it also needs to perform consensus tasks. Therefore, in order to avoid processing burden on node device 1, and to improve synchronization efficiency, node device 4 to node device 7 can be selected as the second node from the set of candidate nodes. Device to perform synchronization tasks. Secondly, match the corresponding second node device for each synchronization task. The matching here mainly has the following strategies:
  • Strategy 1 Match according to storage conditions. Match the synchronization task to the second node device that stores the corresponding block; for example: synchronization task 1 requires synchronization of block 1 to block 10, then select the second node device that stores block 1 to block 10 to perform synchronization Task 1: Another example: synchronization task 2 requires synchronization of blocks 81-90, then select the second node device storing blocks 81-90 to perform synchronization task 2.
  • Strategy 2 Match according to processing performance.
  • one of multiple second node devices can be selected to perform a certain synchronization task. For example, if the processing performance of node device 4 is better than node device 5, node device 4 can be selected to perform synchronization task 1.
  • Processing performance includes but is not limited to CPU processing speed, concurrent processing capacity, network bandwidth resources, etc. The higher the processing performance, the higher the degree of execution, and the faster the synchronization task can be executed.
  • Trust degree refers to the information used to describe the degree of trustworthiness of a node device. The higher the degree of trust, the higher the degree of trustworthiness of the node device. Generally, the trust degree of the node device used by the official organization is higher than that of the non-official organization.
  • the trust degree may be expressed by a score. For example, the trust score range includes [0, 10]. The higher the trust score, the higher the trustworthiness.
  • the degree of trust may be represented by a level. For example, the degree of trust includes three levels of high, medium, and low, and the trustworthiness of the three levels decreases in order.
  • one of multiple second node devices can be selected to perform a certain synchronization task. For example, if the trust level of node device 4 is higher than that of node device 5, node device 4 can be selected to perform synchronization task 1.
  • One synchronization task is performed by one node device, and one node device can perform multiple synchronization tasks. It is understandable that the above-mentioned strategies are not exhaustive, and the embodiments of the present application can also be applied to other strategies, such as a random matching strategy, that is, a second node device can be randomly selected from a plurality of second node devices to perform a certain synchronization Task; another example: weighted average strategy, you can set weights for multiple impact factors (storage condition factor, trust factor, processing performance factor), and select one from multiple second node devices to execute according to the weighted average method The synchronization task.
  • a random matching strategy that is, a second node device can be randomly selected from a plurality of second node devices to perform a certain synchronization Task
  • weighted average strategy you can set weights for multiple impact factors (storage condition factor, trust factor, processing performance factor), and select one from multiple second node devices to execute according to the weighted average method The synchronization task.
  • the second node device selected to perform a synchronization task can start from the block Other node devices in the chain network (such as consensus node devices) obtain the block and return it to the first node device.
  • synchronization task 1 requires synchronization of block 1 to block 10
  • the node device is selected by strategy 2 or strategy 3. 4 to perform synchronization task 1, but the node device 4 does not store the block 1-block 10, then the node device 4 can obtain the block 1-block 10 from the consensus node device and return it to the first Node device.
  • synchronization task 1 and synchronization task 3 are executed by node device 4, synchronization task 2, synchronization task 4, and synchronization task 6 are executed by node device 5, and synchronization task 5, synchronization task 6 and synchronization task are executed by node device 5.
  • 9 is 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.
  • the node device 3 can concurrently perform these 10 synchronization tasks at one time, and the second node device (ie, node device 4, node device 5, node device 6, and node device 7) can internally execute these synchronization tasks in a serial or parallel manner.
  • the block required by the node device 3 is returned to the node device 3, so that the node device 3 can obtain the required synchronized block during the one-time synchronization process.
  • the first node device can add the blocks stored in each skeleton to the local blockchain of the first node device in order (for example, in the order of the generation timestamp of each block), so as to achieve The local blockchain update of the first node device.
  • a synchronization task uses any strategy that does not match the corresponding second node device, for example, no node device in the candidate node set completely stores the blocks required by a certain skeleton; then it is possible to construct the skeleton If it is not reasonable enough, consider rebuilding the skeleton and re-update the synchronization task; of course, it can also be compatible with the existing synchronization method to synchronize the blocks required by the skeleton corresponding to the synchronization task that is not matched to the node device one by one.
  • the synchronization processing scheme for skeleton filling proposed in the embodiment of the present application is based on a synchronization task corresponding to a skeleton, which can synchronize multiple blocks at one time, which effectively improves the efficiency of synchronization processing; Synchronization tasks corresponding to multiple skeletons can be concurrent, so that more blocks can be synchronized at one time based on multiple skeletons, which further improves the efficiency of synchronization processing.
  • Figure 5 shows a flowchart of a synchronization processing method provided by an exemplary embodiment of the present application; the method is executed by the first node device in the blockchain network, and the first node device may be in the blockchain network. Any one of the node devices, the subsequent embodiments of the present application are described by taking the first node device as the node device 3 in the blockchain network shown in FIG. 3 as an example.
  • the blockchain network includes a set of candidate nodes, and the set of candidate nodes includes a plurality of candidate node devices connected to the first node device.
  • the method includes the following steps S501-S504:
  • S501 Obtain a skeleton set and a synchronization task set.
  • the skeleton set is used to store M blocks to be synchronized by the first node device; the skeleton set includes P skeletons, and the synchronization task set includes P synchronization tasks, and one skeleton corresponds to one synchronization Task; where M and P are both positive integers.
  • the any skeleton is represented as the target skeleton;
  • the target skeleton includes N data units, and the N data units are used to store the N blocks to be synchronized by the first node device, and N There is a one-to-one correspondence between each block and N data units, where N is a positive integer and N ⁇ M.
  • the N data units in the target skeleton are arranged in order, and N blocks are consecutive blocks in the blockchain network; the i-th data unit among the N data units is used to store the i-th of the N blocks Block; i is a positive integer and 1 ⁇ i ⁇ N.
  • the target skeleton can be any one of skeleton 1 to skeleton 10.
  • N is 10
  • the first data unit of the target skeleton is used to store block 1.
  • the second data unit of the target skeleton is used to store block 2, and so on.
  • the target skeleton corresponds to the target synchronization task
  • the target synchronization task carries instruction information.
  • the instruction information may include the index of the block corresponding to the first and last two data units in the target skeleton, where the index may be the hash value of the block, or Is the generation timestamp of the block, or the block height corresponding to the block.
  • the indication information may also include the indexes of all the blocks used by the target skeleton for storage.
  • the target synchronization task may include indication information, and the indication information may include the indexes of the block 1 and the block 10, and may also include the indexes of the block 1 to the block 10.
  • the sequential arrangement of the data units of the target skeleton is only an example, and the data units of the target skeleton may also be arranged out of order; of course, the N blocks stored in the target skeleton are also It may not be a continuous block; or, the data unit in the target skeleton may not store N blocks in sequence; in this case, the indication information contained in the target synchronization task only needs to include the index of the N blocks.
  • S502 Select a second node device from the set of candidate nodes.
  • the second node device refers to at least one node device used by the candidate nodes to perform synchronization tasks.
  • the above-mentioned strategy can be used to select the second node device.
  • the strategy can include but is not limited to any of the following: selection according to storage condition matching mode, selection according to processing performance matching mode, and selection according to trust degree matching mode.
  • S503 Concurrently send synchronization tasks in the synchronization task set to the second node device, so that the second node device executes the synchronization task and returns M blocks.
  • the concurrency here includes one-time concurrency and batch concurrency.
  • the so-called one-time concurrency means that the first node device can send all synchronization tasks in the synchronization task set to the second node device at one time, so that all required blocks can be synchronized at one time.
  • the so-called concurrency in batches means that the first node device divides the synchronization tasks in the synchronization task set into batches, and concurrently executes these synchronization tasks in batches.
  • the batch division method may be, for example, according to the order of the blocks, the batch of synchronization tasks corresponding to the block with the previous index is earlier than the batch of synchronization tasks corresponding to the block with the next index.
  • the filling process refers to the process of storing the block in the corresponding data unit.
  • the first node device will sequentially fill the M blocks returned by the second node device into the data units of each skeleton.
  • the target skeleton is any one of the skeleton set, and the target synchronization task is any one of the synchronization task set.
  • the target second node device refers to a second node device selected for the target synchronization task in S502; after the target synchronization task is sent to the target second node device through S503, the target second node device executes the target synchronization task and sends it to the first node
  • the device returns N blocks; the first node device fills the N blocks into the N data units of the target skeleton respectively.
  • the first node device obtains a skeleton set and a synchronization task set when performing synchronization processing.
  • the skeleton set is used to store the M blocks to be synchronized by the first node device;
  • the second node is selected from the set of candidate nodes.
  • the first node device then fills M blocks into each skeleton in the skeleton set.
  • Fig. 6 shows a flowchart of a synchronization processing method provided by another exemplary embodiment of the present application; the method is executed by a first node device in a blockchain network, and the first node device may be a blockchain network
  • the first node device is the node device 3 in the blockchain network shown in FIG. 3 as an example for description.
  • the blockchain network includes a set of candidate nodes, and the set of candidate nodes includes a plurality of candidate node devices connected to the first node device.
  • the method includes the following steps S601-S608:
  • S601 Obtain the block height of the reference blockchain in the blockchain network, and obtain the block height of the first blockchain stored locally by the first node device.
  • the reference block chain refers to the longest (or most complete) block chain among the block chains stored by each node device in the block chain network, and usually refers to the block chain stored by the consensus node device.
  • the block height is used to indicate the number of blocks connected to the blockchain.
  • the block height is the identifier of the block, which can be used to indicate the position of the block in the block chain; the block height of the founding block in the block chain is 0 by default, and the zone of the first block after the founding block
  • the block height is 1 (the first block is referred to as block 1), the block height of the second block after the original block is 2 (the second block is referred to as block 2), and so on .
  • the block height of the current block of the reference blockchain is 100 (this current block can be referred to as block 100 for short), which means that 100 blocks have been stacked on top of the genesis block, that is The number of blocks on the reference block chain formed from the founding block to block 100 is 101.
  • S602 Determine M blocks with a difference 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 M is a positive integer.
  • the 100 blocks with a difference between them include block 101-block 200, which are 100 blocks with a difference
  • S603 Construct a skeleton set according to the M blocks.
  • the skeleton set contains P skeletons, where P is a positive integer.
  • P is a positive integer.
  • S604 Create a synchronization task set for the skeleton set, where the synchronization task set includes P synchronization tasks, and one skeleton corresponds to one synchronization task.
  • S605 Select a second node device from the candidate node set, where the second node device is at least one candidate node device in the candidate node set.
  • the second node device may be selected from the set of candidate nodes according to the storage condition matching manner.
  • the selection process of S605 may include the following steps s21-s22:
  • the block storage statement includes the block storage status of the candidate node device. For example, if the block storage statement of a candidate node device includes the index of block 1 to block 10, it means that the candidate node device declares its storage There are block 1 to block 10.
  • s22 According to the block storage statement of each candidate node device in the candidate node set, at least one candidate node device is selected from the candidate node set and determined as the second node device.
  • the node device that states that the block indicated by the synchronization task is stored can be determined as the second node device that executes the synchronization task, so as to ensure that the second node device is capable of executing the synchronization task.
  • the synchronization task can return to the block indicated by the synchronization task.
  • s21-s22 select the second node device according to the block storage situation, which can increase the probability of successful execution of the synchronization task and increase the success rate of the synchronization process.
  • the second node device can be selected from the set of candidate nodes according to the processing performance matching manner.
  • the selection process of S605 may include the following s23-s24:
  • processing performance includes but is not limited to CPU processing speed, concurrent processing capacity, network bandwidth resources, etc.
  • the performance threshold can be set according to actual conditions.
  • the performance threshold can be the average value of the processing performance of each candidate node device in the candidate node set, that is, at least one candidate node device whose processing performance is higher than the average value can be determined as It is the second node device.
  • the second node device can be selected from the set of candidate nodes according to the trust degree matching method.
  • the selection process of S605 may include the following s25-s26:
  • s25 Obtain the trust degree of each candidate node device in the candidate node set.
  • s26 Determine at least one candidate node device whose concentration trust degree of candidate nodes is higher than the trust threshold value as the second node device.
  • the degree of trust is used to describe the degree of trustworthiness of a node device. The higher the degree of trust, the more reliable the node device is.
  • the trust threshold may be set according to actual conditions. For example, the trust threshold may be 5 points, and at least one candidate node device with a trust score higher than 5 points may be determined as the second node device. The second node device is selected based on the degree of trust, which can prevent some malicious nodes from interfering with the synchronization process and improve the security of the synchronization process.
  • S606 Concurrently send synchronization tasks in the synchronization task set to the second node device, so that the second node device executes the synchronization task and returns M blocks.
  • S607 Fill M blocks into each skeleton in the skeleton set.
  • S608 Read the M blocks stored in each data unit from each skeleton, and sequentially add the read M blocks to the first blockchain stored locally by the first node device.
  • the first node device can add the blocks stored in each skeleton to the local blockchain of the first node device in order (for example, in the order of the generation timestamp of each block), so as to achieve The local blockchain update of the first node device.
  • the first node device reads N blocks stored in sequence by N data units from the target skeleton, and adds the read N blocks to the first area stored locally by the first node device Block chain.
  • the skeleton is a data structure. After N blocks are stored in the target skeleton, the N blocks are sequentially read and sequentially added to the first block chain stored locally by the first node device, so that the first block N blocks were successfully updated on the chain.
  • the first node device can complete the synchronization of all blocks and catch up with other node devices in the blockchain network in time.
  • the first node device obtains a skeleton set and a synchronization task set when performing synchronization processing.
  • the skeleton set is used to store the M blocks to be synchronized by the first node device; the second node is selected from the set of candidate nodes. Node device; concurrently send synchronization tasks in the synchronization task set to the second node device, so that the second node device executes the synchronization task and returns M blocks; the first node device then fills M blocks into each skeleton in the skeleton set middle.
  • FIG. 7 shows a schematic structural diagram of a synchronization processing device provided by an exemplary embodiment of the present application; the synchronization processing device is set in the first node device in the blockchain network.
  • the synchronization processing device may be A computer program (including program code) running in the first node device, for example, the synchronization processing device may be an application software in the first node device; the synchronization processing device may be used to execute the steps shown in FIG. 5 to FIG. 6 Corresponding steps in the embodiment.
  • the first node device may be any node device in the blockchain network, for example, the first node device is the node device in the blockchain network shown in FIG. 3.
  • the blockchain network includes a set of candidate nodes, and the set of candidate nodes includes multiple candidate node devices connected to the first node device; as shown in FIG. 7, the synchronization processing device includes:
  • the obtaining unit 701 is used to obtain a skeleton set and a synchronization task set.
  • the skeleton set is used to store M blocks to be synchronized by the first node device; the skeleton set includes P skeletons, and the synchronization task set includes P synchronization tasks.
  • the P skeletons and the P synchronization tasks have a one-to-one correspondence; wherein M and P are both positive integers;
  • the processing unit 702 is configured to select a second node device from the candidate node set, where the second node device is at least one candidate node device in the candidate node set; concurrently send synchronization tasks in the synchronization task set to the second node device, so that The second node device executes the synchronization task and returns M blocks; and fills the M blocks into each skeleton in the skeleton set.
  • the skeleton set includes a target skeleton, and the target skeleton is any one of P skeletons; the target skeleton includes N data units, and the N data units are used to store N blocks to be synchronized by the first node device , N blocks correspond to N data units one-to-one, and N is a positive integer and N ⁇ M.
  • the N data units in the target skeleton are arranged in order, and the N blocks are consecutive blocks in the blockchain network; the i-th data unit among the N data units is used to store N blocks The i-th block in a block; i is a positive integer and 1 ⁇ i ⁇ N.
  • the target second node device refers to any one of the second node devices; the target second node device is used to execute the target synchronization task corresponding to the target skeleton, and return N blocks to the first node device;
  • the specific method for the first node device to fill the N blocks into the target skeleton is: fill the N blocks into the N data units of the target skeleton respectively.
  • processing unit 702 is further configured to:
  • processing unit 702 is specifically configured to:
  • At least one candidate node device whose concentration trust degree of candidate nodes is higher than the trust threshold is determined as the second node device.
  • processing unit 702 is specifically configured to:
  • At least one candidate node device whose centralized processing performance of candidate nodes is better than the performance threshold is determined as the second node device.
  • processing unit 702 is specifically configured to:
  • At least one candidate node device is selected from the candidate node set and determined as the second node device.
  • the acquiring unit 701 is specifically configured to:
  • the units in the synchronization processing device shown in FIG. 7 can be combined separately or all into one or several other units to form, or some unit(s) of them can also be split. It is composed of multiple units with smaller functions, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application.
  • the above-mentioned units are divided based on logical functions.
  • the function of one unit may also be realized by multiple units, or the functions of multiple units may be realized by one unit.
  • the synchronization processing device may also include other units. In practical applications, these functions may also be implemented with the assistance of other units, and may be implemented by multiple units in cooperation.
  • a general-purpose computing device such as a computer including a central processing unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM) and other processing elements and storage elements
  • CPU central processing unit
  • RAM random access storage medium
  • ROM read-only storage medium
  • the computer program can be recorded on, for example, a computer-readable recording medium, loaded into the above-mentioned computing device via the computer-readable recording medium, and run in it.
  • the first node device obtains a skeleton set and a synchronization task set when performing synchronization processing.
  • the skeleton set is used to store the M blocks to be synchronized by the first node device;
  • the second node is selected from the set of candidate nodes.
  • the first node device then fills M blocks into each skeleton in the skeleton set.
  • Fig. 8 shows a schematic structural diagram of a synchronization processing device provided by an exemplary embodiment of the present application.
  • the synchronization processing device is the first node device in the blockchain network.
  • the first node device can be any node device in the blockchain network.
  • the first node device is the blockchain network shown in FIG. 3 Node device in the.
  • the blockchain network includes a set of candidate nodes, and the set of candidate nodes includes a plurality of candidate node devices connected to the first node device.
  • the synchronization processing device at least includes 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 methods.
  • the computer storage medium 804 may be stored in the memory of the synchronization processing device.
  • the computer storage medium 804 is used to store a computer program.
  • the computer program includes program instructions.
  • the processor 801 is used to execute the program instructions stored in the computer storage medium 804.
  • the processor 801 (or CPU (Central Processing Unit, central processing unit)) is the computing core and control core of a synchronous processing device. It is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions. Realize the corresponding method flow or the corresponding function provided in the embodiment of the present application.
  • the embodiment of the present application also provides a computer storage medium (Memory).
  • the computer storage medium is a memory device in a synchronous processing device for storing programs and data. It is understandable that the computer storage medium herein may include a built-in storage medium in the synchronization processing device, or of course, may also include an extended storage medium supported by the synchronization processing device.
  • the computer storage medium provides storage space, and the storage space stores the operating system of the synchronization processing device.
  • one or more instructions suitable for being loaded and executed by the processor 801 are also stored in the storage space, and these instructions may be one or more computer programs (including program codes).
  • the computer storage medium here can be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory; optionally, it can also be at least one located far away from the aforementioned processor.
  • Computer storage media can be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory; optionally, it can also be at least one located far away from the aforementioned processor.
  • the computer storage medium stores one or more instructions; the processor 801 loads and executes one or more instructions stored in the computer storage medium to implement the corresponding steps in the above-mentioned synchronization processing method embodiment; in specific implementation, the computer One or more instructions in the storage medium are loaded by the processor 801 and execute the following steps:
  • the skeleton set is used to store M blocks to be synchronized by the first node device; the skeleton set includes P skeletons, and the synchronization task set includes P synchronization tasks.
  • the P synchronization tasks have a one-to-one correspondence; where M and P are both positive integers;
  • the skeleton set includes a target skeleton, and the target skeleton is any one of P skeletons; the target skeleton includes N data units, and the N data units are used to store N blocks to be synchronized by the first node device , N blocks correspond to N data units one-to-one, and N is a positive integer and N ⁇ M.
  • the N data units in the target skeleton are arranged in order, and the N blocks are consecutive blocks in the blockchain network; the i-th data unit among the N data units is used to store N blocks The i-th block in a block; i is a positive integer and 1 ⁇ i ⁇ N.
  • the target second node device refers to any one of the second node devices; the target second node device is used to execute the target synchronization task corresponding to the target skeleton, and return N blocks to the first node device;
  • the specific method for the first node device to fill the N blocks into the target skeleton is: fill the N blocks into the N data units of the target skeleton respectively.
  • one or more instructions in the computer storage medium are loaded by the processor 801 and the following steps are also executed:
  • At least one candidate node device whose concentration trust degree of candidate nodes is higher than the trust threshold is determined as the second node device.
  • At least one candidate node device whose centralized processing performance of candidate nodes is better than the performance threshold is determined as the second node device.
  • At least one candidate node device is selected from the candidate node set and determined as the second node device.
  • the first node device obtains a skeleton set and a synchronization task set when performing synchronization processing.
  • the skeleton set is used to store the M blocks to be synchronized by the first node device;
  • the second node is selected from the set of candidate nodes.
  • the first node device then fills M blocks into each skeleton in the skeleton set.
  • the embodiments of the present application also provide a computer program product including instructions, which when run on a computer, cause the computer to execute the method provided in the above-mentioned embodiments.

Abstract

一种同步处理方法、装置、设备及介质,其中的方法由区块链网络中的第一节点设备执行,区块链网络包括备选节点集,备选节点集中包含多个与第一节点设备相连接的备选节点设备,该方法包括:获取骨架集合及同步任务集合(S501),骨架集合用于存储第一节点设备待同步的M个区块;骨架集合中包含P个骨架,同步任务集合中包括P个同步任务,P个骨架和P个同步任务一一对应;其中M、P均为正整数;从备选节点集中选取第二节点设备(S502);向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行所述同步任务并返回M个区块(S503);将M个区块填充至所述骨架集合中的各骨架中(S504)。可有效提高同步处理效率。

Description

一种同步处理方法和相关装置
本申请要求于2020年03月24日提交中国专利局、申请号为202010212529.5、申请名称为“一种同步处理方法、装置、设备及介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及区块链技术领域,具体涉及基于区块链的同步处理。
背景技术
当区块链网络中的某个节点设备在进行区块链的同步处理时,会从区块链网络中的其他节点设备(如共识节点设备或同步节点设备)处逐个地获取所需的区块。
发明内容
本申请实施例提供一种同步处理方法和相关装置,可有效提高同步处理效率。
一方面,本申请实施例提供一种同步处理方法,该方法由区块链网络中的第一节点设备执行,区块链网络包括备选节点集,备选节点集中包含多个与第一节点设备相连接的备选节点设备,该方法包括:
获取骨架集合及同步任务集合,骨架集合用于存储第一节点设备待同步的M个区块;骨架集合中包含P个骨架,同步任务集合中包括P个同步任务,所述P个骨架和所述P个同步任务一一对应;其中M、P均为正整数;
从备选节点集中选取第二节点设备,该第二节点设备是备选节点集中的至少一个备选节点设备;
向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行同步任务并返回M个区块;
将M个区块填充至骨架集合中的各骨架中。
一方面,本申请实施例提供一种同步处理装置,同步处理装置设于区块链网络中的第一节点设备中,区块链网络包括备选节点集,备选节点集中包含多个与第一节点设备相连接的备选节点设备,该同步处理装置包括:
获取单元,用于获取骨架集合及同步任务集合,骨架集合用于存储第一节点设备待同步的M个区块;骨架集合中包含P个骨架,同步任务集合中包括P 个同步任务,所述P个骨架和所述P个同步任务一一对应;其中M、P均为正整数;
处理单元,用于从备选节点集中选取第二节点设备,该第二节点设备是备选节点集中的至少一个备选节点设备;向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行同步任务并返回M个区块;以及将M个区块填充至骨架集合中的各骨架中。
一方面,本申请实施例提供一种同步处理设备,该同步处理设备是区块链网络中的第一节点设备,区块链网络包括备选节点集,备选节点集中包含多个与第一节点设备相连接的备选节点设备;该同步处理设备包括输入设备和输出设备,还包括:
处理器,适于实现一条或多条指令;以及,
计算机存储介质,计算机存储介质存储有一条或多条指令,一条或多条适于由处理器加载并执行上述方面的同步处理方法。
一方面,本申请实施例提供一种计算机存储介质,该计算机存储介质存储有一条或多条指令,一条或多条指令适于由处理器加载并执行上述方面的同步处理方法。
一方面,本申请实施例提供了一种包括指令的计算机程序产品,当其在计算机上运行时,使得所述计算机执行以上方面的同步处理方法。
本申请实施例中,第一节点设备在进行同步处理时,获取骨架集合及同步任务集合,该骨架集合用于存储第一节点设备待同步的M个区块;从备选节点集中选取第二节点设备,该第二节点设备是备选节点集中的至少一个备选节点设备;向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行同步任务并返回M个区块;第一节点设备再将M个区块填充至骨架集合中的各骨架中。通过这种骨架填充的同步处理方式,在一次同步处理过程中可以并发多个骨架对应的同步任务,这样基于多个骨架可以一次性同步更多的区块,提升了同步处理的效率。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请 的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出了本申请一个示例性实施例提供的区块链的基础架构图;
图2示出了本申请一个示例性实施例提供的区块链的结构示意图;
图3示出了本申请一个示例性实施例提供的一种区块链网络的架构示意图;
图4示出了本申请一个示例性实施例提供的一种骨架的结构示意图;
图5示出了本申请一个示例性实施例提供的一种同步处理方法的流程图;
图6示出了本申请一个示例性实施例提供的另一种同步处理方法的流程图;
图7示出了本申请一个示例性实施例提供的一种同步处理装置的结构示意图;
图8示出了本申请一个示例性实施例提供的另一种同步处理设备的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请实施例涉及区块链技术。区块链是指一套去中心化、具备分布式存储特点的基础架构,具体是一种按照时间顺序将数据区块用类似链表的方式组成的数据结构,能够安全存储有先后关系的、能在系统内进行验证的数据,并以密码学方式保证数据不可篡改和不可伪造。
图1示出了本申请一个示例性实施例提供的区块链的基础架构图;如图1所示,区块链的基础架构按照由底至上的顺序主要包括101-105共5个层级结构。其中:
(1)信息数据和默克尔(Merkle)树位于底层101。此处的信息数据是指请求发布至区块链网络,但尚未形成区块的原始数据,例如可以是业务数据、交易数据等等。这些原始数据需要进一步加工(例如经过区块链网络中各节点的验证、进行散列运算等)才能被写入区块内。Merkle树是区块链技术的重要组成部分,区块链不会直接保存明文的原始数据,原始数据需要被执行散列运 算,以散列值的方式被存储。默克尔树就用于将多个原始数据经散列运算形成的散列值按照二叉树结构组织起来,保存在区块的块体中。
(2)区块位于层级102。区块即数据块,底层101的信息数据经过进一步加工之后被写入至层级102中的区块内。多个区块按序连接成链式结构,即形成区块链,链式结构中,前一区块与相邻的后一区块具备父子关系。图2示出了本申请一个示例性实施例提供的区块链的结构示意图;如图2所示,区块i-1(i为正整数)、区块i和区块i+1按序连接成链式结构。其中,区块i分为区块头和区块体两部分,区块头包含前一区块i-1的摘要值及本区块i的摘要值(即本区块的默克尔(Merkle)根)。区块体包含本区块i的完整数据,并以Merkle树的形式组织在一起。区块i-1与区块i具备父子关系,即区块i-1是区块i的父区块,区块i是区块i-1的子区块。同理,区块i是区块i+1的父区块,区块i+1是区块i的子区块。
(3)区块链所遵循的协议与机制位于层级103。这些协议可包括:P2P(Peer-to-Peer,对等式网络)协议;机制可包括但不限于:广播机制、共识机制(包括PoW(Proof Of Work,工作量证明)机制、POS(Proof Of Stake,权益证明)机制等核心机制)。
(4)区块链网络位于层级104。区块链网络由多个节点设备组成;节点设备可以为计算机设备,可包括但不限于:PC(Personal Computer,个人计算机)、服务器、矿机、智能手机、平板电脑、移动计算机等等。区块链网络中的各个节点设备以P2P方式组网,节点设备与节点设备之间按照P2P协议相互通信;各个节点设备共同遵循广播机制、共识机制(包括PoW机制、POS机制等核心机制),共同保证区块链上的数据的不可篡改、不可伪造性,同时实现区块链的去中心化、去信任化等特性。
(5)智能合约位于上层105。智能合约是一组情景应对型的程序化规则和逻辑,是部署在区块链上的去中心化、可信息共享的程序代码。签署合约的各参与方就合约内容达成一致,以智能合约的形式部署在区块链中,即可不依赖任何中心机构自动化地代表各签署方执行合约。
区块链的类型可包括:公有链(Public Blockchain)、私有链(Private Blockchain)和联盟链(Consortium Blockchain)。公有链对外公开,任何人可 以加入并访问区块链;公有链上的区块可以被任何人查看,任何人也可以在公有链上发起交易,还可以随时参与公有链的共识过程。私有链仅在私有组织内部使用,区块链上的读写权限、参与记账权限按私有组织规则来制定;通常用于企业内部的数据管理、审计等。联盟链仅限于联盟成员参与,区块链上的读写权限、参与记账权限按联盟规则来制定;一般用于机构间的交易、结算或清算等场景。图1所示的区块链的基础架构是各种类型的区块链的发展基础,可以理解的是,不同类型的区块链对应的区块链网络的组网方式也会有一些差异。由于区块链具备去中心化、分布式存储、数据的不可篡改、不可伪造等特性,越来越多的业务活动(例如借贷活动、金融交易活动)基于区块链技术展开,以利用区块链的特性来保证业务活动的公平性和公开性。
图3示出了本申请一个示例性实施例提供的一种区块链网络的架构示意图;该区块链网络包括多个节点设备(图中以7个节点设备为例进行说明);如图4所示,节点设备1和节点设备2为共识节点设备,而节点设备3至节点设备7均为同步节点设备。其中,共识节点设备是指不仅能够执行区块同步过程,同时还能够参与区块共识过程的节点设备;同步节点设备是仅能够执行区块同步过程,并不能参与区块共识过程的节点设备。
区块链是一种分布式的应用模式,区块链网络中的每个节点设备各自存储有一条区块链;具体地:在图3所示的区块链网络中,节点设备1在该节点设备1的存储空间中存储区块链1,节点设备2在该节点设备2的存储空间中存储区块链2,节点设备3在该节点设备3的存储空间中存储区块链3,以此类推。由于网路连接性能差异、处理性能差异、加入区块链网络的时间差异等原因,区块链网络中的节点设备所存储的区块链之间会出现差异,区块链网络中的各个节点设备需要通过同步等手段来保持各个节点设备所存储的区块链之间的一致性。例如:区块链网络中已存在n(n为正整数)个节点设备,某个节点设备n+1新加入至区块链网络中,对于该节点设备n+1而言,其存储空间中尚未保存任何区块,该节点设备n+1的区块链n+1的区块高度为0,而对已存在于区块链网络中的节点设备n则可能已存储了10001个区块,该节点设备n的存储空间所存储的区块链n的区块高度可能为10000,那么,节点设备n+1落后于节点设备n,该节点设备n+1需要执行区块同步过程,获取区块高度0至区块高度10000之间的 所有区块来更新自己的区块链n+1,以追赶上节点设备n。实际应用中,区块链网络中产生的新区块需要先由共识节点设备进行共识,共识成功之后由共识节点设备将该新区块添加至该共识节点设备本地存储的区块链上,区块链网络中的同步节点设备再从共识节点设备处获取该新区块并添加至该同步节点设备本地存储的区块链上,完成区块同步过程。基于此,通常认可共识节点设备中存储的区块链是区块链网络中最长(或最完整)的区块链,可以将共识节点设备存储的区块链作为同步处理过程中的参考区块链。
基于图3所示的区块链网络的架构,本申请实施例提出一种同步处理方案,该方案引入骨架(Framework)的概念。图4示出了本申请一个示例性实施例提供的一种骨架的结构示意图;骨架是一种数据结构。一个骨架包含多个数据单元401,每个数据单元用于存储一个区块。参见图4所示的例子,设区块链网络中的任一节点设备(假设是图3所示的节点设备3)需要同步区块1至区块100这100个区块,那么该节点设备3的同步处理流程可包括如下步骤(1)-(4):
(1)根据待同步的区块构建骨架集合,该骨架集合中包含一个或多个骨架。
如图4所示,设骨架集合中共包括10个骨架,每个骨架均包括10个数据单元401,这些数据单元401被预留以在该节点设备3获取到同步区块之后,用来存储这些同步区块;以骨架1为例:骨架1包括10个数据单元401,这些数据单元按序排列,第一个数据单元用于存储区块1,第二个数据单元用来存储区块2,以此类推。骨架集合中,每个骨架包括的数据单元的数量可以相同,如图4所示每个骨架均可包括10个数据单元;当然,各个骨架包括的数据单元数量也可以不同,例如图4中骨架1可包括10个数据单元,骨架2可包括5个数据单元,骨架3可包括15个数据单元,等等。节点设备3可以根据实际情况来设置骨架的数量及骨架包括的数据单元的数量,此处的实际情况可包括但不限于:备选节点集中的节点设备的数量和处理能力、节点设备3的实际并发处理能力等等。
(2)为骨架集合创建同步任务集合,该同步任务集合中包含一个或多个同步任务;一个骨架对应一个同步任务。
如图4所示,骨架1对应同步任务1,骨架2对应同步任务2,骨架3对应同步任务3,以此类推。每个骨架对应的同步任务用于指示返回该骨架用于存储的 多个区块,例如:骨架1对应的同步任务1用于指示向节点设备3返回骨架1用于存储的区块1-区块10;再如:骨架2对应的同步任务2用于指示向节点设备3返回骨架2用于存储的区块11-区块20。可以理解的是,同步任务中携带指示信息,该指示信息可以包括骨架中首尾两个数据单元对应的区块的索引,此处的索引可以是区块的哈希值,或者是区块的生成时间戳,或者是区块对应的区块高度。这样当其他节点设备接收到该同步任务之后,则根据指示信息中的两个区块的索引向该节点设备3返回该骨架中该两个区块及两个区块之间的所有区块。该指示信息也可以包括骨架用于存储的所有区块的索引,这样当其他节点设备接收到该同步任务之后,则根据所需的所有区块的索引向该节点设备3返回所需的所有区块。
(3)选择第二节点设备,该第二节点设备是指区块链网络中与第一节点设备相连接的、用于执行同步任务的至少一个节点设备。
首先确定备选节点集,备选节点集中包含的是与节点设备3直接相连接的备选节点设备。如图3所示,节点设备3的备选节点集中包括节点设备1、节点设备4-节点设备7。由于节点设备1是共识节点设备,还需执行共识任务,因此为了避免给节点设备1造成处理负担,同时为了提升同步效率,可以从备选节点集中选择节点设备4-节点设备7作为第二节点设备来执行同步任务。其次再为每个同步任务匹配相应的第二节点设备,这里的匹配主要有如下策略:
策略一:按照存储情况匹配。将同步任务匹配给存储有相应区块的第二节点设备;例如:同步任务1要求同步区块1-区块10,那么选择存储有区块1-区块10的第二节点设备来执行同步任务1;再如:同步任务2要求同步区块81-区块90,那么选择存储有区块81-区块90的第二节点设备来执行同步任务2。
策略二:按照处理性能匹配。可按照处理性能从多个第二节点设备中选择一个来执行某个同步任务。例如:节点设备4的处理性能优于节点设备5,可以选择节点设备4来执行同步任务1。处理性能包括但不限于CPU处理速度、并发处理量、网路带宽资源等等。处理性能越高,表示执行度越高,越能够快速执行同步任务。
策略三:按照信任度匹配。信任度是指用于描述节点设备可信任的程度的信息,信任度越高,表示该节点设备可信任的程度越高,通常,官方机构所使 用的节点设备的信任度高于非官方机构所使用的节点设备的信任度。在一种实施方式中,信任度可以是采用分值来表示,例如信任度分值范围包括[0,10],信任度分值越高,则表示可信任程度越高。另一种实施方式中,信任度可以采用等级来表示,例如信任度等级包括高、中、低三个等级,该三个等级的可信任的程度依次降低。可按照信任度从多个第二节点设备中选择一个来执行某个同步任务。例如:节点设备4的信任度高于节点设备5,可以选择节点设备4来执行同步任务1。
一个同步任务由一个节点设备来执行,一个节点设备可执行多个同步任务。可以理解的是,上述策略并非穷举,本申请实施例还可适用于其他的策略,例如:随机匹配策略,即可以从多个第二节点设备中随机选取一个第二节点设备执行某个同步任务;再如:加权平均策略,即可以为多个影响因子(存储情况因子、信任度因子、处理性能因子)分别设置权重,按照加权平均的方式从多个第二节点设备中选择一个来执行该同步任务。另外,上述策略二和策略三中,如果被选择用于执行某个同步任务的第二节点设备本身并未存储该同步任务所指示的待同步的区块,该第二节点设备可以从区块链网络中的其他节点设备(如共识节点设备)处获取该区块并返回给第一节点设备,例如:同步任务1要求同步区块1-区块10,通过策略二或策略三选择节点设备4来执行同步任务1,但是该节点设备4中并未存储该区块1-区块10,那么该节点设备4可以从共识节点设备处获得该区块1-区块10并返回给第一节点设备。
(4)向第二节点设备并发多个同步任务,由第二节点设备来执行这些同步任务。
以图4所示为例,设同步任务1和同步任务3由节点设备4执行,同步任务2、同步任务4和同步任务6由节点设备5来执行,同步任务5、同步任务6和同步任务9由节点设备6来执行,同步任务7、同步任务8和同步任务10由节点设备7来执行。那么,节点设备3可以一次性并发这10个同步任务,第二节点设备(即节点设备4、节点设备5、节点设备6和节点设备7)可内部采用串行或并行方式来执行这些同步任务,将节点设备3所需的区块返回给节点设备3,从而使得节点设备3一次性同步处理过程就能获得所需同步的区块。
(5)将第二节点设备返回的区块填充至所述骨架集合中的各骨架中。
以图4所示为例,将节点设备4执行同步任务1返回的区块1-区块10填充至骨架1的各数据单元中;将节点设备4执行同步任务3返回的区块21-区块30填充至骨架3的各数据单元中。待各个骨架填充完整后,第一节点设备可将各个骨架中存储的区块按序(例如按各区块的生成时间戳的先后顺序)添加至第一节点设备的本地区块链上,从而实现了第一节点设备的本地区块链的更新。
需要说明的是,如果某个同步任务采用任何策略均未匹配到对应执行的第二节点设备,例如备选节点集中没有节点设备完整存储了某个骨架所需的区块;那么有可能骨架构建得不够合理,可以考虑重新构建骨架,重新更新同步任务;当然,也可以兼容现有的同步方式,将未匹配到节点设备的同步任务对应的骨架所需的区块逐个逐个的进行同步。
本申请实施例提出的这种骨架填充的同步处理方案,基于一个骨架对应的一个同步任务,可以一次性同步多个区块,有效地提高了同步处理效率;进一步,在一次同步处理过程中还可以并发多个骨架对应的同步任务,这样基于多个骨架可以一次性同步更多的区块,进一步提升了同步处理的效率。
图5示出了本申请一个示例性实施例提供的一种同步处理方法的流程图;该方法由区块链网络中的第一节点设备执行,该第一节点设备可以是区块链网络中的任一个节点设备,本申请后续实施例以第一节点设备是图3所示的区块链网络中的节点设备3为例进行说明。区块链网络包括备选节点集,备选节点集中包含多个与第一节点设备相连接的备选节点设备。该方法包括以下步骤S501-S504:
S501,获取骨架集合及同步任务集合,骨架集合用于存储第一节点设备待同步的M个区块;骨架集合中包含P个骨架,同步任务集合中包括P个同步任务,一个骨架对应一个同步任务;其中M、P均为正整数。
以骨架集合中的任一个骨架为例来说明,该任一个骨架表示为目标骨架;目标骨架包括N个数据单元,N个数据单元用于存储第一节点设备待同步的N个区块,N个区块与N个数据单元一一对应,N为正整数且N≤M。目标骨架中的N个数据单元按序排列,N个区块是区块链网络中的连续区块;N个数据单元中的第i个数据单元用于存储N个区块中的第i个区块;i为正整数且1≤i≤N。参见图4所示的示例,目标骨架可以是骨架1-骨架10中的任一个骨架,以目标 骨架为骨架1为例,N为10,目标骨架的第一个数据单元用于存储区块1,目标骨架的第二个数据单元用于存储区块2,以此类推。目标骨架对应目标同步任务,该目标同步任务中携带指示信息,该指示信息可以包括目标骨架中首尾两个数据单元对应的区块的索引,此处的索引可以是区块的哈希值,或者是区块的生成时间戳,或者是区块对应的区块高度。该指示信息也可以包括目标骨架用于存储的所有区块的索引。以目标骨架为图4所示的骨架1为例,目标同步任务可以包括指示信息,该指信息可以包括区块1和区块10的索引,也可以包括区块1-区块10的索引。
可以理解的是,本申请实施例中,目标骨架的数据单元按序排列仅为一种举例,目标骨架的数据单元也可以不按序排列;当然,目标骨架中所存储的N个区块也可以不是连续区块;或者,目标骨架中的数据单元也可以不用按序来存储N个区块;在此情况下,目标同步任务中包含的指示信息则包含N个区块的索引即可。
S502,从备选节点集中选取第二节点设备。
该第二节点设备是指备选节点集中用于执行同步任务的至少一个节点设备。本步骤可以采用上述的策略来选取第二节点设备,该策略可包括但不限于以下任一种:按照存储情况匹配方式来选取,按处理性能匹配方式来选择以及按照信任度匹配方式来选取。
S503,向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行同步任务并返回M个区块。
此处的并发包括一次性并发和分批次并发。所谓一次性并发是指第一节点设备可以一次性将该同步任务集合中的所有同步任务发送给第二节点设备,这样可以一次性同步所需的所有区块。所谓分批次并发是指第一节点设备对该同步任务集合中的同步任务进行批次划分,分批次并发这些同步任务。其中,批次划分方式例如可以是按照区块的顺序,索引在先的区块对应的同步任务的批次先于索引在后的区块对应的同步任务的批次。
S504,将M个区块填充至骨架集合中的各骨架中。
填充的过程是指将区块存储至对应的数据单元中的过程。第一节点设备会将第二节点设备返回的M个区块依次填充至各骨架的数据单元中。以目标骨架 为例,设目标骨架对应目标同步任务,目标骨架是骨架集合中的任一个,目标同步任务是同步任务集合中的任一个。目标第二节点设备是指S502为目标同步任务选取的一个第二节点设备;目标同步任务经S503发送至目标第二节点设备后,目标第二节点设备执行该目标同步任务,并向第一节点设备返回N个区块;则第一节点设备将该N个区块分别填充至所述目标骨架的N个数据单元中。
本申请实施例中,第一节点设备在进行同步处理时,获取骨架集合及同步任务集合,该骨架集合用于存储第一节点设备待同步的M个区块;从备选节点集中选取第二节点设备,该第二节点设备是备选节点集中的至少一个备选节点设备;向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行同步任务并返回M个区块;第一节点设备再将M个区块填充至骨架集合中的各骨架中。通过这种骨架填充的同步处理方式,基于一个骨架对应的一个同步任务,可以一次性同步多个区块,有效地提高了同步处理效率。在一次同步处理过程中可以并发多个骨架对应的同步任务,这样基于多个骨架可以一次性同步更多的区块,进一步提升了同步处理的效率。
图6示出了本申请另一个示例性实施例提供的一种同步处理方法的流程图;该方法由区块链网络中的第一节点设备执行,该第一节点设备可以是区块链网络中的任一个节点设备,本申请后续实施例以第一节点设备是图3所示的区块链网络中的节点设备3为例进行说明。区块链网络包括备选节点集,备选节点集中包含多个与第一节点设备相连接的备选节点设备。该方法包括以下步骤S601-S608:
S601,获取区块链网络中的参考区块链的区块高度,以及获取第一节点设备本地存储的第一区块链的区块高度。
参考区块链是指区块链网络中的各个节点设备存储的区块链中,最长(或最完整)的那条区块链,通常是指共识节点设备所存储的区块链。其中,区块高度用于表示连接在区块链上的区块数量。区块高度是区块的标志符,可用来指示区块在区块链中的位置;区块链中创始区块的区块高度默认为0,创始区块之后的第一个区块的区块高度为1(该第一个区块简称为区块1),创始区块之后的第二个区块的区块高度为2(该第二个区块简称区块2),以此类推。举例来说,参考区块链的当前区块的区块高度为100(此当前区块可简称为区块 100),这表示已经有100个区块被堆叠在创始区块之上了,即从创始区块到区块100之间形成的参考区块链上的区块数量为101个。
S602,将参考区块链的区块高度与第一区块链的区块高度之间相差的M个区块确定为第一节点设备待同步的区块,M为正整数。
假设参考区块链的区块高度为200,而第一区块链的区块高度为100,那么它们之间相差的100个区块包括区块101-区块200,这相差的100个区块则为第一节点设备待同步的区块,即此时M=100。
S603,根据M个区块构建骨架集合。该骨架集合中包含P个骨架,其中P为正整数。关于骨架集合的构建可以参见图4所示实例,在此不赘述。
S604,为骨架集合创建同步任务集合,该同步任务集合中包括P个同步任务,一个骨架对应一个同步任务。
S605,从备选节点集中选取第二节点设备,该第二节点设备是备选节点集中的至少一个备选节点设备。
一种实施方式中,对应于上述的策略一,即S605可以按照存储情况匹配方式来从备选节点集中选取第二节点设备。该S605的选取流程可包括以下步骤s21-s22:
s21,接收备选节点集中的各个备选节点设备的区块存储声明。
区块存储声明包括备选节点设备的区块存储情况,例如:某个备选节点设备的区块存储声明中包括区块1-区块10的索引,那么表示该备选节点设备声明其存储有区块1-区块10。
s22,根据备选节点集中的各个备选节点设备的区块存储声明从备选节点集中选择至少一个备选节点设备确定为第二节点设备。
本步骤中,针对某个同步任务,可以将声明存储有该同步任务所指示的区块的节点设备确定为执行该同步任务的第二节点设备,这样可以保证该第二节点设备有能力执行该同步任务并能够返回该同步任务所指示的区块。s21-s22按照区块存储情况来选取第二节点设备,可提升同步任务被成功执行的概率,提升同步处理的成功率。
一种实施方式中,对应于上述的策略二,即S605可以按照处理性能匹配方式来从备选节点集中选取第二节点设备。该S605的选取流程可包括以下 s23-s24:
s23,获取备选节点集中的各个备选节点设备的处理性能。
s24,将备选节点集中处理性能优于性能阈值的至少一个备选节点设备确定为第二节点设备。
s23-s24中,处理性能包括但不限于CPU处理速度、并发处理量、网路带宽资源等等。处理性能越高,表示执行度越高,则该第二节点设备能够更快速协助第一节点设备进行同步处理,这样可以提升同步处理的安全性。性能阈值可以根据实际情况进行设定,例如:性能阈值可以是备选节点集中各个备选节点设备的处理性能的平均值,即处理性能高于平均值的至少一个备选节点设备可以被确定为是第二节点设备。
一种实施方式中,对应于上述的策略三,即S605可以按照信任度匹配方式来从备选节点集中选取第二节点设备。该S605的选取流程可包括以下s25-s26:
s25,获取备选节点集中的各个备选节点设备的信任度。
s26,将备选节点集中信任度高于信任阈值的至少一个备选节点设备确定为第二节点设备。
s25-s26中,信任度用于描述节点设备可信任的程度,信任度越高,表示该节点设备更为可信。其中,信任阈值可以根据实际情况进行设定,例如信任阈值可以为5分,信任度分值高于5分的至少一个备选节点设备可以被确定为是第二节点设备。通过信任度来选择第二节点设备,这样可以防止一些恶意节点来干扰同步处理过程,提升同步处理的安全性。
S606,向所述第二节点设备并发同步任务集合中的同步任务,使所述第二节点设备执行同步任务并返回M个区块。
S607,将M个区块填充至所述骨架集合中的各骨架中。
S608,从各个骨架中读取各个数据单元存储的M个区块,并将读取的M个区块按序添加至第一节点设备本地存储的第一区块链上。
待各个骨架填充完整后,第一节点设备可将各个骨架中存储的区块按序(例如按各区块的生成时间戳的先后顺序)添加至第一节点设备的本地区块链上,从而实现了第一节点设备的本地区块链的更新。以目标骨架为例,第一节点设备从目标骨架中读取N个数据单元按序存储的N个区块,并将读取的N个 区块添加至第一节点设备本地存储的第一区块链上。骨架是一种数据结构,目标骨架中存储了N个区块后,将这N个区块顺序读取并依次添加至第一节点设备本地存储的第一区块链上,这样第一区块链上就成功更新了N个区块。当骨架集合中所有骨架的区块均被依次添加至第一区块链上后,第一节点设备即可完成所有区块的同步,及时追赶上区块链网络中的其他节点设备。
本申请实施例中,第一节点设备在进行同步处理时,获取骨架集合及同步任务集合,该骨架集合用于存储第一节点设备待同步的M个区块;从备选节点集中选取第二节点设备;向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行同步任务并返回M个区块;第一节点设备再将M个区块填充至骨架集合中的各骨架中。通过这种骨架填充的同步处理方式,基于一个骨架对应的一个同步任务,可以一次性同步多个区块,有效地提高了同步处理效率。在一次同步处理过程中可以并发多个骨架对应的同步任务,这样基于多个骨架可以一次性同步更多的区块,进一步提升了同步处理的效率。
图7示出了本申请一个示例性实施例提供的一种同步处理装置的结构示意图;该同步处理装置设于区块链网络中的第一节点设备中,具体的,该同步处理装置可以是运行于第一节点设备中的一个计算机程序(包括程序代码),例如该同步处理装置可以是第一节点设备中的一个应用软件;该同步处理装置可以用于执行图5-图6所示的实施例中的相应步骤。该第一节点设备可以是区块链网络中的任一个节点设备,例如该第一节点设备是图3所示的区块链网络中的节点设备。区块链网络包括备选节点集,备选节点集中包含多个与第一节点设备相连接的备选节点设备;如图7所示,该同步处理装置包括:
获取单元701,用于获取骨架集合及同步任务集合,骨架集合用于存储第一节点设备待同步的M个区块;骨架集合中包含P个骨架,同步任务集合中包括P个同步任务,所述P个骨架和所述P个同步任务一一对应;其中M、P均为正整数;
处理单元702,用于从备选节点集中选取第二节点设备,该第二节点设备是备选节点集中的至少一个备选节点设备;向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行同步任务并返回M个区块;以及将M个区块填充至骨架集合中的各骨架中。
一种实施方式中,骨架集合中包括目标骨架,目标骨架是P个骨架中的任一个;目标骨架包括N个数据单元,N个数据单元用于存储第一节点设备待同步的N个区块,N个区块与N个数据单元一一对应,N为正整数且N≤M。
一种实施方式中,目标骨架中的N个数据单元按序排列,N个区块是区块链网络中的连续区块;N个数据单元中的第i个数据单元用于存储N个区块中的第i个区块;i为正整数且1≤i≤N。
一种实施方式中,目标第二节点设备是指第二节点设备中的任一个;目标第二节点设备用于执行目标骨架对应的目标同步任务,并向第一节点设备返回N个区块;第一节点设备将N个区块填充至目标骨架的具体方式是:将N个区块分别填充至目标骨架的N个数据单元中。
一种实施方式中,处理单元702还用于:
从目标骨架中读取N个数据单元存储的N个区块,并将读取的N个区块按序添加至第一节点设备本地存储的第一区块链上。
一种实施方式中,处理单元702具体用于:
获取备选节点集中的各个备选节点设备的信任度;
将备选节点集中信任度高于信任阈值的至少一个备选节点设备确定为第二节点设备。
一种实施方式中,处理单元702具体用于:
获取备选节点集中的各个备选节点设备的处理性能;
将备选节点集中处理性能优于性能阈值的至少一个备选节点设备确定为第二节点设备。
一种实施方式中,处理单元702具体用于:
接收备选节点集中的各个备选节点设备的区块存储声明;
根据备选节点集中的各个备选节点设备的区块存储声明从备选节点集中选择至少一个备选节点设备确定为第二节点设备。
一种实施方式中,获取单元701具体用于:
获取区块链网络中的参考区块链的区块高度,以及获取第一节点设备本地存储的第一区块链的区块高度;
将参考区块链的区块高度与第一区块链的区块高度之间相差的M个区块 确定为第一节点设备待同步的区块;
根据M个区块构建骨架集合。
根据本申请的一个实施例,图7所示的同步处理装置中的各个单元可以分别或全部合并为一个或若干个另外的单元来构成,或者其中的某个(些)单元还可以再拆分为功能上更小的多个单元来构成,这可以实现同样的操作,而不影响本申请的实施例的技术效果的实现。上述单元是基于逻辑功能划分的,在实际应用中,一个单元的功能也可以由多个单元来实现,或者多个单元的功能由一个单元实现。在本申请的其它实施例中,该同步处理装置也可以包括其它单元,在实际应用中,这些功能也可以由其它单元协助实现,并且可以由多个单元协作实现。根据本申请的另一个实施例,可以通过在包括中央处理单元(CPU)、随机存取存储介质(RAM)、只读存储介质(ROM)等处理元件和存储元件的例如计算机的通用计算设备上运行能够执行如图5-图6所示的相应方法所涉及的各步骤的计算机程序(包括程序代码),来构造如图7中所示的同步处理装置,以及来实现本申请实施例的同步处理方法。计算机程序可以记载于例如计算机可读记录介质上,并通过计算机可读记录介质装载于上述计算设备中,并在其中运行。
本申请实施例中,第一节点设备在进行同步处理时,获取骨架集合及同步任务集合,该骨架集合用于存储第一节点设备待同步的M个区块;从备选节点集中选取第二节点设备,该第二节点设备是备选节点集中的至少一个备选节点设备;向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行同步任务并返回M个区块;第一节点设备再将M个区块填充至骨架集合中的各骨架中。通过这种骨架填充的同步处理方式,基于一个骨架对应的一个同步任务,可以一次性同步多个区块,有效地提高了同步处理效率。在一次同步处理过程中可以并发多个骨架对应的同步任务,这样基于多个骨架可以一次性同步更多的区块,进一步提升了同步处理的效率。
图8示出了本申请一个示例性实施例提供的一种同步处理设备的结构示意图。该同步处理设备是区块链网络中的第一节点设备,该第一节点设备可以是区块链网络中的任一个节点设备,例如该第一节点设备是图3所示的区块链网 络中的节点设备。区块链网络包括备选节点集,备选节点集中包含多个与第一节点设备相连接的备选节点设备。如图8所示,该同步处理设备至少包括处理器801、输入设备802、输出设备803以及计算机存储介质804。其中,处理器801、输入设备802、输出设备803以及计算机存储介质804可通过总线或者其它方式连接。计算机存储介质804可以存储在同步处理设备的存储器中,计算机存储介质804用于存储计算机程序,计算机程序包括程序指令,处理器801用于执行计算机存储介质804存储的程序指令。处理器801(或称CPU(Central Processing Unit,中央处理器))是同步处理设备的计算核心以及控制核心,其适于实现一条或多条指令,具体适于加载并执行一条或多条指令从而实现本申请实施例提供的相应方法流程或相应功能。
本申请实施例还提供了一种计算机存储介质(Memory),计算机存储介质是同步处理设备中的记忆设备,用于存放程序和数据。可以理解的是,此处的计算机存储介质既可以包括同步处理设备中的内置存储介质,当然也可以包括同步处理设备所支持的扩展存储介质。计算机存储介质提供存储空间,该存储空间存储了同步处理设备的操作系统。并且,在该存储空间中还存放了适于被处理器801加载并执行的一条或多条的指令,这些指令可以是一个或多个的计算机程序(包括程序代码)。需要说明的是,此处的计算机存储介质可以是高速RAM存储器,也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器;可选的还可以是至少一个位于远离前述处理器的计算机存储介质。
该计算机存储介质中存储有一条或多条指令;由处理器801加载并执行计算机存储介质中存放的一条或多条指令,以实现上述同步处理方法实施例中的相应步骤;具体实现中,计算机存储介质中的一条或多条指令由处理器801加载并执行如下步骤:
获取骨架集合及同步任务集合,骨架集合用于存储第一节点设备待同步的M个区块;骨架集合中包含P个骨架,同步任务集合中包括P个同步任务,所述P个骨架和所述P个同步任务一一对应;其中M、P均为正整数;
从备选节点集中选取第二节点设备,该第二节点设备是备选节点集中的至少一个备选节点设备;
向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行同步任务并返回M个区块;
将M个区块填充至骨架集合中的各骨架中。
一种实施方式中,骨架集合中包括目标骨架,目标骨架是P个骨架中的任一个;目标骨架包括N个数据单元,N个数据单元用于存储第一节点设备待同步的N个区块,N个区块与N个数据单元一一对应,N为正整数且N≤M。
一种实施方式中,目标骨架中的N个数据单元按序排列,N个区块是区块链网络中的连续区块;N个数据单元中的第i个数据单元用于存储N个区块中的第i个区块;i为正整数且1≤i≤N。
一种实施方式中,目标第二节点设备是指第二节点设备中的任一个;目标第二节点设备用于执行目标骨架对应的目标同步任务,并向第一节点设备返回N个区块;第一节点设备将N个区块填充至目标骨架的具体方式是:将N个区块分别填充至目标骨架的N个数据单元中。
一种实施方式中,计算机存储介质中的一条或多条指令由处理器801加载并且还执行如下步骤:
从目标骨架中读取N个数据单元存储的N个区块,并将读取的N个区块按序添加至第一节点设备本地存储的第一区块链上。
一种实施方式中,计算机存储介质中的一条或多条指令由处理器801加载并执行从备选节点集中选取第二节点设备的步骤时,具体执行如下步骤:
获取备选节点集中的各个备选节点设备的信任度;
将备选节点集中信任度高于信任阈值的至少一个备选节点设备确定为第二节点设备。
一种实施方式中,计算机存储介质中的一条或多条指令由处理器801加载并执行从备选节点集中选取第二节点设备的步骤时,具体执行如下步骤:
获取备选节点集中的各个备选节点设备的处理性能;
将备选节点集中处理性能优于性能阈值的至少一个备选节点设备确定为第二节点设备。
一种实施方式中,计算机存储介质中的一条或多条指令由处理器801加载并执行从备选节点集中选取第二节点设备的步骤时,具体执行如下步骤:
接收备选节点集中的各个备选节点设备的区块存储声明;
根据备选节点集中的各个备选节点设备的区块存储声明从备选节点集中选择至少一个备选节点设备确定为第二节点设备。
一种实施方式中,计算机存储介质中的一条或多条指令由处理器801加载并执行获取骨架集合的步骤时,具体执行如下步骤:
获取区块链网络中的参考区块链的区块高度,以及获取第一节点设备本地存储的第一区块链的区块高度;
将参考区块链的区块高度与第一区块链的区块高度之间相差的M个区块确定为第一节点设备待同步的区块;
根据M个区块构建骨架集合。
本申请实施例中,第一节点设备在进行同步处理时,获取骨架集合及同步任务集合,该骨架集合用于存储第一节点设备待同步的M个区块;从备选节点集中选取第二节点设备,该第二节点设备是备选节点集中的至少一个备选节点设备;向第二节点设备并发同步任务集合中的同步任务,使第二节点设备执行同步任务并返回M个区块;第一节点设备再将M个区块填充至骨架集合中的各骨架中。通过这种骨架填充的同步处理方式,基于一个骨架对应的一个同步任务,可以一次性同步多个区块,有效地提高了同步处理效率。在一次同步处理过程中可以并发多个骨架对应的同步任务,这样基于多个骨架可以一次性同步更多的区块,进一步提升了同步处理的效率。
本申请实施例还提供了一种包括指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述实施例提供的方法。
以上所揭露的仅为本申请较佳实施例而已,当然不能以此来限定本申请之权利范围,因此依本申请权利要求所作的等同变化,仍属本申请所涵盖的范围。

Claims (13)

  1. 一种同步处理方法,所述方法由区块链网络中的第一节点设备执行,所述区块链网络包括备选节点集,所述备选节点集中包含多个与所述第一节点设备相连接的备选节点设备,所述方法包括:
    获取骨架集合及同步任务集合,所述骨架集合用于存储所述第一节点设备待同步的M个区块;所述骨架集合中包含P个骨架,所述同步任务集合中包括P个同步任务,所述P个骨架和所述P个同步任务一一对应;其中M、P均为正整数;
    从所述备选节点集中选取第二节点设备,所述第二节点设备是所述备选节点集中的至少一个备选节点设备;
    向所述第二节点设备并发所述同步任务集合中的同步任务,使所述第二节点设备执行所述同步任务并返回所述M个区块;
    将所述M个区块填充至所述骨架集合中的各骨架中。
  2. 如权利要求1所述的方法,目标骨架是所述P个骨架中的任一个;
    所述目标骨架包括N个数据单元,所述N个数据单元用于存储所述第一节点设备待同步的N个区块,所述N个区块与所述N个数据单元一一对应,N为正整数且N≤M。
  3. 如权利要求2所述的方法,所述目标骨架中的N个数据单元按序排列,所述N个区块是所述区块链网络中的连续区块;
    所述N个数据单元中的第i个数据单元用于存储所述N个区块中的第i个区块;i为正整数且1≤i≤N。
  4. 如权利要求2所述的方法,目标第二节点设备是指第二节点设备中的任一个;所述目标第二节点设备用于执行所述目标骨架对应的目标同步任务,并向所述第一节点设备返回所述N个区块;
    针对所述目标第二节点设备,所述将所述M个区块填充至所述骨架集合中的各骨架中包括:
    将所述N个区块分别填充至所述目标骨架的N个数据单元中。
  5. 如权利要求4所述的方法,所述方法还包括:
    从所述目标骨架中读取所述N个数据单元存储的N个区块,并将读取的 所述N个区块按序添加至所述第一节点设备本地存储的第一区块链上。
  6. 如权利要求1-5任意一项所述的方法,所述从所述备选节点集中选取第二节点设备,包括:
    获取所述备选节点集中备选节点设备的信任度;
    将所述备选节点集中信任度高于信任阈值的至少一个备选节点设备确定为所述第二节点设备。
  7. 如权利要求1-5任意一项所述的方法,所述从所述备选节点集中选取第二节点设备,包括:
    获取所述备选节点集中备选节点设备的处理性能;
    将所述备选节点集中处理性能优于性能阈值的至少一个备选节点设备确定为所述第二节点设备。
  8. 如权利要求1-5任意一项所述的方法,所述从所述备选节点集中选取第二节点设备,包括:
    接收所述备选节点集中备选节点设备的区块存储声明;
    根据所述备选节点集中备选节点设备的区块存储声明从所述备选节点集中选择至少一个备选节点设备确定为所述第二节点设备。
  9. 如权利要求1-5任意一项所述的方法,所述获取骨架集合,包括:
    获取所述区块链网络中的参考区块链的区块高度,以及获取所述第一节点设备本地存储的第一区块链的区块高度;
    将所述参考区块链的区块高度与所述第一区块链的区块高度之间相差的M个区块确定为所述第一节点设备待同步的区块;
    根据所述M个区块构建所述骨架集合。
  10. 一种同步处理装置,所述同步处理装置设于区块链网络中的第一节点设备中,所述区块链网络包括备选节点集,所述备选节点集中包含多个与所述第一节点设备相连接的备选节点设备,所述同步处理装置包括:
    获取单元,用于获取骨架集合及同步任务集合,所述骨架集合用于存储所述第一节点设备待同步的M个区块;所述骨架集合中包含P个骨架,所述同步任务集合中包括P个同步任务,所述P个骨架和所述P个同步任务一一对应;其中M、P均为正整数;
    处理单元,用于从所述备选节点集中选取第二节点设备,所述第二节点设备是所述备选节点集中的至少一个备选节点设备;向所述第二节点设备并发所述同步任务集合中的同步任务,使所述第二节点设备执行所述同步任务并返回所述M个区块;以及将所述M个区块填充至所述骨架集合中的各骨架中。
  11. 一种同步处理设备,所述同步处理设备是区块链网络中的第一节点设备,所述区块链网络包括备选节点集,所述备选节点集中包含多个与所述第一节点设备相连接的备选节点设备;所述同步处理设备包括输入设备和输出设备,还包括:
    处理器,适于实现一条或多条指令;以及,
    计算机存储介质,所述计算机存储介质存储有一条或多条指令,所述一条或多条适于由所述处理器加载并执行如权利要求1-9任一项所述的同步处理方法。
  12. 一种计算机存储介质,所述计算机存储介质存储有一条或多条指令,所述一条或多条指令适于由处理器加载并执行如权利要求1-9任一项所述的同步处理方法。
  13. 一种包括指令的计算机程序产品,当其在计算机上运行时,使得所述计算机执行权利要求1-9任意一项所述的同步处理方法。
PCT/CN2021/075370 2020-03-24 2021-02-05 一种同步处理方法和相关装置 WO2021190179A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP21774939.9A EP4016323A4 (en) 2020-03-24 2021-02-05 SYNCHRONOUS PROCESSING METHOD AND RELATED APPARATUS
JP2022523680A JP2022553963A (ja) 2020-03-24 2021-02-05 同期処理方法及び関連装置
US17/721,231 US20220237153A1 (en) 2020-03-24 2022-04-14 Synchronization processing method and related apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010212529.5 2020-03-24
CN202010212529.5A CN111444203B (zh) 2020-03-24 2020-03-24 一种同步处理方法、装置、设备及介质

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/721,231 Continuation US20220237153A1 (en) 2020-03-24 2022-04-14 Synchronization processing method and related apparatus

Publications (1)

Publication Number Publication Date
WO2021190179A1 true WO2021190179A1 (zh) 2021-09-30

Family

ID=71629527

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/075370 WO2021190179A1 (zh) 2020-03-24 2021-02-05 一种同步处理方法和相关装置

Country Status (5)

Country Link
US (1) US20220237153A1 (zh)
EP (1) EP4016323A4 (zh)
JP (1) JP2022553963A (zh)
CN (1) CN111444203B (zh)
WO (1) WO2021190179A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111444203B (zh) * 2020-03-24 2021-09-28 腾讯科技(深圳)有限公司 一种同步处理方法、装置、设备及介质
CN114338724A (zh) * 2021-12-31 2022-04-12 支付宝(杭州)信息技术有限公司 一种区块同步方法、装置、电子设备和存储介质
CN115086350B (zh) * 2022-06-13 2024-01-19 亿度科创(深圳)有限公司 一种区块链节点数据同步方法、设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107332876A (zh) * 2017-05-31 2017-11-07 深圳前海微众银行股份有限公司 区块链状态的同步方法及装置
CN109522362A (zh) * 2018-10-17 2019-03-26 北京瑞卓喜投科技发展有限公司 基于区块链数据的非完全数据同步方法、系统及设备
CN110011788A (zh) * 2019-04-10 2019-07-12 深圳市网心科技有限公司 一种基于区块链的数据处理方法、系统及相关设备
US20190349185A1 (en) * 2018-05-09 2019-11-14 Samsung Sds Co., Ltd. Block generation method in blockchain-based system
CN110569305A (zh) * 2019-08-27 2019-12-13 网易(杭州)网络有限公司 区块同步方法、装置、介质和计算设备
CN111444203A (zh) * 2020-03-24 2020-07-24 腾讯科技(深圳)有限公司 一种同步处理方法、装置、设备及介质

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111614655A (zh) * 2017-03-24 2020-09-01 创新先进技术有限公司 一种共识校验的方法及装置
CN107908472A (zh) * 2017-09-30 2018-04-13 平安科技(深圳)有限公司 数据同步装置、方法及计算机可读存储介质
US11018850B2 (en) * 2017-12-26 2021-05-25 Akamai Technologies, Inc. Concurrent transaction processing in a high performance distributed system of record
CN108848184B (zh) * 2018-06-29 2020-08-28 北京金山安全软件有限公司 一种基于信任机制的区块链节点同步方法及装置
CN109361734B (zh) * 2018-09-18 2021-04-20 百度在线网络技术(北京)有限公司 一种区块链的数据处理方法、装置、设备及介质
CN109274754B (zh) * 2018-10-11 2021-05-04 上海保险交易所股份有限公司 用于在区块链网络中同步数据的方法、设备和存储介质
CN109586934A (zh) * 2018-12-27 2019-04-05 链极智能科技(上海)有限公司 一种区块链底层网络交易同步优化方法
US11080144B2 (en) * 2019-01-25 2021-08-03 Coinbase, Inc. System and method for managing blockchain nodes
CN110430087B (zh) * 2019-09-16 2022-04-05 上海保险交易所股份有限公司 区块链热升级的架构设计与实现
CN110851535B (zh) * 2019-11-18 2021-07-13 腾讯科技(深圳)有限公司 基于区块链的数据处理方法、装置、存储介质及终端

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107332876A (zh) * 2017-05-31 2017-11-07 深圳前海微众银行股份有限公司 区块链状态的同步方法及装置
US20190349185A1 (en) * 2018-05-09 2019-11-14 Samsung Sds Co., Ltd. Block generation method in blockchain-based system
CN109522362A (zh) * 2018-10-17 2019-03-26 北京瑞卓喜投科技发展有限公司 基于区块链数据的非完全数据同步方法、系统及设备
CN110011788A (zh) * 2019-04-10 2019-07-12 深圳市网心科技有限公司 一种基于区块链的数据处理方法、系统及相关设备
CN110569305A (zh) * 2019-08-27 2019-12-13 网易(杭州)网络有限公司 区块同步方法、装置、介质和计算设备
CN111444203A (zh) * 2020-03-24 2020-07-24 腾讯科技(深圳)有限公司 一种同步处理方法、装置、设备及介质

Also Published As

Publication number Publication date
JP2022553963A (ja) 2022-12-27
US20220237153A1 (en) 2022-07-28
CN111444203A (zh) 2020-07-24
EP4016323A4 (en) 2022-11-30
EP4016323A1 (en) 2022-06-22
CN111444203B (zh) 2021-09-28

Similar Documents

Publication Publication Date Title
US11956357B2 (en) Traceable key block-chain ledger
WO2021190179A1 (zh) 一种同步处理方法和相关装置
JP7362654B2 (ja) 分割されたブロックチェーンネットワークにおけるブロックチェーンのブロックの維持管理
EP3659086B1 (en) Computer-implemented system and method for managing a large distributed memory pool in a blockchain network
US11190525B2 (en) Blockchain system and permission management method thereof
CN111061769B (zh) 一种区块链系统的共识方法及相关设备
US11157487B2 (en) Trusted storage method and system based on directed acyclic graph structure
CN112396423A (zh) 一种交易数据处理方法、装置、设备及存储介质
US11676135B2 (en) Blockchain consensus protocol using predictive proof of metrics
EP4300323A1 (en) Data processing method and apparatus for blockchain network, computer device, computer readable storage medium, and computer program product
CN109948003B (zh) 一种同构双模主副链的区块链系统及其区块生产方法
CN111163148B (zh) 一种区块链系统的共识状态的同步方法及相关设备
CN110941676B (zh) 一种配置方法、装置、设备及介质
CN111444204B (zh) 一种同步处理方法、装置、设备及介质
US20230370285A1 (en) Block-chain-based data processing method, computer device, computer-readable storage medium
JP2022551874A (ja) セキュアな共生(Symbiosis)マイニングのための方法および装置
Du et al. Biecs: A blockchain-based intelligent edge cooperation system for latency-sensitive services
Li et al. A survey of state-of-the-art sharding blockchains: Models, components, and attack surfaces
Tang et al. Hedera: a permissionless and scalable hybrid blockchain consensus algorithm in multi-access edge computing for iot
CN111444206B (zh) 一种同步处理方法、装置、设备及介质
Yao et al. Sok: A taxonomy for critical analysis of consensus mechanisms in consortium blockchain
CN116701452A (zh) 数据处理方法、相关设备、存储介质及程序产品
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
Luan et al. Modeling and Verification of CKB Consensus Protocol in Coq

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21774939

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021774939

Country of ref document: EP

Effective date: 20220318

ENP Entry into the national phase

Ref document number: 2022523680

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE