Block chain fragmentation method based on account weight and reputation
By building an account weight graph and optimizing sharding using the community discovery algorithm, the problem of frequent cross-chip transactions in the blockchain system is solved, transaction processing efficiency and system performance are improved, and blockchain scalability is improved.
Patent Information
- Application Number
- CN202510273570.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-10
- Publication Date
- 2025-08-29
AI Technical Summary
The existing blockchain sharding technology ignores the intrinsic connection between accounts when trading sharding, resulting in frequent cross-chip transactions, affecting system performance and transaction processing efficiency, and making it difficult to meet the needs of large-scale transactions.
The blockchain sharding method based on account weight and reputation is adopted. By building an undirected account weight graph, the community discovery algorithm is used to optimize sharding, and the target sharding is calculated based on real-time resource status and business needs, reducing cross-film transactions and improving sharding efficiency.
Significantly reduce the proportion of cross-chip transactions, improve the scalability and transaction processing efficiency of blockchain systems, adapt to efficient operation under different loads, and meet the growing business needs.
Smart Images

Figure CN120567692A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to blockchain sharding technology, which aims to solve the scalability problems faced by blockchain when processing large-scale transactions and improve transaction processing efficiency and system performance. Background Art
[0002] With the widespread adoption of blockchain technology, it is playing a vital role in numerous fields, including finance, supply chain, and the Internet of Things. However, scalability has become a key bottleneck hindering its further development. Traditional blockchain systems, due to the requirement for all nodes to process all transactions, result in low transaction throughput and high latency, making it difficult to meet growing business demands. For example, consensus networks using a proof-of-work mechanism only process one block every 10 minutes, with a maximum transaction throughput of only approximately 7 transactions per second (TPS). The Ethereum platform also boasts a mere 30 TPS, a significant drop from the 100,000 TPS typically experienced by online shopping platforms during promotional events.
[0003] Sharding technology has emerged as a key means of improving blockchain scalability, but existing sharding solutions suffer from numerous shortcomings. Regarding transaction sharding, mainstream modular and random sharding algorithms often ignore the inherent connections between accounts when allocating transactions, simplistically dividing accounts based on address or other single factors. This leads to frequent cross-shard transactions in real-world applications, complicating transaction verification and synchronization and severely impacting system performance. For example, in certain complex blockchain scenarios, a large number of cross-shard transactions can cause network congestion, dramatically reducing transaction processing efficiency and significantly increasing the system's communication, data synchronization, and coordination overhead. In extreme cases, all transactions can become cross-shard transactions, paralyzing the system.
[0004] Therefore, there is an urgent need for a transaction sharding method that can accurately consider account relationships, effectively reduce the proportion of cross-shard transactions, improve the scalability and transaction processing efficiency of the blockchain, and promote the widespread application and in-depth development of blockchain technology in various fields. Summary of the Invention
[0005] The core purpose of this invention is to provide a blockchain sharding solution based on account weight and reputation, which effectively overcomes the shortcomings of existing blockchain sharding technology and significantly improves the scalability and transaction processing efficiency of the blockchain system.
[0006] 1. A blockchain sharding method based on account weight and reputation, characterized by comprising the following steps:
[0007] S1, preliminarily screens nodes based on reputation scores, collects information such as accounts, transaction frequency, and geographic locations of both parties in the blockchain, and builds an account-based transaction sharding model;
[0008] S2, based on the transaction data obtained in step S1, using accounts as nodes, calculates the transaction frequency and geographic location information between accounts as edge weights to construct an undirected account weight graph;
[0009] S3 uses a community discovery algorithm to process the account weight graph obtained in S2. For each account, the modularity gain of the accounts associated with it is calculated. The accounts with the largest modularity gain are selected and merged to form the initial shard. Through multiple rounds of iterative operations, the sharding results are continuously optimized until the shards to which all accounts belong reach a stable state.
[0010] S4: Calculate the target number of shards m based on real-time resource status and business needs. Calculate the comprehensive score of each shard based on the number of nodes in the shard, shard load, and shard performance. Merge or split shards based on the relationship between the actual number of shards and the target shard size. If the actual number of shards is too large, adopt a shard merging solution driven by relevance. Otherwise, adopt a shard splitting solution guided by community discovery until the number of shards reaches the target.
[0011] 2. The method according to claim 1, characterized in that in step S1, the account set collected by the constructed transaction sharding model is recorded as Ac = {ac1, ac2, ac3, ..., ac n}, the collected transaction set is recorded as Tx = {tx 11 ,tx 12 ,…,tx 1j ,tx 22 ,tx 23 ,...,tx 2j ,tx ii ,…,tx ij}, tx ij ={ac i ,ac j ,Num ij},Num ij Indicates the transaction frequency between the two, and the location set is recorded as Dx = {D 11 ,D 12 ,...D 1j ,D 22 ,…D 2j ,…D ii ,…D ij};
[0012] 3. The method according to claim 1, wherein in step S1, the communication delay between two accounts is calculated as an indicator of the physical location between the two accounts. ij =Dj -D i , where D i is the time it takes for account i to send a request for latency test to account j, D j The time when account i receives the latency test result feedback from account j;
[0013] 4. The method according to claim 1, characterized in that in step S2, taking the account as the vertex, the comprehensive weight W of the transaction frequency and communication delay between accounts is ij As edges, construct an undirected account weight graph G = (Ac,W ij ),in δ1 and δ2 are weight parameters, the sum of which is 1. They are set as needed according to the actual situation.
[0014] 5. The method according to claim 1, wherein in step S3, the modularity gain is calculated as follows: each account is first initialized as an independent shard, i.e., Shard = {shard1, shard2, ... shard n}, where shard i ={ac i For each shard, calculate its relationship with the adjacent shards j Modularity gain after merging:
[0015]
[0016] Wherein M is the total weight of the weighted graph, and the calculation method is as described in claim 4. is the sum of the weights between shard i and shard j, calculated as follows:
[0017]
[0018] Represents shard i (shard j) and all external shards The sum of the weights of so The calculation formula is as follows:
[0019]
[0020] 6. The method according to claim 1, wherein in step S3, the step of merging the shards is as follows: traverse all shard pairs and find the modularity gain ΔQ i,j The largest shard pair i ,shard j ), if the obtained ΔQ i,j > 0, merge shards iand shard j For the new shard i+j , and remove the shard from the shard i and shard j , the new shard i+j =shard i ∪shard j Add Shard; On the contrary, if ΔQ i,j ≤0, the current shard structure is retained; after the merger is completed, the weight needs to be dynamically updated, and the new shard and other external shards k The weight update formula between (k≠i,j) is as follows:
[0021]
[0022] in For the original shard i and shard j The weights between them (converted to internal weights after merging); repeat the shard merging operation until any of the following conditions are met: (1) Stable state: the modularity gain ΔQ of all shards i,j ≤0, the next step of merging cannot be performed; (2) the maximum number of iterations T is reached max or the modularity change is less than the threshold ρ;
[0023] 7. The method according to claim 1, wherein in step S4, the target number of shards m is calculated as follows:
[0024]
[0025] Where T is the transaction throughput, τ is the single-shard transaction processing threshold; B and B threshold are the current network bandwidth and the network bandwidth threshold, respectively. When the network bandwidth is insufficient, the number of shards will be increased; C and C threshold They are the average computing power and the average computing power threshold, respectively. When computing resources are sufficient, the number of shards is reduced;
[0026] 8. The method according to claim 1, wherein in step S4, the comprehensive score of each shard is calculated using the following formula:
[0027]
[0028] Among them, sz i is the number of nodes in shard i, avg_sz is the average number of nodes in all current shards, tx_load iis the transaction load of shard i, avg_tx_load is the average transaction load of all shards, per i is the performance information of shard i, α, β, and γ are pre-set weight parameters, and the sum of the three is 1; the calculation formulas for the other values are as follows:
[0029] tx_load i =ω1*tx_cnt+ω2*tx_amount
[0030]
[0031] Among them, tx_cnt is the number of transactions per unit time in shard i, tx_amount is the total amount of all transactions in shard i, ω1 and ω2 are weight parameters, which can be adjusted as needed, and the sum of the two is 1; Tx cross is the number of cross-shard transactions of shard i, Tx total is the total number of transactions in shard i, per i is the cross-shard transaction ratio of shard i, k is the function slope control parameter, and c is the threshold;
[0032] 9. The method according to claim 1, characterized in that in step S4, in the execution of the correlation-driven shard merging scheme, first the candidate shard pairs are screened and the transaction correlation C between the shards is calculated. ij , the calculation formula is as follows:
[0033]
[0034] Select C ij The highest first r shard pairs, and then calculate the Score from these r shard pairs i +Score j The lowest shard pair is merged; in the shard splitting scheme guided by community discovery, the comprehensive score Score is first selected. i The highest shard max , then in shard max Internally, the improved community discovery algorithm is re-run on the account transaction subgraph to generate z ≥ 2 sub-shards;
[0035] The advantages and beneficial effects of the present invention are as follows:
[0036] 1. Innovative account-weighted graph construction and sharding algorithm effectively reduces the proportion of cross-shard transactions. By accurately considering factors such as transaction frequency between accounts to construct a weighted graph and applying a scientific community discovery algorithm for sharding, it can more accurately assign closely related accounts to the same shard than traditional methods, significantly reducing the occurrence of cross-shard transactions, improving transaction processing efficiency, alleviating network congestion, and enhancing overall system performance.
[0037] 2. Based on Invention 1, an efficient sharding optimization strategy is proposed to improve the scalability of the blockchain. By setting the target sharding granularity based on actual needs and optimizing the sharding results based on multiple factors, this strategy can better adapt to blockchain application scenarios of varying scales, ensuring that the system can maintain efficient operation under varying loads, effectively improving the scalability of the blockchain and meeting growing business needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a flow chart of the present invention
[0039] Figure 2 This is a diagram of the sharding algorithm and granularity adjustment model of the present invention; DETAILED DESCRIPTION
[0040] The following describes embodiments of the present invention in detail. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended only to explain the present invention and are not to be construed as limiting the present invention.
[0041] A blockchain sharding method based on account weight and reputation, characterized by comprising the following steps:
[0042] (1) Preliminary screening of nodes based on reputation scores is performed to isolate illegal nodes from the network. Subsequently, information such as the accounts, transaction frequencies, and geographic locations of both parties in the blockchain are collected. The resulting account set is denoted as Ac = {ac1, ac2, ac3, ..., ac n}, the transaction set is recorded as Tx = {tx 11 ,tx 12 ,…,tx 1j ,tx 22 ,tx 23 ,…,tx 2j ,tx ii ,…,tx ij}, where tx ij ={ac i ,ac j ,Num ij},Num ij Indicates the transaction frequency between the two, and the location set is recorded as Dx = {D 11 ,D 12 ,…D 1j ,D 22 ,…D 2j ,…D ii ,…D ij}, the communication delay between accounts is used as an indicator to determine the physical location between two accounts. The communication delay between two accounts D ij =D j -D i , where D i is the time it takes for account i to send a request for latency test to account j, D j The time when account i receives the latency test result feedback from account j;
[0043] (2) Based on the transaction set obtained in step (1), with accounts as nodes, the transaction frequency and geographic location information between accounts are calculated as the weight of the edge, and an undirected account weight graph G = (Ac, W ij ),in δ1 and δ2 are weight parameters, the sum of which is 1. They are set as needed according to the actual situation.
[0044] (3) The account weight graph obtained in (2) is processed using a community discovery algorithm. For each account, it is first initialized into an independent shard, i.e., Shard = {shard1, shard2, ... shard n}, where shard i ={ac i For each shard, calculate its relationship with the adjacent shards j Modularity gain after merging:
[0045]
[0046] Wherein M is the total weight of the weighted graph, and the calculation method is as described in claim 4. is the sum of the weights between shard i and shard j, calculated as follows:
[0047]
[0048] Represents shard i (shard j) and all external shards The sum of the weights of so The calculation formula is as follows:
[0049]
[0050] Traverse all shard pairs and find the modularity gain ΔQ i,j The largest shard pair i ,shard j ), if the obtained ΔQ i,j > 0, merge shards i and shard jFor the new shard i+j , and remove the shard from the shard i and shard j , the new shard i+j =shard i ∪shard j Add Shard; On the contrary, if ΔQ i,j ≤0, the current shard structure is retained; after the merger is completed, the weight needs to be dynamically updated, and the new shard and other external shards k The weight update formula between (k≠i,j) is as follows:
[0051]
[0052] in For the original shard i and shard j The weights between them (converted to internal weights after merging); repeat the shard merging operation until any of the following conditions are met: (1) Stable state: the modularity gain ΔQ of all shards i,j ≤0, the next step of merging cannot be performed; (2) the maximum number of iterations T is reached max Or the modularity change is less than the threshold ρ.
[0053] (4) Calculate the target number of shards m based on the real-time resource status and business requirements. The calculation formula is as follows:
[0054]
[0055] Where T is the transaction throughput, τ is the single-shard transaction processing threshold; B and B threshold are the current network bandwidth and the network bandwidth threshold, respectively. When the network bandwidth is insufficient, the number of shards will be increased; C and C threshold They are the average computing power and the average computing power threshold, respectively. When computing resources are sufficient, the number of shards is reduced;
[0056] (5) The sharding results obtained in (3) are used to calculate the comprehensive score of each shard from three dimensions: the number of nodes in the shard, the shard load, and the shard performance. The calculation formula for the comprehensive score of each shard is as follows:
[0057]
[0058] Among them, sz i is the number of nodes in shard i, avg_sz is the average number of nodes in all current shards, tx_load i is the transaction load of shard i, avg_tx_load is the average transaction load of all shards, peri is the performance information of shard i, α, β, and γ are pre-set weight parameters, and the sum of the three is 1; the calculation formulas for the other values are as follows:
[0059] tx_load i =ω1*tx_cnt+ω2*tx_amount
[0060]
[0061] Among them, tx_cnt is the number of transactions per unit time in shard i, tx_amount is the total amount of all transactions in shard i, ω1 and ω2 are weight parameters, which can be adjusted as needed, and the sum of the two is 1; Tx cross is the number of cross-shard transactions of shard i, Tx total is the total number of transactions in shard i, per i is the cross-shard transaction ratio of shard i, k is the function slope control parameter, and c is the threshold;
[0062] (6) Merge or split according to the relationship between the actual number of shards and the target shard granularity m. If the actual number of shards is too large, a shard merging scheme driven by correlation is adopted to screen candidate shard pairs and calculate the transaction correlation C between shards. ij , the calculation formula is as follows:
[0063]
[0064] Select C ij The highest first r shard pairs, and then calculate the Score from these r shard pairs i +Score j The lowest shard pair is merged; otherwise, the shard splitting scheme guided by community discovery is adopted, and the comprehensive score Score is selected. i The highest shard max , then in shard max Internally, the improved community discovery algorithm is re-run on the account transaction subgraph to generate z ≥ 2 sub-shards. The termination condition for both schemes is that the number of shards reaches the predetermined target.
[0065] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0066] The above embodiments should be understood as merely illustrating the present invention and not as limiting the scope of protection of the present invention. After reading the contents of the present invention, technicians may make various changes or modifications to the present invention, and these equivalent changes and modifications also fall within the scope defined by the claims of the present invention.
Claims
1. A blockchain sharding method based on account weight and reputation, characterized in that: The following steps are involved: S1, preliminarily screens nodes based on reputation scores, collects information such as accounts, transaction frequency, and geographic locations of both parties in the blockchain, and builds an account-based transaction sharding model; S2, based on the transaction data obtained in step S1, using accounts as nodes, calculates the transaction frequency and geographic location information between accounts as edge weights to construct an undirected account weight graph; S3 uses a community discovery algorithm to process the account weight graph obtained in S2. For each account, the modularity gain of the accounts associated with it is calculated. The accounts with the largest modularity gain are selected and merged to form the initial shard. Through multiple rounds of iterative operations, the sharding results are continuously optimized until the shards to which all accounts belong reach a stable state. S4 calculates the target number of shards m based on real-time resource status and business needs, calculates the comprehensive score of each shard from the three dimensions of the number of nodes in the shard, shard load, and shard performance for the sharding results obtained in S3, and merges or splits shards based on the relationship between the actual number of shards and the target shard granularity. If the actual number of shards is too large, a shard merging solution driven by correlation is adopted. Otherwise, a shard splitting solution guided by community discovery is adopted until the number of shards reaches the predetermined target.
2. The method according to claim 1, characterized in that In step S1, the account set collected by the constructed transaction sharding model is recorded as Ac={ac1,ac2,ac3,...,ac n }, the collected transaction set is recorded as Tx = {tx 11 ,tx 12 ,...,tx 1j ,tx 22 ,tx 23 ,...,tx 2j ,tx ii ,...,tx ij }, tx ij ={ac i ,ac j ,Num ij },Num ij Indicates the transaction frequency between the two, and the location set is recorded as Dx = {D 11 ,D 12 ,...D 1j ,D 22 ,...D 2j ,...D ii ,…D ij }.
3. The method according to claim 1, characterized in that In step S1, the communication delay between the two accounts is calculated as an indicator of the physical location between the two accounts. ij =|D i -D j |, where D i is the time it takes for account i to send a request for latency test to account j, D j It is the time when account i receives the latency test result feedback from account j.
4. The method according to claim 1, wherein In step S2, the account is taken as the vertex, and the comprehensive weight W of the transaction frequency and communication delay between accounts is ij As edges, construct an undirected account weight graph G = (Ac,W ij ),in δ1 and δ2 are weight parameters, the sum of which is 1. They are set as needed according to the actual situation.
5. The method according to claim 1, characterized in that In step S3, the modularity gain is calculated as follows: first, each account is initialized as an independent shard, that is, Shard = {shard1, shard2, ... shard n }, where shard i ={ac i For each shard, calculate its relationship with the adjacent shards j Modularity gain after merging: Wherein M is the total weight of the weighted graph, and the calculation method is as described in claim 4. is the sum of the weights between shard i and shard j, calculated as follows: W shardi,j =∑Num pq , and p ∈shard i , and q ∈shard j Represents shard i (shard j) and all external shards The sum of the weights of So W shardi The calculation formula is as follows:
6. The method according to claim 1, characterized in that In step S3, the steps of merging shards are as follows: traverse all shard pairs and find the modularity gain ΔQ i,j The largest shard pair i ,shard j ), if the obtained ΔQ i,j > 0, merge shards i and shard j For the new shard i+j , and remove the shard from the shard i and shard j , the new shard i+j =shard i ∪shard j Add Shard; On the contrary, if ΔQ i,j ≤0, the current shard structure is retained; after the merger is completed, the weight needs to be dynamically updated, and the new shard and other external shards k The weight update formula between (k≠i,j) is as follows: IN shardi+j,k =In shardi,k +W shardj,k Where W shardi,j For the original shard i and shard j The weights between them (converted to internal weights after merging); repeat the shard merging operation until any of the following conditions are met: (1) Stable state: the modularity gain ΔQ of all shards i,j ≤0, the next step of merging cannot be performed; (2) the maximum number of iterations T is reached max Or the modularity change is less than the threshold ρ.
7. The method according to claim 1, characterized in that In step S4, the calculation formula for the target number of shards m is as follows: Where T is the transaction throughput, τ is the single-shard transaction processing threshold; B and B threshold are the current network bandwidth and the network bandwidth threshold, respectively. When the network bandwidth is insufficient, the number of shards will be increased. C and C threshold They are the average computing power and the average computing power threshold respectively. When computing resources are sufficient, the number of shards is reduced.
8. The method according to claim 1, characterized in that In step S4, the calculation formula for the comprehensive score of each shard is as follows: Among them, sz i is the number of nodes in shard i, avg_sz is the average number of nodes in all current shards, tx_load i is the transaction load of shard i, avg_tx_load is the average transaction load of all shards, per i is the performance information of shard i, α, β, and γ are pre-set weight parameters, and the sum of the three is 1; the calculation formulas for the other values are as follows: tx_load i =ω1*tx_cnt+ω2*tx_amount Among them, tx_cnt is the number of transactions per unit time in shard i, tx_amount is the total amount of all transactions in shard i, ω1 and ω2 are weight parameters, which can be adjusted as needed, and the sum of the two is 1; Tx cross is the number of cross-shard transactions of shard i, Tx total is the total number of transactions in shard i, per i is the cross-shard transaction ratio of shard i, k is the function slope control parameter, and c is the threshold.
9. The method according to claim 1, characterized in that In step S4, in the execution of the correlation-driven shard merging scheme, the candidate shard pairs are first screened and the transaction correlation C between the shards is calculated. ij , the calculation formula is as follows: Select C ij The highest first r shard pairs, and then calculate the Score from these r shard pairs i +Score j The lowest shard pair is merged; in the shard splitting scheme guided by community discovery, the comprehensive score Score is first selected. i The highest shard max , then in shard max Internally, the improved community discovery algorithm is rerun with the account transaction subgraph to generate z ≥ 2 sub-shards.