Consensus method and device of block chain, computer readable medium and electronic equipment

By adjusting the proposal waiting time of blockchain nodes, the timeout waiting problem caused by proposal node failure in the BFT consensus algorithm is solved, and the consensus performance of the blockchain is improved.

CN118784658APending Publication Date: 2024-10-15TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310407004.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-07
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

The timeout wait caused by the failure of the proposal node in the BFT consensus algorithm causes the blockchain consensus process to take a long time and affects performance.

Method used

By recording the proposal waiting parameters of each blockchain node, the proposal waiting time of the current proposal node is adjusted. If the proposal message is not received, the waiting time is reduced, and the time for the node to wait to receive the proposal message is reduced.

Benefits of technology

It shortens the consensus time of the blockchain and improves the consensus performance of the blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118784658A_ABST
    Figure CN118784658A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a block chain consensus method and device, a computer readable medium and electronic equipment. The block chain consensus method comprises the following steps: obtaining a proposal waiting parameter corresponding to a current proposal node according to a recorded proposal waiting parameter corresponding to each block chain node; determining a proposal waiting duration corresponding to the current proposal node according to the proposal waiting parameter corresponding to the current proposal node; and in a proposal stage of the current proposal node, if a proposal message initiated by the current proposal node is not received within the proposal waiting duration, adjusting a proposal waiting parameter corresponding to the current proposal node so as to reduce the proposal waiting duration corresponding to the current proposal node. According to the technical scheme of the embodiment of the invention, the consensus time of the block chain can be shortened, and the consensus performance of the block chain can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer and communication technology, and more specifically, to a consensus method, device, computer-readable medium and electronic device for blockchain. Background Art

[0002] In blockchain technology, the consensus mechanism is the basis for ensuring the normal operation of the blockchain system. The so-called consensus means reaching an agreement. Each node device in the blockchain system stores a distributed ledger (i.e., blockchain). The consensus process of the blockchain system is the process of keeping the distributed ledgers between each node device consistent. The BFT (Byzantine Fault Tolerance) consensus algorithm is a commonly used consensus algorithm in blockchain technology. Each block needs to go through three stages: proposal, pre-voting, and pre-submission. If the proposal node fails, then other nodes need to wait for a timeout before voting for an empty block, and the node will still need to wait for a long time to timeout when it acts as a proposal node next time, resulting in a long consensus process, which affects the consensus performance of the blockchain. Summary of the invention

[0003] The embodiments of the present application provide a blockchain consensus method, device, computer-readable medium and electronic device, which can shorten the blockchain consensus time and help improve the blockchain consensus performance.

[0004] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0005] According to one aspect of an embodiment of the present application, a blockchain consensus method is provided, including: obtaining proposal waiting parameters corresponding to a current proposal node according to recorded proposal waiting parameters corresponding to each blockchain node; determining a proposal waiting time corresponding to the current proposal node according to the proposal waiting parameters corresponding to the current proposal node; in the proposal stage of the current proposal node, if no proposal message initiated by the current proposal node is received within the proposal waiting time, adjusting the proposal waiting parameters corresponding to the current proposal node to reduce the proposal waiting time corresponding to the current proposal node.

[0006] According to one aspect of an embodiment of the present application, a consensus device of a blockchain is provided, including: an acquisition unit, configured to acquire a proposal waiting parameter corresponding to a current proposal node according to recorded proposal waiting parameters corresponding to each blockchain node; a determination unit, configured to determine a proposal waiting time corresponding to the current proposal node according to the proposal waiting parameter corresponding to the current proposal node; and a processing unit, configured to adjust the proposal waiting parameter corresponding to the current proposal node during the proposal phase of the current proposal node, if no proposal message initiated by the current proposal node is received within the proposal waiting time, so as to reduce the proposal waiting time corresponding to the current proposal node.

[0007] In some embodiments of the present application, based on the aforementioned scheme, the proposal waiting parameter includes a parameter value; the determination unit is configured as: if the difference between the parameter values ​​corresponding to a set number of other blockchain nodes and the parameter value corresponding to the current proposal node is greater than or equal to a set threshold, then the proposal waiting time corresponding to the current proposal node is determined to be the set time, and the set time is less than the default proposal waiting time of the blockchain network.

[0008] In some embodiments of the present application, based on the aforementioned scheme, the determination unit is configured as follows: if the number of other blockchain nodes whose difference between the parameter values ​​corresponding to the current proposal node is greater than or equal to the set threshold is less than the set number, then the default proposal waiting time will be used as the proposal waiting time corresponding to the current proposal node.

[0009] In some embodiments of the present application, based on the aforementioned scheme, the proposal waiting parameter includes a parameter value; the determination unit is configured to: based on the mapping relationship between the parameter value and the duration, determine the proposal waiting duration corresponding to the current proposal node according to the parameter value corresponding to the current proposal node.

[0010] In some embodiments of the present application, based on the aforementioned scheme, the proposal waiting parameter includes a duration parameter; the determination unit is configured to: use the duration parameter corresponding to the current proposal node as the proposal waiting duration corresponding to the current proposal node.

[0011] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is configured as follows: if no proposal message initiated by the current proposal node is received within the proposal waiting time, the value of the proposal waiting parameter corresponding to the current proposal node is reduced according to the set step size until the minimum value is reached.

[0012] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is also configured to: if a proposal message initiated by the current proposal node is received within the proposal waiting time, the proposal waiting parameters corresponding to the current proposal node are adjusted to maintain or increase the proposal waiting time corresponding to the current proposal node.

[0013] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is configured as follows: if a proposal message initiated by the current proposal node is received within the proposal waiting time, the value of the proposal waiting parameter corresponding to the current proposal node is increased according to the set step size until the maximum value is reached.

[0014] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is configured as follows: if a proposal message initiated by the current proposal node is received within the proposal waiting time, and the block consensus targeted by the proposal message is successful, then the proposal waiting parameters corresponding to the current proposal node are adjusted.

[0015] In some embodiments of the present application, based on the aforementioned scheme, the consensus device of the blockchain also includes: a generation unit, configured to generate a proposal waiting parameter table before obtaining the proposal waiting parameters corresponding to the current proposal node based on the recorded proposal waiting parameters corresponding to each blockchain node, wherein the proposal waiting parameter table includes default proposal waiting parameters set for each blockchain node in the blockchain network.

[0016] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is also configured to: if the blockchain node recovers to a normal state from an abnormal state, synchronize the proposal waiting parameters corresponding to the respective blockchain nodes from other blockchain nodes to update the proposal waiting parameters corresponding to the respective blockchain nodes recorded locally.

[0017] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the consensus method of the blockchain as described in the above embodiment is implemented.

[0018] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more computer programs, wherein when the one or more computer programs are executed by the one or more processors, the electronic device implements the consensus method of the blockchain as described in the above embodiments.

[0019] According to one aspect of an embodiment of the present application, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium. A processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device executes the consensus method of the blockchain provided in the above-mentioned various optional embodiments.

