Consensus mechanism optimization method, system and blockchain network based on Paxos algorithm

By introducing the proposal numbering and retransmission time mechanism into the Paxos algorithm, the problem of excessive communication load and prolonged consensus time in the blockchain network is solved, the consensus mechanism of the blockchain network is optimized, and the information throughput and execution time are reduced.

CN111930840BActive Publication Date: 2024-09-13PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010785078.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-06
Publication Date
2024-09-13
Estimated Expiration
2040-08-06

AI Technical Summary

Technical Problem

The Paxos algorithm causes problems such as excessive communication load and prolonged consensus time in distributed systems, especially in blockchain networks due to increased information traffic and infinite loop competition due to node dispersion.

Method used

The main proposal node sends a preparation request carrying a proposal number to all accepting nodes, and determines the proposal resend time according to preset rules to avoid infinite loop competition and reduce unnecessary information throughput and execution time.

Benefits of technology

It reduces the information throughput and execution time of the Paxos algorithm in the blockchain network, optimizes the consensus mechanism, avoids infinite loop competition, and improves efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111930840B
    Figure CN111930840B
Patent Text Reader

Abstract

The embodiment of the present invention discloses a consensus mechanism optimization method, system, blockchain network and storage medium based on the Paxos algorithm. The present application relates to the field of blockchain technology. The method includes: a main proposal node sends a preparation request carrying a proposal number N to all receiving nodes. If the preparation request is not the preparation request received for the first time, the receiving node determines whether to send a commitment response to the main proposal node according to the received proposal number N. If the commitment response sent by more than half of the receiving nodes is not received, the main proposal node determines the proposal retransmission time according to a preset rule. If the current time reaches the proposal retransmission time, the main proposal node sends a new round of preparation requests and approval requests carrying a proposal number greater than N to all receiving nodes again. The embodiment of the present invention can avoid the infinite loop competition of the main proposal node, reduce the amount of information traffic during the operation of the Paxos algorithm, and improve the execution efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a consensus mechanism optimization method, system, blockchain network and storage medium based on the Paxos algorithm. Background Art

[0002] The Paxos algorithm is a highly fault-tolerant consistency algorithm proposed by Leslie Lamport in 1990. The Paxos algorithm is similar to the existing algorithms that select results through election voting. Both algorithms are executed through a message passing mechanism. The problem that the Paxos algorithm solves is how a distributed system can reach a consensus on a resolution (Value). During the execution of the basic Paxos algorithm, only one proposal can be passed at a time. A typical scenario is that in a distributed database system, if the initial state of each node is consistent and each node executes the same sequence of operations, then they can finally get a consistent state. In order to ensure that each node executes the same sequence of commands, it is necessary to execute a "consistency algorithm" on each instruction to ensure that the instructions seen by each node are consistent.

[0003] However, since there are a large number of nodes in the distributed system, the nodes are not closely connected, but in a relatively dispersed state. Such a layout will cause the proposal node (Proposer) to generate a huge amount of information traffic when sending preparation requests (Prepare) and approval requests (Accept) to the acceptance node (Accepter), causing a series of problems such as excessive communication load. The inventor found that if there is an infinite loop competition between the main proposal node (Leader) and the newly generated main proposal node in the Paxos algorithm running instance, the basic Paxos algorithm will also generate a huge amount of information traffic during operation, and the time used to reach a consensus will be prolonged, increasing the maintenance cost in the process of reaching a consensus on data. Summary of the invention

[0004] The embodiments of the present invention provide a consensus mechanism optimization method, system, blockchain network and storage medium based on the Paxos algorithm, aiming to solve the problems of excessive communication load and prolonged time when reaching a consensus in the Paxos algorithm in the related art.

[0005] In a first aspect, an embodiment of the present invention provides a consensus mechanism optimization method based on the Paxos algorithm, which is applied to a blockchain network, wherein the blockchain network includes a proposal node, an acceptance node and a learning node, and the method includes: a main proposal node sends a preparation request carrying a proposal number N to all acceptance nodes, wherein the main proposal node is a proposal node that currently initiates a proposal to the acceptance node among multiple proposal nodes; if the preparation request is not the first preparation request received, the acceptance node determines whether the received proposal number N is greater than the highest proposal number M of the proposals it has approved; if the received proposal number N is greater than the highest proposal number M of the proposals it has approved, The highest proposal number M of the approved proposals, the accepting node returns a commitment response to the main proposal node to inform it of the resolution of the highest proposal number M that has been approved, and promises that it will not approve any proposal with a proposal number less than the proposal number N; the main proposal node determines whether the commitment response is received from more than half of the accepting nodes; if the commitment response is not received from more than half of the accepting nodes, the main proposal node determines the proposal retransmission time according to the preset rules; if the current time reaches the proposal retransmission time, the main proposal node again sends a new round of preparation requests carrying proposal numbers greater than N to all the accepting nodes.

