Parallel execution method and device of block chain transaction, electronic equipment and program product

By using the trained dependency prediction model to predict and execute blockchain transactions in parallel, the problem of inefficiency of blockchain nodes when executing transactions is solved and the performance of blockchain is improved.

CN119228377APending Publication Date: 2024-12-31HANGZHOU HIGH-TECH ZONE (BINJIANG) INSTITUTE OF BLOCKCHAIN & DATA SECURITY
View PDF 14 Cites 0 Cited by

Patent Information

Application Number
CN202411755684.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

Existing blockchain nodes use serial execution method when executing blockchain transactions, which is inefficient and has low accuracy in determining dependencies through static analysis, making it difficult to effectively improve blockchain performance.

Method used

The trained dependency prediction model is used to predict the dependency relationship of blockchain transactions, and select the best-performing model for execution in parallel to ensure that transactions with no dependencies can be executed in parallel.

Benefits of technology

It improves the accuracy of blockchain transaction dependency prediction and improves the overall performance of blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119228377A_ABST
    Figure CN119228377A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of block chains, and provides a parallel execution method and device of block chain transactions, electronic equipment and a program product. The block chain transaction parallel execution method comprises the following steps: after a first block is received, selecting a target dependency relationship prediction model from dependency relationship prediction models according to performance parameters of the trained dependency relationship prediction models at the current moment; performing dependency relationship prediction processing on all transactions contained in the first block through a target dependency relationship prediction model to obtain a dependency relationship prediction result of each transaction; and according to the dependency relationship prediction result of each transaction, executing each transaction without the dependency relationship in all transactions in parallel. Through the method provided by the invention, the dependency relationship prediction model with the best performance parameter can be selected in real time to perform dependency relationship prediction processing on the transactions contained in the block, so that the accuracy of predicting the transaction dependency relationship can be improved, and the performance of the block chain is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of blockchain technology, and in particular, relates to a method, device, electronic device and program product for parallel execution of blockchain transactions. Background Art

[0002] At present, when executing each blockchain transaction in a block, each blockchain node usually adopts a serial execution method to ensure the consistency of the execution results. However, the efficiency of serial execution of each blockchain transaction is low, which reduces the performance of the blockchain.

[0003] In order to improve the efficiency of executing blockchain transactions, a common method is to determine the dependencies between various blockchain transactions through static analysis, and then execute the various blockchain transactions without dependencies in parallel. However, the accuracy of the method of determining the dependencies between various blockchain transactions through static analysis is low, and it is difficult to effectively improve the performance of the blockchain. Summary of the invention

[0004] In view of this, the embodiments of the present application provide a method, device, electronic device and program product for parallel execution of blockchain transactions to solve the technical problem of low performance of existing blockchains.

[0005] In a first aspect, an embodiment of the present application provides a method for parallel execution of blockchain transactions, comprising: After receiving the first block, selecting a target dependency prediction model from the dependency prediction models according to the performance parameters of the trained dependency prediction models at the current moment; Performing dependency prediction processing on all transactions included in the first block using the target dependency prediction model to obtain a dependency prediction result for each transaction; According to the dependency prediction result of each of the transactions, transactions without dependency among all the transactions are executed in parallel.

[0006] Optionally, each of the dependency relationship prediction models is trained in the following manner: Obtain a number of second blocks; For each of the second blocks, re-execute the second block, determine the transaction information and dependency information of each transaction included in the second block according to the execution result, and construct a training set corresponding to the second block according to the transaction information and dependency information of each transaction; Each of the dependency relationship prediction models is trained according to the training sets corresponding to each of the second blocks.

[0007] Optionally, each of the dependency prediction models includes a first dependency prediction model, a second dependency prediction model, and a third dependency prediction model; and training each of the dependency prediction models according to the training sets corresponding to each of the second blocks includes: Training a plurality of different initial dependency relationship prediction models using the training sets corresponding to the respective second blocks to obtain a plurality of universal first dependency relationship prediction models; Training a plurality of different initial dependency relationship prediction models using the training set corresponding to the second block belonging to the preset contract type to obtain a plurality of second dependency relationship prediction models, wherein the second dependency relationship prediction models are used to predict dependency relationship information between any two transactions belonging to the preset contract type; By training a number of different initial dependency prediction models using the training set corresponding to the second block generated within a preset time range, a number of the third dependency prediction models are obtained; the third dependency prediction model is used to predict the dependency information between any two transactions generated within the preset time range.

[0008] Optionally, the performance parameters of each dependency prediction model at the current moment are determined in the following manner: Obtaining a number of third blocks received before the current moment; For each of the third blocks, re-execute the third block, determine the transaction information and dependency information of each transaction included in the third block according to the execution result, and construct a test set corresponding to the third block according to the transaction information and dependency information of each transaction; For each of the dependency prediction models, the dependency prediction model is tested according to the test sets corresponding to each of the third blocks, and the performance parameters of the dependency prediction model at the current moment are determined according to the test results.

