A load balancing method and device for blockchain sharding model

By building a global load model and prediction model, combined with off-chain migration protocol, load balancing of the blockchain shard system is achieved, solving the problem of unbalanced load of the shard system, improving performance and ensuring the integrity and correctness of data transmission sex.

CN118740853BActive Publication Date: 2024-11-22CRYPTOZOOLOGY & CYBERSPACE SECURITY (HUANGPU) RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411230695.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-11-22
Estimated Expiration
2044-09-04

AI Technical Summary

Technical Problem

During the expansion process of blockchain sharding system, the load distribution is difficult to achieve balance, resulting in some shards being idle and some shards being too high, forming a bottleneck and affecting system performance.

Method used

By building a global load model, the load offset and shard range of busy shards are obtained, and the migration target shard is determined in combination with the prediction model. Off-chain migration is used combined with on-chain verification load migration protocol to achieve balanced load distribution.

Benefits of technology

It effectively solves the problem of unbalanced load of sharded systems, improves the overall performance of the system, and ensures the integrity and correctness of data transmission during load migration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118740853B_ABST
    Figure CN118740853B_ABST
Patent Text Reader

Abstract

The present application discloses a load balancing method and device for a blockchain sharding model. The sharding system is divided into states through a global load model to obtain busy shards and a global load state of the sharding system. For each busy shard, the load offset corresponding to the busy shard is obtained through the global load model, and the shard range involved in the load migration is determined. According to a pre-built prediction model and load offset, the destination shard involved in the load migration is determined, and the method returns to execute the step of obtaining the load offset corresponding to the busy shard through the global load model and determining the shard range involved in the load migration, until the shard range and destination shard involved in the load migration of all busy shards in the sharding system are obtained. According to the shard range, destination shard and global load state involved in the load migration of all busy shards, a load balancing strategy is generated, and load migration is performed according to the load balancing strategy and the load migration protocol.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain sharding technology, and more specifically, to a load balancing method and device for a blockchain sharding model. Background Art

[0002] Blockchain is a specific data structure formed by combining data blocks in a chain in chronological order based on transparent and trusted consensus rules in a peer-to-peer network environment, and a decentralized, trustless distributed shared ledger system that uses cryptography to ensure that its data cannot be tampered with, forged, and traceable.

[0003] In order to improve the scalability of public blockchains, that is, to expand the capacity of public chains, many research works have been proposed. The core of capacity expansion is to improve the performance of blockchains while maintaining decentralization and security. Blockchain sharding technology is a mainstream on-chain capacity expansion technology. It divides the entire blockchain network into non-intersecting parts, namely shards.

[0004] As a blockchain on-chain expansion technology, on the one hand, the introduction of sharding technology does bring strong scalability to the sharding system, but on the other hand, it also introduces some problems behind it. In sharding, performance improvement is achieved by distributing transactions to different shards for parallel processing. Therefore, as the number of shards increases, the throughput of the system can be increased linearly. However, in real scenarios, due to factors such as data distribution, geographical distribution, and node failures, it is often difficult for the load distribution of the entire sharding system to achieve a balanced state. The hot spot problem caused by the unbalanced load will cause some shards in the system to fall into an idle state, while some shards are overloaded and become "hot shards", unable to process transactions in time, and thus become the bottleneck of the entire sharding system.

[0005] Therefore, how to achieve load balancing in the sharding system is an urgent problem to be solved in this application. Summary of the invention

[0006] In view of this, the present application discloses a load balancing method and device for a blockchain sharding model, which aims to perform load migration according to a load balancing strategy and a load migration protocol that combines off-chain migration load with on-chain verification, so as to achieve load balancing of the sharding system under the balanced sharding blockchain, and ensure the integrity and correctness of data transmission during load migration.

[0007] In order to achieve the above purpose, the disclosed technical solution is as follows:

[0008] The first aspect of the present application discloses a load balancing method for a blockchain sharding model, the method comprising:

[0009] The sharding system is divided into states through the pre-built global load model to obtain the busy shards and global load states of the sharding system;

[0010] For each busy shard, obtain the load offset corresponding to the busy shard through the global load model, and determine the shard range involved in the load migration;

[0011] According to the pre-built prediction model and the load offset, the destination shard involved in the load migration is determined, and the step of obtaining the load offset corresponding to the busy shard through the global load model and determining the shard range involved in the load migration is returned to execute, until the shard range and destination shard involved in the load migration of all busy shards in the shard system are obtained;

[0012] Generate a load balancing strategy according to the shard range, the destination shard and the global load status involved in the load migration of all busy shards;

[0013] Load migration is performed according to the load balancing strategy and load migration protocol; wherein the load migration protocol is a load migration protocol that combines off-chain migration with on-chain verification.

[0014] Preferably, the process of building a global load model includes:

[0015] Obtaining the operation data of the sharding system; wherein the operation data of the sharding system includes at least the average number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor, and the corrected communication transmission error factor;

[0016] A global load model is constructed by the average number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor and the corrected communication transmission error factor.

[0017] Preferably, the state division of the shard system by using a pre-built global load model to obtain each busy shard of the shard system and the global load state includes:

[0018] Through the pre-built global load model, the average number of transactions received per second in the current shard of the sharding system, the average hash value of the current shard, the corrected statistical error factor, the corrected communication transmission error factor, the average number of transactions contained in the generated blocks, and the difficulty parameter of the proof of work problem are obtained;

[0019] For all shards, determine the range of the ratio of the average number of transactions received per second in the current shard to the average hash value of the current shard;

[0020] If the ratio is within a first defined range, the shard corresponding to the ratio within the first defined range is determined as a busy shard of the shard system; wherein the first defined range is determined by the average value of the number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, and the corrected statistical error factor; the busy shard is a shard whose processing capacity cannot meet the transaction arrival rate;

[0021] If the ratio is within a second defined range, the shard corresponding to the ratio within the second defined range is determined as a balanced shard of the sharding system; wherein the second defined range is determined by the average value of the number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, the corrected statistical error factor, and the corrected communication transmission error factor; the balanced shard is a shard whose processing capacity matches the transaction arrival rate;

[0022] If the ratio is within a third defined range, the shard corresponding to the ratio within the third defined range is determined as an idle shard of the shard system; wherein the third defined range is determined by the average value of the number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, and the corrected communication transmission error factor; the idle shard is a shard whose processing capacity is greater than the transaction arrival rate;

[0023] This continues until all shards have been judged, and the global load status of the shard system is determined based on the judgment results.

[0024] Preferably, the process of determining the shard range involved in the load migration includes:

[0025] A shard range involved in load migration is determined according to the global load model, the busy shards, and the idle shards.

[0026] Preferably, the process of generating a load balancing strategy includes:

[0027] For each busy shard of the shard system, determine the load state corresponding to the busy shard through the global load state;

[0028] Maintaining a priority queue and determining the number of unspent transaction outputs to migrate out based on the shard load offset, the scaling factor, and the load status corresponding to the busy shard;

[0029] Get the transaction in the priority queue that has the highest probability of being spent in the next epoch;

[0030] The target shard for migrating the transaction with the highest probability of being spent is selected through the balancing shard, and the step of returning to execute the global load state of the shard system and determining the load state corresponding to the busy shard is performed until the shard range and target shard involved in the load migration of all busy shards of the shard system are obtained, so as to complete the process of generating a load balancing strategy.

[0031] Preferably, determining the destination shard involved in the load migration according to the pre-built prediction model and the load offset includes:

[0032] Determine a list of unspent transaction outputs to be migrated based on a pre-built prediction model and the load offset;

[0033] The destination shard involved in the load migration is determined from the list of unspent transaction outputs to be migrated by a preset destination shard calculation formula; wherein the preset destination shard calculation formula is determined by the edge set, constant, proportional coefficient, load offset, average access probability of shards in epochs, and average access probability of idle shard sequences in epochs owned by the idle shards.

[0034] Preferably, performing load migration according to the load balancing strategy and the load migration protocol includes:

[0035] Use the hash function to construct the metadata of the unspent transaction output set that is migrated out of the nodes in the source shard;

[0036] Submitting the cross-shard control transaction of the source shard and the destination shard to the destination shard; the cross-shard control transaction includes at least a checkpoint of a block number and metadata;

[0037] The metadata is transmitted to the destination shard through the source shard, and the transmission process is verified to complete the load migration process; the verification is performed by the source shard based on the metadata and the response of the destination shard in the form of a cross-shard transaction.

