Blockchain transaction processing method and apparatus, electronic device, and readable medium
By clearly defining transaction dependencies in blockchain transactions and packaging and uploading them to the chain according to the execution order, the problem of blockchain transaction execution failure is solved, thereby improving the transaction success rate and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2024-12-17
- Publication Date
- 2026-06-19
AI Technical Summary
In existing technologies, the dependencies of blockchain transactions are not packaged strictly according to the transaction order, leading to transaction execution failures and affecting the success rate and efficiency of transaction execution.
By acquiring transaction dependency information from blockchain transactions, pending transactions are packaged into dependency transaction packages with other transactions according to the transaction execution order, and then uploaded to the blockchain to ensure the clarity and correctness of transaction dependencies.
It improves the success rate and efficiency of blockchain transaction execution, and avoids transaction failures caused by missing transactions or incorrect packaging order.
Smart Images

Figure CN122243630A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a blockchain transaction processing method, apparatus, electronic device, and readable medium. Background Technology
[0002] Blockchain technology is now widely used, and more and more users are interacting with blockchain services by sending transactions to nodes, which then package and execute them. A user often has multiple transactions waiting to be packaged in the transaction pool, and these transactions are interdependent and need to be packaged in the order desired by the user.
[0003] In related technologies, transactions that are interdependent are usually assigned different transaction fees according to their transaction order. The amount of the transaction fees is used to make the blockchain package the transactions in the desired order.
[0004] However, in such schemes, the order in which blockchain packages transactions is not necessarily determined strictly by the transaction fees, and interdependent transactions may not arrive at the blockchain nodes in the order they were ordered. Therefore, dependent transactions may not be packaged in order, leading to transaction execution failures and affecting the success rate and efficiency of blockchain transaction execution. Summary of the Invention
[0005] To address the aforementioned technical issues, this application provides a blockchain transaction processing method, apparatus, electronic device, and readable medium to ensure that the transaction order in a block satisfies the specified transaction dependencies, thereby avoiding transaction execution failures caused by missing dependent transactions or incorrect transaction packaging order.
[0006] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0007] According to one aspect of the embodiments of this application, a blockchain transaction processing method is provided, including:
[0008] Obtain pending transactions from the blockchain, wherein the pending transactions include transaction dependency information between them and other pending transactions in the blockchain;
[0009] Based on the transaction dependency information, other pending transactions that are dependent on the pending transaction are obtained from the pending transaction pool of the blockchain;
[0010] Based on the transaction execution order of the pending transaction and the other pending transactions, the pending transaction and the other pending transactions are packaged into a dependent transaction package;
[0011] The dependent transaction package is uploaded to the blockchain.
[0012] According to one aspect of the embodiments of this application, a blockchain transaction processing apparatus is provided, comprising:
[0013] The transaction acquisition module is configured to acquire pending transactions in the blockchain, wherein the pending transactions include transaction dependency information between them and other pending transactions in the blockchain;
[0014] The transaction dependency module is configured to retrieve other pending transactions that are dependent on the pending transaction from the pending transaction pool of the blockchain based on the transaction dependency information.
[0015] The transaction packaging module is configured to package the pending transaction and the other pending transactions into a dependent transaction package according to the transaction execution order of the pending transaction and the other pending transactions;
[0016] The transaction on-chain module is configured to upload the dependent transaction package to the blockchain.
[0017] In some embodiments of this application, based on the above technical solutions, the dependent transaction module is specifically configured to: retrieve other pending transactions that have a dependency relationship with the pending transaction from the pending transaction pool according to the transaction dependency information; if the pending transaction pool does not contain the other pending transactions, add the pending transaction to the pending transaction pool to wait for the other pending transactions to be executed; if the pending transaction pool contains the other pending transactions, obtain the other pending transactions from the pending transaction pool.
[0018] In some embodiments of this application, based on the above technical solutions, the transaction packaging module is specifically configured to: obtain the transaction order index in the pending transaction and the transaction order index in the other pending transactions, wherein the transaction order index is used to indicate the execution order of blockchain transactions in transaction dependencies; and sort and package the pending transaction and the other pending transactions according to the transaction order index to obtain a dependency transaction package.
[0019] In some embodiments of this application, based on the above technical solutions, the transaction packaging module is further configured to: if the transaction order index of the pending transaction is the same as the transaction order index of the other pending transactions, then discard the pending transaction and delete the other pending transactions from the pending transaction pool.
[0020] In some embodiments of this application, based on the above technical solutions, the dependent transaction module is further configured to: obtain pending transactions from the blockchain, wherein the pending transactions further include transaction types, and the transaction types are dependent transactions or ordinary transactions; if the transaction type of the pending transaction is an ordinary transaction, then the pending transaction is added to the ordinary transaction pool of the blockchain.
[0021] In some embodiments of this application, based on the above technical solutions, the transaction on-chain module is specifically configured to: package the dependent transaction packages in the dependent transaction pool of the blockchain and the pending transactions in the ordinary transaction pool into a block to be on-chain, wherein the dependent transaction pool contains the packaged dependent transaction packages that have not been on-chain; and put the block to be on-chain into the blockchain.
[0022] In some embodiments of this application, based on the above technical solutions, the transaction on-chain module is specifically configured to: obtain the dependent transaction package with the highest transaction fee to be on-chain from the dependent transaction pool of the blockchain; obtain the ordinary transaction with the highest transaction fee to be on-chain from the ordinary transaction pool; and add the ordinary transaction or dependent transaction package with the higher transaction fee to the block to be on-chain according to the transaction fee of the dependent transaction package to be on-chain and the transaction fee of the ordinary transaction to be processed.
[0023] In some embodiments of this application, based on the above technical solutions, the transaction packaging module is further configured to: obtain the transaction fees of each dependent transaction in the dependent transaction package; and determine the transaction fees of the dependent transaction package based on the average transaction fees of each dependent transaction.
[0024] In some embodiments of this application, based on the above technical solutions, the transaction on-chain module is further configured to: receive a transaction verification request for a block to be on-chain, wherein the block to be on-chain contains pending transactions with dependencies; verify the transaction order of the pending transactions with dependencies in the block to be on-chain according to the transaction dependency information of the pending transactions in the block to be on-chain; if the transaction order verification is successful, execute the pending transactions in the blockchain according to the transaction order in the block to be on-chain.
[0025] In some embodiments of this application, based on the above technical solutions, the transaction on-chain module is specifically configured to: obtain the transaction packaging order of each transaction to be processed in the dependent transaction package to be on-chain in the block to be on-chain according to the transaction dependency relationship information of the transaction to be processed; if the transaction packaging order matches the transaction execution order, then the transaction order verification is determined to be successful.
[0026] In some embodiments of this application, based on the above technical solutions, the transaction on-chain module is further configured to: obtain other pending transactions that have a dependency relationship with the pending transaction from the block to be on-chain according to the transaction dependency information of the pending transaction; and determine the transaction execution order according to the transaction order index in the pending transaction and the transaction order index in the other pending transactions.
[0027] In some embodiments of this application, based on the above technical solutions, the transaction acquisition module is further configured to: acquire transaction information of a first blockchain transaction submitted by a first client; receive transaction hashes of second blockchain transactions that are dependent on the first blockchain transaction from a second client; generate transaction dependency information of the first blockchain transaction based on the transaction hashes of the second blockchain transaction; and generate blockchain transactions to be processed based on the transaction information of the first blockchain transaction and the transaction dependency information of the first blockchain transaction.
[0028] According to one aspect of the embodiments of this application, an electronic device is provided, the electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the blockchain transaction processing method as described above by executing the executable instructions.
[0029] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the blockchain transaction processing method as described above.
[0030] According to one aspect of the embodiments of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the blockchain transaction processing method provided in the various optional implementations described above.
[0031] In the embodiments of this application, a blockchain node obtains pending transactions from the blockchain. These pending transactions contain transaction dependency information with other pending transactions in the blockchain. Then, based on this dependency information, it retrieves other pending transactions that are dependent on the pending transaction from the blockchain's pending transaction pool. Next, according to the execution order of the pending transaction and the other pending transactions, it packages the pending transaction and the other pending transactions into a dependency transaction package. Finally, the dependency transaction package is uploaded to the blockchain. In this way, blockchain transactions contain explicit definitions of transaction dependencies. Blockchain nodes package and upload transactions according to the execution dependencies and transaction order, thereby ensuring that the transaction order in the block satisfies the specified transaction dependencies. This avoids transaction execution failures due to missing dependency transactions or incorrect transaction packaging order, thus improving the success rate and efficiency of blockchain transaction execution.
[0032] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0033] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0034] Figure 1 The blockchain transaction processing method described in this application is applied to the system architecture of a blockchain system.
[0035] Figure 2 This is a flowchart of a blockchain transaction processing method according to an embodiment of this application.
[0036] Figure 3 This is a flowchart of a blockchain transaction processing method according to an embodiment of this application.
[0037] Figure 4 This is a flowchart of a blockchain transaction processing method according to an embodiment of this application.
[0038] Figure 5 This is a schematic diagram of a blockchain transaction processing procedure that includes transaction dependencies in an embodiment of this application.
[0039] Figure 6 This is a schematic diagram of the transaction dependency order verification process in an embodiment of this application.
[0040] Figure 7A schematic block diagram of the blockchain transaction processing apparatus in an embodiment of this application is shown.
[0041] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Detailed Implementation
[0042] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
[0043] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0044] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve the predetermined function, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0045] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0046] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0047] It should be understood that the solution presented in this application can be applied to blockchain systems, specifically in the consensus-building process of blockchain transactions. Specifically, in a blockchain system, when consensus-building blockchain transactions, nodes typically package multiple transactions into a blockchain proposal. The consensus nodes then vote on the transactions within the proposal, determining whether they can be added to the blockchain based on the voting results. When transactions have dependencies, blockchain nodes must package blocks according to the order of these dependencies to ensure the normal execution of transactions. Transaction dependency refers to the sequential dependence between different transactions; the successful execution of one transaction depends on one or more other transactions being packaged and executed before it, otherwise the transaction will fail. Dependencies often exist between blockchain transactions. For example, user A sells some virtual resources and then trades the proceeds to user B. User B then trades the received resources to another account. User B executes two transactions, B1 and B2. Transaction B2 depends on the result of transaction B1, thus creating a dependency between B1 and B2. Furthermore, the execution of transaction B1 depends on the result of transaction A1 submitted by user A, so there is also a dependency between transaction A1 and B1. Since the transaction process and content are predetermined, users A and B can choose to submit these three transactions to the blockchain at the same or similar times to improve execution efficiency. In this case, the blockchain needs to package the transactions in the order A1->B1->B2 to ensure successful execution. If transaction B1 is executed before transaction A1, B1 will fail, which in some blockchains can lead to consensus failure and affect the overall efficiency of the blockchain.
[0048] Blockchain technology is now widely used, with more and more users interacting with blockchain services by sending transactions to nodes, which then package and execute them. A user often has multiple transactions waiting to be packaged in a transaction pool, and these transactions are interdependent, requiring packaging in the user's desired order. In related technologies, interdependent transactions are typically assigned different transaction fees based on their order, with the blockchain packaging transactions in the desired sequence based on the transaction fees. However, in such schemes, the order in which the blockchain packages transactions is not strictly determined by transaction fees, and interdependent transactions may not arrive at the blockchain nodes in the correct order. Therefore, dependent transactions may not be packaged in the correct order, leading to transaction execution failures and impacting the success rate and efficiency of blockchain transaction execution.
[0049] Based on this, the technical solution of this application proposes a blockchain transaction processing scheme. Specifically, please refer to... Figure 1 The blockchain transaction processing method according to the embodiments of this application, applied to a blockchain system, can mainly include two parts: user terminals 110 and blockchain nodes 120. Multiple blockchain nodes 120 together form the blockchain, and multiple user terminals 110 are used by different users to access the blockchain. The devices in each part of the system structure can include smartphones, tablets, laptops, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The blockchain devices can also be servers providing various services; these can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Various types of communication media can exist between devices, such as wired or wireless communication links.
[0050] Depending on the implementation requirements, the system architecture in this application embodiment can have any number of terminal devices and servers. For example, the devices in the blockchain node 120 and other components can be a server group composed of multiple server devices. Furthermore, the technical solutions provided in this application embodiment can be applied to a computing platform, or can be implemented jointly by various parts of the system; this application does not impose any special limitations on this.
[0051] like Figure 1 As shown, user terminal 110 submits transactions to be executed to blockchain node 120. User terminals 110 also communicate with each other to exchange information related to dependent transactions. Blockchain node 120 packages transactions according to the dependencies specified by user terminal 110, and communicates with each other to reach consensus and upload the blockchain transactions proposed by user terminal 110 to the blockchain. If consensus is successful, the transaction is uploaded to the blockchain; if consensus fails, the transaction fails. Specifically, blockchain node 120 obtains pending transactions from user terminal 110, which contain transaction dependency information with other pending transactions in the blockchain. Then, based on the transaction dependency information, blockchain node 120 obtains other pending transactions that are dependent on the pending transaction from the blockchain's pending transaction pool, and packages the pending transaction and other pending transactions into a dependent transaction package according to the execution order of the pending transaction. Finally, blockchain node 120 uploads the dependent transaction package to the blockchain.
[0052] The implementation details of the technical solutions in the embodiments of this application are described in detail below: Figure 2A flowchart of a blockchain transaction processing method according to an embodiment of this application is shown. This method can be executed by a device with computing capabilities, such as a server or terminal device of a blockchain system. It is understood that the execution logic control or scheduling process of the blockchain system as a whole can be specifically executed by one node in the blockchain system (e.g., controlled by the master node), or it can be executed jointly by multiple nodes. (Refer to...) Figure 2 As shown, the blockchain transaction processing includes at least steps S210 to S240, which are detailed below:
[0053] Step S210: Obtain pending transactions from the blockchain, wherein the pending transactions contain transaction dependency information between them and other pending transactions in the blockchain.
[0054] The pending transaction is typically submitted to the blockchain node via a client. It contains transaction information from the blockchain transaction, such as the payer, receiver, and contract call data. The pending transaction also includes transaction dependency information. Users add dependency information between the pending transaction and other pending transactions through the client. This dependency information can be obtained online via the client or offline from the submitter of other pending transactions. This dependency information usually includes which transactions(s) depend on the current transaction and which transactions(s) the current transaction depends on. For example, if the overall dependency relationship is that transaction A depends on transaction B, and transaction B depends on transaction C, then the execution order can be considered as transaction C -> transaction B -> transaction A. Transaction B's dependency information would include its dependence on transaction C and its dependence on transaction A. The dependency information typically includes identification information for other pending transactions with dependencies, such as transaction identifiers or transaction hashes.
[0055] Step S220: Based on the transaction dependency information, obtain other pending transactions that are dependent on the pending transaction from the pending transaction pool of the blockchain.
[0056] Blockchain nodes use transaction dependency information to retrieve other pending transactions that are dependent on the current pending transaction from the blockchain's pending transaction pool. The pending transaction pool is a pool used by blockchain nodes to temporarily store blockchain transactions with dependencies. The transaction dependency information includes transaction identification information of other pending transactions, such as transaction identifiers or transaction hashes. Blockchain nodes read other pending transactions that are dependent on the current pending transaction from the pending transaction pool using the transaction identification information. It can be understood that these other pending transactions were previously submitted to the blockchain node, and these other pending transactions themselves also contain transaction dependency information. For example, for transactions A, B, and C in the above example, assume that the blockchain node retrieves transactions A and C from the pending transaction pool based on transaction B. For transaction B, its transaction dependency information will include the transaction identification information of transactions A and C, while the transaction dependency information of transaction A will include the transaction identification information of transactions B and C.
[0057] Step S230: Based on the transaction execution order of the pending transaction and the other pending transactions, package the pending transaction and the other pending transactions into a dependent transaction package.
[0058] Blockchain nodes package pending transactions into dependency transaction bundles according to their execution order. The execution order can be directly included within the pending transactions or determined based on transaction dependency information. For example, the execution order can be determined by sorting transactions based on their dependencies and being depended upon. In some embodiments, the execution order is submitted to the blockchain node along with the pending transactions. Specifically, a dependency transaction bundle can be a sequence of blockchain transactions, where pending transactions are ordered according to their execution order and placed into a designated data structure for bundled processing.
[0059] Step S240: Upload the dependent transaction package to the blockchain.
[0060] In this application, blockchain nodes periodically select transactions with higher priority from their transaction mempool to form blocks, which are then verified and executed by other validator nodes after consensus is reached. Dependent transaction packages are treated as a single transaction during the process of determining which transactions to include on the blockchain. Subsequently, during the actual block generation process, the transactions in the dependent transaction package are added to the block sequentially according to their order. The priority of a transaction or transaction package can be determined based on transaction fees, transaction time, quantity of traded items, or the importance of the transacting parties and recipients. It is understood that the information of the dependent transaction package itself is typically not added to the block. That is, what is actually blockchained is the individual blockchain transactions within the dependent transaction package, and the blockchained block contains blockchain transactions arranged in the order of transaction execution. Furthermore, interdependent transactions only need to be blockchained in the order specified in the dependent transaction package, but they do not necessarily have to be written consecutively. In some embodiments, transactions within a dependent transaction package can be blockchained in different blocks, but they still need to be blockchained in the order specified in the dependent transaction package.
[0061] In the embodiments of this application, a blockchain node obtains pending transactions from the blockchain. These pending transactions contain transaction dependency information with other pending transactions in the blockchain. Then, based on this dependency information, it retrieves other pending transactions that are dependent on the pending transaction from the blockchain's pending transaction pool. Next, according to the execution order of the pending transaction and the other pending transactions, it packages the pending transaction and the other pending transactions into a dependency transaction package. Finally, the dependency transaction package is uploaded to the blockchain. In this way, blockchain transactions contain explicit definitions of transaction dependencies. Blockchain nodes package and upload transactions according to the execution dependencies and transaction order, thereby avoiding transaction execution failures caused by missing dependency transactions or incorrect packaging order, which helps improve the success rate and efficiency of blockchain transaction execution.
[0062] In some embodiments of this application, based on the technical solutions of this application, during the process of obtaining other pending transactions that are dependent on the pending transaction from the pending transaction pool of the blockchain according to the transaction dependency information, the blockchain node will search for other pending transactions that are dependent on the pending transaction in the pending transaction pool according to the transaction dependency information. If the pending transaction pool does not contain the other pending transactions, the blockchain node will add the pending transaction to the pending transaction pool to wait for the other pending transactions to be executed. If the pending transaction pool contains the other pending transactions, the blockchain node will obtain the other pending transactions from the pending transaction pool. In this application, the blockchain node will search for dependent transactions of the pending transaction in the pending transaction pool according to the transaction dependency information. If the pending transaction pool does not contain other pending transactions that are dependent on the current pending transaction, it means that its dependent transactions have not yet arrived at the current blockchain node, and the blockchain node will add the current pending transaction to the pending transaction pool to wait for all dependent transactions to arrive. Transactions in the pending transaction pool are temporarily suspended; they are neither executed nor directly added to the blockchain. Instead, they are packaged into a dependency transaction bundle and added to the blockchain only after all dependent transactions have arrived. Blockchain nodes add pending transactions to the pending transaction pool and then proceed with the next transaction. In essence, when all dependent transactions arrive at the blockchain node, the node can retrieve all dependent transactions from the pending transaction pool before processing the last arriving pending transaction, allowing it to continue the subsequent packaging and on-chain process. This method ensures that dependent transactions are processed together, preventing incomplete on-chain transactions that could lead to execution failure.
[0063] In some embodiments of this application, based on the technical solutions described herein, a blockchain node obtains transaction information of a first blockchain transaction submitted by a first client, and then receives transaction hashes of second blockchain transactions that are dependent on the first blockchain transaction from a second client. The blockchain node generates transaction dependency information for the first blockchain transaction based on the transaction hashes of the second blockchain transactions, and generates blockchain transactions to be processed based on the transaction information and the transaction dependency information of the first blockchain transactions. In this embodiment, the first client runs on the device of the blockchain node, and the second client can run on another device. A user submits transaction information for the first blockchain transaction through the first client, and the blockchain node receives transaction hashes of second blockchain transactions that are dependent on the first blockchain transaction from the second client through the first client. The second blockchain transaction is a transaction submitted to the blockchain through the second client, and the dependency between the first and second blockchain transactions can be pre-arranged offline by the users of the first and second clients. It is understood that the first client also sends the transaction hashes of the first blockchain transaction to the second client. The blockchain node generates transaction dependency information for the first blockchain transaction based on the transaction hashes of the second blockchain transactions. Specifically, the transaction information includes the specific dependency relationship between the first blockchain transaction and the second blockchain transaction; that is, the first blockchain transaction depends on the second blockchain transaction or vice versa. The blockchain node merges and saves the dependency relationship and the transaction hash of the second blockchain transaction as the dependency relationship information for the first blockchain transaction. Then, based on the transaction information and the dependency relationship information, a blockchain transaction to be processed is generated. In this application, the blockchain transaction includes at least five pieces of information: sender, receiver, contract call data, whether it is a dependent transaction, and an array of dependent transactions. Through the above method, blockchain transactions containing dependency relationship information are generated by clients sending transaction hashes of dependent transactions to each other. This allows users to coordinate the dependency order of transactions themselves, eliminating the need for complex dependency retrieval and analysis by the blockchain node, thus improving the blockchain's ability to handle multi-user collaborative transactions and its transaction processing efficiency.
[0064] In embodiments of this application, a method for... Figure 2 Other detailed embodiments of the technical solution shown in the example are as follows: Figure 3 As shown, in one embodiment of the blockchain transaction processing method of this application, the solution of this application may include the following steps:
[0065] Step S310: Obtain pending transactions from the blockchain, wherein the pending transactions contain transaction dependency information between them and other pending transactions in the blockchain.
[0066] Optionally, the implementation details of step S310 are the same as... Figure 2 The steps S210 shown are the same and will not be repeated here.
[0067] Step S320: Based on the transaction dependency information, obtain other pending transactions that are dependent on the pending transaction from the pending transaction pool of the blockchain.
[0068] Optionally, the implementation details of step S320 are the same as those of... Figure 2 The steps S220 shown are the same and will not be repeated here.
[0069] Step S330: Obtain the transaction order index in the pending transactions and the transaction order index in the other pending transactions. The transaction order index is used to indicate the execution order of blockchain transactions in transaction dependencies.
[0070] Step S340: Sort and package the pending transactions and other pending transactions according to the transaction sequence index to obtain a dependent transaction package.
[0071] In this embodiment, the transactions to be processed include transaction order indexes, which can be used as part of transaction dependency information. The transaction order index indicates the execution order of blockchain transactions within the transaction dependency relationship. For example, for three blockchain transactions with dependencies, the transaction order index of the first transaction A to be executed can be set to 0, and the transaction order indices of the subsequent two transactions B and C can be set to 1 and 2, respectively. Transactions in the dependency transaction package are sorted according to their transaction order indices. For example, if the dependency transaction package is in the form of an array, in the example above, the dependency transaction package is an array containing three elements, with array elements numbered 0, 1, and 2 representing transactions A, B, and C, respectively. In another embodiment, the dependency transaction package is in the form of a queue or a stack. Correspondingly, the blockchain node will enqueue the three transactions in ascending order or push them onto the stack in descending order according to their transaction order indices. The transaction order index can be set by the user when submitting the transaction, or it can be determined automatically by the client or the blockchain node based on the relationships between multiple transactions submitted by the user. For example, if a client determines that a user's account has insufficient remaining resources for the next payment transaction, it can establish a dependency between the payment transaction and the next transaction that needs to receive resources, thereby ensuring the payment transaction can be executed successfully. In this way, users can explicitly customize the expected order of transaction dependencies, and then the nodes will package the transactions according to the user-specified dependency order, ensuring the user's transactions are executed successfully.
[0072] Step S350: Upload the dependent transaction package to the blockchain.
[0073] Optionally, the implementation details of step S350 are the same as... Figure 2 The steps S240 shown are the same and will not be repeated here.
[0074] In the embodiments of this application, a blockchain node obtains pending transactions from the blockchain. These pending transactions contain transaction dependency information with other pending transactions in the blockchain. Then, based on this dependency information, it retrieves other pending transactions that are dependent on the pending transaction from the blockchain's pending transaction pool. Next, according to the execution order of the pending transaction and the other pending transactions, it packages the pending transaction and the other pending transactions into a dependency transaction package. Finally, the dependency transaction package is uploaded to the blockchain. In this way, blockchain transactions contain explicit definitions of transaction dependencies. Blockchain nodes package and upload transactions according to the execution dependencies and transaction order, thereby avoiding transaction execution failures caused by missing dependency transactions or incorrect packaging order, which helps improve the success rate and efficiency of blockchain transaction execution.
[0075] In some embodiments of this application, based on the technical solutions of this application, the pending transactions and other pending transactions are sorted and packaged according to the transaction order index. If the transaction order index of the pending transaction is the same as that of the other pending transactions, the blockchain node will discard the pending transaction and delete the other pending transactions from the pending transaction pool. When the blockchain node finds that two transactions have the same transaction order index, it will directly discard all transactions involved in the related dependency relationship, and the related transactions in the pending transaction pool will also be deleted. In this way, the blockchain node can detect transactions that will fail due to incorrect transaction order before the actual execution of the transaction, reducing the probability of transaction failure and the losses caused by transaction failure.
[0076] In some embodiments of this application, based on the technical solutions of this application, the pending transaction further includes a transaction type, which is either a dependent transaction or a normal transaction. During the process of retrieving other pending transactions that are dependent on the pending transaction from the pending transaction pool according to the transaction dependency information, if the transaction type of the pending transaction is a normal transaction, the blockchain node adds the pending transaction to the normal transaction pool of the blockchain. If the transaction type of the pending transaction is a dependent transaction, other pending transactions that are dependent on the pending transaction are retrieved from the pending transaction pool according to the transaction dependency information. In this embodiment, the pending transaction uses a transaction type to indicate whether the current transaction is an independently executed normal transaction or a dependent transaction that depends on other transactions. For dependent transactions, the blockchain node processes them according to the methods of the various technical solutions of this application. For normal transactions, the blockchain node places them into the normal transaction pool. The normal transaction pool is a transaction pool independent of the pending transaction pool. Pending transactions in the normal transaction pool are directly packaged into new blocks when the blockchain node packages blocks. By processing and storing dependent transactions separately from non-dependent transactions, we can avoid the storage of dependent transactions occupying transaction pool space and causing ordinary transactions to be delayed, as well as the processing of dependent transactions causing delays in the processing of ordinary transactions, thus improving the overall efficiency of transaction execution.
[0077] In some embodiments of this application, based on the technical solutions of this application, during the process of uploading the dependent transaction package to the blockchain, the blockchain node packages the dependent transaction packages in the dependent transaction pool of the blockchain and the pending transactions in the ordinary transaction pool into a block to be uploaded to the blockchain. The dependent transaction pool contains packaged but not yet uploaded dependent transaction packages; then, the block to be uploaded to the blockchain is uploaded. In this embodiment, when packaging the blockchain, the blockchain node simultaneously obtains the transactions to be packaged from both the dependent transaction pool and the ordinary transaction pool. The dependent transaction pool contains packaged but not yet uploaded dependent transaction packages, and each dependent transaction package contains at least two transactions. The dependent transaction pool and the ordinary transaction pool are two independent transaction pools. The blockchain node can alternately obtain the transactions to be packaged from these two transaction pools. For example, the blockchain node obtains a dependent transaction package containing four transactions from the dependent transaction pool. Blockchain nodes sequentially add the first dependent transaction to a block. Then, a regular transaction is retrieved from the regular transaction pool and added to the block, followed by the second dependent transaction. This process repeats until all four dependent transactions are added to the block. The next dependent transaction package is then processed, continuing until the block meets its required transaction count. Alternatively, blockchain nodes can add all four dependent transactions to the block together and then retrieve the regular transactions to be uploaded from the regular transaction pool. This method of packaging dependent and regular transactions together avoids transaction delays caused by waiting for transactions in one pool to be packaged, thus improving the blockchain's transaction response speed.
[0078] In some embodiments of this application, based on the technical solutions of this application, during the process of packaging dependent transaction packages in the dependent transaction pool of the blockchain and pending transactions in the ordinary transaction pool into a block to be uploaded to the blockchain, the blockchain node obtains the dependent transaction package with the highest transaction fee from the dependent transaction pool and the ordinary transaction with the highest transaction fee from the ordinary transaction pool. Then, based on the transaction fees of the dependent transaction package and the ordinary transaction, the ordinary transaction or dependent transaction package with the higher transaction fee is added to the block to be uploaded to the blockchain. In this embodiment, the blockchain node determines the priority of ordinary transactions and dependent transaction packages through transaction fees, and adds the transaction or transaction package with the higher transaction fee from the ordinary transaction and dependent transaction package to the block to be uploaded to the blockchain through comparison. Transaction fees are the resources paid by one or both parties to a transaction so that the transaction can be executed. Transaction fees can be determined by the two parties to the transaction, or calculated by the client or blockchain node based on the content of the transaction to be performed, such as charging a fixed fee or charging a certain percentage. The transaction fee for a dependent transaction package can be determined based on the transaction fees of the dependent transactions it contains, such as by using a maximum, minimum, or average value. This allows blockchain nodes to prioritize dependent transaction packages and regular transactions when packaging blocks, which improves the response speed of important transactions and ensures the orderly execution of blockchain transactions.
[0079] In some embodiments of this application, based on the technical solution of this application, the blockchain node also obtains the transaction fees of each dependent transaction in the dependent transaction package, and then determines the transaction fee of the dependent transaction package based on the average transaction fees of each dependent transaction. In this embodiment, the transaction fee of the dependent transaction package is determined by the average transaction fees of each dependent transaction in the dependent transaction package, which is beneficial to the operability of the solution of this application.
[0080] In embodiments of this application, a method for... Figure 2 Other detailed embodiments of the technical solution shown in the example are as follows: Figure 4 As shown, in one embodiment of the blockchain transaction processing method of this application, the solution of this application may include the following steps:
[0081] Step S410: Obtain pending transactions from the blockchain, wherein the pending transactions contain transaction dependency information between them and other pending transactions in the blockchain.
[0082] Optionally, the implementation details of step S410 are the same as those of... Figure 2 The steps S210 shown are the same and will not be repeated here.
[0083] Step S420: Based on the transaction dependency information, obtain other pending transactions that are dependent on the pending transaction from the pending transaction pool of the blockchain.
[0084] Optionally, the implementation details of step S420 are the same as those of... Figure 2 The steps S220 shown are the same and will not be repeated here.
[0085] Step S430: Based on the transaction execution order of the pending transaction and the other pending transactions, package the pending transaction and the other pending transactions into a dependent transaction package.
[0086] Optionally, the implementation details of step S430 are the same as those of... Figure 2 The steps S230 shown are the same and will not be repeated here.
[0087] Step S440: Upload the dependent transaction package to the blockchain.
[0088] Optionally, the implementation details of step S440 are the same as those of... Figure 2 The steps S240 shown are the same and will not be repeated here.
[0089] Step S450: Receive a transaction verification request for a block to be uploaded to the blockchain, wherein the block to be uploaded to the blockchain contains pending transactions with dependencies.
[0090] Step S460: Based on the transaction dependency information of the pending transactions in the block to be uploaded to the blockchain, verify the transaction order of the pending transactions with dependencies in the block to be uploaded to the blockchain.
[0091] Step S470: If the transaction order verification passes, execute the pending transactions in the blockchain according to the transaction order in the block to be added to the chain.
[0092] In this embodiment, during the block consensus process, blockchain nodes verify the execution order of dependent transactions. Specifically, a blockchain node receives a transaction verification request for a block to be added to the blockchain. This verification request is typically initiated by the proposing node after packaging the block. The block to be added to the blockchain contains dependent transactions. During the verification process, the blockchain node reads the transaction dependency information of the transactions. If the read dependency information is not empty, it indicates that the transaction depends on other transactions. Based on the dependency information, the blockchain node verifies the transaction order of dependent transactions within the block to be added to the blockchain. Specifically, the transaction order verification includes the verification of dependent transactions and the verification of the transaction order within the block. The dependent transactions of the current pending transaction can be determined based on the dependency information. The blockchain node determines that all dependent transactions are in the current block to be added to the blockchain, or that the dependent transactions have already been added to the blockchain. The transaction order can be determined based on each dependent transaction. The blockchain node can obtain the corresponding execution order from each dependent transaction and compare it with the order packaged in the block to complete the verification. If the transaction order verification passes, it means the order of transactions packaged in the current block is correct and will not cause transaction failure. Blockchain nodes execute the pending transactions in the blockchain according to the order of transactions in the block to be added to the chain. For example, after consensus is reached on the block, a blockchain node can update its local data based on the individual transactions in the block according to the notification of transaction addition to the chain. If the transaction order verification fails, the blockchain node will not execute these dependent transactions. For example, the blockchain node may vote against the block to be added to the chain or these dependent transactions to prevent them from being formally executed. In this way, the blockchain node verifies the transaction dependency order within the block, ensuring that the block to be added to the chain packages transactions according to the expected transaction dependency order, avoiding transaction order discrepancies due to abnormal packaging order, which could lead to partial transaction failure for users.
[0093] In the embodiments of this application, a blockchain node obtains pending transactions from the blockchain. These pending transactions contain transaction dependency information with other pending transactions in the blockchain. Then, based on this dependency information, it retrieves other pending transactions that are dependent on the pending transaction from the blockchain's pending transaction pool. Next, according to the execution order of the pending transaction and the other pending transactions, it packages the pending transaction and the other pending transactions into a dependency transaction package. Finally, the dependency transaction package is uploaded to the blockchain. In this way, blockchain transactions contain explicit definitions of transaction dependencies. Blockchain nodes package and upload transactions according to the execution dependencies and transaction order, thereby avoiding transaction execution failures caused by missing dependency transactions or incorrect packaging order, which helps improve the success rate and efficiency of blockchain transaction execution.
[0094] In some embodiments of this application, based on the technical solutions of this application, during the process of verifying the transaction order of dependent transactions in the block to be uploaded to the blockchain according to the transaction dependency information of the transactions to be processed in the block to be uploaded, the blockchain node will obtain the transaction packaging order of each transaction in the dependent transaction package in the block to be uploaded to the blockchain according to the transaction dependency information of the transactions to be processed. If the transaction packaging order matches the transaction execution order, the blockchain node determines that the transaction order verification is successful. In this embodiment, the blockchain node will obtain the transaction packaging order of each transaction in the dependent transaction package in the block to be uploaded to the blockchain according to the transaction dependency information. For example, if the transaction dependency information contains three transactions, the blockchain node will query the transaction order of these four transactions in the block to be uploaded to the blockchain, including the current transaction to be processed, to obtain the transaction packaging order. The blockchain node will compare the transaction packaging order with the transaction execution order. The transaction execution order can be directly included in the transaction to be processed, or it can be obtained by summarizing the transaction information of each dependent transaction. If the transaction packaging order matches the transaction execution order, the blockchain node determines that the transaction order verification is successful. If the order in which transactions are packaged does not match the order in which they are executed, it indicates that the order in which the transactions are packaged in the block is incorrect. Blockchain nodes can then vote against these individual transactions or against the entire block. This method ensures that the order in which transactions are packaged in the block matches the expected order, reducing losses caused by transaction execution failures.
[0095] In some embodiments of this application, based on the technical solutions of this application, the blockchain node will also obtain other pending transactions that are dependent on the pending transaction from the block to be uploaded, according to the transaction dependency information of the pending transaction. Then, based on the transaction order index in the pending transaction and the transaction order index in the other pending transactions, the execution order of the transactions will be determined. In this embodiment, the blockchain node retrieves dependent transactions based on the transaction dependency information, and then obtains the transaction order index in each dependency. The desired execution order of each transaction in the dependency is determined based on the order of the transaction order index, which helps improve the operability of the solution.
[0096] The implementation details of the technical solutions in the embodiments of this application are described below with specific examples. Please refer to... Figure 5 , Figure 5 This is a schematic diagram illustrating a blockchain transaction processing procedure involving transaction dependencies in an embodiment of this application. For example... Figure 5 As shown, this process mainly involves six parts. First, a user holds a private key and a wallet address, which allows them to sign and send one or more transactions to a node, waiting for the node to package and execute them. The packaging node is responsible for retrieving transactions from the transaction pool, packaging them into blocks, and broadcasting them to other validator nodes for verification after consensus. At each block height, one validator node is randomly selected as the packaging node. The validator nodes are responsible for verifying the legality of the new block, the legality of the transactions within the new block, and the legality of the transaction dependency order. The ordinary transaction pool stores ordinary transactions, i.e., ordinary transactions that do not depend on any other transactions. The pending transaction pool temporarily stores transactions whose dependent transactions have not yet arrived. For example, if transaction X needs to be packaged with Y, but Y has not yet arrived at a node, then X is temporarily stored in the pending transaction pool. The bundled transaction pool stores bundled transaction packages. Once transactions X and Y have both arrived in the pending transaction pool, transactions X and Y are bundled and placed in this bundled transaction pool, waiting to be packaged together. Figure 5 As shown, user A can submit a simple transaction that does not depend on any other transactions. The transaction details are as follows:
[0097] TX common =(From,To,Calldata,TX) TYPE RelyTx array )
[0098] Here, From, to, and Calldata represent the sender, receiver, and contract call data, respectively. Two new fields have been added to the transaction: TX. TYPE =0 represents a normal transaction, that is, a transaction that does not depend on any other transaction. RelyTx array To use a dependent transaction array, regular transactions can be set to an empty array.
[0099] When user A and user B need to coordinate the dependency order of certain custom transactions, suppose user B has two transactions, B1 and B2, where B2 is executed after B1, and B1 is executed after user A's transaction A1. Then user A sends the following transactions:
[0100] TX A1 =(From,To,Calldata,TX) TYPE RelyTx array (TxIndex)
[0101] Among them, TX TYPE A value of 1 indicates that this is a transaction that depends on other transactions and needs to be bundled and packaged with other transactions in a certain transaction order.
[0102] RelyTx array =[TXHash B1 ,TXHash B2 [ ], that is, the transaction hashes of B1 and B2, TxIndex = 0, indicating that it is the 0th item in this bundle. In this application, RelyTx can be set to null when calculating the transaction hash. array Then perform a hash calculation on the transaction.
[0103] User B sent the following transaction:
[0104] TX B1 =(From,To,Calldata,TX) TYPE ,[TXHash A1 ,TXHash B2 ],1)
[0105] TX B2 =(From,To,Calldata,TX) TYPE ,[TXHash A1 ,TXHash B1 ],2)
[0106] When the blockchain node receives the transaction TX common When the node receives the transaction (TX), it will place the transaction in the regular transaction pool; when the node receives the transaction (TX), it will place the transaction in the regular transaction pool. A1 At that time, the blockchain node will check the RelyTx of the transaction. array It was found to be [TXHash] B1 ,TXHash B2 The blockchain node determines whether transactions B1 and B2 are in the pending transaction pool based on their transaction hashes. If both transactions B1 and B2 are present, the blockchain node will bundle the three transactions together. If either transaction is absent, the blockchain node will bundle transaction TX. A1Place the transaction in the pending transaction pool, waiting for other transactions to arrive.
[0107] After transactions A1, B1, and B2 all arrive at the blockchain node, the blockchain node will retrieve these three transactions from the pending transaction pool and combine them into a single bundled transaction package:
[0108] Tx package =[TX A1 ,TX B1 ,TX B2 ]
[0109] The order in which these three transactions are packaged is based on their TxIndex values, sorted from smallest to largest, with smaller values having higher priority and larger values having lower priority. If some transactions have the same TxIndex value, the entire bundled transaction package will be discarded by the node and will not be included in subsequent packages.
[0110] Next, calculate the average transaction fee for this bundle, i.e.:
[0111]
[0112] GasPrice package This serves as a priority criterion when the bundled transaction is subsequently packaged. The bundle will then be placed in the bundled transaction pool, awaiting further packaging.
[0113] For each block height N, the randomly selected packaging node will retrieve transactions and bundles from the regular transaction pool and the bundled transaction pool, and package them into block N.
[0114] The packaging node sorts transactions in the regular transaction pool and the bundled transaction pool from highest to lowest based on their transaction fees. For regular transactions, the GasPrice is used as the reference, while for bundled transaction packages, the GasPrice is calculated using the above process. package .
[0115] Next, retrieve the trade with the highest transaction fee from the regular trading pool and the bundle with the highest transaction fee from the bundled trading pool. Select the bundle with the higher transaction fee. Then, repeatedly select from both pools, similar to a cursor, always choosing the trade or bundle with the higher transaction fee.
[0116] Finally, the packaging of block N is completed.
[0117] Block N =(TX common ,Tx package )
[0118] Block N will be broadcast to other validator nodes, and after the other validator nodes complete the verification, a consensus will be reached.
[0119] The verification node needs to additionally verify whether the packaging node has packaged transactions in the order of transaction dependencies specified by the user. Please refer to [link / reference]. Figure 6 , Figure 6 This is a schematic diagram of the transaction dependency order verification process in an embodiment of this application. Figure 6 As shown, the validator node first performs a block header validity check. Whenever a new block is received, the validator node verifies the validity of the block header. This mainly includes verifying: whether the block height is correct (e.g., whether it equals the previous block height plus one), whether the block hash is concatenated, and whether the block packer is the randomly and deterministically selected packer. If the verification fails, the block is rejected, and no further steps are required. After successful verification, the validator node distinguishes the block body transactions. The validator node parses the transaction body of the new block, iterating through each transaction. If the transaction type is a normal transaction (TX), then... TYPE If the value is 0, then transaction verification and validation will proceed directly. If the transaction type is a dependency transaction (TX), then... TYPE If the value is 1, then the order of bundled transactions is checked. Specifically, the verification node will retrieve the transaction priority of dependent transactions. If it iterates to transaction B2, that is...
[0120] TX B2 =(From,To,Calldata,TX) TYPE ,[TXHash A1 ,TXHash B1 ],2)
[0121] First, we determine that transaction B2 has a priority of 2. Then, we find that B2 depends on transactions A1 and B1, so we retrieve these two transactions and find that their priorities are 0 and 1, respectively. Therefore, we can determine the transaction priority order as follows:
[0122] Tx priority =[A1, B1, B2]
[0123] The verification node also retrieves the actual transaction order of dependent transactions. It retrieves the actual transaction order of transactions A1, B1, and B2 within the block body, that is, their specific locations within the block body, sorted from smallest to largest, to obtain the actual transaction order of the three transactions:
[0124] Tx order =[A1, B1, B2]
[0125] The verification node then compares the priority with the actual transaction order. This compares the Tx obtained through the above process. priority and Tx orderTo ensure that the order of the transactions is identical, if any discrepancy exists, the three transactions will not be executed, and row transaction verification will not be performed. If all transactions are identical, then row transaction verification will be performed. During transaction verification, the verification node checks the legality of the transaction, such as verifying the validity of the transaction signature. After successful verification, the transaction will be executed, and the world state will be updated. Thus, transactions with dependent order can be executed in the order expected by the user.
[0126] It should be noted that although the steps of the method in this application are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0127] The following describes the implementation of the apparatus of this application, which can be used to execute the blockchain transaction processing method in the above embodiments of this application. Figure 7 A schematic block diagram illustrating the composition of a blockchain transaction processing apparatus in an embodiment of this application is shown. Figure 7 As shown, the blockchain transaction processing device 700 mainly includes:
[0128] The transaction acquisition module 710 is configured to acquire pending transactions in the blockchain, wherein the pending transactions include transaction dependency information between them and other pending transactions in the blockchain.
[0129] The transaction dependency module 720 is configured to obtain other pending transactions that are dependent on the pending transaction from the pending transaction pool of the blockchain based on the transaction dependency information.
[0130] The transaction packaging module 730 is configured to package the pending transaction and the other pending transactions into a dependent transaction package according to the transaction execution order of the pending transaction and the other pending transactions;
[0131] The transaction on-chain module 740 is configured to put the dependent transaction package on the blockchain.
[0132] In some embodiments of this application, based on the above technical solutions, the transaction dependency module 720 is specifically configured to: retrieve other pending transactions that have a dependency relationship with the pending transaction from the pending transaction pool according to the transaction dependency information; if the pending transaction pool does not contain the other pending transactions, add the pending transaction to the pending transaction pool to wait for the other pending transactions to be executed; if the pending transaction pool contains the other pending transactions, obtain the other pending transactions from the pending transaction pool.
[0133] In some embodiments of this application, based on the above technical solutions, the transaction packaging module 730 is specifically configured to: obtain the transaction order index in the pending transaction and the transaction order index in the other pending transactions, wherein the transaction order index is used to indicate the execution order of blockchain transactions in transaction dependencies; and sort and package the pending transaction and the other pending transactions according to the transaction order index to obtain a dependency transaction package.
[0134] In some embodiments of this application, based on the above technical solutions, the transaction packaging module 730 is further configured to: if the transaction order index of the pending transaction is the same as the transaction order index of the other pending transactions, then discard the pending transaction and delete the other pending transactions from the pending transaction pool.
[0135] In some embodiments of this application, based on the above technical solutions, the dependent transaction module 720 is further configured to: obtain pending transactions from the blockchain, wherein the pending transactions further include transaction types, and the transaction types are dependent transactions or ordinary transactions; if the transaction type of the pending transaction is an ordinary transaction, then the pending transaction is added to the ordinary transaction pool of the blockchain.
[0136] In some embodiments of this application, based on the above technical solutions, the transaction on-chain module 740 is specifically configured to: package the dependent transaction packages in the dependent transaction pool of the blockchain and the pending transactions in the ordinary transaction pool into a block to be on-chain, wherein the dependent transaction pool contains the packaged but not yet on-chain dependent transaction packages; and put the block to be on-chain into the blockchain.
[0137] In some embodiments of this application, based on the above technical solutions, the transaction on-chain module 740 is specifically configured to: obtain the dependent transaction package with the highest transaction fee to be on-chain from the dependent transaction pool of the blockchain; obtain the ordinary transaction with the highest transaction fee to be on-chain from the ordinary transaction pool; and add the ordinary transaction or dependent transaction package with the higher transaction fee to the block to be on-chain according to the transaction fee of the dependent transaction package to be on-chain and the transaction fee of the ordinary transaction to be processed.
[0138] In some embodiments of this application, based on the above technical solutions, the transaction packaging module 730 is further configured to: obtain the transaction fees of each dependent transaction in the dependent transaction package; and determine the transaction fees of the dependent transaction package based on the average transaction fees of each dependent transaction.
[0139] In some embodiments of this application, based on the above technical solutions, the transaction on-chain module 740 is further configured to: receive a transaction verification request for a block to be on-chain, wherein the block to be on-chain contains pending transactions with dependencies; verify the transaction order of the pending transactions with dependencies in the block to be on-chain according to the transaction dependency information of the pending transactions in the block to be on-chain; if the transaction order verification is successful, execute the pending transactions in the blockchain according to the transaction order in the block to be on-chain.
[0140] In some embodiments of this application, based on the above technical solutions, the transaction on-chain module is specifically configured to: obtain the transaction packaging order of each transaction to be processed in the dependent transaction package to be on-chain in the block to be on-chain according to the transaction dependency relationship information of the transaction to be processed; if the transaction packaging order matches the transaction execution order, then the transaction order verification is determined to be successful.
[0141] In some embodiments of this application, based on the above technical solutions, the transaction on-chain module 740 is further configured to: obtain other pending transactions that have a dependency relationship with the pending transaction from the block to be on-chain according to the transaction dependency information of the pending transaction; and determine the transaction execution order according to the transaction order index in the pending transaction and the transaction order index in the other pending transactions.
[0142] In some embodiments of this application, based on the above technical solutions, the transaction acquisition module 710 is further configured to: acquire transaction information of a first blockchain transaction submitted by a first client; receive transaction hashes of second blockchain transactions that are dependent on the first blockchain transaction from a second client; generate transaction dependency information of the first blockchain transaction based on the transaction hashes of the second blockchain transaction; and generate blockchain transactions to be processed based on the transaction information of the first blockchain transaction and the transaction dependency information of the first blockchain transaction.
[0143] It should be noted that the apparatus provided in the above embodiments and the method provided in the above embodiments belong to the same concept, and the specific way in which each module performs the operation has been described in detail in the method embodiments, and will not be repeated here.
[0144] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown.
[0145] It should be noted that, Figure 8 The computer system 800 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0146] like Figure 8 As shown, the computer system 800 includes a Central Processing Unit (CPU) 801, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 802 or programs loaded from storage section 808 into Random Access Memory (RAM) 803. The RAM 803 also stores various programs and data required for system operation. The CPU 801, ROM 802, and RAM 803 are interconnected via a bus 804. An Input / Output (I / O) interface 805 is also connected to the bus 804.
[0147] The following components are connected to I / O interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), and speakers, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card and a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to I / O interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 810 as needed so that computer programs read from it can be installed into storage section 808 as needed.
[0148] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by central processing unit (CPU) 801, it performs various functions defined in the system of this application.
[0149] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0150] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0151] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0152] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this application.
[0153] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
[0154] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A blockchain transaction processing method, characterized in that, include: Obtain pending transactions from the blockchain, wherein the pending transactions include transaction dependency information between them and other pending transactions in the blockchain; Based on the transaction dependency information, other pending transactions that are dependent on the pending transaction are obtained from the pending transaction pool of the blockchain; Based on the transaction execution order of the pending transaction and the other pending transactions, the pending transaction and the other pending transactions are packaged into a dependent transaction package; The dependent transaction package is uploaded to the blockchain.
2. The method according to claim 1, characterized in that, The step of retrieving other pending transactions that are dependent on the pending transaction from the pending transaction pool of the blockchain based on the transaction dependency information includes: Based on the transaction dependency information, other pending transactions that are dependent on the pending transaction are retrieved from the pending transaction pool; If the pending transaction pool does not contain the other pending transactions, then the pending transaction is added to the pending transaction pool to wait for the other pending transactions to be executed; If the pending transaction pool contains the other pending transactions, then the other pending transactions are obtained from the pending transaction pool.
3. The method according to claim 1, characterized in that, The step of packaging the pending transaction and the other pending transactions into a dependent transaction package according to the transaction execution order of the pending transaction and the other pending transactions includes: Obtain the transaction order index of the pending transactions and the transaction order index of the other pending transactions, wherein the transaction order index is used to indicate the execution order of blockchain transactions in transaction dependencies; Based on the transaction order index, the pending transactions and other pending transactions are sorted and packaged to obtain a dependent transaction package.
4. The method according to claim 3, characterized in that, Before sorting and packaging the pending transactions and other pending transactions according to the transaction order index, the method further includes: If the transaction order index of the pending transaction is the same as the transaction order index of the other pending transactions, then the pending transaction is discarded and the other pending transactions are removed from the pending transaction pool.
5. The method according to claim 2, characterized in that, The pending transactions also include transaction types, which are either dependent transactions or ordinary transactions; the step of retrieving other pending transactions that are dependent on the pending transaction from the pending transaction pool based on the transaction dependency information includes: If the transaction type of the pending transaction is a normal transaction, then the pending transaction is added to the normal transaction pool of the blockchain; If the transaction type of the pending transaction is a dependent transaction, then based on the transaction dependency information, other pending transactions that have a dependency relationship with the pending transaction are retrieved from the pending transaction pool.
6. The method according to claim 5, characterized in that, The step of putting the dependent transaction package on the blockchain includes: The dependent transaction packages in the dependent transaction pool of the blockchain and the pending transactions in the ordinary transaction pool are packaged into a block to be uploaded to the chain. The dependent transaction pool contains the packaged dependent transaction packages that have not yet been uploaded to the chain. The block to be added to the blockchain is added to the blockchain.
7. The method according to claim 6, characterized in that, The step of packaging dependent transaction packages from the dependent transaction pool of the blockchain and pending transactions from the ordinary transaction pool into a block to be uploaded to the blockchain includes: Obtain the dependency transaction package with the highest transaction fee to be uploaded to the blockchain from the dependency transaction pool of the blockchain; Obtain the ordinary transaction with the highest transaction fee from the ordinary transaction pool that is ready to be uploaded to the blockchain; Based on the transaction fees of the pending on-chain dependent transaction packages and the transaction fees of the pending ordinary transactions, the ordinary transactions or pending on-chain dependent transaction packages with higher transaction fees are added to the pending on-chain blocks.
8. The method according to claim 7, characterized in that, The method further includes: Obtain the transaction fees for each dependent transaction in the dependent transaction package: The transaction cost of the dependent transaction package is determined based on the average transaction cost of each dependent transaction.
9. The method according to claim 1, characterized in that, The method further includes: Receive transaction verification requests for blocks to be uploaded to the blockchain, wherein the blocks to be uploaded to the blockchain contain pending transactions with dependencies. Based on the transaction dependency information of the pending transactions in the block to be uploaded to the blockchain, the transaction order of the pending transactions with dependencies in the block to be uploaded to the blockchain is verified. If the transaction order verification passes, the pending transactions will be executed in the blockchain according to the transaction order in the block to be added to the chain.
10. The method according to claim 9, characterized in that, The step of verifying the transaction order of pending transactions in the pending-to-be-on-chain block based on the transaction dependency information of the pending transactions in the pending-to-be-on-chain block includes: Based on the transaction dependency information of the pending transactions, obtain the transaction packaging order of each pending transaction in the pending blockchain block. If the order in which the transactions are packaged matches the order in which they are executed, then the transaction order verification is successful.
11. The method according to claim 10, characterized in that, The method further includes: Based on the transaction dependency information of the pending transactions, other pending transactions that are dependent on the pending transactions are obtained from the blocks to be uploaded to the blockchain; The transaction execution order is determined based on the transaction order index in the pending transactions and the transaction order index in the other pending transactions.
12. The method according to claim 1, characterized in that, The method further includes: Obtain transaction information for the first blockchain transaction submitted by the first client; Receive the transaction hash of a second blockchain transaction that is dependent on the first blockchain transaction from the second client; Based on the transaction hash of the second blockchain transaction, generate the transaction dependency information of the first blockchain transaction; Based on the transaction information and transaction dependency information of the first blockchain transaction, a blockchain transaction to be processed is generated.
13. A blockchain transaction processing device, characterized in that, include: The transaction acquisition module is configured to acquire pending transactions in the blockchain, wherein the pending transactions include transaction dependency information between them and other pending transactions in the blockchain; The transaction dependency module is configured to retrieve other pending transactions that are dependent on the pending transaction from the pending transaction pool of the blockchain based on the transaction dependency information. The transaction packaging module is configured to package the pending transaction and the other pending transactions into a dependent transaction package according to the transaction execution order of the pending transaction and the other pending transactions; The transaction on-chain module is configured to upload the dependent transaction package to the blockchain.
14. An electronic device, characterized in that, include: processor; Memory for storing the executable instructions of the processor; The processor is configured to execute the blockchain transaction processing method according to any one of claims 1 to 12 by executing the executable instructions.
15. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the blockchain transaction processing method as described in any one of claims 1 to 12.
16. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the blockchain transaction processing method as described in any one of claims 1 to 12.