[0009] Optionally, performing dependency prediction processing on all transactions included in the first block by using the target dependency prediction model to obtain a dependency prediction result for each transaction includes: Dividing all the transactions into a plurality of first transaction combinations, each of the first transaction combinations comprising two transactions; For each of the first transaction combinations, the initiator information, the calling contract address information, the calling contract method information, the method input parameter information and the world state information of the two transactions included in the first transaction combination are input into the target dependency relationship prediction model for dependency relationship prediction processing to obtain the dependency relationship prediction result of the two transactions included in the first transaction combination; According to the dependency prediction results of each of the first transaction combinations, a dependency prediction result of each of the transactions is obtained.

[0010] Optionally, executing in parallel the transactions without dependency among all the transactions according to the dependency prediction result of each of the transactions includes: According to the dependency prediction result of each of the transactions, all the transactions are divided into a plurality of second transaction combinations; each of the second transaction combinations includes at least one transaction, and there is no dependency relationship between the transactions included in different second transaction combinations; The transactions of each of the second transaction combinations are executed in parallel.

[0011] Optionally, after executing in parallel the transactions without dependency among all the transactions according to the dependency prediction result of each of the transactions, the method further includes: Determine each misjudged transaction that is misjudged as not having a dependency relationship among the executed transactions; The misjudged transactions are re-executed in series, and the transaction execution results of the parallel execution and the serial execution are merged.

[0012] In a second aspect, an embodiment of the present application provides a parallel execution device for blockchain transactions, including: A model selection unit, configured to select a target dependency prediction model from each dependency prediction model according to performance parameters of each trained dependency prediction model at a current moment after receiving the first block; A dependency prediction unit, configured to perform dependency prediction processing on all transactions included in the first block by using the target dependency prediction model to obtain a dependency prediction result for each transaction; The parallel execution unit is used to execute in parallel the transactions without dependency among all the transactions according to the dependency prediction result of each transaction.

[0013] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, each step of the parallel execution method of blockchain transactions as described in the first aspect is implemented.

[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the parallel execution method of blockchain transactions as described in the first aspect above are implemented.

[0015] In a fifth aspect, an embodiment of the present application provides a computer program. When the computer program is run on an electronic device, the electronic device executes each step of the parallel execution method of blockchain transactions as described in the first aspect above.

[0016] The parallel execution method, device, electronic device and program product of blockchain transactions provided by the embodiments of the present application have the following beneficial effects: The parallel execution method of blockchain transactions provided by the embodiment of the present application firstly selects a target dependency prediction model from each dependency prediction model according to the performance parameters of each trained dependency prediction model at the current moment after receiving the first block, and then performs dependency prediction processing on all transactions included in the first block through the target dependency prediction model to obtain the dependency prediction result of each transaction, and finally executes all transactions that do not have dependencies in parallel according to the dependency prediction result of each transaction. Through the method of the present application, the dependency prediction model with the best performance parameters can be selected in real time to perform dependency prediction processing on the transactions included in the block, so that the accuracy of predicting transaction dependencies can be improved, thereby improving the performance of the blockchain. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0018] Figure 1 A flowchart of a parallel execution method for blockchain transactions provided in an embodiment of the present application; Figure 2 A schematic diagram of the structure of a parallel execution device for blockchain transactions provided in an embodiment of the present application; Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0019] It should be noted that the terms used in the embodiments of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application. In the description of the embodiments of the present application, unless otherwise specified, "multiple" refers to two or more than two, and "at least one", "one or more" refers to one, two or more. The terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, it is defined that the "first" and "second" features can explicitly or implicitly include one or more of the features.

[0020] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear at different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0021] The parallel execution method of blockchain transactions provided in the embodiments of the present application can be applied to various scenarios where transactions in a block need to be executed in parallel.

[0022] The execution subject of the parallel execution method of blockchain transactions provided in the embodiment of the present application can be, but is not limited to, electronic devices such as mobile phones, tablet computers, laptop computers, and desktop computers. Specifically, the electronic device can be an electronic device corresponding to a certain blockchain node.

[0023] In order to execute blockchain transactions in parallel, the following two methods are commonly used: The first method is to determine the dependencies between various blockchain transactions through static analysis, and then execute the blockchain transactions that do not have dependencies in parallel. However, since the accuracy of static analysis in determining the dependencies between various blockchain transactions is low, it cannot provide a high degree of parallelism and it is difficult to effectively improve the performance of the blockchain.

[0024] The second method is to obtain the actual read-write sets between each blockchain transaction through pre-execution, thereby obtaining the actual dependencies between each blockchain transaction, and then executing each blockchain transaction that has no dependencies in parallel. However, this method requires two execution processes, pre-execution and actual execution, which will cause large delays and it is difficult to effectively improve the performance of the blockchain.

