WO2021244568A1 - Method for consensus in blockchain, and system - Google Patents

Method for consensus in blockchain, and system Download PDF

Info

Publication number
WO2021244568A1
WO2021244568A1 PCT/CN2021/097897 CN2021097897W WO2021244568A1 WO 2021244568 A1 WO2021244568 A1 WO 2021244568A1 CN 2021097897 W CN2021097897 W CN 2021097897W WO 2021244568 A1 WO2021244568 A1 WO 2021244568A1
Authority
WO
WIPO (PCT)
Prior art keywords
consensus
data
node
target proposal
target
Prior art date
Application number
PCT/CN2021/097897
Other languages
French (fr)
Chinese (zh)
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 WO2021244568A1 publication Critical patent/WO2021244568A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/16Arrangements for providing special services to substations
    • H04L12/18Arrangements for providing special services to substations for broadcast or conference, e.g. multicast
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Definitions

  • This document relates to the field of computer technology, in particular to a consensus method and system in the blockchain.
  • the nodes in the blockchain generally communicate with each other in a P2P direct connection.
  • this direct communication method will make the entire blockchain network have a relatively large demand for delay and bandwidth.
  • the embodiments of this specification provide a consensus method and system in the blockchain to solve the problem of communication between nodes in the existing blockchain through P2P direct connection, so that the entire blockchain network has a problem of delay and bandwidth.
  • the demand is larger.
  • a consensus method in the blockchain including: the consensus master node initiates a target proposal for the consensus data in the blockchain,
  • the target proposal includes the root hash composed of the data to be agreed;
  • the consensus master node calls the broadcast network client of the node to broadcast the data to be agreed to the consensus backup node in the blockchain; receives the The consensus backup node proposed by the target determines whether the broadcast network client of this node has data matching the root hash in the target proposal; if the consensus backup node proposed by the target is received, if the broadcast network of this node is determined If the client has data that matches the root hash of the target proposal, then a consensus operation is performed on the target proposal.
  • a blockchain system including: a consensus master node, which initiates a target proposal for the data to be consensus in the blockchain, and the target proposal contains the root hash composed of the data to be consensus; and calls The broadcast network client of this node broadcasts the to-be-consensus data to the consensus backup node in the blockchain; the consensus backup node that receives the target proposal, determines whether the broadcast network client of this node is consistent with the target proposal If it is determined that the broadcast network client of this node has data that matches the root hash in the target proposal, then perform a consensus operation on the target proposal.
  • the consensus master node initiates a target proposal for the data to be consensus in the blockchain, and calls the broadcast network of this node
  • the client broadcasts the data to be consensus to the consensus backup node in the blockchain.
  • the target proposal contains the root hash composed of the data to be consensus; the consensus backup node proposed by the target is received, and it is determined whether the broadcast network client of this node exists and The data that matches the root hash in the target proposal, and if it is determined that the broadcast network client of this node has data that matches the root hash in the target proposal, then a consensus operation is performed on the target proposal.
  • the consensus master node initiates a consensus operation
  • what is transmitted to the consensus backup node is the root hash of the consensus data proposed by the target, not the original data of the consensus data, and the broadcast network client in the consensus master node
  • the terminal broadcasts the original data of the data to be consensus to the consensus backup node in the blockchain.
  • the root hash of the data to be consensus is directly transmitted between nodes, the transmission of root hash between nodes greatly saves the bandwidth occupied during data transmission compared with the original data; on the other hand, through the broadcast network Transmission of the original data of the data to be agreed also reduces the delay of data transmission.
  • Figure 1 is a schematic diagram of the implementation process of a consensus method in a blockchain provided by an embodiment of this specification
  • FIG. 2 is a schematic diagram of the consensus method in the blockchain provided by an embodiment of the specification applied in an actual scenario
  • Fig. 3 is a schematic structural diagram of a blockchain system provided by an embodiment of this specification.
  • the embodiment of this specification proposes a consensus method in the blockchain.
  • the consensus master node initiates a target proposal for the consensus data in the blockchain and calls The broadcast network client of this node broadcasts the consensus data to the consensus backup node in the blockchain.
  • the target proposal contains the root hash composed of the consensus data; the consensus backup node proposed by the target is received, and the broadcast network of this node is determined Whether the client has data that matches the root hash of the target proposal, and if it is determined that the broadcast network client of this node has data that matches the root hash of the target proposal, then consensus operations are performed on the target proposal.
  • the consensus master node initiates a consensus operation
  • what is transmitted to the consensus backup node is the root hash of the consensus data proposed by the target, not the original data of the consensus data, and the consensus is waiting for the consensus through the broadcast network client in the consensus master node.
  • the original data of the data is broadcast to the consensus backup node in the blockchain.
  • the transmission of root hash between nodes greatly saves the bandwidth occupied during data transmission compared with the original data; on the other hand, through the broadcast network Transmission of the original data of the data to be agreed also reduces the delay of data transmission.
  • the target proposal of the target proposal contains the root hash of the data to be agreed.
  • the consensus master node when the consensus master node initiates a target proposal for the consensus data in the blockchain, the consensus master node sends the root hash composed of the consensus data to the consensus backup node in the blockchain Since the root hash is usually a 32-byte data, this will greatly reduce the network bandwidth occupied by the direct data transmission between nodes, and at the same time reduce the data transmission delay.
  • the consensus master node in the embodiment of this specification can also initiate a target proposal for the data to be consensus Determine whether the collected transaction set meets the preset transaction collection conditions.
  • the consensus master node initiates a target proposal for the consensus data in the blockchain, including: the consensus master node obtains the consensus data, and based on the consensus data, generates a target proposal containing the root hash of the consensus data ; If the consensus master node determines that the consensus data meets the preset transaction collection conditions, based on the consensus data, it generates a target proposal containing the root hash composed of the consensus data.
  • the preset transaction collection conditions include at least one of the following: the number of transactions in the data to be agreed is greater than or equal to the preset number; the period for collecting transactions in the data to be agreed is greater than or equal to the specified collection period; the data to be agreed The size is greater than or equal to the specified capacity.
  • the data to be agreed may include one or more transaction sets, and one transaction set includes one or more transaction data, and the data to be agreed may also be empty.
  • the consensus master node obtains the data to be consensus, the consensus master node can obtain one or more transaction sets from the transaction pool, and package the target proposal based on the one or more transaction sets. Specifically, in order to reduce the amount of data transmission between nodes, the target proposal is packaged based on one or more transaction sets, and the packaged target proposal may only include the root hash composed of one or more transaction sets.
  • the consensus master node in the blockchain initiates a consensus algorithm corresponding to the target proposal for the data to be consensus, including at least one of the following: Practical Byzantine Fault Tolerance (PBFT) consensus algorithm; Hotstuff consensus algorithm; LibraBFT Consensus algorithm; Tendermint consensus algorithm.
  • PBFT Practical Byzantine Fault Tolerance
  • the consensus master node sends the PRE-PREPARE message proposed for the target and the signature of the PRE-PREPARE message to the consensus backup node in the blockchain.
  • the format of the PRE-PREPARE message is ⁇ PRE-PREPARE, v, n, d >, where v is the view number of the target proposal, d is the root hash formed by one or more transaction sets corresponding to the target proposal, and n is [h, H] within a certain range.
  • Step 120 The consensus master node calls the broadcast network client of the node to broadcast the data to be consensus to the consensus backup node in the blockchain.
  • the broadcast network client is additionally set in the node based on the defect of the P2P transmission method between nodes in the embodiment of this specification, and the broadcast network client is used to transmit the original data of the data to be consensus to other nodes in the blockchain .
  • the broadcast network client performs data transmission, it does not occupy the network transmission bandwidth between nodes, and specifically transmits data via the broadcast network in the blockchain.
  • the original data of the data to be agreed in the embodiment of this specification is the root of the target proposal.
  • the original data of one or more transaction sets in the corresponding data for consensus can be sent to the consensus backup in the blockchain by the broadcast network client in the consensus master node.
  • the broadcast network client of the node can call the broadcast network client of the node to broadcast the data to be consensus to the broadcast network client of the consensus backup node in the blockchain.
  • the embodiment of this specification may pre-deploy a broadcast network in the blockchain.
  • the broadcast network is used to transmit large-capacity data between nodes, and the broadcast network clients in each node
  • the terminal is used to send and receive data transmitted in the broadcast network.
  • the consensus master node calls the broadcast network client of this node to broadcast the consensus data to the consensus backup node in the blockchain, including: the consensus master node sends the consensus data to the broadcast network client of the node; consensus The broadcast network client of the master node broadcasts the consensus data to the consensus backup node in the blockchain via the broadcast network of the blockchain.
  • the method provided by one or more embodiments of this specification can greatly reduce the amount of data directly communicated between nodes, thereby reducing the amount of data between nodes. Network transmission bandwidth requirements.
  • Step 130 Receive the consensus backup node proposed by the target, and determine whether the broadcast network client of this node has data matching the root hash in the target proposal.
  • the consensus backup node that can receive the target proposal determines whether the broadcast network client of the node has data matching the root hash in the target proposal based on the view identifier in the target proposal.
  • the consensus backup node that receives the target proposal determines whether the broadcast network client of this node has data that matches the root hash in the target proposal, including: the consensus backup node that receives the target proposal, corresponds to the target proposal
  • the target view of the target view is obtained from the broadcast network client of this node corresponding to the transaction data of the target view; the consensus backup node that receives the target proposal, based on the transaction data corresponding to the target view, determines whether the broadcast network client of this node exists Data that matches the root hash in the target proposal.
  • the consensus backup node that receives the target proposal, based on the transaction data corresponding to the target view, determines whether the broadcast network client of the node has data that matches the root hash in the target proposal.
  • the transaction data of the view obtains the root hash formed by the transaction data corresponding to the target view, and then it is determined whether the root hash formed by the transaction data corresponding to the target view is consistent with the root hash carried in the target proposal.
  • the root hash formed by the transaction data corresponding to the target view is consistent with the root hash carried in the target proposal, it indicates that the broadcast network client of this node has data that matches the root hash in the target proposal; and if The root hash formed by the transaction data corresponding to the target view is inconsistent with the root hash carried in the target proposal, indicating that the broadcast network client of this node does not have data that matches the root hash in the target proposal.
  • the consensus backup node that receives the target proposal determines whether the broadcast network client of this node has data that matches the root hash in the target proposal, including: the broadcast network client that receives the consensus backup node proposed by the target The end receives the consensus data from the consensus master node via the broadcast network; the consensus backup node that receives the target proposal determines whether the consensus data received by the broadcast network client of this node matches the root hash of the target proposal.
  • the method further includes: receiving the consensus backup proposed by the target The node, if it is determined that the broadcast network client of this node does not have data that matches the root hash in the target proposal, it will determine whether the broadcast network client of this node receives the target proposal for a preset period of time To the data that matches the root hash in the target proposal.
  • the preset time period is the upper limit of the preset timeout period.
  • the consensus backup node that receives the target proposal if it is determined that the broadcast network client of this node does not have data that matches the root hash in the target proposal, it will usually wait for a timeout period. If the broadcast network client cannot find the data that matches the root hash of the target proposal, it can initiate a view switching operation, that is, start a consensus operation on the next proposal proposed by the target.
  • the method further includes: the consensus backup node that receives the target proposal, if after receiving the target proposal for a preset time period, it is determined that the broadcast network client of the node does not have data that matches the root hash of the target proposal, The view switching operation is initiated.
  • the consensus backup node After the consensus backup node receives the PRE-PREPARE message proposed for the target, it verifies the PRE-PREPARE message, mainly verifying the following: the consensus master node’s signature of the PRE-PREPARE message is correct, and the broadcast network client of its own node Whether there are one or more transaction sets that match d, whether n is in the interval [h, H], and whether the consensus backup node has received a PRE that is under the same v and numbered n but has a different signature -PREPARE information.
  • step 140 the consensus backup node proposed by the target is received, and if it is determined that the broadcast network client of the node has data matching the root hash in the target proposal, then a consensus operation is performed on the target proposal.
  • the method further includes: if the node in the blockchain receives A valid verification message from no less than 3f+1 nodes for the target proposal will generate a block recording the data to be consensus; where f is the maximum number of abnormal nodes allowed in the blockchain.
  • the consensus backup node After the consensus backup node passes the verification of the received PRE-PREPARE message, it sends a PRE-PREPARE message to other nodes in the blockchain, including the consensus master node, in the format of ⁇ PREPARE,v,n,d,i>message, v,n ,d,m have the same content as the above PRE-PREPARE message, i is the number of the current consensus backup node, and at the same time sign ⁇ PREPARE,v,n,d,i>; the consensus master node and other consensus backups in the blockchain
  • the node receives the PREPARE message it mainly performs the following checks: whether the signature of the PREPARE message is correct, whether the node receiving the PREPARE message has received the n under the same view, and whether n is in the interval [h, H] , And whether d is the same as d in the received PRE-PREPARE message.
  • the message is discarded; if the consensus master node and other consensus backup nodes in the blockchain receive PREPARE messages from no less than 3f+1 nodes, and the verification is passed, the message is sent to the blockchain
  • the other nodes in the node send the COMMIT message and the message signature in the format of ⁇ COMMIT,v,n,d,i>, where v,n,d,i are the same as the above PREPARE message content; the node in the blockchain receives the After the COMMIT message, verify the COMMIT message, mainly to verify the following items: whether the signature of the COMMIT message is correct, whether the n under the same view has been received, and whether there is a matching d in the transaction memory pool managed by it One or more transaction sets, whether n is in the interval [h, H].
  • the blockchain network includes a consensus master. Nodes and multiple consensus backup nodes.
  • the consensus backup node takes one of the consensus backup nodes as an example. It should be understood that in actual scenarios, the number of consensus backup nodes is usually multiple.
  • the implementation process of the consensus method in the blockchain includes:
  • the consensus master node After determining whether at least one transaction set collected by this node meets the preset transaction collection conditions, the consensus master node sends the at least one to the broadcast network client of the node when initiating a consensus proposal for the at least one transaction set.
  • the preset transaction collection conditions include, for example, whether the number of transactions in the at least one transaction set is greater than or equal to a preset number, whether the collection period of the at least one transaction set is greater than or equal to a specified collection period, and/or the at least one transaction Is the size of the collection greater than or equal to the specified capacity, etc.
  • the consensus master node sends a pre-prepare message to the consensus backup node.
  • the pre-prepare message contains the root hash of at least one transaction set and block metadata (used to indicate the view and area corresponding to the initiated consensus proposal). Block number).
  • S3 The broadcast network client in the consensus master node sends the at least one transaction set to the broadcast network, so that the broadcast network sends the at least one transaction set to the broadcast network client of the consensus backup node.
  • the broadcast network sends the at least one transaction set to the broadcast network client of the consensus backup node.
  • the consensus backup node obtains transaction data consistent with the block metadata in the pre-prepare message from the broadcast network client of the node, and determines whether the root hash corresponding to the obtained transaction data is the same as that in the pre-prepare message The root hashes are consistent. If they are consistent, continue the consensus operation on the consensus proposal, otherwise wait for the preset time period.
  • the consensus backup node If after the preset time period, the consensus backup node still does not find the transaction data matching the root hash in the pre-prepare message from the broadcast network client of the node, it will initiate a view switch operation to download the consensus proposal.
  • the consensus backup node finds the transaction set corresponding to the block number to be written in the target proposal and is not in the managed transaction memory pool within the specified time period, execute S7, and continue to execute the target proposal after passing the verification If the consensus backup node does not find the transaction set corresponding to the block number to be written in the target proposal and not in the managed transaction memory pool within the specified time period, the view switching operation will be performed.
  • the consensus master node initiates a target proposal for the data to be agreed in the blockchain, and calls the broadcast network client of this node to broadcast the data to be agreed to the consensus backup node in the blockchain ,
  • the target proposal contains the root hash of the consensus data;
  • the consensus backup node that receives the target proposal determines whether the broadcast network client of this node has data that matches the root hash in the target proposal, and if it is determined The broadcast network client of the node has data that matches the root hash in the target proposal, and then performs a consensus operation on the target proposal.
  • the consensus master node initiates a consensus operation
  • what is transmitted to the consensus backup node is the root hash of the consensus data proposed by the target, not the original data of the consensus data, and the broadcast network client in the consensus master node
  • the terminal broadcasts the original data of the data to be consensus to the consensus backup node in the blockchain.
  • the root hash of the data to be consensus is directly transmitted between nodes, the transmission of root hash between nodes greatly saves the bandwidth occupied during data transmission compared with the original data; on the other hand, through the broadcast network Transmission of the original data of the data to be agreed also reduces the delay of data transmission.
  • FIG. 3 is a schematic structural diagram of a blockchain system 300 provided by an embodiment of this specification.
  • the blockchain system 300 may include a consensus master node 310 and a plurality of consensus backup nodes 320, among which: the consensus master node 310 initiates a transaction for the consensus data in the blockchain A target proposal, the target proposal contains the root hash composed of the data to be agreed; and the broadcast network client that calls the node broadcasts the data to be agreed to the consensus backup node in the blockchain; the target proposal is received
  • the consensus backup node 320 of this node determines whether the broadcast network client of this node has data that matches the root hash in the target proposal; and if it is determined that the broadcast network client of this node has the root hash in the target proposal For data matching the hash, a consensus operation is performed on the target proposal.
  • the consensus master node initiates a consensus operation
  • the root hash of the consensus data proposed by the target is transmitted to the consensus backup node, rather than the original data of the consensus data.
  • the original data of the data to be consensus is broadcast to the consensus backup node in the blockchain.
  • the transmission of root hash between nodes greatly saves the bandwidth occupied during data transmission compared with the original data; on the other hand, through the broadcast network Transmission of the original data of the data to be agreed also reduces the delay of data transmission.
  • the consensus backup node 320 that has received the target proposal is configured to: based on the target view corresponding to the target proposal, obtain from the broadcast network client of the node corresponding to the Transaction data of the target view; based on the transaction data corresponding to the target view, determine whether the broadcast network client of this node has data that matches the root hash in the target proposal.
  • the consensus master node 310 is configured to: obtain the data to be agreed, and based on the data to be agreed, generate a root hash that contains the data to be agreed The target proposal; if it is determined that the data to be agreed upon meets a preset transaction collection condition, based on the data to be agreed, the target proposal including the root hash formed by the data to be agreed is generated.
  • the consensus master node 310 is configured to: send the data to be agreed to the broadcast network client of the node; the broadcast network client of the consensus master node sends the The consensus data is broadcast to the consensus backup node in the blockchain via the broadcasting network of the blockchain.
  • the consensus backup node 320 receiving the target proposal performs a consensus operation on the target proposal
  • the consensus master node 310 or the consensus backup node 320 in the blockchain Receive valid verification messages from no less than 3f+1 nodes for the target proposal, then generate a block recording the data to be agreed; where f is the maximum number of abnormal nodes allowed in the blockchain .
  • the consensus backup node 320 to the target proposal is also used to: if it is determined that the broadcast network client of this node does not have data that matches the root hash in the target proposal, then the target proposal is received After a preset period of time, it is determined whether the broadcast network client of the node receives data that matches the root hash in the target proposal.
  • the consensus backup node 320 to the target proposal is also used to: if the target proposal is received for the preset time period, it is determined that the broadcast network client of this node does not have the root hash in the target proposal. If the matching data is matched, the view switching operation is initiated.
  • the consensus algorithm used by the consensus master node to initiate a target proposal for the consensus data in the blockchain includes at least one of the following: a practical Byzantine fault-tolerant PBFT consensus algorithm; a Hotstuff consensus algorithm; LibraBFT Consensus algorithm; Tendermint consensus algorithm.
  • the blockchain system 300 can implement the methods of the method embodiments shown in FIGS. 1 to 2. For details, please refer to the consensus method in the blockchain of the embodiment shown in FIGS. 1 to 2, which will not be repeated here.
  • a typical implementation device is a computer.
  • the computer may be, for example, a personal computer, a laptop computer, a cell phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or Any combination of these devices.
  • Computer-readable media include permanent and non-permanent, removable and non-removable media, and information storage can be realized by any method or technology.
  • the information can be computer-readable instructions, data structures, program modules, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, CD-ROM, digital versatile disc (DVD) or other optical storage, Magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media can be used to store information that can be accessed by computing devices. According to the definition in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.

