Transaction processing method and blockchain node in blockchain system

By grouping and resource payment accounts for multiple transactions in the blockchain system, transactions that may fail to be executed due to insufficient resources are flagged, which solves the problem of low parallelism of transaction execution and insufficient resources in the blockchain system, and achieves more efficient transaction execution.

WO2025092876A1PCT designated stage expired Publication Date: 2025-05-08ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/128773
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-10-31
Filing Date
2024-10-31
Publication Date
2025-05-08

AI Technical Summary

Technical Problem

In a blockchain system, when processing multiple transactions belonging to the same block, it is difficult for the prior art to effectively manage resource payment accounts, resulting in low parallelism of transaction execution and may fail in transaction execution due to insufficient target resources.

Method used

By grouping multiple transactions, not using the resource payment account, several transactions including each resource payment account are determined, and transactions that may fail due to insufficient resources are marked based on the comparison of the resource consumption in the transaction and the number of resources held by the account. Then, according to the grouping results, transactions with unlabeled preset tags are executed concurrently.

Benefits of technology

It realizes that while ensuring fairness in transaction execution, it improves the parallelism of transaction execution, and avoids transaction execution failures caused by insufficient resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024128773_08052025_PF_FP_ABST
    Figure CN2024128773_08052025_PF_FP_ABST
Patent Text Reader

Abstract

A transaction processing method and a blockchain node in a blockchain system, for use in processing a plurality of transactions belonging to the same block, wherein an ith transaction comprises a first number of resources allowed to be consumed by the ith transaction, and a resource payment account. The method comprises: grouping a plurality of transactions, wherein a resource payment account in each transaction is not utilized; for any jth resource payment account among a plurality of resource payment accounts in the plurality of transactions, determining a plurality of transactions comprising the jth resource payment account from among the plurality of transactions according to an arrangement sequence of the plurality of transactions; when the sum of first numbers of resources comprised in respective first K transactions among a plurality of transactions is greater than a current number of target resources held by the jth resource payment account, and the sum of first numbers of resources comprised in respective first K-1 transactions is not greater than the current number, marking transactions after a (k-1)-th transaction with a preset label; and according to a grouping result of the plurality of transactions, concurrently executing transactions without the preset label.
Need to check novelty before this filing date? Find Prior Art

Description

Transaction processing method and blockchain node in blockchain system

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on October 31, 2023, with application number 202311437155.7 and application name “Transaction Processing Method and Blockchain Node in Blockchain System”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The embodiments of this specification belong to the field of blockchain technology, and more particularly to a transaction processing method and blockchain node in a blockchain system. Background Art

[0003] Blockchain is a novel application model for computer technologies, including distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. In a blockchain system, data blocks are linked sequentially in chronological order to form a chain-like data structure, cryptographically guaranteeing an unalterable and unforgeable distributed ledger. Due to its decentralized, tamper-proof, and autonomous nature, blockchain is gaining increasing attention and application.

[0004] Summary of the Invention

[0005] The object of the present invention is to provide a transaction processing method and a blockchain node in a blockchain system.

[0006] In a first aspect, a transaction processing method in a blockchain system is provided, for processing multiple transactions belonging to the same block, wherein for any i-th transaction among the multiple transactions, a first resource quantity allowing the i-th transaction to consume a target resource and a resource payment account used to pay for the target resource consumed by the i-th transaction are included; the method comprises: grouping the multiple transactions, wherein the resource payment accounts included in each of the multiple transactions are not utilized; for any j-th resource payment account among the resource payment accounts included in the multiple transactions, determining, from the multiple transactions, according to the order in which the multiple transactions are arranged, multiple transactions that include the j-th resource payment account; when the sum of the first resource quantities included in each of the first k transactions among the multiple transactions is greater than the current quantity of the target resource held by the j-th resource payment account, and the sum of the first resource quantities included in each of the first k-1 transactions among the multiple transactions is not greater than the current quantity of the target resource held by the j-th resource payment account, marking each transaction after the k-1-th transaction in the multiple transactions with a preset tag; and concurrently executing transactions in the multiple transactions that are not marked with the preset tag according to the grouping result of the multiple transactions.

[0007] In a second aspect, a blockchain node in a blockchain system is provided, which is used to process multiple transactions belonging to the same block, and for any i-th transaction among the multiple transactions, it includes a first resource quantity that allows the i-th transaction to consume the target resource, and a resource payment account used to pay for the target resource consumed by the i-th transaction; the blockchain node includes: a transaction grouping unit, configured to group the multiple transactions, wherein the resource payment account included in each of the multiple transactions is not utilized; a transaction determination unit, configured to, for any j-th resource payment account among the several resource payment accounts included in the multiple transactions, from the arrangement order of the multiple transactions. Several transactions including the j-th resource payment account are determined from the multiple transactions; a transaction marking unit is configured to mark a preset tag on each transaction located after the k-1th transaction in the multiple transactions when the sum of the first resource quantities included in each of the first k transactions in the multiple transactions is greater than the current quantity of the target resource held by the j-th resource payment account, and the sum of the first resource quantities included in each of the first k-1 transactions in the multiple transactions is not greater than the current quantity of the target resource held by the j-th resource payment account; and a transaction processing unit is configured to concurrently execute transactions in the multiple transactions that are not marked with the preset tag according to the grouping result of the multiple transactions.