[0025] Based on this, an embodiment of the present application provides a parallel execution method for blockchain transactions. By executing the various steps of the parallel execution method for blockchain transactions provided by the embodiment of the present application through an electronic device, the accuracy of predicting transaction dependencies can be effectively improved, thereby improving the performance of the blockchain.

[0026] See also Figure 1 , Figure 1The flowchart of the implementation method of a parallel execution method of a blockchain transaction provided in an embodiment of the present application is as follows. The parallel execution method of a blockchain transaction provided in an embodiment of the present application may include steps S101 to S103, which are described in detail as follows: In S101, after receiving the first block, a target dependency prediction model is selected from various dependency prediction models according to the performance parameters of various trained dependency prediction models at the current moment.

[0027] In an embodiment of the present application, several trained dependency prediction models can be pre-stored in the electronic device. After receiving the first block, the electronic device can determine the performance parameters of each dependency prediction model at the current moment, and can select a target dependency prediction model from each dependency prediction model based on the performance parameters of each dependency prediction model at the current moment.

[0028] The target dependency prediction model may be a dependency prediction model with the best performance parameters at the current moment.

[0029] In a possible implementation, each dependency relationship prediction model can be trained through steps a to c. The details are as follows: In step a, a plurality of second blocks are obtained.

[0030] In this implementation, the electronic device can obtain several second blocks for training the dependency prediction model.

[0031] In the present application, the second block may be any block that the electronic device has received and has executed before the current moment, and the first block may be a block that the electronic device has received and has not executed at the current moment. Based on this, it can be understood that after the electronic device has completed the execution of each transaction in the first block, the electronic device can use the first block as the second block for training each dependency prediction model.

[0032] In step b, for each second block, the second block is re-executed, and the transaction information and dependency information of each transaction included in the second block are determined according to the execution result, and a training set corresponding to the second block is constructed according to the transaction information and dependency information of each transaction.

[0033] In this implementation, after obtaining several second blocks, the electronic device can re-execute the second block for each second block. After completing the execution of the second block, the electronic device can determine the transaction information and dependency information of each transaction included in the second block based on the execution result of the second block.

[0034] In practical applications, the electronic device can store blockchain world state information, so that the electronic device can re-execute the second block and can determine the transaction information and dependency information of each transaction contained in the second block.

[0035] Among them, the transaction information of any transaction in the second block may include but is not limited to the initiator information of the transaction, the calling contract address information, the calling contract method information, the method input parameter information and the world state information; the dependency information of any transaction in the second block can be used to describe whether there is a dependency relationship between the transaction and other transactions in the second block. Exemplarily, there are a transaction, b transaction and c transaction in the second block, and the dependency information of transaction a is used to describe whether there is a dependency relationship between transaction a and transaction b, and whether there is a dependency relationship between transaction a and transaction c.

[0036] After determining the transaction information and dependency information of each transaction included in the second block, the electronic device may construct a training set corresponding to the second block according to the transaction information and dependency information of each transaction.

[0037] Exemplarily, the electronic device may combine all transactions in the second block in pairs to obtain a number of transaction combinations including two transactions. Afterwards, for each transaction combination, the electronic device uses the transaction information of the two transactions included in the transaction combination and the dependency information used to describe whether there is a dependency between the two transactions as a training set corresponding to the transaction combination, so that the training sets corresponding to all transaction combinations of the second block can be used as a training set corresponding to the second block.

[0038] The above method for constructing a training set is executed for each second block, and the electronic device can obtain a training set corresponding to each second block.

[0039] In step c, each dependency prediction model is trained according to the training set corresponding to each second block.

[0040] In this implementation, after constructing the training sets corresponding to the respective second blocks, the electronic device can train the respective dependency prediction models according to the training sets corresponding to the respective second blocks.

[0041] Specifically, the electronic device can construct feature information based on the transaction information of two transactions in any transaction combination of any second block, and use whether there is a dependency relationship between the two transactions in the transaction combination as marking information, and input the feature information and marking information into each dependency prediction model for training.

[0042] Since in actual applications, blocks are generated at a higher frequency, the electronic device can continuously obtain the second block, so that the electronic device can continuously obtain the training set to train each dependency prediction model, so that each dependency prediction model can be continuously optimized, thereby continuously improving the accuracy of the target dependency prediction model, and then continuously improving the performance of the blockchain. It can be seen that the performance of each dependency prediction model trained by the dependency prediction model training method provided by this implementation is good.

[0043] In addition, in actual applications, after the electronic device executes a block, it can obtain whether any two transactions in the block have a dependency relationship, without the need to manually mark whether any two transactions have a dependency relationship. Based on this, after the electronic device executes a block, it can automatically generate a training set corresponding to the block. Therefore, the training method of the dependency prediction model provided by this implementation is highly convenient.

