A pbft grouping optimization consensus method for internet of things

CN122994328APending Publication Date: 2026-10-27GANNAN UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410461554.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-17
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

[0004](1)资源限制:现有证明类共识算法需通过大量算力来获取记账权且共识过程中需要消耗大量计算资源,共识交易处理速度慢,不适用于物联网场景

Benefits of technology

[0045]本发明针对当前大规模物联网与区块链融合场景下,因物联网节点资源限制导致的PBFT算法通信开销大、安全性差等问题,提供一种面向物联网的PBFT分组优化共识方法。首先,根据节点性能和信用值综合评估物联网节点质量,筛选出符合场景需求的节点参与共识。其次,基于节点物理位置和综合评估值将节点进行分组聚类,减少资源限制造成的通信开销问题。最后,将共识任务分解到组内和组间执行,同时组内采用三路快速分组的思想进行共识,组间由每组中心相互确认组内共识结果,进一步减少共识规模,提升共识积极性和安全性,从而整体提升效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122994328A_ABST
    Figure CN122994328A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of consensus algorithm in block chain, and discloses a PBFT grouping optimization consensus method for Internet of Things, which comprises the following steps: before starting each round of consensus, obtaining the comprehensive evaluation value of nodes and the physical network coordinates of nodes; selecting the nodes with high comprehensive evaluation value as central nodes, calculating the distance between the remaining nodes and the central nodes through the physical network coordinates of the nodes, and uniformly dividing the remaining nodes into multiple groups according to the nearest distance principle, each group forming a sub-group, and all the central nodes forming a main group; the sub-group adopts a three-way fast sorting method based on the comprehensive evaluation value to conduct intra-group consensus, and after the intra-group consensus reaches an agreement, the central nodes in the main group confirm the intra-group consensus result to complete inter-group consensus; and according to the behavior of the nodes in this round of consensus, the comprehensive evaluation value of the nodes is updated to complete one round of consensus. The application improves the consensus initiative, safety and efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of consensus algorithm technology in blockchain, and in particular to a PBFT (Practical Byzantine Fault Tolerance) group optimization consensus method for the Internet of Things. Background Technology

[0002] In recent years, with the continuous development of IoT technology, the number of IoT devices has grown exponentially. The core foundation of IoT remains the internet, extending and expanding upon it to enable information exchange and communication between objects. However, IoT devices typically have limited computing power and storage resources, and are often geographically distributed, making them vulnerable to security threats. With the application of blockchain technology in peer-to-peer networks, applying core blockchain technologies such as consensus mechanisms, cryptography, and smart contracts to IoT scenarios can effectively solve problems such as high cost, low performance, poor scalability, and low security of central IoT devices.

[0003] In current scenarios combining blockchain and the Internet of Things (IoT), mainstream consensus algorithms have the following three shortcomings when applied to IoT:

[0004] (1) Resource limitations: Existing proof-based consensus algorithms require a large amount of computing power to obtain the right to record transactions, and the consensus process consumes a lot of computing resources, resulting in slow consensus transaction processing speed, which is not suitable for IoT scenarios. In addition, IoT devices have limited resources and cannot supply a large amount of energy for consensus.

[0005] (2) Communication complexity: Existing election-based consensus algorithms also face the problem of limited resources when large-scale IoT nodes are connected. However, the more serious problem is the high communication complexity. The complex consensus process leads to slower response speed and low efficiency of IoT devices.

[0006] (3) Poor security: Existing credit-based consensus algorithms improve the security of the consensus process to a certain extent by conducting credit assessments of nodes and reduce the complexity of consensus communication by using credit grouping. However, they ignore the fact that in specific IoT scenarios, cloud nodes are distributed in different geographical locations according to IoT needs. Therefore, when grouping by credit, the physical location of the nodes must be considered to achieve optimal network coverage and functionality.

[0007] Based on the above analysis, it is evident that IoT systems contain a large number of low-power devices that are widely distributed. However, consensus algorithms suitable for private and public blockchains have low decentralization levels. Therefore, consortium blockchain consensus algorithms are more suitable for IoT scenarios. Among consortium blockchain consensus algorithms, the PBFT algorithm is considered one of the most suitable for IoT due to its tolerance for a certain number of node failures and malicious attacks. Furthermore, compared to competing consensus algorithms such as PoW, the PBFT algorithm is also more efficient.

[0008] Therefore, using the PBFT algorithm to optimize the consensus process of IoT nodes can effectively solve the problems of poor security and high communication complexity in the consensus process of nodes in large-scale IoT scenarios, which lead to low consensus efficiency. This algorithm represents a new research direction combining blockchain consensus technology and IoT technology. Summary of the Invention

[0009] The purpose of this invention is to provide a PBFT group optimization consensus method for the Internet of Things, which improves consensus enthusiasm and security, and enhances consensus efficiency.

[0010] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0011] A PBFT packet optimization consensus method for the Internet of Things (IoT), comprising:

[0012] Step S1, Node Quality Assessment: Before the start of each round of consensus, obtain the comprehensive assessment value of the node and the physical network coordinates of the node. The comprehensive assessment value includes the comprehensive credit assessment value and the comprehensive performance assessment value of the node.

