Transaction scheduling method, transaction execution method, device and computer equipment

By utilizing transaction dependency graphs and free transaction sets for parallel execution in the Ethereum blockchain, the problem of limited smart contract transaction execution speed is solved, enabling more efficient utilization of multi-core processors and improving transaction execution efficiency.

CN115827204BActive Publication Date: 2026-01-02HUNAN UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211721906.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-30
Publication Date
2026-01-02
Estimated Expiration
2042-12-30

AI Technical Summary

Technical Problem

In Ethereum, the execution speed of smart contracts is limited by the sequential execution of transactions, which cannot fully utilize the parallel computing resources of multi-core processors, resulting in low transaction execution efficiency.

Method used

By obtaining the transaction dependency graph and the set of free transactions, multiple dependent and free transactions are selected for parallel execution, and the transaction dependency graph and scheduling table are updated until all transactions are completed.

Benefits of technology

By making full use of the parallel computing resources of multi-core processors, the transaction execution efficiency and overall execution speed of the blockchain system are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115827204B_ABST
    Figure CN115827204B_ABST
Patent Text Reader

Abstract

The application relates to a transaction scheduling method and device, computer equipment and a storage medium. The method comprises the following steps: acquiring a transaction dependency graph and a free transaction set of a block; selecting a plurality of dependent transactions and a plurality of free transactions according to the transaction dependency graph and the free transaction set; adding the dependent transactions and the free transactions to a transaction table; sending a transaction loading signal to a plurality of transaction execution modules to enable the transaction execution modules to load the transactions and execute the transactions in parallel; when a loading completion signal sent by the transaction execution modules is received, selecting a new transaction from the transaction dependency graph and the free transaction set and adding the new transaction to the transaction table, and updating the transaction dependency graph, the transaction table and a preset scheduling table until all the transactions in the block are executed. The method can improve the transaction execution efficiency. The application also provides a transaction execution method and device, computer equipment and a storage medium. The method can avoid repeated execution of the instruction decoding process and improve the transaction execution efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of blockchains, and in particular to a transaction scheduling method and device, a computer device, a computer readable storage medium and a computer program product, and a transaction execution method and device, a computer device, a computer readable storage medium and a computer program product. BACKGROUND

[0002] A smart contract is a computer protocol formalized in code that enables custom functionality in various blockchain scenarios, such as financial services, Internet of Things devices, supply chains, and crowdsourcing platforms.

[0003] Ethereum is currently the largest permissionless blockchain system supporting smart contracts, and is essentially a transaction-based state machine in which any node can participate in maintaining the state of the entire blockchain. Ethereum uses a three-phase model for broadcast consensus execution, and in particular in the execution phase: other nodes will capture the broadcasted new block and execute its internal transactions in turn and verify whether the results are correct. The above execution feature limits the overall execution speed of smart contracts in Ethereum. The execution phase requires that only after the current block is executed and successfully verified can the next block be executed, and the newly generated block must be based on the blockchain state of the old block for state update. This chain structure essentially determines that transaction execution is on the critical path of blockchain system state update (i.e. system throughput).

[0004] However, due to extensive dependencies between transactions, even if the same transaction queue is executed, different execution orders will result in inconsistent execution results. In order to uniformly complete block verification, all nodes serially execute transactions in the order of transactions in the block by default. As can be seen, the above transaction order execution feature cannot fully utilize the parallel computing resources of multi-core processors, affecting transaction execution efficiency. SUMMARY

[0005] Therefore, it is necessary to provide a transaction scheduling method, device, computer device, computer readable storage medium and computer program product capable of improving transaction execution efficiency, and a transaction execution method, device, computer device, computer readable storage medium and computer program product.

[0006] In a first aspect, the present application provides a transaction scheduling method applied to a transaction scheduling module. The method comprises:

[0007] obtaining a transaction dependency graph and a free transaction set of a block, the transaction dependency graph comprising a plurality of dependent transactions having a dependency relationship, and the free transaction set comprising free transactions having no dependency relationship;

[0008] According to the transaction dependency graph and the free transaction set, a plurality of dependent transactions and a plurality of free transactions are selected;

[0009] The dependent transactions and the free transactions are added to the transaction table, and a transaction loading signal is sent to the plurality of transaction execution modules, so that the transaction execution modules load the transactions and execute the transactions in parallel;

[0010] When a loading completion signal sent by the transaction execution module is received, new transactions are selected from the transaction dependency graph and the free transaction set and added to the transaction table, and the transaction dependency graph, the transaction table and the preset scheduling table are updated until it is detected that all transactions in the block are executed.

[0011] In one embodiment, according to the transaction dependency graph and the free transaction set, a plurality of dependent transactions and a plurality of free transactions are selected respectively, including:

[0012] According to the transaction dependency graph, a first number of dependent transactions with zero in-degree are selected, and according to the free transaction set, a second number of free transactions are selected, the first number and the second number being determined based on the number of transaction execution modules.

[0013] In one embodiment, updating the transaction dependency graph and the transaction table includes:

[0014] According to the selected new transactions, the transaction nodes corresponding to the new transactions in the transaction dependency graph are deleted;

[0015] According to the redundant dependency relationship between the new transactions and the transactions currently being executed, the weights of the transactions in the transaction dependency graph and the transaction table are updated, and the synchronization lock state of the transactions in the transaction table is updated.

[0016] In one embodiment, the preset scheduling table includes dependency table entries and redundancy table entries of each transaction execution module, the dependency table entry is a binary value representing whether a transaction table entry has a dependency relationship with a transaction executed by a current transaction execution module, and the redundancy table entry is a binary value representing whether a transaction table entry has a redundant relationship with a transaction executed by a current transaction execution module;

[0017] Updating the preset scheduling table includes:

[0018] The dependency table entries of the transaction execution modules other than the target transaction execution module are subjected to an exclusive OR operation to obtain an exclusive OR operation result, the target transaction execution module being a transaction execution module to be loaded with a transaction;

[0019] The exclusive OR operation result is subjected to an AND operation with the redundancy table entry of the target transaction execution module to obtain an AND operation result;

[0020] According to the AND operation result, the next transaction to be executed by the target transaction execution module is selected from the updated transaction table;

[0021] According to the next execution transaction of the target transaction execution module, the preset schedule table is updated.

[0022] In a second aspect, the present application provides a transaction scheduling device. The device comprises:

[0023] a data acquisition module, configured to acquire a transaction dependency graph and a free transaction set of a block, the transaction dependency graph comprising a plurality of dependent transactions having a dependency relationship, and the free transaction set comprising free transactions having no dependency relationship;

[0024] a transaction selection module, configured to select a plurality of dependent transactions and a plurality of free transactions according to the transaction dependency graph and the free transaction set;

[0025] a transaction addition module, configured to add the dependent transactions and the free transactions to a transaction table, and send a transaction loading signal to the plurality of transaction execution modules, so that the transaction execution modules load the transactions and execute the transactions in parallel;

[0026] a data update module, configured to, when receiving a loading completion signal sent by the transaction execution module, select a new transaction from the transaction dependency graph and the free transaction set to add to the transaction table, and update the transaction dependency graph, the transaction table and the preset schedule table, until all transactions in the block are detected to be executed.

[0027] In a third aspect, the present application further provides a computer device. The computer device comprises a memory and a processor, the memory stores a computer program, and the processor implements the steps in the above transaction scheduling method when executing the computer program.

[0028] In a fourth aspect, the present application further provides a computer readable storage medium. The computer readable storage medium stores a computer program, and the computer program implements the steps in the above transaction scheduling method when executed by a processor.