[0038] Preferably, the process of constructing the prediction model includes:

[0039] For each unspent transaction output, the amount, age, address activity and transaction history information of the unspent transaction output are obtained; wherein the amount is used to indicate the amount of the unspent transaction output; the age is used to indicate the time from the creation to the spending of the unspent transaction output; the address activity is quantified by calculating the number of transactions involved in the address;

[0040] A prediction model is constructed based on the amount, age, address activity and transaction history information of the unspent transaction output.

[0041] The second aspect of the present application discloses a load balancing device for a blockchain sharding model, the device comprising:

[0042] A partitioning unit is used to partition the state of the sharding system by using a pre-built global load model to obtain the busy shards and global load state of the sharding system;

[0043] A first determining unit is used to obtain, for each busy slice, a load offset corresponding to the busy slice through the global load model, and determine a slice range involved in the load migration;

[0044] A second determination unit is used to determine the destination shard involved in the load migration according to the pre-built prediction model and the load offset, and return to execute the step of obtaining the load offset corresponding to the busy shard through the global load model and determining the shard range involved in the load migration, until the shard range and destination shard involved in the load migration of all busy shards in the shard system are obtained;

[0045] A generating unit, configured to generate a load balancing strategy according to the shard range, the destination shard and the global load state involved in the load migration of all busy shards;

[0046] A load migration unit is used to perform load migration according to the load balancing strategy and load migration protocol; wherein the load migration protocol is a load migration protocol that combines off-chain migration with on-chain verification.

[0047] Preferably, the division unit for constructing the global load model includes:

[0048] A first acquisition module is used to acquire the operation data of the sharding system; wherein the operation data of the sharding system at least includes the average number of transactions contained in the generated blocks, the difficulty parameter of the proof of work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor, and the corrected communication transmission error factor;

[0049] The first construction module is used to construct a global load model through the average number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor and the corrected communication transmission error factor.

[0050] It can be known from the above technical scheme that the present application discloses a load balancing method and device for a blockchain sharding model, which divides the state of the sharding system through a pre-constructed global load model to obtain each busy shard and the global load state of the sharding system, and for each busy shard, obtains the load offset corresponding to the busy shard through the global load model, and determines the shard range involved in the load migration, and determines the destination shard involved in the load migration according to the pre-constructed prediction model and load offset, and returns to execute the step of obtaining the load offset corresponding to the busy shard through the global load model and determining the shard range involved in the load migration, until the shard range and destination shard involved in the load migration of all busy shards in the sharding system are obtained, and a load balancing strategy is generated according to the shard range, destination shard and global load state involved in the load migration of all busy shards, and load migration is performed according to the load balancing strategy and the load migration protocol, wherein the load migration protocol is a load migration protocol that combines off-chain migration with on-chain verification.

[0051] Based on the above scheme, a global load model is established by counting the operation data of the sharding system. The global load of the sharding system is described by the load model to obtain the global load status of the sharding system. Based on the global load status, the sharding range and target sharding involved in the load migration of all busy shards, a load balancing strategy is generated. According to the load balancing strategy and the load migration protocol with off-chain migration load combined with on-chain verification, load migration is performed to achieve the purpose of load balancing of the sharding system under the balanced sharding blockchain. In addition, load migration is performed according to the load balancing strategy and the load migration protocol with off-chain migration load combined with on-chain verification to ensure the integrity and correctness of data transmission during load migration. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0053] Figure 1 This is a system architecture diagram of the sharded blockchain load balancing protocol under the UTXO transaction model disclosed in the embodiment of this application;

[0054] Figure 2 This is an overview of the sharded blockchain load balancing protocol under the UTXO transaction model disclosed in the embodiment of the present application;

[0055] Figure 3A schematic diagram of the amount fitting of the prediction modeling in the sharded blockchain load balancing protocol under the UTXO transaction model disclosed in the embodiment of the present application;

[0056] Figure 4 A schematic diagram of age fitting for predictive modeling in a sharded blockchain universal load balancing protocol under the UTXO transaction model disclosed in an embodiment of the present application;

[0057] Figure 5 A schematic diagram of an overview of a load migration protocol in a load balancing protocol disclosed in an embodiment of the present application;

[0058] Figure 6 A flow chart for generating a load balancing strategy disclosed in an embodiment of the present application;

[0059] Figure 7 A code diagram for load migration and verification disclosed in an embodiment of the present application;

[0060] Figure 8 A flowchart of a load balancing method for a blockchain sharding model disclosed in an embodiment of the present application;

[0061] Fig. 9 A schematic diagram showing a time-consuming comparison of state division under different transaction quantities disclosed in an embodiment of the present application;

[0062] Fig.10 A schematic diagram of a cumulative distribution function of load offset under different state division schemes disclosed in an embodiment of the present application;

[0063] Fig.11 is the cumulative distribution function of the transaction queue size under different state division schemes disclosed in the embodiments of the present application;

[0064] Fig.12 A schematic diagram of the structure of a load balancing device for a blockchain sharding model disclosed in an embodiment of the present application;

[0065] Fig.13 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0066] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0067] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0068] As can be seen from the background technology, as a kind of expansion technology on the blockchain chain, on the one hand, the introduction of sharding technology does bring extremely strong scalability to the sharding system, but on the other hand, it also introduces some problems behind it. In sharding, the improvement of performance is completed by distributing transactions to different shards for parallel processing, so as the number of shards increases, the throughput of the system can be linearly improved. However, in real scenarios, limited by factors such as data distribution, geographical distribution, and node failure, the load distribution of the entire sharding system is often difficult to achieve a balanced state. The hot spot problem caused by the unbalanced load will cause some shards in the system to fall into an idle state, and some shards are overloaded and become "hot shards", which cannot process transactions in time, and therefore become the bottleneck of the entire sharding system. Therefore, how to achieve load balancing of the sharding system is a problem that this application urgently needs to solve.

[0069] In order to solve the above problems, the present application discloses a load balancing method and device for a blockchain sharding model, which establishes a global load model by counting the operating data of the sharding system, describes the global load of the sharding system through the load model, and obtains the global load state of the sharding system. Based on the global load state, the sharding range and target sharding involved in the load migration of all busy shards, a load balancing strategy is generated, and load migration is performed according to the load balancing strategy and the load migration protocol verified on the chain in combination with the off-chain migration load, so as to achieve the purpose of load balancing of the sharding system under the balanced sharding blockchain. In addition, load migration is performed according to the load balancing strategy and the load migration protocol verified on the chain in combination with the off-chain migration load, so as to ensure the integrity and correctness of data transmission during the load migration process. The specific implementation method is specifically described through the following embodiments.

[0070] refer to Figure 1 As shown, this is a system architecture diagram of a sharded blockchain load balancing protocol under the unspent transaction output (UTXO) transaction model disclosed in an embodiment of the present application. The sharding system consists of a balancing shard, a root shard, a virtual shard, and a common shard module, which implements a load balancing protocol for a universal sharded blockchain under the UTXO transaction model.

[0071] Among them, in the entire blockchain, there are four types of shards, namely root shards, virtual shards, ordinary shards and balanced shards.

[0072] Root shard: runs enhanced Byzantine consensus and is unique. It is the highest-level shard in the entire shard system that stores the entire state and is responsible for managing leader election, second-phase confirmation, reputation updates, cross-shard transactions, etc.

[0073] Among them, the status of the sharding system is shown in Table 1.

[0074]

[0075] Virtual shards: Made up of virtual nodes running the Proof of Work (POW) consensus, there may be multiple levels in a virtual shard. The higher the level of a virtual shard, the more normal shards there are in its hierarchy.

[0076] Ordinary shards: run PoW consensus, where each shard stores part of the state of the entire shard system. The normal nodes in this ordinary shard are usually nodes with relatively low processing power, which are only responsible for processing and confirming transactions within the shard and cross-shard transaction results from the upper-level virtual shard or root shard.

[0077] Balanced Sharding: Runs Enhanced Byzantine Consensus, which is unique in the entire sharding system and is responsible for synchronizing new blocks of the current epoch from the root shard to obtain global transactions and global load status. It models the access probability of unspent transactions in each common shard in the next epoch based on the prediction model, and stores these transactions in a priority queue based on this probability. At the end of the epoch, it generates a corresponding load strategy based on the load status of the current sharding system and performs load migration.