[0044] In another possible implementation, when training each dependency prediction model according to the training sets corresponding to each second block, it can be implemented through steps d to f, so that multiple dependency prediction models for meeting different needs can be trained. The details are as follows: In step d, several different initial dependency relationship prediction models are trained using the training sets corresponding to the respective second blocks to obtain several universal first dependency relationship prediction models.

[0045] In this implementation, in order to obtain a universal first dependency prediction model, the electronic device may train several different initial dependency prediction models through the training sets corresponding to each second block, thereby obtaining several universal first dependency prediction models.

[0046] It can be understood that the advantage of these first dependency prediction models is their wide range of applicability.

[0047] In step d, a plurality of different initial dependency prediction models are trained using a training set corresponding to a second block of a preset contract type to obtain a plurality of second dependency prediction models.

[0048] In this implementation, the second dependency prediction model can be specifically used to predict the dependency information between any two transactions belonging to the preset contract type. In order to obtain the second dependency prediction model, the electronic device can train several different initial dependency prediction models through the training set corresponding to the second block belonging to the preset contract type, thereby obtaining several second dependency prediction models.

[0049] It can be understood that the advantage of these second dependency prediction models is that they have a high accuracy rate in predicting the dependency between any two transactions belonging to a preset contract type.

[0050] In step f, a plurality of different initial dependency relationship prediction models are trained by using a training set corresponding to the second block generated within a preset time range to obtain a plurality of third dependency relationship prediction models.

[0051] In this implementation, the third dependency prediction model can be specifically used to predict the dependency information between any two transactions generated within a preset time range. In order to obtain the third dependency prediction model, the electronic device can train several different initial dependency prediction models through the training set corresponding to the second block generated within the preset time range, thereby obtaining several third dependency prediction models.

[0052] It can be understood that the advantage of these third dependency relationship prediction models is that they have a high accuracy rate in predicting the dependency relationship information between any two transactions generated within a preset time range.

[0053] It can be seen that the above implementation method obtains various dependency prediction models with different advantages by training different types of training sets, so that a more suitable dependency prediction model can be selected to predict the dependency of the transaction, thereby further improving the accuracy of the dependency prediction model.

[0054] It should be noted that the first dependency prediction model, the second dependency prediction model and the third dependency prediction model described above are only examples and not limitations. Other types of dependency prediction models for actual needs can also be trained according to the methods described in steps e to f.

[0055] The above steps a to f together describe the training process of each dependency prediction model. The following continues to provide an implementation method for selecting a target dependency prediction model from each dependency prediction model.

[0056] In a possible implementation, the electronic device may first determine the performance parameters of each dependency prediction model at the current moment through steps g to i, as described in detail as follows: In step g, a number of third blocks received before the current time are obtained.

[0057] In this implementation, when it is necessary to determine the performance parameters of each dependency prediction model at the current moment, the electronic device can first obtain several third blocks, where the third block can be any block that the electronic device has received and executed at the current moment.

[0058] In the present application, both the second block and the third block can be any block that the electronic device has received and has completed execution at the current moment, and the difference between the second block and the third block is that the second block is used to train the dependency prediction model, and the third block is used to test the dependency prediction model. Based on this, it can be understood that after the electronic device completes the execution of each transaction in the first block, the electronic device can use the first block as the third block to test each dependency prediction model.

[0059] In step h, for each third block, the third block is re-executed, and the transaction information and dependency information of each transaction included in the third block are determined according to the execution result, and a test set corresponding to the third block is constructed according to the transaction information and dependency information of each transaction.

[0060] In this implementation, the specific implementation method of the electronic device constructing a test set corresponding to each third block for each third block can refer to the specific implementation method of constructing a training set corresponding to each second block described in step b, which will not be repeated here.

[0061] After executing step h, the electronic device can construct a test set corresponding to each third block.

[0062] In step i, for each dependency prediction model, the dependency prediction model is tested according to the test sets corresponding to each third block, and the performance parameters of the dependency prediction model at the current moment are determined according to the test results.

[0063] In this implementation, after constructing the test sets corresponding to each third block, the electronic device can test each dependency prediction model according to the test sets corresponding to each third block, and determine the performance parameters of the dependency prediction model at the current moment based on the test results, thereby obtaining the performance parameters of each dependency prediction model at the current moment.

[0064] Exemplarily, the performance parameters of the dependency prediction model at the current moment may include but are not limited to the average block execution time, the maximum block execution time, and the model dependency prediction accuracy. The average block execution time is used to describe the average time required for the dependency prediction model to execute each third block; the maximum block execution time is used to describe the maximum time required for the dependency prediction model to execute each third block; the model dependency prediction accuracy is used to describe the accuracy of the dependency prediction model in predicting the dependencies of each transaction combination in the test set corresponding to each block.

