Leadership transfer method of alliance chain consensus mechanism for cross-domain trusted access of power business
By evaluating the stability of the follower node in the Raft alliance chain and selecting the next leading node for leadership transfer, the problem of reduced consensus efficiency and network split caused by the failure of CA nodes is solved, and the efficient and stable consensus of the Raft alliance chain is achieved.
Patent Information
- Application Number
- CN202211414490.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-11
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2042-11-11
AI Technical Summary
The existing Raft consortium chains have reduced consensus efficiency due to failure of CA nodes, and may have network splits, destroying the entire domain trust relationship.
By receiving the alliance network split probability and the state of each node, the stability of the follower node is evaluated, and the next leadership node is selected based on the reputation value, and the leadership transfer is carried out in advance to prevent network split.
Effectively prevent network splits, maintain the entire domain trust relationship of the Raft alliance chain, and improve the consensus efficiency and stability of the smart grid alliance chain.
Smart Images

Figure CN115811522B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a leadership transfer method for a consortium chain consensus mechanism for cross-domain trusted access of electric power services. Background Art
[0002] Blockchain is the underlying technology of Bitcoin. It is essentially a distributed database based on peer-to-peer networks and cryptography. It can solve the real problem of information asymmetry and achieve trust and collaboration among multiple nodes. With its decentralized, tamper-proof, and transparent transaction security features, blockchain can strengthen the decentralization of 5G networks and services, improve their security and privacy, and change their network management architecture, thereby improving service quality and 5G performance. Consensus algorithm is a key technology that determines the quality of blockchain services. Diego Ongaro proposed the Raft consensus algorithm in 2014. In the Raft consensus algorithm, data only flows from the leader to the follower, so the structure is simpler and the consensus efficiency is higher. It is widely used in smart grid alliance chains.
[0003] However, most of the current research on the Raft consensus algorithm focuses on analyzing and improving its performance. For example, analyzing the system throughput, network stability, and consistency response time of the Raft algorithm, or proposing improvements or improvements to the shortcomings of the Raft algorithm, such as introducing a new state, combining emerging technologies to improve algorithm performance, or proposing an improved consensus mechanism based on the Raft algorithm. In fact, the number of faulty CA nodes in the Raft alliance chain directly determines the consensus efficiency of the Raft alliance chain and whether it can maintain a global trust relationship, which in turn determines the stability of the Raft alliance chain.
[0004] However, the existence of faulty CA nodes seriously affects the consensus efficiency of the Raft alliance chain. Since the faulty CA nodes cannot participate in the consensus, the leader cannot receive enough follower replies during the network split. Therefore, when the number of faulty CA nodes is too large, the Raft alliance chain will experience a network split, resulting in a breakdown of the global trust relationship. There are two main reasons why followers become faulty CA nodes in the Raft alliance chain: one is that the follower has a hardware failure, and the other is that the follower may become a faulty CA node because it cannot continuously receive heartbeat packets due to unreliable transmission. Summary of the invention
[0005] The present invention provides a leadership transfer method for a consortium chain consensus mechanism with cross-domain trusted access to electric power services, which is used to solve the defects in the prior art that the Raft consortium chain consensus efficiency is affected due to the existence of faulty CA nodes, and even network splits occur, resulting in the unavailability of the Raft consortium chain. The CA node status can be predicted in advance to prevent network splits in advance, thereby ensuring that the Raft consortium chain always maintains a global trust relationship.
[0006] The present invention provides a leadership transfer method for a consortium chain consensus mechanism for cross-domain trusted access of electric power services, comprising: receiving the probability of a split of a consortium network and the state of each node in the consortium, wherein the node state comprises a follower state and a fault state; based on the consortium network split probability reaching a preset condition or based on the number of faulty nodes in a faulty state meeting a target condition, sending a credibility request to each follower node, and receiving a credibility value returned by each follower node based on the credibility request; according to each follower node and its corresponding credibility value, using a leader selection algorithm, determining a follower node as the next leader node and performing a leadership transfer.
[0007] According to a leadership transfer method for a consortium chain consensus mechanism for cross-domain trusted access to electric power services provided by the present invention, the follower node as the next leader node is determined and the leadership transfer is performed using a leader selection algorithm based on each follower node and its corresponding reputation value, including: based on the leader selection algorithm, a random number is assigned to each follower node; according to the random number assigned to each follower node and the reputation value corresponding to the follower node, a corresponding weight is obtained; and the follower node corresponding to the maximum weight is selected as the next leader node for leadership transfer.
[0008] According to a leadership transfer method for a consortium chain consensus mechanism with cross-domain trusted access to electric power business provided by the present invention, the following node corresponding to the maximum weight is selected as the next leader node for leadership transfer, including: selecting the follower node corresponding to the maximum weight as the next leader node; updating the current log to the next leader node based on a log replication mechanism; sending a power transfer message to all follower nodes to transfer leadership to the next leader node, and for the remaining follower nodes to update the next leader node to the current leader node according to the power transfer message, and the power transfer message includes the ID and address of the next leader node.
[0009] According to a leadership transfer method for a consortium chain consensus mechanism with cross-domain trusted access to electric power business provided by the present invention, when sending a power transfer message to all follower nodes, it also includes: sending a power transfer message to a faulty node, so that the faulty node cleans up its own database and restarts after receiving the power transfer message to become a follower node again.
[0010] According to a method for transferring leadership of a consortium chain consensus mechanism for cross-domain trusted access to electric power business provided by the present invention, before receiving the random number assigned to each follower node and the reputation value corresponding to the follower node to obtain the corresponding weight, it also includes: based on a preset ratio, selecting the corresponding reputation value from large to small to screen the corresponding follower node.
[0011] According to a leadership transfer method for a consortium chain consensus mechanism with cross-domain trusted access to electric power services provided by the present invention, the follower node information includes a heartbeat loss rate and an election timeout, the consortium network split probability is obtained by a network split probability prediction model based on a node predicted failure time prediction; the node predicted failure time is obtained by using a failure probability model and a local weighted linear regression algorithm based on the heartbeat loss rate and election timeout prediction of each follower node, and the node state is determined based on the node predicted failure time.
[0012] According to a leadership transfer method for a consortium chain consensus mechanism for cross-domain trusted access to electric power services provided by the present invention, the reputation value is obtained by the follower node based on its own load, delay, number of lost heartbeats and log index ratio after receiving the reputation request.
[0013] The present invention also provides a leadership transfer device for a consortium chain consensus mechanism with cross-domain trusted access to electric power services, comprising: a probability receiving module, receiving the probability of a consortium network split and the status of each node in the consortium, wherein the node status includes a follower status and a fault status; a reputation acquisition module, sending a reputation request to each follower node based on the probability of a consortium network split reaching a preset condition or the number of faulty nodes in a faulty state meeting a target condition, and receiving a reputation value returned by each follower node based on the reputation request; a leadership transfer module, determining a follower node as the next leader node and performing a leadership transfer based on each follower node and its corresponding reputation value and using a leader selection algorithm.
[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of electric power services as described in any one of the above-mentioned methods are implemented.
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access to power business as described in any of the above-mentioned methods are implemented.
[0016] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access to power business as described in any of the above-mentioned methods.
[0017] The method for transferring leadership of a consortium chain consensus mechanism for cross-domain trusted access of electric power services provided by the present invention evaluates the stability of each follower node by receiving the probability of alliance network splitting and the status of each node in the alliance, and selects the next leader node according to its reputation value, thereby performing leadership transfer in advance to prevent network splitting and maintain the global trust relationship of the Raft consortium chain; in addition, by selecting the next leader node based on the reputation value, the leader node in the smart grid consortium chain always has high stability and load capacity, thereby improving the consensus efficiency and stability of the smart grid consortium chain. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 This is one of the flow diagrams of the leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of power business provided by the present invention;
[0020] Figure 2 It is a block diagram of the leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of power business provided by the present invention;
[0021] Figure 3 This is the second flow chart of the leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of electric power business provided by the present invention;
[0022] Figure 4 It is a schematic diagram of prediction of the local weighted linear regression algorithm provided by the present invention;
[0023] Figure 5 It is a schematic diagram comparing the throughput of the Raft alliance chain with the leadership transfer mechanism provided by the present invention and the original Raft alliance chain;
[0024] Figure 6 It is a schematic diagram of error analysis of prediction results of a local weighted linear regression algorithm provided by the present invention;
[0025] Figure 7 It is a schematic diagram of the influence of the weight parameters provided by the present invention on the prediction results;
[0026] Figure 8 It is a structural schematic diagram of a leadership transfer device for a consortium chain consensus mechanism for cross-domain trusted access of electric power services provided by the present invention;
[0027] Fig. 9It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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.
[0029] Figure 1 A flow chart of a method for transferring leadership of a consortium chain consensus mechanism for cross-domain trusted access of electric power services according to the present invention is shown, and the method includes:
[0030] S11, receiving the alliance network split probability and the status of each node in the alliance, the node status includes the following status and the fault status;
[0031] S12, based on the alliance network split probability reaching a preset condition or based on the number of faulty nodes in a faulty state meeting a target condition, sending a reputation request to each follower node, and receiving a reputation value returned by each follower node based on the reputation request;
[0032] S13, according to each follower node and its corresponding reputation value, using the leader selection algorithm, determine the follower node as the next leader node and transfer the leadership.
[0033] It should be noted that the execution subject of this method is the current leader node. The S1N in this specification does not represent the order of the leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of power business. Figure 2 The present invention describes a method for transferring leadership of a consortium chain consensus mechanism for cross-domain trusted access to electric power services.
[0034] Step S11, receiving the alliance network split probability and the status of each node in the alliance, where the node status includes a following status and a fault status.
[0035] In this embodiment, the follower node information includes the heartbeat loss rate and the election timeout. The alliance network split probability is predicted by the network split probability prediction model based on the information of each follower node in the alliance, including: the alliance network split probability is obtained by the network split probability prediction model based on the node predicted failure time; the node predicted failure time is predicted based on the heartbeat loss rate and the election timeout of each follower node using the failure probability model and the local weighted linear regression algorithm. The node state is determined based on the node predicted failure time. Figure 2 .
[0036] It should be noted that in the case where there is a non-negligible heartbeat loss rate between the leader node and the follower node, the local weighted linear regression algorithm is used to predict the time when a follower node becomes a CA fault node due to continuous heartbeat loss to predict the CA node status, providing a basis for the network split probability model or relevant personnel to inspect or repair the node; the network split probability model is updated through the node predicted failure time to find the best time to start the leadership transfer, so as to predict the probability of network splitting of the Raft alliance chain at any time according to the number of CA fault nodes and the heartbeat loss rate of the follower node.
[0037] It should be noted that before using the network split probability prediction model to obtain the alliance network split probability based on the node predicted failure time, the node failure probability of the follower is calculated using MATLAB2018 according to the heartbeat loss rate and election timeout of each follower node and the pre-built network split probability prediction model; based on the node failure time when the failure probability meets the preset threshold, the input data set of the local weighted linear regression algorithm is constructed, so as to facilitate the subsequent use of the local weighted linear regression algorithm to predict the node failure time of the follower node, thereby judging the state of the corresponding node according to the predicted node predicted failure time. In this embodiment, the preset threshold can be set based on the actual design requirements, such as 0.9, which is not further limited here.
[0038] In addition, assuming that the Raft alliance chain network size is N, with 1 leader node and m normal follower nodes, there are Nm-1 CA fault nodes, Nm-1≤(N-1) / 2. The network split probability prediction model is used to predict the node predicted failure time and obtain the alliance network split probability, including:
[0039] First, the normally running followers are numbered and their node failure probabilities are mapped to the matrix. In this embodiment, in order to make the modeling more organized, the normal follower nodes are numbered 1-m, and the node failure probabilities of the m follower nodes are
[0040] Secondly, the modified total probability formula is used to calculate the probability P that the Raft alliance chain will not split at any time. N Specifically:
[0041] When the leader node sends the n+1th heartbeat, the event that i (2≤i≤(m-1) / 2) follower nodes in the Raft alliance chain become CA failure nodes is called A i , when A i The network will not split when the event occurs. i =A0∪A1∪A2∪…∪A (m-1) / 2 ;
[0042] A0 event means that no follower node in the Raft alliance chain becomes a CA fault node, and A1 means that only one follower node becomes a CA fault node. Under the premise of A1 event, the event that follower node 1 becomes a CA fault node is called A1. 11 , and so on, A1=A 11 ∪A 12 ∪……∪A 1m , we can get the probability of A1:
[0043]
[0044] A2 means that two follower nodes in the Raft alliance chain become CA fault nodes. Because different follower nodes have different heartbeat loss rates p, it is necessary to determine which two follower nodes become CA fault nodes through combination and traversal, and then calculate the probability of A2. Based on this, the order of elements and events is defined, where:
[0045] Sequentiality of elements: Map the node failure probabilities of the following nodes 1-m into a 1×m matrix and sort the matrix elements. The first element is the node failure probability of the first following node, and so on. The mapping matrix is
[0046] Sequentiality of events: When i (2≤i≤(m-1) / 2) follower nodes become CA fault nodes, it is necessary to determine which i follower nodes have become CA fault nodes. A combination method, called the combination event A ij , Starting from the first element, there is order and uniqueness between the events obtained by traversing and combining the matrix elements from front to back.
[0047] For example, in the A2 event, the event that follows nodes 1 and 2 to become CA failure nodes is A 21 , the event that follows nodes 1 and 3 to become CA failure nodes is A 22 , and so on, the event that nodes m-1 and m become CA failure nodes is The probability of event A2 occurring is:
[0048]
[0049] A (m-1) / 2 The probability of the event occurring is:
[0050]
[0051] The probability P that the Raft alliance chain network does not split N Equal to A iProbability of occurrence:
[0052]
[0053] Finally, the probability P of network splitting in the Raft alliance chain is calculated based on the probability relationship of opposing events. Y In this embodiment, when the leader sends the n+1th heartbeat, the probability of the Raft alliance chain network splitting, that is, the alliance network split probability P Y for:
[0054]
[0055] Step S12: based on the alliance network split probability reaching a preset condition or based on the number of faulty nodes in a faulty state meeting a target condition, a reputation request is sent to each follower node, and a reputation value returned by each follower node based on the reputation request is received.
[0056] In this embodiment, the preset condition may be that the probability of alliance network splitting reaches 80%, and the target condition may be that the number of CA fault nodes f=(N-1) / 2.
[0057] In addition, the reputation request includes the ID, address, term, last log index and timestamp of the current leader node; the reputation value is obtained by the follower node based on its own load, delay, number of lost heartbeats and log index ratio after receiving the reputation request. Specifically, the reputation value of the follower node is expressed as:
[0058]
[0059] Where L represents the load of the follower node, T represents the delay of the follower node, and H represents the number of lost heartbeats of the follower node. Represents the ratio of log index, M f Indicates the last log index of the followed node, M p represents the last log index of the leader node, α, β, γ, and ε represent the proportional coefficients, representing the importance of L, T, and H in the reputation value, respectively, α+β+γ+ε=100. It should be noted that the proportional coefficient can be flexibly adjusted according to actual design requirements to adapt to various application scenarios. For example, in an authentication system that requires the leader to have higher stability, the values of α and γ are increased, or in a trading system that requires the leader to have lower latency, the value of β is increased. In an optional embodiment, α=β=γ=30, ε=10.
[0060] Step S13, based on each follower node and its corresponding reputation value, using the leader selection algorithm, determine the follower node as the next leader node and transfer the leadership.
[0061] In this embodiment, according to each follower node and its corresponding reputation value, a leader selection algorithm is used to determine a follower node as the next leader node and transfer leadership, including:
[0062] First, based on the leader selection algorithm, a random number is assigned to each follower node. Specifically, after the random number is assigned to each follower node based on the leader selection algorithm, that is, before the corresponding weight is obtained according to the random number assigned to each follower node and the corresponding reputation value of the follower node, it also includes: based on a preset ratio, from large to small, the corresponding reputation value is selected to screen the corresponding follower node. Accordingly, when the random number is assigned to each follower node based on the leader selection algorithm, it includes: based on the leader selection algorithm, the random number is assigned to the screened follower node.
[0063] Secondly, the corresponding weight is obtained according to the random number assigned by each follower node and the corresponding reputation value of the follower node. In this embodiment, the weight is expressed as:
[0064] W i =z i ×Value i
[0065] Among them, W i represents the weight of the ith follower node, z i Indicates the random number assigned to the i-th follower node, Value i Represents the reputation value of the i-th follower node.
[0066] Finally, the follower node with the largest weight is selected as the next leader node for leadership transfer. Figure 3 , select the follower node corresponding to the maximum weight as the next leader node to transfer leadership, including: select the follower node corresponding to the maximum weight as the next leader node Leader = max(W i ); based on the log replication mechanism, update the current log to the next leader node; send a power transfer message to all follower nodes to transfer leadership to the next leader node, and for the remaining follower nodes to update the next leader node to the current leader node according to the power transfer message, and the power transfer message includes the ID and address of the next leader node.
[0067] It should be noted that when a power transfer message is sent to all follower nodes, the next leader node, which has the same ID and address as those in the power transfer message, increases its own term and sends heartbeats to other follower nodes to establish leadership authority; the current leader node stops processing client requests, transfers power to the next leader node and returns to the follower state; the remaining follower nodes, whose IDs and addresses are different from those in the power transfer message, set the next leader node as the leader node according to the ID and address in the leadership transfer message, increase their own term, and maintain the follower state.
[0068] In an optional embodiment, since the term of the failed node is greater than that of the new leader node, it cannot return to the follower state after receiving the heartbeat of the new leader node. Therefore, when sending the power transfer message to all follower nodes, it also includes: sending the power transfer message to the failed node so that the failed node can clean up its own database and restart after receiving the power transfer message to become a follower node again. It should be added that after the failed node is called a follower node again, the current leader node updates its log through a consistency check.
[0069] In an optional embodiment, after the follower node is determined as the next leader node for leadership transfer based on each follower node and its corresponding reputation value using a leader selection algorithm, it also includes: after the leadership transfer is completed, the Raft alliance chain can perform log replication normally.
[0070] It should be noted that in the prior art, little attention has been paid to the stability of the Raft algorithm, and there is a lack of relevant research on the unavailability of the Raft alliance chain caused by network splits. The present invention predicts the node failure time of each follower node and then determines the CA node status under the condition that each follower node in the Raft alliance chain has a different heartbeat loss rate p and election timeout k. The probability of network splitting in the Raft alliance chain at any time is calculated through a network split probability model. When the network split probability is too high or the number of CA fault nodes is too large, the network is prevented from splitting by transferring leadership, thereby improving the consensus efficiency and stability of the Raft alliance chain, so that the Raft alliance chain always maintains a global trust relationship.
[0071] In an optional embodiment, the algorithm of the present invention is simulated to verify its performance and compare its throughput with the original Raft alliance chain. The leadership transfer method of the present invention is to transfer leadership when the number of CA fault nodes in the Raft alliance chain reaches half of the original number of follower nodes, so that the CA fault nodes rejoin the Raft alliance chain, solving the problem that the Raft alliance chain has too many CA fault nodes, resulting in low consensus efficiency and even network splitting.
[0072] In the simulation experiment of predicting node failure time with local weighted regression algorithm, the simulation sets each follower node in the Raft alliance chain to have a different heartbeat loss rate p and election timeout k, so each follower node has a different node failure probability and node failure time. Assuming the heartbeat interval is 100ms, the present invention sets the election timeout range to 300ms-699ms, that is, k=3, 4, 5, 6. When the heartbeat loss rate p of a follower node is 0.2, even if k=6, it will become a CA failure node after about 46,000 heartbeats (about 1.3 hours), so the present invention sets the heartbeat loss rate range to 0-0.2. The data set features and labels are shown in the table below, which contains 420 data in total. The development environment can be Python 3.8.
[0073]
[0074] In the leadership transfer simulation experiment, the development environment is LinuxMint19.3 / Golang1.14.3. Throughput is defined as the number of transactions processed per second by the system, denoted as TPS. In the blockchain, TPS is expressed as the ratio of the number of transactions M to the corresponding time t:
[0075]
[0076] The client sends a request every 50ms. All requests are collected and packaged by the leader node to generate blocks, and the BoltDB database is used to persistently store block data and record the number of transactions M and the corresponding time t. The present invention adds a leadership transfer mechanism to the original Raft algorithm. The current leader node will actively transfer leadership when the number of CA fault nodes is f.
[0077] In order to verify that the leadership transfer method can improve the consensus efficiency of the Raft alliance chain, the present invention compares the throughput of the Raft alliance chain with the leadership transfer mechanism and the original Raft alliance chain.
[0078] pass Figure 4 Prediction graph and local weighted linear regression algorithm Figure 5 The throughput comparison chart of the Raft alliance chain with the leadership transfer mechanism and the original Raft alliance chain shows that:
[0079] (1) Most of the data points are located on or around the predicted regression curve. In order to more accurately evaluate the prediction results, the present invention performs error analysis. First, the accuracy of the prediction results is evaluated by the relative error dr between the predicted results and the actual values, which is expressed as:
[0080]
[0081] Among them, yi is the actual value, For the prediction results.
[0082] The analysis results are as follows Figure 6 , the present invention believes that when dr≤0.1, the prediction result is more accurate, so the prediction accuracy can be calculated by the following formula. When k=3, 4, 5 and 6, the accuracy rates are 82.7%, 92.3%, 81.5% and 86.5% respectively, and the overall accuracy rate is 85.7%. Ω(k=i) is the sample space when k=i:
[0083]
[0084] Secondly, the sum of the mean square error r is used to analyze the impact of the weight parameter τ on the prediction results:
[0085]
[0086] The analysis results are as follows Figure 7 As shown, Sr is the training set error and Tr is the test set error. When τ ≥ 0.001, Sr and Tr will increase with the increase of τ. This is because the difference between node failure times is too large. If too many data points are considered, a larger error will be introduced. When 0.00008 ≤ τ ≤ 0.001, there is no specific rule for the change in error size. This is because different data sets are suitable for different τ, and the appropriate τ must be selected to obtain the best prediction results. In addition, when τ = 0.00008 and τ = 0.0002, Sr and Tr are the same for all data sets. Therefore, when k = 3, 5, 6, the present invention sets τ = 0.0002, and when k = 4, the present invention sets τ = 0.001.
[0087] (2) The maximum fault tolerance of the Raft consortium chain is f = (N-1) / 2. When N = 5, 7, 9, 11, 13, f = 2, 3, 4, 5, 6. Figure 5 It can be seen that in the original Raft alliance chain, when the number of CA fault nodes is f, the throughput drops sharply, with specific values of 43, 44, 42, 43, and 26. In the Raft alliance chain with the leadership transfer mechanism, when the number of CA fault nodes is f, the leader node transfers the leadership, and the CA fault node also rejoins the Raft alliance chain as a follower, which means that there is no CA fault node in the Raft alliance chain after the leadership transfer. Therefore, when the CA fault node reaches the maximum fault tolerance of the Raft alliance chain, the Raft alliance chain with the leadership transfer mechanism significantly improves the throughput of the original Raft alliance chain. When N=13 and f=6, the throughput of the Raft alliance chain with the leadership transfer mechanism is about 500 times higher than that of the original Raft alliance chain.
[0088] comprehensive Figure 4 and Figure 5 It can be found that the local weighted linear regression algorithm is relatively accurate in predicting node failure time, with an accuracy rate of up to 85.7%. The leadership transfer method applicable to the Raft algorithm can also significantly improve the throughput of the Raft alliance chain.
[0089] In summary, the embodiment of the present invention evaluates the stability of each follower node through the received alliance network split probability and the status of each node in the alliance, and selects the next leader node according to its reputation value, so as to transfer leadership in advance to prevent network splitting and maintain the global trust relationship of the Raft alliance chain; in addition, by selecting the next leader node based on the reputation value, the leader node in the smart grid alliance chain always has a high stability and load capacity, thereby improving the consensus efficiency and stability of the smart grid alliance chain.
[0090] The following describes the leadership transfer device of the alliance chain consensus mechanism for cross-domain trusted access to the electric power business provided by the present invention. The leadership transfer device of the alliance chain consensus mechanism for cross-domain trusted access to the electric power business described below and the leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access to the electric power business described above can be referenced to each other.
[0091] Figure 8 A schematic diagram of a leadership transfer device for a consortium chain consensus mechanism with cross-domain trusted access to electric power services is shown, the device comprising:
[0092] The probability receiving module 81 receives the alliance network split probability, which is predicted by the network split probability prediction model based on the information of each follower node in the alliance;
[0093] The reputation acquisition module 82 sends a reputation request to each follower node based on the alliance network split probability reaching a preset condition, and receives the reputation value returned by each follower node based on the reputation request;
[0094] The leadership transfer module 83 determines the follower node as the next leader node and performs leadership transfer according to each follower node and its corresponding reputation value using a leader selection algorithm.
[0095] In this embodiment, the device also includes: a node prediction module, which uses a fault probability model and a local weighted linear regression algorithm to predict the heartbeat loss rate and election timeout of each follower node to obtain a node predicted fault time; a state determination module, which obtains the node state based on the node predicted fault time; and an alliance split prediction module, which uses the node predicted fault time to update a pre-built network split probability prediction model to obtain the alliance network split probability.
[0096] Furthermore, the alliance split prediction module includes: a mapping unit, which numbers the followers that operate normally and maps their node failure probabilities into a matrix; a first probability acquisition unit, which uses a deformed total probability formula to calculate the probability that the Raft alliance chain will not split at any time; and a second probability acquisition unit, which calculates the probability of the Raft alliance chain splitting according to the probability relationship between opposing events.
[0097] The leadership transfer module 83 includes: an allocation unit, which allocates random numbers to each follower node based on the leader selection algorithm; a weight acquisition unit, which obtains the corresponding weight according to the random number allocated to each follower node and the reputation value corresponding to the follower node; and a leadership transfer unit, which selects the follower node corresponding to the maximum weight as the next leader node for leadership transfer.
[0098] Furthermore, the leadership transfer module 83 also includes: a screening unit, which selects corresponding credibility values from large to small based on a preset ratio to screen corresponding follower nodes to obtain candidate follower nodes; accordingly, an allocation unit, which allocates random numbers to the screened follower nodes based on a leader selection algorithm.
[0099] In addition, the leadership transfer unit includes: a leadership node selection subunit, which selects the follower node corresponding to the maximum weight as the next leadership node; a log update subunit, which updates the current log to the next leadership node based on the log replication mechanism; a first message sending subunit, which sends a power transfer message to all follower nodes to transfer leadership to the next leadership node, and for the remaining follower nodes to update the next leadership node to the current leadership node according to the power transfer message, and the power transfer message includes the ID and address of the next leadership node.
[0100] It should be noted that when a power transfer message is sent to all follower nodes, the next leader node, which has the same ID and address as those in the power transfer message, increases its own term and sends heartbeats to other follower nodes to establish leadership authority; the current leader node stops processing client requests, transfers power to the next leader node and returns to the follower state; the remaining follower nodes, whose IDs and addresses are different from those in the power transfer message, set the next leader node as the leader node according to the ID and address in the leadership transfer message, increase their own term, and maintain the follower state.
[0101] In an optional embodiment, the leadership transfer unit further includes: a second message sending subunit, which sends a power transfer message to the faulty node, so that the faulty node cleans up its own database and restarts after receiving the power transfer message to become a follower node again.
[0102] In an optional embodiment, the device further includes: a log replication module, after the leadership transfer is completed, the Raft alliance chain can perform log replication normally.
[0103] In summary, the embodiment of the present invention receives the probability of alliance network split and the status of each node in the alliance through the probability receiving module to evaluate the stability of each follower node, and then uses the probability receiving module to select the next leader node according to its reputation value, so as to perform leadership transfer in advance through the leadership transfer module to prevent network splitting and maintain the global trust relationship of the Raft alliance chain; in addition, by selecting the next leader node based on the reputation value, the leader node in the smart grid alliance chain always has a higher stability and load capacity, thereby improving the consensus efficiency and stability of the smart grid alliance chain.
[0104] Fig. 9 An example of a physical structure diagram of an electronic device is shown in FIG. Fig. 9 As shown, the electronic device may include: a processor 91, a communication interface 92, a memory 93 and a communication bus 94, wherein the processor 91, the communication interface 92 and the memory 93 complete mutual communication through the communication bus 94. The processor 91 may call the logic instructions in the memory 93 to execute the alliance chain consensus mechanism leadership transfer method for cross-domain trusted access of the power business, the method comprising: receiving the alliance network split probability, which is obtained by the network split probability prediction model based on the information of each follower node in the alliance; based on the alliance network split probability reaching the preset condition, sending a reputation request to each follower node, and receiving the reputation value returned by each follower node based on the reputation request; according to each follower node and its corresponding reputation value, using the leader selection algorithm, determining the follower node as the next leader node and transferring the leadership.
[0105] In addition, the logic instructions in the above-mentioned memory 93 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0106] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the alliance chain consensus mechanism leadership transfer method for cross-domain trusted access of power services provided by the above methods, and the method includes: receiving the alliance network split probability, which is a network split probability prediction model predicted based on the information of each follower node in the alliance; based on the alliance network split probability reaching a preset condition, sending a credibility request to each follower node, and receiving the credibility value returned by each follower node based on the credibility request; according to each follower node and its corresponding credibility value, using a leader selection algorithm, determine the follower node as the next leader node and transfer leadership.
[0107] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the alliance chain consensus mechanism leadership transfer method for cross-domain trusted access of power services provided by the above-mentioned methods. The method includes: receiving the alliance network split probability, which is predicted by a network split probability prediction model based on information of each follower node in the alliance; based on the alliance network split probability reaching a preset condition, sending a credibility request to each follower node, and receiving a credibility value returned by each follower node based on the credibility request; according to each follower node and its corresponding credibility value, using a leader selection algorithm, determining the follower node as the next leader node and transferring leadership.
[0108] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0109] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0110] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for transferring leadership of a consortium chain consensus mechanism for cross-domain trusted access of electric power services, characterized in that: include: receiving the alliance network split probability and the state of each node in the alliance, wherein the node state includes a following state and a fault state; Based on the alliance network split probability reaching a preset condition or based on the number of faulty nodes in a faulty state meeting a target condition, sending a reputation request to each follower node, and receiving a reputation value returned by each follower node based on the reputation request; According to each of the follower nodes and their corresponding reputation values, a leader selection algorithm is used to determine a follower node as the next leader node and transfer leadership; The following step of determining the follower node as the next leader node and transferring the leadership right by using the leader selection algorithm according to the follower nodes and their corresponding reputation values includes: Based on the leader selection algorithm, assigning a random number to each of the follower nodes; Obtaining a corresponding weight according to the random number assigned by each follower node and the reputation value corresponding to the follower node; Select the follower node corresponding to the maximum weight as the next leader node for leadership transfer; In addition, the follower node information includes a heartbeat loss rate and an election timeout; the alliance network split probability is obtained by a network split probability prediction model based on a node predicted failure time; the node predicted failure time is obtained by using a failure probability model and a local weighted linear regression algorithm based on the heartbeat loss rate and election timeout prediction of each follower node; and the node state is determined based on the node predicted failure time.
2. The leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of power business according to claim 1 is characterized in that: The step of selecting the follower node corresponding to the maximum weight as the next leader node for transferring leadership rights includes: Select the follower node corresponding to the maximum weight as the next leader node; Based on the log replication mechanism, the current log is updated to the next leader node; A power transfer message is sent to all follower nodes to transfer leadership to the next leader node, and the remaining follower nodes update the next leader node to the current leader node according to the power transfer message, wherein the power transfer message includes the ID and address of the next leader node.
3. The leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of power business according to claim 2 is characterized in that: When sending the power transfer message to all follower nodes, it also includes: A power transfer message is sent to the failed node, so that the failed node can clean up its own database and restart after receiving the power transfer message, so as to become a follower node again.
4. The leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of power business according to claim 1 is characterized in that: Before obtaining the corresponding weight according to the random number assigned by each follower node and the reputation value corresponding to the follower node, the method further includes: Based on the preset ratio, select the corresponding reputation value from large to small to filter the corresponding follower nodes.
5. The leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of power business according to claim 1 is characterized in that: The reputation value is obtained by the follower node based on its own load, delay, number of lost heartbeats and log index ratio after receiving the reputation request.
6. A leadership transfer device for alliance chain consensus mechanism with cross-domain trusted access to power business, characterized in that: include: A probability receiving module receives the alliance network split probability and the status of each node in the alliance, wherein the node status includes a following status and a fault status; A reputation acquisition module, which sends a reputation request to each of the follower nodes based on the alliance network split probability reaching a preset condition or based on the number of faulty nodes in a faulty state meeting a target condition, and receives a reputation value returned by each of the follower nodes based on the reputation request; A leadership transfer module, based on each of the follower nodes and their corresponding reputation values, uses a leader selection algorithm to determine a follower node as the next leader node for leadership transfer; The following step of determining the follower node as the next leader node for the leadership transfer by using a leader selection algorithm according to each follower node and its corresponding reputation value includes: Based on the leader selection algorithm, assigning a random number to each of the follower nodes; Obtaining a corresponding weight according to the random number assigned by each follower node and the reputation value corresponding to the follower node; Select the follower node corresponding to the maximum weight as the next leader node for leadership transfer; In addition, the follower node information includes a heartbeat loss rate and an election timeout; the alliance network split probability is obtained by a network split probability prediction model based on a node predicted failure time; the node predicted failure time is obtained by using a failure probability model and a local weighted linear regression algorithm based on the heartbeat loss rate and election timeout prediction of each follower node; and the node state is determined based on the node predicted failure time.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of power business as described in any one of claims 1 to 5 are implemented.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, the steps of the leadership transfer method of the alliance chain consensus mechanism for cross-domain trusted access of power business as described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Leader node election method and system, storage medium and equipment
CN114189421A