[0020] In the technical solutions provided in some embodiments of the present application, the proposal waiting parameters corresponding to the current proposal node are obtained, and the proposal waiting time corresponding to the current proposal node is determined according to the proposal waiting parameters corresponding to the current proposal node. Then, in the proposal stage of the current proposal node, if the proposal message initiated by the current proposal node is not received within the proposal waiting time, the proposal waiting parameters corresponding to the current proposal node are adjusted to reduce the proposal waiting time corresponding to the current proposal node, so that when the current proposal node serves as a proposal node again, the waiting time for other nodes to receive proposal messages can be reduced, thereby shortening the consensus time of the blockchain, which is conducive to improving the consensus performance of the blockchain.

[0021] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A schematic diagram of the structure of a blockchain network is shown;

[0023] Figure 2 A schematic diagram showing the connection relationship between blocks in the blockchain;

[0024] Figure 3 A schematic diagram of the process of the BFT consensus algorithm is shown;

[0025] Figure 4 A schematic diagram showing a consensus node broadcasting a block according to an embodiment of the present application is shown;

[0026] Figure 5 A schematic diagram showing the processing process of each consensus stage of the BFT consensus algorithm is shown;

[0027] Figure 6 A flowchart of a consensus method of a blockchain according to an embodiment of the present application is shown;

[0028] Figure 7 A schematic diagram showing the processing process of each consensus stage in the consensus process according to an embodiment of the present application is shown;

[0029] Figure 8 A schematic diagram showing the processing process of each consensus stage in the consensus process according to an embodiment of the present application is shown;

[0030] Fig. 9 A block diagram of a consensus device of a blockchain according to an embodiment of the present application is shown;

[0031] Fig.10 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0032] The exemplary embodiments are now described in a more comprehensive manner with reference to the accompanying drawings. However, the exemplary embodiments can be implemented in various forms and should not be understood as being limited to these examples; on the contrary, the purpose of providing these embodiments is to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.

[0033] In addition, the features, structures or characteristics described in the present application may be combined in one or more embodiments in any suitable manner. In the following description, there are many specific details so that the embodiments of the present application can be fully understood. However, those skilled in the art will appreciate that when implementing the technical scheme of the present application, all the detailed features in the embodiments may not be needed, one or more specific details may be omitted, or other methods, elements, devices, steps, etc. may be adopted.

[0034] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0035] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0036] It should be noted that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0037] The technical solution of the embodiment of the present application involves blockchain technology. Specifically, blockchain is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks (i.e., blocks) generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.

[0038] The underlying blockchain platform can include processing modules such as user management, basic services, smart contracts, and operation management. Among them, the user management module is responsible for the identity information management of all blockchain participants, including maintaining the generation of public and private keys (account management), key management, and the maintenance of the corresponding relationship between user information and blockchain addresses (authority management). The basic service module is deployed on all blockchain node devices to verify the validity of business requests and record the valid requests to the storage after consensus is reached. For a new business request, the basic service first performs interface adaptation analysis and authentication processing (interface adaptation), and then encrypts the business information through the consensus algorithm (consensus management). After encryption, it is completely and consistently transmitted to the shared ledger (network communication) and recorded and stored. The smart contract module is responsible for the registration and issuance of contracts, as well as contract triggering and contract execution. Developers can define the contract logic in a certain programming language and publish it to the blockchain (contract registration). According to the logic of the contract terms, the key or other event triggers the execution to complete the contract logic. At the same time, it also provides the function of contract upgrade and cancellation. The operation management module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation and real-time status visualization output of the product during the product release process, such as alarm, network status detection, node device health status detection, etc.

[0039] The platform product service layer provides the basic capabilities and implementation framework of typical applications. Developers can superimpose business features based on these basic capabilities to complete the blockchain implementation of business logic. The application service layer provides application services based on blockchain solutions for business participants to use.

[0040] As mentioned above, blockchain is essentially a decentralized database, and the blockchain is maintained by the nodes in the blockchain network. Figure 1The blockchain network shown may include multiple nodes 101, and the multiple nodes 101 may be the various clients forming the blockchain network. Each node 101 may receive input information during normal operation, and maintain the shared data in the blockchain network based on the received input information. In order to ensure the information intercommunication within the blockchain network, there may be an information connection between each node in the blockchain network, and information may be transmitted between nodes through the above information connection. For example, when any node in the blockchain network receives input information, other nodes in the blockchain network obtain the input information according to the consensus algorithm, and store the input information as shared data, so that the data stored on all nodes in the blockchain network are consistent.

[0041] Each node in the blockchain network has a corresponding node identifier, and each node in the blockchain network can store the node identifiers of other nodes, so that the generated blocks can be broadcast to other nodes in the blockchain network according to the node identifiers of other nodes. A node identifier list can be maintained in each node, and the node name and node identifier are stored in the node identifier list accordingly. The node identifier can be an IP (Internet Protocol, a protocol for interconnecting networks) address or any other information that can be used to identify the node.

[0042] Each node in the blockchain network stores the same blockchain. The blockchain consists of multiple blocks, see Figure 2 As shown in the figure, the blockchain consists of multiple blocks, which are connected into a chain structure in the order of creation timestamp from small to large. Each block includes a block header and a block body. The block header stores the hash of the previous block and the Merkle root of this block. The block body contains the complete transaction data of this block and is organized in the form of a Merkle tree. From the structure of the blockchain, it can be seen that the block data stored in each block in the blockchain is associated with the block data stored in the parent block (i.e., the previous block), which ensures the security of the information input in the block.

[0043] Each node in the blockchain network can be a server or a terminal device. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal device can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, smart home, vehicle terminal, aircraft, etc., but is not limited to this. Each node can be directly or indirectly connected by wired or wireless communication, and this application is not limited here.

[0044] It should be noted that the Merkle tree is an important part of blockchain technology. The blockchain will not directly save the original data in plain text. The original data needs to be hashed and stored in the form of hash values. The Merkle tree is used to organize the hash values ​​formed by hashing multiple original data according to the binary tree structure and save them in the block body.

[0045] There is another key technology in blockchain technology, namely the consensus mechanism, which is the basis for ensuring the normal operation of the blockchain system. The so-called consensus means reaching an agreement. Each node device in the blockchain system stores a distributed ledger (i.e., blockchain). The consensus process of the blockchain system is the process of keeping the distributed ledgers between each node device consistent. Among them, all or part of the node devices in the blockchain system can participate in the consensus process of the blockchain system. The consensus process of the blockchain system is usually based on the consensus algorithm. Each node device participating in the consensus executes the corresponding process of the consensus process by running the consensus algorithm. Optional consensus algorithms include PoW (Proof of Work), PoS (Proof of Stake), DPoS (Delegated Proof of Stake), BFT (Byzantine Fault Tolerance), PBFT (Practical Byzantine Fault Tolerance), etc.