[0065] After determining the performance parameters of each dependency prediction model at the current moment, the electronic device may select a target dependency prediction model from each dependency prediction model according to the performance parameters of each dependency prediction model at the current moment.

[0066] The specific implementation method of the electronic device selecting the target dependency prediction model from each dependency prediction model according to the performance parameters of each dependency prediction model at the current moment can be set according to actual needs. For example, the electronic device can set corresponding weights for each different performance parameter according to the needs of the user, so as to select the target dependency prediction model with the best performance from each dependency prediction model according to the performance parameters of each dependency prediction model at the current moment and the weights corresponding to the performance parameters.

[0067] In a possible implementation, after determining the performance parameters of each dependency prediction model at the current moment, the electronic device may also eliminate some dependency prediction models according to the performance parameters of each dependency prediction model at the current moment.

[0068] Exemplarily, the electronic device may eliminate, from among the dependency prediction models, dependency prediction models whose performance parameters at the current moment are lower than a performance parameter threshold, or, the electronic device may eliminate, based on the average block execution time and / or maximum block execution time of the dependency prediction models, dependency prediction models whose performance parameters at the current moment are less than the average block execution time and / or maximum block execution time of a preset serial execution model.

[0069] Through the above method, some dependency prediction models whose performance parameters at the current moment do not meet the requirements can be eliminated, so that there is no need to train some dependency prediction models whose performance parameters at the current moment do not meet the requirements in the future, and there is no need to determine the performance parameters of these dependency prediction models at the current moment, which can improve the efficiency of selecting target dependency prediction models, and then improve the efficiency of parallel execution of blockchain transactions.

[0070] In S102, dependency prediction processing is performed on all transactions included in the first block using the target dependency prediction model to obtain a dependency prediction result for each transaction.

[0071] In an embodiment of the present application, after receiving the first block and selecting a target dependency prediction model, the electronic device can perform dependency prediction processing on all transactions included in the first block through the target dependency prediction model to obtain a dependency prediction result for each transaction.

[0072] Among them, for each transaction included in the first block, the dependency prediction result of the transaction may include the dependency prediction result between the transaction and other transactions included in each first block.

[0073] Exemplarily, the first block may include transaction a, transaction b, transaction c, transaction d and transaction f, based on which, the dependency prediction result of transaction a may include the dependency prediction result between transaction a and transaction b, the dependency prediction result between transaction a and transaction c, the dependency prediction result between transaction a and transaction d, the dependency prediction result between transaction a and transaction d, and the dependency prediction result between transaction a and transaction f.

[0074] In a possible implementation, the electronic device can obtain the dependency prediction result of each transaction included in the first block through steps j to i, as detailed below: In step j, all transactions are divided into a plurality of first transaction combinations, each of which includes two transactions.

[0075] Exemplarily, the first block may include transaction a, transaction b, transaction c, transaction d and transaction f. Based on this, the first transaction combination may be a transaction combination including transaction a and transaction b, a transaction combination of transaction a and transaction c, a transaction combination of transaction a and transaction d, a transaction combination of transaction a and transaction e, a transaction combination of transaction a and transaction f, a transaction combination of transaction b and transaction c, a transaction combination of transaction b and transaction d, a transaction combination of transaction b and transaction e, a transaction combination of transaction b and transaction f, a transaction combination of transaction c and transaction d, a transaction combination of transaction c and transaction e, a transaction combination of transaction c and transaction f, a transaction combination of transaction d and transaction e, a transaction combination of transaction d and transaction f, and a transaction combination of transaction e and transaction f.

[0076] In step k, for each first transaction combination, the initiator information, calling contract address information, calling contract method information, method input parameter information and world state information of the two transactions included in the first transaction combination are input into the target dependency prediction model for dependency prediction processing to obtain the dependency prediction result of the two transactions included in the first transaction combination.

[0077] In this implementation, the electronic device can, for each first transaction combination, input the initiator information, calling contract address information, calling contract method information, method input parameter information and world state information of the two transactions included in the first transaction combination into the target dependency prediction model for dependency prediction processing, and obtain the dependency prediction results of the two transactions included in the first transaction combination, thereby obtaining the dependency prediction results corresponding to each transaction combination.

[0078] In step i, the dependency prediction result of each transaction is obtained according to the dependency prediction results of each first transaction combination.

[0079] In this implementation, after determining the dependency prediction results corresponding to each transaction combination, the dependency prediction results of each transaction can be obtained according to the dependency prediction results of each first transaction combination.