[0006] In the second aspect, an embodiment of the present invention provides a consensus mechanism optimization system based on the Paxos algorithm, which is applied to a blockchain network, wherein the blockchain network includes a proposal node, an acceptance node and a learning node, wherein the main proposal node among the proposal nodes is configured with a first sending unit, a second judgment unit, a determination unit and a re-proposal unit; the acceptance node is configured with a first judgment unit and a return unit, wherein the main proposal node is a proposal node among multiple proposal nodes that currently initiates a proposal to the acceptance node; the first sending unit is used to send a preparation request carrying a proposal number N to all acceptance nodes; the first judgment unit is used to determine whether the received proposal number N is greater than the highest number of approved proposals if the preparation request is not the first preparation request received. Proposal number M; the return unit is used for, if the received proposal number N is greater than the highest proposal number M of the proposals it has approved, the receiving node returns a commitment response to the main proposal node to inform it of the resolution of the highest proposal number M it has approved, and promises not to approve any proposal with a proposal number less than the proposal number N; the second judgment unit is used to determine whether the commitment responses sent by more than half of the receiving nodes are received; the determination unit is used to determine the proposal retransmission time according to preset rules if the commitment responses sent by more than half of the receiving nodes are not received; the re-proposal unit is used for, if the current time reaches the proposal retransmission time, the main proposal node again sends a new round of preparation requests carrying proposal numbers greater than N to all the receiving nodes.

[0007] In a third aspect, an embodiment of the present invention provides a blockchain network, comprising multiple nodes, including a proposal node, an acceptance node and a learning node, each of the nodes corresponding to a computer device, the computer device comprising a memory and a processor connected to the memory; the memory is used to store a computer program; the processors corresponding to the multiple nodes are used to run the computer program stored in the corresponding memory to jointly execute the steps described in the above method.

[0008] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a plurality of computer programs, and the plurality of computer programs, when respectively executed by a plurality of processors, can jointly implement the steps described in the above method.

[0009] The embodiment of the present invention provides a consensus mechanism optimization method, system, blockchain network and storage medium based on Paxos algorithm. The method includes: the main proposal node sends a preparation request carrying a proposal number N to all receiving nodes. If the preparation request is not the preparation request received for the first time, and the received proposal number N is greater than the highest proposal number M of the proposals it has approved, the receiving node returns a commitment response to the main proposal node to inform it of the resolution of the highest proposal number M approved, and promises not to approve any proposal with a proposal number less than the proposal number N; if the received proposal number N is not greater than the highest proposal number M of the proposals it has approved, the main proposal node cannot receive the commitment response sent by the receiving node, if the main proposal node does not receive the commitment response sent by more than half of the receiving nodes, the main proposal node determines the proposal retransmission time according to a preset rule; if the current time reaches the proposal retransmission time, the main proposal node sends a new round of preparation requests carrying a proposal number greater than N to all the receiving nodes again. According to the technical solution of the embodiment of the present invention, when the main proposal node is making a new round of proposals, the proposal retransmission time is determined by preset rules, so that the infinite loop competition between the main proposal node and the newly generated main proposal node during the execution of the Paxos algorithm is reduced to zero, avoiding the inability of the Paxos algorithm to continue execution due to the infinite loop competition, thereby reducing unnecessary information flux and execution time, and realizing the optimization of the consensus mechanism in the blockchain network. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0011] Figure 1 A schematic diagram of an application scenario of a consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention;

[0012] Figure 2 A schematic diagram of the preparation phase of the consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention;

[0013] Figure 3 A schematic diagram of the approval phase flow of the consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention;

[0014] Figure 4 A schematic diagram of a sub-process of a consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention;

[0015] Figure 5 Another flowchart of the approval phase of the consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention;

[0016] Figure 6 Another flowchart of the approval phase of the consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention;

[0017] Figure 7 Another flowchart of the approval phase of the consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention;

[0018] Figure 8 A schematic diagram of the flow of the learning phase of the consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention;

[0019] Fig. 9 A schematic block diagram of a consensus mechanism optimization system based on the Paxos algorithm of the present invention; and

[0020] Fig.10 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0022] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0023] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0024] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0025] See also Figure 1 , Figure 1 Schematic diagram of an application scenario of a consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention. The consensus mechanism optimization method based on the Paxos algorithm is applied to a blockchain network, wherein the blockchain network includes a proposal node, an acceptance node, and a learning node, such as Figure 1 As shown in the figure, it shows a proposal node, an acceptance node and a learning node in the blockchain network. The above nodes need to go through the preparation stage, approval stage and the final learning stage when achieving consistency based on the Paxos algorithm. First, the proposal node sends a proposal to the acceptance node, that is, sends a preparation request and enters the preparation stage. The acceptance node accepts the preparation request sent by the proposal node and determines whether to accept the preparation request of the main proposal node and gives corresponding feedback. When the proposal node receives the commitment response fed back by the acceptance node, it enters the approval stage and sends an approval request to the acceptance stage. The acceptance node accepts the approval request sent by the proposal node and determines whether to accept the approval request of the proposal node and gives corresponding feedback. If the acceptance node approves the approval request of the proposal node, the resolution contained in the approved proposal is sent to the learning node for learning and execution, that is, it enters the final learning stage.

