Consensus method and device in block chain system
By introducing an incentive mechanism into the asynchronous consensus protocol and issuing virtual resources to the consensus proposal node, the problems of proposal speed and communication inefficiency are solved, and the stability and robustness of the blockchain system are improved.
Patent Information
- Application Number
- CN202411215387.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-15
AI Technical Summary
In the blockchain system, the asynchronous consensus protocol cannot be reached in a timely manner due to the proposed speed and communication efficiency of the proposed nodes, which affects the stability of the blockchain system.
Introduce an incentive mechanism, and generate blocks by collecting consensus proposals and reaching the number of Quorums, distributing virtual resources to the consensus proposal nodes, incentivizing nodes to optimize proposal speed and communication efficiency, and improving system stability and robustness.
It effectively avoids the incentives of nodes with low proposed speed and communication efficiency, promotes node optimization, improves the stability and robustness of the blockchain system, and promotes the sustainable development of the system in a healthy direction.
Smart Images

Figure CN118972393A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification belong to the field of blockchain technology, and more particularly to a consensus method and device in a blockchain system. Background Art
[0002] In the blockchain system, different participants can establish a distributed blockchain network through deployed nodes. The decentralized (or multi-centralized) distributed ledger constructed using the chain block structure is stored on each node (or most nodes, such as consensus nodes) in the distributed blockchain network. Such a blockchain system needs to solve the problem of consistency and correctness of the ledger data on multiple decentralized (or multi-centralized) nodes. Blockchain programs are running on each node. Under certain fault tolerance requirements, the consensus mechanism is used to ensure that all loyal nodes have the same transactions, thereby ensuring that all loyal nodes have consistent execution results for the same transaction, and the transactions and execution results are packaged to generate blocks.
[0003] The current mainstream consensus protocols include: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT) protocol, HoneyBadgerBFT protocol, HotStuff protocol, and so on.
[0004] Among them, the various consensus protocols listed above include both asynchronous consensus protocols and non-asynchronous consensus protocols. For example, HoneyBadgerBFT algorithm is a relatively common asynchronous consensus protocol.
[0005] Unlike synchronous consensus protocols, asynchronous consensus protocols can run in asynchronous networks, where messages between nodes can be arbitrarily delayed but will eventually arrive. Moreover, in asynchronous consensus protocols, all consensus nodes are equal, and there is no longer a distinction between master nodes and backup nodes. Each consensus node can initiate a consensus proposal to try to construct a block.
[0006] For example, taking the HoneyBadgerBFT consensus protocol as an example, the HoneyBadgerBFT consensus protocol can support initiating consensus proposals with block identifiers. All consensus nodes participating in the consensus in the blockchain system have the opportunity to initiate a consensus proposal to the block corresponding to the block identifier by carrying a block identifier in the initiated consensus proposal.
[0007] However, since each consensus node in the asynchronous consensus protocol has the opportunity to initiate a consensus proposal, and the probability of whether the initiated consensus proposal can be passed by consensus usually depends largely on the proposal speed and communication efficiency of the proposing node when initiating the consensus proposal; therefore, if some proposing nodes initiate consensus proposals relatively slowly or there are network delays, it is possible that the initiated consensus proposals cannot reach consensus in time, thereby affecting the stability of the blockchain system. Summary of the invention
[0008] This specification proposes a consensus method in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the method is applied to any consensus node participating in the consensus in the blockchain system, and the method includes:
[0009] Collecting consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals corresponding to the current round of consensus initiated by the current consensus node, and consensus proposals corresponding to the current round of consensus initiated by other consensus nodes in the blockchain system;
[0010] Determine whether the number of consensus proposals collected and passed by consensus has reached the quorum;
[0011] If the number of consensus proposals collected and passed reaches Quorum, a block corresponding to this round of consensus is generated based on the collected Quorum consensus proposals, and the block is saved locally to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0012] Optionally, a smart contract for issuing virtual resources is deployed on the blockchain;
[0013] Generate blocks corresponding to this round of consensus based on the collected Quorum consensus proposals, including:
[0014] Generate a block corresponding to this round of consensus locally based on the collected Quorum consensus proposals, and add a contract call transaction for initiating the smart contract in the block.
[0015] Optionally, the contract call transaction is the last transaction included in the block.
[0016] Optionally, the smart contract is a system smart contract deployed in the blockchain by an operator of a blockchain service platform corresponding to the blockchain system; accordingly, the contract call transaction is used to initiate a contract call transaction for the system smart contract.
[0017] Optionally, the contract call transaction does not include transaction sender information.
[0018] Optionally, the locally saving the block to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block, respectively, includes:
[0019] The block is saved locally, and the contract call transaction contained in the block is executed to initiate a contract call for the smart contract deployed on the blockchain, and virtual resources are respectively issued to the proposal nodes corresponding to each consensus proposal contained in the block.
[0020] Optionally, a service interface for issuing virtual resources is deployed on the blockchain service platform corresponding to the blockchain system;
[0021] The block is saved locally to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal contained in the block, including:
[0022] The block is saved locally to trigger the blockchain service platform corresponding to the blockchain system to further call the service interface to respectively issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0023] Optionally, the asynchronous consensus protocol is a consensus protocol that initiates a consensus proposal based on a block identifier; accordingly, the consensus proposal includes a block identifier of a target block to be agreed upon; and a transaction list proposed by the consensus node for the target block;
[0024] Determine whether the number of consensus proposals collected and passed by consensus has reached the quorum, including:
[0025] Count the number of consensus proposals that have been collected and passed by consensus, including the block identifier of the target block;
[0026] It is determined whether the counted number reaches a quorum.
[0027] Optionally, the asynchronous consensus protocol is the HoneyBadgerBFT consensus protocol.
[0028] Optionally, the asynchronous consensus protocol is a consensus protocol that initiates a consensus proposal based on a timestamp corresponding to a time when the consensus proposal is initiated; accordingly, the consensus proposal includes a timestamp corresponding to a time when the consensus proposal is initiated; and a transaction list proposed by the consensus node;
[0029] Determine whether the number of consensus proposals collected and passed by consensus has reached the quorum, including:
[0030] Count the number of consensus proposals collected and passed by consensus, the number of which includes timestamps within the timestamp range corresponding to the target block to be agreed upon;
[0031] It is determined whether the counted number reaches a quorum.
[0032] Optionally, the asynchronous consensus protocol is a MyTumbler consensus protocol.
[0033] Optionally, the blockchain system is a public chain system that supports running an asynchronous consensus protocol.
[0034] Optionally, each consensus proposal included in the block carries a signature generated based on the private key of the proposing node;
[0035] The locally saving the block to trigger the blockchain system to respectively distribute virtual resources to the proposal nodes corresponding to each consensus proposal included in the block includes:
[0036] The block is saved locally to trigger the blockchain system to verify the signatures carried by each consensus proposal contained in the block based on the maintained public key, and after the signature verification is passed, virtual resources are respectively issued to the proposal nodes corresponding to the public key.
[0037] This specification also proposes a consensus method in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the consensus nodes participating in the consensus in the blockchain system pre-specify a target consensus node responsible for generating blocks; the method is applied to the target consensus node, and the method includes:
[0038] Collecting consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals initiated by each consensus node in the blockchain system and corresponding to the current round of consensus;
[0039] Determine whether the number of consensus proposals collected and passed by consensus has reached the quorum;
[0040] If the number of consensus proposals collected and passed reaches Quorum, a block corresponding to this round of consensus is generated based on the collected Quorum consensus proposals, and the block is sent to each consensus node in the blockchain system for storage, so as to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0041] This specification also proposes a consensus method in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; a target consensus node responsible for generating blocks is pre-specified among the consensus nodes participating in the consensus in the blockchain system; the method is applied to any consensus node participating in the consensus in the blockchain system except the target consensus node, and the method includes:
[0042] Receive a block corresponding to the current round of consensus issued by the target consensus node; wherein the block is a block generated by the target consensus node based on the collected Quorum consensus proposals that have been passed by consensus when it is determined that the number of collected consensus proposals that have been passed by consensus reaches Quorum; wherein the consensus proposal includes the consensus proposals corresponding to the current round of consensus initiated by each consensus node in the blockchain system;
[0043] The block is saved locally to trigger the blockchain system to respectively issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0044] This specification also proposes a consensus device in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the device is applied to any consensus node participating in the consensus in the blockchain system, and the device includes:
[0045] A first collection module collects consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals initiated by the current consensus node and corresponding to the current round of consensus, and consensus proposals initiated by other consensus nodes in the blockchain system and corresponding to the current round of consensus;
[0046] The first determination module determines whether the number of consensus proposals collected and passed by consensus has reached the quorum;
[0047] The first saving module generates a block corresponding to this round of consensus based on the collected Quorum consensus proposals if the number of consensus proposals that have been passed reaches Quorum, and saves the block locally to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0048] This specification also proposes a consensus device in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the consensus nodes participating in the consensus in the blockchain system pre-specify a target consensus node responsible for generating blocks; the device is applied to the target consensus node, and the device includes:
[0049] A second collection module collects consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals initiated by each consensus node in the blockchain system and corresponding to the current round of consensus;
[0050] The second determination module determines whether the number of consensus proposals that have been collected and passed by consensus has reached the quorum;
[0051] The sending module generates a block corresponding to this round of consensus based on the collected Quorum consensus proposals if the number of consensus proposals that have been passed reaches Quorum, and sends the block to each consensus node in the blockchain system for storage, so as to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0052] This specification also proposes a consensus device in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; a target consensus node responsible for generating blocks is pre-specified among the consensus nodes participating in the consensus in the blockchain system; the device is applied to any consensus node participating in the consensus in the blockchain system except the target consensus node, and the device includes:
[0053] A receiving module receives a block corresponding to the current round of consensus issued by the target consensus node; wherein the block is a block generated by the target consensus node based on the collected Quorum consensus proposals that have been passed by consensus when it is determined that the number of collected consensus proposals that have been passed by consensus reaches Quorum; wherein the consensus proposal includes the consensus proposals corresponding to the current round of consensus initiated by each consensus node in the blockchain system;
[0054] The second saving module saves the block locally to trigger the blockchain system to respectively distribute virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0055] In the above embodiment, by introducing an incentive mechanism in the blockchain system running the asynchronous consensus protocol, the asynchronous consensus protocol can be used to support the feature that all consensus nodes can initiate consensus proposals, and virtual resources can be issued to the consensus nodes whose initiated consensus proposals have been passed by consensus. On the one hand, since the probability of whether the initiated consensus proposal can be passed by consensus depends largely on the proposal speed and communication efficiency of the proposing node, this method can avoid allowing those inactive consensus nodes whose proposal speed and communication efficiency cannot meet the requirements to obtain virtual resources as incentives; on the other hand, since only the consensus nodes whose initiated consensus proposals are successfully passed by consensus and are successfully added to the newly generated blocks, this method can incentivize each consensus node to continuously optimize the node's own proposal speed and communication efficiency, which can fundamentally promote the blockchain system running the asynchronous consensus protocol to continuously develop sustainably in the direction of system health, thereby improving the stability and robustness of the blockchain system. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0057] Figure 1 It is a flowchart of a consensus method in a blockchain system shown in an embodiment of this specification;
[0058] Figure 2 It is a flowchart of consensus processing based on HoneyBadgerBFT consensus protocol shown in an embodiment of this specification;
[0059] Figure 3 It is a flowchart of consensus processing based on the MyTumbler consensus protocol shown in an embodiment of this specification;
[0060] Figure 4 It is a flowchart of another consensus method in a blockchain system shown in an embodiment of this specification;
[0061] Figure 5 It is a flowchart of another consensus method in a blockchain system shown in an embodiment of this specification;
[0062] Figure 6 is a schematic structural diagram of an electronic device shown in an embodiment of this specification;
[0063] Figure 7It is a block diagram of a consensus device in a blockchain system shown in an embodiment of this specification;
[0064] Figure 8 It is a block diagram of another consensus device in a blockchain system shown in an embodiment of this specification;
[0065] Fig. 9 It is a block diagram of another consensus device in a blockchain system shown in one embodiment of this specification. DETAILED DESCRIPTION
[0066] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0067] This specification proposes a technical solution to improve the stability and robustness of a blockchain system by introducing an incentive mechanism into a blockchain system running an asynchronous consensus protocol.
[0068] See also Figure 1 , Figure 1 This is a flowchart of a consensus method in a blockchain system shown in this specification. The consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol. The method is applied to any consensus node participating in the consensus in the blockchain system. The method includes the following execution process:
[0069] Step 102: Collect consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals initiated by the current consensus node and corresponding to the current round of consensus, and consensus proposals initiated by other consensus nodes in the blockchain system and corresponding to the current round of consensus;
[0070] In this specification, the consensus protocol run by the consensus nodes participating in the consensus in the blockchain system may specifically include an asynchronous consensus protocol. Unlike the synchronous consensus protocol, the asynchronous consensus protocol can be run in an asynchronous network, and in the asynchronous consensus protocol, all consensus nodes are equal, and there is no distinction between master nodes and backup nodes, so that each consensus node can initiate a consensus proposal to try to construct a block.
[0071] Among them, the traditional asynchronous consensus protocol can generally include an asynchronous consensus protocol that initiates a consensus proposal based on a block identifier, and an asynchronous consensus protocol that initiates a consensus proposal based on a timestamp corresponding to the moment when the consensus proposal is initiated. The consensus protocol run by the consensus node in the above blockchain system can be an asynchronous consensus protocol that initiates a consensus proposal based on a block identifier, or an asynchronous consensus protocol that initiates a consensus proposal based on a timestamp corresponding to the moment when the consensus proposal is initiated.
[0072] It should be noted that the asynchronous consensus protocol that initiates consensus proposals based on block identifiers usually uses block identifiers to identify the blocks to be agreed upon, and all consensus nodes jointly initiate a proposed block formation method for the block corresponding to the block identifier. In this case, the consensus proposal initiated by the consensus node can usually include the block identifier of the target block to be agreed upon, as well as the transaction list proposed by the consensus node for the target block.
[0073] For example, the HoneyBadgerBFT consensus protocol is an asynchronous consensus protocol that supports initiating consensus proposals with block identifiers. Based on the HoneyBadgerBFT consensus protocol, all consensus nodes participating in the consensus in the blockchain system have the opportunity to initiate a consensus proposal to the block corresponding to the block identifier by carrying a block identifier in the initiated consensus proposal.
[0074] The asynchronous consensus protocol that initiates consensus proposals based on the timestamp corresponding to the time when the consensus proposal is initiated usually adopts the method that each consensus node independently initiates proposals based on the timestamp corresponding to the time when the consensus proposal is initiated. After the consensus is completed, the consensus proposals initiated by each consensus node are sorted according to the order of the timestamps, and then the consensus proposals initiated by each consensus node are determined according to the sorting order to determine which block the consensus proposals initiated by each consensus node belong to. In this case, the consensus proposal initiated by the consensus node can usually include the timestamp corresponding to the time when the consensus proposal is initiated; and the transaction list proposed by the consensus node for the target block.
[0075] For example, the MyTumbler consensus protocol is an asynchronous consensus protocol that supports initiating consensus proposals with the timestamp corresponding to the time when consensus is initiated. Unlike the HoneyBadgerBFT consensus protocol, based on the MyTumbler consensus protocol, the consensus proposals initiated by the consensus nodes no longer carry the block identifier to be agreed upon, but carry the timestamp corresponding to the time when the consensus proposal is initiated. When the consensus proposals initiated by each consensus node within a period of time are all passed by consensus, the transaction lists contained in the consensus proposals initiated by each consensus node are sorted according to the order of the timestamps corresponding to the time when each consensus node initiated the consensus proposal, and the transaction lists contained in the consensus proposals initiated by each consensus node are determined according to the sorting order to determine which block the transaction lists contained in the consensus proposals initiated by each consensus node should belong to.
[0076] In practical applications, for some blockchain systems that have high requirements on network latency and response time, asynchronous consensus protocols are rarely used as consistency protocols.
[0077] For example, taking the public chain system as an example, since the public chain system usually needs to have the characteristics of high-frequency transactions and fast transaction confirmation, and most asynchronous consensus protocols are not efficient enough, most asynchronous consensus protocols usually cannot meet the needs of the public chain system and cannot be run on the public chain system.
[0078] However, with the continuous development of asynchronous consensus protocols, the performance and ability to adapt to the network environment of asynchronous consensus protocols are increasingly in line with blockchain systems that have high requirements for network latency and response time. It is very likely that in the near future, public chain systems using asynchronous consensus protocols will emerge. For example, in one example, the above-mentioned blockchain system can specifically be a public chain system that supports the operation of asynchronous consensus protocols.
[0079] In this specification, an incentive mechanism can be introduced into a blockchain system running an asynchronous consensus protocol, and the asynchronous consensus protocol can be used to support the feature that all consensus nodes can initiate consensus proposals, and virtual resources can be issued as incentives to consensus nodes whose initiated consensus proposals have been passed by consensus.
[0080] The virtual resources used as incentives can be any form of valuable virtual resources, which is not specifically limited in this specification. For example, it can be a valuable certificate (such as a token) defined on the blockchain, or a virtual asset issued on the blockchain and anchored to a real asset outside the chain, etc.
[0081] In each round of consensus in the blockchain system, each consensus node in the blockchain system can collect transactions submitted by clients that need to be consensused in this round, and construct a consensus proposal corresponding to this round of consensus based on the collected transactions; for example, the consensus proposal can specifically be a transaction list consisting of several transactions signed by the consensus node.
[0082] When the consensus proposal is constructed, the consensus proposal corresponding to this round of consensus can be broadcasted to other consensus nodes participating in the consensus by running the asynchronous consensus protocol, and consensus messages can be exchanged with other consensus nodes participating in the consensus to achieve consensus processing on the consensus proposal.
[0083] Among them, each consensus node in the blockchain system runs an asynchronous consensus protocol and interacts with other consensus nodes participating in the consensus to process the consensus proposals it initiates. The specific process usually depends on the specific type of asynchronous consensus protocol run by the consensus node in the blockchain system.
[0084] For example, in one example, taking the HoneyBadgerBFT consensus protocol as an example, based on the HoneyBadgerBFT consensus protocol, all consensus nodes participating in the consensus in the blockchain system can have the opportunity to initiate a consensus proposal to the block corresponding to the block identifier by carrying a block identifier in the initiated consensus proposal.
[0085] See also Figure 2 , Figure 2 The figure shows a specific process in which a consensus node in a blockchain system runs the HoneyBadgerBFT consensus protocol to interact with other consensus nodes through consensus messages to perform consensus processing on the consensus proposal initiated by itself.
[0086] like Figure 2 As shown in the figure, assuming that the blockchain system includes 4 consensus nodes, numbered Node0 to 3, from the perspective of Node0 in the blockchain system, the consensus process of the HoneyBadgerBFT consensus protocol mainly includes two stages, namely Reliable BroadCast (RBC) and Asynchronous Binary Agreement (ABA, also known as "01 Asynchronous Binary Consensus"). In addition, there is an Asynchronous Common Subset (ACS) protocol based on RBC and ABA.
[0087] In the RBC phase, Node0 must at least interact with other consensus nodes for three rounds of messages, such as Rval, Echo, and Ready; and in the ABA phase, Node0 must at least interact with other consensus nodes for three rounds of messages, such as BVAL, AUX, and Coin. The specific message format and interaction details will not be described in detail in this manual.
[0088] Among them, in the RBC stage, by using three rounds of message interaction, the consensus proposal initiated by Node0 can be reliably broadcast. In the ABA stage, two rounds of voting (BVAL and AUX messages) are first carried out, and then the consensus nodes reach a consensus on the consensus proposal initiated by Node0 by tossing a coin (Coin) to complete the consensus process of the consensus proposal. If the voting result in the ABA stage is inconsistent with the coin toss result, the protocol will enter a new round of ABA (at least three additional rounds of message interaction).
[0089] In the best case, there is a 1 / 2 probability that the HoneyBadgerBFT consensus process can be terminated. In this case, it takes 6 rounds to complete a consensus. In addition, there is a 1 / 4 probability that another ABA process will be entered. Figure 3 In the second ABA process (the ABA process represented by rounds 7, 8, and 9), there is a 1 / 4 probability that it will end in the second round, and there is at least a 1 / 4 probability that the HoneyBadgerBFT consensus process can be ended. In this way, it takes 9 rounds to complete a consensus. After the second ABA process, there is an overall 1 / 8 probability of entering another ABA process... and so on, until all consensus nodes reach a consensus on the vote for the consensus proposal to complete the consensus process of the consensus proposal.
[0090] In another example, taking the MyTumbler consensus protocol as an asynchronous consensus protocol running in the blockchain system, the consensus proposals initiated by the consensus nodes no longer carry the block identifier to be agreed upon, but carry the timestamp corresponding to the time when the consensus proposal was initiated. When the consensus proposals initiated by each consensus node are all passed by consensus within a period of time, the transaction lists contained in the consensus proposals initiated by each consensus node are sorted according to the order of the timestamps corresponding to the time when each consensus node initiated the consensus proposal, and the transaction lists contained in the consensus proposals initiated by each consensus node are determined according to the sorting order to determine which block the transaction lists contained in the consensus proposals initiated by each consensus node should belong to.
[0091] See also Figure 3 , Figure 3 The figure shows a specific process in which a consensus node in a blockchain system runs the MyTumbler consensus protocol to interact with other consensus nodes through consensus messages to perform consensus processing on a consensus proposal initiated by itself.
[0092] like Figure 3 As shown in the figure, unlike the HoneyBadgerBFT consensus protocol, the MyTumbler consensus protocol combines the last two rounds of the RBC process of the HoneyBadgerBFT consensus protocol and the first two rounds of the ABA process. Under certain conditions, it can be shortened to three rounds to complete a consensus. The three rounds of interactive messages are Val message, ENDORSE message and Prom message. It is still assumed that the blockchain system includes 4 consensus nodes, numbered as Node0~3. From the perspective of Node0 in the blockchain system, Node0 must at least interact with other consensus nodes for three rounds of messages, such as Val message, ENDORSE message and Prom message, to process the consensus proposal initiated by itself. Among them, the specific message format and interaction details will not be described in detail in this manual.
[0093] In this specification, the consensus nodes in the blockchain system can not only process the consensus proposals they initiate by running the asynchronous consensus protocol and exchanging consensus messages with other consensus nodes participating in the consensus, but in actual applications, they will also cooperate to complete the consensus processing process for the consensus proposals initiated by other consensus nodes.
[0094] For example, for any consensus node participating in the consensus in the blockchain system, it usually creates a consensus instance locally for the consensus proposals it initiates and the consensus proposals received from other consensus nodes; the consensus instance specifically refers to an algorithm instance that performs consensus processing on the transaction list proposed by a consensus node by running the consensus protocol. The consensus node can interact with other consensus nodes through consensus messages by running the created consensus instance locally, and perform consensus processing on these consensus proposals respectively.
[0095] In the process of completing the consensus processing for the consensus proposals initiated by themselves and the consensus proposals initiated by other nodes, the consensus nodes in the blockchain system can also monitor the consensus progress of each consensus proposal in real time or periodically, and collect the consensus proposals that have been agreed upon by the consensus nodes in the blockchain system.
[0096] For example, in actual applications, the consensus nodes in the blockchain system can monitor the execution results of each consensus instance created locally, and based on the monitored execution results, confirm the consensus proposals that have been passed by consensus, and then collect these consensus proposals that have been passed by consensus.
[0097] Step 104: Determine whether the number of consensus proposals collected and passed by consensus reaches the quorum;
[0098] In this specification, after the consensus nodes in the blockchain system have collected consensus proposals that have been passed by consensus, it can also be determined whether the number of collected consensus proposals that have been passed by consensus has reached the Quorum.
[0099] It should be noted that Quorum usually refers to the number of consensus nodes that can represent the majority in the blockchain.
[0100] For example, in one example, when the number of consensus nodes participating in the consensus in the blockchain is 3f+1, the value of Quorum can be nf, that is, 2f+1. In this way, for a distributed system containing 4 nodes, any 3 nodes can form a Quorum. f refers to the number of Byzantine nodes (i.e. malicious nodes) that the blockchain can tolerate.
[0101] In one embodiment shown, if the asynchronous consensus protocol run by the consensus nodes in the above-mentioned blockchain system is an asynchronous consensus protocol that initiates consensus proposals based on block identifiers, the consensus proposal initiated by the consensus node at this time usually includes the block identifier of the target block to be agreed upon; and the transaction list proposed by the consensus node for the target block.
[0102] In this case, when the consensus node determines whether the number of consensus proposals collected and passed by consensus has reached the Quorum, it can specifically count the number of consensus proposals that contain the block identifier of the above-mentioned target block among the collected and passed consensus proposals; then, it can further determine whether the counted number has reached the Quorum.
[0103] In another embodiment shown, if the consensus node in the above-mentioned blockchain system runs an asynchronous consensus protocol that initiates a consensus proposal based on a timestamp corresponding to the time when the consensus proposal is initiated, the consensus proposal initiated by the consensus node at this time usually includes a timestamp corresponding to the time when the consensus proposal is initiated; and a list of transactions proposed by the consensus node.
[0104] In this case, when the consensus node determines whether the number of consensus proposals that have been collected and passed has reached the quorum, it can specifically count the number of consensus proposals whose timestamps are within the timestamp range corresponding to the target block to be agreed upon among the consensus proposals that have been collected and passed;
[0105] For example, in actual applications, if the consensus nodes in the above blockchain system run an asynchronous consensus protocol that initiates a consensus proposal based on the timestamp corresponding to the time when the consensus proposal is initiated, a timestamp range can be specified for the target block to be agreed upon in each round of consensus, and the timestamp range is specifically used to indicate the transactions that can be included in the target block. After the consensus node collects the consensus proposals that have been agreed upon, it can match the timestamp contained in the consensus proposal with the timestamp range of the target block. If the timestamp contained in the consensus proposal is within the timestamp range of the target block, it indicates that the consensus proposal is a consensus proposal initiated for the target block.
[0106] Then, it can be further determined whether the counted number reaches the Quorum.
[0107] Step 106: If the number of consensus proposals collected and passed by consensus reaches Quorum, a block corresponding to this round of consensus is generated based on the collected Quorum consensus proposals, and the block is saved locally to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0108] In this specification, when the consensus node in the blockchain system determines whether the number of consensus proposals collected and passed by consensus has reached the Quorum, it can further generate a block corresponding to the current round of consensus based on the consensus proposals that have been collected and passed by consensus.
[0109] For example, in actual applications, the order of the transaction lists contained in the Quorum consensus proposals that have been agreed upon in the block is usually agreed upon by each consensus node during the consensus process. The consensus nodes can package the Quorum consensus proposals that have been agreed upon into a new block based on this agreed upon order.
[0110] It should be noted that consensus proposals that have not yet reached consensus, as well as consensus proposals that have reached consensus but the consensus result is consensus failure, will not be included in the generated blocks.
[0111] In one embodiment shown, a smart contract for issuing virtual resources can also be pre-deployed on the blockchain.
[0112] When the consensus node in the blockchain system generates a block based on the collected Quorum consensus proposals that have been agreed upon, a contract call transaction for initiating the above smart contract can be added to the block.
[0113] For example, in one example, the smart contract may be a system smart contract deployed in the blockchain by the operator of the blockchain service platform corresponding to the blockchain system for issuing virtual resources; accordingly, the contract call transaction may be a contract call transaction for initiating a contract call for the system smart contract. For example, conventional contract call transactions usually include the information of the transaction sender, and since the system smart contract usually describes the system call behavior of the blockchain service platform corresponding to the blockchain system, the contract call transaction for initiating a contract call for the system smart contract may not include the information of the transaction sender.
[0114] In this case, during the execution phase of the block, a contract call for the above-mentioned smart contract can be initiated by executing the contract call transaction contained in the block, and virtual resources can be respectively issued to the proposal nodes corresponding to each consensus proposal contained in the block.
[0115] It should be noted that when a contract call transaction for initiating the above-mentioned smart contract is added to the generated block, the specific location of the contract call transaction in the block is not specifically limited in this specification;
[0116] For example, in one example, the contract call transaction can specifically be the last transaction included in the block. In this way, other transactions in the block can be executed first, thereby ensuring that after other transactions in the block are successfully executed, the contract call for the above-mentioned smart contract is triggered, and virtual resources are respectively issued to the proposal nodes corresponding to each consensus proposal included in the block.
[0117] In this specification, after generating a block, the consensus nodes in the blockchain system can save the block locally to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0118] In one embodiment shown, if the block already includes a contract call transaction for initiating the above-mentioned smart contract, after the consensus node in the blockchain system saves the block locally (that is, the block has completed the chain), it can execute the contract call transaction contained in the block during the execution of the transaction contained in the block to initiate a contract call for the smart contract deployed on the blockchain. The smart contract distributes virtual resources to the proposal nodes corresponding to each consensus proposal contained in the block by executing the incentive logic contained therein.
[0119] In another embodiment shown, in addition to issuing virtual resources to the proposal nodes corresponding to each consensus proposal included in the block by calling a smart contract, in actual applications, the above virtual resource issuance process can also be centrally executed by the blockchain service platform (such as a BaaS platform) corresponding to the blockchain system.
[0120] In this case, it is no longer necessary to deploy smart contracts for issuing virtual resources on the blockchain, and a centralized service interface for issuing virtual resources can be pre-deployed on the blockchain service platform corresponding to the blockchain system. After each consensus node in the blockchain system has saved the block locally, the blockchain service platform corresponding to the blockchain system can further initiate an interface call for the above service interface, and issue virtual resources to the proposal nodes corresponding to each consensus proposal contained in the block by executing the incentive logic contained in the service interface.
[0121] For example, in one example, the blockchain service platform corresponding to the blockchain system can monitor the number of consensus nodes in the blockchain system that have successfully saved the block locally (i.e., the number of consensus nodes that have successfully uploaded the block to the chain), and determine whether the number of consensus nodes that have successfully saved the block locally has reached the Quorum; if so, it can further initiate an interface call for the above-mentioned service interface, and by executing the incentive logic contained in the service interface, distribute virtual resources to the proposal nodes corresponding to each consensus proposal contained in the block.
[0122] In one embodiment shown, each consensus proposal included in a block generated by a consensus node in the blockchain may specifically carry a signature generated based on a private key of the proposing node.
[0123] In this case, whether the incentive logic contained in the above-mentioned smart contract is called to allocate virtual resources, or the incentive logic contained in the above-mentioned service interface is called to allocate virtual resources, when virtual resources are respectively issued to the proposing nodes corresponding to each consensus proposal included in the block, the blockchain system can be used to attempt to verify the signatures carried by each consensus proposal included in the block based on the public key maintained; for any consensus proposal included in the block, if the signature carried by the consensus proposal is verified based on a public key maintained by the blockchain system, it indicates that the consensus node corresponding to the public key is the proposing node of the consensus proposal, and virtual resources can be issued to the proposing node at this time.
[0124] By carrying signatures in each consensus proposal included in the block, on the one hand, the legitimacy of the consensus proposal can be verified at any time. On the other hand, by attempting to verify the signatures of each consensus proposal included in the block based on the maintained public key during the virtual resource distribution stage, the identity of the proposing node can be clarified, thereby avoiding the erroneous distribution of virtual resources.
[0125] It should be noted that the specific distribution strategy for virtual resources and the specific quantity of virtual resources distributed to the proposing nodes corresponding to each consensus proposal included in the block are not specifically limited in this specification. In actual applications, incentives can be customized based on specific distribution requirements.
[0126] See also Figure 4 , Figure 4 This is a flowchart of another consensus method in a blockchain system shown in this specification, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the consensus nodes participating in the consensus in the blockchain system pre-specify a target consensus node responsible for generating blocks; the method is applied to the target consensus node, and the method includes the following execution process:
[0127] Step 402: Collect consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals initiated by each consensus node in the blockchain system and corresponding to the current round of consensus;
[0128] In this specification, the asynchronous consensus protocol run by the consensus nodes participating in the consensus in the blockchain system may specifically include supporting the pre-designation of a target consensus node responsible for generating blocks among the consensus nodes participating in the consensus in the blockchain system.
[0129] For example, the target consensus node may specifically be a special consensus node designated from the consensus nodes in the blockchain system to be responsible for coordinating and managing the consensus process, which may be referred to as a leader or coordinator.
[0130] The specific method and specific strategy for specifying the above-mentioned target consensus node from the consensus nodes in the blockchain system are not particularly limited in this specification; for example, in practical applications, a periodic election strategy can be adopted to elect the target consensus node as the leader or coordinator from the consensus nodes in the blockchain system in turn; for example, each round of consensus re-elects a target consensus node as the leader or coordinator.
[0131] In each round of consensus in the blockchain system, each consensus node in the blockchain system can collect transactions submitted by clients that need to be consensused in this round, and construct a consensus proposal corresponding to this round of consensus based on the collected transactions. When the consensus proposal is constructed, the consensus proposal corresponding to this round of consensus can be broadcasted to other consensus nodes participating in the consensus by running the asynchronous consensus protocol, and consensus messages can be exchanged with other consensus nodes participating in the consensus to process the consensus proposal. The specific consensus process will not be described in detail.
[0132] In addition to running asynchronous consensus protocols and exchanging consensus messages with other consensus nodes participating in the consensus to process consensus proposals initiated by themselves, consensus nodes in the blockchain system will also cooperate in completing the consensus processing process for consensus proposals initiated by other consensus nodes in actual applications.
[0133] In the process of completing the consensus processing for the consensus proposals initiated by themselves and the consensus proposals initiated by other nodes, the above-mentioned target consensus nodes designated from the consensus nodes in the blockchain system can monitor the consensus progress of each consensus proposal initiated by each consensus node in real time or periodically, and collect the consensus proposals that have been agreed upon by each consensus node in the blockchain system.
[0134] For example, in actual applications, the above-mentioned target consensus node can monitor the execution results of each consensus instance running on each consensus node in the blockchain system, and based on the monitored execution results, confirm the consensus proposals that have been passed by consensus, and then collect these consensus proposals that have been passed by consensus.
[0135] Step 404: Determine whether the number of consensus proposals that have been collected and passed by consensus has reached the quorum;
[0136] After the above-mentioned target consensus node collects the consensus proposals that have been passed by consensus, it can also be determined whether the number of the collected consensus proposals that have been passed by consensus has reached the Quorum.
[0137] In one embodiment shown, if the asynchronous consensus protocol run by the consensus nodes in the above-mentioned blockchain system is an asynchronous consensus protocol that initiates consensus proposals based on block identifiers, the consensus proposal initiated by the consensus node at this time usually includes the block identifier of the target block to be agreed upon; and the transaction list proposed by the consensus node for the target block.
[0138] In this case, when determining whether the number of consensus proposals collected and passed by consensus has reached the Quorum, the target consensus node may specifically count the number of consensus proposals containing the block identifier of the target block among the collected and passed consensus proposals; then, it may further determine whether the counted number has reached the Quorum.
[0139] In another embodiment shown, if the consensus node in the above-mentioned blockchain system runs an asynchronous consensus protocol that initiates a consensus proposal based on a timestamp corresponding to the time when the consensus proposal is initiated, the consensus proposal initiated by the consensus node at this time usually includes a timestamp corresponding to the time when the consensus proposal is initiated; and a list of transactions proposed by the consensus node.
[0140] In this case, when determining whether the number of consensus proposals collected and passed by consensus has reached the quorum, the target consensus node can specifically count the number of consensus proposals whose timestamps are within the timestamp range corresponding to the target block to be agreed upon. Then, it can be further determined whether the counted number has reached the quorum.
[0141] Step 406: If the number of consensus proposals collected and passed by consensus reaches Quorum, a block corresponding to this round of consensus is generated based on the collected Quorum consensus proposals, and the block is sent to each consensus node in the blockchain system for storage, so as to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0142] When the target consensus node determines whether the number of consensus proposals collected and passed by consensus has reached the Quorum, it can further generate a block corresponding to this round of consensus based on the consensus proposals collected and passed by consensus.
[0143] In one embodiment shown, a smart contract for issuing virtual resources can also be pre-deployed on the blockchain.
[0144] When the target consensus node generates a block based on the collected Quorum consensus proposals that have been agreed upon, it can specifically add a contract call transaction for initiating the smart contract in the block.
[0145] For example, in one example, the smart contract may be a system smart contract deployed in the blockchain by the operator of the blockchain service platform corresponding to the blockchain system for issuing virtual resources; accordingly, the contract call transaction may be a contract call transaction for initiating a contract call for the system smart contract. For example, conventional contract call transactions usually include the information of the transaction sender, and since the system smart contract usually describes the system call behavior of the blockchain service platform corresponding to the blockchain system, the contract call transaction for initiating a contract call for the system smart contract may not include the information of the transaction sender.
[0146] It should be noted that when a contract call transaction for initiating the above-mentioned smart contract is added to the generated block, the specific location of the contract call transaction in the block is not specifically limited in this specification;
[0147] For example, in one example, the contract call transaction can specifically be the last transaction included in the block. In this way, other transactions in the block can be executed first, thereby ensuring that after other transactions in the block are successfully executed, the contract call for the above-mentioned smart contract is triggered, and virtual resources are respectively issued to the proposal nodes corresponding to each consensus proposal included in the block.
[0148] After generating a block, the target consensus node may send the generated block to each consensus node in the blockchain system for storage, so as to trigger the blockchain system to respectively issue virtual resources to the proposal nodes corresponding to each consensus proposal contained in the block.
[0149] For example, the target consensus node may send the generated blocks to each consensus node in the blockchain system for storage by broadcasting.
[0150] In one embodiment shown, if the block already includes a contract call transaction for initiating the above-mentioned smart contract, after the consensus node in the blockchain system saves the block locally (that is, the block has completed the chain), it can execute the contract call transaction contained in the block during the execution of the transaction contained in the block to initiate a contract call for the smart contract deployed on the blockchain. The smart contract distributes virtual resources to the proposal nodes corresponding to each consensus proposal contained in the block by executing the incentive logic contained therein.
[0151] In another embodiment shown, in addition to issuing virtual resources to the proposal nodes corresponding to each consensus proposal included in the block by calling a smart contract, in actual applications, the above virtual resource issuance process can also be centrally executed by the blockchain service platform (such as a BaaS platform) corresponding to the blockchain system.
[0152] In this case, it is no longer necessary to deploy smart contracts for issuing virtual resources on the blockchain, and a centralized service interface for issuing virtual resources can be pre-deployed on the blockchain service platform corresponding to the blockchain system. After each consensus node in the blockchain system has saved the block locally, the blockchain service platform corresponding to the blockchain system can further initiate an interface call for the above service interface, and issue virtual resources to the proposal nodes corresponding to each consensus proposal contained in the block by executing the incentive logic contained in the service interface.
[0153] In one embodiment shown, each consensus proposal included in the block generated by the target consensus node may specifically carry a signature generated based on the private key of the proposing node.
[0154] In this case, whether the incentive logic contained in the above-mentioned smart contract is called to allocate virtual resources, or the incentive logic contained in the above-mentioned service interface is called to allocate virtual resources, when virtual resources are respectively issued to the proposing nodes corresponding to each consensus proposal included in the block, the blockchain system can be used to attempt to verify the signatures carried by each consensus proposal included in the block based on the public key maintained; for any consensus proposal included in the block, if the signature carried by the consensus proposal is verified based on a public key maintained by the blockchain system, it indicates that the consensus node corresponding to the public key is the proposing node of the consensus proposal, and virtual resources can be issued to the proposing node at this time.
[0155] By carrying signatures in each consensus proposal included in the block, on the one hand, the legitimacy of the consensus proposal can be verified at any time. On the other hand, by attempting to verify the signatures of each consensus proposal included in the block based on the maintained public key during the virtual resource distribution stage, the identity of the proposing node can be clarified, thereby avoiding the erroneous distribution of virtual resources.
[0156] See also Figure 5 , Figure 5This is a flowchart of another consensus method in a blockchain system shown in this specification, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the consensus nodes participating in the consensus in the blockchain system pre-specify a target consensus node responsible for generating blocks; the method is applied to any consensus node participating in the consensus in the blockchain system except the target consensus node, and the method includes the following execution process:
[0157] Step 502: receiving a block corresponding to the current round of consensus issued by the target consensus node; wherein the block is a block generated by the target consensus node based on the collected Quorum consensus proposals that have been passed by consensus when it is determined that the number of collected consensus proposals that have been passed by consensus reaches Quorum; wherein the consensus proposal includes the consensus proposals corresponding to the current round of consensus initiated by each consensus node in the blockchain system;
[0158] Step 504: The block is saved locally to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0159] Figure 5 This is an embodiment in which any consensus node participating in the consensus other than the target consensus node is used as the execution subject. The specific implementation details of this embodiment are as follows: Figure 4 The embodiments shown are the same and will not be described in detail in this specification.
[0160] In each of the embodiments shown above, by introducing an incentive mechanism in a blockchain system running an asynchronous consensus protocol, the asynchronous consensus protocol can be used to support the feature that all consensus nodes can initiate consensus proposals, and virtual resources can be distributed to consensus nodes whose initiated consensus proposals have been passed by consensus:
[0161] On the one hand, since the probability of whether the initiated consensus proposal can be passed by consensus depends largely on the proposal speed and communication efficiency of the proposing node, this method can prevent those inactive consensus nodes whose proposal speed and communication efficiency cannot meet the requirements from obtaining virtual resources as incentives.
[0162] For example, consensus proposals initiated by consensus nodes that cannot meet the requirements in terms of proposal speed and communication efficiency may fail to reach consensus during the consensus process, or may not reach consensus even when the quorum consensus proposals have been passed. Therefore, the consensus proposals initiated by these consensus nodes will no longer be added to the generated blocks, and thus these consensus nodes will not be able to obtain virtual resources as incentives.
[0163] On the other hand, since only the consensus nodes that have initiated consensus proposals that have been successfully passed and successfully added to the newly generated blocks can receive virtual resources as incentives, this method can motivate each consensus node to continuously optimize its own proposal speed and communication efficiency, which can fundamentally promote the blockchain system running the asynchronous consensus protocol to continuously develop in a healthy direction, thereby improving the stability and robustness of the blockchain system.
[0164] For example, for a consensus node, if the consensus proposal it initiated fails to pass due to its own proposal speed and communication efficiency, or if the consensus has not been completed when the Quorum consensus proposal has passed, it will not be able to obtain the virtual resources used as incentives. Driven by interests, the operator of the consensus node will inevitably continuously optimize the node's own proposal speed and communication efficiency, so that the stability and robustness of the blockchain system can be continuously enhanced.
[0165] Corresponding to the embodiments of the aforementioned method, this specification also provides embodiments of an apparatus, an electronic device, and a storage medium.
[0166] Figure 6 is a schematic structural diagram of an electronic device provided by an exemplary embodiment. Figure 6 At the hardware level, the device includes a processor 602, an internal bus 604, a network interface 606, a memory 608, and a non-volatile memory 610, and may also include hardware required for other services. One or more embodiments of this specification may be implemented based on software, such as the processor 602 reading the corresponding computer program from the non-volatile memory 610 into the memory 608 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0167] like Figure 7 As shown, Figure 7 This is a block diagram of a consensus device in a blockchain system according to an exemplary embodiment of the present specification. The device can be applied to Figure 6 In the electronic device shown, the technical solution of this specification is implemented. The consensus protocol run by the consensus node in the blockchain system is an asynchronous consensus protocol; the device 70 is applied to any consensus node participating in the consensus in the blockchain system, and the device 70 includes:
[0168] The first collection module 701 collects consensus proposals that have been agreed upon by the consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals initiated by the current consensus node and corresponding to the current round of consensus, and consensus proposals initiated by other consensus nodes in the blockchain system and corresponding to the current round of consensus;
[0169] The first determination module 702 determines whether the number of consensus proposals that have been collected and passed by consensus has reached the quorum;
[0170] The first saving module 703 generates a block corresponding to this round of consensus based on the collected Quorum consensus proposals if the number of consensus proposals that have been passed reaches Quorum, and saves the block locally to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0171] like Figure 8 As shown, Figure 8 This is a block diagram of another consensus device in a blockchain system according to an exemplary embodiment of the present specification. The device can also be applied to Figure 6 In the electronic device shown, the technical solution of this specification is implemented. The consensus protocol run by the consensus node in the blockchain system is an asynchronous consensus protocol; the consensus nodes participating in the consensus in the blockchain system pre-specify the target consensus node responsible for generating blocks; the device 80 is applied to the target consensus node, and the device 80 includes:
[0172] The second collection module 801 collects consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals initiated by each consensus node in the blockchain system and corresponding to the current round of consensus;
[0173] The second determination module 802 determines whether the number of consensus proposals that have been collected and passed by consensus has reached a quorum;
[0174] The sending module 803 generates a block corresponding to this round of consensus based on the collected Quorum consensus proposals if the number of consensus proposals that have been passed reaches Quorum, and sends the block to each consensus node in the blockchain system for storage, so as to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0175] like Fig. 9 As shown, Fig. 9 This is a block diagram of another consensus device in a blockchain system according to an exemplary embodiment of the present specification. The device can also be applied to Figure 6In the electronic device shown, the technical solution of this specification is implemented. The consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the consensus nodes participating in the consensus in the blockchain system pre-specify the target consensus node responsible for generating blocks; the device is applied to any consensus node participating in the consensus in the blockchain system except the target consensus node, and the device includes:
[0176] A receiving module 901 receives a block corresponding to the current round of consensus issued by the target consensus node; wherein the block is a block generated by the target consensus node based on the collected Quorum consensus proposals that have been passed by consensus when it is determined that the number of the collected consensus proposals that have been passed by consensus reaches Quorum; wherein the consensus proposal includes the consensus proposals corresponding to the current round of consensus initiated by each consensus node in the blockchain system;
[0177] The second saving module 902 saves the block locally to trigger the blockchain system to respectively distribute virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
[0178] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0179] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C2051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0180] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, it is not excluded that with the development of computer technology in the future, the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular 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 a combination of any of these devices.
[0181] Although one or more embodiments of the present specification provide method operation steps as described in the embodiments or flow charts, more or less operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiments is only one way of executing the order of many steps, and does not represent the only execution order. When the device or terminal product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment). The term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or equipment including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, product or equipment. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or equipment including the elements. For example, if the words first, second, etc. are used to represent the name, they do not represent any specific order.
[0182] For the convenience of description, the above devices are described in various modules according to their functions. Of course, when implementing one or more of the present specification, the functions of each module can be implemented in the same or more software and / or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0183] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0184] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0185] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0186] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0187] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0188] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. 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, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0189] It should be understood by those skilled in the art that one or more embodiments of the present specification may be provided as a method, system or computer program product. Therefore, one or more embodiments of the present specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, one or more embodiments of the present specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0190] One or more embodiments of this specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of this specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0191] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. In the description of this specification, the description of the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of this specification. In this specification, the schematic representation of the above terms does not necessarily target the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples without contradiction.
[0192] The above description is only an example of one or more embodiments of this specification and is not intended to limit one or more embodiments of this specification. For those skilled in the art, one or more embodiments of this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the scope of the claims.
Claims
1. A consensus method in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; The method is applied to any consensus node participating in consensus in the blockchain system, and the method includes: Collecting consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals corresponding to the current round of consensus initiated by the current consensus node, and consensus proposals corresponding to the current round of consensus initiated by other consensus nodes in the blockchain system; Determine whether the number of consensus proposals collected and passed by consensus has reached the quorum; If the number of consensus proposals collected and passed reaches Quorum, a block corresponding to this round of consensus is generated based on the collected Quorum consensus proposals, and the block is saved locally to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
2. The method according to claim 1, wherein a smart contract for issuing virtual resources is deployed on the blockchain; Generate blocks corresponding to this round of consensus based on the collected Quorum consensus proposals, including: A block corresponding to this round of consensus is generated locally based on the collected Quorum consensus proposals, and a contract call transaction for initiating the smart contract is added to the block.
3. According to the method of claim 1, the contract call transaction is the last transaction included in the block.
4. According to the method as claimed in claim 1, the smart contract is a system smart contract deployed in the blockchain by the operator of the blockchain service platform corresponding to the blockchain system; accordingly, the contract call transaction is used to initiate a contract call transaction for the system smart contract.
5. According to the method of claim 4, the contract call transaction does not include transaction sender information.
6. The method of claim 2, wherein the locally saving the block to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block, respectively, comprises: The block is saved locally, and the contract call transaction contained in the block is executed to initiate a contract call for the smart contract deployed on the blockchain, and virtual resources are respectively issued to the proposal nodes corresponding to each consensus proposal contained in the block.
7. The method according to claim 1, wherein a service interface for issuing virtual resources is deployed on the blockchain service platform corresponding to the blockchain system; The block is saved locally to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal contained in the block, including: The block is saved locally to trigger the blockchain service platform corresponding to the blockchain system to further call the service interface to respectively issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
8. The method according to claim 1, wherein the asynchronous consensus protocol is a consensus protocol that initiates a consensus proposal based on a block identifier; accordingly, the consensus proposal includes a block identifier of a target block to be agreed upon; And, the list of transactions proposed by the consensus node for the target block; Determine whether the number of consensus proposals collected and passed by consensus has reached the quorum, including: Count the number of consensus proposals that have been collected and passed by consensus, including the block identifier of the target block; It is determined whether the counted number reaches a quorum.
9. The method according to claim 8, wherein the asynchronous consensus protocol is the HoneyBadgerBFT consensus protocol.
10. The method according to claim 1, wherein the asynchronous consensus protocol is a consensus protocol that initiates a consensus proposal based on a timestamp corresponding to the time when the consensus proposal is initiated; accordingly, the consensus proposal includes a timestamp corresponding to the time when the consensus proposal is initiated; And, the list of transactions proposed by the consensus node; Determine whether the number of consensus proposals collected and passed by consensus has reached the quorum, including: Count the number of consensus proposals collected and passed by consensus, the number of which includes timestamps within the timestamp range corresponding to the target block to be agreed upon; It is determined whether the counted number reaches a quorum.
11. The method of claim 10, wherein the asynchronous consensus protocol is the MyTumbler consensus protocol.
12. The method according to claim 1, wherein the blockchain system is a public chain system that supports running an asynchronous consensus protocol.
13. The method of claim 1, wherein each consensus proposal included in the block carries a signature generated based on a private key of the proposing node; The locally saving the block to trigger the blockchain system to respectively distribute virtual resources to the proposal nodes corresponding to each consensus proposal included in the block includes: The block is saved locally to trigger the blockchain system to verify the signatures carried by each consensus proposal contained in the block based on the maintained public key, and after the signature verification is passed, virtual resources are respectively issued to the proposal nodes corresponding to the public key.
14. A consensus method in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the consensus nodes participating in the consensus in the blockchain system pre-specify a target consensus node responsible for generating a block; The method is applied to the target consensus node, and the method includes: Collecting consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals initiated by each consensus node in the blockchain system and corresponding to the current round of consensus; Determine whether the number of consensus proposals collected and passed by consensus has reached the quorum; If the number of consensus proposals collected and passed reaches Quorum, a block corresponding to this round of consensus is generated based on the collected Quorum consensus proposals, and the block is sent to each consensus node in the blockchain system for storage, so as to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
15. A consensus method in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the consensus nodes participating in the consensus in the blockchain system pre-specify a target consensus node responsible for generating a block; The method is applied to any consensus node participating in the consensus except the target consensus node in the blockchain system, and the method includes: Receive a block corresponding to the current round of consensus issued by the target consensus node; wherein the block is a block generated by the target consensus node based on the collected Quorum consensus proposals that have been passed by consensus when it is determined that the number of collected consensus proposals that have been passed by consensus reaches Quorum; wherein the consensus proposal includes the consensus proposals corresponding to the current round of consensus initiated by each consensus node in the blockchain system; The block is saved locally to trigger the blockchain system to respectively issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
16. A consensus device in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; The device is applied to any consensus node participating in consensus in the blockchain system, and the device includes: A first collection module collects consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals initiated by the current consensus node and corresponding to the current round of consensus, and consensus proposals initiated by other consensus nodes in the blockchain system and corresponding to the current round of consensus; The first determination module determines whether the number of consensus proposals collected and passed by consensus has reached the quorum; The first saving module generates a block corresponding to this round of consensus based on the collected Quorum consensus proposals if the number of consensus proposals that have been passed reaches Quorum, and saves the block locally to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
17. A consensus device in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the consensus nodes participating in the consensus in the blockchain system pre-specify a target consensus node responsible for generating a block; The device is applied to the target consensus node, and the device includes: A second collection module collects consensus proposals that have been agreed upon by consensus nodes in the blockchain system; wherein the consensus proposals include consensus proposals initiated by each consensus node in the blockchain system and corresponding to the current round of consensus; The second determination module determines whether the number of consensus proposals that have been collected and passed by consensus has reached the quorum; The sending module generates a block corresponding to this round of consensus based on the collected Quorum consensus proposals if the number of consensus proposals that have been passed reaches Quorum, and sends the block to each consensus node in the blockchain system for storage, so as to trigger the blockchain system to issue virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
18. A consensus device in a blockchain system, wherein the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol; the consensus nodes participating in the consensus in the blockchain system pre-specify a target consensus node responsible for generating a block; The device is applied to any consensus node participating in the consensus except the target consensus node in the blockchain system, and the device includes: A receiving module receives a block corresponding to the current round of consensus issued by the target consensus node; wherein the block is a block generated by the target consensus node based on the collected Quorum consensus proposals that have been passed by consensus when it is determined that the number of collected consensus proposals that have been passed by consensus reaches Quorum; wherein the consensus proposal includes the consensus proposals corresponding to the current round of consensus initiated by each consensus node in the blockchain system; The second saving module saves the block locally to trigger the blockchain system to respectively distribute virtual resources to the proposal nodes corresponding to each consensus proposal included in the block.
19. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 15 are implemented.
20. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 15.
21. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 15 are implemented.
Citation Information
Patent Citations
Block chain consensus method, device and system
CN112991067A
Consensus method and block chain node
CN116846907A
Consensus method in block chain system, block chain node and block chain system
CN117319409A
Consensus method and device in block chain system
CN117997698A
Consensus method, blockchain system and consensus node
WO2023056976A1
