Fragmented block chain state distribution method

By predicting the system state through the LSTM-PPO model and combining it with the adaptive local migration method, the problems of long global allocation time and slow convergence in sharded blockchain state allocation are solved, and fast and accurate shard load balancing and low cross-shard transaction rate are achieved.

CN120743549AActive Publication Date: 2025-10-03HEBEI UNIVERSITY
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511211527.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-28
Publication Date
2025-10-03
Estimated Expiration
2045-08-28

AI Technical Summary

Technical Problem

The global allocation of existing sharded blockchain state allocation methods takes a long time to run and converges slowly, and cannot effectively solve the performance bottleneck problem caused by cross-shard transactions.

Method used

A global account allocation method based on LSTM-PPO is adopted, combined with an adaptive local account migration method. The LSTM model is used to predict the future system state and serve as a pre-training step for the PPO method to quickly achieve load balancing between shards and low cross-shard transaction rates.

Benefits of technology

It accelerates the convergence of shard blockchain state distribution, achieves more accurate distribution results, reduces computational complexity, and ensures short-term shard load balancing and low cross-shard transaction rates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120743549A_ABST
    Figure CN120743549A_ABST
Patent Text Reader

Abstract

The invention relates to a fragmented block chain state distribution method, which comprises the following steps of S1, acquiring historical transactions in a fragmented block chain in a reconfiguration stage of the block chain, and constructing a transaction account graph; s2, determining an optimization problem function according to the transaction account graph; s3, establishing an LSTM model; according to the LSTM model and the historical transaction, predicting the state of the active account in each fragmented network at the next moment; s4, according to the prediction state and the optimization problem function of the LSTM model, performing global allocation on the accounts; and S5, after the accounts are globally distributed, cross-fragment transactions are obtained in real time before the reconfiguration stage of the next time of the reconfiguration stage, the candidate fragments of each account and the income of moving to the candidate fragments are determined, and the accounts needing to be migrated and the migration fragments corresponding to the accounts needing to be migrated are determined. According to the method, the LSTM model and the PPO are combined, the accounts are globally allocated under the condition of load balancing, only the accounts in the newly submitted transaction are migrated in the subsequent block chain operation process, and the calculation complexity is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a blockchain state distribution method, in particular to a sharded blockchain state distribution method. Background Art

[0002] Current mainstream blockchain platforms and Ethereum are limited by scalability bottlenecks and performance defects. Their transaction processing efficiency and system throughput are difficult to meet the stringent requirements of high concurrency, elastic expansion and high throughput, which objectively restricts the expansion of this technology into application areas with higher real-time performance and larger business scale.

[0003] Sharding is an effective solution for improving blockchain scalability. Its concept is to divide and conquer all transactions submitted to a blockchain system. However, in practice, the limited performance improvement of sharded blockchains is caused by cross-shard transactions. As the number of shards increases, the number of cross-shard transactions increases significantly, and processing these transactions inevitably incurs expensive communication overhead. To address the performance bottleneck caused by cross-shard transactions, there are two solutions: 1. Designing efficient cross-shard protocols, such as relay schemes and atomic commit protocols, improves the processing efficiency of cross-shard transactions, thereby reducing the user-perceived confirmation latency of cross-shard transactions; 2. Designing a state redistribution algorithm, which fundamentally reduces the number of cross-shard transactions by grouping closely related states into the same shard.

[0004] Currently, relevant technologies are being applied to optimal state allocation in sharded blockchains. For example, CLPA is an account partitioning algorithm that uses community detection. It considers the trade-off between cross-shard transaction rates and shard workload balance as a network partitioning issue. Another example is SPRING, a state placement sharding framework based on deep reinforcement learning. It formulates state placement as a Markov decision process, minimizing the number of cross-shard transactions while ensuring load balance between shards. However, most existing technologies use global account allocation methods based on community detection or neural networks, failing to consider the increasing size of the account set as blocks are generated. This global allocation method suffers from long runtimes and slow convergence. Summary of the Invention