[0078] Specifically, the balancing shard divides the state of the shard system through the pre-built global load model to obtain the busy shards and global load status of the shard system;

[0079] For each busy shard, the balancing shard obtains the load offset corresponding to the busy shard through the global load model, and determines the shard range involved in the load migration;

[0080] The balancing shard determines the destination shard involved in the load migration based on the pre-built prediction model and load offset, and returns to execute the step of obtaining the load offset corresponding to the busy shard through the global load model and determining the shard range involved in the load migration, until the shard range and destination shard involved in the load migration of all busy shards in the shard system are obtained; wherein the destination shard is the shard with the highest penalty load compared to the average value.

[0081] The balancing shard generates a load balancing strategy based on the shard range, destination shard, and global load status involved in the load migration of all busy shards;

[0082] Load migration is performed according to the load balancing strategy and load migration protocol; among which, the load migration protocol is a load migration protocol that combines off-chain migration with on-chain verification.

[0083] An overview of the load balancing protocol is as follows Figure 2 As shown, Figure 2 An overview of the sharded blockchain load balancing protocol under the UTXO transaction model is shown.

[0084] Figure 2 At the beginning of each epoch, the balancing shard will initialize the committee, synchronize the block to model the access probability based on the prediction model, monitor in a loop, and give the prediction model to calculate the access probability. At the end of the epoch, the balancing shard will establish a global load model based on the current epoch statistics, and describe the global load status through the global load model. Finally, the balancing shard will generate the corresponding load balancing strategy based on the global load status. When the committee reaches a consensus, the corresponding load migration is performed through the load balancing strategy and the load migration protocol. The load migration protocol is a load migration protocol that combines off-chain migration with on-chain verification.

[0085] The specific protocol consists of four parts: global load model, prediction model, state division and load migration:

[0086] 1. Global load model:

[0087] First, we need to describe the global load status of the current shard system to understand the current system load. First, we define the load status of the shard, including busy state, balanced state and idle state.

[0088] Busy state: The current shard’s processing capacity cannot meet the transaction arrival rate, causing the shard to be in a high-load state. The transaction backlog becomes the bottleneck of the entire shard system.

[0089] Balanced state: The processing capacity of the current shard matches the transaction arrival rate, the load of the shard is balanced, and its processing capacity is fully utilized.

[0090] Idle state: The current shard processing capacity is higher than the transaction arrival rate, causing the shard to be in a low-load idle state and its processing capacity cannot be fully utilized.

[0091] For a shard system, in an epoch, the average number of transactions contained in the blocks generated in the shard system is N, and the difficulty of the PoW problem is P. For one of the shards, the shard S i The average number of transactions received per second isM i , and the current average hash rate of the shard H i , we can calculate that theoretically this shard generates one block every t seconds, that is, t=P / M i The above data can be calculated by synchronizing the sharding system data of the current era.

[0092] In a sharding system, both N and P are relatively stable values, so P / N is recorded as σ in building a global load model. S i , can be M i , H i , σ to define the sharding i The specific definition range is shown in formula (1).

[0093]

[0094] in, For fragment S i Scope of definition; For Sharding i The load indicates that the shard is in a balanced state; The shard is busy; The shard is in idle state; α 1 To correct the statistical error factor; α 2 is the communication transmission error factor.

[0095] Through the pre-built global load model, the average number of transactions received per second for the current shard of the shard system, the average hash value of the current shard, the corrected statistical error factor, the corrected communication transmission error factor, the average number of transactions contained in the generated blocks (N), and the difficulty parameter (P) of the Proof of Work (POW) problem are obtained. For all shards, the average number of transactions received per second in the shard is determined ( M i ) and the average hash value of the current shard ( H i ) ratio range.

[0096] The definition range includes a first definition range, a second definition range, and a third definition range.

[0097] If the ratio is within the first defined range, the shard corresponding to the ratio within the first defined range is determined as the busy shard of the shard system; if the ratio is within the second defined range, the shard corresponding to the ratio within the second defined range is determined as the balanced shard of the shard system; if the ratio is within the third defined range, the shard corresponding to the ratio within the third defined range is determined as the idle shard of the shard system.

[0098] It should be noted that the first defined range is determined by the N contained in the generated block, the P of the POW problem and the corrected statistical error factor; the second defined range is determined by the N contained in the generated block, the P of the POW problem, the corrected statistical error factor and the corrected communication transmission error factor; the third defined range is determined by the N contained in the generated block, the P of the POW problem and the corrected communication transmission error factor.

[0099] A busy shard is a shard whose processing capacity cannot meet the transaction arrival rate; a balanced shard is a shard whose processing capacity matches the transaction arrival rate; and an idle shard is a shard whose processing capacity is greater than the transaction arrival rate.

[0100] Furthermore, by using the load deviation (S i ), can describe the fragment S i The idleness or busyness of the deviation (S i ) The calculation expression is shown in formula (2).

[0101]

[0102] Among them, deviation (S i ) is the load offset; is a scale parameter used to limit the size of this load offset to a suitable range; M i is the average number of transactions received per second in the shard; H i is the average hash value of the current shard; α 1 To correct the statistical error factor; in the sharding system, both N and P are relatively stable values, so P / N is recorded as σ in building the global load model; α 2 is the communication transmission error factor; according to deviation (S i ) Determine the UTXO list that needs to be migrated ( ind ( v , idle _ Shard _ list )) Determine the migration destination shard based on the UTXO list that needs to be migrated.

[0103] 2. Prediction model:

[0104] In a sharding system, the most basic load migration can be accomplished by migrating unspent UTXOs from busy shards to idle shards. However, for the migration of these unspent transactions, it is necessary to quantify their probability of being spent in the next epoch, otherwise, random migration may not bring benefits to the system's load balancing. This is because random migration cannot guarantee that the migrated unspent transactions are likely to be spent in the next epoch, and if they are not spent for a long time afterwards, then the corresponding migration will not bring benefits to the system, but will consume additional resources.

[0105] In summary, this chapter first focuses on unspent transactions and establishes a prediction model based on four dimensions: amount, age, address activity, and transaction history information to quantify the probability that an unspent UTXO will be spent in the i+1th epoch: f access ( UTXO , i ), which provides the basis for the subsequent state division. The specific prediction model is constructed as follows:

[0106] (1) Amount

[0107] As the basic information of UTXO, the amount directly quantifies the size of UTXO. Based on previous research

[11] , UTXO with larger amount has a lower probability of being spent than UTXO with smaller amount, because it is mostly considered to be used as a store of value, while UTXO with smaller amount has a higher probability of being spent and its liquidity is also stronger.

[0108] The generalized linear model with logarithmic transformation is used for the probability of accessing the amount, and its calculation formula is shown in formula (3).

[0109]

[0110] in, f amount ( x ) is the probability of access to the amount; x is the transaction amount; β is a scale parameter used to x Restricted to a suitable range; e is the Euler number; ln Representative e is the logarithm of the base; π is the ratio of pi; in the sharding system, both N and P are relatively stable values, so P / N is recorded as σ in constructing the global load model; μ is the parameter of the probability density function of the lognormal distribution.

[0111] The generalized linear model using logarithmic transformation for the probability of access to monetary value is shown in the following table: Figure 3 shown. Figure 3 A schematic diagram showing the amount fitting of predictive modeling in the sharded blockchain general load balancing protocol under the UTXO transaction model.

[0112] Figure 3 In the figure, the horizontal axis represents the amount and the vertical axis represents the access probability.

[0113] (2) Age

[0114] Age is the basic information of UTXO, which reflects the time from the creation of UTXO to its consumption. Similar to the fitting of amount, this scheme first counted the age of more than 50,000 UTXOs in digital assets, and used a variety of fitting methods to fit them. The final result proved that the exponential distribution obtained the best fitting effect, and the square value of the correlation coefficient was calculated, and the average value obtained was R2=0.72.

[0115] The distribution and fitting results are as follows Figure 4 As shown, Figure 4 The probability of spending a UTXO is inversely proportional to its age, and more than 61.1% of UTXOs are spent on the same day. x The access probability of UTXO in an hour is modeled by the following formula (4):

[0116]

[0117] in, f age ( x ) is age; λ is the parameter of exponential distribution, i.e. the result of fitting; e is the Euler number; x For time.