[0013] Step S2, Node Distance Grouping: Select the top preset number of nodes with high comprehensive evaluation values ​​as center nodes. Each center node is the center of a group. Calculate the distance between the remaining nodes and the center nodes using the physical network coordinates of the nodes. Divide the remaining nodes evenly into multiple groups according to the principle of closest distance. Each group forms a subgroup, and all center nodes form a main group.

[0014] Step S3, consensus within and outside the node group: The subgroup adopts the optimized three-way fast sorting group consensus method based on the comprehensive evaluation value to achieve consensus within the group. After the consensus within the group is reached, the central nodes in the main group confirm the consensus result within the group to complete the consensus between the groups.

[0015] Step S4: Update node information: Based on the behavior of the nodes in this round of consensus, update the comprehensive evaluation value of the nodes to complete a round of consensus.

[0016] Several alternative methods are provided below, but they are not intended as additional limitations on the overall solution above. They are merely further additions or optimizations. Provided there are no technical or logical contradictions, each alternative method can be combined individually with respect to the overall solution above, or multiple alternative methods can be combined with each other.

[0017] Preferably, the formula for calculating the comprehensive evaluation value is as follows:

[0018] R i =ξ1E i +ξ2C i (1)

[0019] In the formula, R i E represents the overall evaluation value of node i. i C represents the overall performance evaluation value of node i. i Let ξ1 represent the comprehensive credit assessment value of node i, and let ξ2 represent the comprehensive performance assessment weight.

[0020] The formula for calculating the comprehensive performance evaluation value is as follows:

[0021]

[0022]

[0023] E i =σ1E_onl i +σ2E_ans i (4)

[0024] In the formula, E_onl i t represents the online evaluation value of node i. oi E_ans represents the online duration of node i. i t represents the response evaluation value of node i. ai σ1 represents the response time of node i, σ2 represents the online evaluation weight of the node, and σ2 represents the response evaluation weight of the node.

[0025] The formula for calculating the comprehensive credit assessment value is as follows:

[0026]

[0027]

[0028]

[0029] In the formula, C_dir i Num_c represents the direct credit value of node i. i Num_c represents the number of times node i has successfully completed consensus. sThe ratio of Num_v to the total number of times node i participates in consensus represents the consensus credibility of node i, where λ is the consensus credibility weight. i This indicates the number of times node i successfully completed its vote, Num_v s The ratio of C_idir to the total number of votes participated in by node i represents the voting credibility of node i, μ is the voting credibility weight, and C_idir represents the voting credibility weight. i Num_GP represents the indirect credit value of node i. i Num_GC represents the number of times node i exists in the master node group. i C_rank represents the number of times node i exists in the consensus node group, γ is the weight of the number of times node i exists in the master node group, α is the weight of the node activity evaluation, and C_rank represents the number of times node i exists in the consensus node group. i C represents the overall credit assessment value of node i. i Rank, where n is the number of nodes in each group, N represents the total number of nodes, β is the node motivation evaluation weight, and C_his i Let η be the historical comprehensive credit assessment value of node i, and η be the historical comprehensive credit assessment weight.

[0030] Preferably, the calculation of the distance between the remaining nodes and the central node using the physical network coordinates of the nodes includes:

[0031]

[0032] In the formula, d ij Represents the distance between node i and node j, (x i ,y i (x) represents the physical network coordinates of node i. j ,y j ) represents the physical network coordinates of node j, where one of node i and node j is the center node.

[0033] Preferably, the step of evenly dividing the remaining nodes into multiple groups according to the principle of nearest distance includes:

[0034] Each central node forms a group. The node to be grouped is taken and added to the group containing the nearest central node. If the number of nodes in the nearest group exceeds N / K or the proportion of nodes with a comprehensive evaluation value of less than 0.3 in the group exceeds 1 / 3, the node to be grouped is added to the next nearest group. The nodes to be grouped are processed in turn until the node grouping is completed. Here, N represents the total number of nodes and K represents the number of central nodes.

[0035] Preferably, the subgroups employ an optimized three-way fast sorting group consensus method based on comprehensive evaluation values ​​for intra-group consensus. After intra-group consensus is reached, the central nodes within the main group mutually confirm the intra-group consensus results to complete inter-group consensus, including:

[0036] After receiving a request from a client, the central node of the group divides the nodes within the group into a master node group, a consensus node group, and an observer node group based on a comprehensive evaluation value.

[0037] The central node of the group initiates a voting request. The nodes in the consensus node group and the nodes in the observation node group vote together for the nodes in the master node group. The node with the most votes in the master node group is elected as the consensus master node in this round.