[0026] like Figure 2 As shown, Figure 2 A schematic flow chart of the preparation phase of the consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention shows the preparation phase of the consensus mechanism optimization method based on the Paxos algorithm provided in an embodiment of the present invention. In this embodiment, the preparation phase includes the following steps S110-S160:

[0027] S110. The main proposal node sends a preparation request carrying a proposal number N to all receiving nodes, wherein the main proposal node is a proposal node among multiple proposal nodes that currently initiates a proposal to the receiving node.

[0028] In this embodiment, the main proposal node first sends a preparation request to all receiving nodes, wherein the preparation request sent carries the proposal number N, so that the receiving node can determine whether to accept the preparation request according to the proposal number N. Among them, the main proposal node is elected from multiple proposal nodes in the blockchain network, and the specific election method can adopt the existing election rules, which are not limited here. The main proposal node sends a preparation request to the receiving node to avoid conflicts caused by multiple proposal nodes sending preparation requests to the receiving node.

[0029] S120, the receiving node determines whether the received preparation request is the first preparation request received. If the preparation request is the first preparation request received, execute step S130; if the preparation request is not the first preparation request received, execute step S140.

[0030] S130. If the preparation request is the first preparation request received, the receiving node returns a commitment response to the main proposing node, and the commitment response includes a resolution arbitrarily selected by the receiving node or the commitment response is empty, and promises that no proposal with a proposal number less than the proposal number N will be approved.

[0031] In this embodiment, if the accepting node has not accepted any proposal before accepting the preparation request, the accepting node returns a commitment response to the main proposal node, and records the proposal number in the received preparation request as the highest proposal number accepted. The commitment response includes a resolution arbitrarily selected by the accepting node or the commitment response is empty.

[0032] S140, if the preparation request is not the first preparation request received, the receiving node determines whether the received proposal number N is greater than the highest proposal number M of the proposals it has approved. If the received proposal number N is greater than the highest proposal number M of the proposals it has approved, execute step S150; if the received proposal number N is not greater than the highest proposal number M of the proposals it has approved, execute step S160.

[0033] S150. If the received proposal number N is greater than the highest proposal number M of the proposals it has approved, the accepting node returns a commitment response to the main proposing node to inform it of the resolution of the highest proposal number M it has approved, and promises not to approve any proposal with a proposal number less than the proposal number N.

[0034] S160. If the received proposal number N is not greater than the highest proposal number M of the proposals it has approved, the accepting node ignores the preparation request for the received proposal number N.

[0035] In this embodiment, if the preparation request is not the first preparation request received, the receiving node determines whether the received proposal number N is greater than the highest proposal number M of the proposals it has approved. The receiving node accepts preparation requests with proposal numbers greater than the highest proposal number M of the proposals it has approved and sends a commitment response, while ignoring preparation requests with proposal numbers not greater than the highest proposal number M of the proposals it has approved, to ensure that the receiving node records the highest proposal number currently accepted.

[0036] like Figure 3 As shown, after the above preparation stage, the approval stage is entered, and the approval stage includes the following steps S210-S250:

[0037] S210, the main proposal node determines whether it has received the commitment responses sent by more than half of the receiving nodes. If it has received the commitment responses sent by more than half of the receiving nodes, execute step S220; if it has not received the commitment responses sent by more than half of the receiving nodes, execute step S230.

[0038] In this embodiment, the main proposal node determines whether it has received the commitment responses sent by more than half of the receiving nodes. If it has not received the commitment responses sent by more than half of the receiving nodes, the main proposal node's preparation request for this round has failed and it is necessary to initiate a new round of preparation requests. If it has received the commitment responses sent by more than half of the receiving nodes, the main proposal node's preparation request for this round has succeeded, and the main proposal node then sends an approval request to the receiving node to enter the approval stage.

[0039] S220. If the main proposing node receives the commitment responses sent by more than half of the receiving nodes, the main proposing node sends an approval request to more than half of the receiving nodes, and the approval request includes the proposal number N and the resolution of the highest proposal number M in the commitment responses sent by the receiving nodes.

[0040] In this embodiment, the main proposal node that has received the commitment response sent by more than half of the receiving nodes can send an approval request to more than half of the receiving nodes. Among them, more than half of the receiving nodes that receive the preparation request and more than half of the receiving nodes that receive the approval request are not limited to the same receiving nodes, but the number of the above-mentioned receiving nodes must be more than half, so that more than half of the receiving nodes that receive the preparation request and more than half of the receiving nodes that receive the approval request have at least one of the same receiving nodes.

[0041] S230: If the commitment response sent by more than half of the receiving nodes is not received, the main proposal node determines the proposal retransmission time according to the preset rules. It is judged whether the proposal retransmission time has arrived. If the proposal retransmission time has arrived, step S240 is executed; if the proposal retransmission time has not arrived, the main proposal node continues to wait until the proposal retransmission time has arrived to execute step S240.