[0008] In a third aspect, a computing device is provided, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method provided in the first aspect is implemented.

[0009] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed in a computing device, the computing device executes the method provided in the first aspect.

[0010] In the technical solution provided by the embodiments of this specification, for any resource payment account among the multiple resource payment accounts involved in multiple transactions, by including the first resource quantity that the multiple transactions of the resource payment account itself allow to consume, and the current quantity of the target resource held by the resource payment account, it is possible to determine and mark the transactions that are arranged at the back and may fail to execute due to insufficient target resources from the multiple transactions. For the unmarked transactions among the multiple transactions, the resource payment account must hold enough target resources to execute them according to the first resource quantity allowed by it, and there is no need to execute the unmarked transactions in this part of the transactions serially, so there is no need to group multiple transactions and analyze and use the resource payment accounts included in them. Accordingly, the blockchain node only needs to execute the unmarked transactions concurrently according to the grouping results of multiple transactions, which can improve the parallelism of transaction execution while ensuring the fairness of transaction execution. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0012] FIG1 is an architectural diagram of a blockchain system exemplarily provided in an embodiment of this specification;

[0013] FIG2 is a flow chart of a transaction processing method in a blockchain system provided in an embodiment of this specification;

[0014] FIG3 is a schematic diagram of a data structure of a transaction exemplarily provided in an embodiment of this specification;

[0015] FIG4 is a schematic diagram of a process of concurrently processing multiple transactions in a blockchain node exemplarily provided in an embodiment of this specification;

[0016] FIG5 is a schematic diagram of the structure of a blockchain node provided in an embodiment of this specification. DETAILED DESCRIPTION

[0017] To help those skilled in the art better understand the technical solutions in this specification, the following will provide a clear and complete description of the technical solutions in the embodiments of this specification, in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative work should fall within the scope of protection of this specification.

[0018] Figure 1 is an architectural diagram of a blockchain system, exemplified in the embodiments of this specification. A blockchain system may include N blockchain nodes, with Figure 1 illustratively showing eight blockchain nodes, namely, nodes 1 through 8. The lines between nodes schematically represent connections between nodes, such as Transmission Control Protocol (TCP) connections, which support data transmission between different nodes.

[0019] The system data that needs to be persistently stored in the blockchain system can be divided into two parts: block data and status data.

[0020] Block data includes one or more blocks incremented by block height (or block number). A single block can include a block header and a block body. The block header can include the previous block's block hash (or parent hash), timestamp, block number (BlockNum), state root hash (State_Root), transaction root hash (Transaction_Root), and receipt root hash (Receipt_Root). The block body can include a transaction set and a receipt set.

[0021] A transaction in a blockchain system is a unit of work performed and recorded within the blockchain system. A single transaction typically includes a From field, a To field, and a Data field. The From field includes the account initiating the transaction (i.e., the sender), and the To field may include another account involved in or directed by the transaction.

[0022] For any k-th block, the state data at block height (or block number) k-1 can be used to execute the multiple transactions included in the transaction set belonging to the k-th block in order to obtain the execution results of the multiple transactions. The state data at block height k-1 can then be updated based on the execution results of the multiple transactions to obtain the state data at block height k.

[0023] The consensus mechanism in a blockchain system is a mechanism by which blockchain nodes reach a consensus across the entire network on block information, ensuring that the most recently acquired block is accurately stored. Current mainstream consensus mechanisms include Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), and Practical Byzantine Fault Tolerance (PBFT). Consensus is typically reached after a predetermined number of consensus nodes agree on the data being considered. For example, in the PBFT algorithm, if at most f nodes fail, a total of at least 3f + 1 nodes remain, ensuring security and liveness across the entire blockchain system.

[0024] After receiving a transaction from a connected client or other blockchain node, a blockchain node can verify the transaction. Verified transactions are added to the corresponding transaction pool / transaction cache as pending consensus transactions. A blockchain node can also select multiple transactions from the transaction pool belonging to any k-th block to generate its corresponding consensus proposal. This consensus proposal may indicate the multiple transactions belonging to the k-th block and the order in which these multiple transactions are arranged within the k-th block. The blockchain node then reaches consensus on the consensus proposal using the various consensus mechanisms described above. Once consensus is reached on the consensus proposal, the blockchain node executes the multiple transactions and, upon completion, deletes them from the transaction pool.

[0025] Some blockchain systems support the use of parallel technology to improve blockchain system performance. In a typical example, after reaching consensus on the consensus proposal for any k-th block, the blockchain node can perform read-write conflict analysis on multiple transactions belonging to the k-th block. Based on the analysis results, the multiple transactions are divided into M transaction groups. These M transaction groups are then dispatched to the M computing processes or M computing threads included in the blockchain node. The M computing processes or M computing threads then process the transactions in the M groups in parallel. It should be noted that a process refers to the operation of a program on a certain data set in a computer. It is the basic unit for resource allocation in the system and the foundation of the operating system structure. The M computing threads can serve as the execution threads of the computing engine, where the aforementioned computing engine may include several computing processes, and a single computing process may include several computing processes.

