WO2021184873A1 - 用于区块链网络中的数据同步的方法、装置和计算设备 - Google Patents

用于区块链网络中的数据同步的方法、装置和计算设备 Download PDF

Info

Publication number
WO2021184873A1
WO2021184873A1 PCT/CN2020/139308 CN2020139308W WO2021184873A1 WO 2021184873 A1 WO2021184873 A1 WO 2021184873A1 CN 2020139308 W CN2020139308 W CN 2020139308W WO 2021184873 A1 WO2021184873 A1 WO 2021184873A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
data
blocks
blockchain network
nodes
Prior art date
Application number
PCT/CN2020/139308
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 支付宝(杭州)信息技术有限公司
Publication of WO2021184873A1 publication Critical patent/WO2021184873A1/zh

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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/275Synchronous replication

Definitions

  • the embodiments of this specification relate to blockchain technology, and in particular, to a method, device, and computing device for data synchronization in a blockchain network.
  • Blockchain technology also known as distributed ledger technology, is an emerging technology in which several nodes participate in “bookkeeping” and jointly maintain a complete distributed database. Due to the various characteristics of blockchain technology such as decentralization, openness and transparency, and non-tamperability, blockchain technology has been widely used in many fields.
  • the embodiments of this specification provide a method, device and computing device for data synchronization in a blockchain network.
  • the embodiment of this specification provides a method for data synchronization in a blockchain network, which includes: starting from the i-th block of the N blocks that need to be synchronized, sending data to the blockchain Other nodes in the network initiate data requests to obtain the data of the N blocks, where N is a positive integer greater than 1, and i is a positive integer less than or equal to N; receiving the N blocks from the other node
  • the data of the j-th block in the block wherein the data of the j-th block includes a data correctness certificate for verifying the validity of the data of the j-th block, and j is less than or equal to A positive integer of N; verify the validity of the data of the j-th block based on the proof of data correctness included in the data of the j-th block; If the legality verification of is passed, the data of the j-th block is stored.
  • the embodiment of the present specification provides a device for data synchronization in a blockchain network, including: a data request unit, configured to retrieve the i-th zone from the N blocks that need to be synchronized.
  • a data request is initiated to other nodes in the blockchain network to obtain the data of the N blocks, where N is a positive integer greater than 1, and i is a positive integer less than or equal to N;
  • the receiving unit Is used to receive data of the j-th block in the N blocks from the other nodes, wherein the data of the j-th block includes the legality used to verify the data of the j-th block
  • the correctness of the data is proof, j is a positive integer less than or equal to N;
  • the verification unit is used to verify the jth block based on the data correctness proof included in the data of the jth block The legality of the data;
  • the storage unit is used to store the data of the j-th block when the verification unit passes the legality verification of the data of the
  • the embodiment of this specification provides a computing device, including: at least one processor; When the at least one processor is executed, the at least one processor implements the foregoing method.
  • a data request can be initiated from any of the multiple blocks that need to be synchronized, and when the data of any one of the blocks is received, it can be based on the data in the block.
  • the carried data correctness certificate is used to verify the legality of the data of the block, so that when the legality verification is passed, the data synchronization for the block can be completed.
  • Fig. 1 is a schematic flowchart of a method for data synchronization in a blockchain network according to an embodiment.
  • Fig. 2 is a schematic block diagram of an apparatus for data synchronization in a blockchain network according to an embodiment.
  • Fig. 3 is a hardware structure diagram of a computing device used for data synchronization in a blockchain network according to an embodiment.
  • the blockchain network is a new distributed infrastructure. For example, it can usually be built on a peer-to-peer network, using a chained data structure to store and verify data, using a consensus protocol between distributed nodes to ensure the consistency of data update results, and using a cryptographic scheme to ensure the inability of data. Tampering and the security of transmission and access, as well as the use of smart contracts composed of automated script codes to program and manipulate data.
  • the chain data structure usually refers to a form of data organization.
  • state transition records for example, they can also be called transactions
  • Consensus agreement usually refers to a set of agreements used in the blockchain network to ensure that each participating node can independently keep accounts while reaching a consensus on the final accounting result.
  • Common consensus protocols can include non-deterministic consensus protocols and deterministic consensus protocols.
  • a non-deterministic consensus protocol may include a Proof of Work (PoW) protocol, a Proof of Stake (PoS) protocol, and so on.
  • the deterministic consensus protocol may include Practical Byzantine Fault Tolerance (PBFT), HoneyBadgerBFT protocol, etc.
  • blockchain networks can usually include public chain networks, private chain networks, and consortium chain networks.
  • Public chain networks can usually adopt non-deterministic consensus protocols, while private chain networks and alliance chain networks can usually adopt deterministic consensus protocols.
  • each node can ensure the consistency of their data through a consensus protocol.
  • the data of the node may lag behind other normal nodes, that is, the block data of the node and other reasons.
  • the block data of normal nodes is inconsistent.
  • the local optimal block number of the node may be X
  • the current optimal block number of the blockchain network may be Y.
  • the node needs to perform the block number X+1 to the Yth block. Data synchronization for each block.
  • the embodiments of this specification provide a technical solution for data synchronization in a blockchain network.
  • the data of the block may include a proof of correctness of the data for the block.
  • the legality of the data of each block can be independently verified without relying on the data of other blocks.
  • a data request can be initiated from any of the N blocks that need to be synchronized, and when the data of any block is received, it can be based on the data in that block.
  • the proof of the correctness of the data carried is used to independently verify the legality of the data in the block. Once the legality verification is passed, the data of the block can be stored to complete the data synchronization for the block.
  • Fig. 1 is a schematic flowchart of a method for data synchronization in a blockchain network according to an embodiment.
  • the method in FIG. 1 can be executed by a node whose data is lagging in the blockchain network.
  • step 102 starting from the i-th block among the N blocks that need to be synchronized, a data request can be initiated to other nodes in the blockchain network to obtain N blocks The data.
  • N is a positive integer greater than 1
  • i is a positive integer less than or equal to N.
  • step 104 the data of the j-th block among the N blocks is received from other nodes, where the data of the j-th block includes data correctness for verifying the validity of the data of the j-th block Prove that j is a positive integer less than or equal to N.
  • step 106 the legitimacy of the data of the jth block is verified based on the data correctness proof included in the data of the jth block.
  • step 108 if the legality verification of the data of the j-th block is passed, the data of the j-th block is stored.
  • a data request can be initiated from any of the multiple blocks that need to be synchronized, and when the data of any one of the blocks is received, it can be based on the data in the block.
  • the carried data correctness certificate is used to verify the legality of the data of the block, so that when the legality verification is passed, the data synchronization for the block can be completed.
  • the technical solution of this specification can be preferably applied to a consortium chain network adopting a deterministic consensus protocol.
  • step 102 it is possible to determine the N blocks that need to be synchronized by checking the local current optimal block number of the node and the current optimal block number of the blockchain network. For example, assuming that the current optimal block number of the node is X, and the current optimal block number of the blockchain network is Y, then it is necessary to synchronize data from block X+1 to block Y. Here, it can be assumed that from There are N blocks in total from block X+1 to block Y. The current optimal block number of the blockchain network can be obtained from other nodes in the blockchain network.
  • step 102 multiple methods may be adopted to implement the data request.
  • step 102 starting from the first block, request data from the first block to the Nth block.
  • the block data can be requested in a one-time or batch manner.
  • the specific request method can be selected according to various factors such as actual needs, network conditions, node conditions, etc., which is not limited in this specification.
  • the first block to the Nth block can be divided into multiple groups of blocks.
  • Each group of blocks can include the same number of blocks or different numbers of blocks.
  • the embodiments of this specification do not limit this.
  • the data of these multiple sets of blocks can be requested separately. For example, suppose N is 800, that is, there are 800 blocks that need to be synchronized.
  • 800 blocks are divided into 8 groups of blocks, and each group includes 100 blocks. In this way, it is possible to request the data of the 1-100th block from other nodes, request the data of the 101-200th block, and so on, until the data of the 701-800th block is requested.
  • the data request for each group of blocks may not be initiated at the same time.
  • step 102 the data request will be initiated from the middle block among the N blocks. For example, starting from the i-th block, a data request can be initiated according to the increasing direction of the block number.
  • the data from the i-th block to the N-th block can also be requested in a one-time or batch manner.
  • the i-th block to the N-th block can also be divided into multiple groups of blocks. Then, you can request the data of these multiple blocks separately. The data requests for these multiple sets of blocks may not be sent at the same time. For example, assuming that N is 800, that is, there are 800 blocks that need to be synchronized; and assuming that i is 401, then in step 102, a data request will be initiated from the 401th block. If the 401th block to the 800th block are divided into 4 groups of blocks, each group includes 100 blocks, you can request the data of the 401-500th block and the 501-600th block from other nodes respectively Block data, and so on, until the 701-800th block data is requested.
  • the data request for the first block to the i-1th block may be initiated.
  • the data request can be initiated from the i-th block in the direction in which the block number increases, and at the same time from the i-1th block in the decreasing direction of the block number To initiate a data request.
  • data requests can be initiated simultaneously from two directions. It can be seen that this embodiment can further improve the efficiency of data synchronization in the blockchain network.
  • N 800 and i is 401. Then, while requesting data of at least one of the 401-800th blocks from other nodes, it is also possible to request data of at least one of the 1-400th blocks from other nodes.
  • the data request can also be initiated from the i-th block in the decreasing direction of the block number. That is, it is possible to request data from the first block to the i-th block from other nodes.
  • the data of the first block to the i-th block may also be requested in a one-time or batch manner. For the specific manner, refer to the above description, and will not be repeated here.
  • the data request for the i+1th block to the Nth block may be initiated.
  • the data request can be initiated from the i-th block in the decreasing direction of the block number, and at the same time from the i+1th block, in the decreasing direction of the block number.
  • data requests can be initiated simultaneously from two directions. It can be seen that this embodiment can further improve the efficiency of data synchronization in the blockchain network.
  • the starting block and the number of blocks requested can be preset or dynamically adjusted. This can be set or adjusted based on various factors such as actual demand, network conditions, node load, and so on.
  • the N blocks can include the next block of the current optimal block in the node's local area to the current optimal block of the blockchain network.
  • the first block to the Nth block that need to be synchronized can be the next block of the current optimal block locally to the current optimal block of the blockchain network.
  • the node after the node completes the data synchronization of the latest block (that is, the current optimal block of the blockchain network), the node can participate in the normal consensus process of the blockchain network. Then, in one embodiment, the latest block in the blockchain network may be requested first. Specifically, in step 102, a request message may be sent to other nodes, and the request message may be used to request the latest block in the N blocks.
  • the data of the first group of blocks, the first group of blocks may include from the i-th block to the N-th block. And the Nth block can be the current optimal block of the blockchain network.
  • step 104 it is assumed that the j-th block is the current optimal block of the blockchain network.
  • step 108 the data of the current optimal block of the blockchain network can be stored when the legality verification of the data of the current optimal block of the blockchain network is passed.
  • the node since the data synchronization of the current optimal block of the blockchain network has been completed, the node can participate in the normal consensus process of the blockchain network regardless of whether the data synchronization of other blocks has been completed. In this way, nodes with lagging data can participate in the normal consensus process as soon as possible, thereby greatly reducing the performance impact of data synchronization on the node.
  • Fig. 2 is a schematic block diagram of an apparatus for data synchronization in a blockchain network according to an embodiment.
  • the device 200 in FIG. 2 may be a node whose data is lagging behind or a component of the node.
  • the apparatus 200 may include a data request unit 202, a receiving unit 204, a verification unit 206, and a storage unit 208.
  • the data request unit 202 may initiate a data request to other nodes in the blockchain network from the i-th block among the N blocks that need to be synchronized, so as to obtain the data of the N blocks.
  • N is a positive integer greater than 1
  • i is a positive integer less than or equal to N.
  • the receiving unit 204 may receive data of the j-th block among the N blocks from other nodes, where the data of the j-th block includes a data correctness certificate for verifying the legality of the data of the j-th block , J is a positive integer less than or equal to N.
  • the verification unit 206 may verify the legitimacy of the data of the jth block based on the data correctness proof included in the data of the jth block.
  • the storage unit 208 stores the data of the jth block when the verification unit passes the legality verification of the data of the jth block.
  • a data request can be initiated from any of the multiple blocks that need to be synchronized, and when the data of any one of the blocks is received, it can be based on the data in the block.
  • the carried data correctness certificate is used to verify the legality of the data of the block, so that when the legality verification is passed, the data synchronization for the block can be completed.
  • the data request unit 202 may initiate data requests to other nodes in the direction of increasing block numbers starting from the i-th block. In addition, at the same time as the data request initiated from the i-th block, the data request unit 202 can initiate data requests to other nodes in the direction of decreasing block number starting from the i-1th block, where: i is a positive integer greater than 1.
  • the first block to the Nth block in the N blocks are the next block of the local current optimal block to the current optimal block of the blockchain network.
  • the data request unit 202 may send a request message to other nodes, where the request message is used to request the data of the first group of blocks in the N blocks, and the first group of blocks includes the block from the i-th block to the blockchain network The current optimal block.
  • the j-th block may be the current optimal block of the blockchain network.
  • the device 200 may further include a consensus unit 210.
  • the consensus unit 210 may participate in the consensus process of the blockchain network after storing the data of the current optimal block of the blockchain network.
  • the blockchain network may be a consortium chain network adopting a deterministic consensus protocol.
  • Each unit of the device 200 can execute the corresponding steps in the method embodiment of FIG.
  • the above-mentioned apparatus 200 may be implemented by hardware or software, or may be implemented by a combination of software and hardware.
  • the apparatus 200 when the apparatus 200 is implemented by software, it can be formed by reading the corresponding executable instructions in the memory (such as non-volatile memory) into the memory by the processor of the device where it is located and running it.
  • the memory such as non-volatile memory
  • Fig. 3 is a hardware structure diagram of a computing device used for data synchronization in a blockchain network according to an embodiment.
  • the computing device 300 may include at least one processor 302, memory 304, memory 306, and communication interface 308, and at least one processor 302, memory 304, memory 306, and communication interface 308 are connected together via a bus 310.
  • At least one processor 302 executes at least one executable instruction (ie, the above-mentioned element implemented in the form of software) stored or encoded in the memory 304.
  • the executable instructions stored in the memory 304 when executed by the at least one processor 302, enable the computing device to implement the various processes described above in conjunction with FIG. 1.
  • the computing device 300 can be implemented in any suitable form in the art, for example, it includes but is not limited to a desktop computer, a laptop computer, a smart phone, a tablet computer, a consumer electronic device, a wearable smart device, and so on.
  • the embodiments of this specification also provide a machine-readable storage medium.
  • the machine-readable storage medium may store executable instructions, and the executable instructions, when executed by a machine, cause the machine to implement the specific process of the method embodiment described above with reference to FIG. 1.
  • machine-readable storage media may include, but are not limited to, random access memory (Random Access Memory, RAM), read-only memory (Read-Only Memory, ROM), and electrically erasable programmable read-only memory (Electrically-Erasable Programmable). Read-Only Memory, EEPROM), Static Random Access Memory (SRAM), hard disk, flash memory, etc.
  • RAM Random Access Memory
  • ROM read-only memory
  • EEPROM Electrically erasable programmable read-only memory
  • SRAM Static Random Access Memory
  • hard disk hard disk
  • flash memory etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