[0046] Usually, one or more rounds of consensus process are required at a certain block height in the blockchain to reach a consensus among the various node devices participating in the consensus. The block height is used to indicate the number of blocks connected to the blockchain. The block height is the identifier of the block, which can be used to indicate the position of the block in the blockchain. For example, the block height of the genesis block in the blockchain defaults to 0, the block height of the first block after the genesis block is 1 (the first block can be referred to as block 1), the block height of the second block after the genesis block is 2 (the second block can be referred to as block 2), and so on.

[0047] For example, the block height of the current block of a blockchain is 300 (referred to as block 300), which means that 300 blocks have been stacked on the genesis block, that is, the number of blocks on the blockchain formed from the genesis block to block 300 is 301. The consensus process at a certain block height of the blockchain refers to the process of consensus on the blocks to be chained in the blockchain system when the blockchain is at a certain block height. If the consensus on the block to be chained is successful, the block is added to the blockchain, and the block height of the blockchain is +1. For example: the consensus process at the block height of the blockchain is 10. It means the process of consensus on the blocks to be chained in the blockchain system when the blockchain is at the block height of 10. If the consensus on the block is successful, the block is added to the blockchain, and the block height of the blockchain changes from 10 to 11.

[0048] Generally speaking, Figure 3 As shown in the figure, a round of consensus process can be divided into three consensus stages according to the execution order, namely the proposal stage, the prevote stage and the precommit stage. The multiple node devices participating in the same round of consensus process include two types: proposal nodes and non-proposal nodes. The so-called proposal node refers to a node device generated by multiple node devices participating in the consensus through election. As a proposal node, the node device is responsible for generating the block to be agreed upon according to the request in the proposal stage of this round of consensus process, and broadcasting the block to be agreed upon to other node devices participating in the consensus for consensus processing; it is also responsible for consensus processing of the block to be agreed upon. Non-proposal nodes only perform consensus processing on the block to be agreed upon.

[0049] Consensus processing includes pre-voting and pre-submitting. Pre-voting occurs in the pre-voting phase (prevote phase), while pre-submitting occurs in the pre-submitting phase (precommit phase). Pre-voting refers to the process of whether to agree to pre-vote on the block to be agreed upon. If you agree to pre-vote on the block to be agreed upon, it means that you agree to add the block to the blockchain. Pre-submitting refers to the process of whether to agree to pre-submit the block to be agreed upon. If you agree to pre-submit the block to be agreed upon, it means that you confirm that you agree to add the block to the blockchain. In the process of multiple rounds of consensus at the same block height, the node devices participating in the consensus may change for different rounds of consensus, that is, the node devices participating in each round of the consensus process may change, and the proposal node may change, and the block to be agreed upon may also change.

[0050] The following is a detailed description of the specific process of the Ni-th round of consensus process of the blockchain block height H in the embodiment of the present application using a specific example, where H, N, and i are all positive integers, and i is less than N. Taking i=1 as an example, in the N-1th round of consensus process of the blockchain block height H, there are 4 node devices participating in the consensus process. Figure 4 A block broadcasting schematic diagram of a consensus node according to an embodiment of the present application is shown; Figure 4 As shown in the figure, the node devices participating in the consensus process in the blockchain system are node device A, node device B, node device C and node device D. In the N-1th round of consensus process of the block height H of the blockchain, node device B is the proposal node, and node devices A, node devices C and node devices D are non-proposal nodes. Figure 5 As shown in the figure, the specific process of the N-1th round of consensus process at the block height H of the blockchain includes:

[0051] 1. Proposal stage:

[0052] First, node device B (i.e., the proposal node) generates a target block Block-X to be agreed upon, which can be a new block created by node device B. Then, node device B generates a proposal message (proposal) for the target block Block-X, and then broadcasts it to node devices A, C, and D.

[0053] 2. Pre-voting stage:

[0054] Due to network failure, equipment failure or other reasons, some node devices may not be able to receive Block-X broadcast by node device B in the first time. For example, if node device A does not receive Block-X broadcast by node device B in the first time, node device C and node device D both receive Block-X broadcast by node device B in the first time; then in the pre-voting stage, node device B, node device C and node device D all take Block-X as the target block to be agreed upon, and pre-vote Block-X to obtain their respective pre-voting messages. The pre-voting message here contains the block identifier to be pre-voted. For example, node device C pre-votes Block-X to generate a pre-voting message of node device C. The pre-voting message of node device C includes the identifier of Block-X, and the pre-voting message indicates that node device C agrees to pre-vote Block-X, that is, agrees to add Block-X to the blockchain, and Block-X obtains the pre-vote of node device C.

[0055] It is understandable that if node device C does not generate a pre-voting message for node device C, it means that node device C has not pre-voted Block-X; if the pre-voting message for node device C does not include the identifier of Block-X, it means that node device C does not agree to pre-vote for Block-X, that is, it does not agree to add Block-X to the blockchain. Since node device A did not receive Block-X in the first time, it can determine the empty block emptyBlock as the target block to be agreed upon, and pre-vote emptyBlock to obtain the pre-voting message of node device A, and the pre-voting message of node device A includes the identifier of emptyBlock. The first time can be set according to actual needs, such as 1 minute, 3 minutes, etc.

[0056] Node device A, node device B, node device C and node device D each broadcast their own pre-voting message. Due to network failure, device failure or other reasons, some node devices may not receive the pre-voting message broadcast by other node devices within the second time. Therefore, when the second time arrives, each node device participating in the consensus process will count the number of pre-votes obtained by the target block to be agreed upon in the pre-voting stage according to the pre-voting message received within the second time, and confirm whether the number of pre-votes exceeds the quantity threshold. The quantity threshold here can be set according to actual conditions. For example, the quantity threshold can be 50% of the number of node devices participating in the consensus process, or 2 / 3 (or 2 / 3+1) of the number of node devices participating in the consensus process. The second time here can also be set according to actual needs, such as 1 minute, 3 minutes, etc.; the second time can be the same as the first time, or different from the first time.

[0057] For example: suppose the quantity threshold is 2. Since node device A only performs pre-voting on emptyBlock, the pre-voting message of node device A includes the identifier of emptyBlock; while node devices B, C and D all perform pre-voting on Block-X, and the pre-voting messages of node devices B, C and D all include the identifier of Block-X; at the same time, suppose node device A only receives the pre-voting message from node device B, and the number of pre-votes obtained by Block-X in the pre-voting stage is 1 in combination with the statistics of node device A's own pre-voting message, confirming that the number of pre-votes obtained by Block-X does not exceed the quantity threshold of 2. Suppose node device B receives three pre-voting messages from node devices A, C and D, and the number of pre-votes obtained by Block-X is 3 in combination with the statistics of node device B's own pre-voting message, confirming that the number of pre-votes obtained by Block-X exceeds the quantity threshold of 2. Similarly, suppose that node device C receives three pre-voting messages from node device A, node device B, and node device D, and then combines node device C's own pre-voting message to obtain a number of pre-votes obtained by Block-X of 3, confirming that the number of pre-votes obtained by Block-X exceeds the threshold of 2. Suppose that node device D also receives three pre-voting messages from node device A, node device B, and node device C, and then combines node device D's own pre-voting message to obtain a number of pre-votes obtained by Block-X of 3, confirming that the number of pre-votes obtained by Block-X exceeds the threshold of 2.