[0029] In a fifth aspect, the present application further provides a computer program product. The computer program product comprises a computer program, and the computer program implements the steps in the above transaction scheduling method when executed by a processor.

[0030] The transaction scheduling method, the transaction scheduling device, the computer device, the storage medium and the computer program product are different from the traditional way of executing transactions in a block in sequence, but are based on a transaction dependency graph and a free transaction set in a block, select a plurality of dependent transactions and a plurality of free transactions, and then distribute the dependent transactions and the free transactions to a plurality of transaction execution modules for parallel execution. When a loading completion signal sent by the transaction execution module is received, a new transaction is selected from the transaction dependency graph and the free transaction set and added to the transaction table, and the transaction dependency graph, the transaction table and the preset scheduling table are updated until it is detected that all transactions in the block are executed. The above process makes full use of the dependency between transactions, selects a plurality of dependent transactions and a plurality of free transactions, and then distributes the dependent transactions and the free transactions to a plurality of transaction execution modules for parallel execution, realizes asynchronous execution scheduling of transactions in a block, and thus fully utilizes the parallel computing resources of a multi-core processor, speeds up the overall execution speed of the block, and improves the transaction execution efficiency.

[0031] In a sixth aspect, the present application provides a transaction execution method applied to a transaction execution module, the method comprising:

[0032] receiving a transaction loading signal sent by a transaction scheduling module, the transaction loading signal carrying transaction identification information;

[0033] selecting a corresponding target transaction from a transaction table according to the transaction identification information, loading the target transaction, and sending a loading completion signal to the transaction scheduling module, the transaction table being obtained by executing the transaction scheduling method by the transaction scheduling module in the block chain;

[0034] extracting an instruction address of a current to-be-executed instruction in the target transaction;

[0035] if it is determined that the instruction address of the current to-be-executed instruction exists in the preset bytecode cache and the current remaining overhead of the target transaction is not less than the total instruction overhead recorded in the preset bytecode cache, then taking the cache where the current to-be-executed instruction is located as a starting point, sequentially obtaining the operands required by the instructions in each cache line, and executing the bytecode of the instructions in each cache line according to the operands;

[0036] if the execution of the instructions in the preset bytecode cache is completed, returning to the step of extracting the instruction address of the current to-be-executed instruction in the target transaction until all instructions in the target transaction are executed;

[0037] wherein each cache line in the preset bytecode cache records the bytecode of an instruction without a dependency relationship.

[0038] In one of the embodiments, the transaction execution module comprises a plurality of functional units corresponding to the functions of the instructions.

[0039] The bytecode of the instructions in each cache line is executed according to the operation number, including:

[0040] According to the instruction function of the instructions in the smart contract instruction set, the instructions in each cache line are divided into multiple categories;

[0041] The instructions of each category and the operation number required by the instructions are allocated to the functional units corresponding to the instruction function and executed in parallel.

[0042] In one embodiment, the method further comprises:

[0043] If the instruction address of the current to-be-executed instruction in the target transaction does not exist in the preset bytecode cache, the current to-be-executed instruction is decoded, and the decoded current to-be-executed instruction is inserted into the preset bytecode cache according to the dependency relationship between the current to-be-executed instruction and the instructions in the preset bytecode cache, and the instruction overhead of the preset bytecode cache is updated;

[0044] If the current remaining overhead of the target transaction is not less than the total instruction overhead recorded by the updated preset bytecode cache, the cache line where the current to-be-executed instruction is located is taken as the starting point, the operation number required by the instructions in each cache line is sequentially obtained, the bytecode of the instructions in each cache line is executed according to the operation number, and if the execution of the instructions in the preset bytecode cache is completed, the step of extracting the instruction address of the current to-be-executed instruction in the target transaction is returned, and the execution of all instructions in the target transaction is completed.

[0045] In a seventh aspect, the application also provides a transaction execution device. The device comprises:

[0046] The signal receiving module is configured to receive a transaction loading signal sent by the transaction scheduling module, and the transaction loading signal carries transaction identification information;

[0047] The transaction loading module is configured to select a corresponding target transaction from a transaction table according to the transaction identification information, load the target transaction, and send a loading completion signal to the transaction scheduling module, wherein the transaction table is obtained by executing the transaction scheduling method by the transaction scheduling module in the block chain;

[0048] The instruction address extraction module is configured to extract the instruction address of the current to-be-executed instruction in the target transaction;

[0049] The target transaction execution module is configured to: if it is determined that the instruction address of the current to-be-executed instruction exists in the preset bytecode cache and the current remaining overhead of the target transaction is not less than the total instruction overhead recorded in the preset bytecode cache, taking the cache where the current to-be-executed instruction is located as a starting point, sequentially obtaining the operands required by the instructions in each cache line, executing the bytecode of the instructions in each cache line according to the operands, if the execution of the instructions in the preset bytecode cache is completed, returning to the step of extracting the instruction address of the current to-be-executed instruction in the target transaction, and until all the instructions in the target transaction are executed.

[0050] In the preset bytecode cache, each cache line records an instruction without a dependency relationship.

[0051] In an eighth aspect, the present application further provides a computer device. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the steps in the transaction execution method described above are implemented.

[0052] In a ninth aspect, the present application further provides a computer readable storage medium. The computer readable storage medium stores a computer program. When the computer program is executed by a processor, the steps in the transaction scheduling method described above are implemented.

[0053] In a tenth aspect, the present application further provides a computer program product. The computer program product includes a computer program. When the computer program is executed by a processor, the steps in the transaction execution method described above are implemented.

[0054] The transaction execution method, the device, the computer device, the storage medium and the computer program product described above are different from the traditional way of executing a transaction according to the order of the instructions in the transaction. Instead, the instruction address of the current to-be-executed instruction in the target transaction is compared with the address identifier in the preset bytecode cache. Since each cache line in the preset bytecode cache records an instruction without a dependency relationship, if it is determined that the instruction address of the current to-be-executed instruction exists in the preset bytecode cache and the current remaining overhead of the target transaction is not less than the total instruction overhead recorded in the preset bytecode cache, the current to-be-executed instruction does not need to be decoded. Taking the cache where the current to-be-executed instruction is located as a starting point, sequentially obtaining the operands required by the instructions in each cache line, executing the bytecode of the instructions in each cache line according to the operands, if the execution of the instructions in the preset bytecode cache is completed, returning to the step of extracting the instruction address of the current to-be-executed instruction in the target transaction, and until all the instructions in the target transaction are executed. The above process makes full use of the redundancy relationship between transactions, avoids repeated decoding of instructions, removes the redundancy between transactions, shortens the transaction execution time, and improves the transaction execution efficiency. Attached Figure Description

[0055] Figure 1 This is an application environment diagram of a transaction scheduling method or transaction execution method in one embodiment;

[0056] Figure 2 This is a flowchart illustrating a transaction scheduling method in one embodiment;

[0057] Figure 3 This is a framework diagram of an asynchronous parallel scheduling process in one embodiment;

[0058] Figure 4 This is a schematic diagram illustrating an asynchronous execution scheduling process in one embodiment.

[0059] Figure 5 This is a flowchart illustrating the transaction scheduling method in another embodiment;

[0060] Figure 6 This is a flowchart illustrating the steps of updating the scheduling table in one embodiment;

[0061] Figure 7 This is a flowchart illustrating a transaction execution method in one embodiment;

[0062] Figure 8 This is a schematic diagram illustrating the optimization of transaction redundancy relationships in one embodiment;