[0026] When a blockchain node executes a transaction, the execution result includes the read-write set corresponding to the transaction. A read-write set may consist of a read set and / or a write set. A read set contains several unique keys and the key values ​​corresponding to each key, read from the committed world state. A write set also contains several unique keys and the key values ​​corresponding to each key that are expected to be committed. Furthermore, if a transaction deletes a key from the world state, the write set will also include a corresponding mark for the deleted key. For contract call transactions used to invoke smart contracts, the write set may include not only state parameters related to external accounts but also contract parameters related to the smart contract's contract state. In light of the above, the aforementioned keys can correspond to accounts or fields within an account in the blockchain system.

[0027] When dividing multiple transactions into M transaction groups, it is usually necessary to ensure that any two transactions in any two transaction groups do not conflict with each other. Any two transactions do not conflict with each other specifically means that any two transactions do not have any of the following situations: the read set of one transaction includes the same key as the write set of another transaction, or the write set of one transaction includes the same key as the write set of another transaction. For any two transactions that are in conflict, they need to be divided into the same transaction group. In other words, if the write sets of any two transactions contain the same key, it is considered that the two conflicting transactions accessed the same parameters and there is a conflict. The two transactions need to be divided into the same transaction group; if the read set of one transaction and the write set of the other transaction contain the same key, it is considered that the two transactions accessed the same parameters and there is a conflict. The two transactions need to be divided into the same transaction group. In another possible implementation, in order to efficiently determine the grouping information of the aforementioned multiple transactions or efficiently divide the aforementioned multiple transactions into M transaction groups, the aforementioned multiple transactions can generally be grouped according to the requirement that any two transactions in any two different transaction groups do not access the same parameters (i.e., do not contain the same key).

[0028] When executing transactions included in their corresponding transaction groups, the computational processes or threads within a blockchain node consume the node's computing resources. This is especially true for transactions requesting the deployment and invocation of smart contracts, where the node may need to execute a large number of instructions. Accordingly, a target resource can be defined within the blockchain system. This target resource could be, for example, a token or other digital resource. The blockchain node can then, according to predefined rules, deduct a corresponding amount of the target resource from the resource payment account specified by the transaction itself as the resource usage fee for the transaction's use of the blockchain system's computing resources.

[0029] For example, during the execution of a transaction, the computing process or computing thread of a blockchain node can, based on the instructions consumed by the transaction or the amount of data processed due to the execution of the transaction, count the resource consumption amount of the target resources consumed in the execution of the transaction as real-time as possible, and then deduct the target resources held by the resource payment account specified in the transaction according to the resource consumption amount; if the target resources held by the resource payment account specified in the transaction are insufficient to pay for the target resources consumed by the transaction, that is, the current resource quantity of the target resources held by the resource payment account is less than the resource consumption quantity corresponding to the transaction, then the computing process or computing thread can terminate the execution of the transaction, the transaction execution fails, and the target resources held by the resource payment account are cleared.

[0030] A single transaction may specify accounts other than the sender and receiver accounts as its resource payment accounts. Furthermore, multiple transactions within the same block may specify the same resource payment account. If the current amount of target resources held by the same resource payment account is insufficient to cover the required resources for successful execution of that portion of the transaction, some of the transactions may fail to execute successfully.

[0031] In one possible implementation, to ensure fair transaction execution, for transactions that specify the same resource payment account, this same resource payment account is used as the conflict key for these transactions, placing them into the same transaction group. Accordingly, the corresponding computing processes or threads are then required to execute these transactions serially, based on their ranking within the group. This ensures that transactions ranked higher within the group are less likely to fail due to insufficient target resources held by their designated resource payment account. This implementation affects the degree of parallelism in transaction execution.

[0032] The embodiments of this specification at least provide a transaction processing method and blockchain node in a blockchain system. For any i-th transaction among multiple transactions belonging to the same block, including a first resource quantity that allows the i-th transaction to consume a target resource and a resource payment account used to pay for the target resource consumed by the i-th transaction, the blockchain node can first group the multiple transactions, without utilizing the resource payment accounts included in each of the multiple transactions during the grouping process. Then, for any j-th resource payment account among the multiple resource payment accounts included in the multiple transactions, the node determines, based on the order of the multiple transactions, multiple transactions that include the j-th resource payment account. When the sum of the first resource quantities included in each of the first k transactions among the multiple transactions is greater than the current quantity of the target resource held by the j-th resource payment account, and the sum of the first resource quantities included in each of the first k-1 transactions among the multiple transactions is not greater than the current quantity of the target resource held by the j-th resource payment account, each transaction after the k-1th transaction in the multiple transactions is marked with a preset tag. Finally, based on the grouping results of the multiple transactions, the transactions in the multiple transactions that are not marked with the preset tag are concurrently executed.

[0033] In the embodiments of this specification, for any resource payment account among the multiple resource payment accounts involved in multiple transactions, by including the first resource quantity that the resource payment account itself is allowed to consume and the current quantity of the target resource held by the resource payment account, it is possible to determine and mark the transactions that are arranged at the back and may fail to execute due to insufficient target resources from the multiple transactions. For the unmarked transactions among the multiple transactions, the resource payment account must hold enough target resources to execute them according to the first resource quantity allowed by it. There is no need to strictly implement serial execution for the unmarked transactions in this part of the transactions. Therefore, the process of grouping multiple transactions does not require analysis and use of the resource payment accounts included in each of them. Accordingly, the blockchain node only needs to execute the unmarked transactions concurrently according to the grouping results of multiple transactions, which can improve the parallelism of transaction execution while ensuring the fairness of transaction execution.