[0118] The exponential distribution is used to fit the age access probability, and the results are as follows: Figure 4 shown. Figure 4 A schematic diagram of age fitting for predictive modeling in a general load balancing protocol for sharded blockchains under the UTXO transaction model is shown.

[0119] Figure 4 In the figure, the horizontal axis represents the number of days and the vertical axis represents the access probability.

[0120] (3) Address activity

[0121] The activity of an address is quantified by counting the number of transactions involved in it. x In the Era i The activity level is shown in formula (5).

[0122]

[0123] in, f addr ( x , i ) to define the address x In the Era i activity level; γ is a proportionality coefficient; Block The blocks created for the current epoch; epoch i Representing the Era i ; tx For transactions in the block; g ( tx , x ) is defined as shown in formula (6).

[0124]

[0125] Among them, Hash (pubkey i ) is the era i The value of the public key after hashing (Hash); Hash (x) is the address x The hashed value.

[0126] (4) Transaction history information

[0127] In the blockchain system, historical transactions reflect the flow of value and will also affect the status of UTXO, such as an increase in account balance and address activity, which increases the chance of being spent. Therefore, the historical transactions of a UTXO should also be taken into consideration in the model. For a UTXO, the historical transaction information chain is appended and summarized through its input.

[0128] Specifically, in the current prediction model, a UTXO input UTXO inputs Taking into account its historical transaction information, the historical information score of a UTXO is defined as shown in formula (7).

[0129]

[0130] in, f hist ( UTXO inputs ) is the transaction history information of UTXO; input It is the input of transaction UTXO; UTXO inputs A collection of inputs of a UTXO; f access ( input , i) is the access probability of the node corresponding to this input in the previous epoch; input.val For each input input The amount of money.

[0131] Based on the above four dimensions (amount, age, address activity, and transaction history information), the UTXO in the entire transaction network will be i The access probability of +1 is weighted and quantized, as shown in formula (8).

[0132]

[0133] in, w i Represents the weights of different dimensions; f access ( UTXO , i ) is the UTXO in the next epoch i +1 access probability weighted sum quantization; f amount ( UTXO amount ) is the probability of access to the amount; f age ( UTXO age ) is the access probability; f addr ( UTXO address , i ) is the address activity level; f hist ( UTXO inputs ) is the transaction history information of UTXO; w 1 is the weight of the probability of access to the amount; w 2 is the weight of the access probability; w 3 is the weight of the address activity; w 4 is the weight of transaction history information.

[0134] Through predictive modeling, the probability of UTXO being spent can be quantified. The higher the corresponding access probability, the more likely the corresponding UTXO is to be spent in the next epoch.

[0135] 3. Status division:

[0136] (1) Global transaction status

[0137] In order to observe the relationship between transactions more clearly, the global transaction state is modeled in the form of a graph. In the UTXO model, each UTXO is generated by the previous UTXO, that is, the input of each UTXO is the output of the previous UTXO. Therefore, a directed acyclic graph can be constructed based on the UTXO set of historical transactions. First, some concepts are defined as follows:

[0138] Global transaction status network: The global transaction status network is a directed graph G=<V,E> In the form of, V is the UTXO transaction set, E is the directed edge set, if UT XOu uses UT XOv as input, then there exists<v,u> ∈E.

[0139] Among them, a UTXO u represents a UT XOu, that is, an unspent transaction u, and u is a vertex in the entire graph G.

[0140] UTXO v represents a UT XOv, that is, an unspent transaction v, where v is a vertex in the entire graph G.

[0141] Coin creation transaction: As the initial node in the topological order of the entire network, it represents the reward for computing power and is a node with an in-degree of 0.

[0142] Historical transactions: As historical transaction records in the entire network, the out-degree of these nodes is greater than 0, which means that the corresponding UTXO has been spent. Unspent transactions: As transactions that have not been spent in the entire network, the out-degree of these nodes is equal to 0, representing UTXO that has not been spent in the network.

[0143] Based on the above definition, the global transaction data can be converted into a directed acyclic graph (DAG) for storage, and the basic information of each UTXO and the connection between UTXOs can be obtained from it.

[0144] (2) Transaction status classification

[0145] Based on the above global transaction status network, this solution can store and describe the current global transaction status in the form of a directed acyclic graph. Therefore, the task of dividing the transaction network becomes dividing the entire transaction status network into k disjoint node subsets S = {S1, ..., Sk}, where k is the number of shards, S i Represents fragmentation i A set of transactions under management. For all i , j =1→ k ,have U k i=1S i = For simplicity, S i Sharding i .

[0146] in, U Refers to the UTXO data under each shard; Represents the empty set, that is, the entire state is divided into multiple disjoint states.

[0147] In this chapter, the redivision of transaction status is completed through load migration between shards. First, it is necessary to generate a corresponding load balancing strategy to complete the redivision of the network, and perform load migration based on the load balancing strategy to achieve the purpose of optimizing state division. The load model defined above can be used to determine busy shards and idle shards, that is, the range of shards involved in load migration. Based on the prediction model in the previous article, the UTXO of unspent transactions can be stored in the form of a priority queue based on the access probability, and deviation ( S i ) to determine the number of UTXOs to be migrated in and out. For the destination shard (destination idle shard) of the UTXO to be migrated out, in order to maximize the relevant transactions, this solution will try to place transactions involving the same input (transactions with the same input refer to multiple transactions involving inputs derived from the same unspent transaction) in the same shard to minimize the probability of cross-shards in the input direction.

[0148] UT XOv and idle shard sets that need to be migrated at the end of epoch e S l { S 1, S 2, ...., S k}, firstly, we define some concepts based on the formula, as shown in formula (9).

[0149]

[0150] in, Score ( S j ) is a shard j In the Era i The average access probability of Score ( S i ) is a shard S i In the Era i The average access probability of faccess ( i , e ) is the access probability of UTXO i in epoch e+1; avgScore ( S l ) is the idle fragment sequence l In the Era i The average access probability of P ( i , v ) is a shard S i The set of edges owned; S l The set of low-load shards in the current epoch; E i For Sharding S i The set of edges owned; In ( v ) is the edge set of the input of UT XOv.

[0151] For UT XOv and idle fragment sequences, the destination fragment to be migrated is determined by formula (10).

[0152]

[0153] in, ind ( v , L ) is the target shard; θ is a constant in (0, 1]; τ is a proportional coefficient used to control the value of the penalty function; argmax Si is a function used to find the value of the independent variable or the set of independent variable values ​​when the function reaches its maximum value. When we have a function y=f(x), if there exists an x0 that makes f(x0) the largest among all values ​​of x, then x0 is the result of argmax(f(x)), so argmaxsi{} represents the si that makes the following formula reach its maximum value; P ( i , v ) is a shard S i The set of edges owned; avgScore ( S l ) is the idle fragment sequence l In the Era i The average access probability of deviation ( S i ) is the load offset; Score ( S i ) is a shard Si In the Era i The average access probability.

[0154] Based on the above formula (10), this scheme will divide the state into UTXO v Assign it to the shard with the most edges, weighted by the shard's load penalty function, penalizing the shard with the highest load average.

[0155] The generation process of load balancing strategy is as follows: Figure 5 As shown. At the end of the epoch, the balancing shard first obtains the global load state (currState) of the current system. It maintains a priority queue for each busy shard based on its corresponding load state according to the shard load offset and the proportional coefficient α, and determines the number of UTXOs to be migrated. At the same time, the balancing shard also obtains the system idle shard list (idleShards). For the transaction UTXO in the priority queue that has a high probability of being spent in the next epoch v ,Based on the above, the balancing shard selects the destination shard to migrate (penalizing the shard with the highest load compared to the average), and after processing all busy shards, it will summarize the results and generate the final load balancing strategy.

[0156] 4. Workload Migration

[0157] Based on the load balancing strategy generated in each epoch, it is necessary to move the corresponding UTXO between shards to complete the load migration. In this chapter, considering the efficiency of migration, a combination of off-chain migration and on-chain verification is designed to complete data migration. Specifically, load migration is to migrate a large amount of data through off-chain communication links and verify data in the form of cross-shard transactions to complete the entire migration process. The migration protocol is summarized as follows: Figure 6 shown. Figure 6 A schematic diagram of an overview of the load migration protocol in the load balancing protocol is shown.