[0038] After the consensus master node within the group is selected, the group-wide PBFT group consensus process begins. Nodes within the master node group and consensus nodes within the group participate in the consensus. The consensus master node sends a pre-preparation message to other participating consensus nodes. Upon receiving the pre-preparation message, other consensus nodes verify its validity. Nodes whose pre-preparation messages pass verification enter the preparation phase and send preparation messages to other participating consensus nodes; otherwise, they do not send preparation messages. Consensus nodes receiving preparation messages verify their validity. If a consensus node's verification passes, the preparation message is written to its log. This process continues until at least two consensus nodes within the group have participated. 内 After the preparation message is verified by each node, the consensus node enters the response phase; the consensus node in the response phase sends a response message to the group's central node. If the group's central node has collected at least f messages from within the group... 内 If a response message is received from +1 consensus node, the group consensus is successful; otherwise, the group consensus fails. Where f... 内 The threshold for the number of Byzantine nodes within the group;

[0039] Once all groups have reached a consensus, the central nodes of each group broadcast confirmation messages to each other. When each central node collects 2f... 外 After receiving confirmation messages from +1 central node, inter-group consensus is successful; otherwise, it fails. Subsequently, the central node sends the consensus result back to the client, completing the current round of consensus. Where f... 外 This is the threshold for the number of Byzantine nodes outside the group.

[0040] Preferably, the step of dividing the nodes within the group into a master node group, a consensus node group, and an observer node group based on a comprehensive evaluation value includes:

[0041] Nodes with a comprehensive evaluation value in the range (0.8,1) are classified as master nodes, nodes with a comprehensive evaluation value in the range [0.3,0.8] are classified as consensus nodes, and nodes with a comprehensive evaluation value in the range [0,0.3) are classified as observer nodes.

[0042] Preferably, the formula for calculating the votes of each node in the master node group is as follows:

[0043] Sum_v i =Pc Sumv_GC i +P o Sumv_GO i (9)

[0044] In the formula, Sum_v i Sumv_GC represents the final vote count received by node i within the master node group. i Sumv_GO represents the total number of votes cast by nodes in the consensus node group for node i. i P represents the total number of votes cast by nodes in the observation node group for node i. c P represents the voting weight of the consensus node group. o P represents the voting weight of the observation node group. c +P o =1, and P c >P o .

[0045] This invention addresses the problems of high communication overhead and poor security in the PBFT algorithm caused by resource constraints of IoT nodes in current large-scale IoT and blockchain integration scenarios. It provides a PBFT grouping optimization consensus method for IoT. First, the quality of IoT nodes is comprehensively evaluated based on node performance and credit value to select nodes that meet the scenario requirements for consensus participation. Second, nodes are grouped and clustered based on their physical location and comprehensive evaluation value to reduce communication overhead caused by resource constraints. Finally, the consensus task is decomposed into intra-group and inter-group execution. Within each group, a three-way fast grouping approach is used for consensus, while between groups, each group's central member confirms the consensus results, further reducing the consensus scale, improving consensus engagement and security, and thus improving overall efficiency. Attached Figure Description

[0046] Figure 1 This is a topology diagram of a large-scale Internet of Things application scenario involved in this invention;

[0047] Figure 2 This is a flowchart of a PBFT packet optimization consensus method for the Internet of Things provided by the present invention;

[0048] Figure 3 This is a general model diagram of a PBFT packet optimization consensus method for the Internet of Things provided by this invention;

[0049] Figure 4 This is a schematic diagram of the IoT node distance grouping process of the present invention;

[0050] Figure 5 This is a schematic diagram of the consensus process of this invention;

[0051] Figure 6 This is a schematic diagram of the grouping process within the group of the present invention;

[0052] Figure 7 This is a graph showing the communication overhead ratio between the method of this invention and the original PBFT algorithm (the percentage of observed nodes in each group, c, remains constant, while the number of system nodes N and the number of groups K change).

[0053] Figure 8 This is a graph showing the communication overhead ratio between the method of this invention and the original PBFT algorithm (the number of system nodes N remains constant, while the percentage of observed nodes c and the number of groups K change). Detailed Implementation

[0054] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to limit the invention.

[0056] like Figure 1 As shown, a classic large-scale IoT application scenario is constructed, and research is conducted on this scenario. Most specific IoT network applications are extensions of this. In large-scale, dense wireless network scenarios, the IoT network may contain a large number of nodes, including edge nodes, gateway nodes, and cloud nodes. Edge nodes are typically directly connected to physical devices (such as sensors, actuators, etc.), collecting data and performing local processing. Edge nodes usually do not participate in the consensus process, but instead send data to gateway nodes or directly to cloud nodes via communication links. Gateway nodes: Gateway nodes are typically connected to multiple edge nodes, collecting and processing data from multiple edge nodes. Gateway nodes may participate in the consensus process to ensure data integrity and accuracy. Cloud nodes: Cloud nodes are typically connected to multiple gateway nodes or other cloud nodes, receiving and processing data from multiple nodes. Cloud nodes typically participate in the consensus process to ensure data integrity and accuracy. Various communication protocols are typically used between these nodes to exchange information, and encryption technologies may be used to ensure data security and privacy.

[0057] like Figure 2As shown in the figure, this embodiment provides a PBFT grouping optimization consensus method for the Internet of Things (IoT). After grouping IoT nodes according to their actual physical locations, the method further groups the nodes within each group using a three-way fast grouping approach based on comprehensive evaluation. The specific steps include:

[0058] Step S1, Node Quality Assessment: Before each round of consensus begins, obtain the comprehensive assessment value of the node and the physical network coordinates of the node.

[0059] The physical network coordinates are obtained through wireless network positioning technology, and the comprehensive evaluation value includes the node's comprehensive credit evaluation value and the node's comprehensive performance evaluation value. The specific calculation formula is as follows:

[0060] R i =ξ1E i +ξ2C i (1)

[0061] In the formula, R i E represents the overall evaluation value of node i. i C represents the overall performance evaluation value of node i. i Let ξ1 represent the comprehensive credit assessment value of node i, ξ2 represent the comprehensive performance assessment weight, and ξ3 represent the comprehensive credit assessment weight.

[0062] The formula for calculating the comprehensive performance evaluation value is as follows:

[0063]

[0064]

[0065] E i =σ1E_onl i +σ2E_ans i (4)

[0066] In the formula, E_onl i t represents the online evaluation value of node i. oi E_ans represents the online duration of node i. i t represents the response evaluation value of node i. ai The response time of node i is represented by E in formula (4). i The weighted sum of the node's online evaluation value and the node's response evaluation value is obtained, where σ1 is the weight of the node's online evaluation and σ2 is the weight of the node's response evaluation, and σ1=σ2=0.5. Both reflect the node's performance status equally. According to formulas (2)~(4), E i The value range is [0,1]. The longer the node is online and the shorter the response time, the better the node performance.

[0067] The formula for calculating the comprehensive credit assessment value is as follows:

[0068]

[0069]

[0070]

[0071] In the formula, C_dir i Num_c represents the direct credit value of node i, which is composed of the node's consensus credit value and the node's voting credit value. i Num_c represents the number of times node i has successfully completed consensus. s The ratio of Num_v to the total number of times node i participates in consensus represents the consensus credibility of node i, where λ is the consensus credibility weight. i This indicates the number of times node i successfully completed its vote, Num_v s The ratio of C_idir to the total number of votes participated in by node i represents the voting credibility of node i, μ is the voting credibility weight, and C_idir represents the voting credibility weight. i This represents the indirect credit value of node i, which is composed of activity and node incentive. Num_GP i Num_GC represents the number of times node i exists in the master node group. i C_rank represents the number of times node i exists in the consensus node group, γ is the weight of the number of times node i exists in the master node group, α is the weight of the node activity evaluation, and C_rank represents the number of times node i exists in the consensus node group. i C represents the overall credit assessment value of node i. i Rank, where n is the number of nodes in each group, N represents the total number of nodes, β is the node motivation evaluation weight, and C_his i Let be the historical comprehensive credit assessment value of node i, and η be the historical comprehensive credit assessment weight. According to formulas (5) to (7), C i The value ranges from [0,1]. The higher the node's overall credit rating, the safer and more reliable the node is.

[0072] During the first consensus, the comprehensive evaluation value can be initialized randomly, or specific parameters in formulas (1)-(7) can be set or randomly initialized, and then the parameters can be substituted into the formula to calculate the comprehensive evaluation value. For example, during the first consensus, the node comprehensive credit evaluation value C is initialized. i Since they have the same initial credit value, the nodes are ranked the same, all being ranked 1; or initially, the nodes have no historical comprehensive credit assessment value, and the historical comprehensive credit assessment value is initialized to 0, etc.

[0073] Step S2, Node Distance Grouping: Select the top preset number of nodes with high comprehensive evaluation values ​​as center nodes. Each center node is the center of a group. Calculate the distance between the remaining nodes and the center nodes using the physical network coordinates of the nodes. Divide the remaining nodes evenly into multiple groups according to the principle of closest distance. Each group forms a subgroup, and all center nodes form a main group.

[0074] like Figure 3 As shown, taking 10 IoT nodes as an example. Before each round of consensus, it is necessary to obtain the comprehensive evaluation value and physical network coordinates (x, y) of the 10 IoT nodes, where the comprehensive evaluation value is calculated according to formulas (1) to (7). Through the distance-based grouping optimization algorithm, the node with the high comprehensive evaluation value is selected as the center node of the group (the nodes can be sorted from high to low according to the comprehensive evaluation value, and then the first preset number of nodes are taken as the center node). According to the distance between the node and the center node and the comprehensive evaluation value, the nodes are divided into groups to form subgroups, and all center nodes form the main group (where the center node exists in both the subgroups and the main group). In the example figure, the 10 IoT nodes are divided into 2 subgroups and one main group. In large-scale IoT scenarios, the number of nodes in the subgroups and the main group will not be less than 4, which can fully meet the consensus conditions of the PBFT method. The consensus process then begins. Subgroups employ a rapid grouping approach based on comprehensive evaluation values ​​to improve consensus security and efficiency. Once consensus is reached within a subgroup, the main group mutually confirms the consensus result to reduce communication complexity. After consensus is achieved, the node's credit value and performance evaluation are updated in real-time based on its performance in this round of consensus, providing a reliable guarantee for the selection of the consensus center node in the next round.