[0005] The purpose of the present invention is to provide a sharded blockchain state allocation method to solve the problem of long running time and slow convergence of the global allocation method in sharded blockchain state allocation.

[0006] The object of the present invention is achieved like this:

[0007] A sharded blockchain state distribution method comprises the following steps:

[0008] S1. During the blockchain reconfiguration phase, historical transactions in the sharded blockchain are obtained and a transaction account graph is constructed, where the vertices of the transaction account graph are account addresses and the edges are relationships between accounts.

[0009] S2. Determine the optimization problem function based on the number of transactions and load in the transaction account graph;

[0010] S3. Build an LSTM model; based on the LSTM model and historical transactions, predict the state of active accounts in each shard network at the next moment; the state includes the number of cross-shard transactions of active accounts, where an active account has reached a preset number of transactions within a preset time period;

[0011] S4. Globally allocate accounts based on the state predicted by the LSTM model and the optimization problem function;

[0012] S5. After the accounts are globally allocated, before the next reconfiguration phase of the current reconfiguration phase, cross-shard transactions are obtained in real time to determine the candidate shards for each account in the cross-shard transactions. The payoff when the account is moved to the candidate shard is calculated, and the account to be migrated and its corresponding migration shard are determined based on the payoff.

[0013] Furthermore, the optimization problem function in step S2 is determined as follows:

[0014] S2-1. Determine the number of cross-shard transactions, the workload caused by intra-shard transactions, and the workload caused by cross-shard transactions based on the transaction account graph.

[0015] S2-2. Calculate the load balance between shards based on the workload caused by intra-shard transactions and the workload caused by cross-shard transactions.

[0016] S2-3. Determine the optimization problem function based on the number of cross-shard transactions and the load balance level.

[0017] Furthermore, the LSTM model includes two LSTM layers, and the LSTM model is pre-trained.

[0018] Furthermore, the specific method of globally distributing the shard status of the account in step S4 is:

[0019] A PPO model is established, comprising a state space, a reward function, and an action space. State information including predicted states and historical transaction data is determined as the state space, a reward function is determined based on an optimization problem function, and accounts are migrated to target shards as the action space. The PPO agent outputs action decisions based on the current state and simulates environmental changes through a state transition function. After completing a preset number of rounds of training, the trained PPO model is used to achieve global allocation of accounts among shards.

[0020] Furthermore, in step S5, the specific method for determining the accounts to be migrated and their corresponding migration shards is:

[0021] S5a-1. Select the shard where the associated accounts in all cross-shard transactions of the target account are located as candidate shards, where the associated accounts are accounts that have cross-shard transactions with the target account;

[0022] S5a-2. The shard with the highest payoff among the candidate shards is selected as the target shard, and the maximum payoff is used as the increment.

[0023] S5a-3. The target shard is used as the source shard. The shard with the highest gain among the candidate shards is used as the new target shard. The maximum gain is added to the increment to update the increment.

[0024] S5a-4. Loop through step S5a-3 until the target account's gains from migrating from the source shard to other candidate shards are all less than or equal to 0, and the updated increment is greater than the migration threshold. The target account is considered the account to be migrated. The source shard corresponding to the point where the gains of all candidate shards are less than or equal to 0 is considered the migration shard.

[0025] The present invention achieves a low cross-shard transaction rate while ensuring load balancing between shards. The optimal state allocation method consists of a global account allocation method based on LSTM-PPO and an adaptive local account migration method. In the global account allocation method, the LSTM model is relied upon to predict the future system state and serves as a pre-training step for the PPO method, which accelerates the convergence of the allocation algorithm and makes the allocation results more accurate. The adaptive local account migration method executes faster and no longer uses all historical data. It is based only on previous account allocation results and newly submitted transactions, reducing the complexity of the calculation and achieving short-term shard load balancing and low cross-shard transaction rates. The global account allocation method and the adaptive local account migration method use periodic two-stage collaborative optimization to perform state allocation, which has advantages over mainstream allocation methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 It is a flow chart of the present invention.

[0027] Figure 2 It is a schematic diagram of the stage of the global allocation of the present invention in the epoch.

