Method and device for executing transactions in blockchain system
By introducing a sort lock queue mechanism into the blockchain system, the problem of insufficient scalability of the blockchain system is solved, and efficient execution of transactions and effective utilization of computing resources is achieved.
Patent Information
- Application Number
- CN202110991244.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-26
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2041-08-26
AI Technical Summary
Blockchain systems have weak scalability in computing and storage, resulting in insufficient throughput and difficult to meet the needs of applications.
By introducing a sort lock queue mechanism into the blockchain node, the target parameters and sorting of transactions are determined, and transaction target information is added to each sort lock queue, triggering the execution of transaction operations.
Ensure that all transactions have a globally unique order in the blockchain system, improving the efficiency of transaction execution and the utilization of computing resources.
Smart Images

Figure CN113656510B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of blockchain technology, and more particularly, to a method and device for executing transactions in a blockchain system. Background Art
[0002] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is a chain data structure that combines data blocks in a sequential manner in chronological order, and a distributed ledger that cannot be tampered with or forged by cryptography. Due to the characteristics of blockchain such as decentralization, information cannot be tampered with, and autonomy, blockchain has also received more and more attention and application.
[0003] At present, in the relevant technologies, the scalability of blockchain systems in computing and storage is weak, which restricts the throughput of blockchain systems and makes it difficult to meet the needs of applications. Therefore, it is necessary to provide a method for executing transactions in a blockchain system. Summary of the invention
[0004] One or more embodiments of the present specification provide a method and device for executing transactions in a blockchain system.
[0005] According to a first aspect, a method for executing a transaction in a blockchain system is provided, the method being executed by a node of the blockchain, the method comprising:
[0006] Determining various target parameters of the received transaction access and the corresponding ranking of the transactions;
[0007] Adding target information for the transaction to each sorting lock queue corresponding to each target parameter according to the sorting;
[0008] Based on the various sorting lock queues, the execution of the operation corresponding to the transaction is triggered; wherein the operation corresponding to the transaction includes a read and / or write operation.
[0009] According to a second aspect, a device for executing transactions in a blockchain system is provided, which is deployed on a node of the blockchain, and the device includes:
[0010] A determination module, used to determine each target parameter of the received transaction access and the corresponding order of the transaction;
[0011] An adding module, configured to add target information for the transaction in each sorting lock queue corresponding to each target parameter according to the sorting;
[0012] An execution module is used to trigger the execution of the operation corresponding to the transaction based on the various sorting lock queues; wherein the operation corresponding to the transaction includes a read and / or write operation.
[0013] According to a third aspect, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of the above-mentioned first aspects is implemented.
[0014] According to a fourth aspect, a computing device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in any one of the first aspects is implemented.
[0015] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:
[0016] The method and device for executing transactions in a blockchain system provided by the embodiments of this specification trigger the execution of operations corresponding to the transaction based on the sorting lock queues corresponding to the target parameters of the received transaction access, thereby ensuring that all transactions sent to the blockchain system have a globally unique order, thereby more effectively utilizing computing resources and improving the efficiency of transaction execution.
[0017] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 This is an architecture diagram of a blockchain system shown in this specification according to an exemplary embodiment;
[0020] Figure 2 This is a flowchart of a method for executing a transaction in a blockchain system according to an exemplary embodiment of this specification;
[0021] Figure 3a is a schematic diagram of a sorting lock queue according to an exemplary embodiment of this specification;
[0022] Figure 3b is a schematic diagram of a sorting lock queue according to an exemplary embodiment of this specification;
[0023] Figure 4 is an interactive flow chart of another method for executing transactions in a blockchain system according to an exemplary embodiment of this specification;
[0024] Figure 5 It is a block diagram of a device for executing transactions in a blockchain system according to an exemplary embodiment of the present specification. DETAILED DESCRIPTION
[0025] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.
[0026] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit the present application. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0027] It should be understood that, although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0028] like Figure 1 It should be noted that the solution for executing transactions in the blockchain system provided in the embodiments of this specification does not rely on Figure 1 The blockchain system architecture shown can also be applied to other blockchain system architectures.
[0029] exist Figure 1In the blockchain system, the blockchain system may include execution shards and consensus shards, wherein the consensus shards may include n consensus shards such as shard AS1, shard AS2, ... shard ASn, etc. The execution shards may include m execution shards such as shard ES1, shard ES2, ... shard ESm, etc. Different shards each include multiple nodes, and each node may be implemented as any device, server or device cluster with computing and processing capabilities. It can be understood that Figure 1 The n consensus shards and m execution shards are shown for example only. In fact, the blockchain system may include any number of consensus shards and execution shards. For example, the number of consensus shards may be one or more, the number of execution shards may be one or more, and the number of consensus shards may be the same as or different from the number of execution shards.
[0030] Specifically, first, the consensus shard can connect with the client, receive transactions from the client, and reach consensus on the received transactions. Different consensus shards can receive and reach consensus on different transactions. Then, each consensus shard can send the consensus results obtained by each consensus to the nodes of each execution shard. The consensus results can include multiple transactions to be executed (i.e., multiple transactions that have successfully reached consensus) and the execution order of the multiple transactions. The nodes of the execution shard complete the execution of the multiple transactions.
[0031] It should be noted that if the blockchain system includes multiple execution shards, different execution shards can store the status of different accounts. The node of any execution shard can determine the first transaction associated with the execution shard among the multiple transactions included in the received consensus result, and execute the operation corresponding to the first transaction, which may include a read operation and / or a write operation. Among them, the parameters accessed by the first transaction associated with the execution shard include at least one target parameter, and the status of the account corresponding to the target parameter is stored in the execution shard. In addition, the node of the execution shard can ignore transactions other than the first transaction among the multiple transactions. (For the detailed process of any node of any execution shard executing the operation corresponding to any first transaction, please refer to the following Figure 2 Description of the Embodiments)
[0032] For example, shard AS1 receives transactions a and b, and reaches consensus on transactions a and b. Shard AS2 receives transactions c and d, and reaches consensus on transactions c and d. Shard ASn receives transactions x and y, and reaches consensus on transactions x and y. After consensus, shard AS1 can send transactions a and b that have been successfully agreed upon, as well as their order, to shard ES1, shard ES2, ... shard ESm, respectively. Shard AS2 can send transactions c and d that have been successfully agreed upon, as well as their order, to shard ES1, shard ES2, ... shard ESm, respectively. ... Shard ASn can send transactions x and y that have been successfully agreed upon, as well as their order, to shard ES1, shard ES2, ... shard ESm, respectively.
[0033] It should be noted that in order to ensure that the execution order of different execution shards is consistent when executing operations corresponding to transactions, each execution shard can sort the transactions received from the consensus shard according to preset rules. For example, transactions are sorted according to the source of the transaction. For example, shard AS1 obtains multiple groups of transactions (a group of transactions is a transaction included in a consensus result) through consensus, and sends them to each execution shard. The multiple groups of transactions are C11, C12, and C13. Shard AS2 obtains multiple groups of transactions (a group of transactions is a transaction included in a consensus result) through consensus, and sends them to each execution shard. The multiple groups of transactions are C21, C22, and C23. ... Shard ASn obtains multiple groups of transactions through consensus and sends them to each execution shard. The multiple groups of transactions are Cn1, Cn2, and Cn3. After each execution shard receives multiple groups of transactions sent by each consensus shard, it sorts the multiple groups of transactions in the order of C11 (source is shard AS1), C21 (source is shard AS2), ... Cn1 (source is shard ASn), C12 (source is shard AS1), C22 (source is shard AS2), ... Cn2 (source is shard ASn), C13 (source is shard AS1), C23 (source is shard AS2), ... Cn3 (source is shard ASn).
[0034] Next, shard ES1 determines that the first transaction associated with it includes transaction a, transaction c, etc., based on the accounts corresponding to the parameters (read and / or written parameters) accessed by each received transaction. Shard ES2 determines that the first transaction associated with it includes transaction b, ... transaction x. ... Shard ESm determines that the first transaction associated with it includes transaction d, ... transaction x. Among them, transaction x is a cross-shard transaction, the status of the account corresponding to the parameters read by transaction x is stored in shard ES2, and the status of the account corresponding to the parameters written by transaction x is stored in shard ESm. Finally, shard ES1 executes the operations corresponding to transactions a, transaction c, ..., and updates the world state of shard ES1 based on the results of the execution. Shard ES2 executes the operations corresponding to transactions b, ..., transaction x, and updates the world state of shard ES2 based on the results of the execution. Among them, the operation corresponding to transaction x includes reading the status value of parameter S, so the status value corresponding to the read parameter S also needs to be sent to shard ESm. ... Shard ESm receives the state value corresponding to parameter S sent by shard ES2 (for executing the write operation of transaction x), executes the operations corresponding to transactions d, ... transaction x, and updates the world state of shard ESm based on the execution results.
[0035] The solution provided in this specification will be described in detail below in conjunction with specific embodiments.
[0036] like Figure 2 As shown, Figure 2 According to a flowchart of a method for executing a transaction in a blockchain system shown in an exemplary embodiment, the method can be executed by a node of the blockchain, including the following steps:
[0037] In step 201, each target parameter of the received transaction access and the corresponding ranking of the transaction are determined.
[0038] In this embodiment, the node of the blockchain can determine each target parameter accessed by the received transaction and the order corresponding to the transaction. The target parameter accessed by the transaction includes the parameter read and / or the parameter written by the transaction, and the state of the account corresponding to any target parameter accessed by the transaction is stored in the node of the blockchain. Specifically, the consensus result after consensus on the transaction can include the order corresponding to the transaction, and the order corresponding to the consensus transaction can be obtained from the consensus result.
[0039] In step 203, target information for the transaction is added to each sorting lock queue corresponding to each of the target parameters according to the sorting.
[0040] In this embodiment, a preset list is stored in the node of the blockchain, and the correspondence between the parameters and the addresses of the sorting lock queues is recorded in the list. The sorting lock queues corresponding to the target parameters accessed by the transaction can be found from the list, and then the target information for the transaction is added to the sorting lock queues according to the order corresponding to the transaction.
[0041] Specifically, for any target parameter, the target address of the sorting lock queue corresponding to the target parameter can be found from the above preset list. If the target address is found, the target information for the transaction is added to the sorting lock queue corresponding to the target parameter based on the target address according to the above sorting. If the target address is not found, a sorting lock queue corresponding to the target parameter can be created, the target information for the transaction can be added to the first position in the newly created sorting lock queue, and the corresponding relationship between the target address of the newly created sorting lock queue and the target parameter is added to the preset list.
[0042] The target information for the transaction added to the sort lock queue corresponding to any target parameter accessed by the transaction includes the identifier of the transaction and the read / write properties of the target parameter in the transaction. The identifier of the transaction may include but is not limited to the ID of the transaction, the hash value obtained by hashing the ID of the transaction, the hash value obtained by hashing the transaction data of the transaction, etc.
[0043] In step 205, based on each sorting lock queue, the execution of the operation corresponding to the transaction is triggered.
[0044] In this embodiment, the operation corresponding to the transaction may include only read operations (for example, a transaction to query an account balance may involve only read operations), or may include only write operations (for example, a transaction to store evidence may involve only read operations), or may include both read operations and write operations (for example, a transaction to update a certain status of an account may involve both read operations and write operations).
[0045] Specifically, step 205, based on each sorting lock queue, triggering the execution of the operation corresponding to the transaction may include: sub-step 2051, determining whether the trigger condition is met based on the position of the target information for the transaction in each sorting lock queue; and sub-step 2053, triggering the execution of the operation corresponding to the transaction when the trigger condition is met.
[0046] First, in sub-step 2051, the number of target parameters accessed by the transaction can be determined as the initial value of the count value. At least when it is determined that the target information for the transaction is at the first position in any sorting lock queue, the count value is reduced by 1.
[0047] Optionally, in the sorting lock queue corresponding to the target parameter written by the transaction, if the target information for the transaction is at the first place, the count value is reduced by 1. In the sorting lock queue corresponding to the target parameter read by the transaction, if the target information for the transaction is at the first place, or there is no information including the write attribute before the target information for the transaction, the count value is reduced by 1. When the count value is 0, it is determined that the trigger condition is met.
[0048] Finally, in sub-step 2053, when the triggering condition is met, the execution of the operation corresponding to the transaction is triggered. The operation corresponding to the transaction can be executed directly, or the transaction can be put into the execution pool and a transaction can be randomly taken out to execute the corresponding operation.
[0049] Optionally, in step 207, a dequeue operation is performed on each sort lock queue for the target information of the transaction.
[0050] In this embodiment, after the operation corresponding to the transaction is completed, a dequeue operation for the target information for the transaction can be performed for each sorting lock queue. For any sorting lock queue, the target information can be deleted, and the target information for other transactions after the target information can be moved forward by one position.
[0051] For ease of understanding, a complete application example is provided below to schematically illustrate the solution of this embodiment. Specifically, node A of the blockchain stores a preset list, which includes the address of sorting lock queue 1 corresponding to parameter k1, the address of sorting lock queue 2 corresponding to parameter k2, ... the address of sorting lock queue m corresponding to parameter km. The status of the account corresponding to parameter k1, parameter k2, ... parameter km is stored in node A.
[0052] Node A receives multiple transactions, which are arranged in order as transaction 1, transaction 2, and transaction 3. Among them, the parameters accessed by transaction 1 include the read parameter k1 and the written parameter k2, and the number of target parameters accessed is 2, and 2 is used as the initial value of the count value corresponding to transaction 1. The parameters accessed by transaction 2 include the read parameter k1 and the read parameter k2, and the number of target parameters accessed is 2, and 2 is used as the initial value of the count value corresponding to transaction 2. The parameters accessed by transaction 3 include the read parameter k1 and the written parameter k2, and the number of target parameters accessed is 2, and 2 is used as the initial value of the count value corresponding to transaction 3.
[0053] First, based on the preset list, the address of the sorting lock queue 1 corresponding to the parameter k1 and the address of the sorting lock queue 2 corresponding to the parameter k2 can be found. And according to the order of the transactions, the first target information for transaction 1, the second target information for transaction 2, and the third target information for transaction 3 are added to the sorting lock queue 1 and the sorting lock queue 2 respectively.
[0054] like Figure 3a As shown, in the sorting lock queue 1, the first target information for transaction 1 is located at the first position, including the identifier TX1 of transaction 1 and the read-write attribute "read" of parameter k1 in transaction 1. The second target information for transaction 2 is located at the second position, including the identifier TX2 of transaction 2 and the read-write attribute "read" of parameter k1 in transaction 2. The third target information for transaction 3 is located at the third position, including the identifier TX3 of transaction 3 and the read-write attribute "read" of parameter k1 in transaction 3. In the sorting lock queue 2, the first target information for transaction 1 is located at the first position, including the identifier TX1 of transaction 1 and the read-write attribute "write" of parameter k2 in transaction 1. The second target information for transaction 2 is located at the second position, including the identifier TX2 of transaction 2 and the read-write attribute "read" of parameter k2 in transaction 2. The third target information for transaction 3 is located at the third position, including the identifier TX3 of transaction 3 and the read-write attribute "write" of parameter k2 in transaction 3.
[0055] Depend on Figure 3a It can be seen that the first target information is at the first place in both sorting lock queue 1 and sorting lock queue 2, so the count value corresponding to transaction 1 can be reduced by 1 twice. Although the second target information is not at the first place in sorting lock queue 1, the read-write attribute corresponding to the first target information before the second target information is read, so the count value corresponding to transaction 2 can be reduced by 1. The third target information is not at the first place in sorting lock queue 1, but the read-write attributes corresponding to the first target information and the second target information before the third target information are both read, so the count value corresponding to transaction 3 can be reduced by 1. At this time, the count value corresponding to transaction 1 is 0, the count value corresponding to transaction 2 is 1, and the count value corresponding to transaction 3 is 1.
[0056] Since the count value corresponding to transaction 1 is 0, transaction 1 can be put into the execution pool and wait for execution. After the operation corresponding to transaction 1 is completed, the dequeue operation of the first target information is performed. Specifically, the first target information in sort lock queue 1 and sort lock queue 2 is deleted, and the second target information and the third target information are moved forward by one position respectively. Figure 3b As shown, the sort lock queue 1 and the sort lock queue 2 are after the dequeue operation on the first target information is performed.
[0057] Depend on Figure 3b It can be seen that the second target information is in the first place in the sorting lock queue 2, so the count value corresponding to transaction 2 can be reduced by 1. The third target information is not in the first place in the sorting lock queue 2, so the count value corresponding to transaction 3 remains unchanged. At this time, the count value corresponding to transaction 2 is 0. Transaction 2 can be put into the execution pool and wait for execution. After the operation corresponding to transaction 2 is executed, the dequeue operation of the second target information is performed. Specifically, the second target information in the sorting lock queue 1 and the sorting lock queue 2 is deleted, and the subsequent third target information is moved forward by one position.
[0058] The method for executing transactions in a blockchain system provided by the above embodiments of this specification triggers the execution of operations corresponding to the transaction based on the sorting lock queues corresponding to the target parameters of the received transaction access, thereby ensuring that all transactions sent to the blockchain system have a globally unique order, thereby more effectively utilizing computing resources and improving the efficiency of transaction execution.
[0059] like Figure 4 As shown, Figure 4 is an interactive flow chart of a method for executing transactions in a blockchain system according to an exemplary embodiment. Figure 1 Based on the architecture of the blockchain system shown, a scheme for executing transactions in the blockchain system is described. The blockchain system includes execution sharding and consensus sharding. The method includes the following steps:
[0060] In step 401, the client sends the transaction to be agreed upon to the node of the consensus shard.
[0061] In step 403, the nodes of the consensus shard reach consensus on the received transaction.
[0062] In this embodiment, the client can send the transaction to be agreed upon to the node of the consensus shard connected to it, and the node of the consensus shard will reach consensus on the received transaction to obtain a consensus result. The consensus result may include multiple transactions to be executed and the execution order corresponding to the multiple transactions, wherein the transaction to be executed is the transaction with successful consensus.
[0063] In step 405, the nodes of the consensus shard send the consensus results to the nodes of the execution shard.
[0064] In this embodiment, the node of the consensus shard can send the multiple transactions to be executed and the execution order corresponding to the multiple transactions to the node of the execution shard, and the node of the execution shard completes the execution operation of the multiple transactions. Among them, the number of execution shards can be one or more. If the number of execution shards is more than one, the node of the consensus shard can send the multiple transactions to be executed and the execution order corresponding to the multiple transactions to each node included in each execution shard in the multiple execution shards.
[0065] In step 407, the node executing the shard determines the parameters accessed by each transaction in the multiple transactions included in the consensus result.
[0066] In this embodiment, the node executing the sharding can determine the parameters accessed by each transaction by obtaining the identifiers of the parameters accessed by each transaction in the multiple transactions. The parameters accessed by any transaction may include only the parameters read by the transaction, or only the parameters written by the transaction, or both the parameters read by the transaction and the parameters written by the transaction.
[0067] In one implementation, the client may pre-acquire the identifiers of the parameters accessed by the transaction to be sent, and send the transaction and the identifiers of the parameters accessed by the transaction to the nodes of the consensus shard. After the nodes of the consensus shard reach consensus on the transaction, the transaction and the identifiers of the parameters accessed by the transaction are sent to the nodes of the execution shard. In another implementation, the nodes of the execution shard may obtain the identifiers of the parameters accessed by the received transaction by pre-executing the transaction or by using static analysis based on the parameters of the smart contract.
[0068] In step 409, the node executing the shard performs the operation corresponding to the first transaction based on the parameters accessed by each transaction.
[0069] In this embodiment, if there are multiple execution shards, for any first execution shard among the multiple execution shards, the node of the first execution shard executes the operation corresponding to the first transaction associated with the first execution shard among the multiple transactions. The parameters accessed by the first transaction associated with the first execution shard include at least one target parameter, and the state of the account corresponding to the target parameter is stored in the first execution shard.
[0070] In this embodiment, the operations corresponding to any transaction may include only read operations (for example, a transaction to query an account balance may involve only read operations), or may include only write operations (for example, a transaction to store evidence may involve only read operations), or may include both read operations and write operations (for example, a transaction to update a certain status of an account may involve both read operations and write operations).
[0071] In one implementation, the first transaction among multiple transactions may be determined based on the parameters accessed by each transaction, and the identifier of the first transaction may be recorded, and then the first transaction may be executed in sequence according to the recorded identifier.
[0072] In another implementation, the first transaction can also be determined based on the parameters accessed by each transaction, and the target parameters accessed by the first transaction (parameters whose corresponding account status is stored in the first execution shard) and the order corresponding to the first transaction can be determined. Then, the sorting lock queues corresponding to the target parameters accessed by the first transaction are searched, and the target information for the first transaction is added to the sorting lock queues according to the order corresponding to the first transaction, and the execution of the operation corresponding to the first transaction is triggered based on the sorting lock queues.
[0073] In step 411, the node executing the slice updates the world state of the executed slice according to the execution result.
[0074] In this embodiment, after executing the operation corresponding to the first transaction, the node of the execution shard may update the world state of the execution shard according to the result of the execution. Specifically, if there are multiple execution shards, for any first execution shard among the multiple execution shards, after executing the operation corresponding to the first transaction, if it is determined according to the execution result that the operation corresponding to the first transaction includes a write operation, the world state of the first execution shard may be updated based on the result of executing the write operation.
[0075] The method for executing transactions in a blockchain system provided by the above embodiments of this specification divides the blockchain system into an execution shard and a consensus shard, and uses the consensus shard to reach consensus on received transactions, and uses the execution shard to execute transactions reached by the consensus shard, thereby decoupling the consensus and execution functions of the blockchain system and improving the fault tolerance of the blockchain system and the execution efficiency of transactions.
[0076] It should be noted that although the operations of the methods of the embodiments of this specification are described in a specific order in the above embodiments, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. On the contrary, the steps depicted in the flowchart can change the order of execution. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step for execution, and / or one step can be decomposed into multiple steps for execution.
[0077] Corresponding to the aforementioned method embodiment for executing transactions in a blockchain system, this specification also provides an embodiment of an apparatus for executing transactions in a blockchain system.
[0078] like Figure 5 As shown, Figure 5 This is a block diagram of a device for executing transactions in a blockchain system according to an exemplary embodiment of the present specification, which is deployed on a node of the blockchain. The device may include: a determination module 501, an addition module 502 and an execution module 503.
[0079] The determination module 501 is used to determine each target parameter of the received transaction access and the order corresponding to the transaction.
[0080] The adding module 502 is used to add the target information for the transaction in each sorting lock queue corresponding to each target parameter according to the sorting.
[0081] The execution module 503 is used to trigger the execution of the operation corresponding to the transaction based on each sorting lock queue, wherein the operation corresponding to the transaction includes a read and / or write operation.
[0082] In some implementations, the target parameters accessed by the transaction include parameters read and / or parameters written in the transaction.
[0083] In some other implementations, the target information for the transaction added to the sort lock queue corresponding to any target parameter includes an identifier of the transaction and a read / write attribute of the target parameter in the transaction.
[0084] In some other implementations, the execution module 503 may include: a determination submodule and a triggering submodule (not shown in the figure).
[0085] The determination submodule is used to determine whether the trigger condition is satisfied based on the position of the target information in each sorting lock queue.
[0086] The trigger submodule is used to trigger the execution of the operation corresponding to the transaction when the trigger conditions are met.
[0087] In other embodiments, the determination submodule is configured to: determine the number of target parameters accessed by the transaction as the initial value of the count value, and at least when it is determined that the target information is located first in any sort lock queue, reduce the count value by 1, and when the count value is 0, determine that the trigger condition is met.
[0088] In some other embodiments, the device may further include: a releasing module (not shown in the figure).
[0089] The release module is used to execute a dequeue operation on the target information for each sort lock queue.
[0090] In other implementations, the adding module may add the target information for the transaction to the sorting lock queue corresponding to any target parameter according to the above sorting in the following manner:
[0091] Search the preset list for the target address of the sorting lock queue corresponding to the target parameter. If the target address is found, add the target information for the transaction to the sorting lock queue corresponding to the target parameter based on the target address according to the sorting; if the target address is not found, create a sorting lock queue corresponding to the target parameter, and add the target information for the transaction to the first position of the newly created sorting lock queue.
[0092] In some other embodiments, the blockchain system may include execution sharding and consensus sharding, and the node where the device is deployed is the node where the sharding is executed. The device may also include: a receiving module (not shown in the figure).
[0093] Among them, the receiving module is used to receive the transaction to be executed after consensus from the node of the consensus shard.
[0094] In some other embodiments, the blockchain system includes multiple execution shards, and the node where the device is deployed is a node of a first execution shard among the multiple execution shards. The account state corresponding to the target parameter accessed by the transaction is stored in the first execution shard.
[0095] It should be understood that the above device can be pre-set in the node of the blockchain, or loaded into the node of the blockchain by downloading, etc. The corresponding modules in the above device can cooperate with the modules in the node of the blockchain to implement the solution of executing transactions in the blockchain system.
[0096] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of one or more embodiments of the present specification. A person of ordinary skill in the art can understand and implement them without creative work.
[0097] One or more embodiments of the present specification also provide a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 2 A method for executing transactions in a blockchain system provided in any one of the embodiments of FIG. 3 .
[0098] One or more embodiments of the present specification further provide a computing device, including a memory and a processor, wherein the memory stores an executable code, and when the processor executes the executable code, the above-mentioned Figure 2A method for executing transactions in a blockchain system provided in any one of the embodiments of FIG. 3 .
[0099] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0100] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0101] Those of ordinary skill in the art should also be further aware that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those of ordinary skill in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application. Among them, the software module can be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0102] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only the specific implementation method of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A method for executing a transaction in a blockchain system, executed by a node of the blockchain, the method comprising: Determining various target parameters of the received transaction access and the corresponding ranking of the transactions; Adding target information for the transaction to each sorting lock queue corresponding to each target parameter according to the sorting; Based on the respective sorting lock queues, triggering the execution of the operation corresponding to the transaction; wherein the operation corresponding to the transaction includes a read and / or write operation; wherein the target parameter accessed by the transaction includes a parameter read and / or a parameter written in the transaction; The triggering of the execution of the operation corresponding to the transaction based on the respective sorting lock queues includes: Determine the number of target parameters accessed by the transaction as an initial value of the count value; At least when it is determined that the target information is located at the first position in any sort lock queue, the count value is reduced by 1; When the count value is 0, it is determined that the trigger condition is met; When the triggering condition is met, the execution of the operation corresponding to the transaction is triggered.
2. The method according to claim 1, wherein: The target information for the transaction added to the sort lock queue corresponding to any target parameter includes an identifier of the transaction and a read / write attribute of the target parameter in the transaction.
3. The method according to claim 1, wherein: After the operations corresponding to the transaction are completed, it also includes: For each of the sorting lock queues, a dequeue operation is performed on the target information.
4. The method according to claim 1, wherein: Add the target information for the transaction to the sort lock queue corresponding to any target parameter according to the sort in the following manner: Find the target address of the sort lock queue corresponding to the target parameter from the preset list; If the target address is found, adding the target information for the transaction in the sorting lock queue corresponding to the target parameter based on the target address according to the sorting; If the target address is not found, a sorting lock queue corresponding to the target parameter is created, and the target information for the transaction is added to the first position of the newly created sorting lock queue.
5. The method according to claim 1, wherein: The blockchain system includes an execution shard and a consensus shard; the node executing the method is the node of the execution shard; The method further includes: receiving the transaction to be executed after consensus from the node of the consensus shard.
6. The method according to claim 5, wherein: The blockchain system includes multiple execution shards, and the node executing the method is a node of a first execution shard among the multiple execution shards; The account state corresponding to the target parameter of the transaction access is stored in the first execution shard.
7. A device for executing transactions in a blockchain system, deployed on a node of the blockchain, the device comprising: A determination module, used to determine each target parameter of the received transaction access and the corresponding order of the transaction; An adding module, configured to add target information for the transaction in each sorting lock queue corresponding to each target parameter according to the sorting; An execution module, configured to trigger the execution of the operation corresponding to the transaction based on the respective sorting lock queues; wherein the operation corresponding to the transaction includes a read and / or write operation; wherein the target parameter accessed by the transaction includes a parameter read and / or a parameter written in the transaction; Wherein, the execution module is configured to: Determine the number of target parameters accessed by the transaction as an initial value of the count value; At least when it is determined that the target information is located at the first position in any sort lock queue, the count value is reduced by 1; When the count value is 0, it is determined that the trigger condition is met; The trigger submodule is used to trigger the execution of the operation corresponding to the transaction when the trigger condition is met.
8. The device according to claim 7, wherein: The target information for the transaction added to the sort lock queue corresponding to any target parameter includes an identifier of the transaction and a read / write attribute of the target parameter in the transaction.
9. The device according to claim 7, wherein: The device also includes: The release module is used to perform a dequeue operation on the target information for each sort lock queue.
10. The device according to claim 7, wherein: The adding module adds the target information for the transaction in the sorting lock queue corresponding to any target parameter according to the sorting in the following manner: Find the target address of the sort lock queue corresponding to the target parameter from the preset list; If the target address is found, adding the target information for the transaction in the sorting lock queue corresponding to the target parameter based on the target address according to the sorting; If the target address is not found, a sorting lock queue corresponding to the target parameter is created, and the target information for the transaction is added to the first position of the newly created sorting lock queue.
11. The device according to claim 7, wherein: The blockchain system includes an execution shard and a consensus shard; the node where the device is deployed is the node of the execution shard; Wherein, the device further comprises: A receiving module is used to receive the consensus-based transaction to be executed from the node of the consensus shard.
12. The device according to claim 11, wherein The blockchain system includes a plurality of execution shards, and the node where the device is deployed is a node of a first execution shard among the plurality of execution shards; The account state corresponding to the target parameter of the transaction access is stored in the first execution shard.
13. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 6.
14. A computing device, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method and device for realizing joint consensus fragmentation in alliance chain
CN112039860A
Transaction sorting method and device in super account book and computer equipment
CN112287400A
Alliance chain-oriented transaction parallel processing method and system
CN113205417A