A blockchain transaction packaging method for dependent transactions
By introducing Goodput indicators and Jaya algorithms into the blockchain system, and combining greedy algorithms to optimize transaction packaging, the user service quality problem in dependency transactions is solved, and higher system throughput and user satisfaction are achieved.
Patent Information
- Application Number
- CN202310021189.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-06
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2043-01-06
AI Technical Summary
When existing blockchain systems handle transactions with dependencies, it is difficult to optimize user service quality. The traditional first-in-first-out strategy fails to effectively consider the dependencies between transactions, resulting in user satisfaction being affected.
A transaction packaging method based on Goodput indicator is proposed, combining Jaya algorithm and greedy algorithm to optimize transaction conflict merger and allocation strategy, maximize user service quality and system throughput, and optimize transaction packaging strategy through dependency definition and formula modeling. , and aggregate sub-transactions of the same dependent transaction in the same block for processing.
It improves user service quality and system throughput, reduces the response time of dependent transactions, and enhances the performance of blockchain systems in dependency scenarios.
Smart Images

Figure CN116016235B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of blockchain. Background Art
[0002] Blockchain can be seen as a data storage service that uses a consensus mechanism to ensure that transaction content cannot be tampered with. It is a method of combining data blocks into a specific data structure in a chain-like manner in chronological order. Each data block contains a set of transactions and, based on a P2P network, uses cryptography to securely store simple, chronologically related data that can be verified within the system.
[0003] Mainstream blockchain systems represented by Bitcoin, Ethereum, and Hyperledger Fabric process transactions separately. A client request is considered a transaction, and each transaction is sent to the blockchain network for processing as an independent individual. Therefore, in the case of separate transaction processing, most current research is focused on optimizing the system throughput and increasing the transaction processing rate.
[0004] However, the above process does not apply to transactions with dependencies. For two transactions A and B, if transaction A fails, transaction B will definitely fail. It is said that there is a dependency relationship between A and B and B depends on A. Such a dependency relationship exists in tourism customization services. The failure of air ticket booking service will lead to the failure of any service of hotel booking, scenic spot ticket booking, and car booking, because tourists cannot reach the tourist destination without air tickets, and services such as hotels are meaningless. Transactions with dependencies all belong to the same user. Compared with independent transactions, the above transaction types have user attributes and hierarchical attributes, which also brings new problems, namely the impact of the execution results of the above transaction types on user satisfaction. For example, transaction B depends on transaction A. The successful execution of both transactions A and B is the most satisfactory situation for users, but the success of transaction A and the failure of transaction B and the failure of both transactions A and B are the most unsatisfactory situations for users.
[0005] In the dependency scenario, the user service quality issue is crucial, but few people pay attention to this issue. Transaction packaging is the key to improving user service quality because it directly determines the order of transaction arrangement. The existing First In First Out (FIFO) strategy directly packages transactions into blocks according to the order of transaction arrival, without considering the dependencies between transactions. Existing work has made a series of optimizations to the FIFO strategy. This type of work mainly analyzes the correlation of transactions from the perspective of read-write dependencies, or schedules them based on priority, fairness, etc. Existing work has made a series of optimizations to the FIFO strategy, mainly including the optimization of independent transactions and the optimization of dependent transactions. However, none of them considers the business dependencies between transactions, and it is difficult to solve the problem of user satisfaction in the dependency scenario. Therefore, in the dependency scenario, new requirements are put forward for the blockchain system, requiring the blockchain to take into account the experience of both the system side and the user side. Summary of the invention
[0006] In view of the gap in the research field of blockchain for dependent transactions, a transaction packaging method for dependent transactions is proposed. First, according to the characteristics of dependent transactions, a relevant definition of dependent transactions is given, and based on this definition, an indicator based on Goodput that takes into account both system throughput and user service quality is proposed, and the problem is modeled with the purpose of maximizing the Goodput indicator; then, a transaction packaging method based on Jaya is proposed to address the user service quality problem in the dependent transaction scenario. While optimizing the transaction conflict merger, the algorithm obtains a packaging result that maximizes the Goodput indicator, and optimizes the algorithm from the two aspects of exploration ability and development ability. Finally, in order to solve the problem that the transaction allocation blocks of the FIFO strategy are too dispersed, all sub-transactions of the same dependent transaction are aggregated in the same block for processing, and an allocation strategy based on the greedy algorithm is designed.
[0007] (1) Problem Modeling
[0008] 1.1) Define the dependency relationship and express it using formula (1). Define key transactions and additional transactions based on the dependency relationship. MT represents the dependent transaction, T2→T1, there is a dependency relationship between transaction T1 and transaction T2, and transaction T2 depends on transaction T1, where transaction T1 is the key transaction and transaction T2 is the additional transaction.
[0009]
[0010] 1.2) Define the key transaction set. Assume that there are three transactions T1, T2, and T3. Transaction T1 depends on transaction T2, and transaction T1 depends on transaction T3. Then transaction T1 is said to depend on the transaction set {T2, T3}, and the transaction set {T2, T3} is called the key transaction set of transaction T1, that is, KT = {T2, T3}.
[0011] 1.3) Define the revenue of dependent transactions and calculate it using formula (2). MT represents dependent transactions, KT represents the key transaction set, and a i represents the execution result of transaction i and a i ∈{0,1},r i It represents the expected return of the execution result of the user-defined transaction i.
[0012]
[0013] 1.4) Define the user service quality indicator Utility to represent the user satisfaction and calculate it using formula (3). Among them, Profit(MT) represents the actual profit of the dependent transaction MT, and Profit(MT_ideal) represents the ideal profit of the dependent transaction MT, that is, the sum of the profits of all sub-transactions, which is the most satisfactory situation for users.
[0014]
[0015] 1.5) The Goodput index that takes into account both system throughput and user service quality is defined and calculated using formula (4). Where Set represents the dependent transaction set, throughput(Set) represents the number of successful transactions in the dependent transaction set, Represents all dependent transaction MT in the dependent transaction set i The sum of user service quality, m represents the number of dependent transactions.
[0016]
[0017] 1.6) Taking commodity inventory as the business background, model the user service quality issues that depend on transaction scenarios.
[0018] 1.6.1) Define each independent sub-transaction. Since each independent sub-transaction in the commodity inventory scenario is a buying and selling operation on a certain commodity, a four-tuple T = (x, s, p, f) is used to represent each independent sub-transaction. Among them, x∈{0,1} indicates whether the current transaction T is successful or not. x=0 indicates that the transaction T is successfully executed and can be packaged into a block. x=1 indicates that the transaction T fails to execute and needs to be terminated early. s={s1,s2...s l} represents the number of transactions T buying and selling a set of commodities, where s k =(keyk ,num k ) indicates that the key value is key k The number of goods bought and sold is num k ; p represents the revenue of transaction T, f∈{0,1} represents the identifier of transaction T, f=1 represents transaction T is a key transaction, and f=0 represents transaction T is an additional transaction.
[0019] 1.6.2) Define each dependent transaction as a binary tuple MT = (tSet, KT). Where tSet = {T1, T2...T n} represents the set of all independent sub-transactions under the dependent transaction; KT represents the key transaction set of the dependent transaction MT.
[0020] 1.6.3) Define the inventory status of goods using B = {b1, b2...b h}. Where h represents the total number of products, b i For the key value is key i The current world state of the commodity is b i .
[0021] 1.6.4) Define inventory constraints and express them using formula (5). For inventory constraints, we optimize the original read-write conflict problem based on conflict merging to increase the number of successful transactions. We merge conflicts for transactions that modify the same key value. As long as the total transaction volume is ≤ the current inventory volume of the product, all transactions can be successfully executed.
[0022] ∑T i .x*T i .s k .num k ≤ b k (5)
[0023] 1.6.5) Define dependency constraints and express them using formula (6). Dependency constraints mean that if any transaction in the critical transaction set fails to execute, the execution results of the entire dependent transaction must fail.
[0024]
[0025] 1.6.6) Under the premise of satisfying the inventory constraints and dependency constraints, the problem is modeled with the goal of maximizing the Goodput index and expressed as formula (7).
[0026]
[0027] (2) Use the improved Jaya algorithm to find a transaction packaging strategy that satisfies the problem definition in step (1).
[0028] 2.1) Perform preprocessing operations on the transaction set. In view of the characteristics of dependent transactions: the failure of any transaction in the key transaction set will lead to the failure of the additional transactions associated with it. Based on this characteristic, each key transaction set is compressed, that is, the vectors of all sub-transactions in the key transaction set are compressed into one vector for expression. For example, there are currently 100 dependent transactions, each of which contains 3 key transactions and 2 additional transactions. If the packaging result of each transaction is abstracted into a vector, the dimension of the solution vector is 500. If all key transactions in the key transaction set are compressed into one transaction, it is equivalent to that the packaging strategy of all key transactions only needs one vector expression, and the dimension of the solution vector is 300. By preprocessing the transaction set, the dimension of the solution vector can be reduced, which can improve the efficiency of the metaheuristic algorithm.
[0029] 2.2) Optimize the Jaya algorithm and use the optimized Jaya algorithm to obtain the packaging strategy.
[0030] 2.2.1) Encode the problem. The transaction packaging problem is a discrete problem. The result of each transaction is either packaging or not packaging, that is, the packaging result is a discrete variable. Therefore, a discrete encoding strategy is used to generate individuals of n-dimensional solutions and expressed using formula (8). Where i represents individual k in the contemporary population, t represents the number of iterations, n is the number of transactions after preprocessing, and each individual is an n-dimensional integer vector. X i,t The n-dimensional vector value of individual i in the t-th generation population represents the packaging strategy of n transactions, X j,i,t represents the value of the j-th dimension vector of individual i in the t-th generation population, X j,i,t ∈(0,1) indicates whether the jth transaction is packaged.
[0031] X i,t =(X 1,i,t ,X 2,i,t ...X n,i,t ) (8)
[0032] 2.2.2) Design the fitness function. The fitness function is used to evaluate the quality of individuals. Individuals with greater fitness have better performance. However, the encoding strategy does not meet the feasibility principle, that is, there are some solutions that do not meet the inventory constraints and dependency constraints. The two types of constraints must be processed.
[0033] 2.2.2.1) Define the constraint violation degree G to process the inventory constraint and express it as formula (9). Where k represents the product corresponding to key value k, G k (X i,t ) represents the degree of violation of the constraint of individual X on commodity k, G(X i,t ) is the sum of the individual's violations of all commodity inventory constraints, gk (X i,t ) indicates that the difference between the modified amount and the inventory amount of all successful transactions with the key value k in the current packaging strategy is calculated using formula (10). j Indicates whether the jth transaction is packaged, T j .s k .num k Indicates the modification amount num of the item with key k caused by transaction j k , b k Represents the world state of the inventory of item with key k.
[0034]
[0035]
[0036] 2.2.2.2) Calculate the fitness of the solution according to formula (11). A feasible solution refers to a solution that satisfies the inventory constraint, and an infeasible solution refers to a solution that does not satisfy the inventory constraint. Use Goodput(X i,t ) and -G(X i,t ) represents the fitness of feasible solutions and infeasible solutions.
[0037]
[0038] 2.2.2.3) Design a repair factor to handle dependency constraints. If the current solution violates the dependency constraint, that is, the key transaction fails and the additional transaction succeeds. First try to update the value of the key transaction from failure to success. If the constraint violation degree does not increase, then update the modification. Otherwise, update the value of the additional transaction from success to failure to ensure that the dependency constraint is met.
[0039] 2.2.3) Design the iterative evolution formula of Jaya algorithm and introduce taboo search to improve the development capability of Jaya algorithm.
[0040] 2.2.3.1) The Jaya algorithm iteratively evolves according to formula (12). Compared with the traditional Jaya algorithm, the C() crossover operation is used to replace the addition and subtraction operations in the original formula, and a random individual is introduced to improve the exploration ability of the Jaya algorithm. Among them, r1, r2, r3∈(0,1) are generated random numbers, X best,t-1 and X worst,t-1 are the best solution and the worst solution in the t-1 generation population, respectively, X random,t-1 is an individual randomly selected from the t-1th generation population, and C() is a custom crossover operation. According to formula (13), by calculating the two individuals X i,t-1 and X best,t-1 Perform a crossover operation to generate a temporary new individual X temp, for example, as Figure 3-4 shown. For the j-th dimensional vector of the new individual X temp , each time a random number rand(0,1) between (0,1) is generated. If rand(0,1) < r1, then select X j,i,t-1 to fill X j,temp , otherwise select X j,best,t-1 to fill X j,temp . And so on to calculate formula (12) in the same way.
[0041]
[0042]
[0043] 2.2.3.2) Use tabu search to continue developing the solution obtained in step (2.2.3.1). The relevant rules of tabu search are defined as follows:
[0044] 2.2.3.2.1) Initial solution selection. Starting the tabu search process first requires an initial configuration solution, which is added to the tabu list as the current optimal configuration solution. The purpose of introducing tabu search is to improve the local development ability of the Jaya algorithm. Therefore, the individual with better fitness obtained after evolution according to formula (12) is used as the initial solution of tabu search for further development;
[0045] 2.2.3.2.2) Termination criterion. When the global optimal solution is found or the maximum number of iterations is reached, the tabu search is no longer performed, and the final result is output. Design the termination condition of tabu search when the candidate solution set is an empty set, and there is no need to design the number of iterations;
[0046] 2.2.3.2.3) Neighborhood selection. Explore the solution space through a movement rule with a certain step size, and calculate the benefit of the solutions in the candidate set through an evaluation formula to find a solution with better benefit than the current one. Define the fitness function defined by formula (11) as the benefit of the tabu search solution, and respectively design the neighborhood selection rules for feasible solutions and infeasible solutions according to the design of the fitness function and the characteristics of the transaction packaging problem. At the same time, it is required that each neighborhood solution must satisfy the dependency constraint of formula (6). The specific neighborhood selection rules are as follows:
[0047] A. Neighborhood selection of feasible solutions. If the current solution is a feasible solution, it means that the set of successful transactions selected in the transaction packaging strategy represented by the current solution does not exceed the inventory constraint. The fitness of the feasible solution can be improved by flipping the vector representing the transaction with a value of 0 to 1, which is equivalent to trying to convert a failed transaction into a successful transaction.
[0048] B. Neighborhood selection of infeasible solutions. If the current solution is an infeasible solution, it means that the successful transaction set selected in the transaction packaging strategy represented by the current solution has exceeded the inventory constraint.
[0049] The vector represented by the transaction of 1 is flipped to 0, which is equivalent to reducing the degree of constraint violation by converting a successful transaction attempt into a failed transaction, thereby improving the fitness of the infeasible solution.
[0050] 2.2.3.2.4) Taboo table. A table used to store taboo objects, which is the basic premise for taboo search. The taboo table mainly includes two indicators: taboo objects and taboo length. Among them, taboo objects refer to those changing elements that are forbidden in the taboo table, and taboo length refers to the period during which the taboo object cannot be selected. Since the solution after each search iteration changes only one bit relative to the previous solution, the transaction corresponding to the j-th dimension vector of each flip is added to the taboo table, and a random number period is added to each transaction to represent the taboo length.
[0051] 2.2.3.2.5) Amnesty rule. When all objects are banned, the best banned object can be unbanned, or when unbanning an object will bring a great improvement to the target value, the amnesty rule can also be used.
[0052] (3) Use the greedy algorithm to aggregate transactions to solve the problem of independent sub-transactions being too scattered in dependent transactions. A dependent transaction is a set of independent sub-transactions with a dependency relationship. The order in which each independent sub-transaction arrives in the blockchain is random, but the system packages each transaction in the order in which it arrives. For example, if the system stipulates that the block capacity is 500, the first 500 transactions that arrive first will be packaged into the same block and will be prioritized for subsequent verification. The 500 transactions that arrive later will be packaged into the next block and wait for the previous block to be verified before verifying the current block. Therefore, there will be a problem in the above process, that is, the independent sub-transactions under the dependent transaction will be packaged into multiple different blocks, thereby extending the response time of the entire dependent transaction. Based on this, the block generation mechanism was modified to generate multiple blocks at a time, and the sub-transactions belonging to the same dependent transaction were aggregated and processed in the same block. However, the new block generation mechanism also brings new problems, that is, how to allocate N dependent transactions to M blocks. The greedy algorithm is selected to solve the above problems. When allocating transactions, the constraint of block capacity needs to be considered. It is necessary to ensure that the average response time of dependent transactions is minimized while meeting the block capacity. Therefore, the greedy strategy is to select the dependent transaction with the smallest number of sub-transactions each time and put it into the current block to ensure that the block that can be verified first can accommodate multiple dependent transactions and reduce the number of dependent transactions waiting later. If the remaining capacity of the current block cannot accommodate the entire dependent transaction, the dependent transaction will be placed in the next block. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 is the overall flow chart of the method.
[0054] Figure 2 It is a schematic diagram of the transaction preprocessing operation of this method.
[0055] Figure 3 This is the optimized Jaya algorithm flow chart of this method.
[0056] Figure 4 This is a schematic diagram of the transaction aggregation operation of this method. DETAILED DESCRIPTION
[0057] Experimental environment: The cluster of this experiment consists of 6 identical servers connected by Gigabit Ethernet. 4 machines serve as peer nodes of two organizations, 1 machine is used as a sorting node, and 1 machine is used as a client. All nodes are equipped with 8G memory and Intel Xeon (IceLake) Platinum 8369B processor, and the operating system is Ubuntu20.04.3LTS. The experiment was conducted on the basis of Hyperledger Fabric v1.4, and Hyperledger Caliper (or Caliper) was used as a performance testing tool. Caliper allows users to configure workloads, measure the performance of the blockchain using predefined test cases, and generate reports containing multiple performance indicators such as throughput and transaction latency. Modifications were made based on Caliper so that transactions can carry user-defined attributes such as transaction revenue, and statistics on user satisfaction indicators such as user service quality and average response time.
[0058] Workload: Since it is difficult to simulate the scenario of dependent transactions with current workloads, a custom workload is used to generate dependent transactions. The workload of this experiment is divided into main workload and non-main workload, which are used to randomly generate key transactions and additional transactions of a certain user, respectively. Each transaction will carry custom attributes such as user affiliation, transaction identifier (i.e., whether it is a key transaction), and transaction revenue when submitted. The revenue of key transactions is a random integer between 6-10, and the revenue of additional transactions is a random integer between 1-5. Since transaction utility is the ratio of actual revenue to ideal revenue, the revenue dimension does not affect transaction utility. This experiment is based on commodity inventory and simulates a transaction scenario in which inventory changes are caused by commodity trading. Commodity inventory scenarios are widely used in dependent transactions. The transaction feature of this scenario is that the key values of the read and write sets are the same. This experiment mainly tests the system performance when the transaction read and write sets are the same. In addition to supporting the necessary commodity inventory initialization and query operations, this experiment mainly generates a transaction type that includes the same read and write key values, that is, randomly reads the inventory quantity and performs addition and subtraction operations to simulate the commodity trading process. For all experiments, 1000 transactions are used to initialize the initial state of the product inventory, and the main load randomly generates the user's key transactions, and the non-main load randomly generates the user's additional transactions to simulate the product inventory changes in the transaction-dependent scenario.
[0059] From the perspective of independent transactions, the scale of commodities will affect the throughput in the inventory scenario. The scale of commodities mainly affects the degree of read-write conflict between transactions. The degree of conflict is very different when randomly selecting a commodity as a read-write key value from 1,000 commodities and when selecting from 200 commodities. At the same time, the throughput of independent transactions will also affect the average revenue and average response time of dependent transactions. From the perspective of dependent transactions, the number of concurrent users and sub-transactions per unit time will affect the average response time. Because the more concurrent users and sub-transactions per unit time, the more dispersed the arrival order of sub-transactions, and the less likely they are to be packaged into adjacent blocks. The larger the block spacing of sub-transactions, the longer the average response time of the overall dependent transactions. Secondly, the proportion of key transactions in dependent transactions will affect the overall average revenue. When the read-write conflict is large, the more key transactions there are, the greater the possibility of failure of the key transaction set, and the lower the average revenue of dependent transactions. Based on this, the effects of three factors, namely, commodity scale, concurrent users and sub-transactions, and key transaction proportion, on the Fabric system optimized by the current packaging strategy in terms of system performance and user service quality are studied. Finally, ablation experiments were conducted on three optimization points: transaction preprocessing, taboo search, and transaction aggregation.
[0060] Table 1 Fabric blockchain configuration
[0061] parameter value The maximum number of transactions to generate a block 200 Maximum waiting time for generating a block 2s
[0062] Table 2 Workload configuration
[0063]
[0064] In this implementation method, the basic parameter settings of Fabric and workload are shown in Table 1 and Table 2 respectively. The specific implementation method can be divided into the following steps:
[0065] (1) Initialization. Build a blockchain network, configure the blockchain system and workload according to Table 1 and Table 2, and start the blockchain network.
[0066] (2) Performance testing: Evaluate the impact of three factors, namely, product scale, number of concurrent users and sub-transactions, and key transaction ratio, on the system performance and user service quality of the Fabric system optimized for the current packaging strategy.
[0067] 2.1) Evaluate the impact of commodity scale. The change of commodity scale directly affects the degree of conflict. The smaller the commodity scale, the higher the degree of conflict. Reduce the commodity scale from 1000 to 200 with a step size of 200. The other parameters are the same as Table 1 and Table 2. The system throughput and user service quality before and after the improvement are shown in Table 3 and Table 4 respectively.
[0068] Table 3 The impact of commodity scale on system throughput
[0069] Product scale 1000 800 600 400 200 Fabric System 398 378 344 296 187 Improved Fabric system 444 452 446 412 347
[0070] Table 4 The impact of product scale on user service quality
[0071] Product scale 1000 800 600 400 200 Fabric System 0.69 0.57 0.52 0.48 0.34 Improved Fabric system 0.85 0.84 0.82 0.77 0.72
[0072] Table 3 shows the throughput changes of the system before and after the improvement. The improved Fabric system can maintain a throughput of about 450 when the commodity scale is small, and is slightly higher than Fabric when the conflict is not large. As the conflict gradually increases, the throughput of the improved system will gradually decrease. This is mainly because the number of requests for commodities in the transaction exceeds the inventory of the commodity itself, and illegal situations occur, which need to be terminated in time. For example, when the commodity scale is 200, the throughput of the system before and after the improvement is 187 and 347 respectively, which increases the throughput by 85.6%. Therefore, the improved system guarantees a higher throughput than Fabric through conflict merging technology, and the greater the conflict, the more obvious the effect. Table 4 shows the changes in the user service quality of the system before and after the improvement. Since the throughput is expressed as the number of successful transactions per unit time, the change in throughput has a direct impact on the average revenue. Therefore, as the commodity scale decreases, Fabric's revenue has been decreasing. However, the improved system has always maintained a high user service quality, because the impact of transaction revenue is considered when choosing to terminate the transaction. For example, when the number of products changes from 400 to 200, the system throughput decreases by 36.8% and 15.8% before and after the improvement, and the user service quality decreases by 29.0% and 6.8% respectively. Therefore, even if the throughput decreases significantly, the decrease in user benefits is not obvious.
[0073] 2.2) Evaluate the impact of concurrent users and sub-transactions. The concurrent users and sub-transactions directly affect the order of sub-transactions. The larger the above two parameters are, the longer the average response time of the overall dependent transactions will be. The number of sub-transactions is set to 5 and 10 respectively, and the number of concurrent users is changed from 100 to 300 with a step size of 50 under different numbers of sub-transactions. Other parameters are the same as Table 1 and Table 2. Table 5 and Table 6 show the changes in the average response time of the system before and after the improvement when the number of sub-transactions is 5 and 10 respectively.
[0074] Table 5 The impact of concurrent users on average response time when the number of sub-transactions is 5
[0075] Concurrent users 100 150 200 250 300 Fabric System 4.21 4.84 5.45 6.34 6.65 Improved Fabric system 3.26 3.34 3.84 4.62 5.23
[0076] Table 6 The impact of concurrent users on average response time when the number of sub-transactions is 10
[0077] Concurrent users 100 150 200 250 300 Fabric System 4.94 5.84 6.92 7.73 8.53 Improved Fabric system 3.62 4.03 4.62 5.54 7.04
[0078] The changes in Tables 5 and 6 show that with the increase in the number of concurrent users, the average response time of the system before and after the improvement is also gradually increasing. However, the response time of the improved system is much lower than that of Fabric. This is because Fabric's sorting strategy does not take into account the user ownership of the transaction, resulting in the sub-transactions being scattered in blocks far apart. The transaction aggregation operation of the improved system allows dependent transactions to be completely packaged into the same block, reducing the dispersion of processing in the verification phase. Table 5 shows that when the number of sub-transactions is 5 and the number of concurrent users is 100, the average response time of the system before and after the improvement is 4.21 and 3.26 respectively, reducing the response time by 22.6%. Table 6 shows that when the number of sub-transactions is 10 and the number of concurrent users is 100, the average response time of the system before and after the improvement is 4.94 and 3.62 respectively, reducing the response time by 26.7%. Therefore, the impact of the increase in the number of sub-transactions and the number of concurrent users on the system is reflected in the increased possibility of decentralized arrival of transactions, but the transaction aggregation operation of the improved system ensures a lower average response time.
[0079] 2.3) Evaluate the impact of the critical transaction ratio. The critical transaction ratio directly affects the user service quality. In the case of large conflicts, the higher the critical transaction ratio, the greater the possibility of failure of the critical transaction set, and the lower the user service quality. The ratio of critical transactions in dependent transactions is modified to 1:4, 2:3, 3:2, and 4:1 respectively, and the other parameters are the same as Table 1 and Table 2. Table 7 shows the changes in user service quality of the three systems under the influence of different critical transaction ratios.
[0080] Table 7 Impact of key transaction ratio on user service quality
[0081] Key transaction ratio 1:4 2:3 3:2 4:1 Fabric System 0.51 0.48 0.38 0.26 Improved Fabric system 0.79 0.77 0.65 0.48
[0082] Table 7 shows that when the critical transaction ratio is 4:1, the user service quality of the system before and after the improvement is 0.26 and 0.48 respectively, and the user service quality has increased by 84.4%. The reason is that Fabric's sorting strategy does not consider the impact of the transaction benefits and transaction attributes of sub-transactions on the user service quality. The improved system considers the user service quality factor when choosing to terminate the transaction, so the user service quality obtained is much higher than Fabric. However, the increase in the critical transaction ratio will also have the same impact on the improved system, so when the critical transaction ratio is 4:1, a significant decline can be seen.
[0083] Finally, it should be noted that the above examples are only used to illustrate and not to limit the described technology, and all technical solutions and improvements that do not deviate from the spirit and scope of the invention should be included in the scope of the claims.
Claims
1. A blockchain transaction packaging method for dependent transactions, characterized by: (1) According to the characteristics of dependent transactions, a Goodput-based indicator that takes into account both system requirements and user requirements is proposed, and the user service quality problem in the dependent transaction scenario is modeled; (2) The block generation mechanism was modified, and a transaction packaging method based on Jaya was proposed. While optimizing the transaction conflict merging, a packaging result that maximizes the Goodput index was obtained, and the method was optimized; (3) To address the problem of over-dispersed transaction allocation blocks in the FIFO strategy, all sub-transactions of the same user are aggregated into the same block for processing, and a greedy allocation strategy is designed; (1) Problem Modeling 1.1) Define the dependency relationship and express it using formula (1); define key transactions and additional transactions based on the dependency relationship; where MT represents the dependent transaction, T2→T1, there is a dependency relationship between transaction T1 and transaction T2, and transaction T2 depends on transaction T1, where transaction T1 is the key transaction and transaction T2 is the additional transaction; MT={T1,T2|T2→T1} (1) 1.2) Define the key transaction set; Assume that there are three transactions T1, T2, and T3. Transaction T1 depends on transaction T2, and transaction T1 depends on transaction T3. Then transaction T1 is said to depend on the transaction set {T2, T3}, and the transaction set {T2, T3} is called the key transaction set of transaction T1, that is, KT = {T2, T3}; 1.3) Define the revenue of dependent transactions and calculate it using formula (2); where MT represents dependent transactions, KT represents the key transaction set, and a i represents the execution result of transaction i and a i ∈{0, 1}, r i It represents the expected return of the execution result of the user-defined transaction i; 1.4) Define the user service quality indicator Utility to represent the user satisfaction and calculate it using formula (3); where Profit(MT) represents the actual profit of the dependent transaction MT, and Profit(MT_ideal) represents the ideal profit of the dependent transaction MT, that is, the sum of the profits of all sub-transactions, which is the most satisfactory situation for users; 1.5) The Goodput index that takes into account both system throughput and user service quality is defined and calculated using formula (4); where Set represents the dependent transaction set, throughput(Set) represents the number of successful transactions in the dependent transaction set, Represents all dependent transaction MT in the dependent transaction set i The sum of user service quality, m represents the number of dependent transactions; 1.6) Taking commodity inventory as the business background, model the user service quality issues that depend on transaction scenarios; 1.6.1) Define each independent sub-transaction; Since each independent sub-transaction in the commodity inventory scenario is a purchase and sale operation of a certain commodity, a four-tuple T = (x, s, p, f) is used to represent each independent sub-transaction; where x∈{0, 1} represents whether the current transaction T is successful or not, x=1 means that the transaction T is successfully executed and can be packaged into a block, and x=0 means that the transaction T fails to execute and needs to be terminated early; s = {s1, s2...s l} represents the number of transactions T buying and selling a set of commodities, where s k =(key k , num k ) indicates that the key value is key k The number of goods bought and sold is num k ; p represents the revenue of transaction T, f∈{0,1} represents the identifier of transaction T, f=1 represents that transaction T is a key transaction, and f=0 represents that transaction T is an additional transaction; 1.6.2) Define each dependent transaction as a tuple MT = (tSet, KT); where tSet = {T1, T2...T n} represents the set of all independent sub-transactions under the dependent transaction; KT represents the key transaction set of the dependent transaction MT; 1.6.3) Define the inventory status of goods using B = {b1, b2...b h}; where h represents the total number of products, b i For the key value is key i The current world state of the commodity is b i ; 1.6.4) Define inventory constraints and express them using formula (5); for inventory constraints, optimize the original read-write conflict problem based on conflict merging to increase the number of successful transactions; merge conflicts for transactions that modify the same key value. As long as the total transaction volume is ≤ the current inventory volume of the product, all transactions can be successfully executed; ∑T i .x*T i .s k.num k ≤ b k (5) 1.6.5) Define dependency constraints and express them using formula (6); dependency constraints mean that if any transaction in the critical transaction set fails to execute, the execution results of the entire dependent transaction must fail; 1.6.6) Under the premise of satisfying inventory constraints and dependency constraints, the problem is modeled with the goal of maximizing the Goodput index and expressed as formula (7); (2) Use the improved Jaya method to find a transaction packaging strategy that satisfies the problem definition in step (1); 2.1) Perform pre-processing operations on the transaction set; The failure of any transaction in the key transaction set will lead to the failure of the additional transactions associated with it. Based on this feature, each key transaction set is compressed, that is, the vectors of all sub-transactions in the key transaction set are compressed into one vector for expression; 2.2) Optimize the Jaya method and use the optimized Jaya method to obtain the packaging strategy; 2.2.1) Encode the problem; A discrete coding strategy is used to generate individuals of the n-dimensional solution, and it is expressed using formula (8); where i represents individual k in the contemporary population, t represents the number of iterations, n is the number of transactions after preprocessing, and each individual is an n-dimensional integer vector; X i,t The n-dimensional vector value of individual i in the t-th generation population represents the packaging strategy of n transactions, X j,i,t represents the value of the j-th dimension vector of individual i in the t-th generation population, X j,i , t∈(0,1) indicates whether the jth transaction is packaged; X i,t =(X 1,i,t ,X 2,i,t ...X n,i,t ) (8) 2.2.2) Design fitness function; the encoding strategy does not meet the feasibility principle, that is, there are some solutions that do not meet the inventory constraints and dependency constraints, and the two types of constraints must be processed; 2.2.2.1) Define the constraint violation degree G to handle the inventory constraint and express it as formula (9); where, k represents the product corresponding to key value k, G k (X i,t ) represents the degree of violation of the constraint of individual X on commodity k, G(X i,t ) is the sum of the individual's violations of all commodity inventory constraints, g k (X i,t ) indicates that the difference between the modified amount and the inventory amount of all successful transactions with the key value k in the current packaging strategy is calculated using formula (10); where X j Indicates whether the jth transaction is packaged, T i .s k .num k Indicates the modification amount num of the item with key k caused by transaction j k , b k The world state representing the inventory of the item with key k; 2.2.2.2) Calculate the fitness of the solution according to formula (11); the feasible solution refers to the solution that satisfies the inventory constraint, and the infeasible solution refers to the solution that does not satisfy the inventory constraint. Use Goodput(X i,t ) and -G(X i,t ) represents the fitness of feasible solutions and infeasible solutions; 2.2.2.3) Design a repair factor to handle dependency constraints; if the current solution violates the dependency constraint, that is, the key transaction fails and the additional transaction succeeds; first try to update the value of the key transaction from failure to success. If the constraint violation degree does not increase, then update and modify it. Otherwise, update the value of the additional transaction from success to failure to ensure that the dependency constraint is met; 2.2.3) Design the iterative evolution formula of Jaya method and introduce taboo search to improve the development capability of Jaya method; 2.2.3.1) The Jaya method iteratively evolves according to formula (12); compared with the traditional Jaya method, the C() crossover operation is used to replace the addition and subtraction operations in the original formula, and a random individual is introduced to improve the exploration ability of the Jaya method; where r1, r2, r3∈(0, 1) are generated random numbers, X best,t-1 and X worst,t-1 are the best solution and the worst solution in the t-1 generation population, respectively, X random,t-1 is an individual randomly selected from the t-1 generation population, and C() is a custom crossover operation; According to formula (13), by calculating the two individuals X i,t-1 and X best,t-1 Perform a crossover operation to generate a temporary new individual X temp ; For the new individual X temp The j-th dimension vector of , generates a random number rand(0,1) between (0,1) each time, if rand(0,1)<r1, then select X j,i,t-1 Fill X j,temp , otherwise select X j,best,t-1 Fill X j,temp ; Calculate formula (12) in the same way; 2.2.3.2) Use tabu search to continue developing the solution obtained in step (2.2.3.1); the relevant rules of tabu search are defined as follows: 2.2.3.2.1) Initial solution selection: To start the taboo search process, an initial configuration solution is first required, which is added to the taboo table as the current optimal configuration solution. The purpose of introducing the taboo search is to improve the local development capability of the Jaya method. Therefore, the individual with better fitness obtained after evolution according to formula (12) is used as the initial solution of the taboo search. 2.2.3.2.2) Termination criteria: When the global optimal solution is found or the maximum number of iterations is reached, the taboo search is no longer performed and the final result is output; the termination condition of the taboo search is designed when the candidate solution is an empty set; 2.2.3.2.3) Neighborhood selection: The fitness function defined by formula (11) is used as the benefit of the taboo search solution. According to the design of the fitness function and the characteristics of the transaction packaging problem, the neighborhood selection rules for feasible solutions and infeasible solutions are designed respectively. At the same time, each neighborhood solution must satisfy the dependency constraint of formula (6). The specific neighborhood selection rules are as follows: A. Neighborhood selection of feasible solutions; if the current solution is a feasible solution, it means that the set of successful transactions selected in the transaction packaging strategy represented by the current solution does not exceed the inventory constraint; the fitness of the feasible solution can be improved by flipping the vector representing the transaction with a value of 0 to 1, which is equivalent to converting a failed transaction attempt into a successful transaction; B. Neighborhood selection of infeasible solutions: If the current solution is an infeasible solution, it means that the set of successful transactions selected in the transaction packaging strategy represented by the current solution has exceeded the inventory constraint. The degree of constraint violation can be reduced by flipping the vector represented by the transaction with a value of 1 to 0, which is equivalent to converting a successful transaction attempt into a failed transaction, thereby improving the fitness of the infeasible solution. 2.2.3.2.4) Taboo table: a table used to store taboo objects, which is the basic premise for taboo search. The taboo table mainly includes two indicators: taboo objects and taboo length. Among them, taboo objects refer to those changing elements that are forbidden in the taboo table, and taboo length refers to the period during which the taboo object cannot be selected. Since the solution after each search iteration changes only one bit relative to the previous solution, the transaction corresponding to the j-th dimension vector of each flip is added to the taboo table, and a random number period is added to each transaction to represent the taboo length. 2.2.3.2.5) Amnesty rule: When all objects are banned, the best banned object can be unbanned, or when unbanning an object will greatly improve the target value, the amnesty rule can also be used; (3) Use the greedy method for transaction aggregation to solve the problem of independent sub-transactions being too scattered in dependent transactions; a dependent transaction is a set of independent sub-transactions with dependencies. The arrival order of each independent sub-transaction in the blockchain is random, but the system packages each transaction according to the arrival order.