[0075] In this embodiment, the nodes ranked in the top K by comprehensive evaluation value are taken as the center nodes of the group, and the physical distance between node i and the K initial cluster centers j of the Internet of Things nodes is calculated using formula (8):

[0076]

[0077] In the formula, d ij Represents the distance between node i and node j, (x i ,y i (x) represents the physical network coordinates of node i. j ,y j ) represents the physical network coordinates of node j. In this embodiment, i and j are used to distinguish example nodes and are not specifically limited to a certain node.

[0078] When dividing the nodes into groups, each central node forms a group. The node to be grouped is added to the group containing the nearest central node. If the number of nodes in the nearest group exceeds N / K or the proportion of nodes with a comprehensive evaluation value below 0.3 exceeds 1 / 3, the node to be grouped is added to the next nearest group. This process is repeated until the nodes are grouped. Here, N represents the total number of nodes and K represents the number of central nodes.

[0079] Figure 4 Taking K=4 as an example, when grouping, the formula (8) is used to calculate the value of each node (x). i ,y i ) to K group centers (x j ,y j The distance between nodes is determined by the number of nodes in each group. To ensure secure and efficient consensus, the number of nodes in each group should not exceed N / K, and the proportion of nodes with a comprehensive credit value below 0.3 (c) should not exceed 1 / 3. If the number of nodes in a group reaches its maximum or the proportion of nodes with a comprehensive credit value below 0.3 reaches its maximum, the node is added to the next closest group. This process is repeated until grouping is complete. The result after grouping is that the number of nodes in each group is evenly distributed and their quality is not significantly different.

[0080] Step S3, consensus within and outside the node group: The subgroup adopts the optimized three-way fast sorting group consensus method based on the comprehensive evaluation value to achieve consensus within the group. After the consensus within the group is reached, the central nodes in the main group confirm the consensus result within the group to complete the consensus between the groups.

[0081] Since the number of nodes participating in intra-group consensus is much greater than the number of nodes participating in inter-group consensus, and intra-group consensus is the basis for inter-group consensus, the subgroup adopts the idea of ​​three-way fast grouping based on comprehensive evaluation to improve the security and efficiency of consensus. After the intra-group reaches a consensus, the main group nodes confirm the intra-group consensus results to complete the inter-group consensus.

[0082] like Figure 5 As shown, this step also uses 4 group centers and 5 nodes in each group as an example. First, the client sends a request to the center node of each of the 4 groups. After receiving the request, the center node of each group starts a three-way quick sorting based on the comprehensive evaluation value of the nodes, dividing them into three groups: the master node group, the consensus node group, and the observer node group. Then, the nodes in the consensus node group and the observer node group vote to the master node group to select the consensus master node within the group, and the group consensus process begins. The consensus master node sends a pre-preparation message to the other nodes. After the other nodes verify the correct message, they enter the preparation phase together with the consensus master node. After the preparation message is confirmed to be correct, each node replies to the group's center node. The group's center nodes confirm the results with each other and return them to the client. The specific steps are as follows:

[0083] Step S3.1: The client sends a request to K group centers. After receiving the client's request, the group's center node uses an optimized three-way quick sorting method to divide the nodes in the group into master node group, consensus node group and observer node group according to the comprehensive evaluation value.

[0084] According to formula (1), the comprehensive evaluation value of a node is in the range of [0,1]. To ensure system security, the three groups are divided into three groups with a ratio of 2:5:3. That is, nodes with a comprehensive evaluation value in the range of (0.8,1) are classified as master nodes, ensuring that the credit value of the master nodes elected from the master nodes group is high enough and that they are likely to be trusted nodes; nodes with a comprehensive evaluation value in the range of [0.3,0.8] are classified as consensus nodes, ensuring that enough nodes participate in consensus; and nodes with a comprehensive evaluation value in the range of [0,0.3) are classified as observation nodes.

[0085] like Figure 6 As shown, the optimized three-way quicksort method traverses the node array R from left to right once to determine the grouping interval [0.3, 0.8]. This involves maintaining a pointer `lt` such that all elements to the left of `lt` are greater than 0.8, a pointer `gt` such that all elements to the right of `gt` are less than 0.3, and a pointer `i` such that all elements in `R[lt..i-1]` are less than or equal to 0.8 and greater than or equal to 0.3. The elements to be scanned are in `R[i..gt]`. During grouping, `R[i]` is compared with the interval value. If `R[i]` is greater than 0.8, `R[lt]` and `Cn[i]` are swapped, and `lt` and `i` are shifted one position to the right. If `R[i]` is less than 0.3, `R[gt]` and `R[i]` are swapped, and `gt` is shifted one position to the left. If `R[i]` is within the interval, no element needs to be processed, and `i` is shifted one position to the left until `i > gt`, and the scan ends. After grouping, the three parts are recursively sorted using three-way quicksort to obtain the final, reliably ordered three-interval grouped array.

[0086] Step S3.2: After the three-way rapid grouping is completed, the central node of each group initiates a voting request. Nodes within the consensus node group and the observer node group jointly vote for the nodes within the master node group. The node with the most votes in the master node group is elected as the consensus master node for this round. If there are nodes with the same number of votes, the node with the higher overall evaluation value becomes the consensus master node. If the number of votes and the overall evaluation value are also the same, either node is chosen. The formula for calculating the number of votes for each node in the master node group is as follows:

[0087] Sum_v i =P c Sumv_GC i +P o Sumv_GO i (9)

[0088] In the formula, Sum_v iSumv_GC represents the final vote count received by node i within the master node group. i Sumv_GO represents the total number of votes cast by nodes in the consensus node group for node i. i P represents the total number of votes cast by nodes in the observation node group for node i. c P represents the voting weight of the consensus node group. o P represents the voting weight of the observation node group. c +P o =1, and P c >P o In this embodiment, the voting weight is set according to the credit interval ratio, taking P. c P is 0.625. o It is 0.375.

[0089] Step S3.3: After the consensus master node within the group is selected, the group-wide PBFT group consensus begins. Observer nodes do not have the right to participate in consensus; only nodes within the master node group and consensus node group participate. The consensus master node sends a pre-preparation message to other participating consensus nodes. Upon receiving the pre-preparation message, other consensus nodes verify its validity. Nodes whose pre-preparation messages pass verification enter the preparation phase and send preparation messages to other participating consensus nodes; otherwise, they do not send preparation messages. Consensus nodes receiving preparation messages verify their validity. If a consensus node passes verification, it writes the preparation message to its log. When consensus nodes gather at least 2f nodes within the group... 内 After the preparation message is verified by each node, the consensus node enters the response phase; the consensus node in the response phase sends a response message to the group's central node. If the group's central node has collected at least f messages from within the group... 内 If a response message is received from +1 consensus node, then the group consensus is successful; otherwise, the group consensus fails. 内 This is the threshold for the number of Byzantine nodes within the group.

[0090] Step S3.4: After all groups have reached a consensus, the central nodes of each group broadcast confirmation messages to each other. When each central node collects 2f... 外 After receiving confirmation messages from +1 central node, inter-group consensus is successful; otherwise, it fails. Subsequently, the central node sends the consensus result back to the client, completing the current round of consensus. Where f... 外 This is the threshold for the number of Byzantine nodes outside the group.

[0091] Therefore, assuming the total number of nodes in the system is N and the number of groups is K, the number of central nodes is also K. The number of nodes in each group is n = N / K. We also assume the number of nodes in the master node group is n1, the number of nodes in the consensus node group is n2, and the number of nodes in the observation node group is n3, where a = n1 / n, b = n2 / n, and c = n3 / n. Then, the consensus communication overhead within the algorithm group is:

[0092]

[0093] During inter-group consensus, communication overhead only occurs during mutual confirmation at the group center, and its communication overhead is:

[0094] T 组间 =K(K-1) (11)

[0095] =K 2 -K

[0096] According to formulas (10) and (11), the communication overhead of this method can be obtained as follows:

[0097]

[0098] The ratio Z1 between the communication overhead of the method of this invention and the communication overhead of the conventional PBFT algorithm is:

[0099]

[0100] Analysis of formula (13) shows that the Z1 value is related to the c value, the K value and the number of system nodes N.

[0101] (1) The relationship between K and N under the condition that the value of c is constant. Since the value of c in each group will not exceed 1 / 3, in this embodiment, the value of c is 0.3, the value of N is in the range of [1000, 5000], and the value of K is in the range of [100, 500] to observe the change of Z1. The surface plot of Z1 change is as follows. Figure 7 As shown in the figure. The x-axis represents the number of nodes N, the y-axis represents the number of packets K, and the z-axis represents the communication overhead ratio Z1.

[0102] from Figure 7 As can be seen, the communication overhead ratio of the method of this invention does not exceed 0.13, which greatly reduces communication overhead compared with the conventional PBFT algorithm. When the number of groups K is constant, the more system nodes there are, the lower the communication overhead. This is because the consensus is achieved within a group using a three-way fast grouping algorithm, and the communication complexity within the group is greatly reduced as the number of nodes increases. When the number of system nodes N is constant, the system communication overhead increases with the number of groups. This is because the increased number of groups leads to increased consensus overhead between groups, resulting in a relative increase in system communication overhead, but the total communication overhead is still much lower than that of the PBFT algorithm.

[0103] (2) The relationship between K and c under the condition that N is constant. In this embodiment, we assume that there are 3000 nodes in the system. When the value of c is in the range of [0.05, 0.3] and the value of K is in the range of [100, 600], we observe the change of Z1.

[0104] Z1 variation surface diagram as follows Figure 8 As shown in the figure. The x-axis represents the value of c, the y-axis represents the number of packets K, and the z-axis represents the communication overhead ratio Z1. From... Figure 8 As can be seen, when the number of groups K is constant, the larger the value of c, the smaller the communication overhead. This is because the increase in the number of observation nodes reduces the system communication overhead. However, when the value of c is constant, the larger the value of K, the greater the system communication overhead. Between [200, 300], the communication overhead shows a trend of first decreasing and then increasing. This indicates that there is an optimal number of groups. Taking the partial derivative of formula (13) and setting it to 0, the optimal value of K is obtained as follows:

[0105]

[0106] 2K 3 -K 2 =(1-c) 2 N 2 +cN

[0107] When K satisfies formula (14) and is an integer, it is the optimal solution when the values ​​of c and N are fixed. Figure 8 When c is 0.05, the optimal solution for K is between 159 and 160, and close to 160. Therefore, when the number of groups is 160, the system communication overhead is minimized under the same conditions. In the actual IoT scenario, when determining the number of node groups, we can use formula (14) to obtain the optimal number of groups to minimize the system's homogeneous overhead.

[0108] Step S4: Update node information: Based on the node's behavior in this round of consensus, update the node's comprehensive evaluation value to complete a round of consensus.

[0109] The behavior of nodes in this round of consensus includes, if inter-group consensus is successful, the number of times Num_c, the nodes participating in this intra-group and inter-group consensus, successfully complete consensus. i Increment by one; regardless of whether inter-group or intra-group consensus is successful, the total number of consensus participations by nodes participating in this intra-group and inter-group consensus is Num_c. s Increment by one; during group consensus, if a node participates in voting and successfully votes, the node's successful voting count is Num_v. i Increment by one; if a node participates in voting, regardless of whether the vote is successful, the total number of times the node participated in voting is Num_v. s Increment by one; if a node is assigned to the master node group in this consensus, then the number of times that node exists in the master node group is Num_GP. iIncrement by one; if a node is assigned to a consensus node group in this consensus process, then the number of times that node exists in the consensus node group is Num_GC. i Add one; in addition, if a node participates in voting but fails to vote successfully during this consensus process, then the node is a faulty or malicious node; otherwise, the node is a good node.

[0110] This invention provides a PBFT grouping optimization consensus method for the Internet of Things (IoT). It proposes to group IoT nodes according to their actual locations, and within each group, a three-way fast grouping approach based on comprehensive evaluation is used for consensus. Between groups, the consensus results are mutually confirmed by the center of each group. This method can effectively optimize the problem of high communication complexity in IoT scenarios, and has high security and efficiency, and can adapt to the changing needs of IoT scenarios.

[0111] In the specific implementation of this invention, some minor steps utilize methods published in existing literature, such as the conventional PBFT algorithm and the conventional three-way quicksort algorithm, which will not be described in detail here.

[0112] In another embodiment, the present invention also provides a computer, including a processor and a memory storing a plurality of computer instructions, which, when executed by the processor, implement the steps of the PBFT packet optimization consensus method for the Internet of Things.

[0113] For specific limitations on computer instructions, please refer to the limitations on the PBFT packet optimization consensus method for the Internet of Things mentioned above, which will not be repeated here.

[0114] The memory and processor are electrically connected directly or indirectly to enable data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines. The memory stores a computer program that can run on the processor, which implements the method in the embodiments of the present invention by running the computer program stored in the memory.

[0115] The memory may be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc. The memory stores the program, and the processor executes the program upon receiving an execution instruction.

[0116] The processor may be an integrated circuit chip with data processing capabilities. The aforementioned processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor.

[0117] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0118] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the appended claims.