[0042] In this embodiment, the main proposal node sends a preparation request to more than half of the main proposal nodes, but does not receive the commitment response sent by more than half of the receiving nodes, that is, the proposal number N sent by the main proposal node is not the largest proposal number for some receiving nodes. The main proposal node may conflict with the proposal process of the new main proposal node in the process of sending a new round of preparation requests. Determining the proposal retransmission time through preset rules can avoid conflicts with the proposal process of the new main proposal node, thereby promoting the consensus mechanism to be reached as soon as possible.

[0043] S240: If the proposal resending time is reached, the main proposal node sends a new round of preparation requests and approval requests carrying proposal numbers greater than N to all the receiving nodes again.

[0044] like Figure 4 As shown, in one embodiment, for example, in this embodiment, the step of determining the proposal retransmission time according to the preset rule by the main proposal node specifically includes the following steps S231-S232:

[0045] S231, the main proposal node obtains the waiting time generated by a random mechanism;

[0046] S232. The main proposal node determines the time point for sending a new round of preparation requests to all the receiving nodes again according to the current time and the waiting time as the proposal retransmission time.

[0047] In this embodiment, the main proposal node obtains the waiting time generated by the random mechanism, and then determines to send a new round of preparation requests to all the receiving nodes again according to the current time and the waiting time, thereby reducing the probability of conflict between main proposal nodes in the proposal process to zero, avoiding the problem of the Paxos algorithm being unable to continue to execute due to infinite loop competition, and increasing unnecessary information throughput and execution time.

[0048] like Figure 5 As shown, in one embodiment of the present invention, for example, in this embodiment, after the step S150 where the accepting node returns a commitment response to the main proposing node to inform it of the resolution of the highest proposal number M that has been approved and promises not to approve any proposal with a proposal number less than the proposal number N, the method further includes the following steps S170-S190:

[0049] S170, after the receiving node returns a commitment response to the main proposal node, before receiving an approval request from the main proposal node, it determines whether a preparation request sent by a new main proposal node with a proposal number greater than the proposal number N is received. If a preparation request sent by a new main proposal node with a proposal number greater than the proposal number N is received, step S180 is executed; if a preparation request sent by a new main proposal node with a proposal number greater than the proposal number N is not received, step S210 is executed.

[0050] S180, if a preparation request carrying a proposal number greater than the proposal number N is received from a new main proposal node, the receiving node immediately sends a rejection response to the main proposal node corresponding to the proposal number N;

[0051] S190. If the main proposal node corresponding to the proposal number N receives the rejection response sent by the receiving node, the main proposal node stops sending approval requests to the receiving node that sent the rejection response.

[0052] If no preparation request carrying a proposal number greater than the proposal number N is received from the new main proposal node, step S210 is executed.

[0053] In this embodiment, if a preparation request carrying a proposal number greater than the proposal number N is received from a new main proposal node, the receiving node immediately sends a rejection response to the main proposal node corresponding to the proposal number N. The main proposal node receives the rejection response sent by the receiving node, and the main proposal node stops sending approval requests to the receiving node that sent the rejection response. Compared with the execution process of the existing Paxos algorithm, the main proposal node that receives the rejection response no longer sends an approval request to the receiving node that sent the rejection response, which greatly reduces the number of information transmissions between the main proposal node and the receiving node, reduces the communication load, and the main proposal node does not have to wait until it receives the rejection response before sending an invalid approval request, which reduces the execution time of the Paxos algorithm and improves the execution efficiency of the Paxos algorithm.

[0054] like Figure 6 As shown, step S220 includes steps S221-S225.

[0055] S221, the receiving node determines whether the received approval request is the first received approval request. If the approval request is the first received approval request, execute step S222; if the approval request is not the first received approval request, execute step S223.

[0056] S222. If the approval request is the first approval request received, the receiving node receives the approval request, and the receiving node returns an approval response to the main proposal node, and the approval response includes the proposal number and the resolution.

[0057] In this embodiment, if the accepting node has not received an approval request, it approves the first approval request received, and records the proposal number and the resolution in the first approval request received as the highest proposal number it has approved and the resolution corresponding to the highest proposal number.

[0058] S223. If the approval request is not the first approval request received, the receiving node determines whether the proposal number N of the approval request received is greater than the highest proposal number M of the proposals it has approved. If the proposal number N of the approval request received by the receiving node is greater than the highest proposal number M of the proposals it has approved, step S224 is executed; if the proposal number N of the approval request received by the receiving node is not greater than the highest proposal number M of the proposals it has approved, step S225 is executed.

[0059] S224. If the proposal number N of the approval request received by the receiving node is greater than the highest proposal number M of the proposals it has approved, the receiving node sends an approval response to the main proposing node.

[0060] In this embodiment, the proposal number N of the approval request received by the accepting node is greater than the highest proposal number M of the proposals it has approved. The accepting node accepts the approval request and sends an approval response to the main proposal node to inform the main proposal node.