[0158] Figure 6 In the process, the nodes in the source shard (S) construct the metadata (U) of the migrated UTXO set through the hash function (SHA), and the cross-shard control transaction of the source shard and the destination shard (D) is submitted to the destination shard; the cross-shard control transaction includes at least the checkpoint of the block number and metadata, establishes an off-chain connection and migrates the data off-chain, that is, transmits the metadata to the destination shard through S, and verifies the transmission process to complete the load migration process; among them, verification is used to verify the integrity and correctness of the migration.

[0159] The entire load migration is divided into the following three stages:

[0160] (1) Initial phase: When the UTXO set is to be migrated from S to D, the initial phase begins. The nodes in S first construct the metadata of the UTXO set (called U) through hash functions such as SHA, and then submit a cross-shard control transaction involving S and D to D. The transaction includes a block number, which represents a checkpoint of U in the block number. When the control transaction is submitted in the shard through the on-chain cross-shard mechanism, the initial phase ends.

[0161] (2) Dual phase: In the dual phase, S starts to transfer U to D. The transmission between shards is pluggable and can be achieved through one-to-one communication or rumor mechanism. At the same time, S still processes transactions that do not involve migrating UTXO normally.

[0162] (3) Verification phase: In the verification phase, the integrity and correctness of the transmission need to be verified. S performs the verification based on the metadata and D’s response in the form of a cross-shard transaction.

[0163] In the initial mode, due to the transaction delay in the blockchain, that is, there is a delay between the node sending the transaction to the network and all honest nodes being able to confirm the transaction. Therefore, the metadata generated by different nodes may have different versions, and S may not be able to reach a consensus on the same control transaction. In order to synchronize the metadata of each node in S, the protocol sets the following rules: when a node starts to generate metadata, it stops processing any new data transactions and raises objections to the blocks including these transactions during the consensus period until the end of the initial mode, so as to ensure the consistency of the migrated data.

[0164] To ensure the correctness and integrity of the transmission, the detailed protocol of load migration and verification is as follows Figure 7 shown. Figure 7 The code diagram of load migration and verification is shown. After the initial phase is completed, the source shard node ( n s ) to the node in the destination shard ( n d ) After the communication link is established, the summary of the migration data is generated using md5_hash, and the integrity of the migration data is verified by md5_hash. When the transmission is completed, n d A response resp will be returned. n s Will be obtained from resp n d The calculated data digest md5_hash1 is compared with md5_hash1 to determine the integrity of data transmission. If they are inconsistent, the data will be retried before the number of retries r is exhausted. n s After verifying the data integrity, in order to prevent the noden d is malicious and does not inform the rest of the nodes in the shard, n s Will assemble a broadcast request Broadcast::Req{t, signaturens, n d},Require n d Initiate consensus and collect signatures from at least t people. This requirement is implemented based on threshold signatures. n s Will n d The cross-shard transaction containing the threshold signature is verified to ensure that the data is broadcast to enough nodes in the shard.

[0165] The present invention provides a solution that provides an efficient and universal load balancing protocol in a sharded blockchain scenario for describing, predicting and migrating loads to optimize state partitioning. Compared with existing technologies, the present invention has at least one or more of the following advantages:

[0166] In order to compare the load balancing effect and efficiency, based on a layered sharding scheme RMS, a load balancing scheme (RMS-balance) was added to the layered sharding scheme (RMS) in combination with the load balancing protocol. The same sharding scheme RMS was compared with the implementation of periodic transaction state partitioning based on two classic global graph partitioning algorithms, namely, RMS-hash based on the Hash graph partitioning algorithm as the state partitioning implementation (RMS-hash) and RMS-greedy based on the greedy streaming edge partitioning algorithm for state partitioning.

[0167] The Hash graph partitioning algorithm generates a corresponding hash value based on the address of the transaction and takes the modulus of the number of shards to determine the division of the transaction node. It is essentially a point partitioning algorithm. The streaming graph partitioning algorithm Greedy is a streaming edge partitioning algorithm based on intuitive greed. When the entire graph is partitioned into multiple non-intersecting shards, adjacent nodes are placed together to reduce the cutting edges. It uses a greedy algorithm to place a node in the shard that contains the most adjacent nodes, while considering the load balancing of each shard to a certain extent. This algorithm is usually used as a benchmark algorithm for graph partitioning.

[0168] This solution is based on predictive modeling. The modeling and state division of the transaction network is limited to its subset, so it is more efficient than the traditional global graph cutting solution. Compared with the global state graph segmentation algorithm, our solution only needs to traverse and calculate the global subset, so its calculation and traversal time and space complexity will have advantages, so it is more efficient. The comparison of the specific algorithm time and space complexity is shown in Table 2.

[0169]

[0170] In addition, the off-chain migration solution is designed with a load migration protocol that is verified on the chain, which efficiently completes large amounts of data transmission in an off-chain form and is supplemented by on-chain verification to improve the efficiency of the entire migration process.

[0171] The load balancing protocol in this chapter is divided into three components, namely predictive modeling, state partitioning, and load migration. The storage overhead of predictive modeling is mainly used to store the corresponding set of nodes and edges. In the modeling process, the calculation of the two dimensions of amount and age is constant time complexity. The calculation of historical transactions involves multiple inputs, but it is noted that more than 93.1% of the nodes in the entire network have an in-degree of less than 3, so most of the calculations can be approximately considered to be constant time complexity, that is, k represents the average number of new transaction inputs in the current epoch. For the statistics of addresses, in fact, only one traversal of the input of the current epoch transaction is needed to complete the statistics of all addresses, so the overall complexity is linear. The time overhead in state partitioning is mainly in finding the target idle shard. Since the balance follows the principle of relevance to minimize cross-shard transactions in the input direction in state partitioning, it is necessary to traverse the edges in the idle shards to determine the target shard during the migration process. The space overhead in the state partitioning process is mainly in the partitioning results of the storage nodes. In the load migration protocol, its time and space complexity are related to the number of nodes to be migrated. The nodes to be migrated are part of the unspent transaction UTXO nodes in the current system, and during the migration process, it is necessary to establish an off-chain connection between the high-load shard and the low-load shard through cross-shard control transactions. In summary, the proposed load balancing protocol can maintain linear time and space complexity as the number of transactions increases, so it has good scalability.

[0172] Figure 8 The figure shows the load balancing time of different state partitioning schemes under 17 shards as the number of transactions increases. It can be seen that when the number of transactions reaches 100,000, the time overhead of RMS-hash has exceeded that of RMS-balance. This is because as the order of magnitude of transactions continues to increase, even if the hash operation for all nodes in the graph is a constant complexity, the accumulated time overhead of this point division is huge. In RMS-balance, since the traversal of nodes and edges only involves a part of the entire transaction directed acyclic graph, its time overhead is actually optimal when the number of transactions reaches a certain level.

[0173] The present invention builds models based on historical transaction data and divides states based on a prediction model. Compared with traditional random hashing or greedy graph partitioning algorithms, the partitioning results are more accurate and the load balancing effect is better.

[0174] The invention studies the cumulative distribution function (CDF) of the load offset and transaction queue size of the above-mentioned comparison schemes under the same settings, such as Fig. 9 and Fig.10 shown. Fig. 9 The CDF of the load offset of the four schemes under 16 common shards is shown. It can be seen that the load offset distribution of RMS-balance is more convergent and its value is smaller, which also means that the state partitioning effect based on the prediction model in RMS-balance is better than other schemes, so the load is more balanced. Fig.10 The distribution function of the transaction queue size is shown in Figure 2. Compared with RMS-balance and RMS-greedy, the random partitioning of RMS-hash and RMS makes their transaction queues show a clear polarization trend. Among the above four schemes, RMS-balance has the most balanced queue size distribution and the smallest maximum queue size. In summary, the state partitioning based on the prediction model designed in this scheme achieves the best load balancing effect compared with other schemes.

[0175] The design of this solution does not involve any modification to the sharding protocol itself. It only requires the introduction of an additional balancing shard. Therefore, it can better adapt to sharding blockchain expansion protocols under various UTXO transaction models and has good versatility.

[0176] This solution first counts the operating data of the sharding system to establish a global load model. Then, through the historical data of blockchain transactions, the solution conducts statistics and analysis from multiple different dimensions to establish a prediction model. Based on the proposed prediction model and load model, the solution generates a load balancing strategy at the end of each epoch, and completes the load migration in the form of off-chain migration load combined with on-chain verification to achieve the effect of balancing the load under the sharded blockchain. Ultimately, the purpose of optimizing the performance of the sharding system and expanding its usage scenarios is achieved.