[0058] 3. Pre-submission stage:

[0059] Node device B, node device C and node device D all determine Block-X as the target block to be agreed upon, so they all pre-submit Block-X to obtain their own pre-submit voting messages; the pre-submit voting message here contains the block identifier of the pre-submitted block. For example: Node device C pre-submits Block-X to generate a pre-submit voting message of node device C, which includes the identifier of Block-X, and the pre-submit voting message indicates that node device C agrees to pre-submit Block-X, which means that it confirms that it agrees to add Block-X to the blockchain, and Block-X obtains the pre-submission of node device C.

[0060] It is understandable that if node device C does not generate a pre-submission voting message of node device C, it means that node device C has not pre-submitted Block-X; if the pre-submission voting message of node device C does not include the identifier of Block-X, it means that node device C does not agree to pre-submit Block-X, that is, it does not agree to add Block-X to the blockchain. Since node device A determines the empty block emptyBlock as the target block to be agreed upon, node device A pre-submits emptyBlock to obtain the pre-submission voting message of node device A, and the pre-submission voting message of node device A includes the identifier of emptyBlock.

[0061] Node device A, node device B, node device C and node device D each broadcast their own pre-submission voting message. Due to network failure, device failure or other reasons, some node devices may not receive the pre-submission voting message broadcast by other node devices within the third time. When the third time arrives, each node device participating in the consensus process counts the number of pre-submissions obtained by the target block to be agreed upon in the pre-submission stage according to the pre-submission voting message received within the third time, and confirms whether the pre-submission number exceeds the submission threshold. The submission threshold here can be set according to actual conditions, for example, the submission threshold can be 50% of the number of node devices participating in the consensus process, or 2 / 3 (or 2 / 3+1) of the number of node devices participating in the consensus process. The third time here can also be set according to actual needs, for example, 1 minute, 3 minutes, etc.; the third time can be the same as the second time, or different from the second time; similarly, the third time can be the same as the first time, or different from the first time.

[0062] For example: suppose the commit threshold is 2. Since node device A only performs pre-commit processing on emptyBlock, the pre-commit voting message of node device A includes the identifier of emptyBlock; while node devices B, node devices C and node devices D all perform pre-commit processing on Block-X, and the pre-commit voting messages of node devices B, node devices C and node devices D all include the identifier of Block-X; at the same time, suppose node device B receives pre-commit voting messages from node devices A and node devices C, and combines the statistics of node device B's own pre-commit voting messages to obtain the number of pre-commits obtained by Block-X in the pre-commit stage to be 2, confirming that the number of pre-commits obtained by Block-X does not exceed (is not greater than) the commit threshold of 2. Suppose node device C receives pre-commit voting messages from node devices A and node devices C, and combines the statistics of node device C's own pre-commit voting messages to obtain the number of pre-commits obtained by Block-X to be 2, confirming that the number of pre-commits obtained by Block-X does not exceed (is not greater than) the commit threshold of 2. Similarly, suppose that node device A receives three pre-submission voting messages from node device B, node device C, and node device D, and then combines the statistics of node device A's own pre-submission voting message to obtain the pre-submission number of Block-X to be 3, confirming that the pre-submission number obtained by Block-X exceeds the submission threshold of 2. Suppose that node device D also receives three pre-submission voting messages from node device A, node device B, and node device C, and then combines the statistics of node device D's own pre-submission voting message to obtain the pre-submission number of Block-X to be 3, confirming that the pre-submission number obtained by Block-X exceeds the submission threshold of 2.

[0063] After the above three consensus stages, if the number of pre-votes obtained by the target block to be agreed upon exceeds the number threshold, and the number of pre-submissions obtained exceeds the submission threshold, then the consensus of the target block to be agreed upon is successful and can be added to the blockchain, that is, the submission (commit) process is executed; otherwise, the consensus fails and cannot be added to the blockchain. According to the above example, node device A confirms that the number of pre-submissions obtained by Block-X exceeds the submission threshold, but the number of pre-votes obtained does not exceed the number threshold, so it is determined that the consensus of Block-X has failed. Node device B confirms that the number of pre-votes obtained by Block-X exceeds the number threshold, but the number of pre-submissions obtained does not exceed the submission threshold, so it is determined that the consensus of Block-X has failed. Node device C confirms that the number of pre-votes obtained by Block-X exceeds the number threshold, but the number of pre-submissions obtained does not exceed the submission threshold, so it is determined that the consensus of Block-X has failed. Node device D confirms that the number of pre-votes obtained by Block-X exceeds the number threshold, and the number of pre-submissions obtained exceeds the submission threshold, so it is determined that the consensus of Block-X has failed. Node device D confirms that the number of pre-votes obtained by Block-X exceeds the number threshold, and the number of pre-submissions obtained exceeds the submission threshold, so it is determined that the consensus of Block-X has succeeded, and node device D adds Block-X to the blockchain stored locally by node device D.

[0064] To summarize, in the N-1th round of consensus when the block height of the blockchain is H, node device A, node device B and node device C did not reach a consensus on Block-X, and did not write Block-X into their respective distributed ledgers (i.e., added it to their respective locally stored blockchains), but node device D reached a consensus on Block-X and wrote Block-X into its own distributed ledger, then the block height of the blockchain stored locally by node device D becomes H+1; during the Nth round of consensus when the block height of the blockchain is H, node device D will no longer participate in the consensus, and the node devices participating in the consensus will be changed to node device A, node device B and node device C.

[0065] It should be noted that when the Nth round of consensus process is carried out at a block height of H on the blockchain, the proposal node may change. For example, in the above example, the proposal node in the N-1th round of consensus process at a block height of H on the blockchain is node device B, while in the Nth round of consensus process at a block height of H on the blockchain, it may be changed to node device C; then the above three consensus stages are re-executed to complete the Nth round of consensus process at a block height of H on the blockchain.

[0066] From the above consensus mechanism, it can be seen that each block needs to go through three stages: proposal, pre-voting, and pre-submission. In order to ensure the stable operation of the algorithm, each node will have a timer in the proposal stage (in order to ensure that the proposal node can construct the proposal message, the timeout is generally set to a larger time, such as 30s) to wait for the proposal node to generate the proposal message. If other nodes do not receive the proposal message constructed by the proposal node within a certain period of time, then in order to ensure that the algorithm can continue and enter the next round of consensus as soon as possible, an empty proposal message will be voted. Therefore, if a proposal node in the blockchain network does not generate a proposal message or other nodes do not receive the proposal message it initiated, then a consensus on an empty proposal message will be reached according to the consensus process. Then another node is switched to become the proposal node. If a node crashes or is shut down for other reasons at this time, when it is its turn to become the proposal node, other nodes will not receive the proposal message it generates because it has crashed or been shut down. Therefore, other nodes will wait for a while and cast a blank vote. Then a normal node will be switched to become the proposal node. At this time, the normal node generates a proposal message to allow the consensus to continue.