Claims

1. A PBFT (Packet Optimization Thresholding) consensus method for the Internet of Things, characterized in that, The PBFT packet optimization consensus method for the Internet of Things includes: Step S1, Node Quality Assessment: Before the start of each round of consensus, obtain the comprehensive assessment value of the node and the physical network coordinates of the node. The comprehensive assessment value includes the comprehensive credit assessment value and the comprehensive performance assessment value of the node. Step S2, Node Distance Grouping: Select the top preset number of nodes with high comprehensive evaluation values ​​as center nodes. Each center node is the center of a group. Calculate the distance between the remaining nodes and the center nodes using the physical network coordinates of the nodes. Divide the remaining nodes evenly into multiple groups according to the principle of closest distance. Each group forms a subgroup, and all center nodes form a main group. Step S3, consensus within and outside the node group: The subgroup adopts the optimized three-way fast sorting group consensus method based on the comprehensive evaluation value to achieve consensus within the group. After the consensus within the group is reached, the central nodes in the main group confirm the consensus result within the group to complete the consensus between the groups. Step S4: Update node information: Based on the node's behavior in this round of consensus, update the node's comprehensive evaluation value to complete a round of consensus.

2. The PBFT packet optimization consensus method for the Internet of Things according to claim 1, characterized in that, The formula for calculating the comprehensive evaluation value is as follows: R i =ξ1E i +ξ2C i (1) In the formula, R i E represents the overall evaluation value of node i. i C represents the overall performance evaluation value of node i. i Let ξ1 represent the comprehensive credit assessment value of node i, and let ξ2 represent the comprehensive performance assessment weight. The formula for calculating the comprehensive performance evaluation value is as follows: E i =σ1E_onl i +σ2E_ans i (4) In the formula, E_onl i t represents the online evaluation value of node i. oi E_ans represents the online duration of node i. i t represents the response evaluation value of node i. ai σ1 represents the response time of node i, σ2 represents the online evaluation weight of the node, and σ2 represents the response evaluation weight of the node. The formula for calculating the comprehensive credit assessment value is as follows: In the formula, C_dir i Num_c represents the direct credit value of node i. i Num_c represents the number of times node i has successfully completed consensus. s The ratio of Num_v to the total number of times node i participates in consensus represents the consensus credibility of node i, where λ is the consensus credibility weight. i This indicates the number of times node i successfully completed its vote, Num_v s The ratio of C_idir to the total number of votes participated in by node i represents the voting credibility of node i, μ is the voting credibility weight, and C_idir represents the voting credibility weight. i Num_GP represents the indirect credit value of node i. i Num_GC represents the number of times node i exists in the master node group. i C_rank represents the number of times node i exists in the consensus node group, γ is the weight of the number of times node i exists in the master node group, α is the weight of the node activity evaluation, and C_rank represents the number of times node i exists in the consensus node group. i C represents the overall credit assessment value of node i. i Rank, where n is the number of nodes in each group, N represents the total number of nodes, β is the node motivation evaluation weight, and C_his i Let η be the historical comprehensive credit assessment value of node i, and η be the historical comprehensive credit assessment weight.

