Patent Publication Number: US-2022222156-A1

Title: Method and system for active failure recovery of single node improved based on pbft algorithm, computer device and storage medium

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
     This application is a continuation-in-part of International patent application Serial No. PCT/CN2020/120111, field on Oct. 10, 2020, which claims priority to Chinese patent application No. 201910956576.8 filed on Oct. 10, 2019 and entitled “method and system for active failure recovery of single node improved based on PBFT algorithm”, the contents each of which are incorporated herein by reference thereto. 
    
    
     TECHNICAL FIELD 
     The present application relates to the technical field of Practical Byzantine Fault Tolerance algorithm, and particularly relates to a method for active failure recovery of single node improved based on PBFT algorithm, a system for active failure recovery of single node improved based on PBFT algorithm, a computer device and a computer readable storage medium. 
     BACKGROUND 
     PBFT is the abbreviation of Practical Byzantine Fault Tolerance, that is, Practical Byzantine Fault Tolerance Algorithm. This PBFT algorithm is proposed by Miguel Castro and Barbara Liskov, and seeks to solve a problem of low efficiency of the original Byzantine Fault Tolerance algorithm, a complexity of time of the PBFT algorithm is O(N{circumflex over ( )}2), thus, the Byzantine fault tolerance problem can be solved in the actual application of system. In order to tolerate the existence of F Byzantine nodes, the PBFT requires that there are at least (3f+1) nodes in the whole network. 
     The normal consensus process of the PBFT algorithm is divided into three stages including Pre-Prepare phase, Prepare phase, and Commit phase. After a slavery node detects that a master node is abnormal, the slavery node triggers a view change to change the master node to ensure the normal service of the system provided for the outside. However, when one node disconnects with the master node for a short time, this node is still in the normal state after it enters the view change state because other nodes are still normally connected with the master node, therefore, this node can only repeatedly and continuously send view change request, and can be restored to the normal state only when the whole network enters the next view change, a time length spent on failure recovery depends on the time when the whole network triggers the next failure recovery, this passive recovery is obviously not practical for practical application. 
     SUMMARY 
     According to the various embodiments of the present application, a method for active failure recovery of a single node improved based on PBFT algorithm is provided, a point-to-point network containing (3f+1) nodes is required in the PBFT algorithm, at most Byzantine errors of F nodes are tolerable for this point-to-point network, and the method includes following steps: 
     step S 1 : enabling a node operated normally to enter into an abnormal state to become an abnormal node when detecting a failure in a system due to network malfunction; 
     step S 2 : broadcasting a view change request to all nodes in a whole network, and requesting to enter a next view by the abnormal node; where the view change request in the step S 2  comprises an ID, a proposed view value, a height of a stable checkpoint, and PQC information of the node; 
     step S 3 : waiting for view change requests from other nodes within a predetermined period of time and counting a number of the view change requests, and performing recovery for the abnormal node according to a view change recovery method in the PBFT algorithm by the abnormal node, if (2f+1) view change requests containing the same view value are received within the predetermined period of time; or alternatively enabling the abnormal node to enter into a state to be recovered to become a node to be recovered if (2f+1) view change requests are not received within the predetermined period of time; 
     step S 4 : broadcasting a recovery request to all nodes in the whole network by the node to be recovered, where the recovery request includes an ID of the node to be recovered; 
     step S 5 : waiting for replies from other nodes and counting a number of the replies within the predetermined period of time by the node to be recovered, wherein each of other normal nodes returns a view value and a height of a stable checkpoint, an ID and PQC information thereof after receiving the recovery request from the node to be recovered; entering step S 6  to perform a state recovery if the node to be recovered receives (2f+1) replies with the same view value within the predetermined period of time; or alternatively returning to step S 4  if the node to be recovered fails to receive (2f+1) replies with the same view value within the predetermined period of time; 
     where the PQC information includes a Pre-Prepare message, a Prepare message, and a Commit message; 
     step S 6 : calculating, by the node to be recovered, a height of a stable checkpoint of the whole network according to checkpoint information returned by the (2f+1) nodes, performing recovery on the stable checkpoint through a fast synchronization algorithm in the PBFT, and performing a final recovery after the recovery performed on the stable checkpoint is completed, if the height of the stable checkpoint of the node to be recovered is lower than the height of the stable checkpoint of the whole network; or directly performing a final recovery in step S 7  if the height of the stable checkpoint of the node to be recovered is equal to or greater than the height of the stable checkpoint of the whole network; 
     step S 7 : submitting a request for obtaining PQC information after the stable checkpoint to all nodes of the whole network by the node to be recovered; 
     step S 8 : returning, by the other normal nodes, all PQC information after the stable checkpoints of the other normal nodes, after receiving the request for obtaining the PQC information; and 
     step S 9 : redoing the PQC information, by the node to be recovered, according to PQC reply information received from the other normal nodes until the node to be recovered is restored to a height of normal node, thus completing recovery of the abnormal node. 
     Furthermore, the view change request in the step S 2  further includes signature information of the node. 
     Furthermore, in the step S 3  and the step S 5 , a counting rule is that one node can only be counted one time, the node is counted one time when reply information is received multiple times from the same node at the same time within the predetermined period of time. 
     Furthermore, the recovery request in the step S 4  further includes signature information of the node to be recovered. 
     Furthermore, the reply information from the other normal node in the step S 5  further includes signature information of the node. 
     Furthermore, in the step S 9 , the node to be recovered redoes the PQC information at a height above the height thereof so as to be avoided from a repeated execution of the same PQC after receiving the PQC reply information, thus being caused to execute an error process to enter an abnormal state again. 
     According to the various embodiments of the present application, a method for active failure recovery of a single node improved based on PBFT algorithm is further provided, where the method is applied to a point-to-point network containing (3f+1) nodes, Byzantine errors of F nodes are tolerable for this point-to-point network, the method includes following steps: 
     determining an abnormal node, and sending a view change request to other nodes in a whole network by the abnormal node; where the view change request is used for requesting to enter a next view, the view change request includes an ID of the node, a view value proposed by the node, a height of a stable checkpoint of the node, and PQC-Set information of the node; the PQC-Set information respectively corresponds to P-Set Q-Set, and C-Set which are defined for recovery of view change in the PBFT algorithm; 
     waiting for view change requests from other nodes and counting a number of the view change requests within a first predetermined period of time, and setting the abnormal node as a node to be recovered if (2f+1) view change requests are not received within the first predetermined period of time; 
     sending a recovery request to other nodes in the whole network by the node to be recovered, where the recovery request comprises an ID of the node to be recovered; 
     waiting for replies from the other nodes and counting a number of the replies in a second predetermined period of time, where each other node returns a view value and a height of a stable checkpoint, an ID, and PQC-Set information thereof after receiving the recovery request of the node to be recovered; and performing a state recovery if (2f+1) replies containing the same view value are received within the second predetermined period of time; 
     said performing the state recovery includes: 
     obtaining a height of a stable checkpoint of the whole network according to the height of the stable checkpoint and the PQC-Set information returned by the (2f+1) nodes, performing a recovery on the stable checkpoint through a fast synchronization algorithm in the PBFT, and performing a final recovery after the recovery performed on the stable checkpoint is completed, if the height of the stable checkpoint of the node to be recovered is lower than the height of the stable checkpoint of the whole network; or alternatively performing the final recovery if the height of the stable checkpoint of the node to be recovered is greater than or equal to the height of the stable checkpoint of the whole network; 
     said performing the final recovery includes: 
     obtaining, by the node to be recovered, PQC information after the stable checkpoints from the other nodes in the whole network, where the PQC information includes a Pre-Prepare message, a Prepare message, and a Commit message; and redoing the PQC information according to the PQC reply information after the other nodes return their own stable checkpoints, until the node to be recovered is restored to the normal node. 
     In one embodiment, after the step of waiting for view change requests from other nodes and counting the number of the view change requests within the first predetermined period of time, the method further include a step of: 
     completing a recovery of the node to be recovered through the view change recovery method in the PBFT algorithm if (2f+1) view change requests containing the same view value are received in the first predetermined period of time. 
     In one embodiment, after the step of waiting for view change requests from other nodes and counting the number of the view change requests within the second predetermined period of time, the method further comprises a step of: 
     returning to perform the step of sending the recovery request to all other nodes in the whole network by the node to be recovered, if the node to be recovered fails to receive (2f+1) replies containing the same view value. 
     In one embodiment, the view change request further includes signature information of the node. 
     In one embodiment, each node is counted one time in a counting process. 
     In one embodiment, the recovery request further includes signature information of the node to be recovered. 
     In one embodiment, the PQC reply information after the other nodes return their own stable checkpoints includes signature information of the node. 
     In one embodiment, said redoing according to the PQC reply information after the other nodes return their own stable checkpoints includes a following step of: 
     redoing PQC information at a height above the height of the stable checkpoint of the node to be recovered. 
     According to the various embodiments of the present application, a computer device is further provided, the computer device includes a memory and a processor, the memory stores a computer program, that, when being executed by the processor, causes the processor to implement the steps in the method for active failure recovery of single node improved based on PBFT algorithm. 
     According to the various embodiments of the present application, a computer readable storage medium is further provided, the storage medium stores a computer program, that, when being executed by a processor, causes the processor to implement the steps in the method for active failure recovery of a single node improved based on PBFT algorithm. 
     The present application has the beneficial effects as follows: 
     in the method of the present application, a failure recovery process of a single node is added on the basis of the PBFT algorithm, failure recovery of an abnormal node is performed according to two steps, in step one, a view change method based on a classic PBFT algorithm is used to attempt to perform the failure recovery, if the recovery is failed due to expiration, a method for failure recovery of a single node in the second step is entered, in this method, view values are updated by obtaining (2f+1) nodes containing the same view value; and the checkpoint is quickly recovered by obtaining the heights of the checkpoints of the (2f+1) nodes, so that the speed of recovery is improved. The improved method for active failure recovery of a single node based on the PBFT algorithm provided by the present application makes an improvement on the passive recovery method in case of failure in the single node in the classic PBFT algorithm, the speed of failure recovery during operation of the node is greatly improved, and the practicability of the PBFT algorithm is improved. 
    
    
     
       BRIEF DESCRIPTION OF DRAWINGS 
       In order to describe and illustrate the embodiments and/or examples of the invention disclosed herein more clearly, reference may be made to one or more figures. Additional details or examples for describing the figures should not be considered as limitations to the scope of any one of the disclosed inventions, the currently described embodiments and/or examples, as well as the best modes of the inventions that are currently understood. 
         FIG. 1  illustrates a schematic flow diagram of active recovery from abnormality of single node according to one embodiment of the present application; 
         FIG. 2  illustrates a schematic flow diagram of a method for active failure recovery of single node improved based on PBFT algorithm according to one embodiment of the present application; and 
         FIG. 3  illustrates a block diagram of an inner structure of a computer device according to one embodiment of the present application. 
     
    
    
     DESCRIPTION OF EMBODIMENTS 
     In order to facilitate understanding of the present application, and in order to make the above objectives, features, and advantages of the present application be more comprehensible, specific embodiments of the present application will be described in detail below with reference to the accompanying drawings. In the following descriptions, many technical details are illustrated in order to facilitate a thorough understanding of the present application, and some preferable embodiments are provided in the accompanying drawings. However, the present application can be implemented in many different forms and thus is not limited to the embodiments described herein. On the contrary, the objective of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosed contents of the present application. The present application can be implemented in many different methods than those described herein, and a person skilled in the art can make similar improvements without departing from the connotation of the present application, therefore, the present application is not limited by the embodiments disclosed in detail below. 
     In addition, terms “the first” and “the second” are only used for description purposes, and should not be considered as indicating or implying any relative importance, or implicitly indicating the number of indicated technical features. As such, technical feature(s) restricted by “the first” or “the second” can explicitly or implicitly includes one or more such technical feature(s). In the description of the present application, “a plurality of” means two or more, unless otherwise there is additional explicit and detailed limitation. In the descriptions of the present application, “the plurality of” means at least one, such as one, two, etc., unless otherwise there is additional explicit and detailed limitation. 
     Unless otherwise being defined, all technologies and scientific terms used herein have the same meaning as that can be commonly understood by one of ordinary skill in the technical field which the present application belongs to. The terminology used herein is only for the purpose of describing the detailed embodiments and is not intended to limit the present application. The term “and/or” used herein includes arbitrary combination and all combinations of one or more of the associated listed items. 
     As shown in  FIG. 1 , a method for active failure recovery of single node improved based on PBFT algorithm is provided, a point-to-point network containing (3f+1) nodes is required in the PBFT algorithm, Byzantine errors of F nodes at most are tolerable for this point-to-point network, the method includes following steps: 
     At step S 1 : a node operated normally is enabled to enter into an abnormal state to become an abnormal node when detecting a failure in a system due to network malfunction. 
     At step S 2 : a view change request is broadcasted to all nodes in a whole network, and a request of entering a next view is submitted by the abnormal node; where the view change request includes an ID of the node, a proposed view value of the node, a height of a stable checkpoint of the node, and PQC information of the node. 
     At step S 3 : view change requests from other nodes are waited within a predetermined period of time and a number of the view change requests are counted, and a recovery for the abnormal node is performed according to a view change recovery method in the PBFT algorithm by the abnormal node, if (2f+1) view change requests containing the same view value are received within the predetermined period of time; or the abnormal node is enabled to enter into a state to be recovered to become a node to be recovered, if (2f+1) view change requests are not received within the predetermined period of time. 
     In this step, the abnormal node attempts to make a view change firstly, if there are more than (2f+1) nodes in the whole network that are attempting to initiate a view change with the same view value, the abnormal node can complete recovery from abnormality directly through the view change method, in particular, the abnormal node determines a master node in the new view according to a view value proposed by the (2f+1) nodes in the whole network, and waits for the new master node to send a confirmation message, and complete the recovery from abnormality when the confirmation message is received; if the abnormal node fails to receive view change requests of (2f+1) nodes within a predetermined period of time, it indicates that the whole network is in a normal state, and this node is only in an abnormal state, at this time, the abnormal node directly enters a state to be recovered, and performs an autonomous recovery by means of a subsequent recovery method without using a method of continuously and repeatedly sending view change request in the original PBFT algorithm to passively wait for recovery. 
     At step S 4 : a recovery request is broadcasted to all nodes in the whole network by the node to be recovered, where the recovery request includes an ID of the node to be recovered. 
     At step S 5 : replies from other nodes are waited and a number of the replies are counted within the predetermined period of time by the node to be recovered, where each of other normal nodes returns a view value and a height of a stable checkpoint, an ID and PQC information thereof after receiving the recovery request from the node to be recovered; step S 6  is entered to perform a state recovery if the node to be recovered receives (2f+1) replies with the same view value within the predetermined period of time; or step S 4  is returned if the node to be recovered fails to receive (2f+1) replies with the same view value within the predetermined period of time. 
     Where the PQC information include a Pre-Prepare message, a Prepare message, and a Commit message. 
     At step S 6 : a height of a stable checkpoint of the whole network is calculated by the node to be recovered according to the checkpoint information returned by the (2f+1) nodes, and a recovery is performed on the checkpoint through a fast synchronization algorithm in the PBFT, and a final recovery is performed after the recovery performed on the checkpoint is completed, if the height of the stable checkpoint of the node to be recovered is lower than the height of the stable checkpoint of the whole network; or the final recovery is directly performed in step S 7  if the height of the stable checkpoint of the node to be recovered is equal to or greater than the height of the stable checkpoint of the whole network. 
     At step S 7 : a request for obtaining PQC information after the stable checkpoint is submitted to all nodes of the whole network by the node to be recovered. 
     At step S 8 : all PQC information after the stable checkpoints of the other normal nodes are returned by the other normal nodes, after the request for obtaining the PQC information is received. 
     At step S 9 : redo the PQC information by the node to be recovered according to PQC reply information received from the other normal nodes until the node to be recovered is restored to a height of normal node, so that the abnormal node is recovered. 
     Due to the fact that the PQC information is a three-stage consensus message in the PBFT algorithm, the abnormal node can be completely restored to a height of the normal node according to the PQC information. 
     According to the improved method for active failure recovery of single node based on the PBFT algorithm in the present application, the abnormal node can autonomously trigger an failure recovery process, thereby greatly reducing the time spent on failure recovery. 
     In one preferable embodiment, the view change request in the step S 2  further includes signature information of the node. 
     In one preferable embodiment, in the step S 3  and the step S 5 , a counting rule is that one node can only be counted one time, the node can only be counted one time when reply information is received multiple times from the same node at the same time within the predetermined period of time. 
     In one preferable embodiment, the recovery request in the step S 4  further includes signature information of the node to be recovered. The signature information of the node to be recovered is used to authenticate the ID of the node and prevent a malicious node from falsifying the recovery request and thus consuming the network bandwidth of the normal node accordingly. 
     In one preferable embodiment, the reply information from the other normal node in the step S 5  further includes signature information of the node. Where the signature information is used to authenticate the normal node ID of the node to be recovered to prevent the malicious node from falsifying the reply information and thus causing the node to be recovered to be unable to recover. 
     In one preferable embodiment, in the step S 9 , the node to be recovered only redoes the PQC information at a height above the height thereof so as to be avoided from a repeated execution of the same PQC after receiving the PQC reply information, thus being caused to execute an error process to enter an abnormal state again. 
     Furthermore, as shown in  FIG. 2 , a method for active failure recovery of single node improved based on PBFT algorithm disclosed in the present application can be applied to a point-to-point network including (3f+1) nodes, Byzantine errors of F nodes at most are tolerable for this point-to-point network, the method for active failure recovery of single node improved based on PBFT algorithm can be realized by the following steps: 
     At step S 110 : an abnormal node is determined, and a view change request is sent to other nodes in a whole network by the abnormal node; where the view change request is used by the abnormal node for requesting to enter a next view, the view change request includes an ID of the node, a view value proposed by the node, a height of a stable checkpoint of the node, and PQC-Set information of the node; and the PQC-Set information respectively corresponds to P-Set Q-Set, and C-Set which are defined for recovery of view change in the PBFT algorithm. 
     At step S 120 : view change requests from other nodes are waited and a number of the view change requests are counted within a first predetermined period of time, and the abnormal node is set as a node to be recovered, if (2f+1) view change requests are not received within the first predetermined period of time. 
     At step S 130 : a recovery request is sent to other nodes in a whole network by the node to be recovered, where the recovery request includes an ID of the node to be recovered. 
     At step S 140 : replies from the other nodes is waited and a number of the replies is counted in a second predetermined period of time, where each other node returns a view value and a height of a stable checkpoint, an ID, and PQC-Set information thereof after receiving the recovery request of the node to be recovered; and a state recovery is performed if (2f+1) replies containing the same view value are received within the second predetermined period of time. 
     At step S 150 : said performing the state recovery includes: a height of a stable checkpoint of the whole network is obtained according to the height of the stable checkpoint and the PQC-Set information returned by the (2f+1) nodes, a recovery is performed on the checkpoint through a fast synchronization algorithm in the PBFT, and a final recovery is performed after the recovery performed on the checkpoint is completed, if the height of the stable checkpoint of the node to be recovered is lower than the height of the stable checkpoint of the whole network; or alternatively the final recovery is performed if the height of the stable checkpoint of the node to be recovered is greater than or equal to the height of the stable checkpoint of the whole network. 
     At step S 160 : said performing the final recovery includes: PQC information after the stable checkpoint from the other nodes in the whole network is obtained by the node to be recovered, where the PQC information includes a Pre-Prepare message, a Prepare message, and a Commit message; and redo the PQC information according to the PQC reply information after the other nodes return their own stable checkpoints, until the node to be recovered is restored to the normal node. 
     In one embodiment, after the step of waiting for view change requests from other nodes and counting the number of the view change requests within the first predetermined period of time, the method further includes a following step of: 
     completing the recovery through the view change recovery method in the PBFT algorithm if (2f+1) view change requests containing the same view value are received in the first predetermined period of time. 
     In one embodiment, after the step of waiting for view change requests from other nodes and counting the number of the view change requests within the second predetermined period of time, the method further includes a following step of: 
     returning to perform the step of sending the recovery request to all other nodes in the whole network by the node to be recovered, if the node to be recovered fails to receive (2f+1) replies containing the same view value. 
     In one embodiment, the view change request further includes signature information of the node. 
     In one embodiment, each node is counted one time in a counting process. 
     In one embodiment, the recovery request further includes signature information of the node to be recovered. 
     In one embodiment, the PQC reply information after the other nodes return their own stable checkpoints includes signature information of the node. 
     In one embodiment, said redoing according to the PQC reply information after the other nodes return their own stable checkpoints includes: 
     redoing PQC information at a height above the height of the stable checkpoint of the node to be recovered. 
     In one embodiment, a computer device for performing a method for active failure recovery of single node improved based on PBFT algorithm is provided, where the computer device can be a terminal device, and an internal structure diagram of the computer device may be shown in  FIG. 3 . The computer device includes a processor, a memory, a network interface, a display screen, and an input device which are connected through a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for operating the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is configured to communicate with an external terminal through network connection. The computer program is configured to, when being executed by a processor, implements an improved method for active failure recovery of single node based on a PBFT algorithm. The display screen of the computer device may be a LCD (Liquid Crystal Display) screen or an electronic ink display screen, the input device of the computer device can be a touch layer covered on the display screen, the input device can also be a button, a trackball, or a touch pad provided on the housing of the computer device, the input device can also be an external keyboard, a touchpad or a mouse. 
     It should be understood by those skilled in the art that the structure shown in  FIG. 4  is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a definition of a generation device of a smart contract client program applied thereto, and a specific smart contract client program generation device may include more or fewer components than shown in the figures, or combine certain components, or have different component arrangements. 
     A person skilled in the art may understand that the structure shown in  FIG. 4  is merely a block diagram of a part of structure associated with the technical solutions of the present application, and does not constitute a limitation to a generation device of a smart contract client program which the technical solutions of the present application are applied in, and the specific generation device of smart contract client program can include more or less components than that shown in the figures, or combine some components, or have arrangements of components. 
     In one embodiment, a computer device is provided, the computer device includes a memory and a processor, the memory stores a computer program, when the computer program is executed by the processor, the steps in the method for active failure recovery of single node improved based on PBFT algorithm are implemented. 
     In one embodiment, a computer readable storage medium is provided, the storage medium stores a computer program, that, when being executed by a processor, causes the processor to realize the steps in the method for active failure recovery of single node improved based on PBFT algorithm. 
     The person of ordinary skilled in the art may be aware of that, a whole or a part of flow process of implementing the method in the aforesaid embodiments of the present application may be accomplished by using computer program to instruct relevant hardware. The computer program may be stored in a non-volatile computer readable storage medium, when the computer program is executed, the steps in the various method embodiments described above may be included. The non-volatile memory may include ROM (Read Only Memory), programmable ROM, EPROM (Electrically Programmable Read Only Memory), EEPROM (Electrically Erasable Programmable Read Only Memory), or flash memory. The volatile memory may include RAM (Random Access Memory) or external cache memory. By way of illustration instead of limitation, RAM is available in a variety of forms such as SRAM (Static RAM), DRAM (Dynamic RAM), SDRAM (Synchronous DRAM), DDR (Double Data Rate) SDRAM, ESDRAM (Enhanced SDRAM), Synchlink DRAM, RDRAM (Rambus Direct RAM), DRDRAM (Direct RamBus Dynamic RAM), and RDRAM (Rambus Dynamic RAM), etc. 
     The technical features in the above embodiments can be combined arbitrarily, for the sake of simplicity, not all possible combinations of the technical features in the above embodiments are described, however, as long as the combinations of these technical features do not contradict with each other, these combinations should all be considered as being included in the scope of the specification of the present application. 
     The person of ordinary skill in the art should understand that, the forgoing only describe some preferable embodiments of the present application and is not intended to limit the present application. Although the present application has been explained in detail with reference to the aforesaid embodiments, for the person of ordinary skilled in the art, the technical solutions disclosed in the embodiments can also be modified, some technical features can also be equivalently replaced; these modifications or equivalent replacements which are made in the spirit and the principle of the present application should all be included in the protection scope of the present application.