[0067] It can be seen that if a node is down or shut down, when it is its turn to become a proposal node, it will not generate a proposal message to send to other nodes for consensus. Therefore, when it is the turn of this faulty node to become a proposal node, the entire blockchain network will have no proposal message for consensus, which will cause other nodes to wait for a timeout to cast empty votes to reach an empty consensus, and then replace a normal node to become a proposal node and generate a valid proposal message to reach a consensus with a proposal. However, the next time it is the turn of this faulty node to become a proposal node, other nodes will need to wait for a long time, which seriously affects the consensus performance of the blockchain.

[0068] Based on the above technical problems, the embodiment of the present application proposes a new consensus scheme for blockchain, which can shorten the consensus time of blockchain and help improve the consensus performance of blockchain. Specifically, for any blockchain node in the blockchain network, the proposal waiting parameters corresponding to each blockchain node can be recorded. When it is the turn of a node to serve as the current proposal node, the proposal waiting time corresponding to the current proposal node can be determined according to the proposal waiting parameters corresponding to the current proposal node. Then, in the proposal stage of the current proposal node, if the proposal message initiated by the current proposal node is not received within the proposal waiting time, the proposal waiting parameters corresponding to the current proposal node are adjusted to reduce the proposal waiting time corresponding to the current proposal node. In this way, when the current proposal node serves as a proposal node again, the time for other nodes to wait for receiving proposal messages can be reduced, thereby shortening the consensus time of blockchain and helping improve the consensus performance of blockchain.

[0069] The following is a detailed description of various implementation details of the technical solution of the embodiment of the present application:

[0070] Figure 6 A flowchart of a consensus method of a blockchain according to an embodiment of the present application is shown, and the consensus method of the blockchain can be executed by a blockchain node. Specifically, refer to Figure 6 As shown, the consensus method of the blockchain includes at least steps S610 to S630, which are described in detail as follows:

[0071] In step S610, based on the recorded proposal waiting parameters corresponding to each blockchain node, the proposal waiting parameters corresponding to the current proposal node are obtained.

[0072] In some optional embodiments, each blockchain node in the blockchain network can locally record the proposal waiting parameter corresponding to each blockchain node, and the proposal waiting parameter is used to determine the proposal waiting time. For example, the proposal waiting parameter can be a parameter value, and then the proposal waiting time corresponding to a blockchain node as a proposal node can be determined according to the parameter value; the proposal waiting parameter can also be a time parameter, and then the time parameter can be directly used as the corresponding proposal waiting time.

[0073] Optionally, each blockchain node may generate a proposal waiting parameter table at the initial stage, wherein the proposal waiting parameter table includes default proposal waiting parameters set for each blockchain node in the blockchain network.

[0074] In step S620, the proposal waiting time corresponding to the current proposal node is determined according to the proposal waiting parameter corresponding to the current proposal node.

[0075] In some optional embodiments, the proposal waiting parameter may be a parameter value. In this case, when determining the proposal waiting time corresponding to the current proposal node, if the difference between the parameter values ​​corresponding to a set number of other blockchain nodes and the parameter value corresponding to the current proposal node is greater than or equal to a set threshold, the proposal waiting time corresponding to the current proposal node is determined as the set time, and the set time is less than the default proposal waiting time of the blockchain network (such as 30s, etc.). For example, the set threshold may be 5, and the set time may be 1 / 3 or half of the default proposal waiting time.

[0076] Based on the technical solution of the aforementioned embodiment, if the number of other blockchain nodes whose difference between the parameter values ​​corresponding to the current proposal node is greater than or equal to the set threshold is less than the set number, the default proposal waiting time is used as the proposal waiting time corresponding to the current proposal node. Alternatively, if the number of other blockchain nodes whose difference between the parameter values ​​corresponding to the current proposal node is greater than or equal to the set threshold is less than the set number, the proposal waiting time corresponding to the current proposal node can also be appropriately reduced, such as being set to half or 3 / 4 of the default proposal waiting time.

[0077] In some optional embodiments, the proposal waiting parameter may be a parameter value. In this case, when determining the proposal waiting time corresponding to the current proposal node, the proposal waiting time corresponding to the current proposal node may be determined based on the mapping relationship between the parameter value and the time. For example, the mapping relationship between the parameter value and the time may be preset. As an example, if the parameter value is 10, the corresponding proposal waiting time is the default proposal waiting time; if the parameter value is 9, the corresponding proposal waiting time is 9 / 10 of the default proposal waiting time; if the parameter value is 8, the corresponding proposal waiting time is 8 / 10 of the default proposal waiting time... and so on. Then, the proposal waiting time corresponding to the current proposal node may be determined based on the parameter value corresponding to the current proposal node.

[0078] As another example, the mapping relationship between the parameter value and the duration can also be: if the parameter value is 6-10, the corresponding proposal waiting time is the default proposal waiting time; if the parameter value is 0-5, the corresponding proposal waiting time is 1 / 3 of the default proposal waiting time, etc.

[0079] In some optional embodiments, the proposal waiting parameter may be a duration parameter. In this case, when determining the proposal waiting duration corresponding to the current proposal node, the duration parameter corresponding to the current proposal node may be used as the proposal waiting duration corresponding to the current proposal node. That is, in this embodiment, the proposal waiting parameter corresponding to each blockchain node is the actual duration parameter, so the duration parameter may be directly used as the proposal waiting duration.

[0080] In step S630, during the proposal phase of the current proposal node, if the proposal message initiated by the current proposal node is not received within the proposal waiting time, the proposal waiting parameters corresponding to the current proposal node are adjusted to reduce the proposal waiting time corresponding to the current proposal node.

[0081] In some optional embodiments, when the proposal message initiated by the current proposal node is not received within the proposal waiting time, the process of adjusting the proposal waiting parameter corresponding to the current proposal node may be: when the proposal message initiated by the current proposal node is not received within the proposal waiting time, the value of the proposal waiting parameter corresponding to the current proposal node is reduced according to the set step length until the minimum value is reached. For example, the value of the proposal waiting parameter corresponding to blockchain node A is 5. When blockchain node A is used as a proposal node, other blockchain nodes do not receive the proposal message broadcast by blockchain node A within the proposal waiting time. Then, the value of the proposal waiting parameter corresponding to blockchain node A can be adjusted to 4, that is, the step length is set to 1 (of course, the step length can also be set to other values). Optionally, the minimum value can be 0.

