Blockchain sharding method and apparatus fusing community and graph partition, and computing device
By adopting a blockchain sharding method that integrates community discovery and graph partitioning in an IoT environment, the problems of low transaction efficiency and poor scalability are solved, and more efficient transaction processing and network throughput are achieved.
Patent Information
- Application Number
- CN202310711241.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-14
- Publication Date
- 2026-03-20
- Estimated Expiration
- 2043-06-14
AI Technical Summary
Existing blockchain sharding protocols suffer from problems such as low transaction efficiency, poor scalability, low cross-shard transaction confirmation efficiency, and uneven transaction distribution in IoT environments, making it difficult to improve network throughput while ensuring decentralization and security.
The method combines community discovery and graph partitioning. By acquiring the transaction ledger of blockchain shards at the end of each epoch, a graph structure data is constructed. The Louvain community discovery algorithm is used to partition communities, and the HDRF graph partitioning algorithm is combined to optimize sharding. Finally, the optimal sharding is evaluated based on the simulated annealing algorithm, nodes are assigned to different shards, and the state ledger is configured.
It significantly reduces the probability of cross-shard transactions, reduces shard congestion, and improves the transaction processing efficiency of the blockchain network.
Smart Images

Figure CN117033507B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of blockchain, and particularly relates to a blockchain sharding method fusing community and graph partitioning and a computing device. BACKGROUND
[0002] Blockchain can be applied to the Internet of Things environment as a solution for network and device security due to its characteristics of decentralization, non-tamperability and full traceability. However, blockchain technology requires global consensus and stores global account books, and the transactions between Internet of Things devices also obey a power-law distribution, so that the Internet of Things devices cannot build a blockchain by using their own computing power and storage.
[0003] Blockchain sharding technology divides the original blockchain into several smaller sub-sharded blockchains through a database sharding-like idea, each sub-shard processes transactions in parallel, and stores the transaction account books in the sub-shard, so as to improve the transaction efficiency of the whole network and reduce the storage pressure. The sharding protocols in the prior art include Rapidchain, monoxide and brokerchain sharding protocols. Rapidchain reduces the number of cross-shard transactions through routing transactions and a limited cuckoo protocol, but this method cannot balance the transaction load in each shard. Monoxide greatly improves the transaction processing capacity of the whole network by dividing the consensus group and Zhugeliang crossbow mining, but more than 90% of cross-shard transactions still consume a large amount of additional resources. Brokerchain reduces cross-shard transactions through metis graph partitioning and modified state trees, but the metis algorithm needs to obtain a static global view and its efficiency is not good in a large-scale graph.
[0004] The sharding protocol can effectively solve the problems of low transaction efficiency and poor scalability of blockchain, but the sharded blockchain also faces problems such as low cross-shard transaction confirmation efficiency and uneven transaction distribution. Therefore, how to reduce cross-shard transactions, improve running efficiency and increase network throughput while ensuring the decentralization and security of the blockchain is a hot research topic at present. SUMMARY
[0005] To solve the problems in the background art, the embodiments of the present application provide a blockchain sharding method fusing community discovery and graph partitioning and a computing device, which optimizes the sharded blockchain through community aggregation based on a community discovery algorithm and node partitioning based on graph partitioning, thereby improving the transaction and storage efficiency in the Internet of Things.
[0006] To solve the above technical problems, the embodiments of the present application provide a blockchain sharding method fusing community discovery and graph partitioning, which comprises:
[0007] S1. At the end of each round epoch, obtain the transaction ledger of each shard of the blockchain in the round, and process the transaction ledger to obtain the graph structure data of the transaction;
[0008] S2. Community division is performed on the graph data structure of the transaction to obtain a community state graph;
[0009] S3. The community state graph of the transaction is divided to obtain a division result of the transaction data in the current period;
[0010] S4. The division result of the node is evaluated and calculated until the optimal shard division of the blockchain is obtained;
[0011] S5. According to the optimal shard division, the node is divided into different shards, and a state ledger is configured for the divided account.
[0012] Preferably, the obtaining of the transaction ledger of each shard of the blockchain in the round and the processing of the transaction ledger to obtain the graph structure data of the transaction specifically comprises:
[0013] The running time of the consensus phase and the running time of the reconfiguration phase in each epoch period are respectively T c and T r In the reconfiguration phase after the end of each consensus phase, the blockchain obtains the transaction ledger in all shards in the form of Gossip broadcast;
[0014] The obtained transaction ledger of each shard is integrated, and the transaction address information of the sender and the receiver in the transaction ledger is extracted to construct a graph structure data G(v, e), wherein v is the node address of the transaction parties, and e is the transaction itself, indicating the connectivity between the node addresses of the transaction parties.
[0015] Preferably, the community division of the graph data structure of the transaction to obtain a community state graph specifically comprises:
[0016] S201. According to the number of nodes in the graph structure data G(v, e), the same number of communities as the number of nodes e is created, and each node is allocated to a community, and the modularity Q of each community is calculated:
[0017]
[0018] Wherein ∑ in represents the sum of the degrees D of the points of the community, ∑ tot represents the sum of the number of edges e connected with the points inside the community, and m is the sum of the number of all edges in the graph, and the degree D is the sum of the number of edges connected with the node v;
[0019] S202. The modularity gain ΔQ of all nodes to the neighbor community is calculated,
[0020]
[0021] Where, k i,in The degree D of node i to community c is represented by the sum of degrees D; the modularity gain represents the strength of the connectivity between a node and the community. The stronger the connectivity between a node and the community, the greater the modularity gain.
[0022] S203. Assign nodes to the community with the largest modularity gain. If the modularity gain is not greater than 0, do not move nodes until the modularity no longer changes. All nodes are assigned to the corresponding community.
[0023] S204. In the community aggregation phase, the community formed by the nodes is constructed into a new node. According to the connectivity between the new nodes, the new nodes are reconstructed into a new graph G'. The sum of the degrees D of the nodes inside the new node can be regarded as the degree D' of the new node.
[0024] S205. Calculate the modularity gain of the new node and other node communities in the new graph G' until the network is no longer divisible, and output all communities and their contained nodes.
[0025] Preferably, the step of dividing the community state graph of transactions to obtain the division result of transaction data in the current period specifically includes:
[0026] S301. Sort the obtained community and its contained node data in descending order of community size, and reconstruct the graph structure data G(v,e);
[0027] S302. According to the graph structure data G(v,e), read one edge e sequentially, and use the formula θ(V i )=1-δ(V j For the node V corresponding to edge e, i With V j The degree D is normalized.
[0028] S303. Read all edges in the graph structure data G(v,e) and use the formula... Calculate the evaluation score of each edge e on k partitions, and assign the edge e to the partition with the highest score to complete the partitioning of transactions;
[0029] Among them, through the formula Calculate the node V corresponding to edge e respectively. i With V j For the containment states of the k partitions to be divided, g(v,p) is determined by... Calculate the score of the current edge e for all shards k. A(v) represents the set of shards where node v is located when node v exists in multiple shards. When a node is not in any shard, its score is set to 0.
[0030] The penalty score of the point v to each shard p is calculated by the formula Where |p| represents the number of nodes divided into the p shard, λ is used to control the degree of imbalance of the partition size, the initial value is 1, maxsize is the maximum number of edges in the sub-shard, minsize is the minimum number of edges in the sub-shard, and E is a constant with a value of 0.01.
[0031] Preferably, the evaluation and calculation of the division result of the nodes are performed until the optimal shard division of the blockchain is obtained, which specifically includes:
[0032] S401. Calculate the replication score of this round of division and the division running time T i , where |V| is the sum of the number of nodes v in the original transaction data set, and |V'| is the sum of the number of nodes after division. Record the minimum replication score as the replication score, and keep the current shard scheme;
[0033] S402. Select a value for λ in (1, 2), divide the ledger again, and evaluate the new replication score. If the current replication score is less than the minimum replication score, set the current minimum replication score as the replication score of this round, and replace the minimum replication score with the shard scheme corresponding to the minimum replication score. If the current replication score is greater than the minimum replication score, calculate the probability and compare it with a random value 0 < r < 1. If p is greater than r, update the value of λ. If p is less than r, do not accept the value, and keep the existing value of λ unchanged. Where r i is the current replication score;
[0034] S403. When the total execution time |T i | is less than , execute S401-S402 in a loop until the time exceeds The optimal shard division is the scheme corresponding to the current minimum replication score.
[0035] Preferably, according to the optimal shard division, the nodes are divided into different shards, and the state ledger is configured for the divided accounts, which specifically includes:
[0036] S501. According to the optimal shard division, the nodes are divided into ordinary accounts and division accounts. If an account only appears in a single partition in the final division, the account is an ordinary account. If the account appears in multiple partitions, the account is a division account.
[0037] S502. In the global ledger, the normal account is stored as a one-to-one correspondence between the account and the shard where the address is located, the state ledger of the account is transferred to the new shard, and the state ledger of the original shard will be deleted. When there is a new transaction request to the account, the transaction request will be allocated to the new shard;
[0038] S503. According to the optimal shard division, the divided account is opened in all shards to which the divided account belongs, and the account address in the state ledger of the divided account corresponds to the set of shards where the account is located.
[0039] On the other hand, in order to solve the technical problems of the present application, the embodiments of the present application also provide a blockchain sharding device integrating community discovery and graph division, the device comprising:
[0040] At the end of each round epoch, a first unit acquires the transaction ledger of each shard of the blockchain in the round and processes the transaction ledger to obtain the graph structure data of the transaction;
[0041] A second unit performs community division on the graph data structure of the transaction to obtain a community state graph;
[0042] A third unit divides the community state graph of the transaction to obtain a division result of the transaction data in the current period;
[0043] A fourth unit evaluates and calculates the division result of the node until an optimal shard division of the blockchain is obtained;
[0044] A fifth unit divides the node into different shards according to the optimal shard division and configures a state ledger for the divided account.
[0045] In a third aspect, the embodiments of the present application also provide a computer readable storage medium, which stores computer code, when the computer code is executed, the foregoing blockchain sharding method integrating community discovery and graph division is executed.
[0046] In a fourth aspect, the embodiments of the present application also provide a computer device, which comprises:
[0047] One or more processors;
[0048] A memory for storing one or more computer programs;
[0049] When the one or more computer programs are executed by the one or more processors, the one or more processors implement the foregoing blockchain sharding method integrating community discovery and graph division.
[0050] Compared with the prior art, the beneficial effects of the technical scheme of the present application are as follows:
[0051] By obtaining all transaction records of each shard recorded by the blockchain during operation at the end of every other epoch, and processing the transaction data, the transactions are aggregated into a community structure using the Louvain community discovery algorithm based on the processed graph structure data, and the transactions are reordered again; then the graph structure data is divided using the HDRF graph division algorithm, and the division result of the transaction data in the current period is obtained; the division result of the nodes is evaluated multiple times until the optimal division is obtained according to the simulated annealing algorithm; and the nodes are divided into different shards p i According to the present application, the probability of cross-shard transaction can be significantly reduced, thereby reducing the shard congestion caused by cross-shard transaction and improving the efficiency of the blockchain network in processing transactions. BRIEF DESCRIPTION OF DRAWINGS
[0052] The specific embodiments of the present application will be described below with reference to the accompanying drawings.
[0053] Figure 1 A flowchart of a blockchain sharding method combining community discovery and graph division according to an embodiment of the present application;
[0054] Figure 2 A flowchart of a community discovery method for a blockchain sharding method combining community discovery and graph division according to an embodiment of the present application;
[0055] Figure 3 A flowchart of graph division and simulated annealing for a blockchain sharding method combining community discovery and graph division according to an embodiment of the present application;
[0056] Figure 4 An effect diagram of a blockchain sharding method combining community discovery and graph division according to an embodiment of the present application. DETAILED DESCRIPTION
[0057] Before discussing the example embodiments in more detail, it is to be noted that some example embodiments are described as processes or methods depicted as flowcharts. Although the processes are described in a particular sequential order, many of the processes can be performed concurrently, in parallel, or simultaneously. In addition, the order of the processes can be re-arranged. The processes can terminate when their operations are completed, but can also terminate in response to other events not depicted in the flowcharts. The processes can correspond to methods, functions, procedures, subroutines, subprograms, etc.
[0058] The method according to the present application is implemented by a device included in a computer device. The computer device refers to an intelligent electronic device that can perform a predetermined processing procedure such as numerical calculation and / or logical calculation by running a predetermined program or instruction, which can include a processor and a memory, perform the predetermined processing procedure by the processor executing a pre-stored instruction in the memory, or perform the predetermined processing procedure by an ASIC (application specific integrated circuit), an FPGA (field programmable gate array), a DSP (digital signal processor), an embedded device, or the like, or a combination of the above.
[0059] The computer device includes a user device and a network device. The user device includes, but is not limited to, a computer, a smart phone, a PDA, and the like. The network device includes, but is not limited to, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of computers or network servers based on cloud computing. The cloud computing is a kind of distributed computing, which is composed of a super virtual computer of a group of loosely coupled computers. The computer device can be operated alone to implement the present application, or can be connected to a network and interact with other computer devices in the network to implement the present application. The network in which the computer device is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a VPN network, and the like.
[0060] The methods discussed in the following (some in flow charts) can be implemented by hardware, software, firmware, middleware, microcode, hardware description languages, or any combination thereof. When implemented in software, firmware, middleware or microcode, the program code or code segments to perform the necessary tasks can be stored in a machine or computer readable medium such as a storage medium. A processor(s) can perform the necessary tasks.
[0061] The specific structural and functional details disclosed herein are merely representative for purposes of describing the exemplary embodiments of the present application. The present application, however, can be embodied in many alternate forms and should not be construed as limited to the embodiments set forth herein.
[0062] It should be understood that although the terms "first" and "second" and the like can be used herein to describe various devices, these devices should not be limited by these terms. These terms are only used to distinguish one device from another. For example, a first device could be termed a second device, and, similarly, a second device could be termed a first device, without departing from the scope of example embodiments. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0063] It will be understood that when a device or apparatus is referred to as being "connected" or "coupled" to another device or apparatus, it can be directly connected or coupled to the other device or apparatus, or intervening devices or components can be present. By contrast, when an apparatus or device is referred to as being "directly connected" or "directly coupled" to another apparatus or device, there are no intervening devices or components present. Other words used to describe the relationship between devices or elements should be interpreted in a like fashion (e.g., "between" versus "directly between," "adjacent" versus "directly adjacent," etc.).
[0064] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of example embodiments. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0065] It should be noted that in some alternative implementations, the functions / acts described can occur out of the order described. For example, two sequentially depicted figures can in fact be executed substantially concurrently or can sometimes be executed in the reverse order depending upon the functionality / acts involved.
[0066] The application will be further described in conjunction with the figures.
[0067] As Figure 1 shown, to solve the above technical problems, a blockchain sharding method fusing community discovery and graph partitioning is provided, the method comprising:
[0068] S1. At the end of each round epoch, the transaction ledger of each shard of the blockchain in the round is obtained, and the transaction ledger is processed to obtain the graph structure data of the transaction;
[0069] S2. The community state graph is obtained by performing community partitioning on the graph data structure of the transaction;
[0070] S3. The community state graph of the transaction is partitioned to obtain the partitioning result of the transaction data in the current period;
[0071] S4. The partitioning result of the node is evaluated and calculated until the optimal sharding partitioning of the blockchain is obtained;
[0072] S5. According to the optimal sharding partitioning, the node is divided into different shards, and the state ledger is configured for the divided account.
[0073] The blockchain of the scheme runs in epochs, each epoch round sequentially performs a consensus phase and a reconfiguration phase, the consensus phase performs consensus and block output of transactions, and the reconfiguration phase divides transaction addresses according to transaction data of the current round.
[0074] Preferably, S1 specifically comprises:
[0075] The running time of the consensus phase and the running time of the reconfiguration phase in each epoch cycle are respectively T c and T r In the reconfiguration phase after each consensus phase, the blockchain obtains all intra-shard transaction ledgers in a Gossip broadcast manner;
[0076] The obtained transaction ledger of each shard is integrated, and the transaction address information of the sender and the receiver in the transaction ledger is extracted to construct a graph structure data G(v, e), wherein v is a node address of the transaction parties, and e is a transaction itself, indicating connectivity between the node addresses of the transaction parties.
[0077] In the reconfiguration phase after each consensus phase, the blockchain obtains all intra-shard transaction ledgers in a Gossip broadcast manner, and performs data processing on the transaction ledger data set;
[0078] Preferably, the data processing comprises: integrating the obtained transaction ledger of each shard, and extracting the transaction address information of the sender and the receiver in the transaction to construct a graph structure data G(v, e), wherein v is an account address of the transaction parties; and e is a transaction itself, indicating connectivity between the account addresses.
[0079] Preferably, as shown in Figure 2 S2 specifically comprises:
[0080] S201. According to the number of nodes in the graph structure data G(v, e), the same number of communities as the number of nodes e is created, each node is allocated to a community, and the modularity Q of each community is calculated:
[0081]
[0082] Where ∑ in represents the sum of the degrees D of the points of the community, ∑ tot represents the sum of the number of edges e connected with the points inside the community, and m is the sum of the number of all edges in the graph; and the degree D is the sum of the number of edges connected with the node v.
[0083] In the initial running, each node is regarded as a community, and the modularity of each community is calculated, wherein ∑ in represents the sum of the degrees D of the points of the community c, and ∑ totLet e represent the sum of the number of edges e connected to points inside community c, and m represent the sum of the number of all edges in the graph.
[0084] S202. Calculate the modularity gain ΔQ of all nodes with respect to their neighboring communities.
[0085]
[0086] Where, k i,in The degree D of node i to community c is represented by the sum of degrees D; the modularity gain represents the strength of the connectivity between a node and the community. The stronger the connectivity between a node and the community, the greater the modularity gain.
[0087] The Louvain algorithm process is divided into two stages: the modularity optimization stage and the community aggregation stage.
[0088] During the modularity optimization phase, the modularity gain of a node to its neighboring communities is calculated, and the node is assigned to a neighboring community based on the modularity gain.
[0089] During the community aggregation phase, each divided community is treated as a super node, a new network is constructed, and the modularity gain of the new network is recalculated.
[0090] The algorithm repeatedly executes the two phases of modularity optimization and community aggregation until the modularity can no longer be increased and the community size is fixed, at which point the algorithm stops.
[0091] S203. Assign nodes to the community with the largest modularity gain. If the modularity gain is not greater than 0, do not move nodes until the modularity no longer changes. All nodes are assigned to the corresponding community.
[0092] S204. In the community aggregation phase, the community formed by the nodes is constructed into a new node. According to the connectivity between the new nodes, the new nodes are reconstructed into a new graph G'. The sum of the degrees D of the nodes inside the new node can be regarded as the degree D' of the new node.
[0093] S205. Calculate the modularity gain of the new node and other node communities in the new graph G' until the network is no longer divisible, and output all communities and their contained nodes.
[0094] By calculating the modularity gain, it can be determined whether node i should be assigned to community c. The modularity gain of all nodes to communities is calculated iteratively until the modularity no longer changes, at which point all nodes are assigned to the corresponding communities. Nodes are assigned to the community with the maximum gain, and if the gain is not greater than 0, the nodes are not moved.
[0095] In the community aggregation phase, the community formed by the above nodes is constructed into a new node, and the new node is reconstructed into a new graph G'. The sum of the degrees D of the nodes inside the new node can be regarded as the degree D' of the new node.
[0096] Iterate again, calculate the modularity gain of the new node and other node communities in the new graph G', until the network is no longer divisible, and output all communities and the nodes they contain.
[0097] Preferred, such as Figure 3 As shown, the process of dividing the community state graph of transactions to obtain the division results of transaction data within the current period specifically includes:
[0098] S301. Sort the obtained community and its contained node data in descending order of community size, and reconstruct the graph structure data G(v,e);
[0099] S302. According to the graph structure data G(v,e), read one edge e sequentially, and use the formula θ(V i )=1-δ(V j For the node V corresponding to edge e, i With V j The degree D is normalized.
[0100] S303. Read all edges in the graph structure data G(v,e) and use the formula... Calculate the evaluation score of each edge e on k partitions, and assign the edge e to the partition with the highest score to complete the partitioning of transactions;
[0101] Among them, through the formula Calculate the node V corresponding to edge e respectively. i With V j For the containment states of the k partitions to be divided, g(v,p) is determined by... Calculate the score of the current edge e for all shards k. A(v) represents the set of shards where node v is located when node v exists in multiple shards. When a node is not in any shard, its score is set to 0.
[0102] Through formula Calculate the penalty score for point v with respect to each piece p. Where |p| represents the number of nodes assigned to partition p, λ controls the degree of imbalance in partition size in the calculation formula, its initial value is 1, maxsize is the number of edges in the largest subpartition, minsize is the number of edges in the smallest subpartition, and E is a constant with a value of 0.01.
[0103] Preferably, the evaluation and calculation of the node partitioning results until the optimal sharding partition of the blockchain is obtained specifically includes:
[0104] S401. Calculate the replication score for this round of partitioning. With the partitioned running time T iWherein, |V| is the sum of the number of nodes v in the original transaction data set, |V'| is the sum of the number of nodes after division, record the copy score as the minimum copy score, and keep the current shard scheme;
[0105] S402. Select a value of lambda in (1, 2), divide the ledger again, and evaluate the new copy score. If the current copy score is less than the minimum copy score, let the current minimum copy score be the copy score of this round, and replace the minimum copy score with the shard scheme corresponding to the minimum copy score. If the current copy score is greater than the minimum copy score, calculate the probability And compare it with a random value 0 < r < 1. If p is greater than r, update the value of lambda. If p is less than r, do not accept the value, and keep the existing value of lambda unchanged. Wherein r i Is the current copy score;
[0106] S403. When the total execution time |T i | is less than , execute S401-S402 in a loop until the time exceeds The optimal shard division is the scheme corresponding to the current minimum copy score.
[0107] Preferably, the node is divided into different shards according to the optimal shard division, and the state ledger of the divided account is specifically configured as:
[0108] S501. According to the optimal shard division, the nodes are divided into ordinary accounts and divided accounts. If an account only appears in a single partition in the final division, the account is an ordinary account. If the account appears in multiple partitions, the account is a divided account;
[0109] S502. In the global ledger, the ordinary account is stored as a one-to-one correspondence between the account and the address shard, and the state ledger of the account is transferred to the new shard. The original shard state ledger will be deleted. When there is a new transaction request to the account, the transaction request will be allocated to the new shard;
[0110] S503. According to the optimal shard division, a divided account is opened in all shards belonging to the divided account, and the account address in its state ledger will correspond to the set of shards where the account is located.
[0111] Specifically, a part of the account balance is saved in the shard in which the account is divided, and the quota is the ratio of the transaction volume in the round. The larger the transaction volume processed in the shard, the larger the balance amount retained. If a transaction is initiated to the account, the transaction will be allocated to the idle shard for processing. The shard first checks whether the balance of the account in the current shard can meet the transaction. If it meets, the transaction is confirmed and consensus in the shard; if the balance does not meet, the transaction will be forwarded to the next shard.
[0112] In another aspect, to solve the technical problems of the present application, the embodiments of the present application also provide a blockchain sharding device integrating community discovery and graph division, the device comprising:
[0113] At the end of each round epoch, a transaction ledger of each shard of the blockchain in the round is obtained, and the transaction ledger is processed to obtain a first unit of graph structure data of the transaction;
[0114] A second unit of community state graph is obtained by performing community division on the graph data structure of the transaction;
[0115] A third unit of division result of the transaction data in the current period is obtained by dividing the community state graph of the transaction;
[0116] A fourth unit of optimal sharding division of the blockchain is obtained by evaluating and calculating the division result of the node until the optimal sharding division of the blockchain is obtained;
[0117] According to the optimal sharding division, the node is divided into different shards, and a state ledger is configured for the divided account.
[0118] In a third aspect, the embodiments of the present application also provide a computer readable storage medium storing computer code, when the computer code is executed, the foregoing blockchain sharding method integrating community discovery and graph division is executed:
[0119] S1. At the end of each round epoch, a transaction ledger of each shard of the blockchain in the round is obtained, and the transaction ledger is processed to obtain a first unit of graph structure data of the transaction;
[0120] S2. A second unit of community state graph is obtained by performing community division on the graph data structure of the transaction;
[0121] S3. A third unit of division result of the transaction data in the current period is obtained by dividing the community state graph of the transaction;
[0122] S4. A fourth unit of optimal sharding division of the blockchain is obtained by evaluating and calculating the division result of the node until the optimal sharding division of the blockchain is obtained;
[0123] S5. According to the optimal shard division, the nodes are divided into different shards, and the state ledger is configured for the split account.
[0124] As Figure 4 shown in the above technical solutions conceived by the present application, compared with the prior art, the beneficial effects produced by the technical solutions adopted by the embodiments of the present application are as follows:
[0125] By obtaining all transaction records of each shard recorded in the running process of the blockchain at the end of every other epoch, and processing the transaction data, the transactions are aggregated into a community structure according to the processed graph structure data using the Louvain community discovery algorithm, and the transactions are reordered again; then the graph structure data is divided using the HDRF graph division algorithm, and the division result of the transaction data in the current period is obtained; according to the simulated annealing algorithm, the division result of the nodes is evaluated multiple times until the optimal division is obtained; and according to the optimal result of the division, the nodes are divided into different shards p i , and the state ledger is configured for the split account. Thus, the probability of cross-shard transaction can be significantly reduced, thereby reducing the shard congestion caused by cross-shard transactions and improving the efficiency of the blockchain network in processing transactions.
[0126] The software program of the present application can be executed by a processor to realize the steps or functions described above. Similarly, the software program (including related data structures) of the present application can be stored in a computer readable recording medium, such as a RAM memory, a magnetic or optical drive or a soft disk and the like. In addition, some steps or functions of the present application can be realized by hardware, such as a circuit cooperating with a processor to execute respective functions or steps.
[0127] Part of the present application can be applied as a computer program product, for example, computer program instructions, when executed by a computer, through the operation of the computer, the method and / or technical solutions according to the present application can be invoked or provided. The program instructions invoking the method of the present application can be stored in a fixed or removable recording medium, and / or transmitted through a data stream in a broadcast or other signal bearing medium, and / or stored in the working memory of the computer device running according to the program instructions. Here, according to one embodiment of the present application, the device includes a memory for storing computer program instructions and a processor for executing program instructions, wherein when the computer program instructions are executed by the processor, the device is triggered to run the method and / or technical solutions based on the aforementioned multiple embodiments according to the present application.
[0128] It will be obvious to a person skilled in the art that the application is not limited to the details of the above-described exemplary embodiments, but that the application can be implemented in other embodiments without departing from the scope of the application. The application is therefore not limited to the details of the above-described exemplary embodiments, but can be implemented in other specific forms without departing from the essential characteristics of the application. The embodiments should therefore be considered in all respects as illustrative and not restrictive, the scope of the application being defined by the appended claims rather than by the above description, and all changes which come within the meaning and range of equivalents of the claims are therefore intended to be embraced therein. Any reference signs in the claims should not be construed as limiting the claims concerned. The word "comprising" does not exclude other elements or steps not mentioned in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. Multiple elements can be provided by a single element provided that it functions in the same way. The expression "at least one of A and B" should be interpreted as "A or B or both A and B". The expression "at least one of A, B and C" should be interpreted as "A or B or C or any combination of A, B and C". The expression "at least one of A, B or C" should be interpreted as "A or B or C or any combination of A, B and C".
Claims
1. A blockchain sharding method integrating community discovery and graph partitioning, characterized in that, The method includes: S1. At the end of each epoch, obtain the transaction ledger of each shard of the blockchain in that epoch, process the transaction ledger, and obtain the graph structure data of the transactions; S2. Divide the graph data structure of transactions into communities to obtain a community state graph, specifically including: S201. Based on the graph structure data Given the number of nodes, create the same number of communities as the number of nodes, and assign each node to one community. Calculate the modularity Q of each community: ; in The sum of the degrees D of the points in the community. Let represent the sum of the number of edges e connected to points within the community, m be the sum of the number of all edges in the graph, and degree D be the sum of the number of edges connected to node v. S202. Calculate the modularity gain of all nodes with respect to their neighboring communities. , ; in, The degree D of node i to community c is represented by the sum of degrees D; the modularity gain represents the strength of the connectivity between a node and the community. The stronger the connectivity between a node and the community, the greater the modularity gain. S203. Assign nodes to the community with the largest modularity gain. If the modularity gain is not greater than 0, do not move nodes until the modularity no longer changes. All nodes are assigned to the corresponding community. S204. In the community aggregation phase, the communities formed by the nodes are constructed into new nodes, and the new nodes are reconstructed into a new graph according to the connectivity between them. The sum of the degrees D of the nodes inside the new node can be considered as the degree of the new node. ; S205. Calculate the new graph The modularity gain of the new node and other node communities is calculated until the network is no longer divisible, and all communities and their contained nodes are output. S3. Divide the community state graph of transactions to obtain the division results of transaction data within the current period, specifically including: S301. Sort the obtained community and its constituent node data in descending order of community size, and reconstruct the graph structure data. ; S302. According to the diagram structure data Read an edge e sequentially, and use the formula For the node corresponding to edge e and The degree D is normalized. S303. Read graph structure data All edges in the equation, expressed by the formula Calculate the evaluation score of each edge e on k partitions, and assign the edge e to the partition with the highest score to complete the partitioning of transactions; Among them, through the formula Calculate the nodes corresponding to edge e respectively and The containment state of the k partitions that need to be divided, Depend on Calculate the score of the current edge e for all segments k. This means that when node v exists in multiple shards, Let v be the set of shards in which v is located. The score of a node is set to 0 when it is not in any shard. Through formula Calculate the penalty score for point v with respect to each piece p. ,in, This indicates the number of nodes that are assigned to the p-th partition. Used to control the degree of imbalance in partition size in the calculation formula, its initial value is 1, maxsize is the number of inner edges of the largest sub-partition, minsize is the number of inner edges of the smallest sub-partition, and E is a constant with a value of 0.01; S4. Evaluate and calculate the node partitioning results until the optimal sharding partition of the blockchain is obtained, specifically including: S401. Calculate the replication score for this round of partitioning. Divide the running time ,in, The sum of the number of nodes v in the original transaction dataset. To calculate the sum of the number of nodes after partitioning, record this replication score as the minimum replication score and retain the current partitioning scheme; S402. For Select a value in (1, 2), divide the ledger again, and evaluate the new replication score. If the current replication score is less than the minimum replication score, set the current minimum replication score to the replication score of this round and replace it with the sharding scheme corresponding to the minimum replication score. If the current replication score is greater than the minimum replication score, calculate the probability , and compare it with a random value 0 < R < 1. If P' is greater than R, update the value. If P' is less than R, do not accept the value, and at the same time keep the existing value unchanged, where is the current replication score; S403. When the total execution time is... Less than When the time expires, execute S401~S402 in a loop until the time exceeds the limit. Then the optimal partitioning is the scheme corresponding to the current minimum replication score; S5. Based on the optimal sharding, divide the nodes into different shards and configure a status ledger for the divided accounts.
2. The blockchain sharding method integrating community discovery and graph partitioning as described in claim 1, characterized in that, The process of obtaining the transaction ledger of each shard in the blockchain during this round, and processing the transaction ledger to obtain the graph structure data of the transactions, specifically includes: The runtime of the consensus phase and the runtime of the reconfiguration phase in each epoch cycle are set as follows: and During the reconfiguration phase following the conclusion of each consensus phase, the blockchain obtains the transaction ledger of all segments via Gossip broadcast. Each acquired transaction ledger fragment is integrated, and the transaction address information of the sender and receiver is extracted from the transaction ledger to construct a graph structure data. Where v represents the node addresses of both parties in the transaction, e represents the transaction itself, and e represents the connectivity between the node addresses of both parties in the transaction.
3. The blockchain sharding method integrating community discovery and graph partitioning as described in claim 1, characterized in that, The step of dividing nodes into different shards based on optimal sharding and configuring a status ledger for the divided accounts specifically includes: S501. Based on the optimal sharding, divide the nodes into ordinary accounts and partition accounts. If an account appears in only a single partition in the final partitioning, then the account is an ordinary account; if an account appears in multiple partitions, then the account is a partition account. S502. In the global ledger, ordinary accounts are stored as a one-to-one correspondence between accounts and the shards where addresses are located. The state ledger of an account is transferred to a new shard, and the state ledger of its original shard is deleted. When a new transaction request is sent to the account, the transaction request will be assigned to the new shard. S503. Based on the optimal sharding, a sharding account is created within all shards to which the shard belongs, and the account address in its status ledger will correspond to the set of shards to which the account belongs.
4. A computer-readable storage medium storing computer code, wherein when the computer code is executed, the method of any one of claims 1 to 3 is performed.
5. A computer device, the computer device comprising: One or more processors; Memory, used to store one or more computer programs; When the one or more computer programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Graph anonymity method for weighted social network privacy protection
CN114692205A
Graph flow segmentation-based block chain dynamic fragmentation extension method
CN115733841A
Performance optimization method of block chain network protocol Gossip
CN116233095A