Block graph consensus method and device based on extended cluster clustering algorithm
By applying the extended cluster clustering algorithm in the block graph consensus method to build and score the block support set, the problems of vulnerability and backward consistency in the existing technology are solved, and more stable and secure consensus results are achieved.
Patent Information
- Application Number
- CN202411861965.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-03-25
AI Technical Summary
Existing block graph consensus methods are vulnerable to attackers' impact on graph topology, making it difficult to maintain backward consistency, resulting in unstable and secure consensus results.
The block graph consensus method based on the extended cluster clustering algorithm is adopted, and the target block diagram is obtained for layered processing, the block support set is constructed, the aggregation degree score is calculated, and the support set is divided to determine the consensus result.
Finding a stable aggregation subgraph in the divergent graph topology ensures the backward consistency and security of the block graph consensus results and improves the stability of the consensus results.
Smart Images

Figure CN119691481A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a block graph consensus method and device based on an extended clustering algorithm. Background Art
[0002] A block consensus diagram is a chart or diagram used to show the consensus process of nodes in a blockchain network; in blockchain technology, the consensus mechanism is a key mechanism to ensure that each node in a distributed system reaches a consensus on the data status or transaction order.
[0003] Although the relevant technical solution provides a consensus method for block graphs, it is vulnerable to attackers' influence on the graph topology structure, and it is difficult to maintain the backward consistency of the block graph consensus method, thus failing to produce a stable and secure consensus result. Summary of the invention
[0004] In view of this, the present invention provides a block graph consensus method and device based on an extended cluster clustering algorithm to solve the problem that the consensus method of the relevant block graph is susceptible to the influence of attackers on the graph topology structure, it is difficult to maintain the backward consistency of the block graph consensus method, and it is impossible to produce a stable and secure consensus result.
[0005] In a first aspect, the present invention provides a block graph consensus method based on an extended clustering algorithm, the method comprising:
[0006] Obtain the target block graph, perform layered processing on the target block graph, and build a block support set based on the layered processing results; the target block graph consists of the genesis block and the referenced reachable blocks;
[0007] Determine block attributes based on the block support set, and calculate the aggregation degree score of the block support set based on the block attributes;
[0008] The block support set is divided, and the clustering degree of the divided block support set is scored to obtain the clustering degree score of the divided set;
[0009] The clustering score of the block support set is compared with the clustering score of the partition set, and the block graph consensus result is determined based on the comparison result.
[0010] The block graph consensus method based on the extended clustering algorithm provided in this embodiment obtains the target block graph, performs hierarchical processing on the target block graph, and constructs a block support set based on the hierarchical processing result; the target block graph is composed of a genesis block and a reference reachable block; then the block attributes are determined based on the block support set, and the aggregation degree score of the block support set is calculated based on the block attributes; the block support set is divided, and the aggregation degree score of the divided block support set is scored to obtain the aggregation degree score of the divided set; finally, the aggregation degree score of the block support set is compared with the aggregation degree score of the divided set, so as to find a stable clustered subgraph in the divergent graph topology as the block graph consensus result, thereby ensuring the backward consistency of the block graph consensus result, thereby improving the stability of the block graph consensus result.
[0011] In an optional implementation, obtaining a target block map, performing hierarchical processing on the target block map, and constructing a block support set based on the hierarchical processing result includes:
[0012] Define the block height of each block in the target block graph; the block height of the referenced reachable block is determined based on the block height of the genesis block and the block reference relationship;
[0013] The target block graph is layered according to the block height to obtain multi-layer reference reachable blocks;
[0014] Based on the block reference relationship, the blocks reachable by reference at each layer are clustered respectively, and the block support set is constructed based on the clustering results.
[0015] The block graph consensus method based on the extended clustering algorithm provided in this embodiment defines the block height of each block in the target block graph, and then hierarchically processes the target block graph according to the block height to obtain multi-layer reference reachable blocks; finally, the multi-layer reference reachable blocks are clustered to obtain a block support set, and the block support set is represented by a set of blocks that reference reachable blocks. The size of the block support set and the size of its intersection can indirectly describe the degree of aggregation. The larger the size of the support set, the wider the range of propagation of the supported blocks, and the higher the possibility that the new block is referenced and reachable. The above-mentioned clustering effect satisfies the backward consistency; at the same time, the larger the size of the intersection of the support set, the closer the correlation between the forks, and the higher the cost for an attacker to influence the public announcement result by constructing other forks, so that the security of the consensus scheme is also guaranteed to a certain extent.
[0016] In an optional implementation, determining a block attribute based on the block support set, and calculating a clustering degree score of the block support set based on the block attribute, includes:
[0017] The size of the block support set is used as the volume of the point, and the size of the intersection between block support sets is used as the weight of the edge;
[0018] The clustering coefficient of the block support set is calculated based on the volume of the points and the weight of the edges;
[0019] The clustering degree score of the block support set is calculated based on the point volume and the set clustering coefficient.
[0020] The block graph consensus method based on the extended cluster clustering algorithm provided in this embodiment takes the size of the block support set as the volume of the point, and the size of the intersection between the block support sets as the weight of the edge, converts the set clustering problem into a community partitioning problem, and then calculates the clustering degree score of the block support set based on the volume of the point, the weight of the edge, and the set clustering coefficient, providing a basis for judging the clustering degree of the block support set and laying the foundation for obtaining the partition set.
[0021] In an optional implementation, the block support set is divided, and the clustering degree score of the divided block support set is scored to obtain the clustering degree score of the divided set, including:
[0022] Compare the number of blocks in the block support set with a preset threshold, and if the number of blocks in the block support set is greater than the preset threshold, determine a block list based on block attributes;
[0023] Sort the block list, and merge the blocks in the block support set based on the sorting result to obtain a partition set;
[0024] The clustering degree of the partition set is scored to obtain the clustering degree score of the partition set.
[0025] The block graph consensus method based on the extended cluster clustering algorithm provided in this embodiment compares the number of blocks in the block support set with a preset threshold. If the number of blocks in the block support set is greater than the preset threshold, a block list is determined based on the block attributes; the block list is sorted, and the blocks in the block support set are merged based on the sorting result to obtain a partition set, thereby realizing upward clustering within the block support set, and then the partition set is scored for the degree of aggregation to obtain a clustering degree score of the partition set, providing a basis for judging the degree of aggregation of the partition set, and ensuring the backward consistency of the block graph consensus result.
[0026] In an optional implementation, comparing the clustering score of the block support set with the clustering score of the partition set, and determining the block graph consensus result based on the comparison result, including:
[0027] Compare the clustering scores of the block support set with the clustering scores of the partition set;
[0028] If the aggregation degree score of the block support set is greater than or equal to the aggregation degree score of the partition set, the target block graph is partitioned based on the partition set to obtain a block subgraph, and the block subgraph is used as the block graph consensus result.
[0029] The block graph consensus method based on the extended cluster clustering algorithm provided in this embodiment compares the clustering degree score of the block support set with the clustering degree score of the partition set, and adaptively generates the cluster and partition set with the largest score according to the comparison result for the clustering degree score of each layer of the block support set, and merges the results of each layer into a subgraph for output, thereby ensuring the backward consistency and security of the block graph consensus result.
[0030] In an optional implementation, comparing the clustering score of the block support set with the clustering score of the partition set, and determining the block graph consensus result based on the comparison result, further includes:
[0031] If the clustering score of the block support set is less than the clustering score of the partition set, the partition set is partitioned until the clustering score of the partition set is greater than or equal to the clustering score of the partitioned set. The partitioning is stopped to obtain the partitioned set, and the block graph consensus result is determined based on the partitioned set.
[0032] In a second aspect, the present invention provides a block graph consensus device based on an extended clustering algorithm, the device comprising:
[0033] The hierarchical module is used to obtain the target block graph, perform hierarchical processing on the target block graph, and build a block support set based on the hierarchical processing results; the target block graph consists of the genesis block and the reference reachable blocks;
[0034] A calculation module, used to determine block attributes based on the block support set, and calculate the aggregation degree score of the block support set based on the block attributes;
[0035] The scoring module is used to divide the block support set, score the degree of aggregation of the divided block support set, and obtain the degree of aggregation score of the divided set;
[0036] The comparison module is used to compare the aggregation score of the block support set with the aggregation score of the partition set, and determine the block graph consensus result based on the comparison result.
[0037] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the block graph consensus method based on the extended cluster clustering algorithm of the above-mentioned first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0038] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the block graph consensus method based on an extended cluster clustering algorithm of the above-mentioned first aspect or any corresponding embodiment thereof.
[0039] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, which are used to enable a computer to execute the block graph consensus method based on the extended cluster clustering algorithm of the above-mentioned first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 is a schematic diagram of implementing block graph consensus using Phantom according to an embodiment of the present invention;
[0042] Figure 2 is a schematic diagram of implementing block graph consensus by UL-BlockDAG according to an embodiment of the present invention;
[0043] Figure 3 It is a flowchart of a block graph consensus method based on an extended clustering algorithm according to an embodiment of the present invention;
[0044] Figure 4 It is a flowchart of another block graph consensus method based on an extended clustering algorithm according to an embodiment of the present invention;
[0045] Figure 5 is a schematic diagram of a block diagram hierarchical processing result according to an embodiment of the present invention;
[0046] Figure 6 It is a flowchart of another block graph consensus method based on an extended clustering algorithm according to an embodiment of the present invention;
[0047] Figure 7 is an undirected graph representation result of a block support set with a block height of 3 according to an embodiment of the present invention;
[0048] Figure 8 is an undirected graph representation result of the divided set according to an embodiment of the present invention;
[0049] Fig. 9It is a flowchart of another block graph consensus method based on an extended clustering algorithm according to an embodiment of the present invention;
[0050] Fig.10 is a structural block diagram of a block graph consensus device based on an extended clustering algorithm according to an embodiment of the present invention;
[0051] Fig.11 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0053] The process of determining the block graph consensus result is to find a stable and clustered subgraph in the divergent block graph. The clustering of the subgraph is the key criterion for determining whether consensus is reached. At the same time, in the stability assessment of the block graph consensus result, the growth of the graph needs to be taken into account. With the addition of new blocks, the new blocks tend to reference more clustered parts.
[0054] There are two related block graph consensus methods, including:
[0055] (1) Phantom (a consensus algorithm) is a given graph topology that uses the maximum k-aggregate subgraph algorithm to find the largest subset of the graph. The algorithm requires that any block in the subset does not have a reference relationship and the number of other blocks in the subset does not exceed k, where the parameter k is the number of parallel blocks generated simultaneously in a predefined unit time. When k = 1, Phantom will degenerate the block graph into the longest chain. Finally, the largest subset of the given block graph that meets the requirements of the maximum k-aggregate subgraph algorithm is the block graph consensus result.
[0056] Taking parameter k=3 as an example, the process of Phantom achieving block graph consensus is as follows: Figure 1 As shown, the maximum k-clustering subgraph algorithm is applied to output the block set {A, B, C, D, G, I, J, F}, and the exclusion set is {E, H, K}; among them, the block set that has no reference relationship with block B is {C, D, G}, and the number of blocks in this set is less than or equal to 3, so the blocks in the block set {C, D, G} meet the requirements of the maximum k-clustering, thereby determining that blocks C, D and G belong to the largest subset; since block E has no reference relationship with block B, block E is divided into the exclusion set.
[0057] In the process of achieving block graph consensus, Phantom needs to predetermine the parameter k as the average number of parallel blocks. However, the estimation of parameter k is not conducive to expanding the system. If it is estimated too large, any block will be judged as consensus, and if it is estimated too small, some blocks generated by loyal participants will be excluded from the consensus result. Therefore, in terms of the security of block graph consensus, Phantom is vulnerable to the influence of attackers on the graph topology structure, resulting in poor stability of the consensus scheme.
[0058] (2) UL-BlockDAG (Unsupervised Learning based Consensus Protocol for Blockchain) achieves block graph consensus by converting blocks and block reference relationships into an adjacency matrix. Blocks are numbered using the row and column numbers of the adjacency matrix. A value of 0 in the adjacency matrix indicates no referenced block, and 1 indicates a referenced block. The Laplace matrix is then determined by making symmetric and diagonal changes to the adjacency matrix. The spectral clustering algorithm is used to calculate the eigenvalues and eigenvectors of the Laplace matrix, and the eigenvector corresponding to the second smallest eigenvalue is taken. Finally, the positive and negative values in the eigenvector are distinguished to determine the binary set of blocks in the block graph, and the set of blocks corresponding to the positive value is selected as the block graph consensus result.
[0059] The process of UL-BlockDAG forming a consensus result of the block graph is as follows: Figure 2 As shown, the block set {15, 16, 17, 18, 19} is the block set excluded by the spectral clustering algorithm; the corresponding value of the block in the Laplace matrix can be determined according to the reference between the blocks, and block 3 has a reference relationship with block 0, block 5 and block 4, so the corresponding value of block 0, block 5 and block 4 in the Laplace matrix is 1; block 3 has no reference relationship with block 1, block 2 and block 15, so the corresponding value of block 1, block 2 and block 15 in the Laplace matrix is 0.
[0060] Since the feature vectors generated by the spectral clustering algorithm in UL-BlockDAG are binary, that is, some blocks are excluded from the block graph consensus result, if the current block graph is highly clustered, the set partitioning determined by UL-BlockDAG will change significantly as the block graph grows; therefore, due to the influence of the classification algorithm itself, UL-BlockDAG does not have the backward consistency of the block graph consensus, and thus cannot produce a stable block graph consensus result.
[0061] In summary, the block graph consensus method is not effective in outputting the stability of consensus results and faces backward consistency and security issues.
[0062] To solve the above technical problems, an embodiment of the present invention provides a block graph consensus method based on an extended clustering algorithm, and deeply studies the principle of consensus judgment in a block graph, that is, finding a stable clustered subgraph in a divergent graph. The clustering of the subgraph is the criterion for judging the consensus, and the stability needs to consider the growth of the graph. New blocks tend to reference more clustered parts. Therefore, the support set is represented by referencing a reachable set of blocks. The size of the support set and the size of its intersection can indirectly describe the degree of aggregation. The larger the size of the support set, the wider the range of propagation of the supported blocks, and the higher the possibility that the new block reference is reachable. This clustering effect satisfies backward consistency; at the same time, the larger the size of the intersection of the support set, the closer the correlation between the forks, and the higher the cost for an attacker to influence the public announcement result by constructing other forks, so that the security of the consensus scheme is also guaranteed to a certain extent.
[0063] The embodiment of the present invention provides a block diagram consensus method based on an extended cluster clustering algorithm. It should be noted that the block diagram consensus method based on an extended cluster clustering algorithm provided by the embodiment of the present invention can be executed by a device of a block diagram consensus method based on an extended cluster clustering algorithm. The block diagram consensus method based on an extended cluster clustering algorithm can be implemented as part or all of an electronic device through software, hardware, or a combination of software and hardware, wherein the electronic device can be a server or a terminal, wherein the server in the embodiment of the present application can be a single server or a server cluster composed of multiple servers, and the terminal in the embodiment of the present application can be a smart phone, a personal computer, a tablet computer, a wearable device, and other intelligent hardware devices such as an intelligent robot. In the following method embodiments, the execution subject is an electronic device as an example for explanation.
[0064] According to an embodiment of the present invention, an embodiment of a block graph consensus method based on an extended cluster clustering algorithm is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown here.
[0065] In this embodiment, a block graph consensus method based on an extended clustering algorithm is provided, which can be used in the above-mentioned electronic device. Figure 3 is a flowchart of a block graph consensus method based on an extended clustering algorithm according to an embodiment of the present invention, such as Figure 3 As shown, the process includes the following steps:
[0066] Step S301, obtain a target block map, perform hierarchical processing on the target block map, and construct a block support set based on the hierarchical processing result; the target block map is composed of a genesis block and reference reachable blocks.
[0067] Specifically, assume that there are n participants in a divergent graph-structured blockchain system. Each participant runs the same application, and each participant acts as an independent network node. The independent network nodes are interconnected through a peer-to-peer network, and a specified network node is initialized as the genesis block. Among them, participants join the network by creating public and private keys and generate corresponding blocks, which are broadcast to the network after being cryptographically signed.
[0068] Furthermore, in the divergent graph-structured blockchain system, at most f malicious participants are allowed to exist. The f malicious participants may be controlled by the same attacker and have no network latency with other participants. Let p(·) represent the computing power of participants to generate blocks, p(f) represent the computing power of malicious participants to generate blocks, and p(n) represent the computing power of loyal participants to generate blocks. Then it is required that p(f) < p(n) / 2, that is, most blocks in the generated target block graph are generated by loyal participants.
[0069] Furthermore, the blocks that can be traced back through the reference relationship in the target block graph are defined as reference-reachable blocks.
[0070] Step S302: Determine the block attributes based on the block support set, and calculate the aggregation degree score of the block support set based on the block attributes.
[0071] Step S303: Divide the block support set, and perform an aggregation degree scoring on the divided block support set to obtain the aggregation degree score of the divided set.
[0072] Specifically, a merging algorithm is designed within the block support set and clustering is performed upward. The binary classification of the block support set is calculated using the minimum cut idea to obtain the divided set.
[0073] Step S304: Compare the aggregation degree score of the block support set with the aggregation degree score of the divided set, and determine the block graph consensus result based on the comparison result.
[0074] The block graph consensus method based on the extended cluster clustering algorithm provided in this embodiment obtains the target block graph, performs hierarchical processing on the target block graph, and constructs a block support set based on the hierarchical processing result. The target block graph consists of the genesis block and reference-reachable blocks. Furthermore, the block attributes are determined based on the block support set, and the aggregation degree score of the block support set is calculated based on the block attributes. The block support set is divided, and an aggregation degree scoring is performed on the divided block support set to obtain the aggregation degree score of the divided set. Finally, the aggregation degree score of the block support set is compared with the aggregation degree score of the divided set, realizing the confirmation of the block graph consensus result, ensuring the backward consistency of the block graph consensus result, and thus improving the stability of the block graph consensus result.
[0075] In this embodiment, a block graph consensus method based on an extended clustering algorithm is provided, which can be used in the above-mentioned electronic device. Figure 4 is a flowchart of a block graph consensus method based on an extended clustering algorithm according to an embodiment of the present invention, such as Figure 4 As shown, the process includes the following steps:
[0076] Step S401, obtain a target block map, perform hierarchical processing on the target block map, and construct a block support set based on the hierarchical processing result; the target block map is composed of a genesis block and reference reachable blocks.
[0077] Specifically, the above step S401 includes:
[0078] Step S4011, defining the block height of each block in the target block map; wherein the block height of the referenced reachable block is determined according to the block height of the genesis block and the block reference relationship.
[0079] Specifically, assuming that the block height of the genesis block is 1, determine the block reference relationship of the reachable block in the target block graph, and determine the maximum block height among the blocks with the block reference relationship, and add one to the maximum block height to determine the block height of the reachable block.
[0080] Step S4012, hierarchically processing the target block map according to the block height to obtain multi-layer reference reachable blocks.
[0081] Step S4013: cluster the reference-reachable blocks at each layer based on the block reference relationship, and construct a block support set based on the clustering result.
[0082] Specifically, a block support set is constructed for each layer of block reference reachable blocks, where for any reference reachable block b i , through the function r(b i ) represents the set of all blocks that have a reference relationship with the reference reachable block, that is, the block support set. The block support set can be expressed as:
[0083] r(b i )={b j |path(b j ,b i )=1,b i ,b j ∈G} (1)
[0084] Among them, path(b j ,b i ) indicates that from block b j To block b iThe reference path judgment function, when the function return value is 1, it means there is a path to reach, the return value is 0, it means there is no path, G represents the target block graph.
[0085] Furthermore, the process of obtaining the block support set is as follows Figure 5 As shown in the figure, the target block graph G is layered according to the block height, and the blocks in each layer are clustered. For example, the referenced reachable blocks b5, b6, and b7 with a block height of 3 are selected, and the block support sets corresponding to the referenced reachable blocks b5, b6, and b7 are respectively expressed as:
[0086] r(b5)={b8,b9,b 12 ,b 13 ,b 14 ,b 16 ,b 17 ,b 18 ,b 19} (2)
[0087] r(b6)={b8,b9,b 10 ,b 12 ,b 13 ,b 14 ,b 15 ,b 16 ,b 17 ,b 18 ,b 19} (3)
[0088] r(b7)={b 11 ,b 15 ,b 18 ,b 19} (4)
[0089] Step S402: determine the block attributes based on the block support set, and calculate the clustering score of the block support set based on the block attributes. Figure 3 Step S302 of the illustrated embodiment will not be described in detail here.
[0090] Step S403, divide the block support set, and score the clustering degree of the divided block support set to obtain the clustering degree score of the divided set. Figure 3 Step S303 of the illustrated embodiment will not be described in detail here.
[0091] Step S404, compare the clustering score of the block support set with the clustering score of the partition set, and determine the block graph consensus result based on the comparison result. Figure 3 Step S304 of the illustrated embodiment will not be described in detail here.
[0092] The block graph consensus method based on the extended clustering algorithm provided in this embodiment defines the block height of each block in the target block graph; wherein the block height of the referenced reachable block is determined according to the block height of the genesis block and the block reference relationship; and then the target block graph is layered according to the block height to obtain multi-layer referenced reachable blocks; finally, the multi-layer referenced reachable blocks are clustered to obtain a block support set, thereby increasing the possibility of reference reachability of new blocks, thereby ensuring the backward consistency of the block graph consensus result.
[0093] In this embodiment, a block graph consensus method based on an extended clustering algorithm is provided, which can be used in the above-mentioned electronic device. Figure 6 is a flowchart of a block graph consensus method based on an extended clustering algorithm according to an embodiment of the present invention, such as Figure 6 As shown, the process includes the following steps:
[0094] Step S601, obtain the target block map, perform hierarchical processing on the target block map, and construct a block support set based on the hierarchical processing result; the target block map consists of the genesis block and the reference reachable blocks. For details, please refer to Figure 4 Step S401 of the illustrated embodiment will not be described in detail here.
[0095] Step S602: determining block attributes based on the block support set, and calculating the aggregation degree score of the block support set based on the block attributes.
[0096] Specifically, the above step S602 includes:
[0097] Step S6021, taking the size of the block support set as the volume of the point, and taking the size of the intersection between the block support sets as the weight of the edge.
[0098] Specifically, the block support set of each layer is reorganized through an undirected graph, and the size of the block support set is expressed as the volume of the point, where the expression of the point volume is as follows:
[0099] v(b i )=|r(b i )| (5)
[0100] Among them, v(b i ) represents block b i The size of the support set of , that is, the volume of points in the undirected graph.
[0101] Furthermore, let the size of the support set intersection be expressed as the edge weight, where the edge weight is expressed as follows:
[0102] w(b i ,b j )=|r(b i )∩r(bj )| (6)
[0103] Among them, w(b i ,b j ) represents block b j The support set and block b i The size of the intersection between the support sets of , that is, the weight of the edge in the undirected graph, r(b j ) represents block b j support set.
[0104] Specifically, Figure 7 As shown, the size of the support set of referenced reachable blocks b5, b6, and b7 is taken as the volume of the point, i.e., v(b5), v(b6), and v(b7), and the size of the intersection between referenced reachable blocks b5, b6, and b7 is taken as the weight of the edge, i.e., w(b5, b6), w(b6, b7), and w(b5, b7), thereby constructing an undirected graph based on the volume of the point and the weight of the edge.
[0105] Step S6022, calculating the set clustering coefficient corresponding to the block support set based on the volume of the points and the weight of the edges.
[0106] Specifically, the calculation formula of the set clustering coefficient is as follows:
[0107]
[0108] Among them, c(B) represents the clustering coefficient of block support set B.
[0109] For example, Figure 7 As shown, assuming that the block support set B = {b5, b6, b7}, the clustering coefficient of the block support set with a block height of 3 can be calculated. The calculation formula of the clustering coefficient of the block support set B is as follows:
[0110] c(B)=(9+2+3) / (9+4+4)=14 / 17=0.824 (8)
[0111] Step S6023, calculating the clustering degree score of the block support set based on the point volume and the set clustering coefficient.
[0112] Specifically, the calculation formula for the clustering score of the block support set is as follows:
[0113]
[0114] Where s(B) represents the clustering score of the block support set.
[0115] Specifically, the calculation formula for the clustering score of block set B with a height of 3 is as follows:
[0116] s(B)=0.824*12=9.888 (10)
[0117] Step S603, partitioning the block support set, and scoring the degree of aggregation of the partitioned block support set to obtain the degree of aggregation score of the partitioned set.
[0118] Specifically, the above step S603 includes:
[0119] Step S6031, comparing the number of blocks in the block support set with a preset threshold, if the number of blocks in the block support set is greater than the preset threshold, determining a block list based on block attributes.
[0120] Specifically, assuming that the preset threshold is 2, when the number of blocks in the block support set is greater than 2, a block list is established based on the volume of the corresponding points in the block support set and the weight of the edge. The block list can be expressed as:
[0121] x=[w(b i ,b j ),min(v(b i ),v(b j ))],b i ,b j ∈B (11)
[0122] Among them, x represents the block list.
[0123] Step S6032: sort the block list, and merge the blocks in the block support set based on the sorting result to obtain a partition set.
[0124] Specifically, the step of sorting the block list includes: sorting the block list from large to small according to the weight of the edge; if the weights of the edges are the same, sorting them from large to small according to the minimum volume of the points, and finally determining the first two blocks in the block list according to the sorting result, and merging the first two blocks. The merged block set can be expressed as:
[0125] y = {b′ i ,b′ j} (12)
[0126] Among them, y represents the merged block set, b′ i and b′ j Indicates two blocks to be merged.
[0127] Furthermore, the merged set (i.e., partition set) B′ can be expressed as:
[0128] B′=(Bb′ i -b′ j )+y (13)
[0129] Wherein, B′ represents the partition set.
[0130] Step S6033, scoring the degree of aggregation of the partition set to obtain the degree of aggregation score of the partition set.
[0131] Specifically, the clustering degree score of the partition set is scored, and the clustering degree score of the partition set is used as the objective function to guide whether to continue the partitioning; wherein, the calculation formula of the clustering degree score of the partition set is as follows:
[0132]
[0133] Here, k represents the number of divided sets, and k=1 means that the block support set B is not divided.
[0134] For example, Figure 8 As shown, the block support set B = {b5, b6, b7} is divided into {b5, b6} and {b7}, and the partition set B′ = {{b5, b6}, {b7}}. The clustering score of the partition set B′ is:
[0135] s(B′,2)=1*11+1*4-2*(3 / 4) 2 *12=1.5 (15)
[0136] Step S604, compare the clustering score of the block support set with the clustering score of the partition set, and determine the block graph consensus result based on the comparison result. Figure 4 Step S404 of the illustrated embodiment will not be described in detail here.
[0137] The block graph consensus method based on the extended clustering algorithm provided in this embodiment determines a block list based on block attributes if the number of blocks in the block support set is greater than a preset threshold; then sorts the block list, and merges the blocks in the block support set based on the sorting result to obtain a partition set; finally, scores the degree of aggregation of the partition set to obtain a degree of aggregation score of the partition set, which provides a basis for judging the degree of aggregation of the partition set and lays a foundation for determining the block graph consensus result.
[0138] In this embodiment, a block graph consensus method based on an extended clustering algorithm is provided, which can be used in the above-mentioned electronic device. Fig. 9 is a flowchart of a block graph consensus method based on an extended clustering algorithm according to an embodiment of the present invention, such as Fig. 9 As shown, the process includes the following steps:
[0139] Step S901, obtain the target block map, perform hierarchical processing on the target block map, and construct a block support set based on the hierarchical processing result; the target block map consists of the genesis block and the reference reachable blocks. For details, please refer to Figure 6 Step S601 of the illustrated embodiment will not be described in detail here.
[0140] Step S902: determine the block attributes based on the block support set, and calculate the clustering score of the block support set based on the block attributes. Figure 6 Step S602 of the illustrated embodiment will not be described in detail here.
[0141] Step S903, divide the block support set, and score the clustering degree of the divided block support set to obtain the clustering degree score of the divided set. Figure 6 Step S603 of the illustrated embodiment will not be described in detail here.
[0142] Step S904: compare the clustering score of the block support set with the clustering score of the partition set, and determine the block graph consensus result based on the comparison result.
[0143] Specifically, the above step S904 includes:
[0144] Step S9041, comparing the clustering score of the block support set with the clustering score of the partition set.
[0145] Step S9042: If the clustering score of the block support set is greater than or equal to the clustering score of the partition set, the target block graph is partitioned based on the partition set to obtain block subgraphs, and the block subgraphs are used as the block graph consensus results.
[0146] Specifically, if the clustering score of the block support set is less than the clustering score of the partition set, the partition set is partitioned until the clustering score of the partition set is greater than or equal to the clustering score of the partitioned set, and the partitioning is stopped to obtain the partitioned set, and the block graph consensus result is determined based on the partitioned set.
[0147] Furthermore, if the clustering score of the block support set is less than the clustering score of the partition set, the block support set is replaced with the partition set, and the above steps S601-S604 are repeated until the clustering score of the partition set is greater than or equal to the clustering score of the partitioned set, and the partitioning is stopped.
[0148] The block graph consensus method based on the extended clustering algorithm provided in this embodiment compares the aggregation degree score of the block support set with the aggregation degree score of the partition set; further, if the aggregation degree score of the block support set is greater than or equal to the aggregation degree score of the partition set, the target block graph is partitioned based on the partition set to obtain block subgraphs, and the block subgraphs are used as the block graph consensus results, thereby realizing the determination of the block graph consensus results, improving the intersection scale of the support sets in the block graph consensus results, and thus improving the security of the block graph consensus results.
[0149] The following is a specific example to illustrate the specific steps and effects of a block graph consensus method based on an extended clustering algorithm.
[0150] Embodiment 1:
[0151] The specific steps of the block graph consensus method based on the extended clustering algorithm include:
[0152] The target block graph is layered according to the block height, the blocks in each layer are clustered, and the set of blocks that are reachable by reference to the specified block is used as the support set of the block.
[0153] The size of the block support set is taken as the volume of the point, and the size of the intersection of support sets between different blocks is taken as the weight of the edge, and then the clustering degree score of the block support set is calculated.
[0154] A merging algorithm is designed within the block support set to cluster upwards, and the binary classification of the block support set is calculated using the minimum partitioning idea to obtain a partition set; the binary merging algorithm is described as follows:
[0155] 1) Input block support set B, where |B| is the number of blocks in block support set B. If |B|≤2, then directly return block support set B;
[0156] 2) Calculate the block list x = [w(b i ,b j ),min(v(b i ),v(b j ))],b i ,b j ∈B;
[0157] 3) Sort the block list x from large to small, and take the pair of points with the largest sorting result (i.e. the first two blocks in the block list) (b′ i ,b′ j );
[0158] 4) Merge the first two blocks in the block list, y is the merged block set, that is, y = {b′ i ,b′ j};
[0159] 5) Calculate the partition set B′=(Bb′ i -b′ j )+y;
[0160] 6) Let B=B′ and recursively call the current algorithm.
[0161] The degree of clustering of the partition set is scored, and the score is used as the objective function to guide whether the partitioning should continue.
[0162] Taking the score function as the objective function, a clustering partitioning algorithm is designed. The clustering partitioning algorithm is described as follows:
[0163] 1) Initialize the set list L = [B], sort the block support sets in the list from large to small according to the scores, and take the block support set B = L[0];
[0164] 2) Perform the binary merge algorithm on the block support set B to obtain the partition set B′, and calculate the clustering score s(B,1) of the block support set and the clustering score s(B′,2) of the partition set;
[0165] 3. If s(B,1)≥s(B′,2), stop partitioning and return the set L[0] with the largest clustering score;
[0166] 4. Replace the block support set B in the set list L with the two subsets in the partition set B′, and execute the cluster partitioning algorithm in a loop.
[0167] In summary, by defining the clustering degree score and designing the merging and partitioning algorithms, the corresponding subset output is calculated at each layer of block height, and the above scheme is applied to each layer in the target block graph, and finally a block subgraph is formed as the block graph consensus result.
[0168] Embodiment 2:
[0169] The effects of the block graph consensus method based on the extended clustering algorithm include:
[0170] By comparing the block graph consensus method based on the extended clustering algorithm, Phantom and UL-BlockDAG, it can be seen that the block graph consensus method based on the extended clustering algorithm is superior to the other two schemes in terms of throughput. The rough results obtained by performing a simulation experiment for 1000 steps show that through normalization operations, the block graph consensus method based on the extended clustering algorithm has a throughput of nearly 0.86, the Phantom scheme has a throughput of nearly 0.63, and the UL-BlockDAG scheme has a throughput of nearly 0.4.
[0171] In addition, backward consistency is measured by recording changes in block determination results during the consensus execution process; the test results of rough experiments are that the block graph consensus method based on the extended clustering algorithm is 1, the Phantom solution is 0.97, and the UL-BlockDAG solution is 0.40.
[0172] In terms of security, an attacker is introduced to carry out selfish attacks and the number of successful attacks is recorded under specified system parameters. The same as the rough experimental configuration above, the number of successful attacks of the block graph consensus method based on the extended clustering algorithm is 0, the number of successful attacks of the Phantom scheme is 2, and the number of successful attacks of the UL-BlockDAG scheme is 4.
[0173] In this embodiment, a block diagram consensus device based on an extended clustering algorithm is also provided, which is used to implement the above embodiments and preferred implementations, and will not be repeated for what has been described. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0174] This embodiment provides a block graph consensus device based on an extended clustering algorithm, such as Fig.10 As shown, including:
[0175] The hierarchical module 1001 is used to obtain a target block map, perform hierarchical processing on the target block map, and construct a block support set based on the hierarchical processing result; the target block map is composed of a genesis block and reference reachable blocks.
[0176] The calculation module 1002 is used to determine the block attributes based on the block support set, and calculate the clustering degree score of the block support set based on the block attributes.
[0177] The scoring module 1003 is used to divide the block support set, and score the degree of aggregation of the divided block support set to obtain the degree of aggregation score of the divided set.
[0178] The comparison module 1004 is used to compare the clustering degree score of the block support set with the clustering degree score of the partition set, and determine the block graph consensus result based on the comparison result.
[0179] In some optional implementations, the layering module 1101 includes:
[0180] The definition unit is used to define the block height of each block in the target block map; wherein the block height of the referenced reachable block is determined according to the block height of the genesis block and the block reference relationship.
[0181] The hierarchical unit is used to hierarchically process the target block map according to the block height to obtain multi-layer reference reachable blocks.
[0182] The clustering unit is used to cluster the blocks reachable by reference at each layer based on the block reference relationship, and to build a block support set based on the clustering results.
[0183] In some optional implementations, the calculation module 1102 includes:
[0184] As a unit, it is used to take the size of the block support set as the volume of the point and the size of the intersection between the block support sets as the weight of the edge.
[0185] The first calculation unit is used to calculate the set clustering coefficient corresponding to the block support set based on the volume of the points and the weight of the edges.
[0186] The second calculation unit is used to calculate the clustering degree score of the block support set based on the volume of the points and the set clustering coefficient.
[0187] In some optional implementations, the scoring module 1003 includes:
[0188] The determination unit is used to compare the number of blocks in the block support set with a preset threshold, and if the number of blocks in the block support set is greater than the preset threshold, determine the block list based on the block attributes.
[0189] The merging unit is used to sort the block list, and merge the blocks in the block support set based on the sorting result to obtain a partition set.
[0190] The scoring unit is used to score the degree of aggregation of the partition set to obtain the degree of aggregation score of the partition set.
[0191] In some optional implementations, the comparison module 1004 includes:
[0192] The comparison unit is used to compare the clustering degree score of the block support set with the clustering degree score of the partition set.
[0193] The partitioning unit is used to partition the target block graph based on the partitioning set to obtain block subgraphs if the aggregation degree score of the block support set is greater than or equal to the aggregation degree score of the partitioning set, and use the block subgraphs as the block graph consensus results.
[0194] In some optional embodiments, the comparison module 1004 is also used to divide the partitioned set if the clustering score of the block support set is less than the clustering score of the partitioned set, until the clustering score of the partitioned set is greater than or equal to the clustering score of the partitioned set, stop dividing, obtain the partitioned set, and determine the block graph consensus result based on the partitioned set.
[0195] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0196] In this embodiment, a block graph consensus device based on an extended cluster clustering algorithm is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0197] The embodiment of the present invention also provides a computer device having the above Fig.10 The block graph consensus device based on the extended clustering algorithm is shown.
[0198] See also Fig.11 , Fig.11 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Fig.11 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.11 A processor 10 is taken as an example.
[0199] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0200] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0201] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0202] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0203] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 1220, the input device 30 and the output device 40 may be connected via a bus or other means. Fig.11 The example of connecting through bus is taken in the following.
[0204] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0205] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0206] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0207] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A block graph consensus method based on an extended clustering algorithm, characterized in that: The method comprises: Obtaining a target block graph, performing hierarchical processing on the target block graph, and constructing a block support set based on the hierarchical processing result; the target block graph is composed of a genesis block and reference reachable blocks; Determining block attributes based on the block support set, and calculating a clustering degree score of the block support set based on the block attributes; Dividing the block support set, and scoring the degree of aggregation of the divided block support set to obtain a degree of aggregation score of the divided set; The clustering degree score of the block support set is compared with the clustering degree score of the partition set, and the block graph consensus result is determined based on the comparison result.
2. The method according to claim 1, characterized in that The step of obtaining a target block map, performing hierarchical processing on the target block map, and constructing a block support set based on the hierarchical processing result includes: Defining the block height of each block in the target block map; wherein the block height of the referenced reachable block is determined according to the block height of the genesis block and the block reference relationship; The target block graph is layered according to the block height to obtain multi-layer reference reachable blocks; Based on the block reference relationship, the blocks reachable by reference at each layer are clustered respectively, and a block support set is constructed based on the clustering result.
3. The method according to claim 1, characterized in that The determining of the block attribute based on the block support set, and calculating the aggregation degree score of the block support set based on the block attribute, includes: The size of the block support set is used as the volume of the point, and the size of the intersection between the block support sets is used as the weight of the edge; Calculating a set clustering coefficient corresponding to the block support set based on the volume of the point and the weight of the edge; The clustering degree score of the block support set is calculated based on the volume of the points and the set clustering coefficient.
4. The method according to claim 1, characterized in that: The step of dividing the block support set and scoring the degree of aggregation of the divided block support set to obtain the degree of aggregation score of the divided set includes: Comparing the number of blocks in the block support set with a preset threshold, and if the number of blocks in the block support set is greater than the preset threshold, determining a block list based on the block attributes; Sorting the block list, and merging the blocks in the block support set based on the sorting result to obtain a partition set; The clustering degree score is performed on the partition set to obtain the clustering degree score of the partition set.
5. The method according to claim 1, characterized in that: The comparing the clustering degree score of the block support set with the clustering degree score of the partition set, and determining the block graph consensus result based on the comparison result, includes: Comparing the clustering degree score of the block support set with the clustering degree score of the partition set; If the aggregation degree score of the block support set is greater than or equal to the aggregation degree score of the partition set, the target block graph is partitioned based on the partition set to obtain a block subgraph, and the block subgraph is used as the block graph consensus result.
6. The method according to claim 5, characterized in that The comparing the clustering degree score of the block support set with the clustering degree score of the partition set, and determining the block graph consensus result based on the comparison result, further includes: If the clustering score of the block support set is less than the clustering score of the partition set, the partition set is partitioned until the clustering score of the partition set is greater than or equal to the clustering score of the partitioned set, and the partitioning is stopped to obtain the partitioned set, and the block graph consensus result is determined based on the partitioned set.
7. A block graph consensus device based on an extended clustering algorithm, characterized in that: The device comprises: A construction module, used to obtain a target block graph, perform hierarchical processing on the target block graph, and construct a block support set based on the hierarchical processing result; the target block graph is composed of a genesis block and reference reachable blocks; A calculation module, configured to determine block attributes based on the block support set, and calculate a clustering degree score of the block support set based on the block attributes; A scoring module is used to divide the block support set, and score the degree of aggregation of the divided block support set to obtain the degree of aggregation score of the divided set; A comparison module is used to compare the aggregation degree score of the block support set with the aggregation degree score of the partition set, and determine the block graph consensus result based on the comparison result.
8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the block graph consensus method based on the extended clustering algorithm as described in any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the block graph consensus method based on the extended cluster clustering algorithm described in any one of claims 1 to 6.
10. A computer program product, characterized in that It comprises computer instructions, and the computer instructions are used to make a computer execute the block graph consensus method based on the extended cluster clustering algorithm described in any one of claims 1 to 6.