[0080] Exemplarily, for transaction a, the dependency prediction result of transaction a can be obtained based on the dependency prediction result of the transaction combination of transaction a and transaction b, the dependency prediction result of the transaction combination of transaction a and transaction c, the dependency prediction result of the transaction combination of transaction a and transaction d, the dependency prediction result of the transaction combination of transaction a and transaction e, and the dependency prediction result of the transaction combination of transaction a and transaction f.

[0081] In S103, according to the dependency prediction result of each transaction, all transactions without dependency are executed in parallel.

[0082] In an embodiment of the present application, after obtaining the dependency prediction result of each transaction, the electronic device can execute in parallel all transactions that have no dependency according to the dependency prediction result of each transaction.

[0083] In a possible implementation, the electronic device can predict the result according to the dependency relationship of each transaction through steps m to n, and execute all transactions without dependency relationship in parallel, as described in detail as follows: In step m, all transactions are divided into a plurality of second transaction combinations according to the dependency prediction result of each transaction.

[0084] In this implementation, the electronic device may first predict the result according to the dependency relationship of each transaction and divide all transactions into a plurality of second transaction combinations.

[0085] Exemplarily, the electronic device may classify transactions with dependencies into the same second transaction combination according to the dependency prediction result of each transaction. For example, the first block may include transaction a, transaction b, transaction c, transaction d, and transaction f, and the dependency prediction result of each transaction may be that transaction a has a dependency relationship with transaction b, transaction a has a dependency relationship with transaction c, transaction d has a dependency relationship with transaction f, and no other two transactions have a dependency relationship. Based on this, the electronic device may classify transaction a, transaction b, and transaction c into the same second transaction combination, and classify transaction e and transaction f into another second transaction combination.

[0086] In step n, the transactions of the second transaction combinations are executed in parallel.

[0087] In this implementation, after dividing all transactions into multiple second transaction combinations, the electronic device can execute transactions of each second transaction combination in parallel.

[0088] Exemplarily, after the electronic device groups transaction a, transaction b, and transaction c into the same second transaction combination, and groups transaction e and transaction f into another second transaction combination, the electronic device may execute the two groups of second transaction combinations in parallel. For example, the electronic device may first execute transaction a and transaction e in parallel, then execute transaction b and transaction f in parallel, and then execute transaction c.

[0089] In actual applications, since the dependency prediction results predicted by the target dependency prediction model may have prediction errors, after executing all transactions without dependencies in parallel based on the dependency prediction results of each transaction, the electronic device can also determine the misjudged transactions that were misjudged as not having dependencies among the executed transactions, and re-execute the misjudged transactions in serial. After re-executing the misjudged transactions in serial, the electronic device can also merge the transaction execution results of parallel execution and serial execution to correct the erroneous transaction execution results and obtain the final transaction execution results.

[0090] In addition, after determining the predicted transaction, the target dependency prediction model can be re-optimized based on the information of the misjudged transaction to further improve the accuracy of predicting transaction dependencies and further improve the performance of the blockchain.

[0091] It can be seen from the above that the parallel execution method of blockchain transactions provided by the embodiment of the present application firstly selects the target dependency prediction model from each dependency prediction model according to the performance parameters of each trained dependency prediction model at the current moment after receiving the first block, and then performs dependency prediction processing on all transactions contained in the first block through the target dependency prediction model to obtain the dependency prediction result of each transaction, and finally executes all transactions that do not have dependencies in parallel according to the dependency prediction result of each transaction. Through the method of the present application, the dependency prediction model with the best performance parameters can be selected in real time to perform dependency prediction processing on the transactions contained in the block, so that the accuracy of predicting transaction dependencies can be improved, thereby improving the performance of the blockchain.

[0092] It should be noted that, in actual applications, when the electronic device of the blockchain node has not received a block or has only received the first block, the electronic device cannot train each dependency prediction model, and therefore cannot execute the steps of the parallel execution method of blockchain transactions provided in the embodiment of the present application. Based on this, the electronic device can execute the first received block in series, and after executing the first received block, the electronic device can train each dependency prediction model through the block, so that the parallel execution method of blockchain transactions provided in the embodiment of the present application can be used later.

[0093] Based on the parallel execution method of blockchain transactions provided in the above embodiment, the present application embodiment further provides a parallel execution device for blockchain transactions that implements the above method embodiment. Figure 2 , Figure 2 A schematic diagram of the structure of a parallel execution device for blockchain transactions provided in an embodiment of the present application. Figure 2 As shown, the parallel execution device 20 for blockchain transactions may include: a model selection unit 21, a dependency prediction unit 22, and a parallel execution unit 23. Among them: The model selection unit 21 is used to select a target dependency prediction model from various dependency prediction models according to the performance parameters of each trained dependency prediction model at the current moment after receiving the first block.

[0094] The dependency prediction unit 22 is used to perform dependency prediction processing on all transactions included in the first block through the target dependency prediction model to obtain a dependency prediction result for each transaction.