[0028] Figure 3 It is the account transaction topology diagram.

[0029] Figure 4 It is a schematic diagram of global account allocation of the present invention.

[0030] Figure 5This is an experimental comparison chart of the present invention and other methods in terms of the number of cross-shard transactions.

[0031] Figure 6 This is an experimental comparison chart of the present invention and other methods in terms of sharding load. DETAILED DESCRIPTION

[0032] like Figure 1 As shown, the present invention will be further described in detail below with reference to the accompanying drawings.

[0033] S1. During the blockchain reconfiguration phase, historical transactions in the sharded blockchain are obtained and a transaction account graph is constructed.

[0034] Among them, the vertices of the transaction account graph are account addresses, and the edges are the relationships between accounts.

[0035] like Figure 2 As shown, in a sharded blockchain, the entire system consists of K W-Shards and one R-Shard. The system consists of three consecutive phases: the node identity setup phase, the transaction block consensus phase, and the reconfiguration phase. During the node identity setup phase, to resist Sybil attacks, blockchain nodes must register their identities before joining the sharded network. They are then assigned to either W-Shard or R-Shard shards based on their PoW difficulty, with R-Shard having a higher PoW difficulty than W-Shard. During the transaction block consensus phase, the W-Shard performs PBFT consensus on the packaged blocks. Consensused blocks are added to the local blockchain, and the block header and transaction hash list are sent to the R-Shard to enable transaction monitoring across each shard. The R-Shard reaches consensus on the account allocation results and sends the consensus results to each shard, completing account and transaction migration. During the reconfiguration phase, global account allocation is performed using the state prediction and PPO of the present invention. The partition results are added to the state block. After consensus is reached, they are sent to each shard, and accounts are migrated and updated.

[0036] like Figure 3 As shown, a transaction account graph is constructed based on the transactions monitored by R-Shard (i.e. historical transactions). , the transaction account graph is an undirected weighted graph, where V represents the account address, , E is the edge associated with the account. Figure 3 The solid lines in the figure represent transactions within a shard, and the dotted lines represent cross-shard transactions. Indicates that the account is involved and accounts Transaction; Account and accounts The sum of the weights of all transactions between The calculation formula is:

[0037]

[0038] in, Indicates the account involved and The transaction set, Indicates the one-to-one side number between accounts in a transaction.

[0039] Historical transactions are transactions from the previous T epochs.

[0040] because It is an undirected graph, and an edge can only connect two accounts. If a transaction has multiple input or output accounts, a single edge cannot represent the relationship between the accounts. Therefore, the solution is to convert transactions into edges with corresponding weights. For example, in a transaction, if the input accounts are a and b, and the output account is c, then the weight of the edge between accounts a and c and the edge between accounts b and c are both 1 / 2. Finally, the weights of the same edges in all transactions are added together. For example, if there are three transactions between accounts a and d, and the weight of the edge between them in each transaction is 1, then the weight of the edge between accounts a and d is 3. Figure 3 The numbers on the middle edge represent the sum of the weights of the associated accounts in the transactions monitored by R-Shard.

[0041] S2. Determine the optimization problem function based on the number of transactions and load in the transaction account graph.

[0042] The final allocation result of the account is determined by express.

[0043]

[0044] Each account a i Can only be allocated to one shard, i.e. .

[0045] Account With account Being assigned to two different shards will generate an additional relay transaction; With account are assigned to the same shard, i.e. , otherwise 0.

[0046] Calculate account allocation results The number of cross-shard transactions caused :

[0047]

[0048] in, Indicates the total number of accounts in the current blockchain.

[0049] The workload of a shard is caused by intra-shard transactions and cross-shard transactions. The workload of processing cross-shard transactions is defined as the workload of processing internal transactions. times, assuming the workload required to process intra-shard transactions is 1, then the workload required to process cross-shard transactions is . It can be calculated based on historical transaction records, that is, the ratio of the average workload of processing cross-shard transactions and internal transactions in the previous epoch.

[0050] For sharding , workload caused by intra-shard transactions for:

[0051]

[0052] Workload caused by cross-shard transactions for:

[0053]

[0054] Therefore, sharding Workload L k for:

[0055]

[0056] Then the account allocation result The resulting load balancing level between shards is expressed as

[0057]

[0058] in, is the average workload of the shard, .

[0059] The goal of state allocation is to allocate closely related accounts to the same shard as much as possible, reduce the number of cross-shard transactions, and ensure a balanced workload between shards. This means finding an account allocation result X that generates the minimum number of cross-shard transactions and the lowest workload. Therefore, the state allocation problem can be formulated as an optimization function:

[0060]

[0061]

[0062]

[0063]

[0064] S3. Build a Long Short-Term Memory (LSTM) model; based on the LSTM model and historical transactions, predict the state of active accounts in each shard network at the next moment.

[0065] The status includes the number of cross-shard transactions of active accounts, and active accounts are accounts whose transaction volume reaches a preset number within a preset time period.

[0066] like Figure 4 As shown, in the LSTM-PPO-based global account allocation algorithm, the global account allocation problem can be viewed as a Markov decision process. Therefore, deep reinforcement learning (DRL) can be used to solve the problem and obtain the optimal policy. Proximal Policy Optimization (PPO), a type of DRL, uses PPO to allocate accounts based on all historical transaction data to obtain the global optimal solution. However, PPO takes a long time to run and cannot be run frequently for long periods of time. In addition, slow convergence is an inevitable issue of PPO. Trial actions may cause the reward to deviate significantly from the optimal value. In particular, they may lead to the migration of inactive accounts, resulting in additional energy consumption. Therefore, this paper proposes a PPO global account allocation algorithm based on predictive perception.

[0067] R-Shard collects historical transactions from the previous T epochs. A two-layer LSTM prediction model is used to predict future system states and is pre-trained offline as the first step in PPO. In a real system, relying on an LSTM model to predict all accounts is extremely time-consuming and inefficient. Therefore, when predicting account transaction counts, only the transaction counts between active accounts and each shard are predicted. Remaining inactive accounts are treated as a whole, referred to as aggregated accounts, and their transaction counts between each shard are predicted as a whole. For example, if accounts a and b are inactive, and the transaction count between account a and shard C is 2 and account b and shard C is 1, then the transaction count between the inactive account and shard C is 3.

[0068] Among them, active accounts can be determined by the weights of the edges in the transaction account graph. Accounts whose total edge weights are greater than the preset weights are determined as active accounts, and the remaining accounts are inactive accounts. The preset weights can be set according to needs.

[0069] The prediction-aware approach involves two LSTM layers to make more accurate predictions for accounts, where each LSTM layer is responsible for The LSTM model is pre-trained. Specifically, it obtains historical transactions, obtains the number of historical accounts and the historical transaction account graph based on the historical transactions, and inputs the number of historical accounts and the historical transaction account graph into the LSTM model for training. The observation vector captures the changing pattern of the relationship between accounts and shards. After recursive updates, the hidden state of the last time step can be regarded as the environment After the second LSTM layer, a fully connected layer and an output layer are used to produce the final prediction. The output layer of this model is the current shard network. The predicted status of active accounts, that is, the number of transactions between active accounts and each shard.

[0070] S4. Globally allocate accounts based on the state predicted by the LSTM model and the optimization problem function.

[0071] The environment of PPO consists of action space, state space and reward function.

[0072] The predicted state and historical transactions output by LSTM are used as the state space s of PPO t :

[0073]

[0074] in, The predicted status of the account output by the LSTM model, including the number of transactions between active accounts and each shard; is the trading account graph obtained at time t, is the set of active accounts counted at time t, is the number of unconfirmed transactions at time t, which can be obtained directly.

[0075] The data obtained at time t includes the data at and before time t. The set of active accounts counted at time t is obtained based on the transaction account graph obtained at time t.

[0076] Action space a t for:

[0077]

[0078] in, .

[0079] The action space of the present invention is a discrete action space, which determines the number of cross-zone transactions of all accounts in the next state and the workload caused by intra-shard transactions.