[0177] This solution provides a universal load balancing protocol for sharded blockchains under the UTXO transaction model, which is used to describe, predict and migrate the load of the sharded system, and ultimately achieve the purpose of optimizing load distribution. The solution first proposes a global load model based on the sharded system data of each epoch to accurately describe the current load status of the sharded system. Subsequently, the solution performs statistics, analysis and fitting based on the historical blockchain transaction data set, and performs predictive modeling based on the results to ensure the effectiveness and accuracy of load migration. Finally, this solution designs an efficient migration protocol that combines off-chain migration with on-chain verification to ensure efficiency in the load balancing process.

[0178] In the embodiment of the present application, a global load model is established by counting the operation data of the sharding system, and the global load of the sharding system is described by the load model to obtain the global load status of the sharding system. Based on the global load status, the sharding range and the target sharding involved in the load migration of all busy shards, a load balancing strategy is generated, and load migration is performed according to the load balancing strategy and the load migration protocol verified on the chain in combination with the off-chain migration load, so as to achieve the purpose of load balancing of the sharding system under the balanced sharding blockchain. In addition, load migration is performed according to the load balancing strategy and the load migration protocol verified on the chain in combination with the off-chain migration load, so as to ensure the integrity and correctness of data transmission during the load migration process.

[0179] refer to Fig.11 As shown, a load balancing method of a blockchain sharding model disclosed in an embodiment of the present application is shown, and the load balancing method of the blockchain sharding model is applied to the above embodiment. Figure 1 The public sharding system, the load balancing method of the blockchain sharding model mainly includes the following steps:

[0180] S1101: The shard system is divided into states using a pre-built global load model to obtain busy shards of the shard system and global load states.

[0181] In S1101, a global load model is proposed based on the shard system operation data of each epoch to accurately describe the global load status of the current shard system.

[0182] The process of building a global load model includes:

[0183] First, obtain the operating data of the sharding system; the operating data of the sharding system includes at least the average number of transactions contained in the generated blocks (N), the difficulty parameter of the proof of work (POW) problem (P), the average number of transactions received per second in the current shard (M i ), the current shard average hash rate (H i ), corrected statistical error factor and corrected communication transmission error factor.

[0184] Operation data of the sharding system:

[0185] For a sharded system, in an epoch, the average number of transactions contained in the blocks generated in the system is N, and the difficulty of the PoW problem is P. For one of the shards, the shard S i The average number of transactions received per second is M i , and the current average hash rate of the shard H i , we can calculate the theoretical averaget One block is generated per second, that is, t =P / M i The above data can be calculated by synchronizing the running data of the sharding system of the current era.

[0186] Then, a global load model is constructed based on the average number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor, and the corrected communication transmission error factor.

[0187] Specifically, the state of the shard system is divided by using the pre-built global load model to obtain the process of each busy shard of the shard system and the global load state as shown in A1-A6.

[0188] A1: Through the pre-built global load model, obtain the average number of transactions received per second by the current shard of the sharding system, the average hash value of the current shard, the corrected statistical error factor, the corrected communication transmission error factor, the N contained in the generated block, and the P of the POW problem.

[0189] A2: For all shards, determine the average number of transactions received per second in the shard ( M i ) and the average hash value of the current shard ( H i ) ratio range.

[0190] A3: If the ratio is within the first defined range, the shard corresponding to the ratio within the first defined range is determined as the busy shard of the shard system; wherein the first defined range is determined by N contained in the generated block, P of the POW problem and the corrected statistical error factor; the busy shard is the shard whose processing capacity cannot meet the transaction arrival rate.

[0191] A4: If the ratio is within the second definition range, the shard corresponding to the ratio within the second definition range is determined as the balanced shard of the sharding system; wherein the second definition range is determined by N contained in the generated block, P of the POW problem, the corrected statistical error factor and the corrected communication transmission error factor; the balanced shard is the shard whose processing capacity matches the transaction arrival rate.

[0192] A5: If the ratio is within the third defined range, the shard corresponding to the ratio within the third defined range is determined as an idle shard of the shard system; wherein the third defined range is determined by N contained in the generated block, P of the POW problem and the corrected communication transmission error factor; the idle shard is a shard whose processing capacity is greater than the transaction arrival rate.

[0193] A6: Until all shards are judged, and the global state of the shard system is determined based on the judgment results.

[0194] The execution process and execution principle of A1-A6 are similar to those of the above embodiment. Figure 2 The execution process and execution principle of the global load model are consistent, which can be referred to and will not be repeated here.

[0195] S1102: For each busy shard, obtain the load offset corresponding to the busy shard through the global load model, and determine the shard range involved in the load migration.

[0196] In S1102, the shard range involved in the load migration is determined according to the global load model, busy shards, and idle shards.

[0197] S1103: Determine the destination shard involved in the load migration based on the pre-built prediction model and load offset, and return to execute the step of obtaining the load offset corresponding to the busy shard through the global load model and determining the shard range involved in the load migration, until the shard range and destination shard involved in the load migration of all busy shards in the shard system are obtained.

[0198] This solution is based on statistics, analysis and fitting of historical blockchain transaction data sets, and builds a prediction model based on the results to ensure the effectiveness and accuracy of load migration.

[0199] The historical blockchain transaction data set is the public historical transaction data set of digital assets.

[0200] The process of building a prediction model is as follows:

[0201] First, for each UTXO, obtain the amount, age, address activity and transaction history information of the unspent transaction output; the amount is used to indicate the amount of the unspent transaction output; the age is used to indicate the time from the creation to the spending of the unspent transaction output; the address activity is quantified by calculating the number of transactions involved in the address;

[0202] Then, a prediction model is built based on the amount, age, address activity, and transaction history information of unspent transaction outputs.

[0203] Specifically, the process of determining the destination shard involved in the load migration based on the pre-built prediction model and load offset is shown in B1-B2.

[0204] B1: Determine the UTXO list to be (needed to be) migrated based on the pre-built prediction model and load offset ( ind ( v , idle_ Shard _ list )).

[0205] The load offset can refer to the content shown in the above formula (2), which will not be described again here.

[0206] B2: Determine the target shard involved in the load migration from the UTXO list to be migrated through the preset target shard calculation formula; the preset target shard calculation formula is composed of the edge set owned by the idle shard, the constant (θ), the proportional coefficient (τ), the load offset, the shard ( j ) in the era ( i ) and the average access probability and idle shard sequence ( I ) in the era ( i ) is determined by the average access probability.

[0207] The process of determining the destination shard involved in the load migration from the UTXO list to be migrated out by using the preset destination shard calculation formula can be referred to as shown in the above formula (9) and formula (10).

[0208] S1104: Generate a load balancing strategy according to the shard range, target shard, and global load status involved in the load migration of all busy shards.

[0209] The specific process of generating a load balancing strategy is shown in C1-C4.

[0210] C1: For each busy shard in the shard system, determine the load status corresponding to the busy shard through the global load status.

[0211] The global load status of the sharding system is used to understand the current system load situation. The global load status includes busy status, balanced status, and idle status.

[0212] C2: Maintain the priority queue and determine the number of UTXOs to be migrated based on the shard load offset, proportionality factor, and load status corresponding to the busy shard.

[0213] Among them, the number of UTXOs that need to be migrated is determined according to the shard load offset, the proportional coefficient, and the load status corresponding to the busy shard. At the end of the epoch, the balancing shard will first obtain the global load state currState of the current system. It will maintain a priority queue for each busy shard based on its corresponding load status according to the shard load offset and the proportional coefficient α, and determine the number of UTXOs that need to be migrated.

[0214] C3: Get the transaction in the priority queue that has the highest probability of being spent in the next epoch (UTXO v );

[0215] C4: UTXO selection through balanced sharding v The target shard to be migrated is returned to execute the global load status of the shard system, and the step of determining the global load status corresponding to the busy shard is performed until the shard range and target shard involved in the load migration of all busy shards of the shard system are obtained to complete the process of generating a load balancing strategy.

[0216] Among them, the load balancing strategy includes the number of UTXOs that need to be migrated, the shard range and target shard involved in the load migration of all busy shards in the sharding system.

[0217] S1105: Perform load migration according to the load balancing strategy and load migration protocol; wherein the load migration protocol is a load migration protocol that combines off-chain migration with on-chain verification.