[0095] The parallel execution unit 23 is used to predict the result according to the dependency relationship of each transaction, and execute in parallel all transactions that have no dependency relationship.

[0096] Optionally, the parallel execution device 20 for blockchain transactions may further include a model training unit. The model training unit is specifically used for: Obtain a number of second blocks; For each second block, re-execute the second block, determine the transaction information and dependency information of each transaction included in the second block according to the execution result, and construct a training set corresponding to the second block according to the transaction information and dependency information of each transaction; Each dependency prediction model is trained according to the training sets corresponding to each second block.

[0097] The model training unit is specifically used for: Training a number of different initial dependency relationship prediction models using the training sets corresponding to the respective second blocks to obtain a number of universal first dependency relationship prediction models; Through the training set corresponding to the second block belonging to the preset contract type, several different initial dependency prediction models are trained to obtain several second dependency prediction models, where the second dependency prediction models are used to predict the dependency information between any two transactions belonging to the preset contract type; By training a number of different initial dependency prediction models using a training set corresponding to a second block generated within a preset time range, a number of third dependency prediction models are obtained; the third dependency prediction model is used to predict dependency information between any two transactions generated within a preset time range.

[0098] Optionally, the model selection unit 21 is further used for: Obtain several third blocks received before the current time; For each third block, re-execute the third block, determine the transaction information and dependency information of each transaction included in the third block according to the execution result, and construct a test set corresponding to the third block according to the transaction information and dependency information of each transaction; For each dependency prediction model, the dependency prediction model is tested according to the test sets corresponding to each third block, and the performance parameters of the dependency prediction model at the current moment are determined according to the test results.

[0099] Optionally, the dependency relationship prediction unit 22 is specifically used for: Dividing all transactions into a plurality of first transaction combinations, each first transaction combination comprising two transactions; For each first transaction combination, the initiator information, the calling contract address information, the calling contract method information, the method input parameter information and the world state information of the two transactions included in the first transaction combination are input into the target dependency prediction model for dependency prediction processing to obtain the dependency prediction result of the two transactions included in the first transaction combination; According to the dependency relationship prediction results of each first transaction combination, the dependency relationship prediction result of each transaction is obtained.

[0100] Optionally, the parallel execution unit 23 is specifically used for: According to the dependency prediction result of each transaction, all transactions are divided into a plurality of second transaction combinations; each second transaction combination includes at least one transaction, and there is no dependency relationship between the transactions included in different second transaction combinations; The transactions of the second transaction combinations are executed in parallel.

[0101] Optionally, the parallel execution unit 23 is further used for: Determine each misjudged transaction that is misjudged as not having a dependency relationship among each executed transaction; Re-execute each misjudged transaction in series and merge the transaction execution results of parallel execution and serial execution.

[0102] See also Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 3 As shown, the electronic device 3 provided in this embodiment may include: a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30, such as a program corresponding to the parallel execution method of blockchain transactions. When the processor 30 executes the computer program 32, the steps in the embodiment of the parallel execution method applied to blockchain transactions are implemented, such as Figure 1 Alternatively, when the processor 30 executes the computer program 32, the functions of each module / unit in the parallel execution device embodiment of the above-mentioned blockchain transaction are realized, for example Figure 2 The functions of units 21 to 23 are shown.

[0103] Exemplarily, the computer program 32 may be divided into one or more modules / units, one or more modules / units are stored in the memory 31 and executed by the processor 30 to complete the present application. One or more modules / units may be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program 32 in the electronic device 3. For example, the computer program 32 may be divided into a model selection unit 21, a dependency prediction unit 22, and a parallel execution unit 23. For the specific functions of each unit, please refer to Figure 2 The relevant descriptions in the corresponding embodiments are not repeated here.

[0104] Those skilled in the art will understand that Figure 3 This is only an example of the electronic device 3 and does not constitute a limitation on the electronic device 3 , which may include more or less components than those shown in the figure, or a combination of certain components, or different components.

[0105] The processor 30 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.

[0106] The memory 31 may be an internal storage unit of the electronic device 3, such as a hard disk or memory of the electronic device 3. The memory 31 may also be an external storage device of the electronic device 3, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, or a flash card, etc., equipped on the electronic device 3. Further, the memory 31 may also include both an internal storage unit and an external storage device of the electronic device 3. The memory 31 is used to store computer programs and other programs and data required by the electronic device. The memory 31 may also be used to temporarily store data that has been output or is to be output.

[0107] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units as needed, that is, the internal structure of the parallel execution device of blockchain transactions can be divided into different functional units to complete all or part of the functions described above. The functional units in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the unit in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0108] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0109] An embodiment of the present application provides a computer program product. When the computer program product is executed on a terminal device, the terminal device implements the steps in the above-mentioned various method embodiments.

