# The Evolution and Optimization Strategies of a PBFT Consensus Algorithm for Consortium Blockchains
## 4 Analysis of the Improved PBFT Consensus Algorithm
### An Optimized Consensus Algorithm Based on an Optimistic Mechanism  
In the standard PBFT consensus algorithm, the consensus is achieved during the prepare phase. At this point, Byzantine malicious nodes can be detected, and the system can tolerate up to f Byzantine nodes while still reaching consensus. In other words, as long as the primary node is honest and the number of Byzantine nodes does not surpass f + 1, consensus consistency is ensured during the pre-prepare and prepare phases. However, when the primary node itself is Byzantine, two common types of errors may occur when applying the PBFT algorithm in a traceability system:  
1. Advantages Byzantine Error: The primary node may alter a correct message received from the client to one that is beneficial to itself before broadcasting it to the network. For example, it may modify message m into m'. 2. Consistency Byzantine Error: The primary node might send different messages (m and m') with the same sequence number (n) to different nodes, or assign the same sequence number to different client request messages (m and m'). This inconsistency can cause problems during view changes, where nodes present conflicting information, undermining the security of the consensus. In the traditional two-phase PBFT protocol, security issues in the network arise only when the primary node encounters a consistency error. A specific example of such an issue is as follows:  
When the primary node receives client message requests, m and m', it may attempt to assign them the same sequence number n. As a result, in the pre-prepare messages forwarded to other nodes, some may contain <m, v, n>, while others may contain <m', v, n>. Additionally, the primary node might simultaneously send both <m, v, n> and <m', v, n> to other malicious nodes. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Algorithm** & **Multi-Leader Selection Mechanism** & **Number of Consensus Nodes** & **Network Model** & **Reward/Penalty Mechanism** \\ \hline VC-BFT [104] & Vague sets and credit rating & N & Semi-Synchronous Network & Slash malicious nodes, reward \\  & & & & honest participation. \\ \hline RBFT [105] & Monitoring Mechanism and Protocol & N & Semi-Synchronous Network & Penalize redundant faults, \\  & Instance Change Mechanism & N & Semi-Synchronous Network & incentivize consistency. \\ \hline BigBert [106] & Dynamic Coordinator Node & N & Semi-Synchronous Network & Dynamic stake weighting for \\  & Selection Mechanism & N & Semi-Synchronous Network & active nodes. \\ \hline FnF-BFT [107] & Hash Space Partitioning Mechanism & N & Semi-Synchronous Network & Credit-based penalties, rewards for \\  & & & & fast response. \\ \hline \hline \end{tabular}
\end{table} 
Table 12: A comparison of multi-leader selection mechanisms across different algorithms. Assume there are seven nodes (nodes 0, 1, 2, 3, 4, 5, and 6), with the number of Byzantine nodes being f = 2, and the primary node (node 0) and node 6 being malicious. The following will discuss the scenarios encountered during the two-phase consensus submission. Suppose the primary node (node 0) is malicious. After receiving two request messages, m and m', from the client (C), it sends a malicious message <m, v, n> with sequence number n to nodes 1, 2, and 3 (f + 1 honest nodes) during the pre-prepare phase, and sends a malicious message <m', v, n> with the sequence number n to nodes 4 and 5 (f honest nodes). Both messages <m, v, n> and <m', v, n> are also sent to node 6 (a Byzantine node). In the prepare phase, each node forwards a prepare message to others after receiving the pre-prepare message from the primary node. Node 6 may randomly choose to forward either <m, v, n> or <m', v, n>. Suppose node 6 only forwards the correct prepare message containing <m, v, n> to node 2 (fewer than f + 1 honest nodes), and sends the incorrect prepare message containing <m', v, n> to other nodes. In this case, node 2 will receive the prepare messages {m, m, m, m, m', m', m', m', m'}.