A method of PBFT algorithm based on partitioning and clustering

The blockchain cluster nodes are classified through K-means++ classification and clustering algorithm, which solves the problem of poor scalability of the PBFT algorithm under high number of nodes, achieves the improvement of consensus efficiency and stability, and ensures that the cluster is in a high node environment Stable operation.

CN115643008BActive Publication Date: 2024-12-06CHINA THREE GORGES UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211213014.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-30
Publication Date
2024-12-06
Estimated Expiration
2042-09-30

AI Technical Summary

Technical Problem

In the case of a large number of cluster nodes, the performance of the PBFT algorithm is degraded due to complicated communication processes, poor scalability, and the existing improvement methods cannot effectively improve consensus efficiency and stability.

Method used

The K-means++ division and clustering algorithm is used to classify nodes in the blockchain cluster, divided into Good, Normal and Bad node clusters, and participate in stages in the consensus process according to the characteristics of the node cluster, reducing communication overhead and improving consensus efficiency.

Benefits of technology

By dynamically adjusting the clustering center point and the participation stage of hierarchical nodes, communication overhead is reduced, consensus efficiency is improved, and the scalability and stability of the algorithm is improved, so that the cluster can accommodate more nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115643008B_ABST
    Figure CN115643008B_ABST
Patent Text Reader

Abstract

A PBFT algorithm based on partitioning and clustering, it includes the following steps: Step 1: Collect data of all nodes in the blockchain cluster, the data includes the response speed and response times ratio of the nodes in the consensus process; Step 2: Use the response speed and response times ratio of the nodes as two data dimensions of the two-dimensional coordinate system, and draw a node response distribution diagram; Step 3: Input the K-means++ partitioning and clustering algorithm model, and cluster all nodes in the cluster according to the response of the nodes; Step 4: Divide the divided nodes into 3 types of node clusters, namely Good node cluster, Normal node cluster and Bad node cluster; Step 5: The three types of nodes after division participate in different consensus stages of the PBFT algorithm respectively, and finally complete the entire consensus process together. The purpose of the present invention is to solve the technical problem that the existing PBFT algorithm will generate a large amount of communication overhead due to the complicated communication process, thereby causing the performance of the algorithm to be greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of blockchain, and in particular relates to a method of a PBFT algorithm based on partitioning and clustering. Background Art

[0002] As a distributed protocol, blockchain technology realizes distributed systems through digital encryption technology. As one of the core technologies in blockchain, consensus algorithm can ensure the consistency of information in blockchain and the stability of cluster. With the rapid development of blockchain technology, the demand for the number of nodes in the cluster is increasing. This makes the security, stability and scalability of consensus algorithms become hot issues in research.

[0003] PBFT is one of the mainstream consensus algorithms in the alliance chain. After receiving the client's message request, as shown in the attached Figure 2 As shown in the figure, it will go through four consensus processes: pre-preparation, preparation, submission, and reply. Because it can accommodate Byzantine nodes, which account for 1 / 3 of the total number of nodes in the cluster, the stability of the system is guaranteed, and the accounting process is completed by multiple nodes, so that each block has finality. The fault tolerance of the PBFT algorithm has made it widely used in consortium chains. However, when there are a large number of nodes in the cluster, the PBFT algorithm will generate a large amount of communication overhead due to the complicated communication process, which will cause the performance of the algorithm to drop significantly, reflecting the problem of poor scalability of the PBFT algorithm.

[0004] For example, in the study of the PBFT algorithm, Gao Na et al. proposed in the article "Improvement of PBFT Algorithm Based on Network Self-Clustering" published in the 11th issue of "Computer Application Research" in 2021 that according to the network structure and system nodes of the cluster, several seed nodes are selected, and all nodes in the cluster are self-clustered and grouped with the seed nodes as the center, and the entire cluster is divided into several node clusters. The respective agents are elected from the different node clusters after the division, and each agent participates in the consensus process, which can effectively improve the efficiency of consensus. In order to reduce the number of nodes participating in the consensus, the above method first conducts an election within the cluster and then conducts the consensus process, which increases the steps of the consensus process and cannot screen out nodes with low consensus efficiency or downtime within the cluster. When the number of cluster nodes is large, the stability of the system cannot be guaranteed.

[0005] Therefore, the scalability problem of the PBFT algorithm has not been completely solved, and a large number of cluster environments is an inevitable development trend. How to improve the consensus efficiency and stable scalability of the algorithm while ensuring cluster stability? Summary of the invention