[0061] S225. If the proposal number N of the approval request received by the receiving node is not greater than the highest proposal number M of the proposals it has approved, the receiving node immediately sends a rejection response to the main proposal node, and the rejection response includes the resolution of the highest proposal number M approved by the receiving node.

[0062] In this embodiment, since the accepting nodes that receive more than half of the preparation requests and the accepting nodes that receive more than half of the approval requests are not limited to the same accepting nodes, if the proposal number N of the approval request received by the accepting node is not greater than the highest proposal number M of the proposals it has approved, the accepting node immediately sends a rejection response to the main proposing node.

[0063] like Figure 7 As shown, after the main proposing node receives the approval response and / or rejection response sent by the accepting node, steps S226-S228 are included.

[0064] S226. The main proposing node determines whether it has received approval responses from more than half of the receiving nodes.

[0065] S227. If the main proposing node receives approval responses from more than half of the accepting nodes, the main proposing node determines that this round of proposal is successful.

[0066] S228. If the main proposal node does not receive approval responses from more than half of the receiving nodes, the main proposal node determines that this round of proposal has failed, and the main proposal node returns to execute step S110.

[0067] In this embodiment, the proposal of the main proposal node that receives approval responses from more than half of the receiving nodes is successful in this round, and the proposal of the main proposal node that does not receive approval responses from more than half of the receiving nodes fails in this round. If the proposal fails in this round, the main proposal node returns to step S110 and sends a new round of preparation requests and approval requests carrying proposal numbers greater than N to all the receiving nodes.

[0068] like Figure 8As shown, after the approval phase, the Paxos algorithm enters the execution learning phase, and the learning nodes in the blockchain network are divided into multiple learning node sets. The method also includes S310-S330:

[0069] S310, the receiving node selects one of the learning node sets from the multiple learning node sets as the target learning node set;

[0070] S320, the receiving node sends the successfully approved proposal as a successful proposal to the learning nodes in the target learning node set;

[0071] S330. The learning nodes in the target learning node set learn the successful proposal, and forward the successful proposal to the remaining learning node sets in the multiple learning node sets so that the learning nodes in the remaining learning node sets learn the successful proposal.

[0072] In this embodiment, the learning nodes are first divided into multiple learning node sets, and the successfully approved proposals received from the receiving node are first learned by one of the learning node sets, and forwarded by the learning node set to the remaining learning node sets in the multiple learning node sets for learning and execution, which reduces the communication volume of the information release process after the receiving node approves the proposal, and multiple learning nodes in a learning node set learn first, which improves the reliability of the learning node. The learning node also has a proposal function, and the learning node can actively send a preparation request to the receiving node to obtain information about the resolution approved by the receiving node.

[0073] Fig. 9 is a schematic block diagram of a consensus mechanism optimization system 100 based on the Paxos algorithm provided in an embodiment of the present invention. Fig. 9 As shown, corresponding to the consensus mechanism optimization method based on the Paxos algorithm applied to the blockchain network, the present invention also provides a consensus mechanism optimization system 100 based on the Paxos algorithm. The consensus mechanism optimization system 100 based on the Paxos algorithm includes a unit for executing the consensus mechanism optimization method based on the Paxos algorithm. Specifically, the blockchain network includes a proposal node, an acceptance node and a learning node, and the system includes various units configured in the proposal node, the acceptance node and the learning node. Among them, the main proposal node in the proposal node is configured with a first sending unit 101, a second judgment unit 102, a first determination unit 103 and a re-proposal unit 104; the acceptance node is configured with a first judgment unit 201 and a first return unit 202, wherein the main proposal node is a proposal node that currently initiates a proposal to the acceptance node among the multiple proposal nodes.

[0074] The first sending unit 101 is used to send a preparation request carrying a proposal number N to all receiving nodes;

[0075] The first judgment unit 201 is used to judge whether the received proposal number N is greater than the highest proposal number M of the approved proposals if the preparation request is not the first preparation request received;

[0076] The first returning unit 202 is used for, if the received proposal number N is greater than the highest proposal number M of the proposals it has approved, the accepting node returns a commitment response to the main proposal node to inform it of the resolution of the highest proposal number M it has approved, and promises not to approve any proposal with a proposal number less than the proposal number N;

[0077] The second judgment unit 102 is used to judge whether the commitment response sent by more than half of the receiving nodes is received;

[0078] The first determination unit 103 is used to determine the proposal retransmission time according to a preset rule if the commitment response sent by more than half of the receiving nodes is not received;

[0079] The re-proposal unit 104 is used for, if the current time reaches the proposal retransmission time, the main proposal node again sends a new round of preparation requests carrying a proposal number greater than N to all the receiving nodes.