[0034] FIG2 is a flowchart of a transaction processing method in a blockchain system provided in an embodiment of this specification.

[0035] This method can be executed by a blockchain node in a blockchain system to process multiple transactions belonging to the same block. For example, after reaching consensus on a consensus proposal corresponding to any k-th block, the blockchain node can determine, from a transaction pool or other location, multiple transactions belonging to the k-th block in a sequential order according to the instructions of the consensus proposal.

[0036] For any i-th transaction among multiple transactions (recorded as transaction Tx i ), which includes allowing transactions Tx i The first resource quantity of the consumption target resource (recorded as resource quantity S 1i ), and used for payment transactions Tx i The resource payment account for the consumed target resources.

[0037] Transaction Tx i You can specify the sender account or the receiver account as the resource payment account, or you can specify another account different from the sender account and the receiver account as the resource payment account.

[0038] Transaction Tx i Includes the transaction body, including the sender account, receiver account, resource payment account, and allowed transaction Tx i The number of resources S that consume the target resource 1i ;The transaction Tx i The transaction also includes the first signature of the sender's account on the transaction body. When the resource payment account is different from the sender's account, the transaction Tx i It also includes the second signature of the resource payment account on the transaction body.

[0039] For example, see Figure 3. User U1 holding account C1 can first construct a transaction Tx in client A1. i The transaction body, in which the From field of the transaction body includes the sender account C1, the To field includes the receiver account C2, and the Data field includes the resource payment account C3 declared through a specific subfield such as target, and the resource quantity S declared through a specific subfield such as gas limit. 1i ; Then you can use the private key of account C1 to sign the transaction to obtain the signature S c1 , and provide the transaction body and signature S to the client A3 corresponding to the user U3 holding account C3 c1 Then when user U3 agrees to use its account C3 for transaction Tx i When paying for target resources, the private key of account C3 can be used to sign the transaction body to obtain signature S c3 Finally, the transaction body and signature S c1 and signature S c3 Composition of transaction Tx i , sent by client A1 or client A3 to a blockchain node in the blockchain system. The transaction Tx provided in Figure 3 is an example i The structure is only exemplary. For example, in the transaction body, other specific fields can be used in parallel with the Data field to separately declare the transaction Tx. i Designated resource payment account C3 and allowed transaction Tx i The number of resources S that consume the target resource 1i .

[0040] Allow transaction Tx i The amount of target resource consumed S 1i Can be customized by the user.

[0041] When the transaction Tx i The resource payment account specified in the transaction is different from the transaction Tx i When the sender account is Tx i The transaction includes the second signature of the resource payment account on the transaction body, and the blockchain node receives and verifies the transaction Tx i In the process, it is necessary not only to verify the transaction Tx i The first signature corresponding to the sender account also needs to verify the transaction Tx i The second signature corresponding to the resource payment account.

[0042] 2 , the method may include but is not limited to part or all of the following steps S201 to S209 .

[0043] Step S201 : Grouping multiple transactions, wherein resource payment accounts included in each of the multiple transactions are not utilized.

[0044] When grouping multiple transactions, it is necessary to ensure that there is no read-write conflict between the unique keys (keys) in the read-write set of any two transactions in any two transaction groups, except for the resource payment account.

[0045] The blockchain node may include a pre-execution service, which can pre-execute multiple transactions and obtain the pre-execution read-write sets of each of the multiple transactions; further, the multiple transactions can be grouped according to the pre-execution read-write sets. i During the pre-execution process, there is no need to follow the transaction Tx i The resource payment account specified in the transaction reads and writes the target resources held by the resource payment account; thus, when the transaction Tx i When the resource payment account included is different from the sender account and receiver account included in it, the transaction Tx i The pre-execution read-write set does not include the resource payment account included in the i-th transaction.

[0046] Blockchain nodes may also group multiple transactions without pre-execution, ensuring that there are no read-write conflicts between the unique keys (other than the resource payment account) in the read-write sets of any two transactions in any transaction group. For example, a blockchain node could directly use the sender and receiver accounts in each transaction as keys in its read and write sets, and then group multiple transactions according to the keys in their respective read and write sets.

[0047] When multiple transactions are not grouped using their resource payment accounts, the number of transaction groups obtained is relatively higher than when multiple transactions are grouped using their resource payment accounts. The following example illustrates grouping transactions Tx1 to Tx5, which are arranged in sequence as shown in Table 1.

[0048] Table 1

[0049] See Table 1 for examples of transactions Tx1 to Tx5, each of which includes a sender account, a receiver account, and a resource payment account.

[0050] If the resource payment account in transactions Tx1 to Tx5 is used to group transactions Tx1 to Tx5, then K00 is the conflict key for transactions Tx1 to Tx3, and transactions Tx1 to Tx3 need to be divided into the same transaction group; K08 is the conflict key for transactions Tx4 and Tx5, and transactions Tx4 and Tx5 need to be divided into the same transaction group; that is, transactions Tx1 to Tx5 will be divided into 2 transaction groups, and the corresponding parallelism of transaction execution is 2.