用于区块链网络中的数据同步的方法、装置和计算设备。该方法包括:从需要进行数据同步的N个区块中的第i个区块开始,向区块链网络中的其它节点发起数据请求,以便获得N个区块的数据;从其它节点接收N个区块中的第j个区块的数据,其中,第j个区块的数据包括用于验证第j个区块的数据的合法性的数据正确性证明;基于在第j个区块的数据中包括的数据正确性证明,来验证第j个区块的数据的合法性;在对第j个区块的数据的合法性验证通过的情况下,存储第j个区块的数据。

Description

用于区块链网络中的数据同步的方法、装置和计算设备 技术领域
本说明书的实施例涉及区块链技术,并且具体地,涉及用于区块链网络中的数据同步的方法、装置和计算设备。
背景技术
区块链技术,也被称为分布式账本技术,是一种由若干个节点共同参与“记账”,共同维护一份完整的分布式数据库的新兴技术。由于区块链技术具有去中心化、公开透明以及不可篡改等各种特性,使得区块链技术已经在众多的领域中得以广泛应用。
发明内容
考虑到现有技术的上述问题,本说明书的实施例提供了用于区块链网络中的数据同步的方法、装置和计算设备。
一方面,本说明书的实施例提供了一种用于区块链网络中的数据同步的方法,包括:从需要进行数据同步的N个区块中的第i个区块开始,向区块链网络中的其它节点发起数据请求,以便获得所述N个区块的数据,其中,N为大于1的正整数,i为小于或等于N的正整数;从所述其它节点接收所述N个区块中的第j个区块的数据,其中,所述第j个区块的数据包括用于验证所述第j个区块的数据的合法性的数据正确性证明,j为小于或等于N的正整数;基于在所述第j个区块的数据中包括的数据正确性证明,来验证所述第j个区块的数据的合法性;在对所述第j个区块的数据的合法性验证通过的情况下,存储所述第j个区块的数据。
另一方面,本说明书的实施例提供了一种用于区块链网络中的数据同步的装置,包括:数据请求单元,用于从需要进行数据同步的N个区块中的第i个区块开始,向区块链网络中的其它节点发起数据请求,以便获得所述N个区块的数据,其中,N为大于1的正整数,i为小于或等于N的正整数;接收单元,用于从所述其它节点接收所述N个区块中的第j个区块的数据,其中,所述第j个区块的数据包括用于验证所述第j个区块的数据的合法性的数据正确性证明,j为小于或等于N的正整数;验证单元,用于基于在所述第j个区块的数据中包括的数据正确性证明,来验证所述第j个区块的数据的合法性;存储单元,用于在所述验证单元对所述第j个区块的数据的合法性验证通过 的情况下,存储所述第j个区块的数据。
另一方面,本说明书的实施例提供了一种计算设备,包括:至少一个处理器;与所述至少一个处理器进行通信的存储器,其上存储有可执行指令,所述可执行指令在被所述至少一个处理器执行时使得所述至少一个处理器实现上述方法。
可见,在该技术方案中,可以从需要进行数据同步的多个区块中的任一区块发起数据请求,而在接收到其中任一区块的数据时,可以基于该区块的数据中携带的数据正确性证明来验证该区块的数据的合法性,这样在合法性验证通过时,就可以完成针对该区块的数据同步。由此,无需按照区块之间的单方向顺序来依次执行各个区块的数据同步,从而能够提高区块链网络中的数据同步效率。
附图说明
通过结合附图对本说明书的实施例的更详细的描述,本说明书的实施例的上述以及其它目的、特征和优势将变得更加明显,其中,在本说明书的实施例中,相同的附图标记通常代表相同的元素。
图1是根据一个实施例的用于区块链网络中的数据同步的方法的示意性流程图。
图2是根据一个实施例的用于区块链网络中的数据同步的装置的示意性框图。
图3是根据一个实施例的用于区块链网络中的数据同步的计算设备的硬件结构图。
具体实施方式
现在将参考各实施例讨论本文描述的主题。应当理解的是,讨论这些实施例仅是为了使得本领域技术人员能够更好地理解并且实现本文描述的主题,并非是对权利要求书中所阐述的保护范围、适用性或者示例的限制。可以在不脱离权利要求书的保护范围的情况下,对所讨论的元素的功能和排列进行改变。各个实施例可以根据需要,省略、替换或者添加各种过程或组件。
区块链网络是一种全新的分布式基础架构。例如,其通常可以构建在对等网络上,利用链式数据结构来存储和验证数据,利用分布式节点之间的共识协议来保证数据更新结果的一致性,利用密码学方案来保证数据的不可篡改以及传输和访问的安全,以及利用由自动化脚本代码组成的智能合约来编程和操作数据。
其中,链式数据结构通常是指一种数据组织形式。例如,可以将状态转移记录(例 如,其也可以被称为交易)以列表的形式存储在“区块”中,多个区块可以按照一定的逻辑顺序排列,每个区块的“区块头”可以包括表示前一个区块的摘要数据的数据字段,从而形成“链式数据结构”。
共识协议通常是指在区块链网络中用于确保各个参与节点能够独立记账的同时对最终记账结果达成一致的一组协议。常见的共识协议可以包括非确定性共识协议和确定性共识协议。例如,非确定性共识协议可以包括工作量证明(Proof of Work,PoW)协议、权益证明(Proof of Stake,PoS)协议等。确定性共识协议可以包括实用拜占庭容错(Practical Byzantine Fault Tolerance,PBFT)、HoneyBadgerBFT协议等。
就参与方的组织方式而言,区块链网络通常可以包括公有链网络、私有链网络和联盟链网络。公有链网络通常可以采用非确定性共识协议,而私有链网络和联盟链网络通常可以采用确定性共识协议。
如上所述,在区块链网络中,通常可以包括多个参与节点。各个节点之间可以通过共识协议来确保各自数据的一致性。然而,在某些情况下,比如因宕机而重启、网络抖动或新加入区块链网络等等各种原因,节点的数据可能会落后于其它正常节点,即该节点的区块数据与其它正常节点的区块数据不一致。例如,节点本地的最优区块号可能是X,而区块链网络的当前最优区块号可能是Y,在这种情况下,该节点需要对第X+1个区块至第Y个区块进行数据同步。
如上所述,由于各个区块之间存在顺序关联性,这样对某个区块的数据的验证可能需要结合前面区块的数据来完成,所以在对区块进行数据同步时,一般采用单方向顺序依次对各个区块进行数据同步。然而,这种方式可能耗时较长,效率较低。
因此,期望有一种机制来高效地实现节点的数据同步。
鉴于此,本说明书的实施例提供了一种用于区块链网络中的数据同步的技术方案。具体而言,在该技术方案中,区块的数据可以包括针对该区块的数据正确性证明。这样,各个区块的数据的合法性可以独立地验证,而无需依赖于其它区块的数据。那么,在数据同步过程中,可以从需要进行数据同步的N个区块中的任一区块开始发起数据请求,而在接收到任意一个区块的数据时,可以基于该区块的数据中携带的数据正确性证明,来独立地验证该区块的数据的合法性。一旦合法性验证通过,就可以将该区块的数据进行存储,从而完成针对该区块的数据同步。
可见,在该技术方案中,由于可以基于在区块的数据中携带的数据正确性证明来 独立地验证该区块的数据的合法性,而不依赖于其它区块的数据,这样无需按照区块之间的单方向顺序来逐个区块地完成数据同步,从而能够极大地提供区块链网络中的数据同步的效率。
下面将结合具体实施例来描述上述技术方案。
图1是根据一个实施例的用于区块链网络中的数据同步的方法的示意性流程图。例如,图1的方法可以由区块链网络中的数据落后的节点来执行。
如图1所示,在步骤102中,可以从需要进行数据同步的N个区块中的第i个区块开始,向区块链网络中的其它节点发起数据请求,以便获得N个区块的数据。其中,N为大于1的正整数,i为小于或等于N的正整数。
在步骤104中,从其它节点接收N个区块中的第j个区块的数据,其中,第j个区块的数据包括用于验证第j个区块的数据的合法性的数据正确性证明,j为小于或等于N的正整数。
在步骤106中,基于在第j个区块的数据中包括的数据正确性证明,来验证第j个区块的数据的合法性。
在步骤108中,在对第j个区块的数据的合法性验证通过的情况下,存储第j个区块的数据。
可见,在该技术方案中,可以从需要进行数据同步的多个区块中的任一区块发起数据请求,而在接收到其中任一区块的数据时,可以基于该区块的数据中携带的数据正确性证明来验证该区块的数据的合法性,这样在合法性验证通过时,就可以完成针对该区块的数据同步。由此,无需按照区块之间的单方向顺序来依次执行各个区块的数据同步,从而能够提高区块链网络中的数据同步效率。
在一个实施例中,本说明书的技术方案可以优选地适用于采用确定性共识协议的联盟链网络。
在一个实施例中,在步骤102中,可以通过检查节点本地当前最优区块号和区块链网络的当前最优区块号,来确定需要进行同步的N个区块。例如,假设节点本地当前最优区块号是X,而区块链网络的当前最优区块号是Y,那么需要对区块X+1到区块Y进行数据同步,此处可以假设从区块X+1到区块Y共有N个区块。区块链网络的当前最优区块号可以是从区块链网络中的其它节点获得的。
在一个实施例中,在步骤102中,可以采取多种方式来实现数据请求。
在一种方式中,可以从第i个区块开始,按照区块编号增大的方向来向其它节点请求数据。
在一种情况下,如果i为1,则在步骤102中,将从第1个区块开始,请求第1个区块至第N个区块的数据。此处,可以按照一次性或分批方式来请求区块数据。当然,具体的请求方式可以根据实际需求、网络状况、节点状况等等各种因素来选择,本说明书对此不作限定。
比如,可以一次性向其它节点请求第1个区块至第N个区块的数据。
再比如,可以将第1个区块至第N个区块分为多组区块。每组区块可以包括相同数量的区块,也可以包括不同数量的区块。本说明书的实施例对此不作限定。由此,可以分别请求这多组区块的数据。举例而言,假设N为800,即有800个区块需要进行数据同步。另外,假设将800个区块划分为8组区块,每组包括100个区块。这样,可以分别向其它节点请求第1-100个区块的数据,请求第101-200个区块的数据,以此类推,直到请求到第701-800个区块的数据为止。针对各组区块的数据请求可以不是同时发起的。
在另一种情况下,如果i不为1,则在步骤102中,将从N个区块中的中间区块开始发起数据请求。例如,可以从第i个区块开始,按照区块编号增大的方向来发起数据请求。
此处,也可以按照一次性或分批方式来请求第i个区块至第N个区块的数据。
比如,可以向其它节点一次性请求第i个区块至第N个区块的数据。
再比如,也可以将第i个区块至第N个区块划分为多组区块。然后,可以分别请求这多组区块的数据。针对这多组区块的数据请求可以不是同时发送的。举例而言,假设N为800,即有800个区块需要进行数据同步;并且假设i为401,则在步骤102中,将从第401个区块开始发起数据请求。如果第401个区块至第800个区块划分为4组区块,每组包括100个区块,则可以向其它节点分别请求第401-500个区块的数据,请求第501-600个区块的数据,以此类推,直到请求第701-800个区块的数据为止。
在一个实施例中,可以在完成针对第i个区块至第N个区块的数据请求之后,再发起针对第1个区块至第i-1个区块的数据请求。
在另一实施例中,可以在从第i个区块开始,按照区块编号增大的方向来发起数据请求的同时,从第i-1个区块开始,按照区块编号减小的方向来发起数据请求。具体而言,可以从两个方向来同时地发起数据请求。可见,该实施例能够进一步提高区块链网络中的数据同步的效率。
例如,假设N为800,i为401。那么,可以在向其它节点请求第401-800个区块中的至少一个区块的数据的同时,也向其它节点请求第1-400个区块中的至少一个区块的数据。
在另一种方式中,在i不为1的情况下,也可以从第i个区块开始,按照区块编号减小的方向来发起数据请求。即,可以向其它节点请求第1个区块至第i个区块的数据。此处,也可以按照一次性或分批方式来请求第1个区块至第i个区块的数据,具体方式可以参照上面的描述,此处不再赘述。
在一个实施例中,可以在完成针对第1个区块至第i个区块的数据请求之后,发起针对第i+1个区块至第N个区块的数据请求。
在另一实施例中,可以在从第i个区块开始,按照区块编号减小的方向来发起数据请求的同时,从第i+1个区块开始,按照区块编号减小的方向来发起数据请求。具体而言,可以从两个方向来同时地发起数据请求。可见,该实施例能够进一步提高区块链网络中的数据同步的效率。
应当理解的是,上述对于数值的举例仅是为了帮助本领域技术人员更好地理解本说明书的技术方案,而非进行限制。关于从哪个区块开始以及请求多少数量的区块可以是预先设定的,也可以是动态调整的。这可以基于实际需求、网络状况、节点负载等等各种因素来设定或调整。
如前所述,N个区块可以包括节点本地当前最优区块的下一个区块至区块链网络的当前最优区块。也就是说,需要进行同步的第1个区块至第N个区块可以是节点本地当前最优区块的下一个区块至区块链网络的当前最优区块。
在一些情况下,在节点完成最新区块(即区块链网络的当前最优区块)的数据同步之后,节点就可以参与区块链网络的正常共识过程。那么,在一个实施例中,可以首先请求区块链网络中的最新区块,具体地,在步骤102中,可以向其它节点发送请求消息,该请求消息可以用于请求N个区块中的第一组区块的数据,第一组区块可以包括从第i个区块至第N个区块。而第N个区块可以是区块链网络的当前最优区块。
在一个实施例中,在步骤104中,假设第j个区块是区块链网络的当前最优区块。这样,在步骤108中,可以在对区块链网络的当前最优区块的数据的合法性验证通过的情况下,存储区块链网络的当前最优区块的数据。这样,由于已经完成区块链网络的当前最优区块的数据同步,所以节点可以参与区块链网络的正常共识过程,而不管是否已经完成其它区块的数据同步。这样,能够使得数据落后的节点能够尽快参与正常共识过程,从而能够极大地减小数据同步对于该节点的性能影响。
图2是根据一个实施例的用于区块链网络中的数据同步的装置的示意性框图。例如,图2的装置200可以是数据落后的节点或者是该节点的组件。
如图2所示,装置200可以包括数据请求单元202、接收单元204、验证单元206和存储单元208。
数据请求单元202可以从需要进行数据同步的N个区块中的第i个区块开始,向区块链网络中的其它节点发起数据请求,以便获得N个区块的数据。N为大于1的正整数,i为小于或等于N的正整数。
接收单元204可以从其它节点接收N个区块中的第j个区块的数据,其中,第j个区块的数据包括用于验证第j个区块的数据的合法性的数据正确性证明,j为小于或等于N的正整数。
验证单元206可以基于在第j个区块的数据中包括的数据正确性证明,来验证第j个区块的数据的合法性。
存储单元208在验证单元对第j个区块的数据的合法性验证通过的情况下,存储第j个区块的数据。
可见,在该技术方案中,可以从需要进行数据同步的多个区块中的任一区块发起数据请求,而在接收到其中任一区块的数据时,可以基于该区块的数据中携带的数据正确性证明来验证该区块的数据的合法性,这样在合法性验证通过时,就可以完成针对该区块的数据同步。由此,无需按照区块之间的单方向顺序来依次执行各个区块的数据同步,从而能够提高区块链网络中的数据同步效率。
在一个实施例中,数据请求单元202可以从第i个区块开始,按照区块编号增大的方向来向其它节点发起数据请求。此外,与从第i个区块开始发起的数据请求同时地,数据请求单元202可以从第i-1个区块开始,按照区块编号减小的方向来向其它节点发起数据请求,其中,i为大于1的正整数。
在一个实施例中,N个区块中的第1个区块至第N个区块为本地当前最优区块的下一个区块至区块链网络的当前最优区块。
数据请求单元202可以向其它节点发送请求消息,其中,请求消息用于请求N个区块中的第一组区块的数据,第一组区块包括从第i个区块至区块链网络的当前最优区块。
在一个实施例中,第j个区块可以为区块链网络的当前最优区块。装置200还可以包括共识单元210。共识单元210可以在存储区块链网络的当前最优区块的数据之后,参与区块链网络的共识过程。
在一个实施例中,区块链网络可以为采用确定性共识协议的联盟链网络。
装置200的各个单元可以执行图1的方法实施例中的相应步骤,因此,为了描述的简洁,装置200的各个单元的具体操作和功能此处不再赘述。
上述装置200可以采用硬件实现,也可以采用软件实现,或者可以通过软硬件的组合来实现。例如,装置200在采用软件实现时,其可以通过其所在设备的处理器将存储器(比如非易失性存储器)中对应的可执行指令读取到内存中运行来形成。
图3是根据一个实施例的用于区块链网络中的数据同步的计算设备的硬件结构图。如图3所示,计算设备300可以包括至少一个处理器302、存储器304、内存306和通信接口308,并且至少一个处理器302、存储器304、内存306和通信接口308经由总线310连接在一起。至少一个处理器302执行在存储器304中存储或编码的至少一个可执行指令(即,上述以软件形式实现的元素)。
在一个实施例中,在存储器304中存储的可执行指令在被至少一个处理器302执行时,使得计算设备实现以上结合图1描述的各种过程。
计算设备300可以采用本领域任何适用的形式来实现,例如,其包括但不限于台式计算机、膝上型计算机、智能电话、平板计算机、消费电子设备、可穿戴智能设备等等。
本说明书的实施例还提供了一种机器可读存储介质。该机器可读存储介质可以存储有可执行指令,可执行指令在被机器执行时使得机器实现上面参照图1描述的方法实施例的具体过程。
例如,机器可读存储介质可以包括但不限于随机存取存储器(Random Access  Memory,RAM)、只读存储器(Read-Only Memory,ROM)、电可擦除可编程只读存储器(Electrically-Erasable Programmable Read-Only Memory,EEPROM)、静态随机存取存储器(Static Random Access Memory,SRAM)、硬盘、闪存等等。
应当理解的是,本说明书中的各个实施例均采用递进的方式来描述,各个实施例之间相同或相似的部分相互参见即可,每个实施例重点说明的都是与其它实施例的不同之处。例如,对于上述关于装置的实施例、关于计算设备的实施例以及关于机器可读存储介质的实施例而言,由于它们基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
上文对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。
应当理解的是,对于本领域普通技术人员来说,对本说明书中的实施例进行的各种修改将是显而易见的,并且可以在不脱离权利要求书的保护范围的情况下,将本文所定义的一般性原理应用于其它变型。