[0080] In an embodiment of the present invention, the main proposal node is also configured with a waiting unit 105, a second determination unit 106, a first stop unit 107, a second sending unit 108, a fourth judgment unit 109, and a third determination unit 110; the receiving node is configured with a second return unit 203, a third judgment unit 204, a third return unit 205, a fourth return unit 206, and a fifth return unit 207; and the learning node is configured with a selection unit 301, a third sending unit 302, and a learning unit 303.

[0081] The waiting unit 105 is used for the main proposal node to obtain the waiting time generated by the random mechanism;

[0082] The second determination unit 106 is used by the main proposal node to determine the time point for sending a new round of preparation requests to all the receiving nodes again as the proposal retransmission time according to the current time and the waiting time.

[0083] The second return unit 203 is used to, if receiving a preparation request sent by a new main proposal node and carrying a proposal number greater than the proposal number N, the receiving node immediately sends a rejection response to the main proposal node corresponding to the proposal number N.

[0084] The first stopping unit 107 is used for stopping sending approval requests to the receiving node that sent the rejection response if the main proposal node corresponding to the proposal number N receives the rejection response sent by the receiving node.

[0085] The second sending unit 108 is used for sending an approval request to more than half of the receiving nodes if the main proposing node receives the commitment response sent by more than half of the receiving nodes. The approval request includes the proposal number N and the resolution of the highest proposal number M in the commitment response sent by the receiving node.

[0086] The third judgment unit 204 is used for the receiving node to judge whether the proposal number N of the approval request received by it is greater than the highest proposal number M of the proposals it has approved if the approval request is not the first approval request received.

[0087] The third returning unit 205 is used for sending an approval response to the main proposing node if the proposal number N of the approval request received by the receiving node is greater than the highest proposal number M of the proposals it has approved.

[0088] The fourth judgment unit 109 is used by the main proposal node to judge whether it has received approval responses sent by more than half of the receiving nodes.

[0089] The third determination unit 110 is used for the main proposal node to determine that the proposal in this round is successful if the main proposal node receives approval responses sent by more than half of the receiving nodes.

[0090] The fourth return unit 206 is used to send a rejection response to the main proposal node immediately if the proposal number N of the approval request received by the receiving node is not greater than the highest proposal number M of the proposals it has approved. The rejection response includes the resolution of the highest proposal number M approved by the receiving node.

[0091] The learning nodes in the blockchain network are divided into a plurality of learning node sets, and the system further comprises:

[0092] The selection unit 301 is used by the receiving node to select one of the learning node sets from the multiple learning node sets as the target learning node set.

[0093] The third sending unit 302 is used for the receiving node to send the successfully approved proposal as a successful proposal to the learning nodes in the target learning node set.

[0094] The learning unit 303 is used for the learning nodes in the target learning node set to learn the successful proposal, and forward the successful proposal to the remaining learning node sets in the multiple learning node sets so that the learning nodes in the remaining learning node sets learn the successful proposal.

[0095] The fifth return unit 207 is used for, if the preparation request is the first preparation request received, the receiving node returns a commitment response to the main proposal node, the commitment response includes a resolution arbitrarily selected by the receiving node or the commitment response is empty, and promises that no proposal with a proposal number less than the proposal number N will be approved.

[0096] It should be noted that technical personnel in the relevant field can clearly understand that the specific implementation process of the above-mentioned consensus mechanism optimization system 100 based on the Paxos algorithm and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and conciseness of the description, it will not be repeated here.

[0097] Each unit of the consensus mechanism optimization system based on the Paxos algorithm can be implemented in the form of a computer program. The computer program can be used in Fig.10 Runs on the computer device shown.

[0098] See also Fig.10 , Fig.10 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal or a server. The blockchain network includes a plurality of computer devices, each of which serves as a node in the blockchain network, and may specifically be a proposal node, an acceptance node, or a learning node.

[0099] See also Fig.10 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .

[0100] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, which, when executed, can enable the processor 502 to execute a consensus mechanism optimization method based on the Paxos algorithm.

[0101] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .

[0102] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When each computer program 5032 in the plurality of computer devices corresponding to the above-mentioned proposal node, acceptance node or learning node is executed by the corresponding processor 502, the corresponding processor 502 can jointly execute the above-mentioned consensus mechanism optimization method based on the Paxos algorithm.

[0103] The network interface 505 is used to communicate with other devices over the network. Fig.10 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0104] The processor 502 of the proposal node is used to run the computer program 5032 stored in the memory to implement the following steps: sending a preparation request carrying the proposal number N to all receiving nodes.

[0105] Among them, the processor 502 of the receiving node is used to run the computer program 5032 stored in the memory to implement the following steps: if the preparation request is not the first preparation request received, determine whether the received proposal number N is greater than the highest proposal number M of the proposals it has approved; if the received proposal number N is greater than the highest proposal number M of the proposals it has approved, the receiving node returns a commitment response to the main proposal node to inform it of the resolution of the highest proposal number M it has approved, and promises not to approve any proposal with a proposal number less than the proposal number N.