[0051] If the resource payment account in transactions Tx1 to Tx5 is not used to group transactions Tx1 to Tx5, K00 will not serve as a conflict key for transactions Tx1 to Tx3, and transactions Tx1 to Tx3 can be divided into three different transaction groups; K08 is not a resource payment account for transactions Tx4 and Tx5, but it will still serve as a conflict key for transactions Tx4 and Tx5, and transactions Tx4 and Tx5 need to be divided into the same transaction group; that is, transactions Tx1 to Tx5 will be divided into four transaction groups, and the corresponding parallelism of transaction execution is 4.

[0052] Step S203 : for any j-th resource payment account among the plurality of resource payment accounts included in the plurality of transactions, determine a plurality of transactions including the j-th resource payment account from the plurality of transactions according to the arrangement order of the plurality of transactions.

[0053] For example, consider multiple transactions, including transactions Tx1 through Tx5, and the resource payment accounts K00, K09, and K11. For resource payment account K00, the transactions with resource payment account K00 can be determined from transactions Tx1 through Tx5, specifically including transactions Tx1 through Tx3. Similarly, the transactions corresponding to K09 and K11 can be determined in the same manner.

[0054] Step S205: For a number of transactions including the j-th resource payment account, when the sum of the quantities of the first resources included in each of the first k transactions among the number of transactions is greater than the current quantity of the target resource held by the j-th resource payment account, and the sum of the quantities of the first resources included in each of the first k-1 transactions among the number of transactions is not greater than the current quantity of the target resource held by the j-th resource payment account, each transaction after the k-1-th transaction among the number of transactions is marked with a preset label.

[0055] For example, for transactions Tx1 through Tx3 that include resource payment account K00, if the sum of the first resource quantities included in the first three transactions, Tx1 through Tx3, is greater than the current quantity of the target resource held by resource payment account K00, while the sum of the first resource quantities included in the first two transactions, Tx1 and Tx2, is not greater than the current quantity of the target resource held by resource payment account K00, then this indicates that, in order to ensure fairness, transactions ranked higher in the list are less likely to fail to execute successfully due to insufficient target resources held by their designated resource payment accounts. Therefore, the target resources held by resource payment account K00 may not be sufficient to support the successful execution of transaction Tx3 by the blockchain node. Accordingly, a preset tag can be set for transaction Tx3 to indicate that the relevant computing process or computing thread in the blockchain node does not need to execute transaction Tx3 in subsequent processes.

[0056] As shown in Figure 4, setting preset tags for transactions can be achieved through bit sequences corresponding to multiple transactions. For example, for five transactions arranged in sequence, such as transactions Tx1 to Tx5, a bit sequence of length 5 can be maintained; starting from the high / low bit of the bit sequence, if any qth transaction in transactions Tx1 to Tx5 requires a preset tag, the value of the qth bit in the bit sequence can be set to a preset tag, such as 1; otherwise, the value of the qth bit is set to a non-preset tag, such as 0. Obviously, setting preset tags for transactions can also be achieved through other methods, which will not be detailed here.

[0057] In one possible implementation, for a number of transactions including the j-th resource payment account, the first resource quantities included in each of the first k transactions among the number of transactions can be summed up in order of arrangement to obtain the cumulative resource quantities corresponding to the first k transactions; when the cumulative resource quantity is greater than the current quantity of the target resource held by the j-th resource payment account, each transaction after the k-1th transaction among the number of transactions is marked with a preset label.

[0058] In one possible implementation, for several transactions including the j-th resource payment account, the current quantity of the target resource held by the j-th resource payment account is obtained from the state data; the current quantity is cached in a predetermined area as a variable that is allowed to be modified by the blockchain node and is independent of the state data; and the k-th transaction among the several transactions is executed in sequence according to the arrangement order of the several transactions: determining whether the current quantity cached in the predetermined area reaches the first resource quantity included in the k-th transactions; if so, deducting the first resource quantity included in the k-th transaction from the current quantity in the predetermined area; if not, marking each transaction after the k-1-th transaction among the several transactions with a preset label.

[0059] Step S207 : according to the grouping result of the multiple transactions, concurrently execute the transactions that are not marked with the preset tags in the multiple transactions.

[0060] Transactions belonging to different groups can be dispatched to different computing processes or threads within a blockchain node, with each processing the transactions within each group. If a transaction within a transaction group is tagged with a preset tag, an indication indicating that a transaction within that group has been tagged with the preset tag can also be provided to the corresponding computing process or thread.

[0061] Referring to Figure 4, let's continue to assume that transaction Tx1 is divided into transaction group 1, transaction Tx2 is divided into transaction group 2, transaction Tx3 is divided into transaction group 3, and transactions Tx4 and Tx5 are divided into transaction group 4. Then, the four transaction groups, namely transaction groups 1 to 4, can be correspondingly scheduled to the four computing threads included in the blockchain node, namely computing thread 1, computing thread 2, computing thread 3, and computing thread 4. In addition, assuming that transaction Tx3 is marked with a preset tag, then indication information indicating that transaction Tx3 is marked with the preset tag can also be provided to computing thread 3, such as providing a bit sequence of length 5 corresponding to transactions Tx1 to Tx5 in the above example.

