A blockchain sharding method for load balancing based on node contribution value
By adopting the method of node contribution value allocation and performance evaluation in blockchain sharding, the problem of insufficient security and performance considerations when dividing nodes in the existing technology is solved, load balancing and performance improvement between shards are achieved, and enhanced improve the scalability of the blockchain system.
Patent Information
- Application Number
- CN202410801310.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-20
AI Technical Summary
Existing blockchain sharding solutions lack dual considerations of security and performance when dividing nodes and accounts, and do not fully consider the contribution of nodes to sharding security and performance, making it difficult to achieve load balancing between shards.
Adopting a load balancing method based on node contribution value, through four stages: node allocation, account allocation, transaction processing and data update, node security contribution value and performance contribution value are used to distinguish the transaction processing time inside and outside the shard, and redefine sharding load to achieve load balancing among shards.
The security and performance of sharding are improved. By distinguishing the transaction processing time inside and outside the shard, true load balancing is achieved, the number of cross-shard transactions is reduced, and the scalability of the blockchain system is improved.
Smart Images

Figure CN118381597B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of blockchain sharding, and in particular to a blockchain sharding method for achieving load balancing based on node contribution values. Background Art
[0002] In recent years, blockchain technology has continued to flourish and has been widely used in the fields of the Internet of Things, Industrial Internet, and financial systems. However, with the explosive growth of application devices and transmission data, the scalability problem of blockchain has gradually emerged, which limits the development of blockchain in large-scale application scenarios. In order to solve this challenge, sharding technology in the database field has been introduced into the blockchain field, which greatly improves the throughput of blockchain and is considered by academia and industry to be one of the most effective ways to solve the scalability problem of blockchain systems.
[0003] The core idea of blockchain sharding technology is to split the entire blockchain network into several independent sub-networks, each of which is called a "shard". The transactions of the entire system are dispersed among the shards, and each shard handles transactions independently, so that the entire system can execute multiple transactions in parallel, so that the throughput of the blockchain can achieve approximately linear growth. Blockchain sharding can be divided into three main types according to the implementation method: network sharding, transaction sharding, and state sharding. Network sharding refers to dividing the entire blockchain network into multiple shards, which can run in parallel, thereby improving the throughput and performance of the entire network. The goal of network sharding is to reduce the congestion of the entire network and reduce the burden on participating nodes, so that the blockchain can support large-scale transactions and users. Network sharding is the basis of other sharding methods; transaction sharding is a method of grouping or classifying transactions in a certain way so that they can be processed in parallel. Different transaction shards can independently verify and package transactions without interfering with each other. Transaction sharding helps to improve the transaction processing capacity of the blockchain network, reduce transaction congestion, and speed up transaction confirmation. Transaction sharding is often used in conjunction with network sharding to achieve full scalability; state sharding means that the entire ledger is divided into completely different parts and stored in each shard. Usually, the nodes in the shard store the same version of the ledger data. These shards form a complete ledger, enabling the entire shard network to work together. This helps reduce the storage burden of nodes and improves the scalability of the blockchain. Among all sharding, state sharding is the most challenging sharding method.
[0004] ELASTICO is the first sharding scheme to apply sharding technology to blockchain, and is applied to non-permissioned chain scenarios. To ensure the security of sharding, the scheme adopts a random sharding method. At the beginning of each consensus cycle, each participant must calculate a proof of work (PoW) answer. The large amount of computing power required for proof of work provides security for the system, and the result of the proof of work answer will be used as the basis for node sharding. In order to deal with the problem of long processing time in the sharding algorithm, the subsequent OmniLedger protocol proposes to use a distributed random number generation scheme and a verifiable random function to configure sharding, reducing the computational overhead of the sharding process. In response to the problem that the confirmation time of cross-shard transactions seriously restricts the performance of sharding, the RapidChain protocol designs a routing protocol between shards to replace the broadcast method to handle cross-shard transactions, reducing communication overhead; the Pyramid system allows some special shards to store blocks of multiple shards, acting as a bridge, directly verifying and packaging cross-shard transactions, thereby reducing the delay in cross-shard transaction confirmation. The BrokerChain protocol has designed a sharding mechanism for accounts based on the account / balance model, focusing on improving system performance by reducing the number of cross-shard transactions. To address the problem of load balancing between shards, the Transformers protocol has designed a sharding algorithm that takes into account both load balancing and the number of cross-shard transactions for the state sharding of the account / balance model. It measures transactions within a shard and across shards based on the account transaction graph, and then describes the load situation of the shard.
[0005] However, the existing blockchain sharding schemes still lack dual considerations for the security and performance of the shards themselves when dividing nodes and accounts, and do not fully consider the contribution of nodes to the security and performance of the shards. In addition, the existing schemes mainly pursue the consistency of the number of transactions processed between shards when considering load balancing, while ignoring the difference in processing time required for transactions within a shard and across shards, and also ignoring the performance differences between different shards, which makes it difficult to achieve true load balancing between shards. Summary of the invention
[0006] The purpose of the present invention is to provide a blockchain sharding method for achieving load balancing based on node contribution value to solve the problems mentioned in the above background technology.
[0007] To achieve the above object, the present invention provides a blockchain sharding method for realizing load balancing based on node contribution value, which includes four stages, and the four stages constitute a consensus cycle (epoch), and the four stages are respectively a node allocation stage, an account allocation stage, a transaction processing stage and a data update stage;
[0008] The node allocation stage refers to the working node identity determined after solving the PoW answer of the working nodes participating in the blockchain. First, a part of the nodes are randomly selected as allocation nodes, and the remaining nodes are used as working nodes. Then, the working shard to which the working node belongs is determined based on the security contribution value. The shard to which the allocation node belongs is the allocation committee, and the shard to which the working node belongs is the working shard.
[0009] The account allocation phase refers to the allocation committee allocating accounts to each shard based on the account transaction data of the previous epoch and the performance contribution value of the working node of this epoch;
[0010] The transaction processing phase refers to each work shard processing the transactions of the accounts belonging to the work shard, packaging them into blocks and submitting them to the transaction chain to which the work shard belongs;
[0011] The data update phase refers to the allocation committee updating the node contribution value based on the contribution value report submitted by the working shard, and saving the account transaction data based on the transaction block submitted by the working shard.
[0012] Preferably, the specific steps of the node allocation stage are as follows:
[0013] SA1. Obtain node contribution value, transaction data and transaction weight coefficient from the data update block of the allocation chain, where the security contribution value is used in the working node allocation phase, and the transaction data and transaction weight coefficient are used in the account allocation phase;
[0014] SA2, the leader of the allocation committee is divided into four levels according to the node security contribution value. Worker nodes Sort the working nodes from large to small according to their security contribution values to get their rankings. , and then get the working node according to the following formula Level ;
[0015] ;
[0016] SA3: Allocate the working nodes in each level in order according to their security contribution values. In a work slice, the node is obtained according to the following formula The work slice to which it belongs ,
[0017] ;
[0018] SA4: The allocation committee reaches a consensus on the allocation results through PBFT, and the allocation committee votes on the work node allocation results within the committee through the PBFT consensus algorithm;
[0019] SA5: Determine whether consensus has been reached. If so, execute SA6; if not, execute SA7;
[0020] SA6, broadcast working node allocation results;
[0021] SA7: Replace the leader of the allocation committee. After replacing the leader of the allocation committee, execute SA1.
[0022] Preferably, the specific steps of the account allocation stage are as follows:
[0023] SB1. Calculate the performance prediction value of the work slice according to the node performance contribution value. The performance prediction value of the work slice is obtained by summing up the performance contribution values of all working nodes of the work slice.
[0024] SB2. Build an account transaction graph based on the account transaction data. The account transaction data includes the total number of transactions between each account in the previous epoch. Build an account transaction graph based on the transaction data. The nodes are accounts, the edges represent transactions in the previous epoch, and the weight of the edges represents the number of transactions.
[0025] SB3, randomly assign accounts to each work shard;
[0026] SB4. Calculate the cost of moving each account to the working shard where the neighbor account is located. value, and move the account to The maximum value and The corresponding work slices, where Represents the predicted transaction processing time for each work shard, expressed as follows:
[0027] ;
[0028] in Indicates the number of transactions in the work slice, is the number of cross-shard transactions, is the transaction weighting coefficient, is the performance prediction value of the work slice, In the node allocation phase, the account is obtained from the allocation chain. On this basis, the account is allocated from the work shard Move to Worker Shard of It can be expressed as follows:
[0029] ;
[0030] When there is only one account in the work shard where the account is located, ,otherwise, Move the working shard for this account and work sharding Predicted transaction processing time;
[0031] SB5. Determine whether there is an account that changes the work slice to which it belongs. If there is an account that changes the work slice to which it belongs, execute SB4; otherwise, execute SB6;
[0032] SB6. Broadcast the account allocation results and build an account allocation block. Write the account allocation results, i.e. the account-shard mapping table, into the block for PBFT consensus within the committee. After reaching consensus, broadcast the account allocation results to the working nodes and add the block, i.e. the account allocation block, to the allocation chain.
[0033] Preferably, the specific steps of the transaction processing stage are as follows:
[0034] SC1. Select transactions from pending transactions in which both parties have accounts belonging to this work shard;
[0035] SC2: Verify transactions and package them into blocks. Verify transactions through the transaction chain of this work shard, and select successfully verified transactions to package them into blocks.
[0036] SC3: Transaction blocks are voted on in the allocation committee through PBFT, and each working node verifies and votes on the transactions in the transaction block;
[0037] SC4: Determine whether consensus has been reached. If no consensus has been reached, execute SC5; if consensus has been reached, execute SC6;
[0038] SC5: Replace the leader of the allocation committee. After replacing the leader of the allocation committee, execute SC1;
[0039] SC6, the leader of the allocation committee updates the local node contribution value list according to the consensus process. The contribution value is divided into security contribution value and performance contribution value. The security contribution value and performance contribution value are based on the number of transactions processed by this consensus. and processing time , and whether the working node is the leader of the distribution committee to update the performance contribution value of the node, the first After the update, the worker node of worker shard j Performance contribution It is expressed as follows:
[0040] ;
[0041] in Indicates the reward and penalty weight of the master node relative to the slave node, Indicates the number of slave nodes for this consensus. ;
[0042] Security contribution value in one epoch Safety contribution value after update It is expressed as follows:
[0043] ;
[0044] in Indicates the reward weight for successfully submitting a block, Indicates the penalty weight for failing to submit a block, ;
[0045] SC7. Put the transaction block on the chain and broadcast it to the allocation committee.
[0046] Preferably, the specific steps of the data update stage are as follows:
[0047] SD1. The working node submits a contribution value report to the allocation node, which contains the most recently updated security contribution value and performance contribution value of the working node where the shard is located. After the working shard reaches a PBFT consensus on the contribution value report, the report is sent to the allocation committee.
[0048] SD2. The assigned node updates the node contribution value and organizes the account transaction data. The contribution value in the contribution value report represents the contribution value of the working node in this epoch. The global contribution value of the node is updated based on this value:
[0049] ;
[0050] in Indicates the node after this epoch The performance contribution value of Indicates the working node before this epoch The performance contribution value of Indicates the working node after the latest update of this epoch The performance contribution value in this round is Represents the contribution value retention coefficient. Similarly, the performance value of the working node is updated:
[0051] ;
[0052] After updating the contribution value of the working node, sort out the account transactions in this epoch, calculate the total number of transactions between accounts, and then calculate the processing time ratio of cross-shard transactions and intra-shard transactions of each working shard, and take the average value as The latest value of the contribution value data, transaction data and Values are packaged into blocks;
[0053] SD3. Vote on data update results in the distribution committee through PBFT;
[0054] SD4: Determine whether consensus has been reached. If no consensus has been reached, execute SD5; if consensus has been reached, execute SD6;
[0055] SD5: Replace the leader of the allocation committee. After replacing the leader of the allocation committee, execute SD2.
[0056] SD6. Submit the data update block to the distribution chain.
[0057] Therefore, the present invention adopts the above-mentioned blockchain sharding method based on node contribution value to achieve load balancing, which has the following beneficial effects:
[0058] (1) By designing the security contribution value and performance contribution value of nodes, nodes and shards are considered from the perspectives of security and performance. By distinguishing the processing time of transactions within a shard and across shards, the shard load is redefined;
[0059] (2) By utilizing the node security contribution value and PoW algorithm, the security of the shards is improved during node allocation. By utilizing the node performance contribution value and community partitioning algorithm, load balancing and a small number of cross-shard transactions are achieved during account allocation, thereby improving the performance of the shards.
[0060] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 This is the overall framework diagram of the blockchain system of the present invention;
[0062] Figure 2 This is a flowchart of the blockchain system operation of the present invention;
[0063] Figure 3 A flowchart of the blockchain node allocation phase of the present invention;
[0064] Figure 4 This is a flowchart of the blockchain account allocation phase of the present invention;
[0065] Figure 5 This is a flowchart of the blockchain transaction processing stage of the present invention;
[0066] Figure 6 It is a flow chart of the data updating phase of the present invention. DETAILED DESCRIPTION
[0067] Example
[0068] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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 ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0069] Reference Figure 1 The present invention discloses a blockchain sharding method for realizing load balancing based on node contribution value. Generally speaking, there are four stages, including node allocation, account allocation, transaction processing, and data update. The four stages constitute a consensus cycle (epoch), and the time length of a consensus cycle is fixed. Among them, the node allocation stage refers to the node that wishes to participate in the blockchain to determine the node identity after solving the PoW answer, and then determine the shard to which the node belongs according to the security contribution value; the account allocation stage refers to the allocation committee allocating accounts to each shard based on the account transaction data of the previous consensus cycle and the performance contribution value of the working node of this consensus cycle; the transaction processing stage refers to each working shard processing the transaction of the account belonging to the shard, and packaging it into blocks and submitting it to the transaction chain to which the shard belongs; the data update stage refers to the allocation committee updating the node contribution value according to the contribution value report submitted by the working shard, and saving the account transaction data according to the transaction block submitted by the working shard.
[0070] There are multiple working shards, and the nodes in them are called working nodes. Working nodes are responsible for verifying transactions between accounts, packaging them into blocks, and uploading them to the chain after reaching consensus.
[0071] The allocation committee is a special shard, and the nodes in it are called allocation nodes. The allocation node has four responsibilities. First, the allocation node allocates working nodes to each working shard in the node allocation phase; second, the allocation node divides the account in the account allocation phase and determines the shard to which the account belongs; then, the allocation node continuously accepts the transaction block information submitted by the working shard in the transaction processing phase, and records the transaction status of each account within an epoch; finally, the allocation node updates the node contribution value according to the contribution value report submitted by the working node in the data update phase, and packages the node contribution value and account transaction status into blocks in combination with the account transaction status recorded by itself.
[0072] Reference Figure 2 , the overall process of the blockchain sharding method is as follows:
[0073] S1. Nodes solve the PoW problem to determine their identities. Nodes that wish to participate in the blockchain need to solve the PoW problem to resist Sybil attacks and ensure the security of the blockchain. After solving the PoW problem, nodes randomly select a part of the nodes called allocation nodes, and the remaining nodes are working nodes. The shards to which the allocation nodes belong are the allocation committees, and the shards to which the working nodes belong are the working shards.
[0074] S2. Work nodes are allocated according to the security contribution value in the node contribution value. The allocation node obtains the node contribution value of the work nodes participating in this epoch from the latest block of the allocation chain, that is, the data update block submitted in the data update phase of the previous epoch. Then, the allocation node divides the security contribution value of the work nodes into levels, and the work nodes in each level are evenly distributed in each work shard.
[0075] S3. The allocation node predicts the performance of the work slice according to the performance contribution value of the work node. The performance prediction value of each work slice is the sum of the performance contribution values of the node contribution values of the work nodes in the work slice.
[0076] S4. The allocation node allocates accounts according to the performance prediction value of the working shard and the account transaction graph. The allocation node builds the account transaction graph according to the account transaction data, and then calculates the performance prediction value of the working shard according to the weighted calculation of the intra-shard transaction and cross-shard transaction of the working shard. Finally, the modified community partitioning algorithm Louvain algorithm is used to allocate accounts.
[0077] S5. The allocation committee reaches a consensus on the account allocation results and broadcasts it to the working nodes. The allocation committee uses the PBFT consensus algorithm to reach a consensus on the account allocation results. After reaching a result, it is broadcast to the working nodes and the account allocation results are packaged into account allocation blocks and added to the allocation chain.
[0078] S6. The working node updates the account status. After receiving the account allocation result, the working node updates the local account-shard mapping table to confirm the account belonging to the working shard;
[0079] S7. The working node processes and verifies transactions. For pending transactions, the working shard to be processed is determined based on the account. For transactions within a shard, the working node uses the PBFT algorithm to reach consensus. For cross-shard transactions, a two-stage protocol is used to ensure the consistency of cross-shard transactions. The blocks that reach consensus are finally added to the transaction chain of each working shard and broadcast at the same time. After a certain period of time, the working node updates the node contribution value of this epoch and submits the node contribution value report to the allocation committee.
[0080] S8. The allocation node updates the node contribution value and account transaction information. The allocation node organizes the collected account transaction records within this epoch, and then updates the node contribution value according to the node contribution value report, and packages the results into a data update block and submits it to the allocation chain.
[0081] Reference Figure 3 ,The specific steps of the node allocation phase are as follows:
[0082] SA1. Obtain node contribution value, transaction data and transaction weight coefficient from the data update block of the allocation chain, where the security contribution value is used in the working node allocation phase, and the transaction data and transaction weight coefficient are used in the account allocation phase;
[0083] SA2, the leader of the allocation committee is divided into four levels according to the node security contribution value. Worker nodes Sort the working nodes from large to small according to their security contribution values to get their rankings. , and then get the working node according to the following formula Level ;
[0084] ;
[0085] SA3: Allocate the working nodes in each level in order according to their security contribution values. In a work slice, the node is obtained according to the following formula The work slice to which it belongs ,
[0086] ;
[0087] SA4: The allocation committee reaches a consensus on the allocation results through PBFT, and the allocation committee votes on the work node allocation results within the committee through the PBFT consensus algorithm;
[0088] SA5: Determine whether consensus is reached. If consensus is reached, execute S6; if consensus is not reached, execute S7;
[0089] SA6, broadcast working node allocation results;
[0090] SA7: Replace the leader of the allocation committee. After replacing the leader of the allocation committee, execute S1.
[0091] Reference Figure 4 , the specific steps of the account allocation stage are as follows:
[0092] SB1. Calculate the performance prediction value of the work slice according to the node performance contribution value. The performance prediction value of the work slice is obtained by accumulating the performance contribution values of all working nodes of the work slice.
[0093] SB2. Build an account transaction graph based on the account transaction data. The account transaction data includes the total number of transactions between each account in the previous epoch. Build an account transaction graph based on the transaction data. The nodes are accounts, the edges represent transactions in the previous epoch, and the weight of the edges represents the number of transactions.
[0094] SB3, randomly assign accounts to each work shard;
[0095] SB4. Calculate the cost of moving each account to the working shard where the neighbor account is located. value, and move the account to The maximum value and The corresponding work slices, where Represents the predicted transaction processing time for each work shard, expressed as follows:
[0096] ;
[0097] in Indicates the number of transactions in the work slice, is the number of cross-shard transactions, is the transaction weighting coefficient, is the performance prediction value of the work slice, In the node allocation phase, the account is obtained from the allocation chain. On this basis, the account is allocated from the work shard Move to Worker Shard of It can be expressed as follows:
[0098] ;
[0099] When there is only one account in the work shard where the account is located, ,otherwise, Move the working shard for this account and work sharding Predicted transaction processing time;
[0100] SB5. Determine whether there is an account that changes the work slice to which it belongs. If there is an account that changes the work slice to which it belongs, execute SB4; otherwise, execute SB6;
[0101] SB6. Broadcast the account allocation results and build an account allocation block. Write the account allocation results, i.e. the account-shard mapping table, into the block for PBFT consensus within the committee. After reaching consensus, broadcast the account allocation results to the working nodes and add the block, i.e. the account allocation block, to the allocation chain.
[0102] Reference Figure 5 , the specific steps of the transaction processing stage are as follows:
[0103] SC1. Select transactions from pending transactions in which both parties have accounts belonging to this work shard;
[0104] SC2: Verify transactions and package them into blocks. Verify transactions through the transaction chain of this work shard, and select successfully verified transactions to package them into blocks.
[0105] SC3: Transaction blocks are voted on in the allocation committee through PBFT, and each working node verifies and votes on the transactions in the transaction block;
[0106] SC4: Determine whether consensus has been reached. If no consensus has been reached, execute SC5; if consensus has been reached, execute SC6;
[0107] SC5: Replace the leader of the allocation committee. After replacing the leader of the allocation committee, execute SC1;
[0108] SC6, the leader of the allocation committee updates the local node contribution value list according to the consensus process. The contribution value is divided into security contribution value and performance contribution value. The security contribution value and performance contribution value are based on the number of transactions processed by this consensus. and processing time , and whether the working node is the leader of the distribution committee to update the performance contribution value of the node, the first After updating j working nodes Performance contribution It is expressed as follows:
[0109] ;
[0110] in Indicates the reward and penalty weight of the master node relative to the slave node, Indicates the number of slave nodes for this consensus. ;
[0111] Security contribution value in one epoch Safety contribution value after update It is expressed as follows:
[0112] ;
[0113] in Indicates the reward weight for successfully submitting a block, Indicates the penalty weight for failing to submit a block, ;
[0114] SC7. Put the transaction block on the chain and broadcast it to the allocation committee.
[0115] Reference Figure 6 ,The specific steps of the data update phase are as follows:
[0116] SD1. The working node submits a contribution value report to the allocation node, which contains the most recently updated security contribution value and performance contribution value of the working node where the shard is located. After the working shard reaches a PBFT consensus on the contribution value report, the report is sent to the allocation committee.
[0117] SD2. The assigned node updates the node contribution value and organizes the account transaction data. The contribution value in the contribution value report represents the contribution value of the working node in this epoch. The global contribution value of the node is updated based on this value:
[0118] ;
[0119] in Indicates the node after this epoch The performance contribution value of Indicates the working node before this epoch The performance contribution value of Indicates the working node after the latest update of this epoch The performance contribution value in this round is Represents the contribution value retention coefficient. Similarly, the performance value of the working node is updated:
[0120] ;
[0121] After updating the contribution value of the working node, sort out the account transactions in this epoch, calculate the total number of transactions between accounts, and then calculate the processing time ratio of cross-shard transactions and intra-shard transactions of each working shard, and take the average value as The latest value of the contribution value data, transaction data and Values are packaged into blocks;
[0122] SD3. Vote on data update results in the distribution committee through PBFT;
[0123] SD4: Determine whether consensus has been reached. If no consensus has been reached, execute SD5; if consensus has been reached, execute SD6;
[0124] SD5: Replace the leader of the allocation committee. After replacing the leader of the allocation committee, execute SD2.
[0125] SD6. Submit the data update block to the distribution chain.
[0126] Therefore, the present invention adopts the above-mentioned blockchain sharding method based on node contribution value to achieve load balancing, designs a blockchain sharding protocol based on security contribution and performance contribution, and is committed to ensuring the security of sharding while realizing load differentiation of shards with different performances to achieve true load balancing. In order to ensure security, node security contribution value and PoW algorithm are used for node identity confirmation and node allocation; in order to ensure performance, the sharding load is redefined by distinguishing the processing time of intra-shard transactions and cross-shard transactions, and the node performance contribution value and community partitioning algorithm are used to achieve load balancing and a small number of cross-shard transactions during account allocation. The present invention implements a blockchain sharding protocol that takes into account both security and performance, realizes sharding load differentiation according to different sharding performances, realizes true reasonable load distribution, and lays a solid foundation for enhancing the wide application of blockchain systems.
[0127] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.
Claims
1. A blockchain sharding method for achieving load balancing based on node contribution value, characterized in that: It includes four stages, which constitute a consensus cycle. The four stages are node allocation stage, account allocation stage, transaction processing stage and data update stage. The node allocation phase refers to the nodes participating in the blockchain determining their identities after solving the PoW answer. First, a portion of the nodes are randomly selected as allocation nodes, and the remaining nodes are used as working nodes. Secondly, the working shard to which the working node belongs is determined based on the security contribution value. The shard to which the allocation node belongs is the allocation committee, and the shard to which the working node belongs is the working shard. The specific steps are as follows: SA1. Obtain node contribution value, transaction data and transaction weight coefficient from the data update block of the distribution chain; SA2, the leader of the allocation committee is divided into four levels according to the node security contribution value. Worker nodes Sort the working nodes by security contribution value from large to small to get the ranking , according to the following formula to get the working node Level : ; SA3: Allocate the working nodes in each level in order according to their security contribution values. In a work slice, the node is obtained according to the following formula The work slice to which it belongs , ; SA4: The allocation committee reaches a consensus on the allocation results through PBFT, and the allocation committee votes on the work node allocation results within the committee through the PBFT consensus algorithm; SA5: Determine whether consensus has been reached. If so, execute SA6; if not, execute SA7; SA6, broadcast working node allocation results; SA7: Replace the leader of the allocation committee. After replacing the leader of the allocation committee, execute SA1. The account allocation phase refers to the allocation committee allocating accounts to each working shard based on the account transaction data of the previous consensus cycle and the performance contribution value of the working node in this consensus cycle; The specific steps are as follows: SB1. Calculate the performance prediction value of the work slice according to the node performance contribution value. The performance prediction value of the work slice is obtained by accumulating the performance contribution values of all working nodes of the work slice. SB2. Build an account transaction graph based on account transaction data. The account transaction data includes the total number of transactions between accounts in the last consensus cycle. Build an account transaction graph based on the transaction data. The nodes are accounts, the edges represent transactions in the last consensus cycle, and the weight of the edges represents the number of transactions. SB3, randomly assign accounts to each work shard; SB4. Calculate the cost of moving each account to the working shard where the neighbor account is located. value, and move the account to The maximum value and The corresponding work slices, where Represents the predicted transaction processing time for each work shard, expressed as follows: ; in Indicates the number of transactions in the work slice, is the number of cross-shard transactions, is the transaction weighting coefficient, is the performance prediction value of the work slice, In the node allocation phase, the account is obtained from the allocation chain. On this basis, the account is allocated from the work shard Move to Worker Shard of It can be expressed as follows: ; When there is only one account in the work shard where the account is located, ,otherwise, Move the working shard for this account and work sharding Predicted transaction processing time; SB5, determine whether there is an account to change the work slice, if there is an account to change the work slice, then execute SB4; Otherwise, execute SB6; SB6. Broadcast the account allocation results and build an account allocation block. Write the account allocation results, i.e. the account-shard mapping table, into the block for PBFT consensus within the committee. After reaching consensus, broadcast the account allocation results to the working nodes and add the block, i.e. the account allocation block, to the allocation chain. The transaction processing phase refers to each work shard processing the transactions of the accounts belonging to the work shard, packaging them into blocks and submitting them to the transaction chain to which the work shard belongs; The data update phase refers to the allocation committee updating the node contribution value based on the contribution value report submitted by the working shard, and saving the account transaction data based on the transaction block submitted by the working shard.
2. According to claim 1, a blockchain sharding method for achieving load balancing based on node contribution value is characterized in that: The specific steps of the transaction processing stage are as follows: SC1. Select transactions from pending transactions in which both parties have accounts belonging to this work shard; SC2: Verify transactions and package them into blocks. Verify transactions through the transaction chain of this work shard, and select successfully verified transactions to package them into blocks. SC3: Transaction blocks are voted on in the allocation committee through PBFT, and each working node verifies and votes on the transactions in the transaction block; SC4: Determine whether consensus has been reached. If no consensus has been reached, execute SC5; if consensus has been reached, execute SC6; SC5: Replace the leader of the allocation committee. After replacing the leader of the allocation committee, execute SC1; SC6, the leader of the allocation committee updates the local node contribution value list according to the consensus process. The contribution value is divided into security contribution value and performance contribution value. The security contribution value and performance contribution value are based on the number of transactions processed by this consensus. and processing time , and whether the working node is the leader of the distribution committee to update the performance contribution value of the node, the first After the update, the worker node of worker shard j Performance contribution It is expressed as follows: ; in Indicates the reward and penalty weight of the master node relative to the slave node, Indicates the number of slave nodes for this consensus. ; Security Contribution Value in a consensus cycle Safety contribution value after update It is expressed as follows: ; in Indicates the reward weight for successfully submitting a block, Indicates the penalty weight for failing to submit a block, ; SC7. Put the transaction block on the chain and broadcast it to the allocation committee.
3. According to claim 1, a blockchain sharding method for achieving load balancing based on node contribution value is characterized in that: The specific steps of the data update phase are as follows: SD1. The working node submits a contribution value report to the allocation node, which contains the most recently updated security contribution value and performance contribution value of the working node where the shard is located. After the working shard reaches a PBFT consensus on the contribution value report, the report is sent to the allocation committee. SD2. The assigned node updates the node contribution value and organizes the account transaction data. The contribution value in the contribution value report represents the contribution value of the working node in this consensus cycle. The global contribution value of the node is updated based on this value: ; in Indicates the node after this round of consensus cycle The performance contribution value of Indicates the working nodes before this round of consensus cycle The performance contribution value of Indicates the working node after the latest update in this round of consensus cycle The performance contribution value in this round is Represents the contribution value retention coefficient. Similarly, the performance value of the working node is updated: ; After updating the contribution value of the working node, the account transaction status in this round of consensus cycle is sorted out, the total number of transactions between accounts is calculated, and then the processing time ratio of cross-shard transactions and intra-shard transactions of each working shard is calculated, and the average value is taken as The latest value of the contribution value data, transaction data and Values are packaged into blocks; SD3. Vote on data update results in the distribution committee through PBFT; SD4: Determine whether consensus has been reached. If no consensus has been reached, execute SD5; if consensus has been reached, execute SD6; SD5: Replace the leader of the allocation committee. After replacing the leader of the allocation committee, execute SD2. SD6. Submit the data update block to the distribution chain.
Citation Information
Patent Citations
Node selection method, block chain consensus method, device, system and equipment
CN112953981A
Privacy protection asynchronous federation sharing method and system based on block chain
CN114297722A