Claims (11)

  1. 一种用于区块链网络中的数据同步的方法,包括:
    从需要进行数据同步的N个区块中的第i个区块开始,向区块链网络中的其它节点发起数据请求,以便获得所述N个区块的数据,其中,N为大于1的正整数,i为小于或等于N的正整数;
    从所述其它节点接收所述N个区块中的第j个区块的数据,其中,所述第j个区块的数据包括用于验证所述第j个区块的数据的合法性的数据正确性证明,j为小于或等于N的正整数;
    基于在所述第j个区块的数据中包括的数据正确性证明,来验证所述第j个区块的数据的合法性;
    在对所述第j个区块的数据的合法性验证通过的情况下,存储所述第j个区块的数据。
  2. 根据权利要求1所述的方法,其中,从第i个区块开始,向其它节点发起数据请求,包括:
    从所述第i个区块开始,按照区块编号增大的方向来向所述其它节点发起数据请求;
    与从所述第i个区块开始发起的数据请求同时地,从第i-1个区块开始,按照区块编号减小的方向来向所述其它节点发起数据请求,其中,i为大于1的正整数。
  3. 根据权利要求1或2所述的方法,其中,所述N个区块中的第1个区块至第N个区块为本地当前最优区块的下一个区块至所述区块链网络的当前最优区块;
    从第i个区块开始,向其它节点发起数据请求,包括:
    向所述其它节点发送请求消息,其中,所述请求消息用于请求所述N个区块中的第一组区块的数据,所述第一组区块包括从所述第i个区块至所述区块链网络的当前最优区块。
  4. 根据权利要求3所述的方法,其中,所述第j个区块为所述区块链网络的当前最优区块;
    所述方法还包括:
    在存储所述区块链网络的当前最优区块的数据之后,参与所述区块链网络的共识过程。
  5. 根据权利要求1或2所述的方法,其中,所述区块链网络为采用确定性共识协议的联盟链网络。
  6. 一种用于区块链网络中的数据同步的装置,包括:
    数据请求单元,用于从需要进行数据同步的N个区块中的第i个区块开始,向区块链网络中的其它节点发起数据请求,以便获得所述N个区块的数据,其中,N为大于1 的正整数,i为小于或等于N的正整数;
    接收单元,用于从所述其它节点接收所述N个区块中的第j个区块的数据,其中,所述第j个区块的数据包括用于验证所述第j个区块的数据的合法性的数据正确性证明,j为小于或等于N的正整数;
    验证单元,用于基于在所述第j个区块的数据中包括的数据正确性证明,来验证所述第j个区块的数据的合法性;
    存储单元,用于在所述验证单元对所述第j个区块的数据的合法性验证通过的情况下,存储所述第j个区块的数据。
  7. 根据权利要求6所述的装置,其中,所述数据请求单元具体用于:
    从所述第i个区块开始,按照区块编号增大的方向来向所述其它节点发起数据请求;
    与从所述第i个区块开始发起的数据请求同时地,从第i-1个区块开始,按照区块编号减小的方向来向所述其它节点发起数据请求,其中,i为大于1的正整数。
  8. 根据权利要求6或7所述的装置,其中,所述N个区块中的第1个区块至第N个区块为本地当前最优区块的下一个区块至所述区块链网络的当前最优区块;
    所述数据请求单元具体用于:
    向所述其它节点发送请求消息,其中,所述请求消息用于请求所述N个区块中的第一组区块的数据,所述第一组区块包括从所述第i个区块至所述区块链网络的当前最优区块。
  9. 根据权利要求8所述的装置,其中,所述第j个区块为所述区块链网络的当前最优区块;
    所述装置还包括:
    共识单元,用于在存储所述区块链网络的当前最优区块的数据之后,参与所述区块链网络的共识过程。
  10. 根据权利要求6或7所述的装置,其中,所述区块链网络为采用确定性共识协议的联盟链网络。
  11. 一种计算设备,包括:
    至少一个处理器;
    与所述至少一个处理器进行通信的存储器,其上存储有可执行指令,所述可执行指令在被所述至少一个处理器执行时使得所述至少一个处理器实现根据权利要求1至5中任一项所述的方法。