[0063] Figure 9 This is a structural block diagram of a transaction scheduling device in one embodiment;

[0064] Figure 10 This is a structural block diagram of a transaction execution device in one embodiment;

[0065] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0066] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0067] The transaction scheduling method provided in this application can be applied to, for example, Figure 1The application environment shown. Among them, the terminal 102 communicates with the block chain 104 through the network, and the transaction scheduling module 106 and the transaction execution module 108 are deployed on the terminal 102. It can be understood that the transaction scheduling module 106 and the transaction execution module 108 can also exist on different devices, and communicate through the network. In this embodiment, in order to reduce the overhead of device interaction and improve speed, the transaction scheduling module and the transaction execution module can also be integrated into the same terminal as an example for description, and the two communicate through the hardware structure. Specific can be that the terminal 102 obtains the dependency relationship of all transactions in the current block, divides all transactions in the block according to the dependency relationship, constructs a transaction dependency relationship graph and a free transaction list, and stores evidence on the chain. Among them, the transaction dependency relationship graph includes a plurality of dependent transactions with dependency relationship, and the free transaction set includes a plurality of free transactions without dependency relationship. When the terminal 102 receives the transaction scheduling message, it sends a transaction scheduling signal to the transaction scheduling module 106, the transaction scheduling module 106 responds to the transaction scheduling signal, obtains the transaction dependency relationship graph and the free transaction set of the block, then selects a plurality of dependent transactions and a plurality of free transactions from the transaction dependency relationship graph and the free transaction set respectively, and adds the dependent transactions and the free transactions to the transaction table, and sends a transaction loading signal to a plurality of transaction execution modules 108, so that the transaction execution module 108 loads the transaction and executes in parallel. When receiving the loading completion signal sent by the transaction execution module 108, select new transactions from the transaction dependency relationship graph and the free transaction set and add them to the transaction table, and update the transaction dependency relationship graph, the transaction table and the preset scheduling table, until all transactions in the block are executed, thus completing the transaction scheduling process. Among them, the terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things device can be a smart speaker, a smart TV, a smart air conditioner, a smart vehicle device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc.

[0068] In one embodiment, as shown in Figure 2 , a transaction scheduling method is provided, which is applied to Figure 1 the terminal in the application as an example, specifically to the transaction scheduling module 106 in the terminal 102 as an example for description, including the following steps:

[0069] Step S100, obtaining the transaction dependency relationship graph and the free transaction set of the block, the transaction dependency relationship graph including a plurality of dependent transactions with dependency relationship, and the free transaction set including a plurality of free transactions without dependency relationship.

[0070] The transaction dependency relationship graph is a relationship graph including a plurality of dependent transaction nodes (also called dependent transactions) with dependency relationship. The structure of the transaction dependency relationship graph can be as followsFigure 3 Each node in the transaction dependency graph is a key-value pair, where the key represents the current transaction number (T n ), and the value is a two-tuple composed of a smart contract (SC n ) called by the transaction and a specific calling function (f n ), where f is the identifier of the smart contract function. The first step of contract execution compares the 32-bit bytecode to determine the entry function, and f is the identifier. The value field (Value, V in the figure) represents the redundancy of the current transaction execution. Each directed edge in the graph represents a dependency relationship, and the meaning of each edge is that the transaction at the end of the edge depends on the transaction at the beginning of the edge. The free transaction set is a data structure that includes multiple free transactions that have no dependency relationship. A free transaction is a transaction that does not depend on any other transaction and can be executed independently. In actual applications, the dependency relationship between transactions is generated when the block is generated. Therefore, the local node 100 can pre-obtain the dependency relationship of all transactions in the current block, divide all transactions in the block according to the dependency relationship, construct the transaction dependency graph and the free transaction list, and store the evidence on the chain. For example, if the total number of transactions in the block is 10, transactions T0-T5 have a related dependency relationship, and transactions a, b, and c have no dependency relationship with any other transaction, then transactions a, b, and c are divided into the free transaction list; node tasks that call the same smart contract are considered to have common redundancy relationships (which can be referred to as redundancy items Re). If T0, T2, and T4 all call the same smart contract SC1, the redundancy Value of the transaction node corresponding thereto is 3, and the redundancy calculation rules of other nodes are the same. In this way, the transaction dependency graph is constructed. When the transaction scheduling module 106 receives the transaction scheduling signal, it directly obtains the transaction dependency graph and the free transaction set of the block. In this embodiment, the transaction scheduling module can be a CPU (Central Processing Unit, central processor).

[0071] In step S200, a plurality of dependent transactions and a plurality of free transactions are selected according to the transaction dependency graph and the free transaction set.

[0072] In the previous embodiment, after obtaining the transaction dependency graph and the free transaction set of the block, the transaction scheduling module can select a plurality of dependent transactions and a plurality of free transactions from the transaction dependency graph and the free transaction set, respectively, to facilitate the subsequent scheduling of transactions.

[0073] In step S300, the plurality of dependent transactions and the plurality of free transactions are added to the transaction table, and a transaction loading signal is sent to the plurality of transaction execution modules to enable the transaction execution modules to load the transactions and execute the transactions in parallel.

[0074] The transaction table includes data in two dimensions of transaction state L and redundancy V. Among them, "L" in the transaction table represents a synchronization lock flag, 1 represents that the current transaction table item is locked, other transaction execution modules cannot load this transaction, and 0 represents that it is not locked, and the transaction can be normally loaded, and the default is 0; "V" represents the redundancy weight of the transaction, that is, the redundancy, which corresponds to the weight of each node in the transaction dependency graph. After selecting multiple dependent transactions and multiple free transactions, the multiple dependent transactions and the multiple free transactions can be loaded and added to the transaction table, and a transaction loading signal is sent to the multiple transaction execution modules, so that each transaction execution module selects to load the corresponding transaction and executes the loaded transaction in parallel. It can be understood that at the beginning of loading the transaction into the transaction table, the transaction table can be initialized to be empty.

[0075] Step S400, when receiving the loading completion signal sent by the transaction execution module, selecting new transactions from the transaction dependency graph and the free transaction set and adding them to the transaction table, and updating the transaction dependency graph, the transaction table and the preset scheduling table until all transactions in the block are executed.

[0076] The scheduling table represents the scheduling state of each transaction execution module. Specifically, the scheduling table includes redundancy table items and dependency table items of each transaction execution module. The redundancy table item is a binary value representing whether the transaction table item has a redundancy relationship with the transaction executed by the current transaction execution module, that is, it can represent the table item in the transaction table that has a redundancy relationship with the transaction being executed by the current transaction execution module. In this embodiment, the redundancy table item is referred to as a redundancy item, represented by "Re". If a transaction calls the same smart contract, it is considered to have a common redundancy relationship. Initially, all table items of the scheduling table are 0, the number of table items is consistent with the number of transaction execution modules, and each Re consists of 2N-1 binary, corresponding to each table item in the transaction table. If the corresponding position is 1, it indicates that there is a redundancy relationship with the transaction being executed by the current transaction execution module, and if the corresponding position is 0, it indicates that there is no redundancy relationship with the transaction being executed by the current transaction execution module.

[0077] The dependency table item is a binary value representing whether the transaction table item has a dependency relationship with the transaction executed by the current transaction execution module, that is, it can represent the table item in the transaction table that has a dependency relationship with the transaction being executed by the current transaction execution module. In this embodiment, the dependency table item is referred to as a dependency item, represented by "De". Each De consists of 2N-1 binary, corresponding to each table item in the transaction table. If the corresponding position is 1, it indicates that there is a dependency relationship with the transaction being executed by the current transaction execution module, and if the corresponding position is 0, it indicates that there is no dependency relationship with the transaction being executed by the current transaction execution module.