[0218] It should be noted that load migration is to migrate a large amount of data through the off-chain communication link and cooperate with data verification in the form of cross-shard transactions to complete the entire migration process.

[0219] This solution designs an efficient migration protocol that combines off-chain migration with on-chain verification to ensure efficiency during the load balancing process.

[0220] The specific process of performing load migration according to the load balancing strategy and the load migration protocol is shown in D1-D3.

[0221] D1: Use the hash function (SHA) to construct the metadata (U) of the migrated UTXO set from the nodes in the source shard (S).

[0222] D2: Submit the cross-shard control transaction of the source shard and the destination shard (D) to the destination shard; the cross-shard control transaction includes at least the checkpoint of the block number and metadata.

[0223] D3: Metadata is transmitted from the source shard (S) to the destination shard, and the transmission process is verified to complete the load migration process; the verification is performed on the response of the source shard based on the metadata (U) and the cross-shard transaction form of the destination shard.

[0224] The execution process and execution principle of D1-D3 are the same as those of the above embodiment. Figure 6 The execution process and principle of load migration in are the same, which can be referred to and will not be described here.

[0225] In the embodiment of the present application, a global load model is established by counting the operation data of the sharding system, and the global load of the sharding system is described by the load model to obtain the global load status of the sharding system. Based on the global load status, the sharding range and the target sharding involved in the load migration of all busy shards, a load balancing strategy is generated, and load migration is performed according to the load balancing strategy and the load migration protocol verified on the chain in combination with the off-chain migration load, so as to achieve the purpose of load balancing of the sharding system under the balanced sharding blockchain. In addition, load migration is performed according to the load balancing strategy and the load migration protocol verified on the chain in combination with the off-chain migration load, so as to ensure the integrity and correctness of data transmission during the load migration process.

[0226] Based on the above embodiment Fig.12 A load balancing method for a blockchain sharding model is disclosed. The embodiment of the present application also discloses a load balancing device for a blockchain sharding model. Figure 3 As shown, the load balancing device of the blockchain sharding model includes:

[0227] The partitioning unit 1201 is used to partition the state of the shard system by using a pre-built global load model to obtain the busy shards and global load state of the shard system;

[0228] The first determining unit 1202 is used to obtain the load offset corresponding to each busy slice through the global load model, and determine the slice range involved in the load migration;

[0229] The second determination unit 1203 is used to determine the destination shard involved in the load migration according to the pre-built prediction model and load offset, and return to execute the step of obtaining the load offset corresponding to the busy shard through the global load model and determining the shard range involved in the load migration, until the shard range and destination shard involved in the load migration of all busy shards in the shard system are obtained;

[0230] The generating unit 1204 is used to generate a load balancing strategy according to the shard range, the destination shard and the global load status involved in the load migration of all busy shards;

[0231] The load migration unit 1205 is used to perform load migration according to the load balancing strategy and the load migration protocol; wherein the load migration protocol is a load migration protocol that combines off-chain migration with on-chain verification.

[0232] Furthermore, the division unit 1201 for constructing the global load model includes:

[0233] The first acquisition module is used to obtain the operation data of the sharding system; wherein the operation data of the sharding system includes at least the average number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor, and the corrected communication transmission error factor;

[0234] The first building module is used to build a global load model through the average number of transactions contained in the generated blocks, the difficulty parameter of the proof of work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor and the corrected communication transmission error factor.

[0235] Furthermore, the division unit 1201 includes:

[0236] The second acquisition module is used to obtain the average number of transactions received per second in the current shard of the sharding system, the average hash value of the current shard, the corrected statistical error factor, the corrected communication transmission error factor, the average number of transactions contained in the generated blocks, and the difficulty parameter of the proof of work problem through a pre-built global load model;

[0237] A determination module, used to determine, for all shards, a range of a ratio of an average number of transactions received per second in the current shard to an average hash value of the current shard;

[0238] A first determination module is used to determine, if the ratio is within a first definition range, the shard corresponding to the ratio within the first definition range as a busy shard of the shard system; wherein the first definition range is determined by the average value of the number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, and the corrected statistical error factor; a busy shard is a shard whose processing capacity cannot meet the transaction arrival rate;

[0239] A second determination module is used to determine the shard corresponding to the ratio within the second definition range as a balanced shard of the shard system if the ratio is within the second definition range; wherein the second definition range is determined by the average value of the number of transactions contained in the generated blocks, the difficulty parameter of the proof of work problem, the corrected statistical error factor, and the corrected communication transmission error factor; the balanced shard is a shard whose processing capacity matches the transaction arrival rate;

[0240] A third determination module is used to determine the shard corresponding to the ratio within the third definition range as an idle shard of the shard system if the ratio is within the third definition range; wherein the third definition range is determined by the average value of the number of transactions contained in the generated blocks, the difficulty parameter of the proof of work problem, and the correction factor of the communication transmission error; the idle shard is a shard whose processing capacity is greater than the transaction arrival rate;

[0241] The fourth determination module is used to complete the judgment of all shards and determine the global load status of the shard system according to the judgment results.

[0242] Furthermore, the first determining unit 1202 for determining the shard range involved in the load migration is specifically configured to determine the shard range involved in the load migration according to the global load model, busy shards, and idle shards.

[0243] Furthermore, the generating unit 1204 for generating the load balancing strategy includes:

[0244] A fifth determination module, configured to determine, for each busy shard of the shard system, a load state corresponding to the busy shard through the global load state;

[0245] The sixth determination module is used to maintain the priority queue and determine the number of unspent transaction outputs to be migrated out according to the shard load offset, the proportional coefficient and the load status corresponding to the busy shard;

[0246] The third acquisition module is used to obtain the transactions in the priority queue that have the highest probability of being spent in the next epoch;

[0247] The seventh determination module is used to select the destination shard for migration of the exchange with the highest probability of being spent through the balancing shard, and return to execute the step of determining the load state corresponding to the busy shard through the global load state of the shard system, until the shard range and destination shard involved in the load migration of all busy shards of the shard system are obtained, so as to complete the process of generating a load balancing strategy.

[0248] Further, the second determining unit 1203 includes:

[0249] An eighth determination module, used to determine a list of unspent transaction outputs to be migrated based on a pre-built prediction model and load offset;

[0250] The ninth determination module is used to determine the destination shard involved in the load migration from the list of unspent transaction outputs to be migrated through a preset destination shard calculation formula; wherein the preset destination shard calculation formula is determined by the edge set, constant, proportional coefficient, load offset, average access probability of the shard in the epoch, and average access probability of the idle shard sequence in the epoch.

[0251] Furthermore, the load migration unit 1205 includes:

[0252] The second construction module is used to construct the metadata of the unspent transaction output set migrated out of the nodes in the source shard through a hash function;

[0253] A submission module, used to submit the cross-shard control transaction of the source shard and the destination shard to the destination shard; the cross-shard control transaction includes at least a checkpoint of the block number and metadata;

[0254] A verification module is used to transmit the metadata to the destination shard through the source shard and verify the transmission process to complete the load migration process; the verification is performed on the response of the source shard based on the metadata and the cross-shard transaction form of the destination shard.

[0255] Furthermore, the second determination unit 1203 of the constructed prediction model includes:

[0256] The fourth acquisition module is used to obtain the amount, age, address activity and transaction history information of each unspent transaction output; wherein the amount is used to indicate the amount of the unspent transaction output; the age is used to indicate the time from the creation to the spending of the unspent transaction output; the address activity is quantified by calculating the number of transactions involved in the address;

[0257] The third building block is used to build a prediction model based on the amount, age, address activity and transaction history information of unspent transaction outputs.

[0258] In the embodiment of the present application, a global load model is established by counting the operation data of the sharding system, and the global load of the sharding system is described by the load model to obtain the global load status of the sharding system. Based on the global load status, the sharding range and the target sharding involved in the load migration of all busy shards, a load balancing strategy is generated, and load migration is performed according to the load balancing strategy and the load migration protocol verified on the chain in combination with the off-chain migration load, so as to achieve the purpose of load balancing of the sharding system under the balanced sharding blockchain. In addition, load migration is performed according to the load balancing strategy and the load migration protocol verified on the chain in combination with the off-chain migration load, so as to ensure the integrity and correctness of data transmission during the load migration process.

[0259] An embodiment of the present application also provides a storage medium, which includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the load balancing method of the blockchain sharding model as described above.