[0080] The agent is an entity in PPO that can perceive the environment, make decisions and perform actions. The agent expects the optimal allocation of accounts, minimizes the number of cross-shard transactions as much as possible, and ensures the balance of workload between shards. The global reward function r for each t is t (s t ,a t )for:

[0081]

[0082] The state transition function P defines the state of the t Next, after action a t After reaching the new state s t+1 .

[0083] The agent interacts with the environment and obtains a batch of experience data, such as the state s at time t t 、Action a t and reward r t and the state s at the next moment t+1 PPO also includes a policy network and an evaluation network. Data is sampled from the training buffer pool. The evaluation network estimates the value of the state based on the sampled data and updates the evaluation network parameters. The policy network optimizes the evaluation network's output, increasing the probability of selecting high-value actions. During each training round, all accounts to be assigned are evaluated and whether to undergo migration. After each step, the network parameters are updated promptly.

[0084] This method allows for customized training rounds based on actual needs, ultimately outputting a trained model for global account allocation. After account reallocation, the transaction account graph is updated for adaptive account migration into the next epoch.

[0085] S5. After the accounts are globally allocated, before the next reconfiguration phase of the current reconfiguration phase, cross-shard transactions are obtained in real time to determine the candidate shards for each account in the cross-shard transactions. The payoff when the account is moved to the candidate shard is calculated, and the account to be migrated and its corresponding migration shard are determined based on the payoff.

[0086] Get the current transaction, and get the target account based on the current transaction. The shard where the target account is located in the reallocated transaction account graph is the source shard of the target account; the shard where the associated account in the cross-shard transaction is located is used as the candidate shard, and the associated account is the account that has a cross-shard transaction with the target account, that is, , where account a j Yes and account a i Accounts that conduct cross-shard transactions.

[0087] Find the shard with the highest gain among the candidate shards and use it as the target shard. Use the maximum gain as the increment. Then use the target shard as the source shard. Use the remaining candidate shards and the first source shard as candidate shards. Then select the shard with the highest gain from the candidate shards as the target shard. Add the maximum gain to the increment to create the new increment. Repeat the above steps with the target shard as the source shard until a shard is selected as the source shard and the corresponding gains of all candidate shards as target shards are less than or equal to 0. Then determine whether the increment is greater than or equal to the migration threshold. If so, the target account is the account to be migrated, and the corresponding source shard is used as the migration shard. The account is migrated to the migration shard.

[0088] Account Shard from the source Move to other shards Profit for:

[0089]

[0090] in, For account The number of cross-shard transactions in source shard s after leaving source shard s, For account The number of cross-shard transactions in candidate shard t when joining candidate shard t, For account The workload in the source shard s after leaving the source shard s, It is an account The workload in candidate shard t when joining candidate shard t.

[0091] When the account is new, all shards are considered as candidate shards for the account, and a shard with the largest profit is selected as the target shard to be added.

[0092] After migrating the accounts that need to be migrated to the migration shard, the transaction account graph is updated. Afterwards, the newly submitted cross-shard transactions are obtained, and the accounts that need to be migrated and their corresponding migration shards are calculated based on the updated transaction account graph.

[0093] Random is a method for randomly assigning accounts, assigning states based on the last few hexadecimal digits of the address. CPLA, while balancing cross-shard transactions with shard load, designed a lightweight community detection algorithm based on constrained label propagation for global account assignment. SPRING is the first solution to use DRL to solve the state placement problem. During the operation of a sharded blockchain, newly arrived accounts are optimally placed using the PPO algorithm based on their local state within a time window.