[0078] In a specific implementation, when the transaction scheduling module receives the "loading complete" signal sent by the transaction execution module, it indicates that the transactions in the original transaction table have been loaded and completed, and new transactions need to be filled in. At this time, the transaction scheduling module selects new transactions from the transaction dependency graph and the free transaction set to add to the transaction table. At this time, the nodes in the transaction dependency graph decrease, the transaction table increases, and the scheduling state of the transaction execution module in the scheduling table also changes. Therefore, the transaction dependency graph, the transaction table, and the preset scheduling table can be updated according to the scheduling state of the transaction. When the transaction scheduling module receives the "loading complete" signal again, it selects new transactions from the transaction dependency graph and the free transaction set to add to the transaction table, and updates the transaction dependency graph, the transaction table, and the preset scheduling table. In this way, the above process is repeated until it is detected that all transactions in the block have been loaded and successfully executed. The specific asynchronous execution scheduling process can be as shown in Figure 4

[0079] In the above transaction scheduling method, unlike the traditional way of serially executing transactions in the block in the order of transactions, the number of dependent transactions and the number of free transactions are selected based on the transaction dependency graph and the free transaction set in the block, and then the dependent transactions and the free transactions are distributed to multiple transaction execution modules for parallel execution. When the "loading complete" signal sent by the transaction execution module is received, new transactions are selected from the transaction dependency graph and the free transaction set to add to the transaction table, and the transaction dependency graph, the transaction table, and the preset scheduling table are updated until it is detected that all transactions in the block have been executed. The above process fully utilizes the dependency relationship between transactions, selects multiple dependent transactions and multiple free transactions, and then distributes the dependent transactions and the free transactions to multiple transaction execution modules for parallel execution, thereby realizing asynchronous execution scheduling of transactions in the block, fully utilizing the parallel computing resources of the multi-core processor, accelerating the overall execution speed of the block, and improving the transaction execution efficiency.

[0080] As shown in Figure 5 In one embodiment, step S200 includes: step S220, selecting a first number of dependent transactions with an in-degree of zero according to the transaction dependency graph, and selecting a second number of free transactions according to the free transaction set, the first number and the second number being determined based on the number of transaction execution modules.

[0081] ​In this embodiment, when selecting dependent transactions and free transactions, the transaction scheduling module can select according to the number of transaction execution modules. Specifically, if the number of transaction execution modules is N, the total number of selected transactions can be set to 2N-1, N dependent transactions with zero in-degree can be selected from the transaction dependency graph, and then N-1 free transactions can be selected from the free transaction list to complete the selection of 2N-1 transactions. If the number of selected transactions does not reach 2N-1, the selected transactions can be continuously loaded into the transaction table to wait for the loading and execution of the transaction execution module. In this embodiment, the number of transaction execution modules is used to determine the number of transactions added to the transaction table, which can ensure that there are always transaction execution modules.

[0082] In one of the embodiments, updating the transaction dependency graph and the transaction table includes: deleting the corresponding transaction node in the transaction dependency graph according to the selected new transaction, updating the weight of each transaction in the transaction dependency graph and the transaction table according to the redundant dependency relationship between the new transaction and the currently executing transaction, and updating the synchronization lock state of the transaction in the transaction table.

[0083] In specific implementation, updating the transaction dependency graph can include deleting the corresponding transaction node in the transaction dependency graph according to the selected new transaction, and updating the weight of each transaction in the transaction dependency graph and the transaction table according to the redundant dependency relationship between the new transaction and the currently executing transaction, i.e., updating the redundant relationship of each transaction, and updating the synchronization lock state of each transaction in the transaction table.

[0084] For example, if the number of transaction execution modules is 2, the transaction scheduling module takes the CPU as an example.

[0085] Step 1-1. As shown in Figure 3 , the initial state of the transaction table is empty, the redundant relationship of the transaction dependency graph is 0 for transactions T0 and T1, the free transactions are Ta, Tb and Tc, the transaction scheduling module selects T0, T1 and Ta as three transaction nodes as candidate transactions to join the transaction table, and after the selected transactions are added to the transaction table, the corresponding transaction nodes are deleted from the transaction dependency graph, and the weight of the transaction node is updated.

[0086] Step 1-2. The transaction execution module selects the best transaction with the largest weight and no lock from the candidate transactions, locks the selected best transaction, loads and executes it, sends a "loading complete" signal to the CPU after loading is completed, and selects T0 and T1 as the first two transactions to execute.

[0087] Step 1-3. After receiving the "load complete" signal sent by the transaction execution module, the CPU fills the new transaction into the transaction table. The process is the same as step 1-1. Since T0 and T1 have been removed from the transaction dependency graph, the in-degree of T2, T3 and T4 is 0. T2 and T3 can be filled into the transaction table. The weight of each transaction node in the transaction dependency graph is updated according to the redundancy relationship and dependency relationship between the new transaction and the transaction being executed. When the next "load complete" signal arrives, return to step 1-3 to continue the scheduling process until all transactions are scheduled and executed.

[0088] In this embodiment, the transaction dependency graph and the transaction table are updated in time according to the redundancy relationship and dependency relationship between the new transaction and the transaction being executed, which can ensure that the transaction scheduling module makes accurate transaction scheduling.

[0089] As shown in FIG. 4, in one embodiment, the preset scheduling table includes dependency table items and redundancy table items of each transaction execution module. Figure 6

[0090] The updating of the preset scheduling table includes:

[0091] Step S420, performing exclusive OR operation on the dependency table items of the transaction execution modules except the target transaction execution module to obtain an exclusive OR operation result, the target transaction execution module being the transaction execution module of the transaction to be loaded.

[0092] Step S440, performing AND operation on the exclusive OR operation result and the redundancy table item of the target transaction execution module to obtain an AND operation result.

[0093] Step S460, according to the AND operation result, screening the next transaction to be executed of the target transaction execution module from the updated transaction table.

[0094] Step S480, according to the next transaction to be executed of the target transaction execution module, updating the preset scheduling table.

[0095] ​In a specific implementation, when it is detected that the target transaction execution module needs to load a new transaction after executing the loaded task, the dependency table entries of all the transaction execution modules except the target node are subjected to an exclusive OR operation to obtain an exclusive OR operation result, so as to screen out candidate transactions that have no dependency relationship with the transactions being executed by the other transaction execution modules except the target transaction execution module. Then, in order to further screen out the most suitable transaction as the next execution transaction of the target transaction execution module, the exclusive OR operation result is subjected to an AND operation with the redundancy table entry of the target transaction execution module to obtain an AND operation result. According to the AND operation result, the transactions that have a redundancy relationship with the target transaction execution module are screened out from the updated transaction table as the next execution transaction of the target transaction execution module. Then, the next execution transaction of the target transaction execution module is updated to the scheduling table.

