Improved PBFT method and terminal

By updating the node reputation value and selecting the master node in the PBFT consensus algorithm, combining the storage of transaction information and the block construction mechanism, the problems of large bandwidth consumption of the PBFT algorithm and vulnerability to main nodes are solved, and the effect of improving blockchain throughput and enhancing system stability is achieved.

CN119583565AActive Publication Date: 2025-03-07福建福链科技有限公司

Patent Information

Application Number
CN202411814948.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-03-07
Estimated Expiration
2044-12-11

AI Technical Summary

Technical Problem

When the number of nodes increases, the PBFT consensus algorithm consumes a lot of bandwidth and blocks occupy a lot of space, which limits the throughput of the blockchain, and the main node is vulnerable to malicious attacks, increasing the instability of the system.

Method used

The first PBFT consensus algorithm is used to update the initial reputation value of each node, select the master node, and the master node and the consensus node receive the transaction information sent by the client, and store it in the node memory pool to reduce the bandwidth consumption of the master node. Through the mechanism of receiving notifications and transaction confirmation messages in transactions, the master node constructs candidate blocks and broadcasts them, and uses the second PBFT consensus algorithm to perform consensus, increasing the transparency and traceability of the transaction process.

Benefits of technology

It effectively improves block throughput, reduces the possibility and predictability of the master node, thereby reducing the probability of view switching, and ensuring the data consistency and integrity of the consensus node.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119583565A_ABST
    Figure CN119583565A_ABST
Patent Text Reader

Abstract

The invention discloses an improved PBFT consensus method and terminal, and the method comprises the steps: updating an initial reputation value of a node through a first PBFT consensus algorithm, and selecting a main node; the main node and the consensus node receive transaction information sent by the client and store the transaction information to node memory pools corresponding to the nodes respectively; the consensus node sends a transaction receiving notification to the main node, the main node sends a transaction confirmation message to the consensus node, and if the consensus node does not receive the transaction confirmation message, a transaction confirmation information obtaining request is sent to the main node; otherwise, judging whether transaction information corresponding to the transaction confirmation message exists in a node memory pool of the main node according to the transaction confirmation message, if not, broadcasting a transaction request to the node containing the transaction information to obtain the transaction information, constructing a candidate block by the main node, putting the transaction hash into the candidate block, and sending the transaction hash to the main node; and the broadcast candidate block is consensus through a second PBFT consensus algorithm, so that the bandwidth consumption of the main node is reduced, the block throughput is improved, and the disability possibility of the main node is reduced.
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 an improved PBFT consensus method and terminal. Background Art

[0002] The consensus mechanism is one of the core technologies in the blockchain, which ensures the consistency of data in the network. The blockchain technology allows participants to reach a consensus through the consensus mechanism, replacing the reliance on centralized entities in traditional methods. The PBFT (Practical Byzantine Fault Tolerance) algorithm is one of the consensus algorithms. Its key feature is that as long as the number of malicious nodes does not exceed one-third of the total number of consensus nodes, the consistency of node data can be guaranteed. However, it has certain limitations. In PBFT, the client sends the message to the master node, the master node packages the message into blocks, and broadcasts it to other consensus nodes, which will consume the bandwidth resources of the master node, especially when the number of nodes is large. As the number of nodes increases, the required bandwidth also increases. In addition, the original message is included in the block, resulting in a large block space, thereby limiting the number of transactions contained in the block, which in turn affects the throughput of the blockchain. In addition, the selection of the master node through the sequential selection mechanism may lead to malicious attacks on the master node or the selection of malicious nodes as the master node, which increases the probability of view switching and increases the instability of the system. Therefore, an improved PBFT consensus method and terminal that can solve the above problems is urgently needed. Summary of the invention

[0003] The technical problem to be solved by the present invention is to provide an improved PBFT consensus method and terminal, which can reduce the bandwidth consumption of the master node for sending messages, effectively improve the block throughput, and reduce the possibility and predictability of malicious behavior of the master node, thereby reducing the probability of view switching.