[0082] In some optional embodiments, when a proposal message initiated by the current proposal node is received within the proposal waiting time, the proposal waiting parameter corresponding to the current proposal node can be adjusted to maintain or increase the proposal waiting time corresponding to the current proposal node. In this embodiment, if a proposal message initiated by the current proposal node is received within the proposal waiting time, it means that the proposal node is normal, and the proposal waiting time corresponding to the current proposal node can be maintained; and for the blockchain node that has previously shortened the proposal waiting time, its corresponding proposal waiting time can be appropriately increased.

[0083] In some optional embodiments, when a proposal message initiated by the current proposal node is received within the proposal waiting time, the process of adjusting the proposal waiting parameter corresponding to the current proposal node may be to increase the value of the proposal waiting parameter corresponding to the current proposal node according to the set step length until the maximum value is reached. For example, the value of the proposal waiting parameter corresponding to blockchain node A is 5. When blockchain node A is used as a proposal node, other blockchain nodes receive the proposal message broadcast by blockchain node A within the proposal waiting time. Then, the value of the proposal waiting parameter corresponding to blockchain node A can be adjusted to 6, that is, the step length is set to 1 (of course, the step length can also be set to other values). Optionally, the minimum value can be 10.

[0084] In some optional embodiments, if a proposal message initiated by the current proposal node is received within the proposal waiting time, the proposal waiting parameters corresponding to the current proposal node may not be adjusted first. Instead, the proposal waiting parameters corresponding to the current proposal node may be adjusted after the consensus of the block targeted by the proposal message initiated by the current proposal node succeeds. This can eliminate the impact of illegal proposal messages initiated by the current proposal node.

[0085] In some optional embodiments, since normal blockchain nodes will adjust the proposal waiting parameters corresponding to the blockchain nodes according to whether they have received the proposal message initiated by the proposal node, and the blockchain nodes in abnormal state (such as downtime, network failure, etc.) cannot be adjusted in time, the proposal waiting parameters corresponding to each blockchain node can be synchronized from other blockchain nodes when the blockchain node is restored to normal state from the abnormal state, so as to update the proposal waiting parameters corresponding to each blockchain node recorded locally. The technical solution of this embodiment enables the blockchain node that has recovered to normal to update the locally maintained proposal waiting parameters in time, thereby avoiding affecting the consensus process of subsequent blocks, which is conducive to ensuring the consensus performance of the blockchain.

[0086] It can be seen that the technical solution of the embodiment of the present application can adjust the proposal waiting parameters corresponding to the current proposal node during the proposal stage of the current proposal node. If the proposal message initiated by the current proposal node is not received within the proposal waiting time, the proposal waiting time corresponding to the current proposal node can be reduced, so that when the current proposal node is used as a proposal node again, the waiting time for other nodes to receive proposal messages can be reduced, thereby shortening the consensus time of the blockchain, which is conducive to improving the consensus performance of the blockchain.

[0087] The following combination Figures 7 and 8 , the implementation details of the technical solution of the embodiment of the present application are described again with specific examples:

[0088] The technical solution of the embodiment of the present application is mainly to adjust the proposal waiting time when the faulty node is used as a proposal node, so as to avoid waiting for a long time each time and affecting the consensus performance of the blockchain. Specifically, each node can maintain a mapping map, the key of which is the node id, the value is an integer, and the initial value is 0. If the entire blockchain network reaches a consensus when a certain node is used as a proposal node, it means that the node is a normal node, then each node will set the key to the value of this node + 1 in the mapping map maintained by each node. If other nodes do not receive the proposal message generated by this proposal node within the timeout waiting time (i.e., the proposal waiting time), then it can be considered that this node may be faulty, so the mapping map maintained by each node will be the value of this node - 1. Optionally, the value of each key in the mapping map can range from 0 to 10, that is, if the value after the +1 operation exceeds 10, then the value is also set to 10; if the value after the value - 1 operation is lower than 0, then the value is also set to 0.

[0089] Based on the above-maintained mapping map, if a node fails, the value of the node will continue to decrease and eventually become 0. If the node is normal, the value corresponding to the node will continue to increase and eventually become 10. When a node becomes a proposal node, other nodes obtain the value of all node IDs from their local mapping map. If the value of the proposal node ID is lower than the value of other nodes by more than 5, and the number of nodes with a value difference of more than 5 exceeds 2 / 3 of the total number of nodes, then the timeout for other nodes to wait for the proposal message of this proposal node can be adjusted to 1 / 3 of the default proposal waiting time (the specific values ​​in this embodiment are only examples).

[0090] It can be seen that if the value of a node lags behind the value of most nodes (such as 2 / 3) by more than 5, when it becomes a proposal node, the timeout time for other nodes to wait for it to generate a proposal message is 1 / 3 of the normal timeout time. When the faulty node is restored to normal, it can generate a proposal message normally to reach a consensus, and the corresponding value maintained by other nodes will gradually return to normal through the +1 operation. Therefore, the technical solution of the embodiment of the present application can greatly improve the performance of the entire blockchain network when facing node failures.

[0091] Specifically, Figure 7As shown in the figure, suppose there are 4 nodes. Initially, all nodes maintain their own mapping maps, and the values ​​of all node IDs in the mapping map are initialized to 0. Assume that node 4 becomes a faulty node due to downtime or other reasons, and the other 3 nodes are normal nodes. After a period of consensus, the value of node 4 becomes 1, and the value of the other three nodes is 9. At this time, the consensus process of these 4 nodes is as follows:

[0092] The situation where a normal node becomes a proposal node (for the convenience of description, node 1 is taken as an example to illustrate):

[0093] Because node 1 is a normal node, it can generate a normal proposal message and then broadcast the proposal information to other nodes. Figure 7 As shown, node 2 and node 3 are normal nodes. The two nodes are compared based on the values ​​of all keys in the local map. Since node 1 is a normal node, the values ​​of each node ID in the map of node 2 and node 3 are shown in Table 1 below:

[0094]

[0095]

[0096] Table 1

[0097] As shown in Table 1, since no more than 2 / 3 of the nodes are greater than the value of node 1, the time that nodes 2 and 3 wait for node 1 to generate a proposal message is the normal timeout waiting time (represented as timeout). During the timeout, nodes 2 and 3 can receive the proposal message generated by node 1, and then prevote the proposal message, and finally reach a consensus after the precommit vote. After the consensus is reached, the value of node 1 is +1 in the mapping map of each node. Because the value of node 1 does not exceed 10, the value of the mapping map maintained by each node after the consensus is completed is shown in Table 2 below:

[0098] Node ID Value Node 1 10 Node 2 9 Node 3 9 Node 4 1

[0099] Table 2

[0100] The situation where the faulty node (i.e. node 4) becomes the proposal node:

[0101] Because node 4 is a faulty node, it is impossible for it to generate a proposal message, so the consensus process is as follows: Figure 8As shown, normal nodes 1, 2, and 3 are compared based on the value of all keys in their local mapping maps. Since node 4 is a faulty node, the value of each node ID in the mapping maps of nodes 1, 2, and 3 is shown in Table 3 below:

[0102] Node ID Value Node 1 10 Node 2 9 Node 3 9 Node 4 1

[0103] Table 3

[0104] As shown in Table 3, since the difference between the value of node 4 and the value of node 1 is 9, the difference between the value of node 4 and the value of node 2 is 8, and the difference between the value of node 4 and the value of node 3 is 8, the total number of nodes is 4, and the number of nodes whose value difference between node 4 and other nodes is greater than 5 is 3, which exceeds 2 / 3 of the number of nodes. Therefore, the timeout period for nodes 1, 2, and 3 to wait for the proposal message from node 4 is timeout / 3. After timeout / 3, nodes 1, 2, and 3 will time out and cast empty votes, and finally reach a consensus on an empty proposal message. After this round of empty proposal consensus, the map of each node performs a -1 operation on the value of node 4. After the consensus is completed, the value of the mapping map of each node is shown in Table 4 below:

[0105] Node ID Value Node 1 10 Node 2 9 Node 3 9 Node 4 0

[0106] Table 4

[0107] Since no valid consensus was reached when node 4 was the proposal node, in the next round of consensus, a normal node among nodes 1, 2, and 3 becomes the proposal node and can generate proposal messages normally for consensus.

[0108] As the consensus continues to advance, the value of nodes 1, 2, and 3 will continue to increase to 10, while node 4 is a faulty node and its value will gradually decrease to 0. Therefore, when node 4 becomes a proposal node, the timeout waiting time for nodes 1, 2, and 3 to wait for node 4 to generate a proposal message is 1 / 3 of the normal timeout time. At this time, for the consensus process, when faulty node 4 becomes a proposal node, the invalid waiting time of other nodes is shortened, greatly improving the consensus performance of the blockchain.

[0109] If the failed node 4 is restarted and recovered at a certain time, node 4 will start to synchronize blocks from other nodes. After the synchronization of node 4 is completed, if it becomes a proposal node, it can generate proposal messages. After several consensuses, the value of node 4 will gradually increase to 10 in the map of each node. In this way, all nodes become normal nodes and the consensus performance of the system is restored.

[0110] It can be seen that in the embodiment of the application, if a node becomes a faulty node, after several consensuses, its value will gradually decrease until it becomes 0. Then, when it becomes a proposal node, the time other nodes wait for it to generate a proposal message is very short, thus shortening the invalid waiting time. When the faulty node recovers to become a normal node and can generate a proposal message, after several consensus processes, the value of the node gradually increases to a normal value, and the consensus performance of the blockchain system also returns to normal.

[0111] In the above embodiment, the proposal waiting time is adjusted by increasing or decreasing the value of the node. In other embodiments of the present application, each node may also record the initial proposal waiting time corresponding to each node in the local mapping map. If a node acts as a proposal node and does not receive a proposal message initiated by the proposal node within the proposal waiting time, the proposal waiting time corresponding to the proposal node is gradually lowered until it is reduced to the minimum value. This can also shorten the invalid waiting time of other nodes. When the faulty node is restored to a normal node and can generate a proposal message, the proposal waiting time corresponding to the proposal node is gradually increased until it increases to a normal value, and the consensus performance of the blockchain system is restored to normal.

[0112] The following describes an embodiment of the device of the present application, which can be used to execute the consensus method of the blockchain in the above embodiment of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the consensus method of the blockchain in the above embodiment of the present application.

[0113] Fig. 9 A block diagram of a consensus device of a blockchain according to an embodiment of the present application is shown, and the consensus device of the blockchain can be set in a blockchain node.

[0114] Reference Fig. 9 As shown, a consensus device 900 of a blockchain according to an embodiment of the present application includes: an acquisition unit 902, a determination unit 904 and a processing unit 906.

[0115] Among them, the acquisition unit 902 is configured to acquire the proposal waiting parameters corresponding to the current proposal node according to the recorded proposal waiting parameters corresponding to each blockchain node; the determination unit 904 is configured to determine the proposal waiting time corresponding to the current proposal node according to the proposal waiting parameters corresponding to the current proposal node; the processing unit 906 is configured to adjust the proposal waiting parameters corresponding to the current proposal node during the proposal stage of the current proposal node, if no proposal message initiated by the current proposal node is received within the proposal waiting time, so as to reduce the proposal waiting time corresponding to the current proposal node.

[0116] In some embodiments of the present application, based on the aforementioned scheme, the proposal waiting parameter includes a parameter value; the determination unit 904 is configured as: if the difference between the parameter values ​​corresponding to a set number of other blockchain nodes and the parameter value corresponding to the current proposal node is greater than or equal to a set threshold, then the proposal waiting time corresponding to the current proposal node is determined to be the set time, and the set time is less than the default proposal waiting time of the blockchain network.

[0117] In some embodiments of the present application, based on the aforementioned scheme, the determination unit 904 is configured as follows: if the number of other blockchain nodes whose difference between the parameter values ​​corresponding to the current proposal node is greater than or equal to the set threshold is less than the set number, then the default proposal waiting time is used as the proposal waiting time corresponding to the current proposal node.

[0118] In some embodiments of the present application, based on the aforementioned scheme, the proposal waiting parameter includes a parameter value; the determination unit 904 is configured to: based on the mapping relationship between the parameter value and the duration, determine the proposal waiting duration corresponding to the current proposal node according to the parameter value corresponding to the current proposal node.

[0119] In some embodiments of the present application, based on the aforementioned scheme, the proposal waiting parameter includes a duration parameter; the determination unit 904 is configured to: use the duration parameter corresponding to the current proposal node as the proposal waiting duration corresponding to the current proposal node.

[0120] In some embodiments of the present application, based on the aforementioned scheme, the processing unit 906 is configured as follows: if the proposal message initiated by the current proposal node is not received within the proposal waiting time, the value of the proposal waiting parameter corresponding to the current proposal node is reduced according to the set step size until the minimum value is reached.

[0121] In some embodiments of the present application, based on the aforementioned scheme, the processing unit 906 is also configured to: if a proposal message initiated by the current proposal node is received within the proposal waiting time, the proposal waiting parameters corresponding to the current proposal node are adjusted to maintain or increase the proposal waiting time corresponding to the current proposal node.

[0122] In some embodiments of the present application, based on the aforementioned scheme, the processing unit 906 is configured as follows: if a proposal message initiated by the current proposal node is received within the proposal waiting time, the value of the proposal waiting parameter corresponding to the current proposal node is increased according to the set step size until the maximum value is reached.

[0123] In some embodiments of the present application, based on the aforementioned scheme, the processing unit 906 is configured as follows: if a proposal message initiated by the current proposal node is received within the proposal waiting time, and the block consensus targeted by the proposal message is successful, then the proposal waiting parameters corresponding to the current proposal node are adjusted.