Abstract

Disclosed in the present description is a method for consensus in a blockchain and a system, the method comprising: in a blockchain, a consensus primary node initiates a target proposal with respect to data to undergo consensus, the target proposal including a root hash formed from the data to undergo consensus; the consensus main node uses a broadcast network client end of a present node, and broadcasts the data to undergo consensus to a consensus backup node in the blockchain; the consensus backup node that received the target proposal determines, for the broadcast network client end of the present node, whether data matching the root hash in the target proposal exists; if the consensus backup node that received the target proposal determines, for the broadcast network client end of the present node, data matching the root hash in the target proposal exists, performing a consensus operation on the target proposal.

Description

区块链中的共识方法和系统Consensus method and system in blockchain 技术领域Technical field
本文件涉及计算机技术领域,尤其涉及一种区块链中的共识方法和系统。This document relates to the field of computer technology, in particular to a consensus method and system in the blockchain.
背景技术Background technique
目前,在区块链网络中,区块链中的节点之间一般采用P2P直连的方式进行通信。当区块链中的某个节点需要广播数据到其他节点时,这种直连通信方式会使得整个区块链网络对时延和带宽的需求都比较大。At present, in the blockchain network, the nodes in the blockchain generally communicate with each other in a P2P direct connection. When a node in the blockchain needs to broadcast data to other nodes, this direct communication method will make the entire blockchain network have a relatively large demand for delay and bandwidth.
发明内容Summary of the invention
本说明书实施例提供了一种区块链中的共识方法和系统,以解决现有的区块链中的节点之间通过P2P直连的方式进行通信使得整个区块链网络对时延和带宽的需求较大的问题。The embodiments of this specification provide a consensus method and system in the blockchain to solve the problem of communication between nodes in the existing blockchain through P2P direct connection, so that the entire blockchain network has a problem of delay and bandwidth. The demand is larger.
为解决上述技术问题,本说明书实施例是这样实现的:第一方面,提出了一种区块链中的共识方法,包括:共识主节点在区块链中发起针对待共识数据的目标提议,所述目标提议中包含待共识数据构成的根哈希;所述共识主节点调用本节点的广播网络客户端,将所述待共识数据广播至区块链中的共识备份节点;接收到所述目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据;接收到所述目标提议的共识备份节点,若确定本节点的广播网络客户端存在与所述目标提议中的根哈希相匹配的数据,则对所述目标提议进行共识操作。In order to solve the above technical problems, the embodiments of this specification are implemented as follows: First, a consensus method in the blockchain is proposed, including: the consensus master node initiates a target proposal for the consensus data in the blockchain, The target proposal includes the root hash composed of the data to be agreed; the consensus master node calls the broadcast network client of the node to broadcast the data to be agreed to the consensus backup node in the blockchain; receives the The consensus backup node proposed by the target determines whether the broadcast network client of this node has data matching the root hash in the target proposal; if the consensus backup node proposed by the target is received, if the broadcast network of this node is determined If the client has data that matches the root hash of the target proposal, then a consensus operation is performed on the target proposal.
第二方面,提出了一种区块链系统,包括:共识主节点,在区块链中发起针对待共识数据的目标提议,所述目标提议中包含待共识数据构成的根哈希;以及调用本节点的广播网络客户端将所述待共识数据广播至区块链中的共识备份节点;接收到所述目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据;以及若确定本节点的广播网络客户端存在与所述目标提议中的根哈希相匹配的数据,则对所述目标提议进行共识操作。In the second aspect, a blockchain system is proposed, including: a consensus master node, which initiates a target proposal for the data to be consensus in the blockchain, and the target proposal contains the root hash composed of the data to be consensus; and calls The broadcast network client of this node broadcasts the to-be-consensus data to the consensus backup node in the blockchain; the consensus backup node that receives the target proposal, determines whether the broadcast network client of this node is consistent with the target proposal If it is determined that the broadcast network client of this node has data that matches the root hash in the target proposal, then perform a consensus operation on the target proposal.
本说明书实施例采用上述技术方案至少可以达到下述技术效果:采用本说明书实施例提供的共识方法,共识主节点在区块链中发起针对待共识数据的目标提议,并调用本节点的广播网络客户端将待共识数据广播至区块链中的共识备份节点,目标提议中包含待共识数据构成的根哈希;接收到目标提议的共识备份节点,确定本节点的广播网络 客户端是否存在与目标提议中的根哈希相匹配的数据,以及若确定本节点的广播网络客户端存在与目标提议中的根哈希相匹配的数据,则对目标提议进行共识操作。The embodiments of this specification adopt the above technical solutions to at least achieve the following technical effects: using the consensus method provided by the embodiments of this specification, the consensus master node initiates a target proposal for the data to be consensus in the blockchain, and calls the broadcast network of this node The client broadcasts the data to be consensus to the consensus backup node in the blockchain. The target proposal contains the root hash composed of the data to be consensus; the consensus backup node proposed by the target is received, and it is determined whether the broadcast network client of this node exists and The data that matches the root hash in the target proposal, and if it is determined that the broadcast network client of this node has data that matches the root hash in the target proposal, then a consensus operation is performed on the target proposal.
也就是说,在共识主节点发起共识操作时,向共识备份节点传输的是目标提议的待共识数据的根哈希,而不是待共识数据的原始数据,以及通过共识主节点中的广播网络客户端将待共识数据的原始数据广播至区块链中的共识备份节点。这一方面由于节点之间直接进行传输的是待共识数据的根哈希,在节点之间传输根哈希相对原始数据而言极大地节省了数据传输时占用的带宽;另一方面通过广播网络传输待共识数据的原始数据也减少了数据传输的时延。That is to say, when the consensus master node initiates a consensus operation, what is transmitted to the consensus backup node is the root hash of the consensus data proposed by the target, not the original data of the consensus data, and the broadcast network client in the consensus master node The terminal broadcasts the original data of the data to be consensus to the consensus backup node in the blockchain. On the one hand, because the root hash of the data to be consensus is directly transmitted between nodes, the transmission of root hash between nodes greatly saves the bandwidth occupied during data transmission compared with the original data; on the other hand, through the broadcast network Transmission of the original data of the data to be agreed also reduces the delay of data transmission.
附图说明Description of the drawings
此处所说明的附图用来提供对本说明书的进一步理解,构成本说明书的一部分,本说明书的示意性实施例及其说明用于解释本说明书,并不构成对本说明书的不当限定。在附图中:The drawings described here are used to provide a further understanding of the specification and constitute a part of the specification. The exemplary embodiments and descriptions of the specification are used to explain the specification, and do not constitute an improper limitation of the specification. In the attached picture:
图1为本说明书一个实施例提供的一种区块链中的共识方法的实现流程示意图;Figure 1 is a schematic diagram of the implementation process of a consensus method in a blockchain provided by an embodiment of this specification;
图2为本说明书一个实施例提供的区块链中的共识方法应用于实际场景中的示意图;FIG. 2 is a schematic diagram of the consensus method in the blockchain provided by an embodiment of the specification applied in an actual scenario;
图3为本说明书一个实施例提供的一种区块链系统的结构示意图。Fig. 3 is a schematic structural diagram of a blockchain system provided by an embodiment of this specification.
具体实施方式detailed description
为使本文件的目的、技术方案和优点更加清楚,下面将结合本说明书具体实施例及相应的附图对本说明书技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本文件一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本文件保护的范围。In order to make the purpose, technical solutions and advantages of this document clearer, the technical solutions of this specification will be clearly and completely described below in conjunction with specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this document, rather than all the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of this document.
以下结合附图,详细说明本说明书各实施例提供的技术方案。The technical solutions provided by the embodiments of this specification will be described in detail below with reference to the accompanying drawings.
如背景技术中所述,在传统区块链网络中,区块链中的不同节点之间一般采用P2P直连的方式进行通信,即进行节点之间的数据传输。在需要对某个提议进行共识操作时,区块链中参与对该提议进行共识操作的节点需要广播数据到其他节点。然而,这种P2P直连通信方式一般是单播,这对整个区块链网络的时延和带宽需求都比较大。针对这种场景,业界发展出了0层区块链扩容技术,包括中继网络(如比特币FIBRE),或组播网络(如BDN)。然而现有的0层区块链网络都是针对区块的传输进行优化,而对共识 协议本身并没有帮助。As mentioned in the background art, in traditional blockchain networks, different nodes in the blockchain generally communicate in a P2P direct connection, that is, data transmission between nodes. When consensus operations on a certain proposal are required, nodes in the blockchain that participate in consensus operations on the proposal need to broadcast data to other nodes. However, this P2P direct communication method is generally unicast, which requires a relatively large delay and bandwidth for the entire blockchain network. In response to this scenario, the industry has developed a layer 0 blockchain expansion technology, including relay networks (such as Bitcoin FIBRE), or multicast networks (such as BDN). However, the existing layer 0 blockchain network is optimized for the transmission of blocks, and it does not help the consensus protocol itself.
本说明书实施例为了解决这一问题,提出一种区块链中的共识方法,采用本说明书实施例提供的共识方法,共识主节点在区块链中发起针对待共识数据的目标提议,并调用本节点的广播网络客户端将待共识数据广播至区块链中的共识备份节点,目标提议中包含待共识数据构成的根哈希;接收到目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据,以及若确定本节点的广播网络客户端存在与目标提议中的根哈希相匹配的数据,则对目标提议进行共识操作。In order to solve this problem, the embodiment of this specification proposes a consensus method in the blockchain. Using the consensus method provided in the embodiment of this specification, the consensus master node initiates a target proposal for the consensus data in the blockchain and calls The broadcast network client of this node broadcasts the consensus data to the consensus backup node in the blockchain. The target proposal contains the root hash composed of the consensus data; the consensus backup node proposed by the target is received, and the broadcast network of this node is determined Whether the client has data that matches the root hash of the target proposal, and if it is determined that the broadcast network client of this node has data that matches the root hash of the target proposal, then consensus operations are performed on the target proposal.
在共识主节点发起共识操作时,向共识备份节点传输的是目标提议的待共识数据的根哈希,而不是待共识数据的原始数据,以及通过共识主节点中的广播网络客户端将待共识数据的原始数据广播至区块链中的共识备份节点。这一方面由于节点之间直接进行传输的是待共识数据的根哈希,在节点之间传输根哈希相对原始数据而言极大地节省了数据传输时占用的带宽;另一方面通过广播网络传输待共识数据的原始数据也减少了数据传输的时延。When the consensus master node initiates a consensus operation, what is transmitted to the consensus backup node is the root hash of the consensus data proposed by the target, not the original data of the consensus data, and the consensus is waiting for the consensus through the broadcast network client in the consensus master node. The original data of the data is broadcast to the consensus backup node in the blockchain. On the one hand, because the root hash of the data to be consensus is directly transmitted between nodes, the transmission of root hash between nodes greatly saves the bandwidth occupied during data transmission compared with the original data; on the other hand, through the broadcast network Transmission of the original data of the data to be agreed also reduces the delay of data transmission.
具体地,本说明书一个或多个实施例提供的一种区块链中的共识方法的实现流程示意图如图1所示,包括:步骤110,共识主节点在区块链中发起针对待共识数据的目标提议,目标提议中包含待共识数据构成的根哈希。Specifically, the implementation flow diagram of a consensus method in a blockchain provided by one or more embodiments of this specification is shown in FIG. The target proposal of the target proposal contains the root hash of the data to be agreed.
应理解,区块链中的共识主节点和共识备份节点之间如果传输的数据量越大,则会对网络带宽的消耗越大,且时延越大。本说明书实施例为了解决这一问题,在共识主节点在区块链中发起针对待共识数据的目标提议时,共识主节点向区块链中的共识备份节点发送待共识数据构成的根哈希,由于该根哈希通常是一个32字节的数据,这将极大地减少节点之间直接进行数据传输所占用的网络带宽,同时降低了数据传输的时延。It should be understood that the greater the amount of data transmitted between the consensus master node and the consensus backup node in the blockchain, the greater the consumption of network bandwidth and the greater the delay. In order to solve this problem in the embodiment of this specification, when the consensus master node initiates a target proposal for the consensus data in the blockchain, the consensus master node sends the root hash composed of the consensus data to the consensus backup node in the blockchain Since the root hash is usually a 32-byte data, this will greatly reduce the network bandwidth occupied by the direct data transmission between nodes, and at the same time reduce the data transmission delay.
应理解,为确保共识主节点从交易池中捞取收集到的来自客户端的交易的集合达到发起共识的条件,本说明书实施例中的共识主节点在发起针对待共识数据的目标提议之前,还可以确定收集到的交易集合是否满足预设的交易收集条件。It should be understood that, in order to ensure that the collection of transactions from the client terminal collected by the consensus master node from the transaction pool meets the conditions for initiating a consensus, the consensus master node in the embodiment of this specification can also initiate a target proposal for the data to be consensus Determine whether the collected transaction set meets the preset transaction collection conditions.
可选地,共识主节点在区块链中发起针对待共识数据的目标提议,包括:共识主节点获取待共识数据,并基于待共识数据,生成包含有待共识数据构成的根哈希的目标提议;共识主节点若确定待共识数据满足预设的交易收集条件,则基于待共识数据,生成包含有待共识数据构成的根哈希的目标提议。Optionally, the consensus master node initiates a target proposal for the consensus data in the blockchain, including: the consensus master node obtains the consensus data, and based on the consensus data, generates a target proposal containing the root hash of the consensus data ; If the consensus master node determines that the consensus data meets the preset transaction collection conditions, based on the consensus data, it generates a target proposal containing the root hash composed of the consensus data.
其中,该预设的交易收集条件包括下述至少一种:待共识数据中的交易数量大于或等于预设数量;收集待共识数据中的交易的周期大于或等于指定的收集周期;待共识数据的大小大于或等于指定容量。Wherein, the preset transaction collection conditions include at least one of the following: the number of transactions in the data to be agreed is greater than or equal to the preset number; the period for collecting transactions in the data to be agreed is greater than or equal to the specified collection period; the data to be agreed The size is greater than or equal to the specified capacity.
其中,待共识数据可包括一个或多个交易集合,一个交易集合中包括一个或多个交易数据,该待共识数据也可为空。应理解,当待共识数据为空时,由待共识数据打包得到的目标提议也为空。共识主节点获取待共识数据具体可以由共识主节点在交易池中捞取一个或多个交易集合,并基于该一个或多个交易集合打包得到目标提议。具体地,为减少节点之间的数据传输量,基于一个或多个交易集合打包得到目标提议,打包得到的目标提议中可以只包含由一个或多个交易集合构成的根哈希。Wherein, the data to be agreed may include one or more transaction sets, and one transaction set includes one or more transaction data, and the data to be agreed may also be empty. It should be understood that when the consensus data is empty, the target proposal obtained by packaging the consensus data is also empty. When the consensus master node obtains the data to be consensus, the consensus master node can obtain one or more transaction sets from the transaction pool, and package the target proposal based on the one or more transaction sets. Specifically, in order to reduce the amount of data transmission between nodes, the target proposal is packaged based on one or more transaction sets, and the packaged target proposal may only include the root hash composed of one or more transaction sets.
可选地,共识主节点在区块链中发起针对待共识数据的目标提议对应的共识算法包括下述至少一种:实用拜占庭容错(Practical Byzantine Fault Tolerance,PBFT)共识算法;Hotstuff共识算法;LibraBFT共识算法;Tendermint共识算法。Optionally, the consensus master node in the blockchain initiates a consensus algorithm corresponding to the target proposal for the data to be consensus, including at least one of the following: Practical Byzantine Fault Tolerance (PBFT) consensus algorithm; Hotstuff consensus algorithm; LibraBFT Consensus algorithm; Tendermint consensus algorithm.
下面以区块链中的共识算法为PBFT共识算法为例,详细描述共识主节点在区块链中发起针对待共识数据的目标提议的过程。The following takes the consensus algorithm in the blockchain as the PBFT consensus algorithm as an example to describe in detail the process of the consensus master node initiating a target proposal for the consensus data in the blockchain.
共识主节点向区块链中的共识备份节点发送针对目标提议的PRE-PREPARE消息、以及对该PRE-PREPARE消息的签名,该PRE-PREPARE消息的格式为<PRE-PREPARE,v,n,d>,其中v为目标提议所处的视图view编号,d为目标提议对应的一个或多个交易集合构成的根哈希,n是要在某一个范围区间内的[h,H]。The consensus master node sends the PRE-PREPARE message proposed for the target and the signature of the PRE-PREPARE message to the consensus backup node in the blockchain. The format of the PRE-PREPARE message is <PRE-PREPARE, v, n, d >, where v is the view number of the target proposal, d is the root hash formed by one or more transaction sets corresponding to the target proposal, and n is [h, H] within a certain range.
步骤120,共识主节点调用本节点的广播网络客户端,将待共识数据广播至区块链中的共识备份节点。Step 120: The consensus master node calls the broadcast network client of the node to broadcast the data to be consensus to the consensus backup node in the blockchain.
其中,广播网络客户端为本说明书实施例基于节点之间P2P的传输方式的缺陷额外设置在节点内的,该广播网络客户端用于传输待共识数据的原始数据给区块链中的其他节点。该广播网络客户端在进行数据传输时,不占用节点之间的网络传输带宽,具体是经由区块链中的广播网络进行数据传输的。Among them, the broadcast network client is additionally set in the node based on the defect of the P2P transmission method between nodes in the embodiment of this specification, and the broadcast network client is used to transmit the original data of the data to be consensus to other nodes in the blockchain . When the broadcast network client performs data transmission, it does not occupy the network transmission bandwidth between nodes, and specifically transmits data via the broadcast network in the blockchain.
应理解,为了避免待共识数据的原始数据在节点之间直接进行传输过多地占用共识主节点的网络传输带宽,本说明书实施例中的待共识数据的原始数据,即目标提议中的根哈希对应的待共识数据中一个或多个交易集合的原始数据,可以由共识主节点中的广播网络客户端将待共识数据中的一个或多个交易集合、发送给区块链中的共识备份节点的广播网络客户端。具体地,共识主节点可调用本节点的广播网络客户端,将待共识数据广播至区块链中的共识备份节点的广播网络客户端。It should be understood that, in order to avoid the direct transmission of the original data of the data to be agreed between nodes and excessively occupy the network transmission bandwidth of the consensus master node, the original data of the data to be agreed in the embodiment of this specification is the root of the target proposal. The original data of one or more transaction sets in the corresponding data for consensus can be sent to the consensus backup in the blockchain by the broadcast network client in the consensus master node. The broadcast network client of the node. Specifically, the consensus master node can call the broadcast network client of the node to broadcast the data to be consensus to the broadcast network client of the consensus backup node in the blockchain.
可选地,为了减少待共识数据的传输时延,本说明书实施例可预先在区块链中部署广播网络,该广播网络用于传输节点之间的大容量数据,各个节点中的广播网络客户端用于发送和接收广播网络中传输的数据。具体地,共识主节点调用本节点的广播网络客户端,将待共识数据广播至区块链中的共识备份节点,包括:共识主节点将待共识数 据发送给本节点的广播网络客户端;共识主节点的广播网络客户端将待共识数据经由区块链的广播网络,广播至区块链中的共识备份节点。Optionally, in order to reduce the transmission delay of the data to be agreed, the embodiment of this specification may pre-deploy a broadcast network in the blockchain. The broadcast network is used to transmit large-capacity data between nodes, and the broadcast network clients in each node The terminal is used to send and receive data transmitted in the broadcast network. Specifically, the consensus master node calls the broadcast network client of this node to broadcast the consensus data to the consensus backup node in the blockchain, including: the consensus master node sends the consensus data to the broadcast network client of the node; consensus The broadcast network client of the master node broadcasts the consensus data to the consensus backup node in the blockchain via the broadcast network of the blockchain.
由于通过广播网络传输待共识数据没有额外占用节点间的网络传输带宽,因此,采用本说明书一个或多个实施例提供的方法可大幅降低节点间的直接进行通信的数据量,从而降低节点间的网络传输带宽需求。Since the transmission of the data to be agreed through the broadcast network does not additionally occupy the network transmission bandwidth between nodes, the method provided by one or more embodiments of this specification can greatly reduce the amount of data directly communicated between nodes, thereby reducing the amount of data between nodes. Network transmission bandwidth requirements.
步骤130,接收到目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据。Step 130: Receive the consensus backup node proposed by the target, and determine whether the broadcast network client of this node has data matching the root hash in the target proposal.
由于目标提议中还包括用于指示目标提议对应的待共识数据将要写入的区块号,即目标提议的当前视图,且经由广告网络客户端发送的待共识数据中还包括当前视图的标识。因此,可接收到目标提议的共识备份节点基于目标提议中的视图标识,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据。具体地,接收到目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据,包括:接收到目标提议的共识备份节点,基于目标提议对应的目标视图,从本节点的广播网络客户端中获取对应于目标视图的交易数据;接收到目标提议的共识备份节点,基于对应于目标视图的交易数据,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据。Since the target proposal also includes the block number used to indicate that the consensus data corresponding to the target proposal will be written, that is, the current view of the target proposal, and the consensus data sent via the advertising network client also includes the identifier of the current view. Therefore, the consensus backup node that can receive the target proposal determines whether the broadcast network client of the node has data matching the root hash in the target proposal based on the view identifier in the target proposal. Specifically, the consensus backup node that receives the target proposal, determines whether the broadcast network client of this node has data that matches the root hash in the target proposal, including: the consensus backup node that receives the target proposal, corresponds to the target proposal The target view of the target view is obtained from the broadcast network client of this node corresponding to the transaction data of the target view; the consensus backup node that receives the target proposal, based on the transaction data corresponding to the target view, determines whether the broadcast network client of this node exists Data that matches the root hash in the target proposal.
具体地,接收到目标提议的共识备份节点,基于对应于目标视图的交易数据,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据,首先可以基于对应于目标视图的交易数据,得到对应于目标视图的交易数据构成的根哈希,再确定该对应于目标视图的交易数据构成的根哈希是否与目标提议中携带的根哈希一致。Specifically, the consensus backup node that receives the target proposal, based on the transaction data corresponding to the target view, determines whether the broadcast network client of the node has data that matches the root hash in the target proposal. The transaction data of the view obtains the root hash formed by the transaction data corresponding to the target view, and then it is determined whether the root hash formed by the transaction data corresponding to the target view is consistent with the root hash carried in the target proposal.
若该对应于目标视图的交易数据构成的根哈希与目标提议中携带的根哈希一致,则表明本节点的广播网络客户端存在与目标提议中的根哈希相匹配的数据;而若该对应于目标视图的交易数据构成的根哈希与目标提议中携带的根哈希不一致,则表明本节点的广播网络客户端不存在与目标提议中的根哈希相匹配的数据。If the root hash formed by the transaction data corresponding to the target view is consistent with the root hash carried in the target proposal, it indicates that the broadcast network client of this node has data that matches the root hash in the target proposal; and if The root hash formed by the transaction data corresponding to the target view is inconsistent with the root hash carried in the target proposal, indicating that the broadcast network client of this node does not have data that matches the root hash in the target proposal.
可选地,接收到目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据,包括:接收到目标提议的共识备份节点的广播网络客户端经由广播网络,接收来自共识主节点的待共识数据;接收到目标提议的共识备份节点,确定本节点的广播网络客户端接收到的待共识数据是否与目标提议中的根哈希相匹配。Optionally, the consensus backup node that receives the target proposal, determines whether the broadcast network client of this node has data that matches the root hash in the target proposal, including: the broadcast network client that receives the consensus backup node proposed by the target The end receives the consensus data from the consensus master node via the broadcast network; the consensus backup node that receives the target proposal determines whether the consensus data received by the broadcast network client of this node matches the root hash of the target proposal.
可选地,接收到目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据之后,所述方法还包括:接收到目标提议的共识 备份节点,若确定本节点的广播网络客户端不存在与目标提议中的根哈希相匹配的数据,则在接收到目标提议的待预设时间段之后,确定本节点的广播网络客户端是否接收到与目标提议中的根哈希相匹配的数据。Optionally, after receiving the consensus backup node proposed by the target and determining whether the broadcast network client of this node has data matching the root hash in the target proposal, the method further includes: receiving the consensus backup proposed by the target The node, if it is determined that the broadcast network client of this node does not have data that matches the root hash in the target proposal, it will determine whether the broadcast network client of this node receives the target proposal for a preset period of time To the data that matches the root hash in the target proposal.
其中,预设时间段为预先设定的超时时间的上限。接收到目标提议的共识备份节点,若确定本节点的广播网络客户端不存在与目标提议中的根哈希相匹配的数据,通常会等待一个超时时间,当超时时间后,仍然从本节点的广播网络客户端查询不到与目标提议中的根哈希相匹配的数据,则可以发起视图切换操作,即开始对目标提议的下一个提议的共识操作。Among them, the preset time period is the upper limit of the preset timeout period. The consensus backup node that receives the target proposal, if it is determined that the broadcast network client of this node does not have data that matches the root hash in the target proposal, it will usually wait for a timeout period. If the broadcast network client cannot find the data that matches the root hash of the target proposal, it can initiate a view switching operation, that is, start a consensus operation on the next proposal proposed by the target.
可选地,为了不影响目标提议之后的提议的共识操作,接收到目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据之后,所述方法还包括:接收到目标提议的共识备份节点,若在接收到目标提议的预设时间段之后,确定本节点的广播网络客户端不存在与目标提议中的根哈希相匹配的数据,则发起视图切换操作。Optionally, in order not to affect the consensus operation of the proposal after the target proposal, after receiving the consensus backup node of the target proposal, it is determined whether the broadcast network client of this node has data that matches the root hash in the target proposal, so The method further includes: the consensus backup node that receives the target proposal, if after receiving the target proposal for a preset time period, it is determined that the broadcast network client of the node does not have data that matches the root hash of the target proposal, The view switching operation is initiated.
继续沿用区块链中的共识算法为PBFT共识算法为例,详细描述接收到目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据的过程。Continue to use the consensus algorithm in the blockchain as the PBFT consensus algorithm as an example, describe in detail the consensus backup node that receives the target proposal, and determine whether the broadcast network client of this node has data that matches the root hash in the target proposal process.
共识备份节点接收到针对目标提议的PRE-PREPARE消息之后,对该PRE-PREPARE消息进行验证,主要验证以下内容:共识主节点对PRE-PREPARE消息的签名是否正确,其本节点的广播网络客户端中是否存在与d相匹配的一个或多个交易集合,n是否在区间[h,H]内,以及该共识备份节点是否已经收到了一条在同一v下并且编号也是n,但是签名不同的PRE-PREPARE信息。After the consensus backup node receives the PRE-PREPARE message proposed for the target, it verifies the PRE-PREPARE message, mainly verifying the following: the consensus master node’s signature of the PRE-PREPARE message is correct, and the broadcast network client of its own node Whether there are one or more transaction sets that match d, whether n is in the interval [h, H], and whether the consensus backup node has received a PRE that is under the same v and numbered n but has a different signature -PREPARE information.
步骤140,接收到目标提议的共识备份节点,若确定本节点的广播网络客户端存在与目标提议中的根哈希相匹配的数据,则对目标提议进行共识操作。In step 140, the consensus backup node proposed by the target is received, and if it is determined that the broadcast network client of the node has data matching the root hash in the target proposal, then a consensus operation is performed on the target proposal.
可选地,为了对目标提议对应的待共识数据进行写块操作,在接收到目标提议的共识备份节点对目标提议进行共识操作之后,所述方法还包括:若区块链中的节点接收到来自不少于3f+1个节点针对目标提议的有效验证消息,则生成记录有待共识数据的区块;其中,f为区块链中允许的最大异常节点数量。Optionally, in order to write a block operation on the data to be consensus corresponding to the target proposal, after the consensus backup node that receives the target proposal performs the consensus operation on the target proposal, the method further includes: if the node in the blockchain receives A valid verification message from no less than 3f+1 nodes for the target proposal will generate a block recording the data to be consensus; where f is the maximum number of abnormal nodes allowed in the blockchain.
继续沿用区块链中的共识算法为PBFT共识算法为例,详细描述接收到目标提议的共识备份节点,若确定本节点的广播网络客户端存在与目标提议中的根哈希相匹配的数据,则对目标提议进行共识操作的过程。Continue to use the consensus algorithm in the blockchain as the PBFT consensus algorithm as an example to describe in detail the consensus backup node that receives the target proposal. If it is determined that the broadcast network client of this node has data that matches the root hash of the target proposal, The process of consensus operation on the target proposal.
共识备份节点对接收到的PRE-PREPARE消息验证通过后,向区块链中的其他节点包括共识主节点发送一条PREPARE消息,格式为<PREPARE,v,n,d,i>消息,v,n,d,m与上述PRE-PREPARE消息内容相同,i是当前共识备份节点的编号,同时对<PREPARE,v,n,d,i>进行签名;区块链中的共识主节点和其他共识备份节点接收到该PREPARE消息之后,主要进行以下校验:该PREPARE消息的签名是否正确,接收到该PREPARE消息的节点是否已收到了同一视图view下的n,n是否在区间[h,H]内,以及d是否和已收到的PRE-PREPARE消息中的d相同。如果有至少一项验证不通过,则丢弃该消息;如果区块链中的共识主节点和其他共识备份节点接收不少于3f+1个节点的PREPARE消息,且验证通过,则向区块链中的其他节点发送COMMIT消息以及消息签名,格式为<COMMIT,v,n,d,i>,其中,v,n,d,i与上述PREPARE消息内容相同;区块链中的节点接收到该COMMIT消息之后,对该COMMIT消息进行验证,主要校验以下几项:COMMIT消息的签名是否正确,是否已接收到同一视图view下的n,其管理的交易内存池中是否存在与d相匹配的一个或多个交易集合,n是否在区间[h,H]内。After the consensus backup node passes the verification of the received PRE-PREPARE message, it sends a PRE-PREPARE message to other nodes in the blockchain, including the consensus master node, in the format of <PREPARE,v,n,d,i>message, v,n ,d,m have the same content as the above PRE-PREPARE message, i is the number of the current consensus backup node, and at the same time sign <PREPARE,v,n,d,i>; the consensus master node and other consensus backups in the blockchain After the node receives the PREPARE message, it mainly performs the following checks: whether the signature of the PREPARE message is correct, whether the node receiving the PREPARE message has received the n under the same view, and whether n is in the interval [h, H] , And whether d is the same as d in the received PRE-PREPARE message. If at least one verification fails, the message is discarded; if the consensus master node and other consensus backup nodes in the blockchain receive PREPARE messages from no less than 3f+1 nodes, and the verification is passed, the message is sent to the blockchain The other nodes in the node send the COMMIT message and the message signature in the format of <COMMIT,v,n,d,i>, where v,n,d,i are the same as the above PREPARE message content; the node in the blockchain receives the After the COMMIT message, verify the COMMIT message, mainly to verify the following items: whether the signature of the COMMIT message is correct, whether the n under the same view has been received, and whether there is a matching d in the transaction memory pool managed by it One or more transaction sets, whether n is in the interval [h, H].
下面以图2所示的区块链中的共识方法应用于实际场景中的示意图为例,对本说明书实施例提供的方法进行详细介绍,如图2所示,该区块链网络包括一个共识主节点和多个共识备份节点,为便于描述,共识备份节点以其中一个共识备份节点为例,应理解,在实际场景中,共识备份节点的数量通常为多个。该区块链中的共识方法的实施流程包括:The following takes the schematic diagram of the application of the consensus method in the blockchain shown in FIG. 2 in an actual scenario as an example to introduce the method provided in the embodiment of this specification in detail. As shown in FIG. 2, the blockchain network includes a consensus master. Nodes and multiple consensus backup nodes. For ease of description, the consensus backup node takes one of the consensus backup nodes as an example. It should be understood that in actual scenarios, the number of consensus backup nodes is usually multiple. The implementation process of the consensus method in the blockchain includes:
S1,共识主节点在确定本节点收集的至少一个交易集合是否满足预设的交易收集条件之后,在发起针对该至少一个交易集合的共识提议时,向本节点的广播网络客户端发送该至少一个交易集合。其中预设的交易收集条件包括比如该至少一个交易集合中的交易数量是否大于或等于预设数量、该至少一个交易集合的收集周期是否大于或等于指定的收集周期、和/或该至少一个交易集合的大小是否大于或等于指定容量,等等。S1: After determining whether at least one transaction set collected by this node meets the preset transaction collection conditions, the consensus master node sends the at least one to the broadcast network client of the node when initiating a consensus proposal for the at least one transaction set. Transaction collection. The preset transaction collection conditions include, for example, whether the number of transactions in the at least one transaction set is greater than or equal to a preset number, whether the collection period of the at least one transaction set is greater than or equal to a specified collection period, and/or the at least one transaction Is the size of the collection greater than or equal to the specified capacity, etc.
S2,共识主节点向共识备份节点发送pre-prepare消息,该pre-prepare消息中包含至少一个交易集合构成的根哈希以及区块元数据(用于指示所发起的共识提议对应的视图和区块号)。S2. The consensus master node sends a pre-prepare message to the consensus backup node. The pre-prepare message contains the root hash of at least one transaction set and block metadata (used to indicate the view and area corresponding to the initiated consensus proposal). Block number).
S3,共识主节点中的广播网络客户端将该至少一个交易集合发送给广播网络,使得该广播网络将该至少一个交易集合发送给共识备份节点的广播网络客户端。S3: The broadcast network client in the consensus master node sends the at least one transaction set to the broadcast network, so that the broadcast network sends the at least one transaction set to the broadcast network client of the consensus backup node.
S4,广播网络将该至少一个交易集合发送给共识备份节点的广播网络客户端。S4: The broadcast network sends the at least one transaction set to the broadcast network client of the consensus backup node.
S5,共识备份节点从本节点的广播网络客户端中获取与pre-prepare消息中的区块元数据一致的交易数据,并确定获取的交易数据对应的根哈希是否与pre-prepare消息中 的根哈希一致,若一致,则继续对共识提议的共识操作,否则等待预设时间段。S5. The consensus backup node obtains transaction data consistent with the block metadata in the pre-prepare message from the broadcast network client of the node, and determines whether the root hash corresponding to the obtained transaction data is the same as that in the pre-prepare message The root hashes are consistent. If they are consistent, continue the consensus operation on the consensus proposal, otherwise wait for the preset time period.
如果在预设时间段之后,共识备份节点仍然从本节点的广播网络客户端未查找到与pre-prepare消息中的根哈希相匹配的交易数据,则发起视图切换操作,对共识提议的下一个提议进行共识操作。If after the preset time period, the consensus backup node still does not find the transaction data matching the root hash in the pre-prepare message from the broadcast network client of the node, it will initiate a view switch operation to download the consensus proposal. A proposal for consensus operation.
若共识备份节点在指定时间段内查询到与目标提议中的待写入的区块号对应且不在管理的交易内存池中的交易集合,则执行S7,并在通过验证后继续执行对目标提议的共识操作;而若共识备份节点在指定时间段内没有查询到与目标提议中的待写入的区块号对应且不在管理的交易内存池中的交易集合,则执行视图切换操作。If the consensus backup node finds the transaction set corresponding to the block number to be written in the target proposal and is not in the managed transaction memory pool within the specified time period, execute S7, and continue to execute the target proposal after passing the verification If the consensus backup node does not find the transaction set corresponding to the block number to be written in the target proposal and not in the managed transaction memory pool within the specified time period, the view switching operation will be performed.
采用本说明书实施例提供的共识方法,共识主节点在区块链中发起针对待共识数据的目标提议,并调用本节点的广播网络客户端将待共识数据广播至区块链中的共识备份节点,目标提议中包含待共识数据构成的根哈希;接收到目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与目标提议中的根哈希相匹配的数据,以及若确定本节点的广播网络客户端存在与目标提议中的根哈希相匹配的数据,则对目标提议进行共识操作。Using the consensus method provided in the embodiment of this specification, the consensus master node initiates a target proposal for the data to be agreed in the blockchain, and calls the broadcast network client of this node to broadcast the data to be agreed to the consensus backup node in the blockchain , The target proposal contains the root hash of the consensus data; the consensus backup node that receives the target proposal determines whether the broadcast network client of this node has data that matches the root hash in the target proposal, and if it is determined The broadcast network client of the node has data that matches the root hash in the target proposal, and then performs a consensus operation on the target proposal.
也就是说,在共识主节点发起共识操作时,向共识备份节点传输的是目标提议的待共识数据的根哈希,而不是待共识数据的原始数据,以及通过共识主节点中的广播网络客户端将待共识数据的原始数据广播至区块链中的共识备份节点。这一方面由于节点之间直接进行传输的是待共识数据的根哈希,在节点之间传输根哈希相对原始数据而言极大地节省了数据传输时占用的带宽;另一方面通过广播网络传输待共识数据的原始数据也减少了数据传输的时延。That is to say, when the consensus master node initiates a consensus operation, what is transmitted to the consensus backup node is the root hash of the consensus data proposed by the target, not the original data of the consensus data, and the broadcast network client in the consensus master node The terminal broadcasts the original data of the data to be consensus to the consensus backup node in the blockchain. On the one hand, because the root hash of the data to be consensus is directly transmitted between nodes, the transmission of root hash between nodes greatly saves the bandwidth occupied during data transmission compared with the original data; on the other hand, through the broadcast network Transmission of the original data of the data to be agreed also reduces the delay of data transmission.
图3是本说明书实施例提供的区块链系统300的结构示意图。请参考图3,在一种软件实施方式中,区块链系统300可包括共识主节点310和多个共识备份节点320,其中:共识主节点310,在区块链中发起针对待共识数据的目标提议,所述目标提议中包含待共识数据构成的根哈希;以及调用本节点的广播网络客户端将所述待共识数据广播至区块链中的共识备份节点;接收到所述目标提议的共识备份节点320,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据;以及若确定本节点的广播网络客户端存在与所述目标提议中的根哈希相匹配的数据,则对所述目标提议进行共识操作。FIG. 3 is a schematic structural diagram of a blockchain system 300 provided by an embodiment of this specification. Please refer to FIG. 3, in a software implementation, the blockchain system 300 may include a consensus master node 310 and a plurality of consensus backup nodes 320, among which: the consensus master node 310 initiates a transaction for the consensus data in the blockchain A target proposal, the target proposal contains the root hash composed of the data to be agreed; and the broadcast network client that calls the node broadcasts the data to be agreed to the consensus backup node in the blockchain; the target proposal is received The consensus backup node 320 of this node determines whether the broadcast network client of this node has data that matches the root hash in the target proposal; and if it is determined that the broadcast network client of this node has the root hash in the target proposal For data matching the hash, a consensus operation is performed on the target proposal.
基于本说明书实施例提供的区块链系统可以知道:在共识主节点发起共识操作时,向共识备份节点传输的是目标提议的待共识数据的根哈希,而不是待共识数据的原始数据,以及通过共识主节点中的广播网络客户端将待共识数据的原始数据广播至区块链中 的共识备份节点。这一方面由于节点之间直接进行传输的是待共识数据的根哈希,在节点之间传输根哈希相对原始数据而言极大地节省了数据传输时占用的带宽;另一方面通过广播网络传输待共识数据的原始数据也减少了数据传输的时延。Based on the blockchain system provided by the embodiment of this specification, it can be known that when the consensus master node initiates a consensus operation, the root hash of the consensus data proposed by the target is transmitted to the consensus backup node, rather than the original data of the consensus data. And through the broadcast network client in the consensus master node, the original data of the data to be consensus is broadcast to the consensus backup node in the blockchain. On the one hand, because the root hash of the data to be consensus is directly transmitted between nodes, the transmission of root hash between nodes greatly saves the bandwidth occupied during data transmission compared with the original data; on the other hand, through the broadcast network Transmission of the original data of the data to be agreed also reduces the delay of data transmission.
可选地,在一种实施方式中,接收到所述目标提议的共识备份节点320,用于:基于所述目标提议对应的目标视图,从本节点的广播网络客户端中获取对应于所述目标视图的交易数据;基于对应于所述目标视图的交易数据,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据。Optionally, in an implementation manner, the consensus backup node 320 that has received the target proposal is configured to: based on the target view corresponding to the target proposal, obtain from the broadcast network client of the node corresponding to the Transaction data of the target view; based on the transaction data corresponding to the target view, determine whether the broadcast network client of this node has data that matches the root hash in the target proposal.
可选地,在一种实施方式中,所述共识主节点310,用于:获取所述待共识数据,并基于所述待共识数据,生成包含有所述待共识数据构成的根哈希的所述目标提议;若确定所述待共识数据满足预设的交易收集条件,则基于所述待共识数据,生成包含有所述待共识数据构成的根哈希的所述目标提议。Optionally, in one embodiment, the consensus master node 310 is configured to: obtain the data to be agreed, and based on the data to be agreed, generate a root hash that contains the data to be agreed The target proposal; if it is determined that the data to be agreed upon meets a preset transaction collection condition, based on the data to be agreed, the target proposal including the root hash formed by the data to be agreed is generated.
可选地,在一种实施方式中,所述共识主节点310,用于:将所述待共识数据发送给本节点的广播网络客户端;所述共识主节点的广播网络客户端将所述待共识数据经由所述区块链的广播网络,广播至所述区块链中的共识备份节点。Optionally, in an implementation manner, the consensus master node 310 is configured to: send the data to be agreed to the broadcast network client of the node; the broadcast network client of the consensus master node sends the The consensus data is broadcast to the consensus backup node in the blockchain via the broadcasting network of the blockchain.
可选地,在一种实施方式中,在接收到所述目标提议的共识备份节点320对所述目标提议进行共识操作之后,若所述区块链中的共识主节点310或共识备份节点320接收到来自不少于3f+1个节点针对所述目标提议的有效验证消息,则生成记录有所述待共识数据的区块;其中,f为所述区块链中允许的最大异常节点数量。Optionally, in an embodiment, after the consensus backup node 320 receiving the target proposal performs a consensus operation on the target proposal, if the consensus master node 310 or the consensus backup node 320 in the blockchain Receive valid verification messages from no less than 3f+1 nodes for the target proposal, then generate a block recording the data to be agreed; where f is the maximum number of abnormal nodes allowed in the blockchain .
可选地,在一种实施方式中,接收到所述目标提议的共识备份节点320,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据之后,接收到所述目标提议的共识备份节点320,还用于:若确定本节点的广播网络客户端不存在与所述目标提议中的根哈希相匹配的数据,则在接收到所述目标提议的待预设时间段之后,确定本节点的广播网络客户端是否接收到与所述目标提议中的根哈希相匹配的数据。Optionally, in an implementation manner, after receiving the consensus backup node 320 of the target proposal, after determining whether the broadcast network client of the node has data matching the root hash in the target proposal, it receives The consensus backup node 320 to the target proposal is also used to: if it is determined that the broadcast network client of this node does not have data that matches the root hash in the target proposal, then the target proposal is received After a preset period of time, it is determined whether the broadcast network client of the node receives data that matches the root hash in the target proposal.
可选地,在一种实施方式中,接收到所述目标提议的共识备份节点320,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据之后,接收到所述目标提议的共识备份节点320,还用于:若在接收到所述目标提议的预设时间段之后,确定本节点的广播网络客户端不存在与所述目标提议中的根哈希相匹配的数据,则发起视图切换操作。Optionally, in an implementation manner, after receiving the consensus backup node 320 of the target proposal, after determining whether the broadcast network client of the node has data matching the root hash in the target proposal, it receives The consensus backup node 320 to the target proposal is also used to: if the target proposal is received for the preset time period, it is determined that the broadcast network client of this node does not have the root hash in the target proposal. If the matching data is matched, the view switching operation is initiated.
可选地,在一种实施方式中,共识主节点在区块链中发起针对待共识数据的目标提议采用的共识算法包括下述至少一种:实用拜占庭容错PBFT共识算法;Hotstuff共识算法;LibraBFT共识算法;Tendermint共识算法。Optionally, in an implementation manner, the consensus algorithm used by the consensus master node to initiate a target proposal for the consensus data in the blockchain includes at least one of the following: a practical Byzantine fault-tolerant PBFT consensus algorithm; a Hotstuff consensus algorithm; LibraBFT Consensus algorithm; Tendermint consensus algorithm.
区块链系统300能够实现图1~图2的方法实施例的方法,具体可参考图1~图2所示实施例的区块链中的共识方法,不再赘述。The blockchain system 300 can implement the methods of the method embodiments shown in FIGS. 1 to 2. For details, please refer to the consensus method in the blockchain of the embodiment shown in FIGS. 1 to 2, which will not be repeated here.
总之,以上所述仅为本说明书的较佳实施例而已,并非用于限定本说明书的保护范围。凡在本说明书一个或多个实施例的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本说明书一个或多个实施例的保护范围之内。In short, the above descriptions are only preferred embodiments of this specification, and are not used to limit the protection scope of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of this specification shall be included in the protection scope of one or more embodiments of this specification.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules, or units explained in the foregoing embodiments may be specifically implemented by computer chips or entities, or implemented by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cell phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or Any combination of these devices.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media include permanent and non-permanent, removable and non-removable media, and information storage can be realized by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, CD-ROM, digital versatile disc (DVD) or other optical storage, Magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media can be used to store information that can be accessed by computing devices. According to the definition in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "include", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or equipment including a series of elements includes not only those elements, but also Other elements that are not explicitly listed, or include elements inherent to such processes, methods, commodities, or equipment. If there are no more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, method, commodity or equipment that includes the element.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, as for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for related parts, please refer to the part of the description of the method embodiment.