[0096] In the embodiment, the transaction execution module is taken as an example of a PU (Processing Unit, processor), and the number of transaction execution modules is set to 2, namely PU0 and PU1. Figure 3 As shown in the figure, the transaction execution module PU1 is executing transaction T1, and the transaction T0 in the target transaction execution module PU0 has been executed and needs to load a new transaction. At this time, the dependency table entry of PU0 when executing transaction T0 is 000. At this time, the dependency table entry “001” of the remaining transaction execution module PU1 in the scheduling table can be subjected to an exclusive OR operation with “000” to obtain “110” (in this embodiment, the number of transaction execution modules is 2, and if there are more transaction execution modules, the exclusive OR calculation parameter is the dependency table entry of all the other transaction execution modules). The exclusive OR operation result is mapped to each table entry in the transaction table, and “110” is mapped to the transaction table, which indicates that the first and second table entries in the transaction table are 1, and the third table entry is “0”. It is considered that the transactions in the first and second table entries in the transaction table, namely T2 and T3, have no dependency relationship with the transactions of the current other transaction execution modules, and can be used as the transaction candidates of PU0. Then, the exclusive OR operation result “110” is subjected to an AND operation with the redundancy table entry Re of the target transaction execution module PU0: “110 & 101” obtains “100”, which indicates that the transaction in the first table entry in the transaction table, namely T2, can be used as the next execution transaction of PU0. At this time, the scheduling is completed, the next execution transaction T2 of PU0 determined according to the above is used to update the scheduling table, then the transaction state L corresponding to transaction T2 is locked (namely marked as 1), and a transaction loading signal is sent to PU0, so that PU0 loads and executes the corresponding transaction T2.

[0097] In the embodiment, the redundancy table entry and the dependency table entry of the transaction execution module are subjected to an operation, so that a more suitable transaction that has no dependency relationship with the transactions of the other transaction execution modules is screened out as the next execution transaction of the target transaction execution module, and the orderly scheduling of transactions is ensured.

[0098] The embodiment of the present application also provides a transaction execution method, which can also be applied to the application environment as shown in Figure 1 Specifically, the transaction scheduling module 106 can complete the transaction scheduling of the current round according to the transaction scheduling method, determine the current transaction table, and send a transaction loading signal carrying transaction identification information to the plurality of transaction execution modules 108. The transaction execution module 108 receives the corresponding transaction loading signal, selects the corresponding target transaction from the transaction table according to the transaction identification information carried in the transaction loading signal, then loads the target transaction, and sends a loading completion signal to the transaction scheduling module 106. When the transaction execution module 108 determines that the instruction address of the current to-be-executed instruction in the target transaction exists in the preset bytecode cache, and the current remaining overhead of the target transaction is not less than the sum of the overheads of the current to-be-executed instructions, the transaction execution module 108 reads the operands required by the current to-be-executed instruction, executes the current to-be-executed instruction in parallel according to the operands, returns to the step of determining whether the instruction address of the current to-be-executed instruction in the target transaction is consistent with the address identifier in the preset bytecode cache, and continues the transaction execution process until all to-be-executed instructions in the target transaction are executed.

[0099] In one embodiment, as shown in Figure 7 A transaction execution method is provided, and the method is applied to Figure 1 For example, the method is applied to the transaction execution module 108 of the terminal 102, and the method includes the following steps:

[0100] In step S500, a transaction loading signal sent by a transaction scheduling module is received, and the transaction loading signal carries transaction identification information.

[0101] The transaction identification information includes the number or name of the transaction. In this embodiment, the transaction identification information is taken as an example of the number of the transaction. The transaction scheduling module 106 can add the selected transaction to the transaction table according to the transaction scheduling method, and distribute the transactions in the transaction table to different transaction execution modules. After completing the transaction scheduling of the current round, the transaction scheduling module 106 sends a transaction loading signal carrying the number of the transaction to the different transaction execution modules. The transaction execution module receives the corresponding transaction loading signal.

[0102] In step S600, the corresponding target transaction is selected from the transaction table according to the transaction identification information, the target transaction is loaded, and a loading completion signal is sent to the transaction scheduling module. The transaction table is obtained by executing the transaction scheduling method by the transaction scheduling module in the block chain.

[0103] After receiving the corresponding transaction loading signal, the transaction execution module extracts the transaction number in the signal, selects the corresponding target transaction from the transaction table according to the transaction number, and loads the target transaction with a lock and sends a loading completion signal to the transaction scheduling module.

[0104] In step S700, the instruction address of the current to-be-executed instruction in the target transaction is extracted.

[0105] In actual applications, a transaction includes multiple to-be-executed instructions, and each to-be-executed instruction has a fixed instruction address as an identifier. In this embodiment, after sending the loading completion signal to the transaction scheduling module, the transaction is executed, specifically, the instruction address of the current to-be-executed instruction in the target transaction can be extracted according to an instruction counter. It can be understood that the number of current to-be-executed instructions can be multiple.

[0106] In step S800, if it is determined that the instruction address of the current to-be-executed instruction exists in the preset bytecode cache and the current remaining overhead of the target transaction is not less than the total instruction overhead recorded in the preset bytecode cache, the cache row where the current to-be-executed instruction is located is taken as a starting point, the operands required by the instructions in each cache row are sequentially obtained, and the bytecode of the instructions in each cache row is executed according to the operands.

[0107] In step S900, if the instruction execution in the preset bytecode cache is completed, step S700 is returned until all to-be-executed instructions in the target transaction are executed.

[0108] In the preset bytecode cache, the bytecode of each cache row records the instructions without a dependency relationship.

[0109] The bytecode cache is a cache structure including multiple cache rows, each cache row records the bytecode of instructions without a mutual dependency relationship, each cache row takes the instruction address of the first instruction in the current cache row as an identifier, takes the instruction address of the next instruction of the last executed instruction as an ending identifier, and also records the total overhead (GAS) of all instructions in the current cache row. The dependency relationship between instructions is determined by read-after-write, write-after-read, and write-after-write. For details of the specific bytecode cache structure, please refer to Figure 8 GAS in Ethereum is equivalent to the total energy of a transaction. For a transaction, the required GAS for executing the transaction is set in advance, and a certain amount of GAS is consumed for executing each instruction in the transaction.

[0110] When the instruction address of the current to-be-executed instruction in the target transaction is extracted, it can be determined whether the current to-be-executed instruction hits the bytecode cache, that is, whether the instruction address of the current to-be-executed instruction exists in the preset bytecode cache. If it exists, it is determined that the current to-be-executed instruction hits the bytecode cache, that is, the instruction does not need to be decoded, and the bytecode in the bytecode cache can be directly executed to complete the instruction execution. At this time, it can be determined that the current remaining overhead of the target transaction is not less than the total instruction overhead recorded by the preset bytecode cache. If the current remaining overhead of the target transaction is not less than the total instruction overhead recorded by the preset bytecode cache, the cache behavior starting point (denoted as the first cache line) where the current to-be-executed instruction is located is determined, and the operands required by the instructions in each cache line are sequentially obtained. Then, according to the operands, all bytecodes in each cache line are executed to complete all instructions in the bytecode cache. Specifically, when all instructions in the first cache line are executed, the next to-be-executed cache line (denoted as the next cache line) can be found according to the end address in the first cache line. Similarly, the operands required by the instructions in the next cache line are obtained, and all bytecodes in the next cache line are executed according to the operands to complete all instructions in the next cache line. In this way, the execution of the instructions in the preset bytecode cache is completed, the instruction execution is completed, and the data is written back in parallel. The order of the write-back can be obtained during the instruction execution. Then, step S700 is repeated until all instructions of the target transaction are executed.

[0111] If the current remaining overhead of the target transaction is less than the total instruction overhead recorded by the preset bytecode cache, the execution process of the current target transaction is ended. Because the redundant transactions call the same smart contract, the bytecode of the smart contract is fixed after encoding. In the above process, if the current to-be-executed instruction hits the address in the bytecode cache, the corresponding instruction is directly executed according to the bytecode in the cache, which avoids the repeated decoding of the instructions of the redundant transactions that call the same smart contract and eliminates the redundancy between transactions.

