Block chain transaction scheduling method and device, electronic equipment and storage medium
By scheduling according to resource consumption weight in blockchain transactions, the problem of resource waste in blockchain transactions is solved and network performance is improved.
Patent Information
- Application Number
- CN202310604744.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-25
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2043-05-25
AI Technical Summary
During the execution of blockchain transactions, conflicting transaction serial execution leads to waste of resources, reducing the performance of blockchain networks. The existing technology relies on preset sequence or chronological order for scheduling, and cannot effectively avoid excessive resource consumption The transaction is re-execute.
By obtaining multiple blockchain transactions to be executed, the conflict relationship between the target transaction and the reference transaction is determined, and the resource consumption weights of the target transaction and the reference transaction are scheduled, and the transactions that consume more resources are selected and the resources are re-executeed again Consume less transactions and avoid waste of resources.
It effectively improves the performance of the blockchain network, avoids resource waste, optimizes the transaction scheduling process, and improves system efficiency.
Smart Images

Figure CN119025176A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a scheduling method, device, electronic device and storage medium for blockchain transactions. Background Art
[0002] At present, during the execution of blockchain transactions, if there are conflicting blockchain transactions, the conflicting blockchain transactions will be executed serially, so it is necessary to schedule the blockchain transactions, that is, to retain one of the blockchain transactions and re-execute the remaining blockchain transactions. In the related art, blockchain transactions are generally retained based on a preset transaction order or the time sequence in which the blockchain transactions are executed. This method may cause blockchain transactions that consume more resources to be re-executed, resulting in resource waste and reducing the performance of the blockchain network. Summary of the invention
[0003] The following is a summary of the subject matter described in detail in this application. This summary is not intended to limit the scope of the claims.
[0004] The embodiments of the present application provide a method, device, electronic device and storage medium for scheduling blockchain transactions, which can avoid waste of resources and improve the performance of the blockchain network.
[0005] On the one hand, an embodiment of the present application provides a method for scheduling blockchain transactions, including:
[0006] Obtain multiple blockchain transactions to be executed, and execute each of the blockchain transactions;
[0007] Acquire a target transaction that has been executed from the plurality of blockchain transactions, and determine a first conflict relationship between the target transaction and at least one first reference transaction, wherein the first reference transaction is a blockchain transaction that has been currently executed except for the target transaction;
[0008] When the first conflict relationship indicates that there is a conflict between the target transaction and the first reference transaction, obtaining a first weight of the target transaction and a second weight of the first reference transaction, wherein the first weight is determined based on a resource consumption parameter for executing the target transaction, and the second weight is determined based on a resource consumption parameter for executing the first reference transaction;
[0009] The target transaction is scheduled according to the magnitude relationship between the first weight and the second weight.
[0010] On the other hand, the embodiment of the present application also provides a scheduling device for blockchain transactions, including:
[0011] An execution module, used to obtain multiple blockchain transactions to be executed and execute each of the blockchain transactions;
[0012] a conflict detection module, configured to obtain a target transaction that has been executed from the plurality of blockchain transactions, and determine a first conflict relationship between the target transaction and at least one first reference transaction, wherein the first reference transaction is a blockchain transaction that has been executed currently except for the target transaction;
[0013] a weight acquisition module, configured to acquire a first weight of the target transaction and a second weight of the first reference transaction when the first conflict relationship indicates that there is a conflict between the target transaction and the first reference transaction, wherein the first weight is determined based on a resource consumption parameter for executing the target transaction, and the second weight is determined based on a resource consumption parameter for executing the first reference transaction;
[0014] The first scheduling module is used to schedule the target transaction according to the relationship between the first weight and the second weight.
[0015] Furthermore, the first scheduling module is specifically used for:
[0016] Scheduling the target transaction according to a magnitude relationship between the first weight and each of the second weights;
[0017] Alternatively, the sum of the first weights of all the second weights is calculated, and the target transaction is scheduled according to the relationship between the first weight and the sum of the first weights.
[0018] Furthermore, the target transaction is obtained when all the blockchain transactions are executed, the first reference transaction is not added to the transaction snapshot, and the first scheduling module is specifically used to:
[0019] When the first weight is greater than each of the second weights, adding the target transaction to the transaction snapshot;
[0020] Alternatively, when the first weight is less than any of the second weights, re-execute the target transaction;
[0021] Alternatively, when the first weight is equal to at least one of the second weights, and the first weight is greater than the remaining second weights, the target transaction is added to the transaction snapshot or the target transaction is re-executed.
[0022] Furthermore, the first scheduling module is specifically used for:
[0023] taking the target transaction and the first reference transaction having the same weight as the target transaction as a first transaction set;
[0024] One of the blockchain transactions in the transaction set is added to the transaction snapshot, and the remaining blockchain transactions in the transaction set are re-executed.
[0025] Furthermore, the above-mentioned blockchain transaction scheduling device also includes:
[0026] The second scheduling module is used to take the blockchain transactions that have been re-executed and not added to the transaction snapshot as the target transactions whenever the blockchain transactions that have not been added to the transaction snapshot have been re-executed; and schedule the target transactions again until all the blockchain transactions are added to the transaction snapshot.
[0027] Furthermore, the target transaction is obtained whenever one of the blockchain transactions is executed, the first reference transaction is not added to the transaction snapshot, and the first scheduling module is specifically used to:
[0028] When the first weight is greater than the sum of the first weights, waiting for a preset time, and scheduling the target transaction after the preset time is reached;
[0029] Alternatively, when the first weight is less than the sum of the first weights, re-executing the target transaction;
[0030] Alternatively, when the first weight is equal to the sum of the first weights, wait for a preset time period and schedule the target transaction or re-execute the target transaction after the preset time period is reached.
[0031] Furthermore, the above-mentioned conflict detection module is specifically used for:
[0032] Determine a second conflict relationship between the target transaction and a second reference transaction, wherein the second reference transaction is the blockchain transaction other than the target transaction that has been currently executed and added to the transaction snapshot;
[0033] When the second conflict relationship indicates that there is no conflict between the target transaction and the second reference transaction, a first conflict relationship between the target transaction and at least one first reference transaction is determined.
[0034] Furthermore, the first scheduling module is specifically used for:
[0035] After the preset time period is reached, determining a third conflict relationship between the target transaction and at least one third reference transaction, wherein the third reference transaction is the blockchain transaction other than the target transaction that has been currently executed and has not been added to the transaction snapshot;
[0036] When the third conflict relationship indicates that there is a conflict between the target transaction and the third reference transaction, obtaining a third weight of the third reference transaction, wherein the third weight is determined based on a resource consumption parameter of executing the third reference transaction;
[0037] The sum of the second weights of all the third weights is calculated, and the target transaction is scheduled according to the relationship between the first weight and the sum of the second weights.
[0038] Furthermore, the first scheduling module is specifically used for:
[0039] When the first weight is greater than the sum of the second weights, adding the target transaction to the transaction snapshot;
[0040] Alternatively, when the first weight is less than the sum of the second weights, re-executing the target transaction;
[0041] Alternatively, when the first weight is equal to the sum of the second weights, the target transaction is added to the transaction snapshot or the target transaction is re-executed.
[0042] Furthermore, the first scheduling module is specifically used for:
[0043] Determining a fourth conflict relationship between the target transaction and a fourth reference transaction, wherein the fourth reference transaction is the blockchain transaction other than the target transaction that has been currently executed and has been added to the transaction snapshot;
[0044] When the fourth conflict relationship indicates that there is no conflict between the target transaction and the fourth reference transaction, a third conflict relationship between the target transaction and at least one third reference transaction is determined.
[0045] Furthermore, the above-mentioned blockchain transaction scheduling device also includes:
[0046] A third scheduling module is configured to use the blockchain transaction that has been re-executed and not added to the transaction snapshot as the target transaction whenever the blockchain transaction that has not been added to the transaction snapshot is re-executed;
[0047] The target transaction is scheduled again until all the blockchain transactions are added to the transaction snapshot.
[0048] Furthermore, the target transaction is obtained whenever one of the blockchain transactions is executed, the first reference transaction has been added to the transaction snapshot, and the first scheduling module is specifically used to:
[0049] When the first weight is greater than the sum of the first weights, replacing the first reference transaction in the transaction snapshot with the target transaction;
[0050] Alternatively, when the first weight is less than the sum of the first weights, re-executing the target transaction;
[0051] Alternatively, when the first weight is equal to the first weight sum, the first reference transaction in the transaction snapshot is replaced with the target transaction or the target transaction is re-executed.
[0052] Furthermore, the above-mentioned blockchain transaction scheduling device also includes:
[0053] The fourth scheduling module is used to re-execute the first reference transaction that has been replaced in the transaction snapshot; whenever the replaced first reference transaction is re-executed, the re-executed first reference transaction is used as the target transaction; and the target transaction is scheduled again until all the blockchain transactions are added to the transaction snapshot.
[0054] Further, the resource consumption parameter includes at least one of the transaction execution time of the blockchain transaction, the number of read set keys of the blockchain transaction, the read set memory size of the blockchain transaction, the number of write set keys of the blockchain transaction and the write set memory size of the blockchain transaction, and the weight acquisition module is specifically used for:
[0055] Determine a score value corresponding to at least one of the transaction execution time, the number of read set keys, the read set memory size, the number of write set keys, and the write set memory size of the target transaction;
[0056] The first weight is obtained according to at least one of the score values.
[0057] On the other hand, an embodiment of the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned blockchain transaction scheduling method when executing the computer program.
[0058] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is executed by a processor to implement the above-mentioned blockchain transaction scheduling method.
[0059] On the other hand, the embodiment of the present application further provides a computer program product, which includes a computer program stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the scheduling method for implementing the above-mentioned blockchain transaction.
[0060] The embodiments of the present application include at least the following beneficial effects: by executing multiple blockchain transactions, taking the executed blockchain transactions as target transactions, and scheduling the conflicting target transactions and the first reference transaction, first obtain the first weight of the target transaction and the second weight of the first reference transaction. Since the first weight and the second weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the size relationship between the first weight and the second weight is equivalent to scheduling the target transaction according to the resource consumption parameter, so that when scheduling the target transaction, it is possible to retain the blockchain transaction with more resource consumption and re-execute the blockchain transaction with less resource consumption, thereby avoiding resource waste and improving the performance of the blockchain network.
[0061] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent from the description, or may be understood by practicing the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0063] Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present application;
[0064] Figure 2 An optional flowchart of a method for scheduling blockchain transactions provided in an embodiment of the present application;
[0065] Figure 3 An optional flow chart before the deterministic scheduling optimization provided in the embodiment of the present application;
[0066] Figure 4 An optional flow chart of the optimized deterministic scheduling provided in the embodiment of the present application;
[0067] Figure 5 An optional flowchart of the first scheduling link provided in an embodiment of the present application;
[0068] Figure 6 An optional flow chart of the second scheduling link provided in an embodiment of the present application;
[0069] Figure 7 A schematic diagram of an optional architecture before non-deterministic scheduling optimization provided in an embodiment of the present application;
[0070] Figure 8 A schematic diagram of an optional architecture after non-deterministic scheduling optimization provided in an embodiment of the present application;
[0071] Fig. 9 A schematic diagram of an optional process flow after non-deterministic scheduling optimization provided in an embodiment of the present application;
[0072] Fig.10 Another optional flow chart after non-deterministic scheduling optimization provided in an embodiment of the present application;
[0073] Fig.11 A schematic diagram of an optional process of block verification between nodes provided in an embodiment of the present application;
[0074] Fig.12 An optional structural diagram of a scheduling device for blockchain transactions provided in an embodiment of the present application;
[0075] Fig.13 Another optional structural diagram of the scheduling device for blockchain transactions provided in an embodiment of the present application;
[0076] Fig.14 Another optional structural diagram of the scheduling device for blockchain transactions provided in an embodiment of the present application;
[0077] Fig.15 Another optional structural diagram of the scheduling device for blockchain transactions provided in an embodiment of the present application;
[0078] Fig.16 A partial structural block diagram of a terminal provided in an embodiment of the present application;
[0079] Fig.17 A partial structural block diagram of the server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0080] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0081] It should be noted that in each specific embodiment of the present application, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards. Among them, the target object can be a user. In addition, when the embodiment of the present application needs to obtain the target object attribute information, the target object's separate permission or separate consent will be obtained by means of a pop-up window or jumping to a confirmation page, etc., and after the separate permission or separate consent of the target object is clearly obtained, the necessary target object-related data for enabling the normal operation of the embodiment of the present application will be obtained.
[0082] To facilitate understanding of the technical solutions provided in the embodiments of the present application, some key terms used in the embodiments of the present application are explained here:
[0083] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer. The underlying blockchain platform can include processing modules such as user management, basic services, smart contracts, and operation detection. Among them, the user management module is responsible for the identity information management of all blockchain participants, including maintaining the generation of public and private keys (account management), key management, and the maintenance of the corresponding relationship between the user's real identity and the blockchain address (authority management), and, under authorization, supervises and audits the transactions of certain real identities and provides risk control rule configuration (risk control audit); the basic service module is deployed on all blockchain node devices to verify the validity of business requests and record the valid requests to the storage after consensus is reached. For a new business request, the basic service first adapts the interface to parse and authenticate (interface adaptation), and then encrypts the business information through the consensus algorithm (consensus management). The smart contract module is responsible for the registration and issuance of contracts, contract triggering and contract execution. Developers can define the contract logic in a programming language and publish it to the blockchain (contract registration). According to the logic of the contract terms, the key or other events are called to trigger the execution and complete the contract logic. It also provides the function of contract upgrade and cancellation. The operation detection module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation and real-time status visualization output of the product during the product release process, such as alarm, network status detection, node equipment health status detection, etc. The platform product service layer provides the basic capabilities and implementation framework of typical applications. Developers can implement the business logic on the blockchain based on these basic capabilities and superimpose the characteristics of the business. The application service layer provides application services based on the blockchain solution for business participants to use.
[0084] Cloud computing refers to the delivery and use model of IT infrastructure, which means obtaining required resources through the network in an on-demand and easily scalable manner; in a broad sense, cloud computing refers to the delivery and use model of services, which means obtaining required services through the network in an on-demand and easily scalable manner. This service can be related to IT and software, the Internet, or other services. Cloud computing is the product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing.
[0085] At present, during the execution of blockchain transactions, if there are conflicting blockchain transactions, the conflicting blockchain transactions will be executed serially, so it is necessary to schedule the blockchain transactions, that is, to retain one of the blockchain transactions and re-execute the remaining blockchain transactions. In the related art, blockchain transactions are generally retained based on a preset transaction order or the time sequence in which the blockchain transactions are executed. This method may cause blockchain transactions that consume more resources to be re-executed, resulting in resource waste and reducing the performance of the blockchain network.
[0086] Based on this, the embodiments of the present application provide a scheduling method, device, electronic device and storage medium for blockchain transactions, which can avoid resource waste and improve the performance of the blockchain network.
[0087] Reference Figure 1 , Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present application, the implementation environment includes a terminal 101 and a server 102, wherein the terminal 101 and the server 102 are connected via a communication network, and the number of the terminals 101 can be one or more.
[0088] Exemplarily, any terminal 101 can send a blockchain transaction to be executed to the server 102, any two terminals 101 can send different blockchain transactions, and the same terminal 101 can also send different blockchain transactions. The server 102 can obtain multiple blockchain transactions to be executed and execute each blockchain transaction; obtain a target transaction that has been executed from multiple blockchain transactions, and determine a first conflict relationship between the target transaction and at least one first reference transaction, wherein the first reference transaction is a blockchain transaction that has been currently executed except for the target transaction; when the first conflict relationship indicates that there is a conflict between the target transaction and the first reference transaction, obtain a first weight of the target transaction and a second weight of the first reference transaction, wherein the first weight is determined based on the resource consumption parameters of executing the target transaction, and the second weight is determined based on the resource consumption parameters of executing the first reference transaction; schedule the target transaction according to the size relationship between the first weight and the second weight.
[0089] The server 102 executes multiple blockchain transactions and takes the executed blockchain transactions as target transactions. When scheduling the conflicting target transactions and the first reference transaction, the server 102 first obtains the first weight of the target transaction and the second weight of the first reference transaction. Since the first weight and the second weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the relationship between the first weight and the second weight is equivalent to scheduling the target transaction according to the resource consumption parameter. Therefore, when scheduling the target transaction, it is possible to retain the blockchain transaction with more resource consumption and re-execute the blockchain transaction with less resource consumption, thereby avoiding resource waste and improving the performance of the blockchain network.
[0090] Server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. In addition, server 102 can also be a node server in a blockchain network.
[0091] The terminal 101 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a vehicle-mounted terminal, etc., but is not limited thereto. The terminal 101 and the server 102 may be directly or indirectly connected via wired or wireless communication, which is not limited in the present embodiment.
[0092] The method provided in the embodiments of the present application can be applied to various technical fields, including but not limited to cloud computing, blockchain and other technical fields.
[0093] Reference Figure 2 , Figure 2 An optional flow chart of a method for scheduling blockchain transactions provided in an embodiment of the present application, the method for scheduling blockchain transactions can be executed by a server, or can also be executed by a terminal, or can also be executed by a server in cooperation with a terminal, and the method for scheduling blockchain transactions includes but is not limited to the following steps 201 to 204.
[0094] Step 201: Obtain multiple blockchain transactions to be executed, and execute each blockchain transaction;
[0095] Among them, blockchain transactions refer to transactions generated in the blockchain network. Blockchain nodes in the blockchain network can execute blockchain transactions. Blockchain nodes store ledgers, which include blockchains and world state databases. The world state database is a database that stores the current status of all state data. The world state refers to the current status of all state data. The blockchain is used to record the historical transactions involved in the process of changing all state data from the initial state to the current state. Among them, the state data can be stored in the form of key-value pairs. The current state refers to the key of the state data, the value corresponding to the key, and the current version number; the execution of blockchain transactions by blockchain nodes refers to reading or writing state data. If the blockchain transaction is used to read state data, the blockchain transaction will contain the key of the state data. If the blockchain transaction is used to write state data, the blockchain transaction will contain the key of the state data and the value corresponding to the key.
[0096] Exemplarily, the first blockchain transaction is used to read the first state data and write the second state data. The first blockchain transaction includes the key key1 of the first state data, the key key2 of the second state data, and the value value2' of the key key2. When the first blockchain transaction is executed, the value value1 corresponding to the key key1 is read from the world state database. At this time, the current version number of the key key1 in the world state database will not change. Then the value value2' corresponding to the key key2 is written into the world state database, and the version number corresponding to the key key2 in the world state database will change. For example, before executing the first blockchain transaction, the world state database stores the key key2, the value corresponding to the key key2 is value2, and the current version number corresponding to the key key2 is 1. After executing the first blockchain transaction, the current version number corresponding to the key key2 is increased by one, the value corresponding to the key key2 is updated to value2', and the current version number corresponding to the key key2 is updated to 2.
[0097] Based on this, in an embodiment of the present application, after a blockchain node obtains multiple blockchain transactions to be executed, the blockchain node can use multiple threads to concurrently execute blockchain transactions. It can be understood that threads can also be replaced by execution bodies such as processes and coroutines. Each thread executes one of the blockchain transactions, and each blockchain transaction needs to correspond to the same initial world state, which is equivalent to the execution environment of each thread being the same. Specifically, the current world state is obtained from the world state database, and the current world state is used as the initial world state. Then, each thread executes the corresponding blockchain transaction based on the same initial world state.
[0098] Exemplarily, a batch of blockchain transactions to be executed is obtained, the number of blockchain transactions to be executed is 20, and then based on the same initial world state, 20 blockchain transactions are executed concurrently using multiple threads. After all 20 blockchain transactions are executed, the intermediate world state corresponding to each blockchain exchange can be obtained. Generally speaking, due to the differences between different blockchain transactions, the intermediate world states corresponding to each blockchain exchange are different. Therefore, 20 different intermediate world states can be obtained.
[0099] Step 202: Obtaining a target transaction that has been executed from multiple blockchain transactions, and determining a first conflict relationship between the target transaction and at least one first reference transaction;
[0100] The first reference transaction is a blockchain transaction that has been executed except for the target transaction.
[0101] Among them, the execution time of different blockchain transactions may be different. When a blockchain transaction is executed, the executed blockchain transaction can be used as a target transaction. If no other blockchain transactions are executed when the target transaction is executed, it means that at the moment when the target transaction is executed, there is no conflict between other blockchain transactions and the target transaction; conversely, if other blockchain transactions have been executed when the target transaction is executed, it means that at the moment when the target transaction is executed, there may be conflicts between other blockchain transactions and the target transaction. Therefore, the currently executed blockchain transaction other than the target transaction is used as the first reference transaction, and conflict detection is performed on the target transaction and the first reference transaction to determine the first conflict relationship between the target transaction and the first reference transaction, wherein the first conflict relationship is used to indicate whether there is a conflict between the target transaction and the first reference transaction.
[0102] Exemplarily, based on the above content about using multiple threads to concurrently execute 20 blockchain transactions, it can be known that after all 20 blockchain transactions are executed, 20 corresponding intermediate world states can be obtained. Since corresponding read sets and write sets are created for each blockchain transaction during the execution of each blockchain transaction; the read set is used to indicate the state data read by executing the blockchain transaction, so the read set includes the key of the read state data, and the submission version number corresponding to the key, and the read set may also include the value corresponding to the key of the read state data; the write set is used to indicate the state data inserted, deleted or updated by executing the blockchain transaction, so the write set includes the key of the written state data, and the value corresponding to the key. The read set and write set of blockchain transactions can be collectively referred to as the read-write set of blockchain transactions.
[0103] Among them, in multiple blockchain transactions executed serially, when the blockchain transaction with an earlier execution order is executed and the current state of the corresponding state data is updated, the current version number corresponding to the key will change. When the blockchain transaction with an earlier execution order is executed and the state data needs to be read, the current version number corresponding to the key of the state data will be read. If the version number corresponding to the key is updated when the blockchain transaction with an earlier execution order is executed, the current version number corresponding to the key is the updated version number. The updated version number is used as the submitted version number corresponding to the key and recorded in the read set.
[0104] Therefore, executing 20 blockchain transactions can obtain 20 read-write sets. Under ideal conditions, any two read-write sets do not intersect with each other. Two read-write sets do not intersect with each other means that the two read-write sets do not contain the same key. At this time, the above 20 blockchain transactions can be executed in parallel, and the 20 intermediate world states obtained by the execution can be directly merged to obtain the final world state, and then the final world state is used as the execution result of this batch of blockchain transactions; usually, there will be at least one pair of intersecting read-write sets. The intersection of two read-write sets means that the two read-write sets contain at least one identical key. When the read-write set of one blockchain transaction intersects with the read-write set of another blockchain transaction, it is equivalent to that the two blockchain transactions conflict with each other, and each conflicting blockchain transaction needs to be executed serially.
[0105] Step 203: When the first conflict relationship indicates that there is a conflict between the target transaction and the first reference transaction, obtain a first weight of the target transaction and a second weight of the first reference transaction;
[0106] Wherein, the first weight is determined based on the resource consumption parameter of executing the target transaction, and the second weight is determined based on the resource consumption parameter of executing the first reference transaction;
[0107] The resource consumption parameter is used to indicate the resources consumed for executing the blockchain transaction. The resource may be a time resource, a memory resource, etc. For example, when the resource is a time resource, the resource consumption parameter may be the execution time of the blockchain transaction. When the resource is a memory resource, the resource consumption parameter may be at least one of the number of read set keys, the read set memory size, the number of write set keys, and the write set memory size.
[0108] Among them, when the first conflict relationship indicates that there is a conflict between the target transaction and the first reference transaction, it means that the target transaction and the first reference transaction need to be executed serially, and the first weight of the target transaction is determined based on the resource consumption parameters of executing the target transaction, and the second weight of the first reference transaction is determined based on the resource consumption parameters of executing the first reference transaction, and then the target transaction and the first reference transaction are scheduled according to the weight between the first weight of the target transaction and the second weight of the first reference transaction.
[0109] Step 204: Schedule the target transaction according to the relationship between the first weight and the second weight.
[0110] Among them, since the first weight and the second weight are both determined based on the resource consumption parameters, scheduling the target transaction according to the size relationship between the first weight and the second weight is equivalent to scheduling the target transaction according to the resource consumption parameters, so that when scheduling the target transaction, it is possible to retain blockchain transactions with more resource consumption and re-execute blockchain transactions with less resource consumption, thereby avoiding resource waste and improving the performance of the blockchain network.
[0111] In a possible implementation, the target transaction is scheduled according to the relationship between the first weight and the second weight, which may be:
[0112] Scheduling the target transaction according to the relationship between the first weight and each second weight;
[0113] Alternatively, the sum of the first weights of all the second weights is calculated, and the target transaction is scheduled according to the relationship between the first weight and the sum of the first weights.
[0114] Among them, the size relationship between the first weight and each second weight means that the first weight is greater than the second weight, or the first weight is less than the second weight, or the first weight is equal to the second weight; the size relationship between the first weight and the sum of the first weights means that the first weight is greater than the sum of the first weights, or the first weight is less than the sum of the first weights, or the first weight is equal to the sum of the first weights.
[0115] Among them, by comparing the first weight and each second weight, it is possible to effectively determine whether the resource consumption of executing the target transaction is greater than the resource consumption of executing each first reference transaction, thereby retaining the blockchain transaction with more resource consumption and re-executing the blockchain transaction with less resource consumption, thereby avoiding resource waste and improving the performance of the blockchain network.
[0116] In a possible implementation, the target transaction is acquired when all blockchain transactions are executed, and the first reference transaction is not added to the transaction snapshot. The target transaction is scheduled according to the relationship between the first weight and each second weight, which may be:
[0117] When the first weight is greater than each second weight, adding the target transaction to the transaction snapshot;
[0118] Alternatively, when the first weight is less than any second weight, re-execute the target transaction;
[0119] Alternatively, when the first weight is equal to at least one second weight, and the first weight is greater than the remaining second weights, the target transaction is added to the transaction snapshot or the target transaction is re-executed.
[0120] Among them, the transaction snapshot refers to the completion queue of the blockchain transaction. When the blockchain transaction is executed, the executed blockchain is added to the transaction snapshot, which is equivalent to adding the executed blockchain to the end of the completion queue. When multiple blockchain transactions are executed concurrently using multiple threads, the number of completion queues can be multiple, and the number of completion queues depends on the number of blockchain transactions that can be executed in parallel; multiple blockchain transactions that are in conflict with each other correspond to the same completion queue. The blockchain transaction that is added to the transaction snapshot first is at the front of the completion queue, and the blockchain transaction that is added to the transaction snapshot later is at the back of the completion queue. Subsequently, the blockchain transactions that are in conflict with each other can be executed in sequence according to the order in the completion queue.
[0121] Among them, the blockchain transactions can be scheduled in a deterministic scheduling manner, and the execution result of each blockchain transaction is determined. The deterministic scheduling performs conflict detection on the blockchain transactions in a round-by-round manner. In the deterministic scheduling, the time point of the conflict detection is configured as follows: when all blockchain transactions are executed, conflict detection is performed on each executed blockchain transaction respectively to determine the conflict relationship between each executed blockchain transaction. For example, in the first round, conflict detection is performed on the blockchain transactions only when all blockchain transactions are executed to determine the conflict relationship between each blockchain transaction. The result of the conflict detection may be that there is no conflict between multiple blockchain transactions, and the result of the conflict detection may also be that there is a conflict between multiple blockchain transactions. The result of the conflict detection is that there is a conflict or no conflict between multiple blockchain transactions. When the result of the conflict detection indicates that there is no conflict between multiple blockchain transactions, it means that the multiple blockchain transactions can be executed in parallel. When the result of the conflict detection indicates that there is a conflict between multiple blockchain transactions, it means that the multiple blockchain transactions need to be executed serially.
[0122] Therefore, for multiple blockchain transactions that conflict with each other, in the current round, only one of the blockchain transactions is retained and added to the transaction snapshot, and the remaining blockchain transactions are re-executed in the next round. Since deterministic scheduling handles conflicts between transactions in a round-by-round manner, in the next round, conflict detection is performed on the blockchain transactions only when all blockchain transactions that need to be re-executed have been re-executed; therefore, in deterministic scheduling, the target transaction is obtained when all blockchain transactions have been executed, and the first reference transaction to be conflict detected has not been added to the transaction snapshot, and there is no need to perform conflict detection on the first reference transaction that has been added to the transaction snapshot.
[0123] At present, when a deterministic scheduling method is used to schedule multiple conflicting blockchain transactions, the blockchain transaction that is executed first is added to the transaction snapshot in the order in which the blockchain transactions are executed, and the remaining blockchain transactions are re-executed. This may cause the blockchain transactions that consume more resources to be re-executed, thereby causing resource waste and reducing the performance of the blockchain network.
[0124] Based on this, the scheduling method provided in the embodiment of the present application can optimize deterministic scheduling. When scheduling the conflicting target transaction and the first reference transaction, the first weight of the target transaction and the second weight of the first reference transaction are first obtained. Since the first weight and the second weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the size relationship between the first weight and the second weight is equivalent to scheduling the target transaction according to the resource consumption parameter. The resource consumption parameter is used to indicate the resources required to execute the blockchain transaction. The first weight is used to indicate the resources required to execute the target transaction. The second weight is used to indicate the resources required to execute the first reference transaction. When the resources required to execute the target transaction are small, the first weight of the target transaction is small. Conversely, when the resources required to execute the target transaction are large, the first weight of the target transaction is large. Similarly, when the resources required to execute the first reference transaction are small, the second weight of the first reference transaction is small. Conversely, when the resources required to execute the first reference transaction are large, the second weight of the first reference transaction is large.
[0125] Specifically, for the three comparison situations of the first weight and the second weight, when the first weight is the largest, the target transaction is retained and added to the transaction snapshot; when the first weight is less than any second weight, the target transaction is re-executed; when the first weight is the same as part of the second weights and the first weight is greater than the remaining second weights, the target transaction can be added to the transaction snapshot or re-executed. This allows for the retention of blockchain transactions that consume more resources and the re-execution of blockchain transactions that consume less resources when scheduling the target transaction, thereby avoiding waste of resources and improving the performance of the blockchain network.
[0126] Exemplarily, for three blockchain transactions A, B, and C that conflict with each other, before executing the blockchain transactions, the sequence numbers of the three blockchain transactions can be determined as: A < B < C. When starting to execute these three blockchain transactions simultaneously, the first-round execution results will definitely be A, B, and C. Assume that the order of the resources consumed by executing these three blockchain transactions is: A < B < C. In the first round, when all three blockchain transactions have been executed, conflict detection is performed on the blockchain transactions. Since blockchain transaction A, blockchain transaction B, and blockchain transaction C conflict with each other, scheduling needs to be performed on blockchain transaction A, blockchain transaction B, and blockchain transaction C. One of the blockchain transactions is used as the target transaction, and the remaining blockchain transactions are used as the first reference transactions. When blockchain transaction A is the target transaction and blockchain transactions B and C are the first reference transactions, the first weight of blockchain transaction A is less than the second weight of blockchain transaction B, and at the same time, the first weight of blockchain transaction A is less than the second weight of blockchain transaction C. Therefore, in the next round, blockchain transaction A is re-executed. Similarly, when blockchain transaction B is the target transaction, it can be determined that blockchain transaction B needs to be re-executed in the next round. In the next round, blockchain transactions A and B can start executing simultaneously; when blockchain transaction C is the target transaction, the first weight of blockchain transaction C is greater than the second weight of blockchain transaction A, and the first weight of blockchain transaction C is greater than the second weight of blockchain transaction B. Therefore, blockchain transaction C is added to the transaction snapshot; thus, during the conflict handling in the first round, it is possible to retain the blockchain transaction C that consumes more resources and add this blockchain transaction C to the transaction snapshot, and re-execute the blockchain transactions A and B that consume less resources. Similarly, during the conflict handling in the second round, it is possible to retain the blockchain transaction B that consumes more resources and add this blockchain transaction B to the transaction snapshot, and re-execute the blockchain transaction A that consumes less resources, avoiding resource waste and improving the performance of the blockchain network.
[0127] In a possible implementation manner, adding the target transaction to the transaction snapshot or re-executing the target transaction can specifically be taking the target transaction and the first reference transactions with the same weight as the target transaction as the first transaction set; adding one of the blockchain transactions in the transaction set to the transaction snapshot and re-executing the remaining blockchain transactions in the transaction set; based on this, when dealing with the situation where the first weight is the same as some of the second weights and the first weight is greater than the remaining second weights, taking the target transaction and the first reference transactions with the same weight as the target transaction as the first transaction set, and then in the first transaction set, selecting the blockchain transaction to be added to the transaction snapshot and selecting the blockchain transaction to be re-executed, so that the conflicting blockchain transactions can be executed serially.
[0128] Among them, the selection can be made in a random selection manner. Specifically, a blockchain transaction is randomly selected in the first transaction set and added to the transaction snapshot, and the remaining blockchain transactions in the first transaction set are re-executed. When all blockchain transactions are added to the transaction snapshot, in the results of each random selection, whether it is selected to add the transaction snapshot to the transaction snapshot, or to select to add the remaining blockchain transactions to the transaction snapshot, it can be ensured that conflicting blockchain transactions can be executed serially.
[0129] Based on this, when random selection is used for selection, the execution order of multiple blockchain transactions executed in series is not fixed, but as long as the execution results obtained after all blockchain transactions are executed are the same, consensus can be achieved later; the execution process of blockchain transactions is: first call the transaction execution function in the smart contract, and then process the historical transaction data according to the transaction execution function and the blockchain transaction, wherein there can be multiple smart contracts, and multiple transaction execution functions can be deployed in one smart contract. Therefore, it is necessary to call the corresponding transaction execution function in the corresponding smart contract. The historical transaction data refers to the state data in the initial world state before the execution of the blockchain transaction, and the execution result of the blockchain transaction is the final world state after the execution of the blockchain transaction; therefore, when non-conflicting blockchain transactions are executed in parallel, and when conflicting blockchain transactions are executed in series, changing the execution order of multiple blockchain transactions executed in series can also make the final world state obtained after all blockchain transactions are executed the same.
[0130] Among them, the state data can be stored in the form of key-value pairs. Different blockchain transactions can be used to process the state data corresponding to different keys, and can also be used to process the state data corresponding to the same key. When different blockchain transactions are used to process the state data corresponding to the same key, and the blockchain transactions are executed in parallel, there will be conflicts between the blockchain transactions.
[0131] Exemplarily, there are three blockchain transactions to be executed, as follows: the first blockchain transaction is a transfer of 100 yuan from the first object to the second object through its own account, the second blockchain transaction is a transfer of 200 yuan from the first object to the third object through its own account, and the third blockchain transaction is a transfer of 200 yuan from the fourth object to the fifth object through its own account;
[0132] Before executing each blockchain transaction, the corresponding state data in the initial world state is as follows: the first historical transaction data is that there is 500 yuan in the account of the first object, and the second historical transaction data is that there is 300 yuan in the account of the fourth object;
[0133] Through conflict detection, it can be determined that the first blockchain transaction and the second blockchain transaction conflict with each other, the first blockchain transaction and the second blockchain transaction need to be executed serially, and the third blockchain transaction does not conflict with the remaining blockchain transactions, and the third blockchain transaction can be executed in parallel with the remaining blockchain transactions;
[0134] Assuming that the resources consumed by executing the first blockchain transaction and executing the second blockchain transaction are the same, it is equivalent to that the weights of the first blockchain transaction and the second blockchain transaction are the same, and a random selection method can be used for selection;
[0135] In the first case: first call the first transaction execution function to execute the first blockchain transaction, process the first historical transaction data, and obtain the first execution result that the first object has 400 yuan in its account. Then use the first execution result as the historical transaction data, call the second transaction execution function to execute the second blockchain transaction, process the first execution result, and obtain the second execution result that the first object has 200 yuan in its account. During the execution of the first blockchain transaction and the second blockchain transaction, the third blockchain transaction can be executed in parallel, call the third transaction execution function to execute the third blockchain transaction, process the third historical transaction data, and obtain the third execution result that the fourth object has 100 yuan in its account. Therefore, the final world state after all blockchain transactions are executed is: the first object has 200 yuan in its account, and the fourth object has 100 yuan in its account.
[0136] In the second case: first call the second transaction execution function to execute the second blockchain transaction, process the first historical transaction data, and obtain the first execution result that the first object has 300 yuan in its account, then use the first execution result as the historical transaction data, call the first transaction execution function to execute the first blockchain transaction, process the first execution result, and obtain the second execution result that the first object has 200 yuan in its account; during the execution of the first blockchain transaction and the second blockchain transaction, the third blockchain transaction can be executed in parallel, call the third transaction execution function to execute the third blockchain transaction, process the third historical transaction data, and obtain the third execution result that the fourth object has 100 yuan in its account. Therefore, the final world state obtained after all blockchain transactions are executed is: the first object has 200 yuan in its account, and the fourth object has 100 yuan in its account.
[0137] It can be seen that compared with the first case, the final world state obtained after all blockchain transactions are executed is not changed in the second case; therefore, when non-conflicting blockchain transactions are executed in parallel, and when conflicting blockchain transactions are executed serially, changing the execution order of multiple blockchain transactions executed serially can also make the final world state obtained after all blockchain transactions are executed the same.
[0138] Specifically, the blockchain transaction at a fixed position in the first transaction set is added to the transaction snapshot, and the remaining blockchain transactions in the first transaction set are re-executed; assuming that each blockchain transaction is arranged in order in the first transaction set, the fixed position may be the first or the last, therefore, the blockchain transaction at the first or the last in the first transaction set is added to the transaction snapshot; the fixed position may also be in the middle position, when the number of blockchain transactions in the first transaction set is an even number, half of the value of the number of transactions is used as the value of the middle position, for example, the number of transactions is 4, and the value of the middle position is 2, therefore, the blockchain transaction at the second position in the first transaction set is added to the transaction snapshot; similarly, the fixed selection method will not affect the execution result of the blockchain transaction.
[0139] In a possible implementation, the blockchain transaction scheduling method further includes:
[0140] Whenever all blockchain transactions that have not been added to the transaction snapshot are re-executed, the blockchain transactions that have been re-executed and not added to the transaction snapshot are used as target transactions;
[0141] The target transaction is scheduled again until all blockchain transactions are added to the transaction snapshot.
[0142] Among them, the target transaction can be scheduled in a deterministic scheduling manner. The deterministic scheduling is to perform conflict detection on blockchain transactions in a round-by-round manner. For example, in the first round, conflict detection is performed on blockchain transactions only when all blockchain transactions have been executed to determine the conflict relationship between each blockchain transaction. The result of the conflict detection may be that there is no conflict between multiple blockchain transactions, or the result of the conflict detection may be that there is a conflict between multiple blockchain transactions. The result of the conflict detection is that there is a conflict or no conflict between multiple blockchain transactions. When the result of the conflict detection indicates that there is no conflict between multiple blockchain transactions, it means that the multiple blockchain transactions can be executed in parallel. Therefore, when the target transaction does not conflict with each first reference transaction, the target transaction can be added to the transaction snapshot without re-executing the target transaction; however, when the result of the conflict detection indicates that there is a conflict between multiple blockchain transactions, it means that the multiple blockchain transactions need to be executed serially.
[0143] Therefore, when the target transaction conflicts with the first reference transaction, the target transaction cannot be executed in parallel with the conflicting first reference transaction. The target transaction is scheduled according to the relationship between the first weight and the second weight. Specifically, in the current round, for the conflicting blockchain transactions, the blockchain transaction with the largest weight is added to the transaction snapshot, and the blockchain transaction with a smaller weight is re-executed in the next round. In addition, in the second round, after all blockchain transactions that need to be re-executed have been re-executed, the re-executed blockchain transactions are conflict-detected. The re-executed blockchain transactions are equivalent to the target transactions in the first round. Therefore, the target transaction can be scheduled again according to the scheduling method of the first round. It can be seen that in the current round, if there are still conflicting blockchain transactions, it is necessary to re-execute the blockchain transactions with a smaller weight, and then schedule the target transaction again in the next round until entering a round where there are no conflicting blockchain transactions. At the end of this round, the scheduling of the target transaction is completed, which is equivalent to all blockchain transactions being added to the transaction snapshot.
[0144] Specifically, refer to Figure 3 , Figure 3 An optional flow chart before deterministic scheduling optimization provided in an embodiment of the present application adds the first executed blockchain transaction to the transaction snapshot in the order in which the blockchain transactions are executed, and re-executes the remaining blockchain transactions. This may cause the blockchain transactions that consume a lot of resources to be re-executed, thereby resulting in a waste of resources and reducing the performance of the blockchain network.
[0145] In addition, refer to Figure 4 , Figure 4 An optional flow diagram after deterministic scheduling optimization provided in an embodiment of the present application, six blockchain transactions are executed in parallel, and the six blockchain transactions are: Tx0, Tx1, Tx2, Tx3, Tx4 and Tx5, the execution time of Tx0 is 3 seconds, the execution time of Tx1 is 1 second, the execution time of Tx2 is 2 seconds, the execution time of Tx3 is 4 seconds, the execution time of Tx4 is 2 seconds, and the execution time of Tx5 is 4 seconds, the preset duration is 1 second, based on the resources consumed by executing each blockchain transaction, it can be determined that the weight of Tx0 is 30, the weight of Tx1 is 10, the weight of Tx2 is 20, the weight of Tx3 is 40, the weight of Tx4 is 20, and the weight of Tx5 is 40;
[0146] In the first round, when all blockchain transactions have been executed, conflict detection is performed on each blockchain transaction. For example, Tx0 is used as the target transaction, and other blockchain transactions that have been executed and not added to the transaction snapshot are used as the first reference transactions. The first reference transactions include: Tx1, Tx2, Tx3, Tx4 and Tx5. Then, the first conflict relationship between the target transaction and each first reference transaction is determined. Since the read-write sets of Tx0, Tx2 and Tx5 all contain key k1, while the read-write sets of Tx1, Tx3 and Tx4 do not contain key k1, after conflict detection, it can be determined that there is a conflict between Tx0 and Tx2, and there is a conflict between Tx0 and Tx5. Then, according to the size relationship between the weight of Tx0 and the weight of Tx2, Tx0 is scheduled, and according to the weight of Tx0 and Tx5, the conflict relationship between Tx0 and Tx5 is determined. 5, Tx0 is scheduled. Since the weight of Tx0 is less than the weight of Tx5, Tx0 is re-executed. Similarly, it can be determined that Tx2 is re-executed and Tx5 is added to the transaction snapshot; then Tx1 is used as the target transaction. The read-write sets of Tx1 and Tx3 both contain key k2. After conflict detection, it can be determined that there is a conflict between Tx1 and Tx3. Then, according to the size relationship between the weight of Tx1 and the weight of Tx3, Tx1 is scheduled. Since the weight of Tx1 is less than the weight of Tx3, Tx1 is re-executed. Similarly, Tx3 is added to the transaction snapshot; then Tx4 is used as the target transaction. The read-write sets of Tx4 both contain key k3. After conflict detection, it can be determined that Tx4 does not conflict with other blockchain transactions, and Tx4 is added to the transaction snapshot;
[0147] In the second round, the re-executed Tx0, Tx1, and Tx2 are scheduled to add Tx0 and Tx1 to the transaction snapshot and re-execute Tx2.
[0148] In the third round, the re-executed Tx2 is scheduled to be added to the transaction snapshot. After the third round, all blockchain transactions are added to the transaction snapshot, completing the scheduling of the target transaction.
[0149] It can be seen that compared with the total execution time of 12 seconds before deterministic scheduling optimization, the total execution time after deterministic scheduling optimization is 9 seconds, which is reduced by three seconds, and the execution efficiency is improved by 25%. At the same time, it can retain blockchain transactions with more resource consumption and re-execute blockchain transactions with less resource consumption, avoiding resource waste and improving the performance of the blockchain network.
[0150] In addition, according to the scheduling results of the target transaction, a directed acyclic graph (DAG) is constructed. The directed acyclic graph and each blockchain transaction can be packaged to obtain a proposal block carrying the directed acyclic graph. The proposal block is then sent to the verification node in the blockchain network. The verification node can execute the blockchain transactions in the proposal block based on the directed acyclic graph.
[0151] In a possible implementation, the target transaction is obtained whenever one of the blockchain transactions is executed, the first reference transaction is not added to the transaction snapshot, and the target transaction is scheduled according to the relationship between the first weight and the sum of the first weights, specifically:
[0152] When the first weight is greater than the sum of the first weights, wait for a preset time, and schedule the target transaction after the preset time is reached;
[0153] Alternatively, when the first weight is less than the sum of the first weights, re-execute the target transaction;
[0154] Alternatively, when the first weight is equal to the sum of the first weights, wait for a preset time period and schedule the target transaction or re-execute the target transaction after the preset time period is reached.
[0155] Among them, the target transaction can be scheduled in a non-deterministic scheduling manner. In the non-deterministic scheduling, the execution result of each blockchain transaction is uncertain. The non-deterministic scheduling uses the specific execution time of the blockchain transaction as the judgment standard. In the non-deterministic scheduling, the time point of conflict detection is configured as follows: whenever a blockchain transaction is executed, a conflict detection is performed on the blockchain transaction to determine the conflict relationship between the blockchain transaction and the other blockchain transactions that have been executed. The result of the conflict detection may be that there is no conflict between the blockchain transaction and the other blockchain transactions that have been executed, or the result of the conflict detection may be that there is a conflict between the blockchain transaction and the other blockchain transactions that have been executed; when the result of the conflict detection indicates that there is no conflict between the blockchain transaction and the other blockchain transactions that have been executed, it means that the blockchain transaction can be executed in parallel with the other blockchain transactions that have been executed; when the result of the conflict detection indicates that there is a conflict between the blockchain transaction and the other blockchain transactions that have been executed, it means that the blockchain transaction needs to be executed serially with the blockchain transactions with which there is a conflict.
[0156] Therefore, for blockchain transactions that conflict with each other, only one of the blockchain transactions is retained and added to the transaction snapshot, and the remaining blockchain transactions are re-executed; since the execution time of different blockchain transactions can be different, in non-deterministic scheduling, the time points of conflict detection corresponding to different blockchain transactions can also be different, and the target transaction is obtained whenever one of the blockchain transactions is executed.
[0157] At present, when a non-deterministic scheduling method is used to schedule multiple conflicting blockchain transactions, the blockchain transaction that is executed first is added to the transaction snapshot in the order in which the blockchain transactions are executed, and the remaining blockchain transactions are re-executed. This may cause the blockchain transactions that consume more resources to be re-executed, thereby causing resource waste and reducing the performance of the blockchain network.
[0158] Based on this, the scheduling method provided in the embodiment of the present application can optimize non-deterministic scheduling. Non-deterministic scheduling can be applicable to pessimistic scenarios. In pessimistic scenarios, a blockchain transaction is allowed to depend on multiple blockchain transactions at the same time. When the target transaction is executed, the first scheduling link is entered. In the first scheduling link: when the target transaction is executed, the conflicting target transaction and the first reference transaction are scheduled. The first weight of the target transaction and the second weight of the first reference transaction are first obtained. The number of first reference transactions can be one or more. Therefore, according to the number of first reference transactions, different scheduling situations can be distinguished, as follows:
[0159] Scheduling situation 11: The number of first reference transactions is one, and the sum of the first weights is the second weight of the first reference transaction. Since the first weight and the second weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the relationship between the first weight and the sum of the first weights is equivalent to scheduling the target transaction according to the resource consumption parameter. The resource consumption parameter is used to indicate the resources required to execute the blockchain transaction. The first weight is used to indicate the resources required to execute the target transaction. The second weight is used to indicate the resources required to execute the first reference transaction. When the resources required to execute the target transaction are small, the first weight is small. Conversely, when the resources required to execute the target transaction are large, the first weight is large. Similarly, when the resources required to execute the first reference transaction are small, the sum of the first weights is small. Conversely, when the resources required to execute the first reference transaction are large, the sum of the first weights is large.
[0160] Scheduling situation 12: There are multiple first reference transactions, and when the target transaction is executed, there is no conflict between any two first reference transactions. All first reference transactions can be used as the first reference set. The second weights of all first reference transactions need to be summed, which is equivalent to obtaining the sum of the first weights of the first reference set. Since the first weight and the second weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the size relationship between the first weight and the sum of the first weights is equivalent to scheduling the target transaction according to the resource consumption parameter. The resource consumption parameter is used to indicate the resources required to execute the blockchain transaction. The first weight is used to indicate the resources required to execute the target transaction. The second weight is used to indicate the resources required to execute the first reference transaction. When the resources required to execute the target transaction are small, the first weight is small. Conversely, when the resources required to execute the target transaction are large, the first weight is large. Similarly, when the resources required to execute all first reference transactions in the first reference set are small, the sum of the first weights is small. Conversely, when the resources required to execute all first reference transactions in the first reference set are large, the sum of the first weights is large.
[0161] Exemplarily, the first reference transaction 1, the first reference transaction 2 and the first reference transaction 3 are all used to process the state data corresponding to the same key, the execution time of the first reference transaction 1 is 1 second, the execution time of the first reference transaction 2 is 2 seconds, and the execution time of the first reference transaction 3 is 3 seconds; the first reference transaction 1 and the first reference transaction 2 are started to be executed at the same time, when one second is reached, the first reference transaction 1 is completed, and the first reference transaction 1 is used as the target transaction, and through conflict detection, it is determined that the first reference transaction 1 does not conflict with the remaining blockchain transactions, and the first reference transaction 1 is retained, and at this time, the first reference transaction 3 is started to be executed; when two seconds are reached, the first reference transaction 2 is completed, and the first reference transaction 1 is used as the target transaction, and through conflict detection, it is determined that there is a conflict between the first reference transaction 2 and the first reference transaction 1, and then the weight relationship between the first reference transaction 2 and the first reference transaction 1 is determined. Assuming that the weight of the first reference transaction 2 is larger, the first reference transaction 1 is re-executed and the first reference transaction 2 is retained. When three seconds are reached, the first reference transaction 1 is executed again, and the first reference transaction 1 is used as the target transaction. Through conflict detection, it is determined that the first reference transaction 1 does not conflict with the remaining blockchain transactions, and the first reference transaction 1 is retained; when four seconds are reached, the first reference transaction 3 is executed, and the first reference transaction 3 is used as the target transaction. Through conflict detection, it is determined that the first reference transaction 3 conflicts with the remaining blockchain transactions. Since there is no conflict between the first reference transaction 1 and the first reference transaction 2 when the first reference transaction 3 is executed, the first reference transaction 1 and the first reference transaction 2 are used as the first reference set. Assuming that the weight of the first reference transaction 1 is 100, the weight of the first reference transaction 2 is 200, and the weight of the first reference transaction 3 is 250, by summing the weights of the first reference transaction 1 and the first reference transaction 2, the first weight sum of the first reference set is 300. Comparing the size relationship between the first weight and the first weight sum, since 250<300, the first reference transaction 3 is re-executed, and the first reference transaction 1 and the first reference transaction 2 are retained, so as to retain the blockchain transactions with more resource consumption and re-execute the blockchain transactions with less resource consumption, thereby avoiding resource waste and improving the performance of the blockchain network.
[0162] Based on this, since a blockchain transaction is allowed to depend on multiple blockchain transactions at the same time in a pessimistic scenario, when the target transaction is executed, some blockchain transactions that the target transaction depends on may not have been executed yet. By setting a preset duration and waiting, it is possible to wait for each blockchain transaction that the target transaction depends on to be executed, so that the scheduling result of the target transaction is more accurate, thereby improving the certainty of the execution result. Specifically, if there is no need to re-execute the target transaction in the first scheduling link, enter the second scheduling link. In the second scheduling link: after reaching the preset duration, the target transaction is scheduled, so that when the target transaction is scheduled, the blockchain transaction with more resource consumption can be retained and the blockchain transaction with less resource consumption can be re-executed, thereby avoiding resource waste and improving the performance of the blockchain network.
[0163] It should be noted that different blockchain transactions may correspond to different preset durations, but it is necessary to ensure that the preset duration is set according to the same delay rules in each node. For example, the corresponding preset duration is set according to the contract, requiring that all nodes have the same preset duration for the same contract.
[0164] In a possible implementation, determining a first conflict relationship between a target transaction and at least one first reference transaction may specifically be determining a second conflict relationship between the target transaction and a second reference transaction, wherein the second reference transaction is a blockchain transaction other than the target transaction that has been currently executed and has been added to the transaction snapshot; when the second conflict relationship indicates that there is no conflict between the target transaction and the second reference transaction, determining the first conflict relationship between the target transaction and the at least one first reference transaction.
[0165] The second conflict relationship is used to indicate whether there is a conflict between the target transaction and the second reference transaction.
[0166] Based on this, in the first scheduling link, it is necessary to first determine whether there is a conflict between the target transaction and the second reference transaction, which is equivalent to determining whether there is a conflict between the target transaction and the blockchain transaction that has been currently added to the transaction snapshot. If there is a conflict, the target transaction is re-executed. There is no need to subsequently determine the size relationship between the first weight and the sum of the first weights, which can improve the scheduling efficiency of blockchain transactions, and thus improve the execution efficiency of blockchain transactions.
[0167] Specifically, refer to Figure 5 , Figure 5An optional flow chart of the first scheduling link provided in an embodiment of the present application requires three judgments in sequence. In the first judgment, the second conflict relationship is used to determine whether there is a conflict between the target transaction and the second reference transaction. When the judgment is yes, the target transaction is re-executed, otherwise a second judgment is performed. In the second judgment, the first conflict relationship is used to determine whether there is a conflict between the target transaction and the first reference transaction. When the judgment is no, the target transaction is re-executed, otherwise a third judgment is performed. In the third judgment, it is determined whether the first weight is greater than the sum of the first weights. When the first weight is greater than the sum of the first weights, the second scheduling link is entered, and a preset time is waited in the second scheduling link. When the first weight is less than the sum of the first weights, the target transaction is re-executed. When the first weight is equal to the sum of the first weights, you can choose to enter the second scheduling link or choose to re-execute the target transaction. The figure shows the option of re-executing the target transaction.
[0168] Among them, when the blockchain transaction starts to execute, the current transaction quantity in the transaction snapshot is used as the first reference quantity, wherein the current transaction quantity in the transaction snapshot refers to the number of blockchain transactions contained in the transaction snapshot. After the corresponding transaction execution time, the blockchain transaction is completed. When the blockchain transaction is completed, the blockchain transaction is used as the target transaction, and the current transaction quantity in the transaction snapshot is used as the second reference quantity. The first reference quantity and the second reference quantity are compared. When the first reference quantity is the same as the second reference quantity, it means that the target transaction does not have a second reference transaction, otherwise the target transaction has a second reference transaction.
[0169] In contrast, in another possible implementation, in the first scheduling link, it is not necessary to determine whether there is a conflict between the target transaction and the second reference transaction. Compared with the case where it is necessary to determine whether there is a conflict between the target transaction and the second reference transaction, it will take a little more time in the scheduling process. However, this time is much less than the time spent on re-executing a blockchain transaction that consumes more resources. Therefore, when scheduling the target transaction, it is possible to retain the blockchain transaction that consumes more resources and re-execute the blockchain transaction that consumes less resources, thereby avoiding resource waste and improving the performance of the blockchain network.
[0170] In a possible implementation, the target transaction is scheduled after a preset time is reached. Specifically, after the preset time is reached, a third conflict relationship between the target transaction and at least one third reference transaction is determined, wherein the third reference transaction is a blockchain transaction other than the target transaction that has been currently executed and has not been added to the transaction snapshot; when the third conflict relationship indicates that there is a conflict between the target transaction and the third reference transaction, a third weight of the third reference transaction is obtained, wherein the third weight is determined based on a resource consumption parameter for executing the third reference transaction; the sum of the second weights of all third weights is calculated, and the target transaction is scheduled according to the relationship between the first weight and the sum of the second weights.
[0171] Among them, the third conflict relationship is used to indicate whether there is a conflict between the target transaction and the third reference transaction; the size relationship between the first weight and the sum of the second weights means that the first weight is greater than the sum of the second weights, or the first weight is less than the sum of the second weights, or the first weight is equal to the sum of the second weights.
[0172] Based on this, when it is determined to wait for a preset time in the first scheduling link, it is determined to enter the second scheduling link, and wait for the preset time in the second scheduling link. After the preset time is reached, the conflicting target transaction and the third reference transaction are scheduled, and the first weight of the target transaction and the third weight of the third reference transaction are first obtained. The number of the third reference transactions can be one or more. Therefore, according to the number of the third reference transactions, different scheduling situations can be distinguished, as follows:
[0173] Scheduling situation 13: The number of third reference transactions is one, and the sum of the second weights is the third weight of the third reference transaction. Since the first weight and the third weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the size relationship between the first weight and the sum of the second weight is equivalent to scheduling the target transaction according to the resource consumption parameter. The resource consumption parameter is used to indicate the resources required to execute the blockchain transaction. The first weight is used to indicate the resources required to execute the target transaction. The third weight is used to indicate the resources required to execute the third reference transaction. When the resources required to execute the target transaction are small, the first weight is small. Conversely, when the resources required to execute the target transaction are large, the first weight is large. Similarly, when the resources required to execute the third reference transaction are small, the sum of the second weights is small. Conversely, when the resources required to execute the third reference transaction are large, the sum of the second weights is large.
[0174] Scheduling situation 14: There are multiple third reference transactions, and when the target transaction is executed, there is no conflict between any two third reference transactions. All third reference transactions can be used as the second reference set. Similar to scheduling situation 12, the third weights of all third reference transactions need to be summed, which is equivalent to obtaining the sum of the second weights of the second reference set. Since the first weight and the third weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the size relationship between the first weight and the sum of the second weight is equivalent to scheduling the target transaction according to the resource consumption parameter. The resource consumption parameter is used to indicate the resources required to execute the blockchain transaction. The first weight is used to indicate the resources required to execute the target transaction. The third weight is used to indicate the resources required to execute the third reference transaction. When the resources required to execute the target transaction are small, the first weight is small. Conversely, when the resources required to execute the target transaction are large, the first weight is large. Similarly, when the resources required to execute all third reference transactions in the second reference set are small, the sum of the second weights is small. Conversely, when the resources required to execute all third reference transactions in the second reference set are large, the sum of the second weights is large.
[0175] In addition, relative to scheduling situation 14, there is also scheduling situation 15.
[0176] Scheduling situation 15: There are multiple third reference transactions, and when the target transaction is executed, there are conflicts between the third reference transactions. In the transaction set consisting of the target transaction and the third reference transactions, the blockchain transaction with the largest weight is retained, and the blockchain transaction with the smallest weight is re-executed.
[0177] In a possible implementation, the target transaction is scheduled according to the relationship between the first weight and the sum of the second weights, which may be:
[0178] When the first weight is greater than the sum of the second weights, the target transaction is added to the transaction snapshot;
[0179] Alternatively, when the first weight is less than the sum of the second weights, re-execute the target transaction;
[0180] Alternatively, when the first weight is equal to the sum of the second weights, the target transaction is added to the transaction snapshot or the target transaction is re-executed.
[0181] Based on this, for the three comparison situations of the first weight and the sum of the second weight, when the first weight is greater than the sum of the second weight, the target transaction is retained and added to the transaction snapshot; when the first weight is less than the sum of the second weight, the target transaction is re-executed; when the first weight is equal to the sum of the second weight, the target transaction can be added to the transaction snapshot or re-executed. Therefore, when scheduling the target transaction, it is possible to retain blockchain transactions with more resource consumption and re-execute blockchain transactions with less resource consumption, thereby avoiding resource waste and improving the performance of the blockchain network.
[0182] In a possible implementation, determining a third conflict relationship between a target transaction and at least one third reference transaction may specifically include: determining a fourth conflict relationship between the target transaction and a fourth reference transaction, wherein the fourth reference transaction is a blockchain transaction other than the target transaction that has been currently executed and has been added to the transaction snapshot; when the fourth conflict relationship indicates that there is no conflict between the target transaction and the fourth reference transaction, determining a third conflict relationship between the target transaction and the at least one third reference transaction.
[0183] The fourth conflict relationship is used to indicate whether there is a conflict between the target transaction and the fourth reference transaction.
[0184] Based on this, in the second scheduling link, it is necessary to first determine whether there is a conflict between the target transaction and the fourth reference transaction, which is equivalent to determining whether there is a conflict between the target transaction and the blockchain transaction that has been currently added to the transaction snapshot. If there is a conflict, the target transaction is re-executed. There is no need to subsequently determine the size relationship between the first weight and the sum of the second weights, which can improve the scheduling efficiency of blockchain transactions, and thus improve the execution efficiency of blockchain transactions.
[0185] Specifically, refer to Figure 6 , Figure 6 An optional flow chart of the second scheduling link provided in an embodiment of the present application requires three judgments in sequence. In the first judgment, the fourth conflict relationship is used to determine whether there is a conflict between the target transaction and the fourth reference transaction. When the judgment is yes, the target transaction is re-executed, otherwise a second judgment is performed. In the second judgment, the first conflict relationship is used to determine whether there is a conflict between the target transaction and the third reference transaction. When the judgment is no, the target transaction is re-executed, otherwise a third judgment is performed. In the third judgment, it is determined whether the first weight is greater than the sum of the second weights. When the first weight is greater than the sum of the second weights, the target transaction is added to the transaction snapshot. When the first weight is less than the sum of the second weights, the target transaction is re-executed. When the first weight is equal to the sum of the second weights, you can choose to add the target transaction to the transaction snapshot or choose to re-execute the target transaction. The figure shows the option of re-executing the target transaction.
[0186] Among them, when the target transaction is executed, the current transaction quantity in the transaction snapshot is used as the second reference quantity. After the corresponding preset time period, the target transaction reaches the preset time period. When the target transaction reaches the preset time period, the current transaction quantity in the transaction snapshot is used as the third reference quantity. The second reference quantity and the third reference quantity are compared. When the second reference quantity is the same as the third reference quantity, it means that the target transaction does not exist a fourth reference transaction, otherwise the blockchain transaction exists a fourth reference transaction.
[0187] In contrast, in another possible implementation, in the second scheduling link, it is not necessary to determine whether there is a conflict between the target transaction and the fourth reference transaction. Compared with the case where it is necessary to determine whether there is a conflict between the target transaction and the fourth reference transaction, it will take a little more time in the scheduling process. However, this time is much less than the time spent on re-executing a blockchain transaction that consumes more resources. Therefore, when scheduling the target transaction, it is possible to retain the blockchain transaction that consumes more resources and re-execute the blockchain transaction that consumes less resources, thereby avoiding resource waste and improving the performance of the blockchain network.
[0188] In a possible implementation, the blockchain transaction scheduling method further includes:
[0189] Whenever a blockchain transaction that has not been added to the transaction snapshot is re-executed, the blockchain transaction that has been re-executed and not added to the transaction snapshot is used as the target transaction;
[0190] The target transaction is scheduled again until all blockchain transactions are added to the transaction snapshot.
[0191] Among them, the target transaction can be scheduled by non-deterministic scheduling. In the non-deterministic scheduling, the execution result of each blockchain transaction is uncertain. The non-deterministic scheduling can be applicable to pessimistic scenarios. In the pessimistic scenario, a blockchain transaction is allowed to depend on multiple blockchain transactions at the same time. The non-deterministic scheduling uses the specific execution time of the blockchain transaction as the judgment standard. In the non-deterministic scheduling, the time point of the conflict detection is configured as follows: whenever a blockchain transaction is executed, a conflict detection is performed on the blockchain transaction to determine the conflict relationship between the blockchain transaction and the other blockchain transactions that have been executed. Therefore, when the blockchain transaction is re-executed, it is necessary to re-detect the conflict on the blockchain transaction to determine the conflict relationship between the blockchain transaction and the other blockchain transactions that have been executed. When all blockchain transactions are added to the transaction snapshot, it means that the scheduling of the target transaction has been completed.
[0192] Specifically, refer to Figure 7 , Figure 7An optional flow chart before non-deterministic scheduling optimization provided in an embodiment of the present application adds the blockchain transaction that is executed first to the transaction snapshot in the order in which the blockchain transactions are executed, and re-executes the remaining blockchain transactions. This may cause the blockchain transactions that consume more resources to be re-executed, thereby resulting in a waste of resources and reducing the performance of the blockchain network.
[0193] In addition, refer to Figure 8 , Figure 8 An optional flow chart after optimization of non-deterministic scheduling provided in an embodiment of the present application. In non-deterministic scheduling, whenever a blockchain transaction is executed, a conflict detection is performed on the blockchain transaction to determine the conflict relationship between the blockchain transaction and the remaining executed blockchain transactions. In addition, since a blockchain transaction is allowed to depend on multiple blockchain transactions at the same time in a pessimistic scenario, when the target transaction is executed, some blockchain transactions that the target transaction depends on may not have been executed. By setting a preset time and waiting, it is possible to wait for each blockchain transaction that the target transaction depends on to be executed, so that the scheduling result of the target transaction is more accurate, thereby improving the certainty of the execution result.
[0194] Specifically, six blockchain transactions are executed in parallel, and the six blockchain transactions are: Tx0, Tx1, Tx2, Tx3, Tx4 and Tx5, the execution time of Tx0 is 3 seconds, the execution time of Tx1 is 1 second, the execution time of Tx2 is 2 seconds, the execution time of Tx3 is 4 seconds, the execution time of Tx4 is 2 seconds, and the execution time of Tx5 is 4 seconds. The preset duration is 1 second. Based on the resources consumed by executing each blockchain transaction, it can be determined that the weight of Tx0 is 30, the weight of Tx1 is 10, the weight of Tx2 is 20, the weight of Tx3 is 40, the weight of Tx4 is 20, and the weight of Tx5 is 40;
[0195] When one second is reached, Tx1 is executed and Tx1 is taken as the target transaction. In the first scheduling phase, conflict detection is performed to determine that Tx1 does not conflict with other blockchain transactions. Tx1 enters the second scheduling phase and waits for a preset time in the second scheduling phase.
[0196] When two seconds are reached, Tx1 reaches the preset duration, and through conflict detection in the second scheduling link, it is determined that Tx1 does not conflict with other blockchain transactions, and Tx1 is added to the transaction snapshot; at the same time, Tx2 is executed, Tx2 is used as the target transaction, and through conflict detection in the first scheduling link, it is determined that Tx2 does not conflict with other blockchain transactions, Tx2 enters the second scheduling link, and Tx2 waits for the preset duration in the second scheduling link; at the same time, Tx4 is executed, Tx4 is used as the target transaction, and through conflict detection in the first scheduling link, it is determined that Tx4 does not conflict with other blockchain transactions, Tx4 enters the second scheduling link, and Tx4 waits for the preset duration in the second scheduling link;
[0197] When three seconds have passed, Tx0 is executed and Tx0 is used as the target transaction. In the first scheduling phase, conflict detection is performed. Since the read and write sets of Tx0 and Tx2 both contain key k1, and Tx2 is executed and not added to the transaction snapshot, it is determined that Tx2 is the first reference transaction that conflicts with Tx1. According to the relationship between the weight of Tx0 and the weight of Tx2, Tx0 is scheduled. Since the weight of Tx0 is greater than that of Tx2, Tx0 enters the second scheduling phase. In the second scheduling phase, Tx0 At the same time, Tx2 reaches the preset time, and through conflict detection in the second scheduling link, it is determined that Tx0 is the third reference transaction that conflicts with Tx2. According to the size relationship between the weight of Tx2 and the weight of Tx0, Tx2 is scheduled. Since the weight of Tx2 is less than the weight of Tx0, Tx2 is re-executed; At the same time, Tx4 reaches the preset time, and through conflict detection in the second scheduling link, it is determined that Tx4 does not conflict with other blockchain transactions, and Tx4 is added to the transaction snapshot;
[0198] When it reaches four seconds, Tx0 reaches the preset duration and passes the conflict detection in the second scheduling link. Since the read and write sets of Tx0 and Tx5 both contain key k1, and Tx5 has been executed and not added to the transaction snapshot, it is determined that Tx5 is the third reference transaction that conflicts with Tx0. According to the size relationship between the weight of Tx0 and the weight of Tx5, Tx0 is scheduled. Since the weight of Tx0 is less than the weight of Tx5, Tx0 is re-executed; at the same time, Tx3 is executed and Tx3 is used as the target transaction. It passes the conflict detection in the first scheduling link. Since the key k2 is included in the read / write sets of Tx3 and Tx1, and Tx1 has been added to the transaction snapshot, it is determined that Tx1 is the second reference transaction that conflicts with Tx3, and Tx3 is re-executed; at the same time, Tx5 is executed, and Tx5 is used as the target transaction. Through conflict detection in the first scheduling phase, it is determined that Tx0 is the first reference transaction that conflicts with Tx5. According to the size relationship between the weight of Tx5 and the weight of Tx0, Tx5 is scheduled. Since the weight of Tx5 is greater than the weight of Tx0, Tx5 waits for a preset time in the second scheduling phase;
[0199] When five seconds are reached, Tx2 is re-executed and Tx2 is used as the target transaction. In the first scheduling phase, through conflict detection, it is determined that Tx5 is the first reference transaction that conflicts with Tx2. According to the size relationship between the weight of Tx2 and the weight of Tx5, Tx2 is scheduled. Since the weight of Tx2 is less than the weight of Tx5, Tx2 is re-executed. At the same time, Tx5 reaches the preset duration. Through conflict detection in the second scheduling phase, it is determined that Tx2 is the third reference transaction that conflicts with Tx5. According to the size relationship between the weight of Tx5 and the weight of Tx2, Tx5 is scheduled. Since the weight of Tx5 is greater than the weight of Tx2, Tx5 is added to the transaction snapshot.
[0200] When seven seconds are reached, Tx0 is re-executed and completed, and Tx0 is used as the target transaction. In the first scheduling link, through conflict detection, it is determined that Tx2 is the first reference transaction that conflicts with Tx0. According to the size relationship between the weight of Tx0 and the weight of Tx2, Tx0 is scheduled. Since the weight of Tx0 is greater than the weight of Tx2, Tx0 enters the second scheduling link, and Tx0 waits for a preset time in the second scheduling link; at the same time, Tx2 is re-executed and completed, and Tx2 is used as the target transaction. In the first scheduling link, through conflict detection, it is determined that Tx0 is the first reference transaction that conflicts with Tx2. According to the size relationship between the weight of Tx2 and the weight of Tx0, Tx2 is scheduled. Since the weight of Tx2 is less than the weight of Tx0, Tx2 is re-executed;
[0201] When it reaches eight seconds, Tx0 reaches the preset duration. In the second scheduling phase, conflict detection is performed to determine that Tx0 does not conflict with other blockchain transactions, and Tx0 is added to the transaction snapshot. At the same time, Tx3 is executed, and Tx3 is used as the target transaction. In the first scheduling phase, conflict detection is performed to determine that Tx3 does not conflict with other blockchain transactions, and Tx3 enters the second scheduling phase, where Tx3 waits for the preset duration.
[0202] When nine seconds are reached, Tx2 is executed, and Tx2 is taken as the target transaction. In the first scheduling link, conflict detection is performed to determine that Tx2 does not conflict with other blockchain transactions, and Tx2 enters the second scheduling link, where Tx2 waits for a preset time. At the same time, Tx3 reaches the preset time, and conflict detection is performed in the second scheduling link to determine that Tx3 does not conflict with other blockchain transactions, and Tx3 is added to the transaction snapshot. When ten seconds are reached, Tx2 reaches the preset time, and conflict detection is performed in the second scheduling link to determine that Tx2 does not conflict with other blockchain transactions, and Tx2 is added to the transaction snapshot.
[0203] It can be seen that compared with the total execution time of 12 seconds before the non-deterministic scheduling optimization, the total execution time after the non-deterministic scheduling optimization for the pessimistic scenario is 10 seconds, which is reduced by two seconds, and the execution efficiency is improved by nearly 17%. The execution efficiency is significantly improved, and blockchain transactions with more resource consumption are retained, and blockchain transactions with less resource consumption are re-executed, avoiding resource waste and improving the performance of the blockchain network.
[0204] In addition, according to the scheduling results of the target transaction, a transaction directed acyclic graph is constructed, the transaction directed acyclic graph and each blockchain transaction are packaged to obtain a proposal block carrying the directed acyclic graph, and then the proposal block is sent to the verification node in the blockchain network. The verification node can execute the blockchain transaction in the proposal block based on the transaction directed acyclic graph.
[0205] In a possible implementation, the extension time can be further optimized. For example, the preset time can be optimized by a block-by-block optimization method. The block with the highest block height in the blockchain is used as the initial block, and an initial preset time is set for the initial block. The corresponding blockchain transaction is scheduled according to the initial preset time, and then the blockchain transaction is executed, and the total execution time is determined. According to the total execution time, the preset time is optimized. In the next block of the initial block, the corresponding blockchain transaction is scheduled according to the optimized preset time, and then the blockchain transaction is executed. The preset time can be optimized again by the total execution time. Therefore, the preset time can be continuously optimized to obtain a better preset time, which can effectively improve the execution efficiency; wherein, optimizing the preset time can be to extend the preset time, or it can be to shorten the preset time, depending on the actual situation.
[0206] In addition, the preset duration can also be optimized through simulation training methods. The block with the highest block height in the blockchain is used as the initial block, and a preset duration is preset for the initial block. Then, a batch of blockchain transactions are selected in the transaction pool as sample transactions. Based on the initial block, the corresponding sample transactions are scheduled according to the initial preset duration, and then the sample transactions are executed, and the total execution time is determined. Then, based on the total execution time, an optimized preset duration is determined. Then, based on the initial block again, the corresponding sample transactions are scheduled according to the optimized preset duration, and then the sample transactions are executed and the total execution time is determined. The preset duration can be optimized again through the total execution time. Therefore, the preset duration can be continuously optimized to obtain a better preset duration, which can effectively improve the execution efficiency.
[0207] In a possible implementation, the target transaction is obtained whenever one of the blockchain transactions is executed, the first reference transaction has been added to the transaction snapshot, and the target transaction is scheduled according to the relationship between the first weight and the sum of the first weights, which may be:
[0208] When the first weight is greater than the sum of the first weights, replacing the first reference transaction in the transaction snapshot with the target transaction;
[0209] Alternatively, when the first weight is less than the sum of the first weights, re-execute the target transaction;
[0210] Alternatively, when the first weight is equal to the sum of the first weights, the first reference transaction in the transaction snapshot is replaced with the target transaction or the target transaction is re-executed.
[0211] Based on this, the scheduling method provided in the embodiment of the present application can also optimize the non-deterministic scheduling of optimistic scenarios. In the optimistic scenario, the number of blockchain transactions that a blockchain transaction depends on is less than or equal to one. When conflicting blockchain transactions are executed serially, each blockchain transaction only depends on the previous blockchain transaction and will not depend on multiple blockchain transactions at the same time. Exchanging the execution order of blockchain transactions will not affect the final execution result. Therefore, conflicting transaction replacement is allowed in the optimistic scenario. Specifically, when the blockchain transaction is executed, if there is no conflicting transaction that conflicts with the blockchain transaction in the transaction snapshot, the blockchain transaction can be temporarily added to the transaction snapshot, or if there is a conflicting transaction that conflicts with the blockchain transaction in the transaction snapshot, if replacement is required, the blockchain transaction can replace the conflicting transaction in the transaction snapshot and re-execute the conflicting transaction; therefore, in the optimistic scenario, the first reference transaction is the blockchain transaction that has been added to the transaction snapshot.
[0212] When the target transaction is executed, the conflicting target transaction and the first reference transaction are scheduled. The first weight of the target transaction and the second weight of the first reference transaction are first obtained. The number of the first reference transactions may be one or more. Therefore, different scheduling situations can be distinguished according to the number of the first reference transactions, as follows:
[0213] Scheduling situation 21: The number of first reference transactions is one, and the sum of the first weights is the second weight of the first reference transaction. Since the first weight and the second weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the relationship between the first weight and the sum of the first weights is equivalent to scheduling the target transaction according to the resource consumption parameter. The resource consumption parameter is used to indicate the resources required to execute the blockchain transaction. The first weight is used to indicate the resources required to execute the target transaction. The second weight is used to indicate the resources required to execute the first reference transaction. When the resources required to execute the target transaction are small, the first weight is small. Conversely, when the resources required to execute the target transaction are large, the first weight is large. Similarly, when the resources required to execute the first reference transaction are small, the sum of the first weights is small. Conversely, when the resources required to execute the first reference transaction are large, the sum of the first weights is large.
[0214] Specifically, when multiple blockchain transactions for processing state data corresponding to the same key are executed in parallel, and the time points at which the various blockchain transactions are executed do not overlap, the first blockchain transaction that is executed will be temporarily added to the transaction snapshot, and the blockchain transactions that are executed later will be weighted compared with the blockchain transactions in the transaction snapshot, and whether replacement is required will be determined based on the weight comparison result; if the time points at which some blockchain transactions are executed overlap, the blockchain transaction that performs conflict detection first will not treat the blockchain transaction that performs conflict detection later as a conflicting transaction. For example, if two blockchain transactions are executed in parallel and the blockchain transactions are executed at the same time, one of the blockchain transactions will be added. As the target transaction, conflict detection is performed on the target transaction. Since another blockchain transaction will not be used as a conflicting transaction, the blockchain transaction that has been conflict-detected first is directly temporarily added to the transaction snapshot, which is equivalent to the number of the first reference transaction being zero. Then another blockchain transaction is used as the target transaction and conflict detection is performed on the target transaction. The other blockchain transaction will be weighted compared with the blockchain transaction in the transaction snapshot, and whether it needs to be replaced is determined based on the weight comparison result, which is equivalent to the number of the first reference transaction being one. Similarly, if the time points at which three or more blockchain transactions are executed coincide, only the blockchain transaction that has been added to the transaction snapshot will be used as the first reference transaction.
[0215] In addition, according to the scheduling results of the target transaction, a transaction directed acyclic graph is constructed, the transaction directed acyclic graph and each blockchain transaction are packaged to obtain a proposal block carrying the directed acyclic graph, and then the proposal block is sent to the verification node in the blockchain network. The verification node can execute the blockchain transaction in the proposal block based on the transaction directed acyclic graph.
[0216] Scheduling situation 22: There are multiple first reference transactions, and multiple first reference transactions have been added to the transaction snapshot. All first reference transactions can be used as the third reference set. The second weights of all first reference transactions need to be summed, which is equivalent to obtaining the sum of the first weights of the third reference set. Since the first weight and the second weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the size relationship between the first weight and the sum of the first weights is equivalent to scheduling the target transaction according to the resource consumption parameter. The resource consumption parameter is used to indicate the resources required to execute the blockchain transaction. The first weight is used to indicate the resources required to execute the target transaction. The second weight is used to indicate the resources required to execute the first reference transaction. When the resources required to execute the target transaction are small, the first weight is small. Conversely, when the resources required to execute the target transaction are large, the first weight is large. Similarly, when the resources required to execute all first reference transactions in the third reference set are small, the sum of the first weights is small. Conversely, when the resources required to execute all first reference transactions in the third reference set are large, the sum of the first weights is large.
[0217] In addition, due to the existence of system scheduling, system scheduling will result in the situation that not all transactions are started completely in parallel. System scheduling refers to the scheduling of the program by the operating system. In this case, when the blockchain transaction executed later is completed, all the first reference transactions that were executed first and completed can be used as objects of weight comparison, and the sum of the first weights of all the second weights is calculated. By comparing the size between the first weight and the sum of the first weights, it can be effectively determined whether the resource consumption of executing the target transaction is greater than the resource consumption corresponding to executing all the first reference transactions that were executed first and completed, thereby retaining the blockchain transactions with more resource consumption and re-executing the blockchain transactions with less resource consumption, avoiding resource waste and improving the performance of the blockchain network.
[0218] Specifically, refer to Fig. 9 , Fig. 9Another optional flow diagram after non-deterministic scheduling optimization provided in an embodiment of the present application, executing three blockchain transactions in parallel, the three blockchain transactions are: Tx0, Tx1, Tx2, the execution time of Tx0 is 3 seconds, the execution time of Tx1 is 1 second, and the execution time of Tx2 is 2 seconds. Based on the resources consumed by executing each blockchain transaction, it can be determined that the weight of Tx0 is 25, the weight of Tx1 is 10, and the weight of Tx2 is 20;
[0219] When one second is reached, Tx1 is executed and taken as the target transaction. Through conflict detection, it is determined that Tx1 does not conflict with other blockchain transactions, and Tx1 is added to the transaction snapshot. At the same time, due to system scheduling, Tx0 is executed.
[0220] When two seconds have passed, Tx2 is executed and Tx2 is used as the target transaction. Through conflict detection, it is determined that Tx1 is the first reference transaction that conflicts with Tx2. Tx2 is scheduled based on the weight relationship between Tx1 and Tx2. Since the weight of Tx2 is greater than that of Tx1, Tx2 replaces Tx1 in the transaction snapshot, which is equivalent to adding Tx2 to the transaction snapshot and re-executing Tx1.
[0221] When three seconds have passed, Tx1 is re-executed and used as the target transaction. After conflict detection, it is determined that Tx1 does not conflict with other blockchain transactions, and Tx1 is added to the transaction snapshot.
[0222] When four seconds are reached, Tx0 is executed, and Tx0 is used as the target transaction. Through conflict detection, it is determined that Tx1 and Tx2 are both the first reference transactions that conflict with Tx0. Since there is no conflict between Tx1 and Tx2, Tx1 and Tx2 are used as the third reference set. The first weight sum of the third reference set is calculated to be 30. According to the relationship between the weight of Tx0 and the first weight sum, Tx0 is scheduled. Since the weight of Tx0 is less than the first weight sum, Tx0 is re-executed to retain blockchain transactions with more resource consumption and re-execute blockchain transactions with less resource consumption, thereby avoiding resource waste and improving the performance of the blockchain network.
[0223] Among them, for the three comparison situations of the first weight and the sum of the first weights, when the first weight is greater than the sum of the first weights, the target transaction is retained and the target transaction replaces the first reference transaction, which is equivalent to temporarily adding the target transaction to the transaction snapshot and re-executing the first reference transaction. When the first weight is less than the sum of the first weights, the target transaction is re-executed. When the first weight is equal to the sum of the first weights, the target transaction can replace the first reference transaction, or the first reference transaction can be re-executed. Therefore, when the target transaction is scheduled, it is possible to retain blockchain transactions with more resource consumption and re-execute blockchain transactions with less resource consumption, thereby avoiding resource waste and improving the performance of the blockchain network.
[0224] In a possible implementation, the blockchain transaction scheduling method further includes:
[0225] Re-execute the first reference transaction that was replaced in the transaction snapshot;
[0226] Whenever the replaced first reference transaction is re-executed, the re-executed first reference transaction is used as the target transaction;
[0227] The target transaction is scheduled again until all blockchain transactions are added to the transaction snapshot.
[0228] Among them, the target transaction can be scheduled by non-deterministic scheduling. In the non-deterministic scheduling, the execution result of each blockchain transaction is uncertain. The non-deterministic scheduling uses the specific execution time of the blockchain transaction as the judgment standard. The non-deterministic scheduling can be applicable to optimistic scenarios. In the optimistic scenario, conflicting transactions are allowed to be replaced. In the non-deterministic scheduling, the time point of conflict detection is configured as follows: whenever a blockchain transaction is executed, a conflict detection is performed on the blockchain transaction to determine the conflict relationship between the blockchain transaction and the remaining blockchain transactions that have been executed. Therefore, when the blockchain transaction is re-executed, it is necessary to re-detect the conflict of the blockchain transaction. For example, when the first reference transaction is re-executed, the re-executed first reference transaction is used as the target transaction, and the conflict relationship between the target transaction and the remaining blockchain transactions that have been executed is re-determined. When all blockchain transactions are added to the transaction snapshot, it means that the scheduling of the target transaction has been completed.
[0229] Specifically, refer to Fig.10 , Fig.10Another optional flow chart after the non-deterministic scheduling optimization provided in the embodiment of the present application, in the non-deterministic scheduling, each time a blockchain transaction is executed, a conflict detection is performed on the blockchain transaction to determine the conflict relationship between the blockchain transaction and the other blockchain transactions that have been executed. In addition, conflicting transaction replacement is allowed in an optimistic scenario.
[0230] Specifically, six blockchain transactions are executed in parallel, and the six blockchain transactions are: Tx0, Tx1, Tx2, Tx3, Tx4 and Tx5. The execution time of Tx0 is 3 seconds, the execution time of Tx1 is 1 second, the execution time of Tx2 is 2 seconds, the execution time of Tx3 is 4 seconds, the execution time of Tx4 is 2 seconds, and the execution time of Tx5 is 4 seconds. Based on the resources consumed by executing each blockchain transaction, it can be determined that the weight of Tx0 is 30, the weight of Tx1 is 10, the weight of Tx2 is 20, the weight of Tx3 is 40, the weight of Tx4 is 20, and the weight of Tx5 is 40;
[0231] When one second is reached, Tx1 is executed and Tx1 is used as the target transaction. Through conflict detection, it is determined that Tx1 does not conflict with other blockchain transactions, and Tx1 is added to the transaction snapshot;
[0232] When two seconds have passed, Tx2 is executed and used as the target transaction. Through conflict detection, it is determined that Tx2 does not conflict with other blockchain transactions, and Tx2 is added to the transaction snapshot. At the same time, Tx4 is executed and used as the target transaction. Through conflict detection, it is determined that Tx4 does not conflict with other blockchain transactions, and Tx4 is added to the transaction snapshot.
[0233] When three seconds have passed, Tx0 is executed and Tx0 is used as the target transaction. Through conflict detection, it is determined that Tx2 is the first reference transaction that conflicts with Tx0. Tx0 is scheduled based on the weight of Tx0 and the weight of Tx2. Since the weight of Tx0 is greater than that of Tx2, Tx0 replaces Tx2 in the transaction snapshot, which is equivalent to adding Tx0 to the transaction snapshot and re-executing Tx2.
[0234] When four seconds are reached, Tx3 is executed, and Tx3 is used as the target transaction. Through conflict detection, it is determined that Tx1 is the first reference transaction that conflicts with Tx3. According to the size relationship between the weight of Tx3 and the weight of Tx1, Tx3 is scheduled. Since the weight of Tx3 is greater than the weight of Tx1, Tx3 replaces Tx1 in the transaction snapshot, which is equivalent to adding Tx3 to the transaction snapshot and re-executing Tx1; at the same time, Tx5 is executed, and Tx5 is used as the target transaction. Through conflict detection, it is determined that Tx0 is the first reference transaction that conflicts with Tx5. According to the size relationship between the weight of Tx5 and the weight of Tx0, Tx5 is scheduled. Since the weight of Tx5 is greater than the weight of Tx0, Tx5 replaces Tx0 in the transaction snapshot, which is equivalent to adding Tx5 to the transaction snapshot and re-executing Tx0;
[0235] When five seconds have passed, Tx1 is executed and used as the target transaction. Through conflict detection, it is determined that Tx1 does not conflict with other blockchain transactions, and Tx1 is added to the transaction snapshot. At the same time, Tx2 is executed and used as the target transaction. Through conflict detection, it is determined that Tx5 is the first reference transaction that conflicts with Tx2. According to the relationship between the weight of Tx2 and the weight of Tx5, Tx2 is scheduled. Since the weight of Tx2 is less than that of Tx5, Tx2 is re-executed.
[0236] When seven seconds have passed, Tx0 is executed and used as the target transaction. Through conflict detection, it is determined that Tx0 does not conflict with other blockchain transactions, and Tx0 is added to the transaction snapshot. At the same time, Tx2 is executed and used as the target transaction. Through conflict detection, it is determined that Tx0 is the first reference transaction that conflicts with Tx2. According to the relationship between the weight of Tx2 and the weight of Tx0, Tx2 is scheduled. Since the weight of Tx2 is less than the weight of Tx0, Tx2 is re-executed.
[0237] When nine seconds have passed, Tx2 is executed and used as the target transaction. After conflict detection, it is determined that Tx2 does not conflict with other blockchain transactions and Tx2 is added to the transaction snapshot.
[0238] Refer again Figure 7 It can be seen that compared with the total execution time of 12 seconds before the non-deterministic scheduling optimization, the total execution time after the non-deterministic scheduling optimization for the optimistic scenario is 9 seconds, which is reduced by 3 seconds. The execution efficiency is improved by 25%, and the execution efficiency is significantly improved.
[0239] In a possible implementation, the resource consumption parameter includes at least one of a transaction execution time of a blockchain transaction, a number of read set keys of a blockchain transaction, a read set memory size of a blockchain transaction, a number of write set keys of a blockchain transaction, and a write set memory size of a blockchain transaction. The first weight may be specifically determined by the following steps:
[0240] Determine a score value corresponding to at least one of a transaction execution time, a number of read-set keys, a read-set memory size, a number of write-set keys, and a write-set memory size of a target transaction;
[0241] A first weight is obtained according to at least one score value.
[0242] Among them, the resource consumption parameter is used to indicate the resources needed to execute the blockchain transaction. Therefore, the first weight is used to indicate the resources needed to execute the target transaction. The resources needed to execute the blockchain transaction can be time resources, memory resources, etc.
[0243] Regarding the time resources consumed in executing blockchain transactions, the transaction execution time is very sensitive to the transaction requester and can be determined by the transaction execution time of the blockchain transaction. Therefore, the resource consumption parameter can be the transaction execution time.
[0244] In addition, for the memory resources consumed by executing blockchain transactions, for the transaction executor, the information of the read-write set involved is an important resource consumption evaluation factor, which can be determined by at least one of the number of read-set keys, the read-set memory size, the number of write-set keys and the write-set memory size. The reasons are as follows:
[0245] The state data can be stored in the form of key-value pairs. During the execution of a blockchain transaction, a read set and a write set will be created for the blockchain transaction. The read set is used to indicate the state data read by the blockchain transaction. Therefore, the read set includes the key of the read state data and the submission version number corresponding to the key. The read set can also include the value corresponding to the key. The write set is used to indicate the state data inserted, deleted or updated by the blockchain transaction. Therefore, the write set includes the key of the written state data and the value corresponding to the key. The number of read set keys refers to the number of keys included in the read set, and the number of write set keys refers to the number of keys included in the write set. The read set memory size refers to the sum of the memory occupied by each data in the read set, and the write set memory size refers to the sum of the memory occupied by each data in the write set. It can be seen that creating a read set and a write set will occupy memory space. The more keys contained in the read set, the more memory resources are usually consumed. The more keys contained in the write set, the more memory resources are usually consumed. The larger the sum of the memory occupied by each data in the read set, the more memory resources are consumed. The larger the sum of the memory occupied by each data in the write set, the more memory resources are consumed.
[0246] Therefore, the memory resources consumed by executing blockchain transactions can be determined by at least one of the number of read set keys, the read set memory size, the number of write set keys, and the write set memory size. It can be seen that the resource consumption parameters can be the number of read set keys, the read set memory size, the number of write set keys, and the write set memory size.
[0247] It is understandable that other parameters for indicating the resources required to execute blockchain transactions can be selected as resource consumption parameters according to actual conditions, and this embodiment of the present application does not limit this.
[0248] Specifically, when using multiple types of resource consumption parameters to determine the first weight, in order to facilitate calculation, the values of each resource consumption parameter need to be consistent. Therefore, the first weight can be obtained by first calculating the score value corresponding to each resource consumption parameter and then calculating the sum of each score value.
[0249] In a possible implementation, since different resource consumption parameters have different degrees of influence on the evaluation of resource consumption, a corresponding upper limit of the score value may be set for each resource consumption parameter.
[0250] Exemplarily, the upper limits of the score values corresponding to the various resource consumption parameters are shown in Table 1 below:
[0251] Table 1
[0252] Upper limit of score value Resource consumption parameters 100 Transaction execution time 50 Number of read set keys 70 Read set memory size 20 Number of write set keys 30 Write set memory size
[0253] Among them, it can be seen from Table 1 that the corresponding upper limit of the score value is set according to the influence of each resource consumption parameter on the evaluation of resource consumption. For example, the transaction execution time has the greatest influence on the evaluation of resource consumption, so the upper limit of the score value corresponding to the transaction execution time is the largest. Then, based on the upper limit of the score value of the resource consumption parameter and the actual parameter value, the score value corresponding to the resource consumption parameter can be determined.
[0254] Taking the transaction execution time as an example, the upper limit of the score value corresponding to the transaction execution time is 100 points. By setting multiple time thresholds, 100 points can be divided into multiple score intervals. For example, the time threshold can be set to 1 second, 2 seconds, 3 seconds, 4 seconds and 5 seconds. When the transaction execution time is less than 1 second, the score value corresponding to the transaction execution time is 100 points. When the transaction execution time is between 1 second and 2 seconds, the score value corresponding to the transaction execution time is in the score range of 80 to 100 points. When the transaction execution time is between 2 seconds and 3 seconds, the score value corresponding to the transaction execution time is in the score range of 50 to 80 points. Within the score range, when the transaction execution time is between 3 seconds and 4 seconds, the score value corresponding to the transaction execution time is between 20 and 50 points; when the transaction execution time is between 4 seconds and 5 seconds, the score value corresponding to the transaction execution time is between 0 and 20 points; when the transaction execution time is greater than 5 seconds, the score value corresponding to the transaction execution time is 0. Within the score range, the actual score value can be determined according to the linear relationship between the score value and the transaction execution time. Similarly, the score values corresponding to other resource consumption parameters can be calculated, and then all the score values are added together to obtain the first weight.
[0255] It is understandable that the upper limit of the score value corresponding to the resource consumption parameter can be set to other values according to actual conditions, and the embodiments of the present application do not limit this.
[0256] In another possible implementation, the same upper limit of the score value may be set for each resource consumption parameter. For example, the upper limit of the score value is set to 100 points. Taking the transaction execution time as an example again, the actual score value of the transaction execution time can be determined according to the above-mentioned score value determination method. The score value corresponding to other resource consumption parameters can be determined according to the score value determination method based on the same principle. Since different resource consumption parameters have different degrees of influence on the evaluation of resource consumption, corresponding weight values can be set for the score values corresponding to different resource consumption parameters according to the degree of influence of each resource consumption parameter on the evaluation of resource consumption. Then, based on the corresponding weight values, the score values corresponding to each resource consumption parameter are weighted, and then all weighted score values are added together to obtain the first weight.
[0257] Reference Fig.11 , Fig.11An optional flow diagram of block verification between nodes provided in an embodiment of the present application, wherein the blockchain network includes a block-producing node and a verification node, the number of the verification nodes can be multiple, and multiple blockchain transactions, such as Tx0, Tx1, Tx2, Tx3, Tx4 and Tx5, are executed in parallel through multi-threading of the block-producing node, and the executed blockchain transaction is used as the target transaction. When scheduling the conflicting target transaction and the first reference transaction, the first weight of the target transaction and the second weight of the first reference transaction are first obtained. Since the first weight and the second weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the size relationship between the first weight and the second weight is equivalent to scheduling the target transaction according to the resource consumption parameter, so that the target transaction can be scheduled in the target transaction. When scheduling the target transaction, the blockchain transactions with more resource consumption are retained, and the blockchain transactions with less resource consumption are re-executed to avoid resource waste and improve the performance of the blockchain network. According to the scheduling result of the target transaction, a transaction directed acyclic graph is constructed, and the transaction directed acyclic graph and each blockchain transaction are packaged to obtain a proposed block carrying the directed acyclic graph. The proposed block will also include the final world state determined according to the execution result of the blockchain transaction. The block-producing node sends the proposed block to each verification node. The verification node can execute the blockchain transaction in the proposed block based on the transaction directed acyclic graph to obtain a reference world state, and compare the reference state with the final state. When the reference world state is the same as the final world state, the verification of the proposed block passes, otherwise the verification fails.
[0258] It is to be understood that, although the steps in the above-mentioned various flow charts are shown in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in the present embodiment, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above-mentioned flow charts can include a plurality of steps or a plurality of stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of the steps or stages in other steps or other steps.
[0259] Reference Fig.12 , Fig.12 An optional structural diagram of a scheduling device for blockchain transactions provided in an embodiment of the present application, the scheduling device 1200 for blockchain transactions includes:
[0260] An execution module 1201 is used to obtain multiple blockchain transactions to be executed and execute each blockchain transaction;
[0261] The conflict detection module 1202 is used to obtain a target transaction that has been executed from multiple blockchain transactions, and determine a first conflict relationship between the target transaction and at least one first reference transaction, wherein the first reference transaction is a blockchain transaction that has been executed except the target transaction.
[0262] A weight acquisition module 1203 is used to acquire a first weight of the target transaction and a second weight of the first reference transaction when the first conflict relationship indicates that there is a conflict between the target transaction and the first reference transaction, wherein the first weight is determined based on a resource consumption parameter for executing the target transaction, and the second weight is determined based on a resource consumption parameter for executing the first reference transaction;
[0263] The first scheduling module 1204 is used to schedule the target transaction according to the relationship between the first weight and the second weight.
[0264] Further, the first scheduling module 1204 is specifically used for:
[0265] Scheduling the target transaction according to the relationship between the first weight and each second weight;
[0266] Alternatively, the sum of the first weights of all the second weights is calculated, and the target transaction is scheduled according to the relationship between the first weight and the sum of the first weights.
[0267] Furthermore, the target transaction is obtained when all blockchain transactions are executed, and the first reference transaction is not added to the transaction snapshot. The first scheduling module 1204 is specifically used to:
[0268] When the first weight is greater than each second weight, adding the target transaction to the transaction snapshot;
[0269] Alternatively, when the first weight is less than any second weight, re-execute the target transaction;
[0270] Alternatively, when the first weight is equal to at least one second weight, and the first weight is greater than the remaining second weights, the target transaction is added to the transaction snapshot or the target transaction is re-executed.
[0271] Further, the first scheduling module 1204 is specifically used for:
[0272] The target transaction and the first reference transaction having the same weight as the target transaction are taken as a first transaction set;
[0273] Add one of the blockchain transactions in the transaction set to the transaction snapshot and re-execute the remaining blockchain transactions in the transaction set.
[0274] Further, refer to Fig.12 , Fig.12Another optional structural diagram of the scheduling device for blockchain transactions provided in an embodiment of the present application, the scheduling device 1200 for blockchain transactions further includes:
[0275] The second scheduling module 1205 is used to take the blockchain transactions that have been re-executed and not added to the transaction snapshot as target transactions whenever all blockchain transactions that have not been added to the transaction snapshot have been re-executed; and schedule the target transactions again until all blockchain transactions are added to the transaction snapshot.
[0276] Furthermore, the target transaction is obtained whenever one of the blockchain transactions is executed, and the first reference transaction is not added to the transaction snapshot. The first scheduling module 1204 is specifically used to:
[0277] When the first weight is greater than the sum of the first weights, wait for a preset time, and schedule the target transaction after the preset time is reached;
[0278] Alternatively, when the first weight is less than the sum of the first weights, re-execute the target transaction;
[0279] Alternatively, when the first weight is equal to the sum of the first weights, wait for a preset time period and schedule the target transaction or re-execute the target transaction after the preset time period is reached.
[0280] Furthermore, the conflict detection module 1202 is specifically used for:
[0281] Determining a second conflict relationship between the target transaction and a second reference transaction, wherein the second reference transaction is a blockchain transaction other than the target transaction that has been currently executed and has been added to the transaction snapshot;
[0282] When the second conflict relationship indicates that there is no conflict between the target transaction and the second reference transaction, a first conflict relationship between the target transaction and the at least one first reference transaction is determined.
[0283] Further, the first scheduling module 1204 is specifically used for:
[0284] After a preset time period is reached, determining a third conflict relationship between the target transaction and at least one third reference transaction, wherein the third reference transaction is a blockchain transaction other than the target transaction that has been currently executed and has not been added to the transaction snapshot;
[0285] When the third conflict relationship indicates that there is a conflict between the target transaction and the third reference transaction, obtaining a third weight of the third reference transaction, wherein the third weight is determined based on a resource consumption parameter of executing the third reference transaction;
[0286] The sum of the second weights of all third weights is calculated, and the target transaction is scheduled according to the size relationship between the first weight and the sum of the second weights.
[0287] Further, the first scheduling module 1204 is specifically used for:
[0288] When the first weight is greater than the sum of the second weights, the target transaction is added to the transaction snapshot;
[0289] Alternatively, when the first weight is less than the sum of the second weights, re-execute the target transaction;
[0290] Alternatively, when the first weight is equal to the sum of the second weights, the target transaction is added to the transaction snapshot or the target transaction is re-executed.
[0291] Further, the first scheduling module 1204 is specifically used for:
[0292] Determining a fourth conflict relationship between the target transaction and a fourth reference transaction, wherein the fourth reference transaction is a blockchain transaction other than the target transaction that has been currently executed and has been added to the transaction snapshot;
[0293] When the fourth conflict relationship indicates that there is no conflict between the target transaction and the fourth reference transaction, a third conflict relationship between the target transaction and at least one third reference transaction is determined.
[0294] Further, refer to Fig.14 , Fig.14 Another optional structural diagram of the scheduling device for blockchain transactions provided in an embodiment of the present application, the scheduling device 1200 for blockchain transactions further includes:
[0295] The third scheduling module 1206 is used to take the blockchain transaction that has been re-executed and not added to the transaction snapshot as the target transaction whenever the blockchain transaction that has not been added to the transaction snapshot is re-executed; and schedule the target transaction again until all blockchain transactions are added to the transaction snapshot.
[0296] Furthermore, the target transaction is obtained whenever one of the blockchain transactions is executed, and the first reference transaction has been added to the transaction snapshot. The first scheduling module 1204 is specifically used to:
[0297] When the first weight is greater than the sum of the first weights, replacing the first reference transaction in the transaction snapshot with the target transaction;
[0298] Alternatively, when the first weight is less than the sum of the first weights, re-execute the target transaction;
[0299] Alternatively, when the first weight is equal to the sum of the first weights, the first reference transaction in the transaction snapshot is replaced with the target transaction or the target transaction is re-executed.
[0300] Further, refer to Fig.15 , Fig.15 Another optional structural diagram of the scheduling device for blockchain transactions provided in an embodiment of the present application, the scheduling device 1200 for blockchain transactions further includes:
[0301] The fourth scheduling module 1207 is used to re-execute the replaced first reference transaction in the transaction snapshot; whenever the replaced first reference transaction is re-executed, the re-executed first reference transaction is used as the target transaction; and the target transaction is scheduled again until all blockchain transactions are added to the transaction snapshot.
[0302] Further, the resource consumption parameter includes at least one of the transaction execution time of the blockchain transaction, the number of read set keys of the blockchain transaction, the read set memory size of the blockchain transaction, the number of write set keys of the blockchain transaction, and the write set memory size of the blockchain transaction. The weight acquisition module 1203 is specifically used for:
[0303] Determine a score value corresponding to at least one of a transaction execution time, a number of read-set keys, a read-set memory size, a number of write-set keys, and a write-set memory size of a target transaction;
[0304] A first weight is obtained according to at least one score value.
[0305] The above-mentioned blockchain transaction scheduling device 1200 and blockchain transaction scheduling method are based on the same inventive concept. By executing multiple blockchain transactions, the executed blockchain transaction is used as the target transaction. When scheduling the conflicting target transactions and the first reference transaction, the first weight of the target transaction and the second weight of the first reference transaction are first obtained. Since the first weight and the second weight are both determined based on the resource consumption parameter, scheduling the target transaction according to the size relationship between the first weight and the second weight is equivalent to scheduling the target transaction according to the resource consumption parameter. Therefore, when scheduling the target transaction, it is possible to retain the blockchain transaction with more resource consumption and re-execute the blockchain transaction with less resource consumption, thereby avoiding resource waste and improving the performance of the blockchain network.
[0306] The electronic device for executing the scheduling method of the blockchain transaction provided in the embodiment of the present application may be a terminal. Fig.16 , Fig.16This is a partial structural block diagram of a terminal provided in an embodiment of the present application. The terminal includes: a camera assembly 1610, a memory 1620, an input unit 1630, a display unit 1640, a sensor 1650, an audio circuit 1660, a wireless fidelity (WiFi) module 1670, a processor 1680, and a power supply 1690. Those skilled in the art can understand that Fig.16 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0307] The camera assembly 1610 can be used to capture images or videos. Optionally, the camera assembly 1610 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions.
[0308] The memory 1620 may be used to store software programs and modules. The processor 1680 executes various functional applications and data processing of the terminal by running the software programs and modules stored in the memory 1620 .
[0309] The input unit 1630 may be used to receive input digital or character information and generate key signal input related to the terminal's settings and function control. Specifically, the input unit 1630 may include a touch panel 1631 and other input devices 1632 .
[0310] The display unit 1640 may be used to display input information or provided information and various menus of the terminal. The display unit 1640 may include a display panel 1641 .
[0311] The audio circuit 1660 , the speaker 1661 , and the microphone 1662 may provide an audio interface.
[0312] The power source 1690 may be alternating current, direct current, a disposable battery, or a rechargeable battery.
[0313] The number of sensors 1650 may be one or more, and the one or more sensors 1650 include but are not limited to: acceleration sensors, gyroscope sensors, pressure sensors, optical sensors, etc. Among them:
[0314] The acceleration sensor can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal. For example, the acceleration sensor can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1680 can control the display unit 1640 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor. The acceleration sensor can also be used for collecting game or user motion data.
[0315] The gyroscope sensor can detect the body direction and rotation angle of the terminal, and the gyroscope sensor can cooperate with the acceleration sensor to collect the user's 3D actions on the terminal. The processor 1680 can implement the following functions based on the data collected by the gyroscope sensor: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0316] The pressure sensor can be set in the side frame of the terminal and / or the lower layer of the display unit 1640. When the pressure sensor is set in the side frame of the terminal, the user's holding signal of the terminal can be detected, and the processor 1680 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor. When the pressure sensor is set in the lower layer of the display unit 1640, the processor 1680 controls the operability controls on the UI interface according to the user's pressure operation on the display unit 1640. The operability control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0317] The optical sensor is used to collect the ambient light intensity. In one embodiment, the processor 1680 can control the display brightness of the display unit 1640 according to the ambient light intensity collected by the optical sensor. Specifically, when the ambient light intensity is high, the display brightness of the display unit 1640 is increased; when the ambient light intensity is low, the display brightness of the display unit 1640 is decreased. In another embodiment, the processor 1680 can also dynamically adjust the shooting parameters of the camera assembly 1610 according to the ambient light intensity collected by the optical sensor.
[0318] In this embodiment, the processor 1680 included in the terminal can execute the blockchain transaction scheduling method of the previous embodiment.
[0319] The electronic device for executing the scheduling method of the above-mentioned blockchain transaction provided in the embodiment of the present application may also be a server, referring to Fig.17 , Fig.17This is a partial structural block diagram of a server provided in an embodiment of the present application. The server 1700 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 1722 (for example, one or more processors) and a memory 1732, and one or more storage media 1730 (for example, one or more mass storage devices) storing application programs 1742 or data 1744. Among them, the memory 1732 and the storage medium 1730 can be short-term storage or permanent storage. The program stored in the storage medium 1730 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server 1700. Furthermore, the central processing unit 1722 can be configured to communicate with the storage medium 1730 and execute a series of instruction operations in the storage medium 1730 on the server 1700.
[0320] The server 1700 may also include one or more power supplies 1726, one or more wired or wireless network interfaces 1750, one or more input and output interfaces 1758, and / or, one or more operating systems 1741, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0321] The processor in the server 1700 can be used to execute the scheduling method of the blockchain transaction.
[0322] An embodiment of the present application also provides a computer-readable storage medium, which is used to store program code, and the program code is used to execute the scheduling method of blockchain transactions in the aforementioned embodiments.
[0323] The embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the scheduling method for implementing the above-mentioned blockchain transaction.
[0324] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0325] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0326] It should be understood that in the description of the embodiments of the present application, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to not include the number, and above, below, within, etc. are understood to include the number.
[0327] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0328] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0329] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0330] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.
[0331] It should also be understood that the various implementation methods provided in the embodiments of the present application can be combined arbitrarily to achieve different technical effects.
[0332] The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the above implementation mode. Technical personnel familiar with the field can also make various equivalent modifications or substitutions under the shared conditions without violating the spirit of the present application. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.
Claims
1. A method for scheduling blockchain transactions, characterized in that: include: Obtain multiple blockchain transactions to be executed, and execute each of the blockchain transactions; Acquire a target transaction that has been executed from the plurality of blockchain transactions, and determine a first conflict relationship between the target transaction and at least one first reference transaction, wherein the first reference transaction is a blockchain transaction that has been currently executed except for the target transaction; When the first conflict relationship indicates that there is a conflict between the target transaction and the first reference transaction, obtaining a first weight of the target transaction and a second weight of the first reference transaction, wherein the first weight is determined based on a resource consumption parameter for executing the target transaction, and the second weight is determined based on a resource consumption parameter for executing the first reference transaction; The target transaction is scheduled according to the magnitude relationship between the first weight and the second weight.
2. The method for scheduling blockchain transactions according to claim 1, characterized in that: The scheduling of the target transaction according to the magnitude relationship between the first weight and the second weight includes: Scheduling the target transaction according to a magnitude relationship between the first weight and each of the second weights; Alternatively, the sum of the first weights of all the second weights is calculated, and the target transaction is scheduled according to the relationship between the first weight and the sum of the first weights.
3. The method for scheduling blockchain transactions according to claim 2, characterized in that: The target transaction is acquired when all the blockchain transactions are executed, the first reference transaction is not added to the transaction snapshot, and the target transaction is scheduled according to the relationship between the first weight and each of the second weights, including: When the first weight is greater than each of the second weights, adding the target transaction to the transaction snapshot; Alternatively, when the first weight is less than any of the second weights, re-execute the target transaction; Alternatively, when the first weight is equal to at least one of the second weights, and the first weight is greater than the remaining second weights, the target transaction is added to the transaction snapshot or the target transaction is re-executed.
4. The method for scheduling blockchain transactions according to claim 3, characterized in that: The adding the target transaction to the transaction snapshot or re-executing the target transaction includes: taking the target transaction and the first reference transaction having the same weight as the target transaction as a first transaction set; One of the blockchain transactions in the transaction set is added to the transaction snapshot, and the remaining blockchain transactions in the transaction set are re-executed.
5. The method for scheduling blockchain transactions according to claim 3 or 4, characterized in that: The scheduling method further includes: Whenever the blockchain transactions that are not added to the transaction snapshot are re-executed, the blockchain transactions that are re-executed and not added to the transaction snapshot are used as the target transactions; The target transaction is scheduled again until all the blockchain transactions are added to the transaction snapshot.
6. The method for scheduling blockchain transactions according to claim 2, characterized in that: The target transaction is obtained whenever one of the blockchain transactions is executed, the first reference transaction is not added to the transaction snapshot, and the target transaction is scheduled according to the relationship between the first weight and the sum of the first weights, including: When the first weight is greater than the sum of the first weights, waiting for a preset time, and scheduling the target transaction after the preset time is reached; Alternatively, when the first weight is less than the sum of the first weights, re-executing the target transaction; Alternatively, when the first weight is equal to the sum of the first weights, wait for a preset time period and schedule the target transaction or re-execute the target transaction after the preset time period is reached.
7. The method for scheduling blockchain transactions according to claim 6, characterized in that: The determining a first conflict relationship between the target transaction and at least one first reference transaction includes: Determine a second conflict relationship between the target transaction and a second reference transaction, wherein the second reference transaction is the blockchain transaction other than the target transaction that has been currently executed and added to the transaction snapshot; When the second conflict relationship indicates that there is no conflict between the target transaction and the second reference transaction, a first conflict relationship between the target transaction and at least one first reference transaction is determined.
8. The method for scheduling blockchain transactions according to claim 6, characterized in that: The scheduling of the target transaction after the preset time period is reached includes: After the preset time period is reached, determining a third conflict relationship between the target transaction and at least one third reference transaction, wherein the third reference transaction is the blockchain transaction other than the target transaction that has been currently executed and has not been added to the transaction snapshot; When the third conflict relationship indicates that there is a conflict between the target transaction and the third reference transaction, obtaining a third weight of the third reference transaction, wherein the third weight is determined based on a resource consumption parameter of executing the third reference transaction; The sum of the second weights of all the third weights is calculated, and the target transaction is scheduled according to the relationship between the first weight and the sum of the second weights.
9. The method for scheduling blockchain transactions according to claim 8, characterized in that: The step of scheduling the target transaction according to the relationship between the first weight and the sum of the second weight includes: When the first weight is greater than the sum of the second weights, adding the target transaction to the transaction snapshot; Alternatively, when the first weight is less than the sum of the second weights, re-executing the target transaction; Alternatively, when the first weight is equal to the sum of the second weights, the target transaction is added to the transaction snapshot or the target transaction is re-executed.
10. The method for scheduling blockchain transactions according to claim 8, characterized in that: The determining a third conflict relationship between the target transaction and at least one third reference transaction includes: Determining a fourth conflict relationship between the target transaction and a fourth reference transaction, wherein the fourth reference transaction is the blockchain transaction other than the target transaction that has been currently executed and has been added to the transaction snapshot; When the fourth conflict relationship indicates that there is no conflict between the target transaction and the fourth reference transaction, a third conflict relationship between the target transaction and at least one third reference transaction is determined.
11. The method for scheduling blockchain transactions according to any one of claims 6 to 10, characterized in that: The scheduling method further includes: Whenever the blockchain transaction that has not been added to the transaction snapshot is re-executed, the blockchain transaction that has been re-executed and not added to the transaction snapshot is used as the target transaction; The target transaction is scheduled again until all the blockchain transactions are added to the transaction snapshot.
12. The method for scheduling blockchain transactions according to claim 2, characterized in that: The target transaction is obtained whenever one of the blockchain transactions is executed, the first reference transaction has been added to the transaction snapshot, and the target transaction is scheduled according to the relationship between the first weight and the sum of the first weights, including: When the first weight is greater than the sum of the first weights, replacing the first reference transaction in the transaction snapshot with the target transaction; Alternatively, when the first weight is less than the sum of the first weights, re-executing the target transaction; Alternatively, when the first weight is equal to the first weight sum, the first reference transaction in the transaction snapshot is replaced with the target transaction or the target transaction is re-executed.
13. The method for scheduling blockchain transactions according to claim 12, characterized in that: The scheduling method further includes: re-executing the first reference transaction that is replaced in the transaction snapshot; Whenever the replaced first reference transaction is re-executed, the re-executed first reference transaction is used as the target transaction; The target transaction is scheduled again until all the blockchain transactions are added to the transaction snapshot.
14. The method for scheduling blockchain transactions according to claim 1, characterized in that: The resource consumption parameter includes at least one of the transaction execution time of the blockchain transaction, the number of read set keys of the blockchain transaction, the read set memory size of the blockchain transaction, the number of write set keys of the blockchain transaction, and the write set memory size of the blockchain transaction, and the first weight is determined by the following steps: Determine a score value corresponding to at least one of the transaction execution time, the number of read set keys, the read set memory size, the number of write set keys, and the write set memory size of the target transaction; The first weight is obtained according to at least one of the score values.
15. A scheduling device for blockchain transactions, characterized in that: include: An execution module, used to obtain multiple blockchain transactions to be executed and execute each of the blockchain transactions; a conflict detection module, configured to obtain a target transaction that has been executed from the plurality of blockchain transactions, and determine a first conflict relationship between the target transaction and at least one first reference transaction, wherein the first reference transaction is a blockchain transaction that has been executed currently except for the target transaction; a weight acquisition module, configured to acquire a first weight of the target transaction and a second weight of the first reference transaction when the first conflict relationship indicates that there is a conflict between the target transaction and the first reference transaction, wherein the first weight is determined based on a resource consumption parameter for executing the target transaction, and the second weight is determined based on a resource consumption parameter for executing the first reference transaction; The first scheduling module is used to schedule the target transaction according to the relationship between the first weight and the second weight.
16. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method for scheduling blockchain transactions described in any one of claims 1 to 14 is implemented.
17. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the scheduling method for blockchain transactions described in any one of claims 1 to 14 is implemented.
18. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the scheduling method for blockchain transactions described in any one of claims 1 to 14 is implemented.
Citation Information
Patent Citations
System for managing resources in virtual environment and implementation method thereof
CN102103518A
Serial execution method, device and system for task instances
CN102455932A
Blockchain intelligent contract transaction concurrent execution method
CN110517140A
Spatial multi-aircraft multi-target cooperative scheduling method
CN114997613A
Transaction execution method and device, computer equipment and medium
CN115760405A
Cited By
Power transaction method based on block chain technology
CN121213079A