[0062] For any p-th transaction in any n-th transaction group, the n-th computation process or the n-th computation thread can first determine whether the p-th transaction is marked with a preset tag; for example, by querying the value of the bit corresponding to the p-th transaction from the aforementioned bit sequence to determine whether the p-th transaction is marked with the preset tag. If the p-th transaction is not marked with the preset tag, the n-th computation process or the n-th computation thread executes the p-th transaction and obtains an execution result for the p-th transaction. Conversely, if the p-th transaction is marked with the preset tag, the n-th computation process or the n-th computation thread can directly generate an execution result indicating that the p-th transaction failed to execute.

[0063] For a transaction executed by the nth computing process or the nth computing thread, the nth computing process or the nth computing thread does not need to change the quantity of target resources held by the resource payment account designated by the exchange based on the resource payment account designated by the exchange and the second quantity of target resources consumed by the transaction during the execution of the transaction.

[0064] For a transaction executed by the nth computing process or the nth computing thread, the transaction will generally not fail due to insufficient target resources included in the resource payment account designated by the transaction; regardless of whether the transaction is successfully executed by the blockchain node, the execution result of the transaction includes the resource payment account designated by the transaction and the second quantity of the target resources consumed by the transaction.

[0065] For transactions executed by the nth computing process or the nth computing thread, the nth computing process or the nth computing thread may also return its corresponding resource payment account and the second amount of the target resource consumed to a specific process in the blockchain node, such as the block management process, so that the block management process can subsequently deduct the target resource held by it from the relevant resource payment account. For example, the nth computing process or the nth computing thread may return the execution results of all transactions in its corresponding transaction group to the block management process.

[0066] Step S209: For several transactions including the j-th resource payment account, obtain the second resource quantity of each of the consumed target resources based on the execution results of the first k transactions, and deduct the target resources held by the j-th resource payment account according to the sum of the second resource quantities.

[0067] Continuing with the previous example, the blockchain node can implement this through its block management process, obtaining the second resource quantity of the target resource consumed by each of the first k transactions in a number of transactions that specify the j-th resource payment account as its resource payment account, and deducting the target resource held by the j-th resource payment account according to the sum of the second resource quantities of the target resource consumed by each of the first k transactions.

[0068] Based on the same concept as the aforementioned method embodiment, the embodiment of this specification also provides a blockchain node 500 in a blockchain system, which is used to process multiple transactions belonging to the same block. For any i-th transaction among the multiple transactions, it includes a first resource quantity allowing the i-th transaction to consume the target resource, and a resource payment account used to pay for the target resource consumed by the i-th transaction. The blockchain node 500 includes: a transaction grouping unit 501, configured to group the multiple transactions, wherein the resource payment accounts included in each of the multiple transactions are not utilized; a transaction determination unit 503, configured to, for any j-th resource payment account among the multiple resource payment accounts included in the multiple transactions, determine from the multiple transactions the multiple transactions including the j-th resource payment account according to the arrangement order of the multiple transactions; a transaction marking unit 505, configured to mark each transaction located after the k-1th transaction in the multiple transactions with a preset tag when the sum of the first resource quantities included in the first k transactions in the multiple transactions is greater than the current quantity of the target resources held by the j-th resource payment account, and the sum of the first resource quantities included in the first k-1 transactions in the multiple transactions is not greater than the current quantity of the target resources held by the j-th resource payment account; a transaction processing unit 507, configured to concurrently execute transactions in the multiple transactions that are not marked with a preset tag according to the grouping results of the multiple transactions.

[0069] In one possible embodiment, the blockchain node 500 also includes: a resource management unit 509, configured to obtain the second resource quantity of each of the target resources consumed by each of the first k transactions based on the execution results of the first k transactions, and deduct the target resources held by the j-th resource payment account according to the sum of the second resource quantities.

[0070] In one possible implementation, the transaction grouping unit 501 is configured to determine a pre-execution read-write set for each of the multiple transactions, wherein when the resource payment account included in the i-th transaction is different from the sender account and the receiver account included therein, the resource payment account included in the i-th transaction is not included in the pre-execution read-write set of the i-th transaction; and group the multiple transactions according to the pre-execution read-write set.

[0071] In one possible implementation, the grouping result of the multiple transactions includes multiple transaction groups, and the multiple transaction groups correspond to multiple computing processes or multiple computing threads in the blockchain node; wherein the transaction processing unit 507 is configured to execute, for any p-th transaction in any n-th transaction group, in the n-th computing process or n-th computing thread: determining whether the p-th transaction is marked with a preset tag; when the p-th transaction is not marked with a preset tag, executing the p-th transaction to obtain the execution result of the p-th transaction.

[0072] In a possible implementation, the transaction processing unit 507 is further configured to execute in the nth computing process or the nth computing thread: when the pth transaction is marked with a preset tag, generate an execution result indicating that the pth transaction has failed to execute.

[0073] In one possible implementation, the transaction marking unit 505 is configured to sum the first resource quantities included in each of the first k transactions among the transactions in the order in which the transactions are arranged, to obtain the cumulative resource quantities corresponding to the first k transactions; when the cumulative resource quantity is greater than the current quantity of the target resource held by the j-th resource payment account, mark each transaction after the k-1-th transaction among the transactions with a preset label.

[0074] In one possible implementation, the transaction marking unit 505 is configured to obtain the current quantity of the target resource held by the j-th resource payment account from the status data; cache the current quantity in a predetermined area; and, in accordance with the arrangement order of the transactions, sequentially execute for the k-th transaction among the transactions: determine whether the current quantity cached in the predetermined area reaches the first resource quantity included in the k transactions; if so, deduct the first resource quantity included in the k-th transaction from the current quantity in the predetermined area; if not, mark each transaction after the k-1-th transaction among the transactions with a preset tag.