[0260] The present application also provides an electronic device, whose structural diagram is as follows: Fig.13 As shown, it specifically includes a memory 1301 and one or more instructions 1302, wherein the one or more instructions 1302 are stored in the memory 1301 and are configured to be executed by one or more processors 1303 to execute the one or more instructions 1302 to execute the load balancing method of the above-mentioned blockchain sharding model.

[0261] It should be noted that the embodiments of the present invention can be implemented by hardware, software, or a combination of software and hardware. The hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. It can be understood by a person of ordinary skill in the art that the above-mentioned devices and methods can be implemented using computer executable instructions and / or contained in a processor control code, such as a carrier medium such as a disk, CD or DVD-ROM, a programmable memory such as a read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. Such code is provided on the carrier medium. The device and its modules of the present invention can be implemented by hardware circuits such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, etc., or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., can also be implemented by software executed by various types of processors, and can also be implemented by a combination of the above-mentioned hardware circuits and software, such as firmware.

[0262] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principle of the present invention should be covered by the protection scope of the present invention.

[0263] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0264] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0265] The steps in the methods of the embodiments of the present application can be adjusted in order, combined, and deleted according to actual needs.

[0266] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.

[0267] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

[0268] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A load balancing method for a blockchain sharding model, characterized in that: The method comprises: The sharding system is divided into states through the pre-built global load model to obtain the busy shards and global load states of the sharding system; For each busy shard, obtain the load offset corresponding to the busy shard through the global load model, and determine the shard range involved in the load migration; According to the pre-built prediction model and the load offset, the destination shard involved in the load migration is determined, and the step of obtaining the load offset corresponding to the busy shard through the global load model and determining the shard range involved in the load migration is returned to execute, until the shard range and destination shard involved in the load migration of all busy shards in the shard system are obtained; Generate a load balancing strategy according to the shard range, the destination shard and the global load status involved in the load migration of all busy shards; Perform load migration according to the load balancing strategy and load migration protocol; wherein the load migration protocol is a load migration protocol that combines off-chain migration with on-chain verification; The step of determining the destination shard involved in the load migration according to the pre-built prediction model and the load offset includes: Determine a list of unspent transaction outputs to be migrated based on a pre-built prediction model and the load offset; Determine the destination shard involved in the load migration from the list of unspent transaction outputs to be migrated by using a preset destination shard calculation formula; wherein the preset destination shard calculation formula is determined by the edge set, constant, proportional coefficient, load offset, average access probability of shards in an epoch, and average access probability of idle shard sequences in an epoch. The process of building a predictive model includes: For each unspent transaction output, the amount, age, address activity and transaction history information of the unspent transaction output are obtained; wherein the amount is used to indicate the amount of the unspent transaction output; the age is used to indicate the time from the creation to the spending of the unspent transaction output; the address activity is quantified by calculating the number of transactions involved in the address; A prediction model is constructed based on the amount, age, address activity and transaction history information of the unspent transaction output.

2. The method according to claim 1, characterized in that The process of building a global load model includes: Obtaining the operation data of the sharding system; wherein the operation data of the sharding system includes at least the average number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor, and the corrected communication transmission error factor; A global load model is constructed by the average number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor and the corrected communication transmission error factor.

3. The method according to claim 1, characterized in that: The sharding system is divided into states by using the pre-built global load model to obtain the busy shards and global load states of the sharding system, including: Through the pre-built global load model, the average number of transactions received per second in the current shard of the sharding system, the average hash value of the current shard, the corrected statistical error factor, the corrected communication transmission error factor, the average number of transactions contained in the generated blocks, and the difficulty parameter of the proof of work problem are obtained; For all shards, determine the range of the ratio of the average number of transactions received per second in the current shard to the average hash value of the current shard; If the ratio is within a first defined range, the shard corresponding to the ratio within the first defined range is determined as a busy shard of the shard system; wherein the first defined range is determined by the average value of the number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, and the corrected statistical error factor; the busy shard is a shard whose processing capacity cannot meet the transaction arrival rate; If the ratio is within a second defined range, the shard corresponding to the ratio within the second defined range is determined as a balanced shard of the sharding system; wherein the second defined range is determined by the average value of the number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, the corrected statistical error factor, and the corrected communication transmission error factor; the balanced shard is a shard whose processing capacity matches the transaction arrival rate; If the ratio is within a third defined range, the shard corresponding to the ratio within the third defined range is determined as an idle shard of the shard system; wherein the third defined range is determined by the average value of the number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, and the corrected communication transmission error factor; the idle shard is a shard whose processing capacity is greater than the transaction arrival rate; This continues until all shards have been judged, and the global load status of the shard system is determined based on the judgment results.

4. The method according to claim 3, characterized in that The process of determining the shard range involved in load migration includes: A shard range involved in load migration is determined according to the global load model, the busy shards, and the idle shards.

5. The method according to claim 3, characterized in that: The process of generating a load balancing policy includes: For each busy shard of the shard system, determine the load state corresponding to the busy shard through the global load state; Maintaining a priority queue and determining the number of unspent transaction outputs to migrate out based on the shard load offset, the scaling factor, and the load status corresponding to the busy shard; Get the transaction in the priority queue that has the highest probability of being spent in the next epoch; The target shard for migrating the transaction with the highest probability of being spent is selected through the balancing shard, and the step of returning to execute the global load state of the shard system and determining the load state corresponding to the busy shard is performed until the shard range and target shard involved in the load migration of all busy shards of the shard system are obtained, so as to complete the process of generating a load balancing strategy.

6. The method according to claim 1, characterized in that The performing load migration according to the load balancing strategy and the load migration protocol includes: Use the hash function to construct the metadata of the unspent transaction output set that is migrated out of the nodes in the source shard; Submitting the cross-shard control transaction of the source shard and the destination shard to the destination shard; the cross-shard control transaction includes at least a checkpoint of a block number and metadata; The metadata is transmitted to the destination shard through the source shard, and the transmission process is verified to complete the load migration process; the verification is performed by the source shard based on the metadata and the response of the destination shard in the form of a cross-shard transaction.

7. A load balancing device for a blockchain sharding model, characterized in that: The device comprises: A partitioning unit is used to partition the state of the sharding system by using a pre-built global load model to obtain the busy shards and global load state of the sharding system; A first determining unit is used to obtain, for each busy slice, a load offset corresponding to the busy slice through the global load model, and determine a slice range involved in the load migration; A second determination unit is used to determine the destination shard involved in the load migration according to the pre-built prediction model and the load offset, and return to execute the step of obtaining the load offset corresponding to the busy shard through the global load model and determining the shard range involved in the load migration, until the shard range and destination shard involved in the load migration of all busy shards in the shard system are obtained; A generating unit, configured to generate a load balancing strategy according to the shard range, the destination shard and the global load state involved in the load migration of all busy shards; A load migration unit, configured to perform load migration according to the load balancing strategy and the load migration protocol; wherein the load migration protocol is a load migration protocol combining off-chain migration with on-chain verification; Wherein, the second determining unit includes: An eighth determination module, configured to determine a list of unspent transaction outputs to be migrated based on a pre-built prediction model and the load offset; A ninth determination module, configured to determine the destination shard involved in the load migration from the list of unspent transaction outputs to be migrated by using a preset destination shard calculation formula; wherein the preset destination shard calculation formula is determined by the edge set owned by the idle shard, a constant, a proportional coefficient, the load offset, the average access probability of the shard in the epoch, and the average access probability of the idle shard sequence in the epoch; The second determination unit of the constructed prediction model includes: The fourth acquisition module is used to acquire the amount, age, address activity and transaction history information of each unspent transaction output; wherein the amount is used to indicate the amount of the unspent transaction output; the age is used to indicate the time from the creation to the spending of the unspent transaction output; the address activity is quantified by calculating the number of transactions involved in the address; The third building module is used to build a prediction model according to the amount, age, address activity and transaction history information of the unspent transaction output.

8. The device according to claim 7, characterized in that The division units for building the global load model include: A first acquisition module is used to acquire the operation data of the sharding system; wherein the operation data of the sharding system at least includes the average number of transactions contained in the generated blocks, the difficulty parameter of the proof of work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor, and the corrected communication transmission error factor; The first construction module is used to construct a global load model through the average number of transactions contained in the generated blocks, the difficulty parameter of the proof-of-work problem, the average number of transactions received per second in the current shard, the average hash rate of the current shard, the corrected statistical error factor and the corrected communication transmission error factor.