# Research on Progress of Blockchain Consensus Algorithm:
## 3 Blockchain Consensus Algorithm
### Non-Byzantine Fault-Tolerant Consensus Algorithm
#### 3.2.3 Raft Algorithm  
In 2013, [PERSON] et al. [54] proposed the Raft algorithm. The Raft algorithm uses the log replication of each node in the system to achieve unification of transactions and consensus. The nodes in the system are also divided into three categories: namely, leaders, followers, and candidates. The three types of identities can be transformed into each other. The leader in the algorithm is responsible for processing interactive information, log replication, log distribution, and other tasks. There is usually only one leader during each consensus process. Followers are similar to voters in voting activities, generally one-way passively accepting the log information sent by the leader. Candidates can be transformed from followers and have a probability of being elected as the new leader. There are two main working phases in the Raft algorithm: the leader election phase and the log synchronization phase. At the beginning of the leader election phase, except for an initial leader node, other nodes are initialized as followers. The initial leader first sends logs one-way to all followers, and followers passively receive the log information sent by the leader. Each follower has a random timeout period. If the message sent by the leader is not received within this time, the follower will turn into a candidate and initiate a leader election request. Candidates transformed from followers will vote for themselves and send other followers to request voting applications. If the candidate receives more than half of the votes in the process, the identity is converted to leader. If the leader information from other nodes is received in the middle of the election, it indicates that other candidates pre-empted to become the leader, and the election failed. If a candidate does not receive more than half of the votes, it also means that the election has failed and needs to wait until the next election request. The process of Raft election is shown in Figure 4.  
Figure 3: Paxos algorithm flow. When the leader is elected, it enters the next stage of log replication. In this stage, the leader will create new log entries into the leader's log, update the log content in real time, and send the new log content to the followers through log replication. After receiving the log information, followers update the locally stored log information and return a confirmation message. Once the leader receives more than half of the confirmation information, the log reaches a consensus. If there is a system failure, so that the leader cannot access most of the followers, the leader can only update the accessed followers' information, but other followers in the system cannot get log updates. In this case, the system will automatically execute a leader election, and the new leader will continue to work as a leader. When the system failure is repaired, the leader before the failure will become a follower. All updated information proposed by the old leader during the failure will be rolled back. At the same time, the old leader will receive information updates from the new leader, so that the consistency and security of the system can be guaranteed. The process of the Raft log replication phase is shown in Figure 5.  
The Raft algorithm is easier to understand and realize than the Paxos algorithm proposed earlier. The algorithm is more efficient compared to the Paxos algorithm. The Leader election and log replication mechanism are adopted by the Raft algorithm; the Raft algorithm relies on the strong leadership of the leader. A single leader sends log information to other nodes for management. Even if the leader fails due to a failure, a new leader will be selected immediately to ensure the safety and stability of the system. Since the leader node can only support a limited number of node networks, and the fault tolerance is not very good, the Raft algorithm cannot support public chains with many nodes that are open to the outside world. The Raft algorithm is only applicable to private chains and cannot deal with malicious nodes.