A Sharded Blockchain Transaction Allocation Method Based on WPR Graph Algorithm
Through the sharded blockchain transaction allocation method based on WPR graph algorithm, the problem of unbalanced load and excessive cross-chip transaction ratio in blockchain sharding technology is solved, and the balance of sharded load and system efficiency are improved. Provides a more efficient transaction processing method.
Patent Information
- Application Number
- CN202410988820.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-07-23
AI Technical Summary
The transaction allocation method in the existing blockchain sharding technology leads to unbalanced load and excessive cross-chip transaction ratio, resulting in reduced system efficiency and increased complexity, and lack of effective solutions.
Using the sharded blockchain transaction allocation method based on WPR graph algorithm, the sharded matching degree and queue load calculation are calculated through transaction information, queue load information and macro-time information, so as to achieve balancing of sharded load and controlling cross-chip transaction ratio , reduce algorithm complexity and improve efficiency.
It realizes the control of low algorithm complexity and cross-chip transaction ratio, reduces algorithm overhead, improves load balancing and system efficiency, and reduces transaction processing delays.
Smart Images

Figure CN118524108B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of blockchain sharding, and in particular to a sharded blockchain transaction allocation method based on a WPR graph algorithm. Background Art
[0002] Blockchain is a centralized distributed database technology designed to record and verify digital transactions. It consists of a series of blocks, each of which contains a certain amount of transaction data. These blocks are linked together in chronological order to form an immutable chain of transaction records, hence the name "blockchain". Blockchain does not rely on a central authority or intermediary, but instead maintains and verifies transactions through multiple nodes in the network. Each full node has access to the complete blockchain, which ensures data transparency and security. Once a transaction is added to the blockchain, it cannot be modified or deleted, thus ensuring the immutability and security of the transaction. In addition, it can also be used in many fields such as supply chain management, distributed energy, and the Internet of Things, providing highly reliable transaction records and decentralized management methods.
[0003] Although blockchain technology has great potential, it also faces many challenges, such as performance, data privacy, legal and regulatory issues. Traditional blockchain systems usually have a single shared ledger for the entire network, and each full node needs to process all transactions on the entire blockchain. As the number of blockchain users and transactions increases, this design leads to performance bottlenecks such as reduced transaction processing efficiency and increased latency, limiting the scalability of blockchain. As a solution to improve the performance and scalability of blockchain networks, blockchain sharding technology has emerged, which divides the entire blockchain network into multiple shards, each of which can run independently and process its own transactions. Therefore, each node in the network only needs to process the data of a specific shard, rather than the full amount of data of the entire blockchain, thereby improving the performance and scalability of the blockchain system. The specific working principle of blockchain sharding technology involves three aspects: shard creation, shard operation, and cross-shard interaction: (1) Shard creation determines how the blockchain network creates shards according to certain rules, usually by allocating transactions to different shards based on transaction characteristics or addresses; (2) Shard operation determines the consensus mechanism and transaction processing rules when each shard runs independently, which enables transactions between shards to be processed in parallel, improving overall performance; (3) Cross-shard interaction determines what protocol is used between shards to share data and status during cross-shard interaction to ensure consistency and security.
[0004] The transaction allocation method of sharded blockchain can vary according to different projects and protocols. The current mainstream transaction allocation methods of sharded blockchain mainly include the following:
[0005] 1. Random Sharding: This is one of the simplest ways, where transactions are randomly assigned to different shards. Although this method is simple, it may cause some shards to be overloaded while other shards are underloaded.
[0006] 2. Address-based sharding: This method distributes transactions to different shards based on the addresses involved in the transactions. This ensures that transactions from the same account are assigned to the same shard, thus maintaining a certain degree of data locality.
[0007] 3. Transaction Hash Sharding: This method uses the hash value of the transaction to determine the shard assignment. Typically, the transaction hash is compared with the shard's ID to decide which shard to assign the transaction to.
[0008] 4. Proof of Stake (PoS) Sharding: Some sharded blockchains use the PoS consensus mechanism, where nodes with more tokens or staked more tokens have a higher chance of becoming validators of the shard and can therefore process more transactions. This approach can improve the efficiency of the overall network.
[0009] 5. Sharding by historical transaction records: Some sharding systems allocate transactions to shards based on the characteristics of historical transaction records. For example, transactions are allocated to shards based on transaction timestamps or transaction types.
[0010] However, the current transaction allocation methods of sharded blockchains will lead to varying degrees of load balancing problems and the problem of excessively high cross-shard transaction ratios. On the one hand, the load balancing problem of the transaction allocation method is that the loads of different shards may be uneven, causing some shards to be overloaded while other shards are relatively idle. This not only wastes resources, but also reduces the efficiency and performance of the entire system. On the other hand, the proportion of cross-shard transactions is too high, which means that most transactions need to be transferred between different shards, increasing the complexity of the system and transaction processing time. At present, there is a lack of a universal solution to control the proportion of cross-shard transactions while ensuring load balancing of each shard transaction queue. Summary of the invention
[0011] The purpose of the present invention is to provide a sharded blockchain transaction allocation method based on the WPR graph algorithm, which achieves low cost and solves the problems mentioned in the above background technology.
[0012] To achieve the above objectives, the present invention provides a sharded blockchain transaction allocation method based on the WPR graph algorithm, and the specific steps are as follows:
[0013] S1. The user first writes the basic transaction information and signs to confirm to create the initial transaction. The transaction information includes related transaction information, queue load information and macro timeliness information;
[0014] S2. After receiving the initial transaction created, the relevant verification node will determine whether the transaction has any legality issues, including invalid signature, insufficient balance, double spending and format error;
[0015] S3. If the judgment of S2 is passed, the macro timeliness parameters of the predecessor information and the current transaction network in the relevant transaction information of the transaction are obtained;
[0016] S4. The relevant verification nodes perform shard matching calculation based on the collected transaction information and macro timeliness parameters;
[0017] S5. After completing the shard matching calculation, obtain the current queue information of each shard, including queue length and historical transaction response time;
[0018] S6. The relevant verification node performs shard queue load calculation based on the collected shard queue information;
[0019] S7, sorting the overall fitness of each shard by combining the shard matching degree and the queue load;
[0020] S8. Screen the overall fitness ranking results of each shard to obtain the target shard address;
[0021] S9. After the relevant verification node sends the transaction to the target shard, it will determine whether the transaction is completed normally.
[0022] S10. If the judgment of S9 is passed, the status information of this allocation work will be promptly fed back and updated to the sharded blockchain system.
[0023] Preferably, the status information in step S10 includes additional vectors, response time and basic transaction information.
[0024] Preferably, the specific steps of the macro-timeliness parameter calculation method in step S3 are as follows:
[0025] S31. Determine the time range for transaction statistics, and determine the time of transaction data to be included in the statistics in annual units. The default range is from the beginning of the operation of the transaction network to the present;
[0026] S32. Count the number of citations of transactions in each year within the time range, divide them by year, and simply calculate the total sum;
[0027] S33. Starting from the starting point of the proposed time range, the number of cited transactions is accumulated year by year;
[0028] S34. Each time the data is accumulated, the proportion of the accumulated amount in the total number of cited transactions is calculated;
[0029] S35. Determine whether the current accumulated transaction reference ratio exceeds 50%;
[0030] S36. If the judgment of S35 is passed, then according to the formula Calculate the macro-timeliness parameters, where U is the number of years with a cumulative citation percentage less than and closest to 50%, X is the cumulative citation percentage from the statistical starting point to year U, and Y is the cumulative citation percentage from the statistical starting point to year U+1.
[0031] Preferably, the specific steps of calculating the transaction matching degree in S4 are as follows:
[0032] S41, obtaining a reference transaction list of the target transaction to be allocated, specifically, obtaining timestamp information, additional vector information, in-degree and out-degree information of each transaction in the reference transaction list;
[0033] S42, obtaining the adjacent node information of each referenced transaction, specifically including the in-degree and out-degree information of the adjacent nodes;
[0034] S43. Based on the information obtained from S41 and S42, the formula The reference weight coefficient of each referenced transaction is calculated, where Represents a transaction to be allocated, Represents the reference transaction, represents the in-degree of the transaction to be allocated, represents the out-degree of the transaction to be allocated, The transaction set representing the output of the referenced transaction, represents the in-degree of transactions in the set, Represents the out-degree of transactions in the set;
[0035] S44, obtaining the macroscopic timeliness parameters of the system;
[0036] S45. Based on the information obtained from S41 and S44, the formula The timeliness weight coefficient of each reference transaction is calculated, where t represents the time when the reference transaction occurred. Represents the macro-timeliness parameters of the system;
[0037] S46, based on the data obtained from S43 and S45, the formula Calculate the shard fitness vector of the transaction to be allocated, where is an adjustable hyperparameter, For transactions to be allocated, is the reference transaction set of the transaction to be allocated, For trading The additional vector of For trading The reference weight coefficient is For trading The time weight coefficient of For Sharding The number of internal transactions;
[0038] S47, monitoring the allocation status of the transaction and determining whether it has been placed;
[0039] S48. If the determination in S47 is passed, the additional vector of the target transaction is updated and saved.
[0040] Preferably, the specific steps of the shard queue load calculation method in step S6 are as follows:
[0041] S61, obtaining queue length information of each shard;
[0042] S62. Obtain a response time list of historical transactions of a certain length saved by each shard;
[0043] S63: Based on the historical information obtained in S62, the expected transaction response delay of each shard is estimated using the exponentially weighted moving average method. Based on the queue length information obtained in S61, the vector Hadamard product is further performed to obtain the transaction queue load score of each shard. , is a k-dimensional vector, where k is the number of shards in the system and each dimension represents the queue load score of a shard;
[0044] S64, monitoring the allocation status of the transaction and determining whether it has been placed;
[0045] S65. If the determination in S64 is passed, the response time of the target transaction is updated and saved.
[0046] Therefore, the present invention adopts the above-mentioned sharded blockchain transaction allocation method based on the WPR graph algorithm, which has the following beneficial effects:
[0047] (1) Control the shard queue load and cross-shard transaction ratio through lower algorithm complexity;
[0048] (2) In order to reduce algorithm overhead and the number of cross-shard transactions, the present invention makes an approximate implementation based on the improved PageRank algorithm, and at the same time transfers part of the computational workload to the global system for storage and call, thus avoiding large-scale cyclic updates of the entire transaction network;
[0049] (3) In order to maintain load balance, the present invention takes into account both the real-time queue delay prediction and the queue size, thus ensuring the relative accuracy of the load calculation.
[0050] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 This is the overall framework diagram of the sharded blockchain transaction allocation mechanism of the present invention;
[0052] Figure 2 This is a flowchart of the algorithm for the sharded blockchain transaction allocation mechanism of the present invention;
[0053] Figure 3 This is a flowchart of the calculation of macro-timeliness parameters of the blockchain transaction network of the present invention;
[0054] Figure 4 This is a flow chart of the calculation of the shard matching degree of the present invention;
[0055] Figure 5 This is a flow chart of the queue load calculation of the sharding system of the present invention. DETAILED DESCRIPTION
[0056] Example
[0057] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] Reference Figure 1 The present invention discloses a sharded blockchain transaction allocation method based on the WPR graph algorithm, including user initiating transactions, verification preparation of transaction information, transaction allocation, transaction verification and disk placement, and feedback update. Among them, the user organizes the basic information of the transaction as the initiating node; after the basic verification, the transaction obtains the predecessor transaction information, the load of each shard queue, the macro network timeliness information and waits for algorithm allocation; the user node executes the approximate algorithm based on the WPR graph according to the transaction information to obtain the target shard address; the transaction is sent to the target shard for verification and disk placement; after the allocation is completed, the status information of this allocation is fed back to the blockchain transaction network to keep real-time updates.
[0059] Blockchain transaction network: A large-scale network consisting of all transactions generated by the blockchain system since its operation, each of which represents a completed transaction. In the blockchain system, a transaction can usually have multiple inputs and outputs. The input of each transaction is provided by the previously generated unspent transaction output (UTXO), and the output of each transaction will become one or more UTXOs waiting to be consumed. The reference and spending relationship between transactions constitutes the edges in the network. The nature of the transaction can determine that there will be no circular reference relationship in the entire system, so the entire transaction network is a huge directed acyclic graph.
[0060] Transaction information: Transaction information refers to the necessary information used to serve the transaction allocation algorithm. In the present invention, it specifically includes three parts: relevant transaction information, queue load information, and macro-timeliness information. Relevant transaction information mainly involves the predecessor transaction nodes of the current transaction and their adjacent nodes. This information serves the shard matching degree calculation of the transaction allocation algorithm; queue load information mainly involves the queue length of each current shard, the confirmation time of the previous transaction, etc. This information serves the queue load calculation of the transaction allocation algorithm; macro-timeliness information is a statistical parameter obtained by observing the entire transaction network. It is updated on a larger time scale and mainly serves the shard matching degree calculation of the transaction allocation algorithm.
[0061] State information: State information refers to the information that reveals the local state of the transaction network after the transaction initiated by the user is allocated. It mainly serves the timely update of the local state of the transaction network, including three parts: additional vectors, response time, and basic transaction information. The additional vector is a set of vectors generated and maintained during the allocation and placement of transactions. Each transaction has a corresponding unique vector, which is used to characterize the fitness score between each transaction and each shard. After the placement is completed, the additional vector of the transaction is determined and stored, waiting to participate in the fitness calculation of future new transactions; the response time refers to the time it takes for a transaction to be sent from the target shard to the final placement. Each shard will collect the most recent transaction response time to provide a more accurate queue load calculation; the basic transaction information refers to the inherent information of the transaction itself, such as amount information, signature information, etc.
[0062] like Figure 2 As shown, the specific steps of the overall process are:
[0063] S1: The user first writes the basic transaction information and signs to confirm to create the initial transaction.
[0064] S2: After receiving the initial transaction created, the relevant verification node will determine whether there are any legal issues with the transaction, including invalid signature, insufficient balance, double spending, format error, etc.
[0065] S3: If the judgment of S2 is passed, the transaction precursor information and the macro timeliness parameters of the current transaction network are obtained.
[0066] S4: The relevant verification nodes perform shard matching calculations based on the collected transaction information and parameters.
[0067] S5: After completing the shard matching calculation, obtain the queue information of each current shard, including queue length, historical transaction response time, etc.
[0068] S6: The relevant verification nodes perform shard queue load calculation based on the collected shard queue information.
[0069] S7: Sort the overall fitness of each shard based on the shard matching degree and queue load.
[0070] S8: Filter the overall fitness ranking results to obtain the target shard address.
[0071] S9: After the relevant verification node sends the transaction to the target shard, it will determine whether the transaction-related work is completed normally.
[0072] S10: If the judgment of S9 is passed, the status information of this allocation work will be promptly fed back and updated to the sharded blockchain system.
[0073] like Figure 3 As shown, the specific steps of the method for calculating the macro-timeliness parameters of the trading network in step S3 are as follows:
[0074] S31: Determine the time range for transaction statistics. The time of transaction data to be included in the statistics is determined on an annual basis. The default range is from the beginning of the operation of the transaction network to the present.
[0075] S32: Count the number of citations of transactions in each year within the time range, divide them by year, and simply calculate the total sum.
[0076] S33: Starting from the starting point of the time range prepared in step S31, the transaction citations counted and divided are accumulated year by year.
[0077] S34: Each time the amount is accumulated, the proportion of the accumulated amount in the total number of cited transactions is calculated.
[0078] S35: Determine whether the current accumulated transaction reference ratio exceeds 50%.
[0079] S36: If the judgment of S35 is passed, then according to the formula Calculate the macro-timeliness parameters, where U is the number of years with a cumulative citation percentage less than and closest to 50%, X is the cumulative citation percentage from the statistical starting point to year U, and Y is the cumulative citation percentage from the statistical starting point to year U+1.
[0080] like Figure 4 As shown, the specific steps of the shard matching degree calculation method in step S4 are as follows:
[0081] S41: Obtain a reference transaction list of the target transaction to be allocated, specifically, obtain the timestamp information, additional vector information, in-degree (the number of input transactions) and out-degree (the number of output transactions) information of each transaction in the list.
[0082] S42: Obtain the adjacent node information of each referenced transaction, specifically including the in-degree and out-degree information of the adjacent nodes.
[0083] S43: Based on the information obtained from S41 and S42, the formula The reference weight coefficient of each referenced transaction is calculated, where Represents a transaction to be allocated, Represents the reference transaction, represents the in-degree of the transaction to be allocated, Represents the out-degree of the transaction to be allocated (approximately replaced by the number of addresses of transaction output), The transaction set representing the output of the referenced transaction, represents the in-degree of transactions in the set, Represents the out-degree of the transaction in the collection.
[0084] S44: Obtaining the macroscopic timeliness parameters of the system .
[0085] S45: Based on the information obtained from S41 and S44, the formula The timeliness weight coefficient of each reference transaction is calculated, where t represents the time when the reference transaction occurred (in years from now). Represents the macro-timeliness parameters of the system.
[0086] S46: Based on the data obtained from S43 and S45, the formula Calculate the shard fitness vector of the transaction to be allocated, where is an adjustable hyperparameter, For transactions to be allocated, is the reference transaction set of the transaction to be allocated, For trading The additional vector of For trading The reference weight coefficient is For trading The time weight coefficient of For Sharding The number of internal transactions.
[0087] S47: Monitor the allocation status of the transaction to determine whether it has been placed.
[0088] S48: If the determination of S47 is passed, the additional vector of the target transaction is updated and saved.
[0089] like Figure 5 As shown, the specific steps of the sharding system queue load calculation method in step S6 are as follows:
[0090] S61: Obtain information such as the queue length of each shard.
[0091] S62: Obtain a response time list of historical transactions of a certain length saved by each shard.
[0092] S63: Based on the historical information obtained in S62, use the exponentially weighted moving average method to estimate the expected transaction response delay of each shard , according to the queue length information obtained in step 1 , and further perform the vector Hadamard product to obtain the transaction queue load score of each shard , which is a k-dimensional vector, k is the number of shards in the system, and each dimension represents the queue load score of a shard.
[0093] S64: Monitor the allocation status of the transaction and determine whether it has been placed.
[0094] S65: If the determination in S64 is passed, the response time of the target transaction is updated and saved.
[0095] Therefore, the present invention adopts the above-mentioned sharded blockchain transaction allocation method based on the WPR graph algorithm, realizes the comprehensive control of algorithm efficiency, network efficiency, and load control, directly addresses the pain points and difficulties of transaction allocation in the sharded blockchain system, improves the user experience, and lays a solid foundation for promoting the iterative progress of the transaction allocation algorithm of the sharded blockchain system.
[0096] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.
Claims
1. A sharded blockchain transaction allocation method based on the WPR graph algorithm, characterized in that: The specific steps are as follows: S1. The user first writes the transaction information and signs it to create the initial transaction. The transaction information includes relevant transaction information, queue load information, and macro timeliness information. S2. After receiving the initial transaction created, the relevant verification node determines whether the transaction has any legality issues, including invalid signature, insufficient balance, double spending and format error; S3. If the judgment of S2 is passed, the predecessor information in the transaction information related to the transaction and the macro timeliness parameters of the current transaction network are obtained; The specific steps of the macro-timeliness parameter calculation method are as follows: S31. Determine the time range for transaction statistics, and determine the time of transaction data to be included in the statistics in annual units. The default range is from the beginning of the operation of the transaction network to the present; S32. Count the number of citations of transactions in each year within the time range, divide them by year, and simply calculate the total sum; S33, starting from the starting point of the time range proposed in S31, accumulating the transaction citations counted and divided year by year; S34. Each time the data is accumulated, the proportion of the accumulated amount in the total number of cited transactions is calculated; S35. Determine whether the current accumulated transaction reference ratio exceeds 50%; S36. If the judgment of S35 is passed, then according to the formula Calculate the macro-timeliness parameters, where U is the number of years with a cumulative citation percentage less than and closest to 50%, X is the cumulative citation percentage from the statistical starting point to year U, and Y is the cumulative citation percentage from the statistical starting point to year U+1; S4. The relevant verification nodes perform shard matching calculation based on the collected precursor information and macro timeliness parameters; The specific steps for calculating the shard matching degree are as follows: S41, obtaining a reference transaction list of the target transaction to be allocated, specifically, obtaining timestamp information, additional vector information, in-degree and out-degree information of each transaction in the reference transaction list; S42, obtaining the adjacent node information of each referenced transaction, specifically including the in-degree and out-degree information of the adjacent nodes; S43. Based on the information obtained from S41 and S42, the formula The reference weight coefficient of each referenced transaction is calculated, where Represents a transaction to be allocated, Represents the reference transaction, represents the in-degree of the transaction to be allocated, represents the out-degree of the transaction to be allocated, The transaction set representing the output of the referenced transaction, represents the in-degree of transactions in the set, Represents the out-degree of transactions in the set; S44, obtaining the macroscopic timeliness parameters of the system; S45. Based on the information obtained from S41 and S44, the formula The timeliness weight coefficient of each reference transaction is calculated, where t represents the time when the reference transaction occurred. Represents the macro-timeliness parameters of the system; S46, based on the data obtained from S43 and S45, the formula Calculate the shard fitness vector of the transaction to be allocated, where is an adjustable hyperparameter, For transactions to be allocated, is the reference transaction set of the transaction to be allocated, For trading The additional vector of For trading The reference weight coefficient is For trading The time weight coefficient of For Sharding The number of internal transactions; S47, monitoring the allocation status of the transaction and determining whether it has been placed; S48. If the determination in S47 is passed, the additional vector of the target transaction is updated and saved; S5. After completing the shard matching calculation, obtain the current queue information of each shard, including queue length and historical transaction response time; S6. The relevant verification node performs shard queue load calculation based on the collected shard queue information; The specific steps of the shard queue load calculation method are as follows: S61, obtaining queue length information of each shard; S62. Obtain a response time list of historical transactions of a certain length saved by each shard; S63: Based on the historical information obtained in S62, the expected transaction response delay of each shard is estimated using the exponentially weighted moving average method. Based on the queue length information obtained in S61, the vector Hadamard product is further performed to obtain the transaction queue load score of each shard. , is a k-dimensional vector, where k is the number of shards in the system and each dimension represents the queue load score of a shard; S64, monitoring the allocation status of the transaction and determining whether it has been placed; S65. If the determination in S64 is passed, the response time of the target transaction is updated and saved; S7, sorting the overall fitness of each shard by combining the shard matching degree and the queue load; S8. Screen the overall fitness ranking results of each shard to obtain the target shard address; S9. After the relevant verification node sends the transaction to the target shard, it will determine whether the transaction is completed normally. S10. If the judgment of S9 is passed, the status information of this allocation work will be promptly fed back and updated to the sharded blockchain system.
2. According to claim 1, a sharded blockchain transaction allocation method based on the WPR graph algorithm is characterized in that: The status information in step S10 includes additional vectors, response time and basic transaction information.