3. The PBFT packet optimization consensus method for the Internet of Things according to claim 1, characterized in that, The calculation of the distance between the remaining nodes and the central node using the physical network coordinates of the nodes includes: In the formula, d ij Represents the distance between node i and node j, (x i ,y i (x) represents the physical network coordinates of node i. j ,y j ) represents the physical network coordinates of node j, where one of node i and node j is the center node.

4. The PBFT packet optimization consensus method for the Internet of Things according to claim 1, characterized in that, The process of evenly dividing the remaining nodes into multiple groups according to the principle of nearest distance includes: Each central node forms a group. The node to be grouped is taken and added to the group of the nearest central node. If the number of nodes in the nearest group exceeds N / K or the proportion of nodes with a comprehensive evaluation value of less than 0.3 in the group exceeds 1 / 3, the node to be grouped is added to the next nearest group. The nodes to be grouped are processed in turn until the node grouping is completed. Here, N represents the total number of nodes and K represents the number of central nodes.

5. The PBFT packet optimization consensus method for the Internet of Things according to claim 1, characterized in that, The subgroups employ an optimized three-way fast sorting group consensus method based on comprehensive evaluation values ​​for intra-group consensus. After intra-group consensus is reached, the central nodes within the main group mutually confirm the intra-group consensus results to complete inter-group consensus, including: After receiving a request from a client, the central node of the group divides the nodes within the group into a master node group, a consensus node group, and an observer node group based on a comprehensive evaluation value. The central node of the group initiates a voting request. The nodes in the consensus node group and the nodes in the observation node group vote together for the nodes in the master node group. The node with the most votes in the master node group is elected as the consensus master node in this round. After the consensus master node within the group is selected, the group-wide PBFT group consensus process begins. Nodes within the master node group and consensus nodes within the group participate in the consensus. The consensus master node sends a pre-preparation message to other participating consensus nodes. Upon receiving the pre-preparation message, other consensus nodes verify its validity. Nodes whose pre-preparation messages pass verification enter the preparation phase and send preparation messages to other participating consensus nodes; otherwise, they do not send preparation messages. Consensus nodes receiving preparation messages verify their validity. If a consensus node's verification passes, the preparation message is written to its log. This process continues until at least two consensus nodes within the group have participated. 内 After the preparation message is verified by each node, the consensus node enters the response phase; the consensus node in the response phase sends a response message to the group's central node. If the group's central node has collected at least f messages from within the group... 内 If a response message is received from +1 consensus node, the group consensus is successful; otherwise, the group consensus fails. Where f... 内 The threshold for the number of Byzantine nodes within the group; Once all groups have reached a consensus, the central nodes of each group broadcast confirmation messages to each other. When each central node collects 2f... 外 After receiving confirmation messages from +1 central node, inter-group consensus is successful; otherwise, it fails. Subsequently, the central node sends the consensus result back to the client, completing the current round of consensus. Where f... 外 This is the threshold for the number of Byzantine nodes outside the group.

6. The PBFT packet optimization consensus method for the Internet of Things according to claim 5, characterized in that, The process of dividing the nodes within a group into a master node group, a consensus node group, and an observer node group based on a comprehensive evaluation value includes: Nodes with a comprehensive evaluation value in the range (0.8,1) are classified as master nodes, nodes with a comprehensive evaluation value in the range [0.3,0.8] are classified as consensus nodes, and nodes with a comprehensive evaluation value in the range [0,0.3) are classified as observer nodes.

7. The PBFT packet optimization consensus method for the Internet of Things according to claim 5, characterized in that, The formula for calculating the votes of each node in the master node group is as follows: Sum_v i =P c Sumv_GC i +P o Sumv_GO i (9) In the formula, Sum_v i Sumv_GC represents the final vote count received by node i within the master node group. i Sumv_GO represents the total number of votes cast by nodes in the consensus node group for node i. i P represents the total number of votes cast by nodes in the observation node group for node i. c P represents the voting weight of the consensus node group. o P represents the voting weight of the observation node group. c +P o =1, and P c >P o .