[0112] In the transaction execution method, the instruction address of the current to-be-executed instruction in the target transaction is compared with the address identifier in the preset bytecode cache. Since each cache line in the preset bytecode cache records instructions without a dependency relationship, if it is determined that the instruction address of the current to-be-executed instruction exists in the preset bytecode cache and the current remaining overhead of the target transaction is not less than the total instruction overhead recorded in the preset bytecode cache, the current to-be-executed instruction does not need to be decoded, and the bytecode of the instructions in each cache line is executed according to the operands required by the instructions in each cache line, starting from the cache line where the current to-be-executed instruction is located. If the execution of the instructions in the preset bytecode cache is completed, the step of extracting the instruction address of the current to-be-executed instruction in the target transaction is returned, and the execution of all to-be-executed instructions in the target transaction is completed. The above process fully utilizes the redundancy relationship between transactions, can avoid repeated decoding of instructions, and thus achieves the purpose of removing the redundancy between transactions, thereby shortening the transaction execution time and improving the transaction execution efficiency.

[0113] In one of the embodiments, the transaction execution module includes a plurality of functional units corresponding to instruction functions.

[0114] According to the operands, the bytecode of each instruction in the target cache line is executed, including: according to the instruction functions of the instructions in the smart contract instruction set, the instructions in each cache line are divided into a plurality of categories, and the instructions in each category and the operands required by the instructions are distributed to the functional units corresponding to the instruction functions and executed in parallel.

[0115] In actual application, the number of functional units is equal to the maximum number of instructions in each cache line. Specifically, according to the instruction functions contained in the smart contract set, the instructions in the cache line are divided into different categories, and each category is given to a corresponding functional unit for execution, that is, each category of instructions and the required operands corresponding to the instructions are distributed to the corresponding functional units, so that the functional units execute the instructions in parallel. In this way, the instruction execution time can be greatly shortened, and the transaction execution efficiency can be improved.

[0116] In one of the embodiments, the method further includes:

[0117] In step S920, if the instruction address of the current to-be-executed instruction in the target transaction does not exist in the preset bytecode cache, the current to-be-executed instruction is decoded, and the decoded current to-be-executed instruction is inserted into the preset bytecode cache according to the dependency relationship between the current to-be-executed instruction and the instructions in the preset bytecode cache, and the instruction overhead of the preset bytecode cache is updated.

[0118] If the current remaining overhead of the target transaction is not less than the total instruction overhead recorded by the updated preset bytecode cache, the operands required by the instructions in each cache line are sequentially obtained from the cache where the current to-be-executed instruction is located, the bytecode of the instructions in each cache line is executed according to the operands, if the execution of the instructions in the preset bytecode cache is completed, step S700 is returned, and all instructions in the target transaction are executed until all instructions in the target transaction are executed.

[0119] The current to-be-executed instruction is decoded, that is, the current to-be-executed instruction is converted into bytecode, which is used for execution by the Ethereum virtual machine. In actual application, not all current to-be-executed instructions can find consistent address identifiers in the preset bytecode cache. If the instruction address of the current to-be-executed instruction in the target transaction does not exist in the preset bytecode cache, the current to-be-executed instruction is decoded, the bytecode obtained after decoding is inserted into the bytecode cache, and the instruction overhead of the preset bytecode cache is updated. Then, it is compared whether the current remaining GAS is less than the total instruction overhead recorded by the updated preset bytecode cache. If not, the current to-be-executed instruction is executed in the manner of hitting the bytecode cache, the operands required by the instructions in each cache line are sequentially obtained from the cache where the current to-be-executed instruction is located, the bytecode of the instructions in each cache line is executed according to the operands, if the execution of the instructions in the preset bytecode cache is completed, the step of extracting the instruction address of the current to-be-executed instruction in the target transaction is returned, and all instructions in the target transaction are executed until all instructions in the target transaction are executed.

[0120] Specifically, the bytecode obtained after decoding is inserted into the bytecode cache, which can be: first, it is judged whether the current to-be-executed instruction has a dependency relationship with the instruction stored in the current cache line. If there is no dependency relationship, the decoded bytecode is inserted into the current cache line, and the total GAS of the current cache line is updated. If the inserted instruction is a branch instruction, the current inserted branch instruction is taken as the end of the cache line, this line is inserted and cannot be inserted with new instructions. If the current to-be-executed instruction has a dependency relationship with the instruction in the cache line, the current cache line is inserted and cannot be inserted with new instructions. At this time, a new cache line is created, and the bytecode obtained by decoding the to-be-executed instruction is inserted into the new empty line. If the current cache line is full, the cache line is replaced according to the LRU (Least Recently Used) algorithm. After the bytecode of the current to-be-executed instruction is successfully inserted, the next instruction address of the newly inserted instruction is taken as the end address of the current line. Figure 8As shown, the instruction PUSHx80 and the instruction PUSHx40 can be written into the stack at the same time at the write stage, and there is no dependency between the instructions, which can be placed in the same cache line, the starting address of the cache line is i, and the ending address is the next instruction address i+2 of the instruction PUSHx40; the MSTORE instruction takes out two elements from the top of the stack as the offset and data written into the memory, which depends on the data inserted by the previous two PUSH instructions, so there is a dependency relationship, and needs to be inserted into a new line, at this time the first cache line cannot be inserted into the instruction cache any more, according to this rule, the bytecode cache corresponding to the transaction execution process of the embodiment is as shown in Figure 6 As shown.

[0121] It should be understood that, although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the arrow, these steps are not necessarily executed in the order indicated by the arrow. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be alternately executed with at least part of other steps or steps or stages in other steps.

[0122] Based on the same inventive concept, the embodiments of the present application also provide a transaction scheduling device for implementing the transaction scheduling method described above, and a transaction execution device for implementing the transaction execution method described above. The implementation scheme for solving the problem provided by the above device is similar to the implementation scheme described in the above method, so the specific limitations in one or more transaction scheduling device or transaction execution device embodiments provided below can refer to the limitations of the transaction scheduling method or the transaction execution method in the above text, which will not be described here.

[0123] In one embodiment, as Figure 9 shown, a transaction scheduling device is provided. The device includes a data acquisition module 810, a transaction selection module 820, a transaction adding module 830, and a data updating module 840, wherein:

[0124] The data acquisition module 810 is configured to acquire a transaction dependency graph of a block and a free transaction set, the transaction dependency graph including a plurality of dependent transactions having a dependency relationship, and the free transaction set including a plurality of free transactions having no dependency relationship.

[0125] The transaction selection module 820 is configured to select a plurality of dependent transactions and a plurality of free transactions according to the transaction dependency graph and the free transaction set.

[0126] The transaction adding module 830 is configured to add the dependent transactions and the free transactions into the transaction table, and send a transaction loading signal to the plurality of transaction execution modules to enable the transaction execution modules to load the transactions and execute the transactions in parallel.

[0127] The data updating module 840 is configured to select new transactions from the transaction dependency graph and the free transaction set to add into the transaction table when a loading completion signal sent by the transaction execution module is received, and update the transaction dependency graph, the transaction table and the preset scheduling table until all the transactions in the block are detected to be executed.