Claims (10)

  1. 一种区块链中的共识方法,包括:A consensus method in the blockchain, including:
    共识主节点在区块链中发起针对待共识数据的目标提议,所述目标提议中包含待共识数据构成的根哈希;The consensus master node initiates a target proposal for the data to be consensus in the blockchain, and the target proposal contains the root hash composed of the data to be consensus;
    所述共识主节点调用本节点的广播网络客户端,将所述待共识数据广播至区块链中的共识备份节点;The consensus master node calls the broadcast network client of this node to broadcast the consensus data to the consensus backup node in the blockchain;
    接收到所述目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据;The consensus backup node that receives the target proposal, and determines whether the broadcast network client of the node has data that matches the root hash in the target proposal;
    接收到所述目标提议的共识备份节点,若确定本节点的广播网络客户端存在与所述目标提议中的根哈希相匹配的数据,则对所述目标提议进行共识操作。The consensus backup node that receives the target proposal, if it is determined that the broadcast network client of the node has data that matches the root hash in the target proposal, then performs a consensus operation on the target proposal.
  2. 如权利要求1所述的方法,接收到所述目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据,包括:The method according to claim 1, wherein the consensus backup node that receives the target proposal and determines whether the broadcast network client of the node has data matching the root hash in the target proposal includes:
    接收到所述目标提议的共识备份节点,基于所述目标提议对应的目标视图,从本节点的广播网络客户端中获取对应于所述目标视图的交易数据;The consensus backup node that receives the target proposal obtains transaction data corresponding to the target view from the broadcast network client of the node based on the target view corresponding to the target proposal;
    接收到所述目标提议的共识备份节点,基于对应于所述目标视图的交易数据,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据。The consensus backup node that receives the target proposal, based on the transaction data corresponding to the target view, determines whether the broadcast network client of the node has data that matches the root hash in the target proposal.
  3. 如权利要求1所述的方法,共识主节点在区块链中发起针对待共识数据的目标提议,包括:The method according to claim 1, wherein the consensus master node initiates a target proposal for the data to be agreed in the blockchain, including:
    所述共识主节点获取所述待共识数据,并基于所述待共识数据,生成包含有所述待共识数据构成的根哈希的所述目标提议;The consensus master node obtains the data to be agreed, and based on the data to be agreed, generates the target proposal including the root hash formed by the data to be agreed;
    所述共识主节点若确定所述待共识数据满足预设的交易收集条件,则基于所述待共识数据,生成包含有所述待共识数据构成的根哈希的所述目标提议。If the consensus master node determines that the data for consensus meets the preset transaction collection conditions, based on the data for consensus, the target proposal including the root hash formed by the data for consensus is generated.
  4. 如权利要求1所述的方法,所述共识主节点调用本节点的广播网络客户端将所述待共识数据广播至区块链中的共识备份节点,包括;The method according to claim 1, wherein the consensus master node calls the broadcast network client of the node to broadcast the data to be consensus to the consensus backup node in the blockchain, comprising;
    所述共识主节点将所述待共识数据发送给本节点的广播网络客户端;The consensus master node sends the data to be agreed upon to the broadcast network client of the node;
    所述共识主节点的广播网络客户端将所述待共识数据经由所述区块链的广播网络,广播至所述区块链中的共识备份节点。The broadcast network client of the consensus master node broadcasts the to-be-consensus data to the consensus backup node in the blockchain via the broadcast network of the blockchain.
  5. 如权利要求4所述的方法,接收到所述目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据,包括:The method according to claim 4, the consensus backup node that receives the target proposal, and determines whether the broadcast network client of the node has data matching the root hash in the target proposal, comprising:
    接收到所述目标提议的共识备份节点的广播网络客户端经由所述广播网络,接收来自所述共识主节点的所述待共识数据;The broadcast network client that receives the consensus backup node proposed by the target receives the data to be agreed from the consensus master node via the broadcast network;
    接收到所述目标提议的共识备份节点,确定本节点的广播网络客户端接收到的所述 待共识数据是否与所述目标提议中的根哈希相匹配。The consensus backup node that receives the target proposal determines whether the data to be consensus received by the broadcast network client of the node matches the root hash in the target proposal.
  6. 如权利要求1所述的方法,在接收到所述目标提议的共识备份节点对所述目标提议进行共识操作之后,所述方法还包括:The method according to claim 1, after the consensus backup node that receives the target proposal performs a consensus operation on the target proposal, the method further comprises:
    若所述区块链中的节点接收到来自不少于3f+1个节点针对所述目标提议的有效验证消息,则生成记录有所述待共识数据的区块;其中,f为所述区块链中允许的最大异常节点数量。If a node in the blockchain receives a valid verification message proposed by no less than 3f+1 nodes for the target, a block recording the data to be agreed upon is generated; where f is the zone The maximum number of abnormal nodes allowed in the blockchain.
  7. 如权利要求1所述的方法,接收到所述目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据之后,所述方法还包括:The method according to claim 1, after receiving the consensus backup node of the target proposal, and determining whether the broadcast network client of the node has data matching the root hash in the target proposal, the method further include:
    接收到所述目标提议的共识备份节点,若确定本节点的广播网络客户端不存在与所述目标提议中的根哈希相匹配的数据,则在接收到所述目标提议的待预设时间段之后,确定本节点的广播网络客户端是否接收到与所述目标提议中的根哈希相匹配的数据。The consensus backup node that receives the target proposal, if it is determined that the broadcast network client of this node does not have data that matches the root hash in the target proposal, it will wait for a preset time after receiving the target proposal After the segment, it is determined whether the broadcast network client of this node receives data that matches the root hash in the target proposal.
  8. 如权利要求7所述的方法,接收到所述目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据之后,所述方法还包括:The method according to claim 7, after receiving the consensus backup node of the target proposal, and determining whether the broadcast network client of the node has data matching the root hash in the target proposal, the method further include:
    接收到所述目标提议的共识备份节点,若在接收到所述目标提议的预设时间段之后,确定本节点的广播网络客户端不存在与所述目标提议中的根哈希相匹配的数据,则发起视图切换操作。The consensus backup node that receives the target proposal, if after receiving the target proposal for the preset time period, it is determined that the broadcast network client of this node does not have data that matches the root hash of the target proposal , The view switching operation is initiated.
  9. 如权利要求1-8中任一所述的方法,共识主节点在区块链中发起针对待共识数据的目标提议采用的共识算法包括下述至少一种:According to the method according to any one of claims 1-8, the consensus algorithm that the consensus master node initiates in the blockchain for the target proposal of the consensus data includes at least one of the following:
    实用拜占庭容错PBFT共识算法;Practical Byzantine fault-tolerant PBFT consensus algorithm;
    Hotstuff共识算法;Hotstuff consensus algorithm;
    LibraBFT共识算法;LibraBFT consensus algorithm;
    Tendermint共识算法。Tendermint consensus algorithm.
  10. 一种区块链中的共识系统,包括:A consensus system in the blockchain, including:
    共识主节点,在区块链中发起针对待共识数据的目标提议,所述目标提议中包含待共识数据构成的根哈希;以及调用本节点的广播网络客户端将所述待共识数据广播至区块链中的共识备份节点;The consensus master node initiates a target proposal for the consensus data in the blockchain, the target proposal contains the root hash of the consensus data; and the broadcast network client calling this node broadcasts the consensus data to Consensus backup nodes in the blockchain;
    接收到所述目标提议的共识备份节点,确定本节点的广播网络客户端是否存在与所述目标提议中的根哈希相匹配的数据;以及若确定本节点的广播网络客户端存在与所述目标提议中的根哈希相匹配的数据,则对所述目标提议进行共识操作。The consensus backup node that receives the target proposal determines whether the broadcast network client of this node has data that matches the root hash in the target proposal; and if it is determined that the broadcast network client of this node exists and the If the root hash of the target proposal matches the data, the consensus operation is performed on the target proposal.
