
1. Introduction
In blockchain system, the consensus algorithm enables all participants to jointly maintain transaction data and achieve mutual trust relationships without integrated control. Consensus algorithms can be roughly divided into proof-based consensus algorithms and voting-based consensus algorithms; the most classic consensus voting-based algorithm is the PBFT algorithm. But this consensus algorithm has some problems to improve. Then many variant consensus algorithms are presented to issue the shortcomings of PBFT. In BBFT [1], it uses the topology tree structure and message aggregation to reduce the communication complexity. Liu et al. presented the FastBFT [2] in 2018. It uses a message aggregation and trust execution environments technique to improve the PBFT. Since in PBFT, the total number of nodes is 3f + 1 (f is the number of fault nodes), then Giuliana Santos Veronese et al. propose MinBFT [3] and Rudiger Kaitza et al. present CheapBFT [4]. Their methods all reduce the total nodes’ number from 3f + 1 to 2f + 1. Zyzzyva [5] is a Speculative Byzantine Fault Tolerance which is proposed by Ramakrishna Kotla et al. It changes three-protocol of PBFT to improve performance. HAO et al. proposed the CDBFT [6]. It combines DPOS and PBFT to reduce the participation probability of malicious replicas in the consensus process. Jeon et al. proposed the DBFT [7] which makes optimization for the application of public blockchain. Among all the PBFT variant algorithms, few have improved the algorithm by changing the way the master node is selected. So this article proposes a consensus mechanism based on an improved genetic algorithm. BAGLEY took the lead in using the concept of “genetic algorithm” in the paper [8] in 1967. The improved genetic algorithm is used to obtain the best primary node when it is selected. After calculation, the algorithm improves transaction efficiency and processing time. The structure of the paper is as follows: Section 2 describes the traditional PBFT algorithm, Section 3 introduces the consensus algorithm based on the improved genetic algorithm, and Section 4 does a summary to this article.
2. Practical Byzantine Fault Tolerance Algorithm
PBFT algorithm was presented by Castro and Liskvo in 1999 [9]. It requires that each consensus be executed in the same order on each copy, and each participant decides the content of the consensus by voting. PBFT adopts a three-phase protocol: PREPREPARE, PREPARE, and COMMIT.
PRE-PREPARE
In the PRE-PREPARE phase, the primary sends a pre-prepare message to all replica nodes.
PREPARE
When the backup node i has received the pre-prepare message, it enters the PREPARE phase, and sends the prepare message to other nodes. Besides it writes both the pre-prepare message and the prepare message to the log.
In the PBFT algorithm, the PRE-PREPARE phase and the PREPARE phase ensure that the non-faulty replica nodes agree on the ordering of requests in the same view. BFT systems shall guarantee safety and liveness in the presence of faulty servers and clients [10].
COMMIT
The replica joins in the COMMIT phase and broadcasts to all replicas the commit message. Figure 1 is a flow chart of the three-phase agreement.
The above three steps determine the number of replicas in PBFT is 3f + 1 and the communication complexity is o(f2) (f is the number of faulty nodes).
3. A Variant Consensus Mechanism Based on an Improved Genetic Algorithm
Since in the PBFT algorithm nodes are divided into the primary node and other replica nodes, and the primary node as a consensus node executes a three-phase protocol to complete transactions. Once the primary node fails, it will re-select, which will cause the efficiency of system transaction execution to decrease. Therefore, the selection of the primary node is very essential. This paper proposes an improved genetic algorithm to select the best primary node of PBFT. The improved genetic algorithm mainly uses the elitist strategy to retain the best individual, and the best individual does not undergo mutation, crossover and other operations, and directly enters the next generation. The improved algorithm not only improves convergence, but also ensures that the optimal individual characteristics are not destroyed in the evolution process [11] [12]. Firstly, each participant is involved in coding into the corresponding chromosomes to form the initial initial population. Secondly, select the master node according to the fitness function. Then use the elitist selection strategy to perform crossover and mutation operations to achieve the best primary node selection.
Step I
Encoding all participating codes to chromosome. Suppose there are m participating nodes, a chromosome of an m-dimensional vector is obtained after encoding, this dimension is the number of all participating nodes N = {n1, n2, ..., ni, ..., nm}.
Step II
Setting fitness function
for all encoded chromosomes. ni represents a legal chromosome, N represents the set of all chromosomes, Fau() represents the number of times that the node has problems, and Eff() represents the efficiency of the node’s transaction with other nodes. According to the f(ni) to obtain the optimal solution, the best primary node is selected.
Step III
Selecting the best master node according to the elitist selection strategy, and other nodes perform mutation and selection operations.
Step IV
When the termination conditions are met, the optimal solution of the function will be used as the primary node to participate in the implementation of the PBFT three-phase protocol.
Figure 2 is a flowchart of the improved algorithm.
![]()
Figure 2. Improved algorithm flow chart.
4. Conclusions
Latency is an important indicator to measure the performance of the blockchain. The delay is mainly affected by two aspects: one is the network communication performance when the message is propagated between nodes, and the other is the operating efficiency of the consensus algorithm. According to formula Delay = TBroadcast + TConsensus, in the fitness function
, if a node meets the minimum Fau() and the maximum Eff(), during the consensus process, TBroadcast decreases, so the entire Delay decreases. Compared with the traditional PBFT algorithm, the delay is effectively reduced.
This paper proposes a PBFT algorithm based on an improved genetic algorithm, which uses genetic algorithm to improve the selection strategy of the primary node, so that the improved PBFT algorithm consensus efficiency is higher.