[0106] The processor 502 of the proposal node is used to run the computer program 5032 stored in the memory to implement the following steps: determine whether the commitment responses sent by more than half of the receiving nodes are received; if the current time reaches the proposal retransmission time, the main proposal node again sends a new round of preparation requests carrying a proposal number greater than N to all the receiving nodes.

[0107] In this embodiment, the processor 502 of the proposal node specifically implements the following steps when implementing the step of the main proposal node determining the proposal retransmission time according to preset rules: the main proposal node obtains the waiting time generated by a random mechanism; the main proposal node determines the time point for sending a new round of preparation requests to all the receiving nodes again as the proposal retransmission time based on the current time and the waiting time.

[0108] In this embodiment, after the processor 502 of the receiving node implements the step of returning a commitment response to the main proposal node to inform it of the resolution of the highest proposal number M that has been approved and promising not to approve any proposal with a proposal number less than the proposal number N, it also performs the following step: if a preparation request carrying a proposal number greater than the proposal number N is received from a new main proposal node, the receiving node immediately sends a rejection response to the main proposal node corresponding to the proposal number N.

[0109] In this embodiment, the steps executed by the processor 502 of the proposal node also include: if the main proposal node corresponding to the proposal number N receives the rejection response sent by the receiving node, the main proposal node stops sending approval requests to the receiving node that sent the rejection response.

[0110] In this embodiment, the steps executed by the processor 502 of the proposal node also include: if the commitment response is received from more than half of the receiving nodes, the main proposal node sends an approval request to more than half of the receiving nodes, and the approval request includes the proposal number N and the resolution of the highest proposal number M in the commitment response sent by the receiving node.

[0111] In this embodiment, the steps executed by the processor 502 of the receiving node also include: if the approval request is not the first approval request received, the receiving node determines whether the proposal number N of the approval request received by it is greater than the highest proposal number M of the proposals it has approved; if the proposal number N of the approval request received by the receiving node is greater than the highest proposal number M of the proposals it has approved, the receiving node sends an approval response to the main proposal node.

[0112] In this embodiment, the steps executed by the processor 502 of the proposal node also include: the main proposal node determines whether it has received approval responses sent by more than half of the receiving nodes; if the main proposal node receives approval responses sent by more than half of the receiving nodes, the main proposal node determines that this round of proposal is successful.

[0113] In this embodiment, the steps executed by the processor 502 of the receiving node also include: if the proposal number N of the approval request received by the receiving node is not greater than the highest proposal number M of the proposals it has approved, the receiving node immediately sends a rejection response to the main proposal node, and the rejection response includes the resolution of the highest proposal number M approved by the receiving node.

[0114] In this embodiment, the steps executed by the processor 502 of the receiving node also include: if the preparation request is the first preparation request received, the receiving node returns a commitment response to the main proposing node, the commitment response includes a resolution arbitrarily selected by the receiving node or the commitment response is empty, and promises that no proposal with a proposal number less than the proposal number N will be approved.

[0115] In this embodiment, the learning nodes in the blockchain network are divided into multiple learning node sets. The processor 502 of the learning node implements the learning node learning step including: the receiving node selects one of the learning node sets from the multiple learning node sets as the target learning node set; the receiving node sends the successfully approved proposal as a successful proposal to the learning node in the target learning node set; the learning node in the target learning node set learns the successful proposal, and forwards the successful proposal to the remaining learning node sets in the multiple learning node sets so that the learning nodes in the remaining learning node sets learn the successful proposal.

[0116] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0117] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.

[0118] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a plurality of computer programs, and the plurality of computer programs, when respectively executed by a plurality of processors, can jointly implement the various embodiments of the consensus mechanism optimization method based on the Paxos algorithm.

[0119] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.

[0120] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0121] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and 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.

[0122] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0123] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.

[0124] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A consensus mechanism optimization method based on the Paxos algorithm is applied to a blockchain network, wherein the blockchain network includes a proposal node, an acceptance node, and a learning node. It is characterized in that The method comprises: The main proposal node sends a preparation request carrying the proposal number N to all receiving nodes, wherein the main proposal node is the proposal node that currently initiates a proposal to the receiving node among the multiple proposal nodes; If the preparation request is not the first preparation request received, the receiving node determines whether the received proposal number N is greater than the highest proposal number M of the proposals it has approved; If the received proposal number N is greater than the highest proposal number M of the proposals it has approved, the accepting node returns a commitment response to the main proposal node to inform it of the resolution of the highest proposal number M it has approved, and promises not to approve any proposal with a proposal number less than the proposal number N; The main proposing node determines whether the commitment responses sent by more than half of the receiving nodes are received; If the commitment response sent by more than half of the receiving nodes is not received, the main proposal node determines the proposal retransmission time according to the preset rules; If the proposal resend time is reached, the main proposal node sends a new round of preparation requests and approval requests with proposal numbers greater than N to all the receiving nodes again; The step of the main proposal node determining the proposal resending time according to a preset rule includes: The main proposal node obtains the waiting time generated by a random mechanism; The main proposal node determines the time point for sending a new round of preparation requests to all the receiving nodes again according to the current time and the waiting time as the proposal retransmission time.