[0094] like Figure 5 and Figure 6 As shown, the present invention consistently outperforms other comparison schemes in terms of overall cross-shard transaction control and shard load balancing. The cumulative distribution function curve of the present invention is closest to the left, and the load distribution is more balanced, which is better than the Random, CLPA, and SPRING schemes. It can also be observed from the figure that the longer SPRING runs, the worse its performance in terms of the number of cross-shard transactions; and the load distribution of SPRING is not balanced. This is because the number of new accounts arriving is less than in the initial stage, and the number of cross-shard transactions generated by hot accounts cannot be compensated by the reasonable placement of new accounts. However, the number of cross-shard transactions between different epochs of the present invention fluctuates significantly. This fluctuation is mainly due to the policy design. In each epoch, only newly created accounts are placed in the shards, and existing hot accounts are not dynamically migrated, resulting in local fluctuations. However, overall, the present invention can reduce the number of cross-shard transactions while achieving workload balance between shards.

Claims

1. A sharded blockchain state distribution method, characterized in that: The steps include: S1. During the blockchain reconfiguration phase, historical transactions in the sharded blockchain are obtained and a transaction account graph is constructed, where the vertices of the transaction account graph are account addresses and the edges are relationships between accounts. S2. Determine the optimization problem function based on the number of transactions and load in the transaction account graph; S3. Build an LSTM model; based on the LSTM model and historical transactions, predict the state of active accounts in each shard network at the next moment; the state includes the number of cross-shard transactions of active accounts, where an active account has reached a preset number of transactions within a preset time period; S4. Globally allocate accounts based on the state predicted by the LSTM model and the optimization problem function; S5. After the accounts are globally allocated, obtain cross-shard transactions in real time before the reconfiguration phase of the next epoch of the reconfiguration phase to determine the candidate shards for each account in the cross-shard transaction; Calculate the revenue when the account is moved to the candidate shard, and determine the account to be migrated and the corresponding migration shard based on the revenue.

2. The sharded blockchain state distribution method according to claim 1, characterized in that: The optimization problem function in step S2 is determined as follows: S2-1. Determine the number of cross-shard transactions, the workload caused by intra-shard transactions, and the workload caused by cross-shard transactions based on the transaction account graph. S2-2. Calculate the load balance between shards based on the workload caused by intra-shard transactions and the workload caused by cross-shard transactions. S2-3. Determine the optimization problem function based on the number of cross-shard transactions and the load balance level.

3. The sharded blockchain state distribution method according to claim 1, characterized in that: The LSTM model includes two LSTM layers, and the LSTM model is pre-trained.

4. The sharded blockchain state distribution method according to claim 1, characterized in that: The specific method of globally distributing the shard status of the account in step S4 is: A PPO model is established, comprising a state space, a reward function, and an action space. State information including predicted states and historical transaction data is determined as the state space, a reward function is determined based on an optimization problem function, and accounts are migrated to target shards as the action space. The PPO agent outputs action decisions based on the current state and simulates environmental changes through a state transition function. After completing a preset number of rounds of training, the trained PPO model is used to achieve global allocation of accounts among shards.

5. The sharded blockchain state distribution method according to claim 1, characterized in that: The specific method for determining the accounts to be migrated and their corresponding migration shards in step S5 is: S5a-1. Select the shard where the associated accounts in all cross-shard transactions of the target account are located as candidate shards, where the associated accounts are accounts that have cross-shard transactions with the target account; S5a-2. The shard with the highest payoff among the candidate shards is selected as the target shard, and the maximum payoff is used as the increment. S5a-3. The target shard is used as the source shard. The shard with the highest gain among the candidate shards is used as the new target shard. The maximum gain is added to the increment to update the increment. S5a-4. Loop through step S5a-3 until the target account's gains from migrating from the source shard to other candidate shards are all less than or equal to 0, and the updated increment is greater than the migration threshold. The target account is considered the account to be migrated. The source shard corresponding to the point where the gains of all candidate shards are less than or equal to 0 is considered the migration shard.

Citation Information

Patent Citations

  • Block chain fragmentation method based on account migration and block chain system

    CN116383203A

  • Block chain load balancing method and system based on deep reinforcement learning

    CN119232658A

  • Transaction processing optimization method based on fragmented block chain

    CN119537008A

  • Block chain address allocation method and system based on reinforcement learning

    CN120358240A

  • Apparatus and method for adaptively managing sharded blockchain network based on deep q network

    US20220067063A1