[0124] In some embodiments of the present application, based on the aforementioned scheme, the consensus device 900 of the blockchain also includes: a generation unit, configured to generate a proposal waiting parameter table before obtaining the proposal waiting parameters corresponding to the current proposal node based on the recorded proposal waiting parameters corresponding to each blockchain node, wherein the proposal waiting parameter table includes default proposal waiting parameters set for each blockchain node in the blockchain network.

[0125] In some embodiments of the present application, based on the aforementioned scheme, the processing unit 906 is also configured to: if the blockchain node recovers to a normal state from an abnormal state, synchronize the proposal waiting parameters corresponding to each blockchain node from other blockchain nodes to update the proposal waiting parameters corresponding to each blockchain node recorded locally.

[0126] Fig.10 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.

[0127] It should be noted that Fig.10 The computer system 1000 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0128] like Fig.10As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1002 or the program loaded from the storage part 1008 to the random access memory (RAM) 1003, such as executing the method described in the above embodiment. In the RAM 1003, various programs and data required for system operation are also stored. The CPU 1001, the ROM 1002 and the RAM 1003 are connected to each other through the bus 1004. The input / output (I / O) interface 1005 is also connected to the bus 1004.

[0129] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed so that a computer program read therefrom is installed into the storage section 1008 as needed.

[0130] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1009, and / or installed from a removable medium 1011. When the computer program is executed by a central processing unit (CPU) 1001, various functions defined in the system of the present application are executed.

[0131] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0132] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of the boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and a computer program.

[0133] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0134] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more computer programs, and when the above one or more computer programs are executed by an electronic device, the electronic device implements the method described in the above embodiment.

[0135] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0136] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.

[0137] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.

[0138] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A consensus method for blockchain, characterized in that: include: According to the recorded proposal waiting parameters corresponding to each blockchain node, obtain the proposal waiting parameters corresponding to the current proposal node; Determine the proposal waiting time corresponding to the current proposal node according to the proposal waiting parameter corresponding to the current proposal node; During the proposal phase of the current proposal node, if a proposal message initiated by the current proposal node is not received within the proposal waiting time, the proposal waiting parameters corresponding to the current proposal node are adjusted to reduce the proposal waiting time corresponding to the current proposal node.

2. The consensus method of blockchain according to claim 1, characterized in that: The proposal waiting parameter includes a parameter value; Determining the proposal waiting time corresponding to the current proposal node according to the proposal waiting parameter corresponding to the current proposal node includes: If the difference between the parameter values ​​corresponding to a set number of other blockchain nodes and the parameter value corresponding to the current proposal node is greater than or equal to a set threshold, the proposal waiting time corresponding to the current proposal node is determined as the set time, and the set time is less than the default proposal waiting time of the blockchain network.

3. The consensus method of blockchain according to claim 2, characterized in that: The method further comprises: If the number of other blockchain nodes whose difference between the parameter values ​​corresponding to the current proposal node is greater than or equal to the set threshold is less than the set number, the default proposal waiting time will be used as the proposal waiting time corresponding to the current proposal node.

4. The consensus method of blockchain according to claim 1, characterized in that: The proposal waiting parameter includes a parameter value; Determining the proposal waiting time corresponding to the current proposal node according to the proposal waiting parameter corresponding to the current proposal node includes: Based on the mapping relationship between parameter value and duration, the proposal waiting duration corresponding to the current proposal node is determined according to the parameter value corresponding to the current proposal node.

5. The consensus method of blockchain according to claim 1, characterized in that: The proposal waiting parameters include a duration parameter; Determining the proposal waiting time corresponding to the current proposal node according to the proposal waiting parameter corresponding to the current proposal node includes: The duration parameter corresponding to the current proposal node is used as the proposal waiting duration corresponding to the current proposal node.

6. The consensus method of the blockchain according to any one of claims 1 to 5, characterized in that: If the proposal message initiated by the current proposal node is not received within the proposal waiting time, the proposal waiting parameters corresponding to the current proposal node are adjusted, including: If the proposal message initiated by the current proposal node is not received within the proposal waiting time, the value of the proposal waiting parameter corresponding to the current proposal node is reduced according to the set step size until the minimum value is reached.

7. The consensus method of the blockchain according to any one of claims 1 to 5, characterized in that: The method further comprises: If a proposal message initiated by the current proposal node is received within the proposal waiting time, the proposal waiting parameter corresponding to the current proposal node is adjusted to maintain or increase the proposal waiting time corresponding to the current proposal node.

8. The consensus method of blockchain according to claim 7, characterized in that: If a proposal message initiated by the current proposal node is received within the proposal waiting time, the proposal waiting parameters corresponding to the current proposal node are adjusted, including: If a proposal message initiated by the current proposal node is received within the proposal waiting time, the value of the proposal waiting parameter corresponding to the current proposal node is increased according to the set step size until the maximum value is reached.

9. The consensus method of blockchain according to claim 7, characterized in that: If a proposal message initiated by the current proposal node is received within the proposal waiting time, the proposal waiting parameters corresponding to the current proposal node are adjusted, including: If a proposal message initiated by the current proposal node is received within the proposal waiting time, and the block consensus targeted by the proposal message succeeds, the proposal waiting parameters corresponding to the current proposal node are adjusted.

10. The consensus method of blockchain according to any one of claims 1 to 5, characterized in that: Before obtaining the proposal waiting parameters corresponding to the current proposal node according to the recorded proposal waiting parameters corresponding to each blockchain node, the method further includes: Generate a proposal waiting parameter table, which contains default proposal waiting parameters set for each blockchain node in the blockchain network.

11. The consensus method of blockchain according to any one of claims 1 to 5, characterized in that: The method further comprises: If the blockchain node recovers to a normal state from an abnormal state, the proposal waiting parameters corresponding to each blockchain node are synchronized from other blockchain nodes to update the proposal waiting parameters corresponding to each blockchain node recorded locally.

12. A consensus device for blockchain, characterized in that: include: An acquisition unit, configured to acquire a proposal waiting parameter corresponding to a current proposal node according to the recorded proposal waiting parameters corresponding to each blockchain node; A determination unit configured to determine a proposal waiting time corresponding to the current proposal node according to a proposal waiting parameter corresponding to the current proposal node; The processing unit is configured to adjust the proposal waiting parameters corresponding to the current proposal node to reduce the proposal waiting time corresponding to the current proposal node if the proposal message initiated by the current proposal node is not received within the proposal waiting time during the proposal phase of the current proposal node.

13. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the consensus method of the blockchain as described in any one of claims 1 to 11 is implemented.

14. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more computer programs, which, when executed by the one or more processors, enables the electronic device to implement the consensus method of the blockchain as described in any one of claims 1 to 11.

15. A computer program product, characterized in that The computer program product includes a computer program, which is stored in a computer-readable storage medium. A processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device executes the consensus method of the blockchain as described in any one of claims 1 to 11.