PCT/CN2020/139308 2020-03-16 2020-12-25 用于区块链网络中的数据同步的方法、装置和计算设备 WO2021184873A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010180584.0A CN111061813B (zh) 2020-03-16 2020-03-16 用于区块链网络中的数据同步的方法、装置和计算设备
CN202010180584.0 2020-03-16

Publications (1)

Publication Number Publication Date
WO2021184873A1 true WO2021184873A1 (zh) 2021-09-23

Family

ID=70307906

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/139308 WO2021184873A1 (zh) 2020-03-16 2020-12-25 用于区块链网络中的数据同步的方法、装置和计算设备

Country Status (2)

Country Link
CN (2) CN111061813B (zh)
WO (1) WO2021184873A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114422526A (zh) * 2021-12-31 2022-04-29 支付宝(杭州)信息技术有限公司 一种区块同步方法、装置、电子设备和存储介质

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111061813B (zh) * 2020-03-16 2020-07-07 支付宝(杭州)信息技术有限公司 用于区块链网络中的数据同步的方法、装置和计算设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180039667A1 (en) * 2016-08-05 2018-02-08 Chicago Mercantile Exchange Inc. Systems and methods for blockchain rule synchronization
CN110011788A (zh) * 2019-04-10 2019-07-12 深圳市网心科技有限公司 一种基于区块链的数据处理方法、系统及相关设备
CN110572287A (zh) * 2019-09-05 2019-12-13 腾讯科技(深圳)有限公司 数据容灾方法、装置、计算机设备和存储介质
CN110798509A (zh) * 2019-07-15 2020-02-14 腾讯科技(深圳)有限公司 区块数据同步方法、装置、介质、电子设备
CN111061813A (zh) * 2020-03-16 2020-04-24 支付宝(杭州)信息技术有限公司 用于区块链网络中的数据同步的方法、装置和计算设备

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108537063A (zh) * 2018-02-26 2018-09-14 阿里巴巴集团控股有限公司 一种数据存储的方法、装置及设备
WO2019195820A1 (en) * 2018-04-06 2019-10-10 Daniel Maurice Lerner Securing temporal digital communications via authentication and validation
CN109493061B (zh) * 2018-12-28 2021-03-23 合肥达朴汇联科技有限公司 一种区块链的数据的验证方法、装置、电子设备及存储介质
EP3673620B8 (en) * 2019-07-11 2022-02-16 Advanced New Technologies Co., Ltd. Shared blockchain data storage

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180039667A1 (en) * 2016-08-05 2018-02-08 Chicago Mercantile Exchange Inc. Systems and methods for blockchain rule synchronization
CN110011788A (zh) * 2019-04-10 2019-07-12 深圳市网心科技有限公司 一种基于区块链的数据处理方法、系统及相关设备
CN110798509A (zh) * 2019-07-15 2020-02-14 腾讯科技(深圳)有限公司 区块数据同步方法、装置、介质、电子设备
CN110572287A (zh) * 2019-09-05 2019-12-13 腾讯科技(深圳)有限公司 数据容灾方法、装置、计算机设备和存储介质
CN111061813A (zh) * 2020-03-16 2020-04-24 支付宝(杭州)信息技术有限公司 用于区块链网络中的数据同步的方法、装置和计算设备

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114422526A (zh) * 2021-12-31 2022-04-29 支付宝(杭州)信息技术有限公司 一种区块同步方法、装置、电子设备和存储介质
CN114422526B (zh) * 2021-12-31 2024-03-15 支付宝(杭州)信息技术有限公司 一种区块同步方法、装置、电子设备和存储介质