[0075] An embodiment of this specification also provides a computer-readable storage medium having a computer program / instruction stored thereon. When the computer program / instruction is executed in a computing device, the computing device is caused to execute a transaction processing method in a blockchain system provided in any embodiment of this specification.

[0076] An embodiment of this specification also provides a computing device, including a memory and a processor, wherein the memory stores a computer program / instructions, and when the processor executes the computer program / instructions, it implements a transaction processing method in a blockchain system provided in any embodiment of this specification.

[0077] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages ​​and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.

[0078] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.

[0079] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not exclude that with the future development of computer technology, the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, an in-vehicle human-computer interaction device, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0080] Although one or more embodiments of this specification provide method operation steps as described in the embodiments or flow charts, more or fewer operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the device or terminal product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment). The term "comprise", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or equipment including a series of elements includes not only those elements, but also includes other elements that are not clearly listed, or also includes elements inherent to such process, method, product or equipment. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or equipment including the elements. For example, if the words first, second, etc. are used to represent the name, they do not represent any particular order.

[0081] For the convenience of description, the above devices are described in terms of functions divided into various modules. Of course, when implementing one or more of the present specifications, the functions of each module can be implemented in the same or multiple software and / or hardware, or the module that implements the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as 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.

[0082] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and / or one or more blocks in the block diagram.

[0083] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0084] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0085] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0086] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0087] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be used by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0088] Those skilled in the art will appreciate that one or more embodiments of this specification may be provided as a method, system, or computer program product. Thus, one or more embodiments of this specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0089] One or more embodiments of this specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. One or more embodiments of this specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0090] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between the various embodiments can be referenced to each other. Each embodiment focuses on the differences from other embodiments. In particular, since the system embodiments are generally similar to the method embodiments, the description is relatively simple. For relevant parts, reference can be made to the description of the method embodiments. Throughout this specification, reference to the terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with that embodiment or example are included in at least one embodiment or example of this specification. In this specification, the schematic representations of these terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and integrate the different embodiments or examples, and features of different embodiments or examples, described in this specification, unless they conflict with each other.

[0091] The foregoing description is merely an example of one or more embodiments of this specification and is not intended to limit the one or more embodiments of this specification. Those skilled in the art will appreciate that various modifications and variations of one or more embodiments of this specification are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of this specification are intended to be included within the scope of the claims.

Claims

1. A transaction processing method in a blockchain system, for processing multiple transactions belonging to the same block, for any i-th transaction among the multiple transactions, including a first resource quantity that allows the i-th transaction to consume a target resource, and a resource payment account for paying the target resource consumed by the i-th transaction; the method comprises: grouping the plurality of transactions, wherein a resource payment account included in each of the plurality of transactions is not utilized; For any j-th resource payment account among the plurality of resource payment accounts included in the plurality of transactions, determining a plurality of transactions including the j-th resource payment account from the plurality of transactions according to the arrangement order of the plurality of transactions; When the sum of the first resource quantities included in each of the first k transactions among the plurality of transactions is greater than the current quantity of the target resource held by the j-th resource payment account, and the sum of the first resource quantities included in each of the first k-1 transactions among the plurality of transactions is not greater than the current quantity of the target resource held by the j-th resource payment account, a preset label is marked on each transaction after the k-1-th transaction among the plurality of transactions; According to the grouping result of the multiple transactions, transactions that are not marked with a preset tag among the multiple transactions are executed concurrently.

2. The method according to claim 1, further comprising: According to the execution results of the first k transactions, the second resource quantity of the target resource consumed by each of the first k transactions is obtained, and the target resource held by the j-th resource payment account is deducted according to the sum of the second resource quantities.

3. The method according to claim 1, wherein grouping the plurality of transactions comprises: Determining the pre-execution read-write sets of the multiple transactions, wherein when the resource payment account included in the i-th transaction is different from the sender account and the receiver account included in the i-th transaction, the pre-execution read-write set of the i-th transaction does not include the resource payment account included in the i-th transaction; The multiple transactions are grouped according to the pre-execution read-write sets.

4. The method according to claim 1, wherein the grouping results of the plurality of transactions include a plurality of transaction groups, and the plurality of transaction groups correspond to a plurality of computing threads in the blockchain node; in, The concurrently executing transactions that are not marked with a preset tag in the multiple transactions according to the grouping results of the multiple transactions includes: for any p-th transaction in any n-th transaction group, the n-th computing thread determines whether the p-th transaction is marked with a preset tag; when the p-th transaction is not marked with the preset tag, the n-th computing thread executes the p-th transaction to obtain the execution result of the p-th transaction.

5. The method according to claim 4, further comprising: When the p-th transaction is marked with a preset label, the n-th computing thread generates an execution result indicating that the p-th transaction has failed to execute.

