A cloud-native blockchain consensus method and system
By improving the node reputation scoring mechanism and the method of classifying and participating in the consensus, the problem of the master node being unable to receive messages during the cloud native blockchain consensus process is solved, the stability and reliability of the system are improved, and the risk of errors and communication overhead are reduced.
Patent Information
- Application Number
- CN202410930914.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-07-12
AI Technical Summary
In the cloud-native blockchain consensus process, the master node may not receive enough messages during the commit or prepare stages, causing the consensus process to stagnate or be restarted, affecting consensus efficiency.
By improving the reputation mechanism of node scoring, calculating the node's reputation value, making penalty corrections based on the number of transaction messages and response time in the message queue, classifying nodes to participate in the consensus process, ensuring that more trustworthy nodes participate in key steps, and reducing the number of small reputation values The participation of nodes thereby improves the security and reliability of the system.
It improves the stability and reliability of the consensus process, reduces the risk of errors or malicious behavior, reduces communication overhead, increases node throughput and reduces latency.
Smart Images

Figure CN118473640B
Abstract
Description
Technical Field
[0001] The present invention generally relates to the field of consensus algorithm technology. More specifically, the present invention relates to a cloud-native blockchain consensus method and system. Background Art
[0002] Blockchain is a decentralized distributed database technology. Compared with traditional centralized systems, blockchain technology not only solves the problems of security and single point of failure, but also improves transaction speed and transparency. Consensus algorithm is the core technology of blockchain, which solves the problems of trust and consistency and is the main factor determining the performance of blockchain system. At present, according to the type of blockchain, consensus algorithms can be divided into three categories: public chain consensus, private chain consensus and alliance chain consensus. Among them, public chain mainly uses proof of work (PoW), which has poor practicality; private chain mainly uses distributed consensus algorithm Raft to reach consensus; alliance chain mainly uses PBFT algorithm.
[0003] The PBFT algorithm is mainly used to solve the Byzantine Generals' Problem in distributed network systems. Due to network delays, message loss and other issues, inconsistent data information may occur between nodes. The PBFT algorithm enables each node to reach a consensus while ensuring the security and availability of the system.
[0004] In the PBFT consensus process, the prior art usually improves the consensus process through a reputation mechanism (also known as a "trust mechanism", "credit mechanism", etc.). For example, patent document CN112039964A discloses a node reputation consensus method based on blockchain. The patent document detects and evaluates the credibility of nodes, and adopts a corresponding reputation reduction penalty mechanism for consensus nodes with abnormal behavior to ensure that nodes do not do evil. In abnormal situations such as network problems, malicious nodes or faulty nodes will not respond to requests from other nodes. Therefore, when evaluating the reputation value of a node, the performance of the node is usually taken into account, such as the node's throughput and node latency.
[0005] However, before the consensus process of cloud-native blockchains, consumer clients usually need to receive transaction information through many message queues (transaction messages that need to be agreed upon are obtained from message queues), so the response time of the entire distributed system is also related to the performance of the message queue (for example, latency, message throughput, etc.). Furthermore, if there are a large number of messages that need to be agreed upon, the system load will increase, which may cause the system response to become slower. Because there are dependencies between nodes in a distributed system, the performance of the message queue will also affect the node latency.
[0006] There are some attempts in the existing technology to directly adopt the PBFT algorithm of the reputation mechanism in blockchain technology. It may happen that the master node cannot receive enough messages during commit or prepare, causing the consensus process to stagnate or restart, affecting the consensus efficiency. Summary of the invention
[0007] In order to solve the technical problem that the master node may not receive enough messages in the commit stage or prepare stage, so that the consensus process stagnates or restarts, affecting the consensus efficiency, the present invention proposes a cloud-native blockchain consensus method, which improves the reputation mechanism of node scoring to make the reputation value of each node more accurate. To this end, the present invention provides solutions in the following aspects.
[0008] In a first aspect, a cloud-native blockchain consensus method is provided, the method comprising: in response to a producer client generating transaction information, storing the transaction information in a message queue; transmitting the transaction information to a consumer client that has a subscription relationship with the producer; in response to the consumer client verifying the transaction information successfully, and i The node succeeded in the previous consensus and calculated the i The accumulated value of the node R i : , among which, the last consensus i The node's reputation value is V i ', a 1 , a 2 as well as a 3 are accumulation coefficients of preset sizes, and a 1 < a 2 < a 3 , m 1 and m 2 are all reputation value thresholds of preset size, and m 1 > m 2 , No. i Node is any node; according to i Node response time t i Calculating the timeout value O i : ,in, t 0is the response time threshold, b is the timeout factor of the preset size, S 0 is the total length of the message queue at the current moment, S 1 is the length of the transaction information occupied in the message queue at the current moment; i The node’s reputation in this consensus: ; Reach consensus on the transaction information based on the reputation value of each node.
[0009] The beneficial effects of the present invention are:
[0010] The present invention is based on the number of consensus transaction messages (occupied length S 1 ) and the number of all messages in the queue (total length S 0 ), the degree of penalty (i.e., reduction of reputation value) after a node timeout occurs is corrected. This avoids the situation where a normal node is punished as a faulty node or a malicious node after a timeout due to external influences (the number of messages received by the consumer client), and its reputation value does not accurately evaluate its credibility (the degree to which it may be a faulty node or a malicious node). The present invention improves the stability and reliability of the consensus process by increasing the accuracy of the node's reputation value, thereby better ensuring the stability and reliability of the blockchain system.
[0011] It should be noted that the greater the proportion of transaction messages that require consensus in all messages in the message queue, the greater the number of messages received by the consumer client per unit time, that is, the greater the number of messages that require consensus. At this time, the system load will increase, which may cause the system response to become slower.
[0012] The reason for the correction of the penalty level is: even if the node times out when the external influence is large (the number of messages received by the consumer client is large), it is undeniable that its performance is worse than other nodes that have not timed out, but it cannot be considered that it is likely to be a faulty node or a malicious node, so it is punished less, that is, the reduction in its reputation value is small. On the other hand, nodes that time out when the external influence is small (the number of messages received by the consumer client is small) are likely to be faulty nodes or malicious nodes that deliberately do not respond, so the reduction in their reputation value is large.
[0013] In one embodiment, the consensus on the transaction information based on the reputation value of each node includes: arranging all nodes in descending order according to the reputation value, and dividing them into first-class nodes, second-class nodes and third-class nodes, wherein the first The nodes are first-class nodes, to The nodes are the second type of nodes, to nodes are the third type of nodes, and the total number of nodes is n ,and n =3 f +1, f >1; consensus is reached on the transaction information based on the first type of nodes, the second type of nodes and the third type of nodes, wherein any node in the first type is the master node and the first type of nodes participates in the prepare phase, the first type of nodes and the second type of nodes participate in the commit phase, and the first type of nodes, the second type of nodes and the third type of nodes participate in the reply phase.
[0014] The effect is: by allowing more credible nodes to participate in the key consensus process, the security and reliability of the system are improved. At the same time, the number of nodes with lower reputation values participating in the consensus process is reduced, thereby reducing communication overhead, improving the throughput of each node and reducing the latency of each node. For nodes with lower reputation values, the number of nodes participating in the consensus is reduced, thereby reducing the risk of errors or malicious behavior. The reason is: nodes are classified according to their reputation values, so that nodes with higher reputation values participate in the prepare stage and verify the information broadcast by the master node, nodes with higher or medium reputation values participate in the commit stage, and all nodes participate in the reply node to store the consensus results.
[0015] In one embodiment, the consensus on the transaction information through the first-category nodes, the second-category nodes and the third-category nodes includes: determining any node in the first category as a master node, the master node packing the transaction information into blocks according to the received timing and verifying it to obtain a verification result; the master node broadcasts a pre-prepare message to all first-category nodes, wherein the pre-prepare message includes the block and the verification result; in response to any first-category node passing the message legitimacy verification of the pre-prepare message, broadcasting the prepare message to the master node, other first-category nodes and second-category nodes; in response to the number of the master node, the first-category nodes and the second-category nodes receiving the prepare message being greater than or equal to 4 f / 3+1, the master node, the first type of nodes and the second type of nodes all broadcast commit information to the master node, the first type of nodes, the second type of nodes and the third type of nodes; in response to the master node receiving the number of commit information greater than or equal to 5 f / 3+1, add the block to the end of the blockchain.
[0016] In one embodiment, the message legitimacy verification of the pre-prepare message by any of the first-type nodes includes: verifying whether the signature of the pre-prepare message is valid, verifying whether the format of the pre-prepare message is correct, and verifying whether the view number and sequence number of the proposed block included in the pre-prepare message are correct.
[0017] The effects are: by verifying whether the signature of the pre-prepare message is valid, the authenticity of the pre-prepare message can be ensured; by verifying whether the format of the pre-prepare message is correct, the compliance of the pre-prepare message to standards and specifications can be ensured; by verifying whether the view number and sequence number of the proposed block included in the pre-prepare message are correct, it can be ensured that the proposed block complies with consensus rules and conditions.
[0018] In one embodiment, in response to the number of the master node receiving the preparation completion message being less than 4 f / 3+1, replace the master node.
[0019] The effect is to avoid the situation where the master node is a faulty or malicious node, thereby affecting the consensus. The reason is: if the number of the master node receiving the preparation completion message is less than 4 f / 3+1, indicating that the master node did not correctly transmit the preparation completion message to all first-class nodes (there are 2 first-class nodes in total). f +1), at this time, it is judged that the master node may be a faulty or malicious node, so the master node is replaced.
[0020] In one embodiment, in response to the master node receiving the number of commit messages being less than 5 f / 3+1, do not add the block to the end of the blockchain.
[0021] In one embodiment, in response to the consumer client verifying the transaction information successfully, i The node failed to reach consensus in the last consensus. i The accumulated value of the node R : R =0.
[0022] The effect is that for nodes that have not reached a consensus, no reward will be given to the node after the consensus is completed, that is, the accumulated value R is 0. Based on this, most malicious nodes cannot get rewards (accumulated value) after multiple consensus attempts because the consensus is unsuccessful, making their reputation value lower than that of other normal nodes.
[0023] In one embodiment, a cloud-native blockchain consensus method further includes obtaining the total length of the message queue.S 0 and occupied length S 1 : Get the first number of all messages in the message queue, the first number is the total length S 0 ; Obtain the second number of transaction messages subscribed by the consumer client in the message queue, the second number being the occupied length S 1 .
[0024] In one embodiment, a cloud-native blockchain consensus method further includes calculating the timeout value according to the actual bandwidth and the total bandwidth of the message queue. O i : The maximum bandwidth of the message queue within a time window is determined as the total bandwidth B 0 ; Get the bandwidth of the message queue at the current moment, the bandwidth at the current moment is the actual bandwidth B 1 ; Calculate the timeout value O i : .
[0025] The effect is that if the actual bandwidth of the message queue is small at the current moment, it means that the network environment may be poor at this time. The number of transaction information processed by the message queue per unit time is small, so its response time is short. At this time, it is considered that the node is more likely to have its actual delay exceed the predetermined threshold, so the "penalty" of its reputation value is reduced, that is, the timeout value is increased. O i The absolute value of O i <0).
[0026] In a second aspect, a blockchain consensus system for cloud original sound includes: a processor configured to execute program instructions; a memory configured to store the program instructions, and when the program instructions are loaded and executed by the processor, the processor executes a blockchain consensus method for cloud original sound described in any one of the above-mentioned invention contents. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0028] Figure 1is a flowchart schematically illustrating a cloud-native blockchain consensus method according to an embodiment of the present invention;
[0029] Figure 2 is a flow chart schematically illustrating step S6 according to an embodiment of the present invention;
[0030] Figure 3 is a flowchart schematically illustrating step S602 according to an embodiment of the present invention;
[0031] Figure 4 is a consensus flow chart schematically illustrating an embodiment of the present invention;
[0032] Figure 5 It is a block diagram schematically showing a structure of a cloud-native blockchain consensus system according to this embodiment. DETAILED DESCRIPTION
[0033] 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0034] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0035] Figure 1 The present invention schematically illustrates a flowchart of the steps of a cloud-native blockchain consensus method according to an embodiment of the present invention.
[0036] like Figure 1 As shown, a cloud-native blockchain consensus method includes steps S1 to S6.
[0037] Step S1: In response to the producer client generating transaction information, the transaction information is stored in a message queue.
[0038] Among them, the message queue is a middleware that transmits messages between producers and consumers. It can decouple the communication between different components in the system and provide a reliable message transmission mechanism.
[0039] Step S2: Transmit the transaction information to the consumer client that has a subscription relationship with the producer.
[0040] The messaging mode between the consumer client and the producer client is the publish-subscribe mode. i sh-Subscr ibe Pattern, in which the sender (publisher) of a message publishes the message to a specific topic (or topic, channel, etc.), and the receiver (subscriber) of the message can subscribe to one or more topics to receive messages published to these topics. This pattern allows multiple consumers to receive the same message at the same time, realizing one-to-many message delivery.
[0041] Step S3: In response to the consumer client verifying the transaction information successfully, i The node succeeded in the previous consensus and calculated the i The accumulated value of the node R .
[0042] Among them, when , among which, the last consensus i The node's reputation value is V i ', a 1 , a 2 as well as a 3 are accumulation coefficients of preset sizes, and a 1 < a 2 < a 3 , m 1 and m 2 are all reputation value thresholds of preset size, and m 1 > m 2 , No. i A node is any node. The accumulation coefficients are all positive values, so the accumulation value is the reward value of the node after participating in and completing the consensus each time.
[0043] In one embodiment, the reputation value threshold m 1 =50, m 2 =70, the accumulation coefficient a 1 =5, a 2 =2, a 3 =1.
[0044] Step S4: According to i Node response time t i Calculating the timeout value Oi .
[0045] in, ,in, t 0 is the response time threshold, b is the timeout factor of the preset size, S 0 is the total length of the message queue at the current moment, S 1 It is the length of time that the transaction information occupies in the message queue at the current moment.
[0046] In one embodiment, the total length of the message queue is obtained. S 0 and occupied length S 1 : Get the first number of all messages in the message queue, the first number is the total length S 0 ; Obtain the second number of transaction messages subscribed by the consumer client in the message queue, the second number being the occupied length S 1 .
[0047] In one embodiment, the timeout value is calculated based on the actual bandwidth and the total bandwidth of the message queue. O i : The maximum bandwidth of the message queue within a time window is determined as the total bandwidth B 0 ; Get the bandwidth of the message queue at the current moment, the bandwidth at the current moment is the actual bandwidth B 1 ; Calculate the timeout value O i : .
[0048] It should be noted that if the actual bandwidth of the message queue is small at the current moment (largely different from the total bandwidth), this may mean that the network environment is poor (network packet loss, network delay and other bad environments) or hardware failure, resulting in a small number of transactions processed by the message queue per unit time. Due to the reduction in response time, the node may receive less reputation value "penalty" when the actual delay exceeds the predetermined threshold. Therefore, it is possible to consider increasing the timeout value to 0. i The absolute value of i <0).
[0049] Step S5: Calculate the i The node’s reputation in this consensus: .
[0050] Among them,i The reputation value of a node is composed of the reputation value of the node in the last consensus, the accumulated value R i and timeout value O i The reputation value in the last consensus indicates the performance and contribution of the node in the last consensus, which can be obtained by participating in consensus, verifying transactions, etc. R i A positive value indicates the performance and contribution of the node in the past multiple consensuses, which can be accumulated by continuously participating in consensus and obtaining rewards; the timeout value O i If it is a negative value, it means that the node is punished for failing to complete the consensus task in time. i If a node successfully completes the consensus task in the last consensus, i.e. the last confirmation stage, it will receive a reward and its reputation value will increase. i If a node fails to complete the consensus task in time during this consensus, it will be punished and its reputation value will be reduced. In this way, by rewarding and punishing the performance of nodes, the participation and contribution of nodes can be promoted, and the reliability and security of the entire blockchain system can be improved.
[0051] Step S6: reaching consensus on the transaction information based on the reputation value of each node.
[0052] In one embodiment, nodes with a reputation value less than a predetermined threshold are determined as suspicious nodes, and nodes with a reputation value greater than a predetermined threshold are determined as consensus nodes. Consensus is reached on transaction information through consensus nodes.
[0053] Figure 2 is a flow chart schematically illustrating step S6 according to an embodiment of the present invention.
[0054] like Figure 2 As shown, step S6 includes step S601 to step S602.
[0055] Step S601: Arrange all nodes in descending order of reputation value and divide them into first-category nodes, second-category nodes and third-category nodes.
[0056] Among them, The nodes are first-class nodes, to The nodes are the second type of nodes, to nodes are the third type of nodes, and the total number of nodes is n ,and n =3 f +1, f >1. Indicates 2 f +1 to round up, Indicates 2 f +2 to round up, Indicates 5 f / 2+1 to round up, Indicates 5 f / 2+2 is rounded up, Indicates 3 f +1 for rounding up.
[0057] Based on this, the reputation value of the first type of node is higher, and the probability of it being a faulty node or a malicious node is lower; the reputation value of the second type of node is slightly lower, and the probability of it being a faulty node or a malicious node is higher than that of the first type of node; the reputation value of the second type of node is lower, and the probability of it being a faulty node or a malicious node is higher than that of the first type of node; the reputation value of the second type of node is very low, and the probability of it being a faulty node or a malicious node is higher than that of the second type of node.
[0058] Step S602: consensus is reached on the transaction information based on the first type of nodes, the second type of nodes and the third type of nodes.
[0059] The first type of nodes participate in the prepare phase, the first type of nodes and the second type of nodes participate in the commit phase, and the first type of nodes, the second type of nodes and the third type of nodes participate in the reply phase.
[0060] Figure 3 is a flow chart schematically illustrating step S602 according to an embodiment of the present invention.
[0061] like Figure 3 As shown, step S602 includes steps S6021 to S6025.
[0062] Step S6021: Determine any node in the first category as a master node, and the master node packages the transaction information into blocks according to the received sequence and verifies it to obtain a verification result.
[0063] Among them, a block includes transaction information of multiple transactions, which are packaged and combined into a block according to the timing when the transaction information arrives at the master node.
[0064] Furthermore, the method of determining the master node can be round-robin or random selection. in): The master node is selected in turn according to a predefined order. Each node becomes the master node in a certain order, ensuring that each node has the opportunity to participate in the consensus process. Random selection: The system randomly selects a node as the master node. This method can reduce the potential risk of attacks because the attacker cannot know in advance which node will be the next master node.
[0065] Step S6022: The master node broadcasts a pre-prepare message to all first-category nodes, wherein the pre-prepare message includes the block and the verification result.
[0066] It should be noted that after the master node verifies the transaction, it will get a verification result. This result includes the verification status of each transaction: whether each transaction is valid, complete and consistent.
[0067] Step S6023: In response to any of the first-type nodes passing the message legitimacy verification of the pre-prepare message, broadcasting the prepare message to the main node, other first-type nodes and second-type nodes.
[0068] Among them, this stage is: pre-prepare stage. The message legitimacy verification of the pre-prepare message by any of the first-type nodes includes: verifying whether the signature of the pre-prepare message (i.e., the pre-prepare package) is valid, verifying whether the format of the pre-prepare message is correct, and verifying whether the view number and sequence number of the proposed block included in the pre-prepare message are correct. Based on this, in response to the first-type node passing the message legitimacy verification of the pre-prepare message, it packages the signature, transaction information, and verification results into the prepare message, and then broadcasts the prepare message to the master node, other first-type nodes, and second-type nodes.
[0069] Step S6024: In response to the number of prepare messages received by the master node, the first type of node, and the second type of node being greater than or equal to 4 f / 3+1, the master node, the first type of nodes, and the second type of nodes broadcast commit information to the master node, the first type of nodes, the second type of nodes, and the third type of nodes.
[0070] This phase is the prepare phase. The number of the first type of nodes (including the master node) is 2 f +1, there are 2 nodes that receive and verify the legitimacy of the pre-prepare message f +1, at this time the number of failed nodes and malicious nodes that can be tolerated does not exceed 2 f / 3, at this time, if the number of the master node, the master node, the first type of node and the second type of node receiving the prepare message is greater than or equal to 4 f / 3+1, and the verification of the prepare message is passed, the corresponding node will generate commit information and broadcast the commit information to all nodes.
[0071] In another embodiment, in response to the master node receiving the number of the preparation completion messages being less than 4 f / 3+1, replace the master node. The reason is: when the number of preparation completion messages received by the master node is less than 4f / 3+1, there may be malicious nodes or faulty nodes in the network that cause the consensus to be unable to continue. In order to ensure the normal progress of the consensus, the master node can be replaced and the consensus can be re-conducted.
[0072] Step S6025: In response to the master node receiving the number of commit messages greater than or equal to 5 f / 3+1, add the block to the end of the blockchain.
[0073] Furthermore, in response to the master node receiving the number of commit messages being less than 2 f +1, do not add the block to the end of the blockchain.
[0074] In another embodiment, in response to any one of the number of received commit messages being greater than or equal to 5 f / 3+1, send a request to the consumer client to add the block to the end of the blockchain, in response to the number of requests received by the client being greater than or equal to 2 f +1, adding the block to the end of the blockchain.
[0075] Figure 4 FIG. 4 is a flowchart schematically illustrating a consensus process according to an embodiment of the present invention.
[0076] like Figure 4 As shown, the master node is selected from the first type of nodes, and the remaining first type of nodes participate in the two stages of the consensus, the pre-prepare stage and the prepare stage. After entering the commit stage, the second type of nodes begin to participate in the consensus. After the prepare message is broadcast to the first type of nodes and the second type of nodes, the nodes verify the legitimacy of the message and broadcast the commit message to the entire network. The third type of nodes do not participate in the core consensus process, but only participate in the reply stage. After receiving the commit message, they store the message in the local node and reply to the client. At the same time, since the second type of nodes only participate in the consensus in the commit stage, the third type of nodes only participate in the reply stage and do not participate in the three core stages of the consensus, the number of communications will be reduced, thereby reducing communication overhead.
[0077] Figure 5 It is a block diagram schematically showing a structure of a cloud-native blockchain consensus system according to this embodiment.
[0078] The present invention also provides a cloud-native blockchain consensus method. Figure 5 As shown, the system includes a processor and a memory, the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a cloud-native blockchain consensus method according to the first aspect of the present invention is implemented.
[0079] The system also includes other components familiar to those skilled in the art, such as a communication bus and a communication interface, whose configuration and functions are known in the art and thus will not be described in detail here.
[0080] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program, which may be used by or in conjunction with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium may be any suitable magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory (RRAM). i st i ve RandomAccess Memory、Dynamic Random Access Memory DRAM(Dynam i c Random Access Memory), Static Random Access Memory SRAM (Stat i c Random-Access Memory), Enhanced Dynamic Random Access Memory EDRAM (Enhanced Dynamic Random Access Memory i c Random Access Memory), High Bandwidth Memory HBM (H i gh-Bandw i dth Memory), Hybrid Memory Cube HMC (Hybr i d Memory Cube) and the like, or any other medium that can be used to store the required information and can be accessed by the application, module, or both. Any such computer storage medium can be part of the device or accessible or connectable to the device. Any application or module described in the present invention can be implemented using computer-readable / executable instructions that can be stored or otherwise maintained by such a computer-readable medium.
[0081] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0082] Although this specification has shown and described multiple embodiments of the present invention, it is obvious to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will think of many changes, modifications and alternatives without departing from the idea and spirit of the present invention.
Claims
1. A blockchain consensus method for cloud native, It is characterized in that include: In response to the producer client generating transaction information, storing the transaction information in a message queue; Transmit transaction information to the client of the consumer that has a subscription relationship with the producer; In response to the consumer client verifying the transaction information successfully, i The node succeeded in the previous consensus and calculated the i The accumulated value of the node R i : , among which, the last consensus i The node's reputation value is V i ', a 1 , a 2 as well as a 3 are accumulation coefficients of preset sizes, and a 1 < a 2 < a 3 , m 1 and m 2 are all reputation value thresholds of preset size, and m 1 > m 2 , No. i Node is any node; According to i Node response time t i Calculating the timeout value O i : ,in, t 0 is the response time threshold, b is the timeout factor of the preset size, S 0 is the total length of the message queue at the current moment, S 1 The length of time that the transaction information currently occupies in the message queue; Calculate the i The node’s reputation in this consensus: ; The transaction information is consensus-based according to the reputation value of each node.
2. According to the cloud-native blockchain consensus method of claim 1, It is characterized in that The consensus on the transaction information according to the reputation value of each node includes: Arrange all nodes in descending order of reputation value and divide them into first-class nodes, second-class nodes and third-class nodes. The nodes are first-class nodes, to The nodes are the second type of nodes, to nodes are the third type of nodes, and the total number of nodes is n ,and n =3 f +1, f >1; The transaction information is consensused according to the first type of nodes, the second type of nodes and the third type of nodes, wherein any node in the first type is the master node and the first type of node participates in the prepare phase, the first type of node and the second type of node participate in the commit phase, and the first type of node, the second type of node and the third type of node participate in the reply phase.
3. According to the cloud-native blockchain consensus method of claim 2, It is characterized in that The consensus on the transaction information by the first type of nodes, the second type of nodes and the third type of nodes includes: Determine any node in the first category as a master node, and the master node packages the transaction information into blocks according to the received time sequence and verifies the blocks to obtain a verification result; The master node broadcasts a pre-prepare message to all first-type nodes, wherein the pre-prepare message includes the block and the verification result; In response to any of the first-type nodes passing the message legitimacy verification of the pre-prepare message, broadcasting the prepare message to the master node, other first-type nodes, and second-type nodes; In response to the number of the master node, the first type of node and the second type of node receiving the prepare message being greater than or equal to 4 f / 3+1, the master node, the first type of nodes, and the second type of nodes all broadcast commit information to the master node, the first type of nodes, the second type of nodes, and the third type of nodes; In response to the master node receiving the number of commit messages greater than or equal to 5 f / 3+1, add the block to the end of the blockchain.
4. According to the cloud-native blockchain consensus method of claim 3, It is characterized in that The message legitimacy verification of the pre-prepare message by any of the first-type nodes includes: verifying whether the signature of the pre-prepare message is valid, verifying whether the format of the pre-prepare message is correct, and verifying whether the view number and sequence number of the proposed block included in the pre-prepare message are correct.
5. According to the cloud-native blockchain consensus method of claim 3, It is characterized in that In response to the master node receiving the number of the preparation completion messages being less than 4 f / 3+1, replace the master node.
6. According to the cloud-native blockchain consensus method of claim 3, It is characterized in that In response to the master node receiving less than 5 commit messages, f / 3+1, do not add the block to the end of the blockchain.
7. According to the cloud-native blockchain consensus method of claim 1, It is characterized in that In response to the consumer client verifying the transaction information successfully, i The node failed to reach consensus in the last consensus. i The accumulated value of the node R : R =0.
8. According to the cloud-native blockchain consensus method of claim 1, It is characterized in that Also includes obtaining the total length of the message queue S 0 and occupied length S 1 : Get the first number of all messages in the message queue, the first number being the total length S 0 ; Obtain the second number of transaction messages subscribed by the consumer client in the message queue, where the second number is the occupied length S 1 .
9. According to the cloud-native blockchain consensus method of claim 1, It is characterized in that The timeout value is calculated based on the actual bandwidth and total bandwidth of the message queue. O i : The maximum value of the bandwidth of the message queue within a time window is determined as the total bandwidth B 0 ; Get the current bandwidth of the message queue, where the current bandwidth is the actual bandwidth B 1 ; Calculate the timeout value O i : .
10. A blockchain consensus system for cloud native sound, It is characterized in that include a processor configured to execute program instructions; A memory configured to store the program instructions, which, when loaded and executed by the processor, enables the processor to execute a cloud-native blockchain consensus method according to any one of claims 1 to 9.
