Power distribution network based on subset consensus
By adopting an architecture based on subset consensus in the distribution network, the distribution network system is divided into multiple sub-clusters. Each sub-cluster uses the PBFT algorithm internally and the Raft algorithm between sub-clusters, which solves the problem of high communication overhead in the existing technology. and does not support Byzantine fault tolerance issues, achieving a high-performance and highly fault-tolerant distribution network system.
Patent Information
- Application Number
- CN202411474831.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-01-24
AI Technical Summary
The prior art uses PBFT algorithm in the distribution network to cause high communication overhead, while using Raft algorithm does not support Byzantine fault tolerance, and cannot effectively deal with the threat of malicious nodes.
Adopting a sub -set consensus distribution network architecture, the distribution network system is divided into multiple sub -clusters. Each sub -cluster uses the PBFT algorithm to achieve the subset consensus. Cross -child consensus.
Through the subset consensus architecture, the communication overhead of a single node is reduced, the performance and fault tolerance of the system are improved, and the consistency and reliability of data can still be maintained in the face of Byzantine faults.
Smart Images

Figure CN119362431A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data consensus technology, and in particular to a distribution network based on subset consensus. Background Art
[0002] With the continuous increase in the amount of data in the distribution network and the increase in the number of nodes, the system faces the risk of malicious tampering of node data. Such tampering may cause inconsistencies in the primary and backup data, seriously affecting the reliability and stability of the system. In order to ensure the consistency of data in the primary and backup systems of the distribution network, existing technologies include PBFT (Practical Byzantine Fault Tolerance) consensus algorithm and Raft (Replication and Fault Tolerant) consensus algorithm and other technical means, which can maintain the correctness and consistency of data in the face of abnormal node behavior, and can also effectively prevent data tampering and error propagation, thereby ensuring the safe operation of the distribution network system and data reliability.
[0003] As a consensus algorithm that supports Byzantine fault tolerance, the PBFT algorithm can ensure data consistency between nodes in a static network structure, but its communication overhead is high and it is difficult to effectively cope with the computing needs of massive node access in the distribution network. In contrast, the Raft algorithm has higher consensus efficiency and less computational complexity, and is suitable for ensuring the consistency of node data in the system. However, the Raft algorithm is not suitable for Byzantine fault tolerance scenarios, that is, it cannot provide the same high security when facing malicious nodes. Summary of the invention
[0004] The present invention provides a distribution network based on subset consensus to solve the technical problems that the prior art only uses the PBFT algorithm resulting in high communication overhead and only uses the Raft algorithm without supporting Byzantine fault tolerance.
[0005] In order to solve the above technical problems, an embodiment of the present invention provides a distribution network based on subset consensus, comprising: a main cluster and a plurality of subclusters formed by devices in the distribution network;
[0006] The sub-cluster includes a master device and several backup devices, and the sub-cluster adopts the PBFT algorithm to achieve subset consensus;
[0007] The main cluster is composed of the master device of each sub-cluster, and the main cluster adopts the Raft algorithm to achieve cross-sub-cluster consensus.
[0008] As a preferred solution, the sub-cluster division method includes:
[0009] Obtain the communication bandwidth, communication delay and physical distance between two devices in the distribution network;
[0010] According to the communication bandwidth, communication delay and physical distance between two devices in the distribution network, the communication edge weight between two devices is calculated;
[0011] According to the communication edge weights between two devices in the distribution network, a weighted network graph is constructed; wherein the nodes of the weighted network graph represent the devices in the distribution network, and the edge weights are equal to the communication edge weights between the corresponding devices;
[0012] The nodes in the weighted network graph are clustered to maximize the communication modularity of the division results, thereby obtaining a plurality of the divided subclusters; wherein the communication modularity is an indicator used to measure the comprehensive communication density of all subclusters, and the communication modularity is calculated based on the communication edge weight.
[0013] As a preferred solution, the method of calculating the communication edge weight between two devices according to the communication bandwidth, communication delay and physical distance between two devices in the distribution network includes:
[0014] According to the communication bandwidth and communication delay between two devices in the distribution network, the communication capability value between two devices is calculated;
[0015] According to the communication capability value and physical distance between two devices in the distribution network, the communication edge weight between two devices is calculated.
[0016] As a preferred solution, the calculation formula of the communication edge weight is:
[0017]
[0018]
[0019] In the formula, i represents the i-th node; j represents the j-th node; M ij represents the communication edge weight between node i and node j; W ij Represents the communication capability value between node i and node j; represents the physical distance between node i and node j; B ij represents the communication bandwidth between node i and node j; represents the communication delay between node i and node j; α is the distance weight adjustment factor; β1 and β2 are the communication capacity weight adjustment factors.
[0020] As a preferred solution, the method for calculating the communication modularity includes:
[0021] Obtain the sum of weights of all edges in the weighted network, the sum of weights of all edges of each node, and the weights of edges between any two nodes;
[0022] According to the division results, determine whether any two nodes belong to the same subcluster;
[0023] The communication modularity of the partitioning result is calculated according to the judgment result, the weights of all edges in the weighted network, the sum of the weights of all edges of each node, and the weights of the edges between any two nodes.
[0024] As a preferred solution, the calculation formula of the communication modularity is:
[0025]
[0026] In the formula, ρ represents the communication modularity; m represents the sum of the weights of all edges in the weighted network; M ij represents the communication edge weight between node i and node j; k i represents the sum of the weights of all edges of node i; k j represents the sum of the weights of all edges of node j; δ(i, j) represents whether nodes i and j belong to the same subcluster, if so, δ(i, j) = 1, otherwise δ(i, j) = 0.
[0027] As a preferred solution, the method for the sub-cluster to achieve subset consensus using the PBFT algorithm includes:
[0028] After obtaining a request from a client, the master device of the sub-cluster broadcasts a pre-prepare message to all backup devices in the sub-cluster, so that each backup device broadcasts a prepare message to other nodes in the sub-cluster after receiving the pre-prepare message, broadcasts a commit message to other nodes in the sub-cluster after receiving at least a preset number of prepare messages, and sends a response to the client after receiving at least a preset number of commit messages.
[0029] As a preferred solution, the main cluster uses the Raft algorithm to achieve cross-subset consensus, including:
[0030] The global master device of the master cluster creates a new log entry according to system requirements and operation commands, and broadcasts the log entry to other master devices in the master cluster, so that other master devices return a confirmation message to the global master device after receiving the log entry; wherein the global leader is selected from all the master devices;
[0031] After receiving confirmation messages returned by more than half of the master devices, the log entry is submitted, the data status of the device is updated, and the submission result is broadcast to other master devices in the main cluster, so that other master devices synchronously update the data status of the device after receiving the submission result.
[0032] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0033] The present invention includes a main cluster and several subclusters formed by the devices in the distribution network; the subclusters include a main device and several backup devices, and the subclusters use the PBFT algorithm to achieve subset consensus; the main cluster is composed of the main devices of each subcluster, and the main cluster uses the Raft algorithm to achieve cross-subset consensus. The present invention divides the entire distribution network system into multiple subclusters, and each subcluster uses the Byzantine fault-tolerant algorithm PBFT for consensus. At the same time, the main devices in all subclusters form a main cluster, and the Raft algorithm is used in the main cluster for consensus, coordinating the operations between the subclusters, thereby ensuring that the system can still maintain consistency and reliability in the face of Byzantine faults, and also reducing the communication overhead of a single node, improving the performance and fault tolerance of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a structural diagram of a distribution network based on subset consensus provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.
[0036] Embodiment 1
[0037] Please refer to Figure 1 , is a schematic diagram of a structure of a distribution network based on subset consensus provided by an embodiment of the present invention, comprising: a main cluster and a plurality of subclusters formed by devices in the distribution network;
[0038] The sub-cluster includes a master device and several backup devices, and the sub-cluster adopts the PBFT algorithm to achieve subset consensus;
[0039] The main cluster is composed of the master device of each sub-cluster, and the main cluster adopts the Raft algorithm to achieve cross-sub-cluster consensus.
[0040] It should be noted that the entire distribution network system is divided into multiple sub-clusters, and the Byzantine fault-tolerant algorithm PBFT is used for consensus within each sub-cluster. At the same time, the main devices in all sub-clusters form a main cluster, and the Raft algorithm is used within the main cluster for consensus and coordination of operations between sub-clusters, thereby ensuring that the system can still maintain consistency and reliability in the face of Byzantine faults, reducing the communication overhead of a single node, and improving the performance and fault tolerance of the system.
[0041] In a preferred embodiment, the sub-cluster division method includes:
[0042] Obtain the communication bandwidth, communication delay and physical distance between two devices in the distribution network;
[0043] According to the communication bandwidth, communication delay and physical distance between two devices in the distribution network, the communication edge weight between two devices is calculated;
[0044] According to the communication edge weights between two devices in the distribution network, a weighted network graph is constructed; wherein the nodes of the weighted network graph represent the devices in the distribution network, and the edge weights are equal to the communication edge weights between the corresponding devices;
[0045] The nodes in the weighted network graph are clustered to maximize the communication modularity of the division results, thereby obtaining a plurality of the divided subclusters; wherein the communication modularity is an indicator used to measure the comprehensive communication density of all subclusters, and the communication modularity is calculated based on the communication edge weight.
[0046] It should be noted that the communication edge weight is an indicator used to measure the communication status between two devices. The higher the communication edge weight, the better the communication status between the two devices. The communication modularity is an indicator used to measure the comprehensive communication tightness of all sub-clusters in the partition result. It is calculated based on the cluster relationship between each device in the partition result and the communication edge weight of the device. The higher the communication modularity, the tighter the comprehensive communication of the sub-clusters in the partition result.
[0047] In this embodiment, a method for dividing device subclusters in a distribution network is provided, and a community detection algorithm based on communication modularity is used to divide the distribution network system into multiple independent subclusters. First, the communication bandwidth, communication delay and physical distance between two devices in the distribution network are collected. Then, based on the communication bandwidth, communication delay and physical distance between all devices, the communication edge weights between two devices are calculated. Next, a weighted network graph is constructed with the devices as nodes and the communication edge weights between devices as edge weights. Finally, the nodes in the weighted network graph are clustered, and the target division result is the result of maximizing the communication modularity.
[0048] The specific division process is as follows:
[0049] (1) Node initialization: All nodes are initially a community;
[0050] (2) Local optimization: For each node, try to move it to the child nodes of all neighbors and select the community that maximizes the communication modularity;
[0051] (3) Global aggregation: Merge the nodes in the communities formed in step (2) to form a new reduced network. Each new node in the reduced network represents a community in the original network.
[0052] (4) Iteration: Repeat steps (2) and (3) until the communication modularity no longer increases.
[0053] In a preferred embodiment, the step of calculating the communication edge weights between two devices according to the communication bandwidth, communication delay and physical distance between two devices in the distribution network includes:
[0054] According to the communication bandwidth and communication delay between two devices in the distribution network, the communication capability value between two devices is calculated;
[0055] According to the communication capability value and physical distance between two devices in the distribution network, the communication edge weight between two devices is calculated.
[0056] It should be noted that the communication capability value is an indicator used to measure the communication capability between two devices. The higher the communication capability value, the higher the communication capability between the two devices.
[0057] In this embodiment, a method for calculating the communication edge weight is provided. First, the communication capability value between two devices is calculated based on the communication bandwidth and communication delay between two devices in the distribution network. Then, the communication edge weight between two devices is calculated based on the communication capability value and the physical distance.
[0058] In a preferred embodiment, the calculation formula of the communication edge weight is:
[0059]
[0060]
[0061] In the formula, i represents the i-th node; j represents the j-th node; M ij represents the communication edge weight between node i and node j; W ij Represents the communication capability value between node i and node j; represents the physical distance between node i and node j; B ij represents the communication bandwidth between node i and node j; represents the communication delay between node i and node j; α is the distance weight adjustment factor; β1 and β2 are the communication capacity weight adjustment factors.
[0062] In this embodiment, a specific calculation formula for the communication edge weight is given, wherein the distance weight adjustment factor and the communication capability weight adjustment factor can be set according to the needs.
[0063] In a preferred embodiment, the method for calculating the communication modularity includes:
[0064] Obtain the sum of weights of all edges in the weighted network, the sum of weights of all edges of each node, and the weights of edges between any two nodes;
[0065] According to the division results, determine whether any two nodes belong to the same subcluster;
[0066] The communication modularity of the partitioning result is calculated according to the judgment result, the weights of all edges in the weighted network, the sum of the weights of all edges of each node, and the weights of the edges between any two nodes.
[0067] In this embodiment, a method for calculating communication modularity is provided. First, the weight sum of all edges in the weighted network (i.e., the sum of the weights of all edges), the weight sum of all edges of each node, and the weight of the edge between two nodes are confirmed and obtained. Then, based on the subcluster division result, the cluster relationship between two nodes is judged, that is, whether they belong to the same subcluster. Finally, based on the cluster relationship judgment result and the above-mentioned data obtained, the communication modularity of the division result is calculated.
[0068] In a preferred embodiment, the calculation formula of the communication modularity is:
[0069]
[0070] In the formula, ρ represents the communication modularity; m represents the sum of the weights of all edges in the weighted network; M ij represents the communication edge weight between node i and node j; k i represents the sum of the weights of all edges of node i; k j represents the sum of the weights of all edges of node j; δ(i,j) indicates whether nodes i and j belong to the same subcluster. If so, δ(i,j) = 1, otherwise δ(i,j) = 0.
[0071] In this embodiment, a specific calculation formula for the communication modularity is given.
[0072] In a preferred embodiment, the method for implementing subset consensus using the PBFT algorithm in the sub-cluster includes:
[0073] After obtaining a request from a client, the master device of the sub-cluster broadcasts a pre-prepare message to all backup devices in the sub-cluster, so that each backup device broadcasts a prepare message to other nodes in the sub-cluster after receiving the pre-prepare message, broadcasts a commit message to other nodes in the sub-cluster after receiving at least a preset number of prepare messages, and sends a response to the client after receiving at least a preset number of commit messages.
[0074] In this embodiment, a method for achieving subset consensus is provided. First, the master device obtains a request from the client and broadcasts a pre-prepare message to all backup devices in the same subcluster, where the pre-prepare message includes an operation request and a timestamp. Then, each backup node verifies the received pre-prepare message and broadcasts the prepare message to all other devices in the same subcluster. Then, after receiving a preset number of prepare messages, each backup node broadcasts a commit message to all other devices in the same subcluster. Then, after receiving a preset number of commit messages, each backup device performs an operation and sends a response to the client.
[0075] It should be noted that the consensus condition is met when the backup node receives a preset number of prepare messages. The preset number is generally 2f+1, where f is the maximum number of Byzantine fault nodes that the distribution network system can tolerate.
[0076] It should also be noted that the selection of the master device needs to comply with the characteristics of high bandwidth and low latency. When selecting the master device, the bandwidth and latency of all devices in the sub-cluster are measured and evaluated, and devices with higher bandwidth and lower latency are selected as candidate devices. Then, according to the principle of bandwidth first and latency second, the devices with the best performance are sorted and screened, and a list of master devices in the consensus process is generated, and the first device in the list is used as the initial master device. The backup device will detect the status of the master device in real time to confirm whether the master device has failed. After confirming that the master device has failed, the next device in the master device list is selected as the new master device.
[0077] In a preferred embodiment, the method in which the main cluster uses the Raft algorithm to achieve cross-subset consensus includes:
[0078] The global master device of the master cluster creates a new log entry according to system requirements and operation commands, and broadcasts the log entry to other master devices in the master cluster, so that other master devices return a confirmation message to the global master device after receiving the log entry; wherein the global leader is selected from all the master devices;
[0079] After receiving confirmation messages returned by more than half of the master devices, the log entry is submitted, the data status of the device is updated, and the submission result is broadcast to other master devices in the main cluster, so that other master devices synchronously update the data status of the device after receiving the submission result.
[0080] It should be noted that the master device in the sub-cluster is used as a node in the main cluster. One of the devices in the main cluster is selected as the global master device, which is used to handle log replication and heartbeat information transmission. Each master device can become a candidate for the global master device. The initial term number of the global leader is set to 0. If the master device does not receive the heartbeat signal of the global master device within the set election timeout period, it is considered that the current global leader may have failed, and the master device will increase its term number by 1. Each master device votes based on the term number of the candidate. When a master device initiates an election and declares itself as a candidate, the other master devices will check the term number of the candidate. If the term number of the candidate is higher than or equal to the term number of other master devices, it means that the candidate is more qualified to become the global master device, so the other master devices will vote for the candidate. Each master device can only cast one vote in each election cycle, and can only vote for a candidate whose term number is greater than or equal to its current term number. Candidates need to obtain the support of more than half of the master devices to be elected as global masters. If the candidate does not meet this condition, the election will start again.
[0081] In this embodiment, a method for achieving a subset-crossing consensus is provided. First, the global master device creates a new log entry according to the system requirements or operation commands, and broadcasts the log entry to other master devices in the main cluster. Then, after receiving the log entry, other master devices replicate it and reply to the global master device for confirmation. Next, after the global master device receives confirmation from more than half of the master devices, it performs a commit operation, marks the log entry as committed, updates the data status, and notifies the other master devices in the main cluster of the commit result. Finally, after receiving the commit result, other master devices synchronously update the data status of their own devices.
[0082] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.
Claims
1. A distribution network based on subset consensus, characterized in that: include: A main cluster and a plurality of subclusters formed by devices in the distribution network; The sub-cluster includes a master device and several backup devices, and the sub-cluster adopts the PBFT algorithm to achieve subset consensus; The main cluster is composed of the master device of each sub-cluster, and the main cluster adopts the Raft algorithm to achieve cross-sub-cluster consensus.
2. The power distribution network according to claim 1, characterized in that: The sub-cluster division method includes: Obtain the communication bandwidth, communication delay and physical distance between two devices in the distribution network; According to the communication bandwidth, communication delay and physical distance between two devices in the distribution network, the communication edge weight between two devices is calculated; According to the communication edge weights between two devices in the distribution network, a weighted network graph is constructed; wherein the nodes of the weighted network graph represent the devices in the distribution network, and the edge weights are equal to the communication edge weights between the corresponding devices; The nodes in the weighted network graph are clustered to maximize the communication modularity of the division results, thereby obtaining a plurality of the divided subclusters; wherein the communication modularity is an indicator used to measure the comprehensive communication density of all subclusters, and the communication modularity is calculated based on the communication edge weight.
3. The power distribution network according to claim 2, characterized in that: The method of calculating the communication edge weights between two devices according to the communication bandwidth, communication delay and physical distance between two devices in the distribution network includes: According to the communication bandwidth and communication delay between two devices in the distribution network, the communication capability value between two devices is calculated; According to the communication capability value and physical distance between two devices in the distribution network, the communication edge weight between two devices is calculated.
4. The power distribution network according to claim 3, characterized in that: The calculation formula of the communication edge weight is: In the formula, i represents the i-th node; j represents the j-th node; M ij represents the communication edge weight between node i and node j; W ij Represents the communication capability value between node i and node j; represents the physical distance between node i and node j; B ij represents the communication bandwidth between node i and node j; represents the communication delay between node i and node j; α is the distance weight adjustment factor; β1 and β2 are the communication capacity weight adjustment factors.
5. The power distribution network according to claim 2, characterized in that: The method for calculating the communication modularity includes: Obtain the sum of weights of all edges in the weighted network, the sum of weights of all edges of each node, and the weights of edges between any two nodes; According to the division results, determine whether any two nodes belong to the same subcluster; The communication modularity of the partitioning result is calculated according to the judgment result, the weights of all edges in the weighted network, the sum of the weights of all edges of each node, and the weights of the edges between any two nodes.
6. The power distribution network according to claim 5, characterized in that: The calculation formula of the communication modularity is: In the formula, ρ represents the communication modularity; m represents the sum of the weights of all edges in the weighted network; M ij represents the communication edge weight between node i and node j; k i represents the sum of the weights of all edges of node i; k j represents the sum of the weights of all edges of node j; δ(i, j) indicates whether nodes i and j belong to the same subcluster. If so, δ(i, j) = 1, otherwise δ(i, j) = 0.
7. The power distribution network according to claim 1, characterized in that: The method for the sub-cluster to achieve subset consensus using the PBFT algorithm includes: After obtaining a request from a client, the master device of the sub-cluster broadcasts a pre-prepare message to all backup devices in the sub-cluster, so that each backup device broadcasts a prepare message to other nodes in the sub-cluster after receiving the pre-prepare message, broadcasts a commit message to other nodes in the sub-cluster after receiving at least a preset number of prepare messages, and sends a response to the client after receiving at least a preset number of commit messages.
8. The power distribution network according to claim 1, characterized in that: The method in which the main cluster uses the Raft algorithm to achieve cross-subset consensus includes: The global master device of the master cluster creates a new log entry according to system requirements and operation commands, and broadcasts the log entry to other master devices in the master cluster, so that other master devices return a confirmation message to the global master device after receiving the log entry; wherein the global leader is selected from all the master devices; After receiving confirmation messages returned by more than half of the master devices, the log entry is submitted, the data status of the device is updated, and the submission result is broadcast to other master devices in the main cluster, so that other master devices synchronously update the data status of the device after receiving the submission result.