[0128] In the transaction scheduling device, different from the traditional way of executing transactions in the block in sequence, the plurality of dependent transactions and the plurality of free transactions are selected according to the transaction dependency graph and the free transaction set in the block, and then the dependent transactions and the free transactions are distributed to the plurality of transaction execution modules for parallel execution. When a loading completion signal sent by the transaction execution module is received, new transactions are selected from the transaction dependency graph and the free transaction set to add into the transaction table, and the transaction dependency graph, the transaction table and the preset scheduling table are updated until all the transactions in the block are detected to be executed. The above process makes full use of the dependency between transactions, selects the plurality of dependent transactions and the plurality of free transactions, and then distributes the dependent transactions and the free transactions to the plurality of transaction execution modules for parallel execution, so as to realize asynchronous execution scheduling of the transactions in the block, thereby fully utilizing the parallel computing resources of the multi-core processor, accelerating the overall execution speed of the block and improving the transaction execution efficiency.

[0129] In one embodiment, the transaction selecting module 820 is further configured to select a first number of dependent transactions with an in-degree of zero according to the transaction dependency graph, and select a second number of free transactions according to the free transaction set, the first number and the second number being determined based on the number of the transaction execution modules.

[0130] In one embodiment, the data updating module 840 is further configured to delete a transaction node corresponding to the new transaction in the transaction dependency graph according to the selected new transaction, update the weight of each transaction in the transaction dependency graph and the transaction table, and the synchronization lock state of the transaction in the transaction table according to the redundant dependency relationship between the new transaction and the transaction being executed.

[0131] In one embodiment, the preset scheduling table includes a dependency table item and a redundancy table item of each transaction execution module.

[0132] The data updating module 840 is further configured to perform an exclusive-OR operation on the dependency table items of the transaction execution modules other than the target transaction execution module, to obtain an exclusive-OR operation result, the target transaction execution module being the transaction execution module of the transaction to be loaded, perform an AND operation on the exclusive-OR operation result and the redundancy table item of the target transaction execution module, to obtain an AND operation result, and filter out the next transaction to be executed of the target transaction execution module from the updated transaction table according to the AND operation result, and update the preset scheduling table according to the next transaction to be executed of the target transaction execution module.

[0133] As shown in Figure 10 In one embodiment, the application further provides a transaction execution device. The device comprises a signal receiving module 910, a transaction loading module 920, an instruction address extracting module 930 and a target transaction execution module 940, wherein:

[0134] The signal receiving module 910 is configured to receive a transaction loading signal sent by a transaction scheduling module, the transaction loading signal carrying transaction identification information.

[0135] The transaction loading module 920 is configured to select a corresponding target transaction from a transaction table according to the transaction identification information, load the target transaction by locking, and send a loading completion signal to the transaction scheduling module, the transaction table being obtained by executing the above transaction scheduling method by the transaction scheduling module in the block chain.

[0136] The instruction address extracting module 930 is configured to extract an instruction address of a current to-be-executed instruction in the target transaction.

[0137] The target transaction execution module 940 is configured to, if it is determined that the instruction address of the current to-be-executed instruction exists in a preset bytecode cache and the current remaining overhead of the target transaction is not less than a total instruction overhead recorded in the preset bytecode cache, take the cache row where the current to-be-executed instruction is located as a starting point, sequentially obtain operands required by instructions in each cache row, execute bytecodes of the instructions in each cache row according to the operands, if the execution of the instructions in the preset bytecode cache is completed, control the instruction address extracting module 930 to perform the operation of extracting the instruction address of the current to-be-executed instruction in the target transaction, and until the execution of all to-be-executed instructions in the target transaction is completed.

[0138] Each cache row in the preset bytecode cache records an instruction without a dependency relationship.

[0139] In the transaction execution device, the instruction address of the current to-be-executed instruction in the target transaction is compared with the address identifier in the preset bytecode cache. Since each cache line in the preset bytecode cache records instructions without dependency, if it is determined that the instruction address of the current to-be-executed instruction exists in the preset bytecode cache and the current remaining overhead of the target transaction is not less than the total instruction overhead recorded in the preset bytecode cache, the current to-be-executed instruction does not need to be decoded. The bytecode of the instructions in each cache line is executed by taking the cache line where the current to-be-executed instruction is located as a starting point and sequentially obtaining the operands required by the instructions in each cache line. If the execution of the instructions in the preset bytecode cache is completed, the step of extracting the instruction address of the current to-be-executed instruction in the target transaction is returned, and the execution of all to-be-executed instructions in the target transaction is completed. The above process fully utilizes the redundancy relationship between transactions, avoids repeated decoding of instructions, removes the redundancy between transactions, shortens the transaction execution time, and improves the transaction execution efficiency.

[0140] In one of the embodiments, the transaction execution module includes a plurality of functional units corresponding to instruction functions.

[0141] The target transaction execution module 940 is further configured to divide the instructions in the target cache line into a plurality of categories according to the instruction functions of the instructions in the smart contract, and distribute the instructions in each category and the operands required by the instructions to the functional units corresponding to the instruction functions for parallel execution.

[0142] In one of the embodiments, the target transaction execution module 940 is further configured to, if the instruction address of the current to-be-executed instruction in the target transaction does not exist in the preset bytecode cache, decode the current to-be-executed instruction, insert the decoded current to-be-executed instruction into the preset bytecode cache according to the dependency relationship between the current to-be-executed instruction and the instructions in the preset bytecode cache, update the instruction overhead of the preset bytecode cache, if the current remaining overhead of the target transaction is not less than the total instruction overhead recorded in the updated preset bytecode cache, take the cache line where the current to-be-executed instruction is located as a starting point, sequentially obtain the operands required by the instructions in each cache line, execute the bytecode of the instructions in each cache line according to the operands, if the execution of the instructions in the preset bytecode cache is completed, control the instruction address extraction module 950 to perform the operation of extracting the instruction address of the current to-be-executed instruction in the target transaction, and execute all instructions in the target transaction.

[0143] Each module in the aforementioned transaction scheduling and execution devices can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0144] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 11 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a transaction execution method or a transaction scheduling method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0145] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0146] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the transaction scheduling method or transaction execution method described above.

[0147] In one of the embodiments, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the transaction scheduling method or the transaction execution method.

[0148] In one of the embodiments, a computer program product is provided, and the computer program product includes a computer program, and the computer program is executed by a processor to implement the steps of the transaction scheduling method or the transaction execution method.

[0149] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of the related data need to comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0150] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.

[0151] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.

[0152] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A transaction scheduling method, characterized in that, Applied to a transaction scheduling module, the method includes: Obtain the transaction dependency graph and free transaction set of the block. The transaction dependency graph includes multiple dependent transactions with dependencies, and the free transaction set includes free transactions without dependencies. Based on the transaction dependency graph and the set of free transactions, multiple dependent transactions and multiple free transactions are selected. Add multiple dependent transactions and multiple free transactions to the transaction table, and send a transaction loading signal to multiple transaction execution modules so that the transaction execution modules load the transactions and execute them in parallel; When a load completion signal is received from the transaction execution module, a new transaction is selected from the transaction dependency graph and the free transaction set and added to the transaction table. The transaction dependency graph, the transaction table, and the preset scheduling table are then updated until all transactions in the block are detected to have been executed. The preset scheduling table includes dependency entries and redundancy entries for each transaction execution module. The dependency entry is a binary value that indicates whether there is a dependency relationship between the transaction entry and the transaction executed by the current transaction execution module. The redundancy entry is a binary value that indicates whether there is a redundancy relationship between the transaction entry and the transaction executed by the current transaction execution module. Updating the preset scheduling table includes: performing an XOR operation on the dependency entries of transaction execution modules other than the target transaction execution module to obtain the XOR result, wherein the target transaction execution module is the transaction execution module of the transaction to be loaded; performing a AND operation on the XOR result and the redundant entries of the target transaction execution module to obtain the AND result; selecting the next transaction to be executed for the target transaction execution module from the updated transaction table based on the AND result; and updating the preset scheduling table based on the next transaction to be executed for the target transaction execution module.

