Improved PBFT consensus method based on vehicle end block chain
By introducing node reputation value and genetic algorithm grouping and selecting consensus nodes in the PBFT consensus algorithm, the problems of inefficiency and poor scalability of traditional PBFT algorithms when the number of nodes is large, and a more efficient consensus process and better fault tolerance and scalability are achieved.
Patent Information
- Application Number
- CN202411451134.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-04-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional PBFT consensus algorithms consume long time and poor scalability when the number of nodes is large, and the choice of master nodes is random, which may lead to failure or malicious behavior to increase time consumption.
By setting the initial reputation value of the node and dividing the node status according to the reputation value and behavior, using a genetic algorithm to divide the nodes into groups and select consensus nodes, dynamically adjust the number of nodes, improve consensus efficiency, and optimize node behavior through the reward and punishment system.
It improves the efficiency of nodes participating in consensus, enhances the fault tolerance and scalability of the algorithm, reduces the time consumption caused by master node selection, and improves the participation of nodes and the stability of the system through reward and punishment mechanisms.
Smart Images

Figure CN119743482A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to blockchain technology, and specifically to an improved PBFT consensus method based on a vehicle-side blockchain, which solves the problems of random selection of master nodes and long algorithm time consumption in a traditional Byzantine algorithm. Background Art
[0002] The blockchain consensus algorithm is a mechanism that ensures that all nodes in a distributed network reach a consensus on the blockchain. This algorithm is crucial in a decentralized system because there is no single central authority to verify and record transactions. Common blockchain consensus algorithms include Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT), Raft, etc.
[0003] The Byzantine Fault Tolerance (BFT) algorithm has attracted widespread attention since it was proposed. However, due to its high complexity, it has not been applied in practice. It was not until 1999 that the Practical Byzantine Fault Tolerance (PBFT) algorithm was proposed. The original intention of the algorithm was to deal with the Byzantine Generals Problem. It can still reach a consensus in the presence of a certain number of malicious nodes (up to one-third of malicious nodes can be tolerated), which is a significant advantage in terms of security and fault tolerance. In addition, the PBFT algorithm reduces the complexity of the BFT algorithm from exponential to polynomial level, improving the algorithm's throughput and execution speed. In comparison, algorithms such as POW, POS, and DPOS have different fault tolerance capabilities when dealing with malicious nodes, but none of them can completely solve the Byzantine Generals Problem (the consensus problem in the presence of malicious nodes).
[0004] The consensus phase of the PBFT algorithm includes the request phase, the pre-preparation phase, the preparation phase, the confirmation phase, and the reply phase. PBFT requires two rounds of voting, and the time complexity is O(n 2 ), the time consumption will increase when the number of nodes is large, resulting in slow consensus and poor scalability. This limits the PBFT algorithm to systems with a small number of nodes. In addition, the selection of the master node in the algorithm is random, which brings a potential problem: if the master node fails or is a malicious node, it will trigger the algorithm to try to switch the protocol and reselect the master node, which will increase the time consumption. Summary of the invention
[0005] In view of this, this patent proposes an improved PBFT consensus method based on the vehicle-side blockchain to solve the node selection problem and improve the efficiency of nodes participating in the consensus. At the same time, it can dynamically adjust the number of nodes when nodes join and exit, so that the algorithm has better fault tolerance and scalability. The specific technical solution is as follows:
[0006] Step 1: Assume that the initial reputation value of each node in the blockchain is 60, the highest node reputation value is 100, and the reputation value will not increase after reaching 100, and will not decrease after falling below 0. The node reputation value is divided into R good , R nomal , R limit Three levels. good Is a high reputation value, R nomal is the normal reputation value, R limit It is the minimum reputation value. If the reputation value is lower than this value, the node will be directly removed from the blockchain system.
[0007] Step 2: Based on the node's reputation value and the node's behavior, the node's credit status is divided into four states: trusted, normal, abnormal, and invalid. The trusted state means that the node has not generated any invalid blocks and its reputation value exceeds R good ; The normal state means that the node has not generated invalid blocks and its reputation value is higher than R limit ; Abnormal state means that the node generates invalid blocks, but its reputation value is not less than R nomal The invalid state means that the node generates an invalid block, but its reputation value is lower than R nomal .
[0008] Step 3: Consider the reputation values of the nodes in the trusted, normal, and abnormal states in the blockchain as an array group, use a genetic algorithm to divide the group into k groups, and select some as consensus nodes.
[0009] Step 4: The trusted nodes ranked "first" and "second" in reputation among the consensus nodes are selected as candidate master nodes. If there are no trusted nodes, nodes with higher reputation values are selected from normal nodes as candidate master nodes. Then other non-consensus nodes vote on the candidate master nodes to select the master node. During the consensus voting process, each consensus node can support, abstain, or oppose.
[0010] Step 5: Define the reward and punishment system based on the node's voting and participation in consensus. The specific rules of reward and punishment are: (1) Allocate rewards to nodes that support the proxy node and successfully generate blocks. (2) When the proxy node exhibits malicious behavior or fails, the node supporting the proxy node will be punished by credit. Otherwise, the credit reward will be allocated to the node corresponding to the proxy node. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 This is the flow chart of the PBFT algorithm.
[0012] Figure 2 This is a flow chart of the improved PBFT consensus algorithm proposed in this invention. DETAILED DESCRIPTION
[0013] 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 only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0014] The present invention proposes an improved PBFT consensus method based on the vehicle-side blockchain, which specifically includes the following steps:
[0015] Step 1: System initialization. Assume that the initial reputation value of each node in the blockchain is 60, the highest node reputation value is 100, and the reputation value will not increase after reaching 100, and will not decrease after falling below 0. The node reputation value is divided into R good , R nomal , R limit There are three levels, 80, 50, and 45 respectively. good Is a high reputation value, R nomal is the normal reputation value, R limit It is the minimum reputation value. If the reputation value is lower than this value, the node will be directly removed from the blockchain system.
[0016] Step 2: Credit status classification. According to the node reputation value and node behavior, the node's credit status is divided into four states: trusted, normal, abnormal, and invalid. The trusted state means that the node has not generated any invalid blocks and its reputation value exceeds R good ; The normal state means that the node has not generated invalid blocks and its reputation value is higher than R limit ; Abnormal state means that the node generates invalid blocks, but its reputation value is not less than R nomal The invalid state means that the node generates an invalid block, but its reputation value is lower than R nomal .
[0017] Furthermore, nodes in a trusted state have priority in participating in the selection of master nodes. When there is no trusted node or there is only one trusted node, the nodes with higher reputation values among normal nodes and abnormal nodes can participate in the election of master nodes. Both normal nodes and trusted nodes are eligible to vote for master nodes. Invalid nodes cannot vote for master nodes, but can serve as replica nodes to verify blocks published by master nodes.
[0018] Step 3: Select consensus nodes. In the blockchain system, each node has a reputation value and can be in a trusted, normal, abnormal, or invalid state. By using a genetic algorithm, combining the reputation value and the characteristics of abnormal nodes for uniform grouping, and designing a fitness function, it is possible to effectively achieve a balanced distribution of reputation values and a reasonable distribution of abnormal nodes in the group. Select some of them as consensus nodes.
[0019] Furthermore, genetic algorithm is a computational model that simulates the biological evolution process based on natural selection and genetics in Darwin's theory of biological evolution. It is a way to search for the optimal solution by simulating the natural evolution process. The main steps of genetic algorithm include initializing the population, evaluating fitness, selection, crossover, mutation, generating a new population, and iteration. In the PBFT algorithm, assume that the number of nodes is N, and the total number of trusted nodes, normal nodes, and abnormal nodes is N. r , assuming that it is divided into S groups, group k ∈{group1, group 2,......, group S} indicates that the nodes in the blockchain are divided into the kth group, group S Indicates the last group. Using genetic algorithms can make the total credit value of each group as equal as possible, and the number of abnormal nodes as equal as possible.
[0020] Furthermore, the specific steps of the genetic algorithm are:
[0021] Step 1: Use a length N r An array of represents an individual, where each element of the array represents the group to which the node belongs. P individuals are randomly generated as the initial population, and each individual represents a grouping scheme.
[0022] Step 2: Design a fitness function. The fitness function needs to comprehensively consider two factors: the balance of reputation values and the distribution of abnormal nodes. In order to make the total reputation value of each group close to the average level, the variance can be used to measure the balance; in order to avoid the concentration of abnormal nodes in one group, the number of abnormal nodes in each group can be calculated to measure their distribution.
[0023] Step 2.1 Calculate the total reputation value of each group and the number of abnormal nodes in each group.
[0024]
[0025] Formula (1) is used to calculate the total reputation value of each group, v ki represents the reputation value of node i in the kth group; Formula (2) is used to calculate the number of abnormal nodes in each group, α ki An indicator variable indicating whether the k-th group node i is an abnormal node (abnormal nodes are 1, normal and trusted nodes are 0).
[0026] Step 2.2: Calculate the total variance of reputation values and the number of abnormal nodes.
[0027]
[0028] Formula (3) is used to calculate the variance of the sum of the reputation values of S groups, where Represents the average total reputation, and its calculation formula is: Formula (4) is used to calculate the variance of the number of abnormal nodes, where is the number of abnormal nodes in each group, and its calculation formula is
[0029] Step 2.3 defines the comprehensive fitness function:
[0030]
[0031] Among them, α and β are weight parameters used to balance the importance of reputation balance and abnormal node distribution. In this patent, α is set to 0.6 and β is set to 0.4.
[0032] Step 2.4 selects better individuals as parents according to the fitness value to ensure that individuals with higher fitness have a higher probability of being selected.
[0033] The parent individuals selected in step 2.5 generate offspring individuals through crossover operation. The crossover operation simulates the gene recombination in the biological genetic process. For example, two individuals consisting of reputation values and abnormal nodes can be selected, and their partial array segments can be exchanged to generate a new grouping scheme.
[0034] Step 2.6: Mutation and generation of new population. Mutation of offspring individuals means randomly changing the grouping of individuals to achieve the purpose of enhancing population diversity and prevent the algorithm from falling into a local optimum. Then, some or all individuals in the population are replaced with newly generated offspring individuals to form a new generation of population. Repeat the fitness evaluation, selection, crossover and mutation steps until the stopping condition is met.
[0035] Step 4: Master node selection. The trusted nodes ranked "first" and "second" in the reputation value of the consensus nodes are selected as candidate master nodes. If there is a lack of trusted nodes, the nodes with higher reputation values are selected from the normal nodes as candidate master nodes. According to the non-consensus nodes selected in step 3, only trusted and normal nodes have voting rights, while abnormal nodes do not have voting rights, but they can verify the release of blocks. In the vote, trusted and normal nodes can support, abstain, or oppose, and the corresponding values are 1, 0, and -1, respectively, and the weight of their votes is proportional to their reputation values. The voting results are:
[0036]
[0037] Among them, result pq refers to the score calculated in the qth candidate master node group in the pth group, R pqrepresents the reputation value of the qth candidate master node in the pth group, 1≤p≤S, 1≤q≤2. up represents the trusted nodes and normal nodes with the highest reputation value in the group, a ki represents the reputation value of the i-th node in the k-th group, vote ki represents the voting value of the i-th node in the k-th group. num represents the number of trusted nodes and normal nodes with the highest reputation value in the group where the candidate master node is located. i It indicates the reputation value of the other consensus nodes in the group where the candidate master node is located, and vote indicates the voting status of the other consensus nodes in the group where the candidate master node is located.
[0038] Step 5: Reward and punishment settings. Define the reward and punishment system based on the node's voting status and participation in consensus. The specific rules of rewards and punishments are: (1) Rewards are allocated to nodes that support proxy nodes and successfully generate blocks. (2) When the proxy node exhibits malicious behavior or fails, the nodes that support the proxy node will be punished by credit. Otherwise, the credit reward will be allocated to the point corresponding to the proxy node.
[0039] Furthermore, based on the node’s voting status and participation in consensus, the rewards and penalties for voting are defined as follows:
[0040] The reputation reward formula is:
[0041]
[0042] The reputation penalty formula is:
[0043]
[0044] Among them, R ki represents the reputation value of the i-th node in the k-th group, Indicates the reputation value of the i-th node in the k-th group last time. In this patent, V1=1, V2=5, V3=10.
Claims
1. An improved PBFT consensus method based on vehicle-side blockchain, characterized in that: The following steps are involved: 1) System initialization. Assume that the initial reputation value of each node in the blockchain is 60, the highest node reputation value is 100, and the reputation value will not increase after reaching 100, and will not decrease after falling below 0. The node reputation value is divided into R good , R nomal , R limit There are three levels, 80, 50, and 45 respectively. good Is a high reputation value, R nomal is the normal reputation value, R limit It is the minimum reputation value. If the reputation value is lower than this value, the node will be directly removed from the blockchain system. 2) Credit status classification. According to the node reputation value and node behavior, the node credit status is divided into four states: trusted, normal, abnormal, and invalid. The trusted state means that the node has not generated any invalid blocks and its reputation value exceeds R good ; The normal state means that the node has not generated invalid blocks and its reputation value is higher than R limit ; Abnormal state means that the node generates invalid blocks, but its reputation value is not less than R nomal ; Invalid state means that the node generates an invalid block, but its reputation value is lower than R nomal . 3) Select consensus nodes. In the blockchain system, each node has a reputation value and can be in a trusted, normal, abnormal, or invalid state. By using a genetic algorithm, combining the reputation value and the characteristics of abnormal nodes for uniform grouping, and designing a fitness function, it is possible to effectively achieve a balanced distribution of reputation values and a reasonable distribution of abnormal nodes in the group. Select some of them as consensus nodes. 4) Master node selection. The trusted nodes ranked "first" and "second" in reputation among the consensus nodes are selected as candidate master nodes. If there are no trusted nodes, nodes with higher reputation values are selected from normal nodes as candidate master nodes. According to the non-consensus nodes selected in 3), only trusted and normal nodes have voting rights, while abnormal nodes do not have voting rights, but they can verify the release of blocks. 5) Reward and punishment settings. Define the reward and punishment system based on the node's voting status and participation in consensus. The specific rules of rewards and punishments are: (1) Rewards are allocated to nodes that support proxy nodes and successfully generate blocks. (2) When a proxy node exhibits malicious behavior or fails, credit penalties are imposed on nodes that support the proxy node. Otherwise, the credit award will be allocated to the node corresponding to the proxy node.
2. An improved PBFT consensus method based on vehicle-side blockchain according to claim 1, characterized in that: The credit status division mentioned above refers to dividing nodes into four states: trusted, normal, abnormal, and invalid, and dividing the permissions for these four states. Invalid nodes are not eligible to become consensus nodes. Trusted nodes have priority in participating in the selection of master nodes. When there are no trusted nodes or there is only one trusted node, the nodes with higher reputation values among normal nodes can participate in the election of master nodes. Both normal nodes and trusted nodes are eligible to vote for master nodes. Abnormal nodes cannot vote for master nodes, but can serve as replica nodes to verify blocks published by master nodes.
3. According to the improved PBFT consensus method based on the vehicle-side blockchain according to claim 1, it is characterized in that: The genetic algorithm is a method of searching for the optimal solution by simulating the natural evolution process. Its steps include initializing the population, evaluating fitness, selection, crossover, mutation, generating a new population, and iteration. In this algorithm, it is assumed that the number of nodes is N, and the total number of trusted nodes, normal nodes, and abnormal nodes is N. r , assuming that the consensus nodes are divided into S groups, group k ∈{group1, group2,...,group S } indicates that the nodes in the blockchain are divided into the kth group, group S Indicates the last group.
4. According to claim 1, an improved PBFT consensus method based on vehicle-side blockchain is characterized in that: The fitness calculation steps of the genetic algorithm are: 1) Calculate the total reputation value of each group and the number of abnormal nodes in each group. The calculation formula is as follows: S k Used to calculate the total reputation value of each group, v ki A represents the reputation value of node i in the kth group; k Used to calculate the number of abnormal nodes in each group, α ki An indicator variable indicating whether the k-th group node i is an abnormal node (abnormal nodes are 1, normal and trusted nodes are 0). 2) Method for calculating the total variance of reputation values and the number of abnormal nodes. The calculation formula is as follows: σ1 2 Used to calculate the variance of the sum of the reputation values of S groups, where represents the average total reputation, Used to calculate the variance of the number of abnormal nodes, where is the number of abnormal nodes in each group. 3) Define the comprehensive fitness function. Its definition formula is as follows: Among them, α and β are weight parameters used to balance the balance of reputation values and the importance of abnormal node distribution. α is set to 0.6 and β is set to 0.
4.
5. According to claim 1, the improved PBFT consensus method based on the vehicle-side blockchain is characterized in that: The selection content in the genetic algorithm is: selecting the better individuals as the parent generation according to the fitness value.
6. According to claim 1, an improved PBFT consensus method based on vehicle-side blockchain is characterized in that: The crossover content of the genetic algorithm mentioned is: the selected parent individuals generate offspring individuals through the crossover operation. The crossover operation simulates the gene recombination in the biological genetic process. In this algorithm, two individuals consisting of reputation values and abnormal nodes are selected, and their partial array segments are exchanged to generate a new grouping scheme.
7. According to claim 1, an improved PBFT consensus method based on vehicle-side blockchain is characterized in that: In the genetic algorithm, mutation operation is performed on the offspring individuals, which means randomly changing the grouping of individuals, so as to achieve the purpose of enhancing the diversity of the population and prevent the algorithm from falling into the local optimum; then, the newly generated offspring individuals replace part or all of the individuals in the population to form a new generation of population. Repeat the fitness evaluation, selection, crossover and mutation steps until the stopping condition is met.
8. According to claim 1, an improved PBFT consensus method based on vehicle-side blockchain is characterized in that: The calculation of the master node voting result is: Among them, result pq refers to the score calculated in the qth candidate master node group in the pth group, R pq represents the reputation value of the qth candidate master node in the pth group, 1≤p≤S, 1≤q≤2. up represents the trusted nodes and normal nodes with the highest reputation value in the group, a ki represents the reputation value of the i-th node in the k-th group, vote ki represents the voting value of the i-th node in the k-th group. num represents the number of trusted nodes and normal nodes with the highest reputation value in the group where the candidate master node is located. i It indicates the reputation value of the other consensus nodes in the group where the candidate master node is located, and vote indicates the voting status of the other consensus nodes in the group where the candidate master node is located.
9. The improved PBFT consensus method based on vehicle-side blockchain according to claim 1 is characterized in that: The reward and punishment formula is: Reputation Reward Formula Credit Penalty Formula R ki represents the reputation value of the i-th node in the k-th group, Represents the reputation value of the i-th node in the k-th group last time. Among them, V1=1, V2=10, V3=15.
Citation Information
Patent Citations
A block chain consensus method based on credit evaluation
CN109819022A
Optimal consensus node selection method based on genetic algorithm
CN110458291A
Improved PBFT consensus method based on reputation and voting mechanism
CN111355810A
Node excitation method and system under unauthorized block chain architecture based on fragments
CN113037504A
Blockchain consensus systems and methods involving a time parameter
US20200134578A1