Also Published As

Publication number Publication date
CN111061813B (zh) 2020-07-07
CN111061813A (zh) 2020-04-24
CN111723158A (zh) 2020-09-29

Similar Documents

Publication Publication Date Title
WO2021036702A1 (zh) 一种基于区块链系统的共识方法及装置
JP6816300B2 (ja) ブロックチェーンネットワークにおけるトランザクションの並列実行
JP7362654B2 (ja) 分割されたブロックチェーンネットワークにおけるブロックチェーンのブロックの維持管理
TWI690184B (zh) 跨區塊鏈的認證方法及裝置、電子設備
WO2021032138A1 (zh) 一种基于区块链系统的共识方法、装置及系统
KR101727525B1 (ko) 블록체인 기반 분산 저장 방법 및 이를 이용한 장치
EP3619668B1 (en) Performing parallel execution of transactions in a distributed ledger system
CA3098769C (en) Asynchronous processing of blockchain blocks
CN110399424B (zh) 区块生成方法、装置、区块链节点及存储介质
WO2019101240A2 (en) Authentication based on a recoverd public key
US20230316273A1 (en) Data processing method and apparatus, computer device, and storage medium
WO2021184873A1 (zh) 用于区块链网络中的数据同步的方法、装置和计算设备
CN111066047A (zh) 实现基于区块链的工作流
AU2019207314C1 (en) Method and device for avoiding double-spending problem in read-write set-model-based blockchain technology
CN112163950A (zh) 一种方便扩展、节点资源复用的区块链链网构建方法、系统及终端设备
JP6920442B2 (ja) ブロックチェーンシステムのノード間の通信を確立するための方法及びデバイス
WO2021068477A1 (zh) 区块处理方法、装置、计算机设备及存储介质
CN110599175A (zh) 一种区块处理方法及相关设备
CN111640018B (zh) 一种区块链交易存在性验证方法及装置
KR20190086301A (ko) 블록 체인을 이용한 분산 데이터베이스 시스템 및 방법
WO2023160093A1 (zh) 区块链的节点入网及装置和电子设备
CN112579343B (zh) 区块链节点数据的恢复方法及装置
CN113382018A (zh) 一种基于区块链的多链管理方法及其系统
CN111461688A (zh) 一种基于区块链技术的服务收费系统及其收费方法
CN115859374A (zh) 基于区块链的数据存证方法及装置

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: 20925155

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20925155

Country of ref document: EP

Kind code of ref document: A1