[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is: An improved PBFT consensus method includes the following steps: S1. Use the first PBFT consensus algorithm to update the initial reputation value of each node and select the master node; S2. The master node and all consensus nodes participating in the consensus process receive the transaction information sent by the client, and store the transaction information in the node memory pool corresponding to each node; S3. The consensus node sends a transaction reception notification to the master node, and the transaction reception notification includes a transaction hash. When the master node receives a first preset number of transaction reception notifications, the master node sends a transaction confirmation message to the consensus node. If the consensus node does not receive the transaction confirmation message, it sends a request to obtain transaction confirmation information to the master node. Otherwise, it determines whether the transaction information corresponding to the transaction confirmation message exists in its own node memory pool according to the transaction confirmation message. If not, it broadcasts a transaction request to the node containing the transaction information to obtain the transaction information. The master node constructs a candidate block and puts the transaction hash into the candidate block. The master node broadcasts the candidate block and adopts the second PBFT consensus algorithm for consensus.

[0005] In order to solve the above technical problems, another technical solution adopted by the present invention is: An improved PBFT consensus terminal includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, each step of the above-mentioned improved PBFT consensus method is implemented.

[0006] The beneficial effects of the present invention are as follows: an improved PBFT consensus method and terminal provided by the present invention, by adopting a first PBFT consensus algorithm to update the initial reputation value of each node, select a master node, and ensure that the nodes in the candidate master node set are honest nodes; the master node and all consensus nodes participating in the consensus process receive the transaction information sent by the client, and store the transaction information in the node memory pool corresponding to each node, avoiding dependence on the central node, reducing the bandwidth consumption of the master node sending messages in the subsequent consensus process, and effectively improving the block throughput; the consensus node sends a transaction reception notification to the master node, when the master node receives a first preset number of transaction reception notifications, the master node sends a transaction confirmation message to the consensus node, the transaction reception notification includes a transaction hash, the candidate block is constructed by the master node, the transaction hash is placed in the candidate block, the master node broadcasts the candidate block and adopts the second PBFT consensus algorithm for consensus, thereby increasing the transparency and traceability of the transaction process, performing corresponding processing according to the transaction confirmation information received by the consensus node and the data in the node memory pool, providing integrity protection, and ensuring the data consistency of the consensus node. BRIEF DESCRIPTION OF THE DRAWINGS

[0007] Figure 1 This is a flow chart of an improved PBFT consensus method according to an embodiment of the present invention; Figure 2 This is a schematic diagram of an improved PBFT consensus terminal according to an embodiment of the present invention; Figure 3This is a consensus phase flow chart of an improved PBFT consensus method according to an embodiment of the present invention; Description of labels: 1. An improved PBFT consensus terminal; 2. Memory; 3. Processor. DETAILED DESCRIPTION

[0008] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.

[0009] Please refer to Figure 1 , the embodiment of the present invention provides an improved PBFT consensus method, comprising the steps of: S1. Use the first PBFT consensus algorithm to update the initial reputation value of each node and select the master node; S2. The master node and all consensus nodes participating in the consensus process receive the transaction information sent by the client, and store the transaction information in the node memory pool corresponding to each node; S3. The consensus node sends a transaction reception notification to the master node, and the transaction reception notification includes a transaction hash. When the master node receives a first preset number of transaction reception notifications, the master node sends a transaction confirmation message to the consensus node. If the consensus node does not receive the transaction confirmation message, it sends a request to obtain transaction confirmation information to the master node. Otherwise, it determines whether the transaction information corresponding to the transaction confirmation message exists in its own node memory pool according to the transaction confirmation message. If not, it broadcasts a transaction request to the node containing the transaction information to obtain the transaction information. The master node constructs a candidate block and puts the transaction hash into the candidate block. The master node broadcasts the candidate block and adopts the second PBFT consensus algorithm for consensus.

[0010] From the above description, it can be seen that the beneficial effects of the present invention are: by adopting the first PBFT consensus algorithm to update the initial reputation value of each node, the master node is selected to ensure that the nodes in the candidate master node set are honest nodes; the master node and all consensus nodes participating in the consensus process receive the transaction information sent by the client, and store the transaction information in the node memory pool corresponding to each node, avoiding dependence on the central node, reducing the bandwidth consumption of the master node sending messages in the subsequent consensus process, and effectively improving the block throughput; the consensus node sends a transaction reception notification to the master node, and when the master node receives the first preset number of transaction reception notifications, the master node sends a transaction confirmation message to the consensus node, the transaction reception notification includes a transaction hash, the master node builds a candidate block, puts the transaction hash into the candidate block, and the master node broadcasts the candidate block using the second PBFT consensus algorithm for consensus, thereby increasing the transparency and traceability of the transaction process, and performing corresponding processing according to the transaction confirmation information received by the consensus node and the data in the node memory pool, providing integrity protection, and ensuring the data consistency of the consensus node.

[0011] Furthermore, the step S1 specifically includes: Assign an initial reputation value to each node, use the first PBFT consensus algorithm to perform a preset round of consensus, and calculate and update the initial reputation value of each node after each round of consensus according to the reputation evaluation mechanism; A set of candidate master nodes is obtained according to the reputation value of each node, and a master node is selected from the set of candidate master nodes using a random number node selection mechanism.

[0012] From the above description, it can be seen that by adopting the first PBFT consensus algorithm to perform preset rounds of consensus, the reputation value of each node is calculated and updated after each round of consensus according to the reputation evaluation mechanism, and a set of candidate master nodes is obtained according to the reputation value of each node, so as to ensure that the nodes in the candidate master node set are honest nodes, and a random number node selection mechanism is used to select the master node from the candidate master node set to avoid the possibility and predictability of malicious behavior of the master node, thereby reducing the probability of view switching.

[0013] Furthermore, the selecting a master node from the set of candidate master nodes using a random number node selection mechanism includes: The nodes in the candidate master node set are sorted based on the public keys to obtain a node sorting array, and a random number is generated by a trusted third party. The trusted third party performs a hash operation on the random number to obtain a first hash value, and broadcasts the first hash value to all candidate master nodes in the candidate master node set; When the candidate master node receives the first hash value, it queries the public key of the node in the middle position in the node sorting array, calculates the second hash value based on the first hash value and the public key, and performs a modulus operation on the second hash value to obtain the node value, and takes the corresponding node in the node sorting array whose sequence number is consistent with the node value as the master node.

[0014] From the above description, it can be seen that by sorting the nodes in the candidate master node set based on the public key, it is ensured that each node has an equal chance to become the master node, and a random number is generated by a trusted third party, and the random number is hashed to obtain a first hash value. The second hash value is calculated by combining the first hash value and the public key of the middle position node, and the corresponding node in the node sorting array whose serial number is consistent with the node value is used as the master node, avoiding the predictability of the master node, while also ensuring the uniqueness of the master node.

[0015] Furthermore, the step S3 includes: The master node sends a pre-prepare message to the consensus nodes participating in the consensus process. If a consensus node receives the pre-prepare message, it checks the transaction information in the corresponding node memory pool and verifies the pre-prepare message. If the verification is successful, it broadcasts the pre-prepare message to other consensus nodes. If a consensus node receives a first preset number of prepare messages, the prepare message is verified, and if the verification passes, a submission message is broadcast to other consensus nodes; If a consensus node receives the submission message, it verifies the submission message, and when a first preset number of correct submission messages are received, it broadcasts a reply message to the client; When the client receives reply messages sent by the second preset number of consensus nodes, the round of consensus is completed.

[0016] From the above description, it can be seen that through the exchange of pre-prepared messages, prepared messages and submitted messages by the master node and multiple consensus nodes participating in the consensus process, as well as message verification at each stage of the consensus process, an efficient and secure consensus process is achieved, the fault tolerance and scalability of the system are improved, and the consistency and integrity of the data of each node in the blockchain are ensured.

[0017] Furthermore, the step S3 further includes: If the master node does not have any errors, the consensus round is completed, the node updates its reputation value, and enters the next consensus round; If an error occurs in the master node, the master node is reselected based on a random selection mechanism and consensus is re-performed until no error occurs in the master node.

[0018] From the above description, it can be seen that by detecting errors in the master node, quickly responding to the failure of the master node, providing a fault repair method, and reselecting the master node for consensus, the overall fault tolerance is improved, ensuring that the consensus process can be executed stably, thereby ensuring the data consistency of all nodes.

[0019] Please refer to Figure 2 Another embodiment of the present invention provides an improved PBFT consensus terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements each step of the above-mentioned improved PBFT consensus method when executing the computer program.

[0020] The improved PBFT consensus method and terminal of the present invention are suitable for consensus in blockchain, which can effectively improve block throughput and reduce the possibility and predictability of malicious behavior of the master node, and are described in detail below through specific implementation methods: Please refer to Figure 1 , Embodiment 1 of the present invention is: an improved PBFT consensus method, comprising the steps of: S1. Use the first PBFT consensus algorithm to update the initial reputation value of each node and select the master node.

[0021] In this embodiment, the first PBFT consensus algorithm is used to update the initial reputation value of each node, select the master node, ensure that the nodes in the candidate master node set are honest nodes, reduce the possibility of the master node doing evil, and thus reduce the probability of view switching.

[0022] Furthermore, in this embodiment, the step S1 specifically includes: assigning an initial reputation value to each node, using the first PBFT consensus algorithm to perform a preset round of consensus, and calculating and updating the initial reputation value of each node after each round of consensus according to the reputation evaluation mechanism; obtaining a set of candidate master nodes according to the reputation value of each node, and selecting a master node from the set of candidate master nodes using a random number node selection mechanism, further ensuring that the nodes in the set of candidate master nodes are honest nodes, while also avoiding the possibility and predictability of malicious behavior of the master nodes.

[0023] Further, in this embodiment, the reputation value of each node is calculated and updated according to the reputation evaluation mechanism after each round of consensus, specifically: different reputation formulas are selected based on the node status to calculate the node reputation value, including: if the node has no malicious behavior during the consensus process, correctly broadcasts and verifies the message, that is, the node is an honest node, then the overall reputation value of the node is calculated based on the node voting enthusiasm, node transaction timeliness, and node historical performance; if the node has malicious behavior during the consensus process, tampers with the message, etc., that is, the node is a malicious node, then the reputation value is reduced and it is permanently prohibited to enter the candidate master node set. By reducing the reputation value of the malicious node and increasing the reputation value of the honest node, because the system can only tolerate no more than one-third of the total consensus node data, after multiple rounds of consensus, the reputation mechanism can further ensure that the nodes in the candidate master node set are honest nodes, wherein the reputation value calculation formula of the honest node is: , , ,in, Score the node's enthusiasm, Score the timeliness of node transactions, are influencing factors, representing the weight of the node's enthusiasm score and the node's transaction timeliness score in the node's reputation value. ; The number of nodes voting in the preparation phase. The number of nodes voting for the submission phase, The total number of votes required by nodes in the preparation phase is: The total number of votes that nodes need to submit in the submission phase. are influencing factors, representing the weights of the number of node votes in the preparation phase and the number of node votes in the submission phase in the node enthusiasm score, ; is the response time of node i in the consensus. The response time is preferably the sum of the time from receiving the first transaction message to sending the next stage message in the preparation stage and the submission stage. If the node is offline or the response time exceeds a certain threshold, the node transaction timeliness score is 0. The reputation value calculation formula of the malicious node is: ,in, .

[0024] Further, in this embodiment, the selection of a master node from the candidate master node set using a random number node selection mechanism includes: sorting the nodes in the candidate master node set based on public keys to obtain a node sorting array, and generating a random number by a trusted third party, the trusted third party performing a hash operation on the random number to obtain a first hash value, and broadcasting the first hash value to all candidate master nodes in the candidate master node set; when the candidate master node receives the first hash value, querying the public key of a node located in the middle position in the node sorting array, calculating a second hash value based on the first hash value and the public key, performing a modulus operation on the second hash value to obtain a node value, and taking the corresponding node in the node sorting array whose sequence number is consistent with the node value as the master node. The specific selection process is as follows: 1. Sort the candidate master nodes based on the public key to get the node sorting array [a1, a2, ..., a k ], k is the total number of candidate master nodes; 2. The trusted third party generates a random number Randnum, which is known only to the trusted third party. The trusted third party performs a hash operation on the random number, i.e. H1=hash(Randnum), obtains the first hash value H1, and broadcasts it to all candidate master nodes; 3. After receiving H1, the candidate master node queries the public key of the node in the middle position in the node sorting array and calculates the second hash value. The calculation formula is: H=hash(H1||pk), where pk is the public key of the consensus node (if the number of nodes is even, the node on the left in the middle is selected); 4. Perform a modulus operation on the second hash value to obtain a node value P2 = H mod k, and take the corresponding node in the node sorting array whose sequence number is consistent with the node value as the main node.

[0025] By sorting the nodes in the candidate master node set based on the public key, it is ensured that each node has an equal chance to become the master node, and a random number is generated by a trusted third party, and the random number is hashed to obtain a first hash value. The second hash value is calculated by combining the first hash value and the public key of the intermediate node, and the corresponding node whose sequence number in the node sorting array is consistent with the node value is used as the master node. The cryptographic characteristics of the hash function are used to ensure the randomness and confidentiality of the master node selection process. At the same time, a trusted third party is used to coordinate some key steps, so that before the master node is selected, the malicious node cannot predict the final result of the master node selection, avoiding the predictability of the master node and ensuring the security of the master node.

[0026] S2. The master node and all consensus nodes participating in the consensus process receive the transaction information sent by the client, and store the transaction information in the node memory pool corresponding to each node.

[0027] In this embodiment, the client sends a message request to the master node and the consensus node. The message request is , where request is the request, o is the client operation, t is the timestamp, and c is the client identifier. For client signing, the master node and consensus node receive transaction information and store the transaction information in the node memory pool corresponding to each node, avoiding dependence on the central node, reducing the bandwidth consumption of the master node sending messages in the subsequent consensus process, and effectively improving the block throughput.

[0028] S3. The consensus node sends a transaction reception notification to the master node, and the transaction reception notification includes a transaction hash. When the master node receives a first preset number of transaction reception notifications, the master node sends a transaction confirmation message to the consensus node. If the consensus node does not receive the transaction confirmation message, it sends a request to obtain transaction confirmation information to the master node. Otherwise, it determines whether the transaction information corresponding to the transaction confirmation message exists in its own node memory pool according to the transaction confirmation message. If not, it broadcasts a transaction request to the node containing the transaction information to obtain the transaction information. The master node constructs a candidate block and puts the transaction hash into the candidate block. The master node broadcasts the candidate block and adopts the second PBFT consensus algorithm for consensus.

[0029] In this embodiment, the consensus node sends a transaction receipt notification to the master node, and the master node receives the transaction receipt notification and verifies it. The transaction receipt notification is , where id is the consensus node number, m is the transaction information initiated by the client, hash(m) is the hash value of the transaction collected by the node, and c is the client identifier. The master node signs the transaction receipt notification sent by the consensus node to ensure that the master node can obtain the information of all relevant transactions in a timely manner. The master node verifies the transaction receipt notification to ensure the legitimacy and validity of the transaction. If the master node receives the first preset number of transaction receipt notifications, the master node aggregates the received transaction receipt notifications to obtain an aggregate signature, sends the aggregate signature, participant list and transaction confirmation information to the consensus node, and puts the transaction hash into the candidate block. The first preset number is preferably 2f+1 (f is the number of malicious consensus nodes). The transaction confirmation message sent by the master node to the consensus node is , where confirm means transaction confirmation, hash(m) is the hash value of the transaction collected by the node, c is the client identifier, and number is the position number corresponding to the transaction hash placed in the candidate block in order. Sign for the master node, and the master node aggregates the signatures of the nodes that receive notifications of the broadcast transaction. The master node only broadcasts the transaction hash for consensus; if there is a consensus node that has not received the transaction confirmation information, the consensus node sends a request to obtain the transaction confirmation information to the master node, that is, number and the previous transaction confirmation message are not increasing in sequence, and the consensus node will determine the number of missing transaction confirmation information based on the difference in number, and then initiate a request to the master node to broadcast the missing transaction confirmation information; if there is a consensus node that receives the transaction confirmation information and the transaction hash corresponding to the transaction confirmation information is not included in the node memory pool of the consensus node, then the transaction request is broadcast to the node containing the transaction information to obtain the transaction information, and corresponding processing is performed according to the situation of the consensus node receiving the transaction confirmation information and the data situation of the node memory pool, to provide integrity protection and ensure the data consistency of the consensus node.

[0030] Further, in this embodiment, step S3 includes: the master node sends a pre-prepare message to the consensus nodes participating in the consensus process. If there is a consensus node that receives the pre-prepare message, the transaction information in the corresponding node memory pool is checked, and the pre-prepare message is verified, including whether the master node signature is correct, whether the block summary is correct, whether there are duplicate view messages, whether the block transaction hash is correct, etc. If the verification is successful, the prepare message is broadcast to other consensus nodes; if there is a consensus node that receives a first preset number of prepare messages, the prepare message is verified, and if the verification is successful, a commit message is broadcast to other consensus nodes; if there is a consensus node that receives the commit message, the commit message is verified, and when the first preset number of correct commit messages is received, a reply message is broadcast to the client; when the client receives a reply message sent by a second preset number of consensus nodes, the round of consensus is completed, wherein the first preset number is preferably 2f+1 and the second preset number is preferably f+1, and the pre-prepare message is , the preparation message is , the commit message is , the reply message is , where f is the number of malicious consensus nodes, pre-prepare is the pre-prepare message identifier, prepare is the prepare message identifier, commit is the commit message identifier, reply is the reply message identifier, v is the current view of the message being sent, n is the sequence number assigned by the master node for the request, and num is the total number of transactions contained in the block. is the block information, is the block hash value, It is the signature of the master node, i is the consensus node number, and the master node and multiple consensus nodes participating in the consensus process exchange pre-prepared messages, prepared messages and submitted messages, as well as message verification at each stage of the consensus process to achieve an efficient and secure consensus process, improve the system's fault tolerance and scalability, and ensure the consistency and integrity of the data of each node in the blockchain.

[0031] Furthermore, in this embodiment, there is a situation where a malicious node disguises itself as an honest node to conduct consensus in order to increase its reputation and enter the high reputation list before committing malicious acts. The following verification behaviors can ensure that even if a malicious node commits malicious acts after being elected as the master node, it can be detected to ensure that the consensus can proceed smoothly, including: if the master node continues to fail to respond to transaction reception notifications or broadcasts inconsistent confirmation information to different nodes, it will be determined as a malicious node based on the timeout mechanism and the verification in the consensus process. The consensus node will initiate a view switch to replace the master node and reduce the reputation of the malicious master node; if the master node sends an incorrect transaction confirmation message, after the consensus node receives the transaction confirmation message, the nodes in the aggregate signature verify the transaction confirmation message. If it is found that the transaction hash value does not match the transaction hash value in its own node memory pool, the master node is considered to have committed malicious acts. The consensus node will initiate a view switch to replace the master node and reduce the reputation of the malicious master node.

[0032] For further information, please refer to Figure 3 , Figure 3 The present invention is a flow chart of the consensus phase of an improved PBFT consensus method according to an embodiment of the present invention. In this embodiment, the step S3 also includes: if the master node has no error, the round of consensus is completed, the node updates its reputation value, and enters the next round of consensus; if the master node has an error, the master node is reselected based on a random selection mechanism and consensus is re-performed until the master node has no error. By detecting errors in the master node, the failure of the master node is quickly responded to, a fault repair method is provided, and the master node is reselected for consensus, thereby improving the overall fault tolerance and ensuring that the consensus process can be stably executed, thereby ensuring data consistency of all nodes.

[0033] Please refer to Figure 2 , Embodiment 2 of the present invention is: an improved PBFT consensus terminal 1, comprising a memory 2, a processor 3, and a computer program stored in the memory 2 and executable on the processor 3, wherein the processor 3 implements each step of an improved PBFT consensus method of Embodiment 1 when executing the computer program.

[0034] In summary, the present invention provides an improved PBFT consensus method and terminal, which selects a master node by updating the initial reputation value of each node using the first PBFT consensus algorithm, including: allocating an initial reputation value to each node, using the first PBFT consensus algorithm to perform a preset round of consensus, and calculating and updating the initial reputation value of each node after each round of consensus according to the reputation evaluation mechanism; obtaining a set of candidate master nodes according to the reputation value of each node, and selecting a master node from the candidate master node set using a random number node selection mechanism, further ensuring that the nodes in the candidate master node set are honest nodes, while also avoiding the possibility and predictability of the master node doing evil; using a random number node selection mechanism from the candidate master node set The node selection mechanism selects a master node, including: sorting the nodes in the candidate master node set based on the public key to obtain a node sorting array, and generating a random number by a trusted third party, the trusted third party performing a hash operation on the random number to obtain a first hash value, and broadcasting the first hash value to all candidate master nodes in the candidate master node set; when the candidate master node receives the first hash value, querying the public key of the node located in the middle position in the node sorting array, calculating a second hash value according to the first hash value and the public key, performing a modulus operation on the second hash value to obtain a node value, and taking the corresponding node in the node sorting array whose sequence number is consistent with the node value as the master node, and using The cryptographic properties of the hash function are used to ensure the randomness and confidentiality of the master node selection process. At the same time, a trusted third party is used to coordinate some key steps to avoid the predictability of the master node and ensure the security of the master node. The master node and all consensus nodes participating in the consensus process receive the transaction information sent by the client, and store the transaction information in the node memory pool corresponding to each node, avoiding dependence on the central node, reducing the bandwidth consumption of the master node sending messages in the subsequent consensus process, and effectively improving the block throughput. The consensus node sends a transaction reception notification to the master node, and the transaction reception notification includes a transaction hash. When the master node receives a first preset number of transaction reception notifications, the master node sends a transaction Confirm the message to the consensus node. If the consensus node does not receive the transaction confirmation message, it sends a request to obtain the transaction confirmation information to the master node. Otherwise, it determines whether the transaction information corresponding to the transaction confirmation message exists in its own node memory pool according to the transaction confirmation message. If not, it broadcasts the transaction request to the node containing the transaction information to obtain the transaction information. The master node constructs a candidate block and puts the transaction hash into the candidate block. The master node broadcasts the candidate block and uses the second PBFT consensus algorithm for consensus. According to the situation of the consensus node receiving the transaction confirmation information and the data situation of the node memory pool, corresponding processing is performed to provide integrity protection and ensure the data consistency of the consensus node;The master node sends a pre-prepare message to the consensus nodes participating in the consensus process. If a consensus node receives the pre-prepare message, it checks the transaction information in the corresponding node memory pool and verifies the pre-prepare message, including whether the master node signature is correct, whether the block summary is correct, whether there are duplicate view messages, whether the block transaction hash is correct, etc. If the verification is successful, the prepare message is broadcast to other consensus nodes; if a consensus node receives a first preset number of prepare messages, the prepare message is verified. If the verification is successful, the commit message is broadcast to other consensus nodes; if a consensus node receives the commit message, the commit message is verified. When the first preset number of correct commit messages are received, a reply message is broadcast to the client; when the client receives a reply message sent by a second preset number of consensus nodes, the client sends a reply message to the client. When the message is repeated, the round of consensus is completed. The master node and multiple consensus nodes participating in the consensus process exchange pre-prepared messages, prepared messages and submitted messages, as well as message verification at each stage of the consensus process, to achieve an efficient and secure consensus process, improve the fault tolerance and scalability of the system, and ensure the consistency and integrity of the data of each node in the blockchain; if the master node has no errors, the round of consensus is completed, the node updates its reputation value and enters the next round of consensus; if the master node has an error, the master node is reselected based on the random selection mechanism and consensus is re-performed until the master node has no errors. By detecting the errors of the master node, the failure of the master node is quickly responded to, a fault repair method is provided, and the master node is reselected for consensus, which improves the overall fault tolerance and ensures that the consensus process can be stably executed, thereby ensuring the data consistency of all nodes. ;

[0035] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. An improved PBFT consensus method, characterized in that: Includes steps: S1. Use the first PBFT consensus algorithm to update the initial reputation value of each node and select the master node; S2. The master node and all consensus nodes participating in the consensus process receive the transaction information sent by the client, and store the transaction information in the node memory pool corresponding to each node; S3. The consensus node sends a transaction reception notification to the master node, and the transaction reception notification includes a transaction hash. When the master node receives a first preset number of transaction reception notifications, the master node sends a transaction confirmation message to the consensus node. If the consensus node does not receive the transaction confirmation message, it sends a request to obtain transaction confirmation information to the master node. Otherwise, it determines whether the transaction information corresponding to the transaction confirmation message exists in its own node memory pool according to the transaction confirmation message. If not, it broadcasts a transaction request to the node containing the transaction information to obtain the transaction information. The master node constructs a candidate block and puts the transaction hash into the candidate block. The master node broadcasts the candidate block and adopts the second PBFT consensus algorithm for consensus.

2. An improved PBFT consensus method according to claim 1, characterized in that: The step S1 specifically includes: Assign an initial reputation value to each node, use the first PBFT consensus algorithm to perform a preset round of consensus, and calculate and update the initial reputation value of each node after each round of consensus according to the reputation evaluation mechanism; A set of candidate master nodes is obtained according to the reputation value of each node, and a master node is selected from the set of candidate master nodes using a random number node selection mechanism.

3. An improved PBFT consensus method according to claim 2, characterized in that: The selecting a master node from the set of candidate master nodes using a random number node selection mechanism includes: The nodes in the candidate master node set are sorted based on the public keys to obtain a node sorting array, and a random number is generated by a trusted third party. The trusted third party performs a hash operation on the random number to obtain a first hash value, and broadcasts the first hash value to all candidate master nodes in the candidate master node set; When the candidate master node receives the first hash value, it queries the public key of the node in the middle position in the node sorting array, calculates the second hash value based on the first hash value and the public key, and performs a modulus operation on the second hash value to obtain the node value, and takes the corresponding node in the node sorting array whose sequence number is consistent with the node value as the master node.

4. The improved PBFT consensus method according to claim 1, characterized in that: The step S3 comprises: The master node sends a pre-prepare message to the consensus nodes participating in the consensus process. If a consensus node receives the pre-prepare message, it checks the transaction information in the corresponding node memory pool and verifies the pre-prepare message. If the verification is successful, it broadcasts the pre-prepare message to other consensus nodes. If a consensus node receives a first preset number of prepare messages, the prepare message is verified, and if the verification passes, a submission message is broadcast to other consensus nodes; If a consensus node receives the submission message, it verifies the submission message, and when a first preset number of correct submission messages are received, it broadcasts a reply message to the client; When the client receives reply messages sent by the second preset number of consensus nodes, the round of consensus is completed.

5. An improved PBFT consensus method according to claim 4, characterized in that: The step S3 further includes: If the master node does not have any errors, the consensus round is completed, the node updates its reputation value, and enters the next consensus round; If an error occurs in the master node, the master node is reselected based on a random selection mechanism and consensus is re-performed until no error occurs in the master node.

6. An improved PBFT consensus terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: S1. Use the first PBFT consensus algorithm to update the initial reputation value of each node and select the master node; S2. The master node and all consensus nodes participating in the consensus process receive the transaction information sent by the client, and store the transaction information in the node memory pool corresponding to each node; S3. The consensus node sends a transaction reception notification to the master node, and the transaction reception notification includes a transaction hash. When the master node receives a first preset number of transaction reception notifications, the master node sends a transaction confirmation message to the consensus node. If the consensus node does not receive the transaction confirmation message, it sends a request to obtain transaction confirmation information to the master node. Otherwise, it determines whether the transaction information corresponding to the transaction confirmation message exists in its own node memory pool according to the transaction confirmation message. If not, it broadcasts a transaction request to the node containing the transaction information to obtain the transaction information. The master node constructs a candidate block and puts the transaction hash into the candidate block. The master node broadcasts the candidate block and adopts the second PBFT consensus algorithm for consensus.

7. An improved PBFT consensus terminal according to claim 6, characterized in that: The step S1 specifically includes: Assign an initial reputation value to each node, use the first PBFT consensus algorithm to perform a preset round of consensus, and calculate and update the initial reputation value of each node after each round of consensus according to the reputation evaluation mechanism; A set of candidate master nodes is obtained according to the reputation value of each node, and a master node is selected from the set of candidate master nodes using a random number node selection mechanism.

8. An improved PBFT consensus terminal according to claim 7, characterized in that: The selecting a master node from the set of candidate master nodes using a random number node selection mechanism includes: The nodes in the candidate master node set are sorted based on the public keys to obtain a node sorting array, and a random number is generated by a trusted third party. The trusted third party performs a hash operation on the random number to obtain a first hash value, and broadcasts the first hash value to all candidate master nodes in the candidate master node set; When the candidate master node receives the first hash value, it queries the public key of the node in the middle position in the node sorting array, calculates the second hash value based on the first hash value and the public key, and performs a modulus operation on the second hash value to obtain the node value, and takes the corresponding node in the node sorting array whose sequence number is consistent with the node value as the master node.

9. An improved PBFT consensus terminal according to claim 6, characterized in that: The step S3 comprises: The master node sends a pre-prepare message to the consensus nodes participating in the consensus process. If a consensus node receives the pre-prepare message, it checks the transaction information in the corresponding node memory pool and verifies the pre-prepare message. If the verification is successful, it broadcasts the pre-prepare message to other consensus nodes. If a consensus node receives a first preset number of prepare messages, the prepare message is verified, and if the verification passes, a submission message is broadcast to other consensus nodes; If a consensus node receives the submission message, it verifies the submission message, and when a first preset number of correct submission messages are received, it broadcasts a reply message to the client; When the client receives reply messages sent by the second preset number of consensus nodes, the round of consensus is completed.

10. An improved PBFT consensus terminal according to claim 9, characterized in that: The step S3 further includes: If the master node does not have any errors, the consensus round is completed, the node updates its reputation value, and enters the next consensus round; If an error occurs in the master node, the master node is reselected based on a random selection mechanism and consensus is re-performed until no error occurs in the master node.

Citation Information

Patent Citations

  • DR-PBFT improved algorithm based on reputation value model

    CN115277722A

  • PBFT consensus method based on reputation improvement

    CN116614516A

  • Block chain consensus method capable of randomly selecting main node

    CN117411636A

  • Improved PBFT consensus method based on reputation scoring mechanism

    CN117527834A

  • Energy block chain node consensus method based on improved PBFT consensus mechanism

    CN117745433A

Cited By

  • Credit investigation data secure storage method and system

    CN121037139A

  • A method and system for secure storage of credit information data

    CN121037139B