[0110] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0111] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0112] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A parallel execution method for blockchain transactions, characterized in that: include: After receiving the first block, selecting a target dependency prediction model from the dependency prediction models according to the performance parameters of the trained dependency prediction models at the current moment; Performing dependency prediction processing on all transactions included in the first block using the target dependency prediction model to obtain a dependency prediction result for each transaction; According to the dependency prediction result of each of the transactions, transactions without dependency among all the transactions are executed in parallel.

2. The method according to claim 1, characterized in that Each of the dependency relationship prediction models is trained in the following manner: Obtain a number of second blocks; For each of the second blocks, re-execute the second block, determine the transaction information and dependency information of each transaction included in the second block according to the execution result, and construct a training set corresponding to the second block according to the transaction information and dependency information of each transaction; Each of the dependency relationship prediction models is trained according to the training sets corresponding to each of the second blocks.

3. The method according to claim 2, characterized in that Each of the dependency prediction models includes a first dependency prediction model, a second dependency prediction model, and a third dependency prediction model; and training each of the dependency prediction models according to the training sets corresponding to each of the second blocks includes: Training a plurality of different initial dependency relationship prediction models using the training sets corresponding to the respective second blocks to obtain a plurality of universal first dependency relationship prediction models; Training a plurality of different initial dependency relationship prediction models using the training set corresponding to the second block belonging to the preset contract type to obtain a plurality of second dependency relationship prediction models, wherein the second dependency relationship prediction models are used to predict dependency relationship information between any two transactions belonging to the preset contract type; By training a number of different initial dependency prediction models using the training set corresponding to the second block generated within a preset time range, a number of the third dependency prediction models are obtained; the third dependency prediction model is used to predict the dependency information between any two transactions generated within the preset time range.

4. The method according to claim 1, characterized in that: The performance parameters of each dependency prediction model at the current moment are determined in the following manner: Obtaining a number of third blocks received before the current moment; For each of the third blocks, re-execute the third block, determine the transaction information and dependency information of each transaction included in the third block according to the execution result, and construct a test set corresponding to the third block according to the transaction information and dependency information of each transaction; For each of the dependency prediction models, the dependency prediction model is tested according to the test sets corresponding to each of the third blocks, and the performance parameters of the dependency prediction model at the current moment are determined according to the test results.

5. The method according to claim 1, characterized in that The step of performing dependency prediction processing on all transactions included in the first block by using the target dependency prediction model to obtain a dependency prediction result for each transaction includes: Dividing all the transactions into a plurality of first transaction combinations, each of the first transaction combinations comprising two transactions; For each of the first transaction combinations, the initiator information, the calling contract address information, the calling contract method information, the method input parameter information and the world state information of the two transactions included in the first transaction combination are input into the target dependency relationship prediction model for dependency relationship prediction processing to obtain the dependency relationship prediction result of the two transactions included in the first transaction combination; According to the dependency prediction results of each of the first transaction combinations, a dependency prediction result of each of the transactions is obtained.

6. The method according to claim 1, characterized in that The step of executing in parallel all transactions without dependencies among all transactions according to the dependency prediction result of each transaction includes: According to the dependency prediction result of each of the transactions, all the transactions are divided into a plurality of second transaction combinations; each of the second transaction combinations includes at least one transaction, and there is no dependency relationship between the transactions included in different second transaction combinations; The transactions of each of the second transaction combinations are executed in parallel.

7. The method according to any one of claims 1 to 6, characterized in that: After executing in parallel the transactions without dependency among all the transactions according to the dependency prediction result of each of the transactions, the method further includes: Determine each misjudged transaction that is misjudged as not having a dependency relationship among the executed transactions; The misjudged transactions are re-executed in series, and the transaction execution results of the parallel execution and the serial execution are merged.

8. A parallel execution device for blockchain transactions, characterized in that: include: A model selection unit, configured to select a target dependency prediction model from each dependency prediction model according to performance parameters of each trained dependency prediction model at a current moment after receiving the first block; A dependency prediction unit, configured to perform dependency prediction processing on all transactions included in the first block by using the target dependency prediction model to obtain a dependency prediction result for each transaction; The parallel execution unit is used to execute in parallel the transactions without dependency among all the transactions according to the dependency prediction result of each transaction.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, each step in the parallel execution method of blockchain transactions as described in any one of claims 1 to 7 is implemented.

10. A computer program product, characterized in that When the computer program is executed by a processor, each step in the parallel execution method of blockchain transactions as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Parallel processing method and device of block chain data, equipment and storage medium

    CN108537543A

  • Method and device for processing blockchain data, equipment and storage medium

    CN108595157A

  • Parallel execution method based on Java smart contracts

    CN110532038A

  • Method and device for obtaining transaction dependency relationship in block chain

    CN110599166A

  • Performing parallel execution of transactions in distributed ledger system

    CN111095326A