2. The transaction scheduling method according to claim 1, characterized in that, The step of selecting multiple dependent transactions and multiple free transactions based on the transaction dependency graph and the set of free transactions includes: Based on the transaction dependency graph, a first number of dependent transactions with an in-degree of zero are selected, and a second number of free transactions are selected based on the free transaction set. The first number and the second number are determined based on the number of transaction execution modules.

3. The transaction scheduling method according to claim 1, characterized in that, Updating the transaction dependency graph and the transaction table includes: Based on the selected new transaction, delete the corresponding transaction node in the transaction dependency graph; Based on the redundant dependencies between new transactions and currently executing transactions, update the transaction dependency graph and the weights of each transaction in the transaction table, as well as the synchronization lock status of transactions in the transaction table.

4. A transaction execution method, characterized in that, Applied to a transaction execution module, the method includes: Receive a transaction loading signal sent by the transaction scheduling module, wherein the transaction loading signal carries transaction identification information; Based on the transaction identifier information, the corresponding target transaction is selected from the transaction table, the target transaction is locked and loaded, and a loading completion signal is sent to the transaction scheduling module. The transaction table is obtained by the transaction scheduling module in the blockchain by executing the transaction scheduling method as described in any one of claims 1-3. Extract the instruction address of the currently pending instruction in the target transaction; If it is determined that the instruction address of the current instruction to be executed exists in the preset bytecode cache, and the current remaining overhead of the target transaction is not less than the total instruction overhead recorded in the preset bytecode cache, then starting from the cache line where the current instruction to be executed is located, the operands required by the instructions in each cache line are obtained in sequence, and the bytecode of the instructions in each cache line is executed according to the operands; If the instructions in the preset bytecode cache have been executed, then return to the step of extracting the instruction address of the instruction to be executed in the target transaction, until all instructions in the target transaction have been executed. In the preset bytecode cache, each cache line records the bytecode of instructions that do not have dependencies.

5. The transaction execution method according to claim 4, characterized in that, The transaction execution module includes multiple functional units corresponding to instruction functions; The execution of the bytecode of the instructions in each cache line based on the operands includes: Based on the instruction functions of the instructions in the smart contract instruction set, the instructions in each cache line are divided into multiple categories; The various types of instructions and the operands required by the instructions are assigned to the functional units corresponding to the function of the instructions for parallel execution.

6. The transaction execution method according to claim 4, characterized in that, The method further includes: If the instruction address of the instruction to be executed in the target transaction does not exist in the preset bytecode cache, the instruction to be executed is decoded, and according to the dependency relationship between the instruction to be executed and the instructions in the preset bytecode cache, the decoded instruction to be executed is inserted into the preset bytecode cache, and the instruction overhead of the preset bytecode cache is updated. If the current remaining overhead of the target transaction is not less than the total overhead of instructions recorded in the updated preset bytecode cache, then starting from the cache line where the instruction to be executed is located, the operands required by the instructions in each cache line are obtained sequentially, and the bytecode of the instructions in each cache line is executed according to the operands. If the instructions in the preset bytecode cache are executed, then the step of extracting the instruction address of the instruction to be executed in the target transaction is returned until all instructions in the target transaction are executed.

7. A transaction scheduling device, characterized in that, The device includes: The data acquisition module is used to acquire the transaction dependency graph and free transaction set of the block. The transaction dependency graph includes multiple dependent transactions with dependencies, and the free transaction set includes free transactions without dependencies. The transaction selection module is used to select multiple dependent transactions and multiple free transactions based on the transaction dependency graph and the set of free transactions. The transaction adding module is used to add multiple dependent transactions and multiple free transactions to the transaction table, and send transaction loading signals to multiple transaction execution modules so that the transaction execution modules load the transactions and execute the transactions in parallel. The data update module is used to select new transactions from the transaction dependency graph and the free transaction set and add them to the transaction table when it receives the load completion signal sent by the transaction execution module, and update the transaction dependency graph, the transaction table and the preset scheduling table until it is detected that all transactions in the block have been executed. The preset scheduling table includes dependency entries and redundancy entries for each transaction execution module. The dependency entry is a binary value that indicates whether there is a dependency relationship between the transaction entry and the transaction executed by the current transaction execution module. The redundancy entry is a binary value that indicates whether there is a redundancy relationship between the transaction entry and the transaction executed by the current transaction execution module. Updating the preset scheduling table includes: performing an XOR operation on the dependency entries of transaction execution modules other than the target transaction execution module to obtain the XOR result, wherein the target transaction execution module is the transaction execution module of the transaction to be loaded; performing a AND operation on the XOR result and the redundant entries of the target transaction execution module to obtain the AND result; selecting the next transaction to be executed for the target transaction execution module from the updated transaction table based on the AND result; and updating the preset scheduling table based on the next transaction to be executed for the target transaction execution module.

8. A transaction execution apparatus, characterized in that, The device includes: The signal receiving module is used to receive the transaction loading signal sent by the transaction scheduling module, wherein the transaction loading signal carries transaction identification information; The transaction loading module is used to select the corresponding target transaction from the transaction table according to the transaction identifier information, lock and load the target transaction, and send a loading completion signal to the transaction scheduling module. The transaction table is obtained by the transaction scheduling module in the blockchain by executing the transaction scheduling method as described in any one of claims 1-3. The instruction address extraction module is used to extract the instruction address of the instruction to be executed in the target transaction. The target transaction execution module is configured to, if it is determined that the instruction address of the currently to-be-executed instruction exists in a preset bytecode cache and the current remaining overhead of the target transaction is not less than the total instruction overhead recorded in the preset bytecode cache, then starting from the cache line where the currently to-be-executed instruction is located, sequentially obtain the operands required by the instructions in each cache line, execute the bytecode of the instructions in each cache line according to the operands, and if the instructions in the preset bytecode cache are executed, control the instruction address extraction module to execute the step of extracting the instruction address of the currently to-be-executed instruction in the target transaction, until all instructions in the target transaction are executed; In the preset bytecode cache, each cache line records the bytecode of instructions that do not have dependencies.

9. The transaction execution apparatus according to claim 8, characterized in that, The target transaction execution module is further configured to: if the instruction address of the currently to-be-executed instruction in the target transaction does not exist in the preset bytecode cache, decode the currently to-be-executed instruction, and insert the decoded currently to-be-executed instruction into the preset bytecode cache according to the dependency relationship between the currently to-be-executed instruction and the instructions in the preset bytecode cache, and update the instruction overhead of the preset bytecode cache; if the current remaining overhead of the target transaction is not less than the total instruction overhead recorded in the updated preset bytecode cache, then starting from the cache line where the currently to-be-executed instruction is located, sequentially obtain the operands required by the instructions in each cache line, execute the bytecode of the instructions in each cache line according to the operands, and if the instructions in the preset bytecode cache are executed, return to the step of extracting the instruction address of the currently to-be-executed instruction in the target transaction, until all instructions in the target transaction are executed.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1-3 or 4-6.

Citation Information

Patent Citations

  • Dependency-aware transaction batching for data replication

    US20150269215A1