6. The method according to claim 1, when the sum of the first resource quantities included in the first k transactions among the plurality of transactions is greater than the current quantity of the target resource held by the j-th resource payment account, and the sum of the first resource quantities included in the first k-1 transactions among the plurality of transactions is not greater than the current quantity of the target resource held by the j-th resource payment account, marking each transaction after the k-1-th transaction among the plurality of transactions with a preset label, comprises: According to the arrangement order of the plurality of transactions, the first resource quantities included in each of the first k transactions among the plurality of transactions are summed up in turn to obtain the cumulative resource quantities corresponding to the first k transactions; When the accumulated resource quantity is greater than the current quantity of the target resource held by the j-th resource payment account, Each transaction after the k-1th transaction among the plurality of transactions is marked with a preset label.

7. The method according to claim 1, when the sum of the first resource quantities included in the first k transactions among the plurality of transactions is greater than the current quantity of the target resource held by the j-th resource payment account, and the sum of the first resource quantities included in the first k-1 transactions among the plurality of transactions is not greater than the current quantity of the target resource held by the j-th resource payment account, marking each transaction after the k-1-th transaction among the plurality of transactions with a preset label, comprises: Obtaining the current quantity of the target resource held by the j-th resource payment account from the status data; Cache the current quantity in a predetermined area; According to the arrangement order of the several transactions, the kth transaction among the several transactions is executed in sequence: determining whether the current quantity cached in the predetermined area reaches the first resource quantity included in the k transactions; if yes, deducting the first resource quantity included in the kth transaction from the current quantity in the predetermined area; if not, marking each transaction after the k-1th transaction among the several transactions with a preset label.

8. A blockchain node in a blockchain system, used to process multiple transactions belonging to the same block, for any i-th transaction among the multiple transactions, including a first resource quantity that allows the i-th transaction to consume a target resource, and a resource payment account used to pay for the target resource consumed by the i-th transaction; the blockchain node includes: a transaction grouping unit configured to group the plurality of transactions, wherein resource payment accounts respectively included in the plurality of transactions are not utilized; a transaction determination unit configured to determine, for any j-th resource payment account among the plurality of resource payment accounts included in the plurality of transactions, a plurality of transactions including the j-th resource payment account from the plurality of transactions according to the arrangement order of the plurality of transactions; a transaction marking unit configured to mark each transaction after the k-1th transaction among the plurality of transactions with a preset label when the sum of the first resource quantities included in each of the first k transactions among the plurality of transactions is greater than the current quantity of the target resource held by the jth resource payment account and the sum of the first resource quantities included in each of the first k-1th transactions among the plurality of transactions is not greater than the current quantity of the target resource held by the jth resource payment account; The transaction processing unit is configured to concurrently execute transactions that are not marked with a preset tag among the multiple transactions according to the grouping results of the multiple transactions.

9. The blockchain node according to claim 8, further comprising: The resource management unit is configured to obtain the second resource quantity of the target resource consumed by each of the first k transactions according to the execution results of the first k transactions, and deduct the target resource held by the jth resource payment account according to the sum of each second resource quantity.

10. According to the blockchain node according to claim 8, the transaction grouping unit is configured to determine the pre-execution read-write sets of each of the multiple transactions, wherein when the resource payment account included in the i-th transaction is different from the sender account and the receiver account included therein, the resource payment account included in the i-th transaction is not included in the pre-execution read-write set of the i-th transaction; and the multiple transactions are grouped according to the pre-execution read-write set.

11. The blockchain node according to claim 8, wherein the grouping results of the multiple transactions include multiple transaction groups, and the multiple transaction groups correspond to multiple computing threads in the blockchain node; wherein, The transaction processing unit is configured to execute, on an nth computing thread, for any p-th transaction in any n-th transaction group: determining whether the p-th transaction is marked with a preset tag; when the p-th transaction is not marked with a preset tag, the nth computing thread executing the p-th transaction to obtain an execution result of the p-th transaction.

12. According to the blockchain node according to claim 11, the transaction processing unit is also configured to generate an execution result in the nth computing thread indicating that the pth transaction has failed to execute when the pth transaction is marked with a preset label.

13. According to the blockchain node of claim 8, the transaction marking unit is configured to sum up the first resource quantities included in each of the first k transactions among the transactions in order of arrangement of the transactions to obtain the cumulative resource quantities corresponding to the first k transactions; when the cumulative resource quantity is greater than the current quantity of the target resources held by the j-th resource payment account, a preset label is marked for each transaction after the k-1-th transaction among the transactions.

14. According to the blockchain node of claim 8, the transaction marking unit is configured to obtain the current quantity of the target resource held by the j-th resource payment account from the status data; cache the current quantity to a predetermined area; and, in accordance with the arrangement order of the several transactions, execute in sequence on the k-th transaction among the several transactions: determine whether the current quantity cached in the predetermined area reaches the first resource quantity included in the k transactions; if so, deduct the first resource quantity included in the k-th transaction from the current quantity in the predetermined area; if not, mark each transaction after the k-1-th transaction among the several transactions with a preset label.

15. A computing device, comprising a memory and a processor, wherein the memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 7 is implemented.

16. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed in a computing device, the computing device implements the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Limit resource processing method, online transaction processing method and limit resource processing device

    CN104599177A

  • Method for transaction processing and transaction server

    CN107016536A

  • Block chain transaction execution method and system, electronic equipment and storage medium

    CN109559226A

  • Block chain transaction data processing method and device, electronic device and medium

    CN109784930A

  • Transaction distribution method, node and block chain system

    CN116308772A