[0006] The purpose of the present invention is to solve the technical problem that the existing PBFT algorithm generates a large amount of communication overhead due to the complicated communication process, thereby causing the performance of the algorithm to be greatly reduced, thus resulting in poor scalability of the PBFT algorithm.

[0007] A method of a PBFT algorithm based on partitioning clustering, comprising the following steps:

[0008] Step 1: Collect data from all nodes in the blockchain cluster, including the response speed and response ratio of the nodes during the consensus process;

[0009] Step 2: Use the node response speed and response times ratio as two data dimensions of the two-dimensional coordinate system to draw a node response distribution diagram;

[0010] Step 3: Enter the K-means++ partitioning clustering algorithm model and cluster all nodes in the cluster according to the node response;

[0011] Step 4: Divide the divided nodes into three types of node clusters, namely Good node cluster, Normal node cluster and Bad node cluster;

[0012] Step 5: The three types of nodes after division participate in different consensus stages of the PBFT algorithm respectively, and finally complete the entire consensus process together.

[0013] In step 2, the two data dimensions in the two-dimensional coordinate system are defined as follows:

[0014] The node response times ratio is used as the x-axis of the two-dimensional coordinate system, and the response times ratio M satisfies the formula: M Goodi is the response ratio of any node i in the Good node cluster, M Normali is the response ratio of any node i in the Normal node cluster, M Badi is the response ratio of any node i in the Bad node cluster. Where T is the number of consensus cycles the cluster has experienced, and the number of times the node has participated in the preparation process in T cycles is p i , participated in the submission process for c times i , the number of times participated in the reply process is r i .

[0015] The response speed of the node is taken as the y-axis of the two-dimensional coordinate system, and the response speed of the node is defined according to the time it takes for the node to respond to the client or the main node information. The response speed V of the node is expressed as the average of n response speeds, which satisfies the formula: V represents the response speed of the node, where the i-th response time of the node is t i, and use its reciprocal value to represent the single response speed of the node. If the number of responses of the node in one cycle is n, the sum of the n response speeds of the node is divided by the number of responses to obtain the average value V of the n response speeds.

[0016] In step 3, all nodes in the cluster are clustered and divided using the following steps:

[0017] Step 1): Define the final desired number of node clusters n (n>=3);

[0018] Step 2): K-means++ will autonomously select the cluster center point and select the remaining n-1 cluster centers according to the principle of far point priority.

[0019] In step 4, when the divided nodes are divided into three types of node clusters, the following steps are adopted:

[0020] Step 1): According to the node cluster division result in the two-dimensional coordinate system, the cluster center point coordinates of n nodes are obtained;

[0021] Step 2): Compare and obtain a cluster center point with the farthest Euclidean distance from the origin of the coordinate system, which is used as the cluster center of the Good node cluster;

[0022] Step 3): Compare and obtain a cluster center point with the closest Euclidean distance to the origin of the coordinate system as the cluster center of the Bad node cluster;

[0023] Step 4): The remaining node cluster is the Normal node cluster.

[0024] The Good node cluster represents a part of nodes that respond actively and quickly; the Normal node cluster represents most of the nodes that participate in the consensus process and perform normally; the Bad node cluster represents a part of nodes that passively participate in the consensus and respond slowly, and the probability of malicious nodes is higher.

[0025] In step 5, the three types of nodes participate in different consensus stages of the PBFT algorithm to jointly complete the entire consensus process, including the following steps:

[0026] Step 1): Good nodes participate in the PBFT consensus process from the election process. That is, after the cluster receives the message request from the client, it selects a master node from the Good nodes to start the pre-preparation and preparation process. All Good nodes will participate in the entire consensus process.

[0027] Step 2): The Normal node cluster participates in the consensus process during the submission phase, assists in the verification and forwarding of information, and participates in the reply process;

[0028] Step 3): The Bad node cluster participates in the consensus response process of the cluster, passively updates the local log of the node, and sends a reply message to the client; finally, the consensus process is completed.

[0029] Compared with the prior art, the present invention has the following technical effects:

[0030] 1) The present invention can dynamically adjust the value of the initial cluster center point of the K-means++ algorithm according to the change in the number of nodes in the cluster or the final desired clustering result, making the method more adaptable;

[0031] 2) The present invention can change the stages at which nodes of different levels participate in the consensus process according to needs, so that the algorithm can have better randomness or stability. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:

[0033] Figure 1 It is a structural schematic diagram of the present invention;

[0034] Figure 2 This is a diagram of the PBFT consensus phase in the prior art;

[0035] Figure 3 This is a comparison chart of the consensus efficiency experiment of the present invention. DETAILED DESCRIPTION