2. According to the consensus mechanism optimization method based on the Paxos algorithm according to claim 1, It is characterized in that After the step of the accepting node returning a commitment response to the main proposal node to inform it of the resolution of the highest proposal number M that it has approved and promising not to approve any proposal with a proposal number less than the proposal number N, the method further includes: If a preparation request with a proposal number greater than the proposal number N is received from a new main proposal node, the receiving node immediately sends a rejection response to the main proposal node corresponding to the proposal number N; If the main proposal node corresponding to the proposal number N receives the rejection response sent by the receiving node, the main proposal node stops sending approval requests to the receiving node that sent the rejection response.

3. According to the consensus mechanism optimization method based on the Paxos algorithm according to claim 1, It is characterized in that The method further comprises: If the commitment response is received from more than half of the receiving nodes, the main proposal node sends an approval request to more than half of the receiving nodes, where the approval request includes the proposal number N and the resolution of the highest proposal number M in the commitment response sent by the receiving node; If the approval request is not the first approval request received, the receiving node determines whether the proposal number N of the approval request received is greater than the highest proposal number M of the proposals it has approved; If the proposal number N of the approval request received by the receiving node is greater than the highest proposal number M of the proposals it has approved, the receiving node sends an approval response to the main proposal node; The main proposal node determines whether it has received approval responses sent by more than half of the receiving nodes; If the main proposal node receives approval responses from more than half of the receiving nodes, the main proposal node determines that this round of proposal is successful.

4. According to the consensus mechanism optimization method based on the Paxos algorithm according to claim 3, It is characterized in that The method further comprises: If the proposal number N of the approval request received by the accepting node is not greater than the highest proposal number M of the proposals it has approved, the accepting node immediately sends a rejection response to the main proposal node, and the rejection response includes the resolution of the highest proposal number M approved by the accepting node.

5. According to the consensus mechanism optimization method based on the Paxos algorithm according to claim 3, It is characterized in that The learning nodes in the blockchain network are divided into a plurality of learning node sets, and the method further comprises: The receiving node selects one of the learning node sets from the multiple learning node sets as the target learning node set; The accepting node sends the successfully approved proposal as a successful proposal to the learning nodes in the target learning node set; The learning nodes in the target learning node set learn the successful proposal, and forward the successful proposal to the remaining learning node sets in the multiple learning node sets so that the learning nodes in the remaining learning node sets learn the successful proposal.

6. According to the consensus mechanism optimization method based on the Paxos algorithm according to claim 1, It is characterized in that The method further comprises: If the preparation request is the first preparation request received, the receiving node returns a commitment response to the main proposal node, and the commitment response includes a resolution arbitrarily selected by the receiving node or the commitment response is empty, and promises that no proposal with a proposal number less than the proposal number N will be approved.

7. A consensus mechanism optimization system based on the Paxos algorithm, applied to a blockchain network, wherein the blockchain network includes a proposal node, an acceptance node, and a learning node. It is characterized in that The main proposal node in the proposal node is configured with a first sending unit, a second judgment unit, a determination unit and a re-proposing unit; the receiving node is configured with a first judgment unit and a return unit, wherein the main proposal node is a proposal node among the multiple proposal nodes that currently initiates a proposal to the receiving node; The first sending unit is used to send a preparation request carrying a proposal number N to all receiving nodes; The first judgment unit is used for judging whether the received proposal number N is greater than the highest proposal number M of the approved proposals if the preparation request is not the first preparation request received; The return unit is used to return a commitment response to the main proposal node to inform it of the resolution of the highest proposal number M approved, and to promise not to approve any proposal with a proposal number smaller than the proposal number N, if the received proposal number N is greater than the highest proposal number M of the proposals it has approved; The second judgment unit is used to judge whether the commitment response sent by more than half of the receiving nodes is received; The determination unit is used to determine the proposal retransmission time according to a preset rule if the commitment response sent by more than half of the receiving nodes is not received; The re-proposing unit is used to send a new round of preparation requests carrying a proposal number greater than N to all the receiving nodes again if the current time reaches the proposal re-sending time; The main proposal node is also configured with a waiting unit and a second determination unit; The waiting unit is used for the main proposal node to obtain the waiting time generated by the random mechanism; The second determination unit is used by the main proposal node to determine the time point for sending a new round of preparation requests to all the receiving nodes again as the proposal retransmission time according to the current time and the waiting time.

8. A blockchain network, comprising a plurality of nodes, the plurality of nodes comprising a proposal node, an acceptance node and a learning node, each of the nodes corresponding to a computer device, the computer device comprising a memory and a processor connected to the memory; the memory is used to store a computer program; It is characterized in that The processors corresponding to the multiple nodes are used to run the computer programs stored in the corresponding memories to jointly execute the steps of the method as claimed in any one of claims 1 to 6.

9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a plurality of computer programs, which, when respectively executed by a plurality of processors, can jointly implement the steps of the method according to any one of claims 1 to 6.