PCT/CN2021/097897 2020-06-05 2021-06-02 Method for consensus in blockchain, and system WO2021244568A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010506075.2 2020-06-05
CN202010506075.2A CN111600965B (en) 2020-06-05 2020-06-05 Consensus method and system in blockchain

Publications (1)

Publication Number Publication Date
WO2021244568A1 true WO2021244568A1 (en) 2021-12-09

Family

ID=72190106

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/097897 WO2021244568A1 (en) 2020-06-05 2021-06-02 Method for consensus in blockchain, and system

Country Status (2)

Country Link
CN (1) CN111600965B (en)
WO (1) WO2021244568A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114338673A (en) * 2021-12-30 2022-04-12 马上消费金融股份有限公司 Transaction data processing method, device, equipment, system and storage medium
CN114401271A (en) * 2022-01-13 2022-04-26 中国人民解放军国防科技大学 Test data tamper-proof method, block chain system and medium
CN114598475A (en) * 2022-01-24 2022-06-07 浙江甲骨文超级码科技股份有限公司 Byzantine fault-tolerant consensus algorithm and system based on fabric

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111600965B (en) * 2020-06-05 2023-10-27 支付宝(杭州)信息技术有限公司 Consensus method and system in blockchain
CN112801794B (en) * 2021-02-08 2022-04-15 网易(杭州)网络有限公司 Transaction execution method and device, electronic equipment and storage medium
CN113365229B (en) * 2021-05-28 2022-03-25 电子科技大学 Network time delay optimization method of multi-union chain consensus algorithm
CN113254272B (en) * 2021-06-09 2022-09-13 腾讯科技(深圳)有限公司 Data processing method and device for block chain network, computer equipment and medium
CN113573255A (en) * 2021-07-26 2021-10-29 上海点融信息科技有限责任公司 Method, device and storage medium for consensus based on block chain
CN113821569B (en) * 2021-09-30 2024-02-06 广州智链未来科技有限公司 Block chain consensus method and block chain

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180253702A1 (en) * 2015-11-24 2018-09-06 Gartland & Mellina Group Blockchain solutions for financial services and other transactions-based industries
CN108550038A (en) * 2018-04-18 2018-09-18 杭州秘猿科技有限公司 A kind of data dissemination system and method applied to block chain
CN109150598A (en) * 2018-08-10 2019-01-04 上交所技术有限责任公司 A kind of BFT common recognition algorithm bandwidth utilization rate improved method based on block piece
CN109379397A (en) * 2018-08-31 2019-02-22 阿里巴巴集团控股有限公司 Transaction common recognition processing method and processing device, electronic equipment based on block chain
US20200026699A1 (en) * 2018-07-20 2020-01-23 True Blockchain Technology Ltd. Highly Performant Decentralized Public Ledger with Hybrid Consensus
CN110798308A (en) * 2019-10-31 2020-02-14 支付宝(杭州)信息技术有限公司 Block chain signature method and system
CN111600965A (en) * 2020-06-05 2020-08-28 支付宝(杭州)信息技术有限公司 Consensus method and system in block chain

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101656618B (en) * 2009-09-11 2012-09-05 中兴通讯股份有限公司 Multimedia message broadcasting method and system based on structural Peer-to-Peer Network (PPN)
JP6140312B2 (en) * 2013-04-11 2017-05-31 エルジー エレクトロニクス インコーポレイティド Optimal route transmission method including a plurality of waypoints and apparatus therefor
US10204341B2 (en) * 2016-05-24 2019-02-12 Mastercard International Incorporated Method and system for an efficient consensus mechanism for permissioned blockchains using bloom filters and audit guarantees
CN106878000B (en) * 2017-03-06 2020-02-21 中钞信用卡产业发展有限公司杭州区块链技术研究院 Alliance chain consensus method and system
CN107220130B (en) * 2017-05-12 2021-12-07 北京众享比特科技有限公司 Method, device and system for realizing information consensus at nodes of block chain
US10826987B2 (en) * 2018-04-06 2020-11-03 Datalogic Ip Tech S.R.L. Systems and methods for consensus-based data security for networked devices
KR102079786B1 (en) * 2018-10-25 2020-02-21 주식회사 팀그릿 Method and system for providing sales broadcast using block-chain
CN109327548A (en) * 2018-11-27 2019-02-12 北京瑞卓喜投科技发展有限公司 A kind of block chain update method and block chain more new system
CN110727731B (en) * 2019-09-05 2021-12-21 创新先进技术有限公司 Method for adding node in block chain network and block chain system
CN111212126B (en) * 2019-12-27 2023-05-26 百度在线网络技术(北京)有限公司 Data transmission method, device, equipment and medium of block chain network
GB2592980A (en) * 2020-03-13 2021-09-15 Nchain Holdings Ltd Blockchain transaction double spend proof

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180253702A1 (en) * 2015-11-24 2018-09-06 Gartland & Mellina Group Blockchain solutions for financial services and other transactions-based industries
CN108550038A (en) * 2018-04-18 2018-09-18 杭州秘猿科技有限公司 A kind of data dissemination system and method applied to block chain
US20200026699A1 (en) * 2018-07-20 2020-01-23 True Blockchain Technology Ltd. Highly Performant Decentralized Public Ledger with Hybrid Consensus
CN109150598A (en) * 2018-08-10 2019-01-04 上交所技术有限责任公司 A kind of BFT common recognition algorithm bandwidth utilization rate improved method based on block piece
CN109379397A (en) * 2018-08-31 2019-02-22 阿里巴巴集团控股有限公司 Transaction common recognition processing method and processing device, electronic equipment based on block chain
CN110798308A (en) * 2019-10-31 2020-02-14 支付宝(杭州)信息技术有限公司 Block chain signature method and system
CN111600965A (en) * 2020-06-05 2020-08-28 支付宝(杭州)信息技术有限公司 Consensus method and system in block chain

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114338673A (en) * 2021-12-30 2022-04-12 马上消费金融股份有限公司 Transaction data processing method, device, equipment, system and storage medium
CN114401271A (en) * 2022-01-13 2022-04-26 中国人民解放军国防科技大学 Test data tamper-proof method, block chain system and medium
CN114598475A (en) * 2022-01-24 2022-06-07 浙江甲骨文超级码科技股份有限公司 Byzantine fault-tolerant consensus algorithm and system based on fabric
CN114598475B (en) * 2022-01-24 2022-11-01 浙江甲骨文超级码科技股份有限公司 Byzantine fault-tolerant consensus method and system based on fabric