[0036] like Figure 1 As shown, a method of a PBFT algorithm based on partitioning clustering includes the following steps:

[0037] Step 1: Collect data from all nodes in the blockchain cluster, including the response speed and response ratio of the nodes during the consensus process;

[0038] Step 2: Use the node response speed and response times ratio as two data dimensions of the two-dimensional coordinate system to draw a node response distribution diagram;

[0039] Step 3: Enter the K-means++ partitioning clustering algorithm model and cluster all nodes in the cluster according to the node response;

[0040] Step 4: Divide the divided nodes into three types of node clusters, namely Good node cluster, Normal node cluster and Bad node cluster;

[0041] Step 5: The three types of nodes after division participate in different consensus stages of the PBFT algorithm respectively, and finally complete the entire consensus process together.

[0042] In step 2, the two data dimensions in the two-dimensional coordinate system are defined as follows:

[0043] The node response times ratio is used as the x-axis of the two-dimensional coordinate system, and the response times ratio M satisfies the formula: M Goodi is the response ratio of any node i in the Good node cluster, M Normali is the response ratio of any node i in the Normal node cluster, M Badi is the response ratio of any node i in the Bad node cluster. Where T is the number of consensus cycles the cluster has experienced, and the number of times the node has participated in the preparation process in T cycles is p i , participated in the submission process for c times i , the number of times participated in the reply process is r i .

[0044] The response speed of the node is taken as the y-axis of the two-dimensional coordinate system, and the response speed of the node is defined according to the time it takes for the node to respond to the client or the main node information. The response speed V of the node is expressed as the average of n response speeds, which satisfies the formula: V represents the response speed of the node, where the i-th response time of the node is t i , and use its reciprocal value to represent the single response speed of the node. If the number of responses of the node in one cycle is n, the sum of the n response speeds of the node is divided by the number of responses to obtain the average value V of the n response speeds.

[0045] In step 3, all nodes in the cluster are clustered and divided using the following steps:

[0046] Step 1): Define the final desired number of node clusters n (n>=3);

[0047] Step 2): K-means++ will autonomously select the cluster center point and select the remaining n-1 cluster centers according to the principle of far point priority.

[0048] In step 4, when the divided nodes are divided into three types of node clusters, the following steps are adopted:

[0049] Step 1): According to the node cluster division result in the two-dimensional coordinate system, the cluster center point coordinates of n nodes are obtained;

[0050] Step 2): Compare and obtain a cluster center point with the farthest Euclidean distance from the origin of the coordinate system, which is used as the cluster center of the Good node cluster;

[0051] Step 3): Compare and obtain a cluster center point with the closest Euclidean distance to the origin of the coordinate system as the cluster center of the Bad node cluster;

[0052] Step 4): The remaining node cluster is the Normal node cluster.

[0053] In the present invention, the Good node cluster represents a part of nodes that actively respond and respond quickly; the Normal node cluster represents most of the nodes that participate in the consensus process and perform normally; the Bad node cluster represents a part of nodes that passively participate in the consensus and respond slowly, and the probability of malicious nodes is higher.

[0054] In step 5, the three types of nodes participate in different consensus stages of the PBFT algorithm to jointly complete the entire consensus process, including the following steps:

[0055] Step 1): Good nodes participate in the PBFT consensus process from the election process. That is, after the cluster receives the message request from the client, it selects a master node from the Good nodes to start the pre-preparation and preparation process. All Good nodes will participate in the entire consensus process.

[0056] Step 2): The Normal node cluster participates in the consensus process during the submission phase, assists in the verification and forwarding of information, and participates in the reply process;

[0057] Step 3): The Bad node cluster participates in the consensus response process of the cluster, passively updates the local log of the node, and sends a reply message to the client; finally, the consensus process is completed.

[0058] The present invention proposes an optimized PBFT consensus algorithm based on partitioning and clustering to solve the problems of efficiency and stable scalability of the PBFT algorithm. Before the PBFT algorithm process starts, all nodes in the cluster are first divided and graded using the K-means++ partitioning and clustering algorithm, and node clusters of different clusters after division are selected to participate in different processes of the PBFT consensus, which can reduce the number of nodes involved in each consensus process and reduce communication overhead; and can improve the quality of nodes participating in the consensus and improve consensus efficiency; thereby allowing the cluster to accommodate more nodes under the premise of PBFT ensuring cluster stability, so that the algorithm has better scalability.

[0059] Example:

[0060] The present invention uses Golang language in a Windows system to simulate a blockchain experimental environment with 100 nodes. After recording the corresponding situation data of all nodes, the present invention defines the n value of the K-means++ partition clustering model as 4, obtains 4 node clusters after clustering, and defines the node cluster with the farthest Euclidean distance from the coordinate origin as the Good node cluster, and the node cluster with the closest Euclidean distance to the coordinate origin as the Bad node cluster, and the remaining two node clusters are Normal node clusters.

[0061] Different node clusters are involved in different consensus stages, and the time taken to complete 20 consensus cycles by the improved algorithm and the original PBFT algorithm in a cluster environment of 100 nodes is compared. The experimental results are as follows: Figure 3 As shown in the figure, by comparison, the improved consensus algorithm (called KPBFT in the experiment) improves the consensus efficiency by an average of 40% based on PBFT.

[0062] The present invention combines the PBFT algorithm and the K-means++ partitioning clustering algorithm. Before the consensus process begins, the nodes in the cluster are first graded and divided. The graded nodes are allowed to participate in different stages of the consensus process, which improves the efficiency and scalability of the consensus algorithm.

Claims

1. A method of a PBFT algorithm based on partitioning and clustering, characterized in that: It includes the following steps: Step 1: Collect data from all nodes in the blockchain cluster, including the response speed and response ratio of the nodes during the consensus process; Step 2: Use the node response speed and response times ratio as two data dimensions of the two-dimensional coordinate system to draw a node response distribution diagram; Step 3: Enter the K-means++ partitioning clustering algorithm model and cluster all nodes in the cluster according to the node response; Step 4: Divide the divided nodes into three types of node clusters, namely Good node cluster, Normal node cluster and Bad node cluster; Step 5: The three types of nodes after division participate in different consensus stages of the PBFT algorithm respectively, and finally complete the entire consensus process together; In step 2, the two data dimensions in the two-dimensional coordinate system are defined as follows: The node response times ratio is used as the x-axis of the two-dimensional coordinate system, and the response times ratio M satisfies the formula: M Goodi is the response ratio of any node i in the Good node cluster, M Normali is the response ratio of any node i in the Normal node cluster, M Badi is the response ratio of any node i in the Bad node cluster, where T is the number of consensus cycles the cluster has experienced, and the number of times the node has participated in the preparation process in T cycles is p i , participated in the submission process for c times i , the number of times participated in the reply process is r i ; The response speed of the node is taken as the y-axis of the two-dimensional coordinate system, and the response speed of the node is defined according to the time it takes for the node to respond to the client or the main node information. The response speed V of the node is represented by the average of n response speeds, satisfying the formula: V represents the response speed of the node, where the i-th response time of the node is t i , and use its reciprocal value to represent the single response speed of the node. If the number of responses of the node in one cycle is n, sum up the n response speeds of the node and divide it by the number of responses to get the average value V of the n response speeds; In step 4, when the divided nodes are divided into three types of node clusters, the following steps are adopted: Step 1): According to the node cluster division result in the two-dimensional coordinate system, the cluster center point coordinates of n nodes are obtained; Step 2): Compare and obtain a cluster center point with the farthest Euclidean distance from the origin of the coordinate system, which is used as the cluster center of the Good node cluster; Step 3): Compare and obtain a cluster center point with the closest Euclidean distance to the origin of the coordinate system as the cluster center of the Bad node cluster; Step 4): The remaining node cluster is the Normal node cluster; In step 5, the three types of nodes participate in different consensus stages of the PBFT algorithm to jointly complete the entire consensus process, including the following steps: Step 1): Good nodes participate in the PBFT consensus process from the election process. That is, after the cluster receives the message request from the client, it selects a master node from the Good nodes to start the pre-preparation and preparation process. All Good nodes will participate in the entire consensus process; Step 2): The Normal node cluster participates in the consensus process during the submission phase, assists in the verification and forwarding of information, and participates in the reply process; Step 3): The Bad node cluster participates in the consensus response process of the cluster, passively updates the local log of the node, and sends a reply message to the client; finally, the consensus process is completed.

2. The method according to claim 1, characterized in that: In step 3, all nodes in the cluster are clustered and divided using the following steps: Step 1): Define the final desired number of node clusters n, where n>=3; Step 2): K-means++ will autonomously select the cluster center point and select the remaining n-1 cluster centers according to the principle of far point priority.

3. The method according to claim 1 or 2, characterized in that: The Good node cluster represents a part of nodes that respond actively and quickly; the Normal node cluster represents most of the nodes that participate in the consensus process and perform normally; the Bad node cluster represents a part of nodes that passively participate in the consensus and respond slowly, and the probability of malicious nodes is higher.