Also Published As

Publication number Publication date
CN111600965A (en) 2020-08-28
CN111600965B (en) 2023-10-27

Similar Documents

Publication Publication Date Title
WO2021244568A1 (en) Method for consensus in blockchain, and system
CN108648078B (en) Transaction preprocessing method and device and electronic equipment
TWI710979B (en) Cross-block chain interaction method, device, system, and electronic equipment
CN109189751B (en) Data synchronization method based on block chain and terminal equipment
TWI690184B (en) Cross-blockchain authentication method and device, and electronic equipment
WO2020216280A1 (en) Block processing methods, node and system
CN111539726B (en) Block chain consensus system and method
TWI727467B (en) Trustworthiness verification method, system, device and equipment of alliance chain
US11444783B2 (en) Methods and apparatuses for processing transactions based on blockchain integrated station
EP3933646B1 (en) Consensus methods and systems in consortium blockchain
TWI724574B (en) Block chain-based accounting method and device, and electronic equipment
WO2023045620A1 (en) Transaction data processing method and apparatus, computer device and storage medium
WO2021244581A1 (en) Consensus method in alliance chain and alliance chain system
WO2020063763A1 (en) Data storage method, apparatus and system, and server, control node and medium
US20210158351A1 (en) Methods, systems, apparatuses and devices for verifying credibility of consortium blockchain
US11783339B2 (en) Methods and apparatuses for transferring transaction based on blockchain integrated station
US20230098190A1 (en) Data processing method, apparatus, device and medium based on distributed storage
TWI716822B (en) Method and device for correcting transaction causality, and electronic equipment
US20210160312A1 (en) Service processing methods and systrems based on a consortium blockchain network
TWI686703B (en) Method and device for data storage and business processing
US20210328907A1 (en) Blockchain systems, and message transmission methods and apparatuses
WO2023050986A1 (en) Maintenance of network architecture information of blockchain system
EP3933647A1 (en) Consensus methods and systems in consortium blockchain
CN117061535A (en) Multi-activity framework data synchronization method, device, computer equipment and storage medium
CN112258184B (en) Method, apparatus, electronic device and readable storage medium for freezing blockchain network

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

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

Country of ref document: EP

Kind code of ref document: A1