Block chain quota consumption control method and system supporting parallel transaction processing
By introducing a withholding mechanism with a quota consumption cap in the blockchain, the performance bottleneck caused by serial processing of transactions on the same account is resolved, parallel transaction processing and throughput improvement are achieved, and transaction consistency and uniform reduction of resource consumption are ensured.
Patent Information
- Application Number
- CN202510675347.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2025-09-05
AI Technical Summary
In blockchain, multiple transactions initiated by the same account must be processed serially due to read-write dependencies. This results in limited transaction execution performance and throughput in concurrent scenarios. This is especially true when quota consumption control mode is enabled, which leads to resource constraints on transaction processing and settlement inconsistencies.
Through a withholding fee mechanism based on the quota consumption cap, the quota consumption cap for transaction execution is determined in advance, and fees are uniformly deducted from the account status balance after the transaction is executed, enabling parallel processing of transactions from the same initiator, avoiding the impact of dependencies, and ensuring transaction consistency and throughput improvement.
It enables parallel processing of multiple transactions initiated by the same account, reduces the state read and write operations that consume account quotas, accelerates block execution and chain upload, and improves transaction throughput and throughput performance.
Smart Images

Figure CN120598554A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain quota consumption control method and system that supports parallel transaction processing. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] In blockchain, transaction serialization is an important factor limiting blockchain performance.
[0004] In the relevant existing technology, a parallel execution method for blockchain transactions based on read-write sets is proposed. By calling the smart contract for pre-execution when the transaction is constructed, a temporary world state is maintained and a read-write set is generated. When the block is constructed, a transaction dependency graph is directly constructed according to the read-write set, and the sequential transaction execution sequence is converted into a parallel transaction execution sequence. By executing transactions in parallel, the block execution efficiency and performance are improved.
[0005] However, limiting and settling the computing and storage resources consumed by on-chain transaction processing is a fundamental blockchain capability. The account state model is a commonly used data recording model. Each account has a quota balance state attribute that records the real-time status of the quota balance and is used to limit and settle the computing and storage resources consumed by transaction processing. When quota consumption control mode is enabled, transactions within a block, including transactions initiated by the same account and transactions for recharging or transferring quotas to that account, have read and write dependencies. This requires these transactions to be processed serially, impacting transaction execution performance and throughput in concurrent scenarios. Summary of the Invention
[0006] In order to solve the above problems, the present invention proposes a blockchain quota consumption control method and system that supports parallel transaction processing. Through a pre-withholding mechanism based on the quota consumption upper limit and a unified deduction method for transactions with the same initiator based on actual consumption after execution, it can support parallel processing of transactions with the same initiator, accelerate block execution and chain uploading, improve transaction throughput, and solve the performance limitation problem brought about by quota consumption control.
[0007] In order to achieve the above object, the present invention adopts the following technical solutions:
[0008] In a first aspect, the present invention provides a blockchain quota consumption control method supporting parallel transaction processing, comprising:
[0009] Build a transaction dependency graph based on the account read and write sets of transactions in the block;
[0010] According to the transaction dependency graph, the withholding fee processing is performed on the transactions subject to withholding fees in accordance with the transaction order, the withholding fee value is determined, and the post-withholding fee balance of the account of the initiator of the transaction subject to withholding fee is updated; wherein the transaction subject to withholding fee is a non-breakpoint transaction, a transaction that is different from the initiator of the breakpoint transaction and does not depend on the breakpoint transaction; the breakpoint transaction includes a quota breakpoint transaction and an insufficient balance breakpoint transaction, and the insufficient balance breakpoint transaction is a transaction in which the post-withholding fee balance of the account is less than the withholding fee value;
[0011] Transactions that meet the set conditions are executed in parallel, and the pre-deducted fee value is used as the quota consumption limit for transaction execution. The actual quota consumption value after the transaction execution is accumulated to the actual total deduction of the initiator's account, so that a unified deduction is made from the initiator's account status balance after the transaction execution.
[0012] As an optional implementation method, during the withholding fee processing, if the current transaction is the first transaction of its initiator account in this withholding fee processing, the account balance after withholding fee is set as the account status balance;
[0013] If the account status balance of the current transaction initiator is 0, the on-chain status of the current transaction is marked as a failed transaction, and the current transaction is removed from the transaction dependency graph, ending the withholding fee processing for this transaction.
[0014] As an optional implementation, the process of determining the withholding fee value includes: if the current transaction is the first transaction of its initiator account in this withholding fee processing, the withholding fee value is the minimum value of the account status balance, the system quota consumption limit, and the user quota consumption limit; if not, the withholding fee value is the minimum value of the system quota consumption limit and the user quota consumption limit;
[0015] The balance after updating the account withholding fee is the balance of the account withholding fee of the current transaction initiator's account minus the withholding fee value of the current transaction.
[0016] As an optional implementation, the setting conditions are:
[0017] All transactions with an out-degree of 0 and withheld fees will be directly executed by the smart contract, and the withheld fee value will be used as the upper limit of the transaction execution quota during execution;
[0018] All breakpoint transactions with an out-degree of 0 and a sequence number smaller than the current transaction and the same initiator account transactions that have all been executed will be processed as breakpoint transactions.
[0019] As an optional implementation, the process of processing breakpoint transactions for quota breakpoint transactions includes:
[0020] Update the account status balance of the write account involved in the breakpoint transaction and the account initiator of the breakpoint transaction;
[0021] Fees are deducted from the account status balance. The updated account status balance is minus the withholding fee value. The withholding fee value is the minimum value of the account status balance, the system quota consumption limit, and the user quota consumption limit.
[0022] Call the smart contract to execute the current transaction. After the execution is completed, the overcharged withholding fee value of the account status balance will be rolled back based on the actual quota consumption; the balance of the account after withholding the fee is updated to the account status balance, and the current transaction is removed from the transaction dependency graph;
[0023] After the current transaction, the fees for subsequent transactions that have not been withheld will be withheld again. After the withholding is completed, the current transaction ends and the transactions that meet the set conditions are selected again for parallel processing.
[0024] As an optional implementation method, the process of breakpoint transaction processing for insufficient balance breakpoint transactions includes: updating the account status balance of the initiator of the breakpoint transaction, deducting the actual quota consumption from the account status balance; then continuing the withholding fee processing from the current transaction, and after completing the withholding fee, starting again to select transactions that meet the set conditions for parallel processing.
[0025] In a second aspect, the present invention provides a blockchain quota consumption control system that supports parallel transaction processing, comprising:
[0026] A dependency graph building module is configured to build a transaction dependency graph based on the account read-write sets of transactions in the block;
[0027] The withholding fee module is configured to perform withholding fee processing for transaction execution quota consumption on transactions subject to withholding fees in sequence according to a transaction dependency graph, determine a withholding fee value, and update the post-withholding fee balance of the account of the initiator of the transaction subject to withholding fees; wherein the transaction subject to withholding fees is a non-breakpoint transaction, a transaction that is different from the initiator of the breakpoint transaction and is not dependent on the breakpoint transaction; breakpoint transactions include quota breakpoint transactions and insufficient balance breakpoint transactions, and insufficient balance breakpoint transactions are transactions in which the post-withholding fee balance of the account is less than the withholding fee value;
[0028] The transaction parallel execution module is configured to execute transactions that meet the set conditions in parallel, use the pre-deducted fee value as the quota consumption upper limit for transaction execution, and add the actual quota consumption value after the transaction execution to the actual total deduction of the initiator's account, so as to perform a unified deduction process from the initiator's account status balance after the transaction execution.
[0029] In a third aspect, the present invention provides an electronic device comprising a memory and a processor, and computer instructions stored in the memory and executed on the processor, wherein the computer instructions, when executed by the processor, perform the method described in the first aspect.
[0030] In a fourth aspect, the present invention provides a computer-readable storage medium for storing computer instructions, wherein when the computer instructions are executed by a processor, the method described in the first aspect is performed.
[0031] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which implements the method described in the first aspect when executed by a processor.
[0032] Compared with the prior art, the present invention has the following beneficial effects:
[0033] In order to solve the problem of quota consumption control demand in blockchain transaction processing, there are quota consumption of account sending transactions, quota change transactions with unpredictable variable amounts such as transfer and recharge, and serial processing of multiple transactions initiated by the same account affects blockchain performance and transaction throughput. The present invention provides a blockchain quota consumption control method and system that supports parallel transaction processing. Through a pre-withholding mechanism based on the quota consumption upper limit and a unified deduction method for transactions with the same initiator account according to actual consumption after execution, the dependency relationship of multiple transactions initiated by the same account is avoided, and the consistency and correctness processing of quota change transactions with unpredictable variable amounts such as transfer and recharge can be taken into account. The parallel processing of multiple transactions initiated by the same account is realized, and the deduction of balance changes of the same initiator account is merged into a final unified deduction, which reduces the state reading and writing caused by the account quota consumption deduction, accelerates the execution of blocks on the chain, and improves the transaction throughput.
[0034] Advantages of additional aspects of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0036] Figure 1 Flowchart of a blockchain quota consumption control method supporting parallel transaction processing provided in Example 1 of the present invention;
[0037] Figure 2 A flowchart of transaction fee withholding provided in Example 1 of the present invention;
[0038] Figure 3 A flowchart of parallel transaction processing provided in Example 1 of the present invention;
[0039] Figure 4A flow chart of breakpoint transaction processing provided in Example 1 of the present invention;
[0040] Figure 5 The transactions and their transaction dependency graph included in an example block provided in Example 1 of the present invention;
[0041] Figure 6 is based on Figure 5 Schematic diagram of parallel processing of transactions within a block based on the transaction dependency graph. DETAILED DESCRIPTION
[0042] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0043] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present invention belongs.
[0044] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that the terms "include" and "comprise" and any variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0045] In the absence of conflict, the embodiments of the present invention and the features thereof may be combined with each other.
[0046] Example 1
[0047] This embodiment provides a blockchain quota consumption control method that supports parallel transaction processing. Figure 1 Shown, including:
[0048] Build a transaction dependency graph based on the account read and write sets of transactions in the block;
[0049] According to the transaction dependency graph, the withholding fee processing is performed on the transactions subject to withholding fees in accordance with the transaction order, the withholding fee value is determined, and the post-withholding fee balance of the account of the initiator of the transaction subject to withholding fee is updated; wherein the transaction subject to withholding fee is a non-breakpoint transaction, a transaction that is different from the initiator of the breakpoint transaction and does not depend on the breakpoint transaction; the breakpoint transaction includes a quota breakpoint transaction and an insufficient balance breakpoint transaction, and the insufficient balance breakpoint transaction is a transaction in which the post-withholding fee balance of the account is less than the withholding fee value;
[0050] Transactions that meet the set conditions are executed in parallel, and the pre-deducted fee value is used as the quota consumption limit for transaction execution. The actual quota consumption value after the transaction execution is accumulated to the actual total deduction of the initiator's account, so that a unified deduction is made from the initiator's account status balance after the transaction execution.
[0051] In this embodiment, first, the quota consumption control mode is turned on, a block execution request is received, and block execution-related configurations are prepared; then, a transaction dependency graph is constructed based on the account read-write sets of transactions in the block.
[0052] The read-write set includes a read set and a write set. The read set is a set of world state accounts read by a transaction, and the write set is a set of world state accounts written by a transaction, but does not include accounts written only due to quota consumption as the initiator.
[0053] The transaction dependency graph is a directed acyclic graph, in which a vertex represents a transaction and a directed edge represents that a tail transaction depends on a head transaction.
[0054] When constructing a transaction dependency graph based on read-write sets, if at least one element in the write set of two transactions exists in the read-write set of another transaction, then there is only one connecting path between the vertices formed by the two transactions. The connection direction is from the transaction with the larger sequence number to the transaction with the smaller sequence number. The transaction with the larger sequence number must be executed after the transaction with the smaller sequence number is completed.
[0055] In this embodiment, according to the transaction dependency graph, the withholding fee processing of the transaction execution quota consumption is performed on the transactions to be withheld in sequence according to the transaction order, the withholding fee value is determined and the withholding fee value of the transaction is marked at the corresponding point in the transaction dependency graph, and the balance after withholding fee in the account of the initiator of the transaction to be withheld is recorded and updated; wherein, the transaction to be withheld is a non-breakpoint transaction, a transaction that is different from the initiator of the breakpoint transaction and does not depend on the breakpoint transaction; the breakpoint transaction includes a quota breakpoint transaction and an insufficient balance breakpoint transaction, and the insufficient balance breakpoint transaction is a transaction in which the balance of the account after withholding fee is less than the withholding fee value.
[0056] like Figure 2 As shown, the withholding fee processing starts from the transaction with the smallest sequence number and which has not been processed for withholding fee, and the following steps are performed on the transactions that have not been processed for withholding fee:
[0057] Step 1041: From the pending fee deduction transactions, select a transaction that has a different initiator than the pending breakpoint transaction and does not depend on the pending breakpoint transaction according to the transaction order from smallest to largest, and proceed to step 1042;
[0058] If the transaction does not exist, that is, the initiator of the transaction is the same as the initiator of an existing breakpoint transaction to be executed, or is dependent on a breakpoint transaction to be executed, the withholding fee processing for this transaction will be terminated.
[0059] Step 1042: If the current transaction is the first transaction of the initiator's account in this withholding fee process, then the account's post-withholding fee balance cache is set as the account status balance;
[0060] Determine whether the current account status balance of the transaction initiator is 0; if so, proceed to step 1043; otherwise, proceed to step 1044.
[0061] The account status balance is the balance recorded on the account status object, which is the final actual effective value of the account status.
[0062] The post-withholding balance cache of the account is a cache value obtained by deducting the withholding fee value of all transactions of the account that have not actually been deducted based on the account status balance.
[0063] Step 1043: Mark the on-chain status of the current transaction as a failed transaction, remove the current transaction from the transaction dependency graph, end the transaction withholding fee processing, and proceed to step 1041.
[0064] Step 1044: Determine whether the current transaction is a transaction involving quota change, such as transfer or recharge;
[0065] If the current transaction is a quota transaction, proceed to step 1045 ; otherwise, proceed to step 1046 .
[0066] Step 1045: Mark the current transaction as a quota breakpoint transaction, end the transaction withholding fee processing, and proceed to step 1041.
[0067] Step 1046: Calculate the withholding fee value;
[0068] If the current transaction is the first transaction of the initiator's account in this withholding fee process, the withholding fee value is the minimum of the account status balance, the system quota consumption limit, and the quota consumption limit set by the user;
[0069] If not, the withheld fee value is the minimum of the system quota consumption limit and the quota consumption limit set by the user.
[0070] Step 1047: Determine whether the account withholding fee balance cache of the current transaction initiator's account is greater than or equal to the withholding fee value of the current transaction; if so, proceed to step 1048, otherwise proceed to step 1049.
[0071] Step 1048: Mark the withholding fee value, subtract the withholding fee value of this transaction from the account withholding fee balance cache of the current transaction initiator account, update the account withholding fee balance cache, and enter step 1041.
[0072] Step 1049: Mark the current transaction as an insufficient balance breakpoint transaction, end the transaction fee withholding, and proceed to step 1041.
[0073] In this embodiment, based on the transaction dependency graph, transactions that meet the set conditions are selected and processed in parallel. The pre-deducted fee value is used as the quota consumption limit for transaction execution. After waiting for the transaction processing results in a loop, new pending transactions are selected for processing until all transactions are processed.
[0074] The actual quota consumption accumulated value after each transaction is executed is cached, and the actual quota consumption value after each transaction is executed is accumulated to the actual total deduction cache of the initiator's account. After the transaction is executed, a unified deduction is made from the initiator's account status balance.
[0075] Specifically, the process of processing transactions based on the transaction dependency graph includes:
[0076] Select transactions that meet the conditions for parallel processing;
[0077] After waiting for non-breakpoint transactions to complete, update the initiator's account's actual total deduction cache, remove the point corresponding to the current transaction in the transaction dependency graph, and select transactions that meet the conditions for parallel processing again;
[0078] After all transactions are completed, the actual quota consumption value recorded in the actual total deduction cache is deducted from the account status balance.
[0079] Specifically, such as Figure 3 As shown in the figure, the process of parallel transaction processing includes:
[0080] Step 1051: All transactions with an out-degree of 0 and with pre-withheld fees are directly executed by the smart contract. During execution, the pre-withheld fee value is used as the upper limit of the transaction execution quota and is passed to the smart contract execution engine. The smart contract engine executes the transaction. When the upper limit is exceeded, the execution is automatically terminated and the relevant changes are rolled back, and a failure result is returned.
[0081] Step 1052: Process all breakpoint transactions whose out-degree is 0 and whose sequence number is smaller than that of the current transaction and whose transactions with the same initiator account have been executed. After the processing is completed, proceed to step 1051.
[0082] Step 1053: Wait for a non-breakpoint transaction to be completed.
[0083] Step 1054: Remove the executed transaction from the transaction dependency graph.
[0084] Step 1055: Determine whether the number of vertices in the transaction dependency graph is 0; if it is 0, proceed to step 1056; otherwise, proceed to step 1051.
[0085] Step 1056: deduct the value in the actual total deduction cache from the account status balance.
[0086] In this embodiment, the breakpoint transaction processing includes insufficient balance breakpoint transaction processing and quota breakpoint transaction processing; the breakpoint transaction processing process is as follows: Figure 4 As shown, specifically including:
[0087] Step 10521: Determine whether the breakpoint transaction is a quota transaction;
[0088] If yes, then for the quota breakpoint transaction, execute steps 10522 to 10526;
[0089] Otherwise, it is an insufficient balance breakpoint transaction, and steps 10527-10528 are executed.
[0090] Step 10522: For the quota breakpoint transaction, update the account status balance of the write account involved in the breakpoint transaction and the initiator account of the breakpoint transaction.
[0091] Step 10523: Deduct the fee from the account status balance. The updated account status balance is the amount minus the withholding fee value. The withholding fee value is the minimum value of the account status balance, the system quota consumption limit, and the user quota consumption limit.
[0092] Step 10524: Call the smart contract to execute the transaction.
[0093] Step 10525: After the execution is completed, the withholding fee value that is overdeducted from the account status balance is rolled back based on the actual quota consumption; the balance of the account after withholding the fee is updated to the account status balance, and the point is removed from the transaction dependency graph.
[0094] Step 10526: After this transaction, the fee withholding process will be started again for subsequent transactions that have not been withheld. After the fee withholding process is completed, the current transaction ends and the parallel processing of transactions that meet the conditions will be started again.
[0095] Step 10527: For the breakpoint transaction with insufficient balance, the account status balance of the initiator of the breakpoint transaction is updated, and the actual quota consumption that has occurred is deducted from the account status balance.
[0096] Step 10528: Then continue with the withholding fee processing starting from this transaction. After the withholding fee is completed, start selecting transactions that meet the conditions again for parallel processing.
[0097] Among them, updating the account status balance is: deducting the actual quota consumption from the account status balance, that is, updating the account status balance minus the actual total deduction cache value, resetting the actual total deduction cache value to 0, and resetting the account withholding balance cache to the account status balance.
[0098] The actual total deduction for an account is the accumulated value of the actual quota consumption for all transactions that have been completed under the account but have not yet been deducted from the quota consumption in the account status balance.
[0099] like Figure 5 The figure shows the transactions and their transaction dependency graph contained in an example block: the block contains 17 transactions, the initiator of transactions 0, 2, 4, 6, 8, 9, and 11 is From1, the initiator of transactions 1, 3, 5, 7, 10, and 12 is From2, and the initiator of transactions 13, 14, 15, and 16 is From3. Among them, transaction 7 is a transaction in which From2 transfers 430 to From1.
[0100] like Figure 6 The shown is based on Figure 5 A diagram of parallel processing of transactions within a block based on a transaction dependency graph. To illustrate the implementation steps, in this example, the quota transfer transaction actually consumes 40 quotas, while all other transactions actually consume 10 quotas. The quota consumption cap for all transactions is 40.
[0101] Specifically:
[0102] 701: First withholding fee: When it reaches transaction 4, the balance of the From1 account after the withholding fee is 20, and the withholding fee value is 40, which is insufficient balance. It is marked as an insufficient balance breakpoint transaction. Transactions 6, 8, 9, and 11 have the same initiator as 4 and skip the withholding fee. Transactions 7, 10, and 12 depend on transaction 4 and skip the withholding fee. The withholding fee is completed for all other transactions.
[0103] 702: Execution after the first withholding fee: Transactions 0, 1, 2, 3, 5, 13, 14, 15, and 16 are all enabled for execution. Wait until transaction 2 is completed and breakpoint 4 meets the conditions to start breakpoint transaction processing. First, update the From1 account status balance to 80, and then start withholding fees from transaction 4.
[0104] 703: Second withholding fee: Go to transaction 7 as a quota transaction, mark transaction 7 as a quota breakpoint transaction, and skip the withholding fees of subsequent dependent transactions 8, 9, 10, 11, and 12.
[0105] 704: After the second fee withholding, select transaction execution: Transactions 4 and 6 begin executing in parallel. After transaction 4 completes, transaction 7 meets the breakpoint transaction processing conditions, and breakpoint processing for transaction 7 begins: first, update the From1 and From2 account status balances. After deducting the actual quota consumption, the balance of From1 is 60, and that of From2 is 470. Deduct the quota value 40 required for transaction 7 from the account status balance. Execute transaction 7, and the actual consumed quota is 40. The over-deducted quota is returned to 0. Then, the third fee withholding begins.
[0106] 705: The third withholding fee: Transactions 8, 9, and 11 have sufficient balances to complete the withholding fee. Transactions 10 and 12 are directly marked as failed transactions and removed from the dependency graph because the balance of the from2 account status is 0.
[0107] 706: After the third withholding fee, select transaction execution: Transactions 8, 9, and 11 meet the conditions and start execution. After all transactions are executed, the number of vertices in the dependency graph is 0, and the transaction execution ends.
[0108] It should be noted that all data is obtained in compliance with laws and regulations and with user consent, and the data is used legally.
[0109] Example 2
[0110] This embodiment provides a blockchain quota consumption control system that supports parallel transaction processing, including:
[0111] A dependency graph building module is configured to build a transaction dependency graph based on the account read-write sets of transactions in the block;
[0112] The withholding fee module is configured to perform withholding fee processing for transaction execution quota consumption on transactions subject to withholding fees in sequence according to a transaction dependency graph, determine a withholding fee value, and update the post-withholding fee balance of the account of the initiator of the transaction subject to withholding fees; wherein the transaction subject to withholding fees is a non-breakpoint transaction, a transaction that is different from the initiator of the breakpoint transaction and is not dependent on the breakpoint transaction; breakpoint transactions include quota breakpoint transactions and insufficient balance breakpoint transactions, and insufficient balance breakpoint transactions are transactions in which the post-withholding fee balance of the account is less than the withholding fee value;
[0113] The transaction parallel execution module is configured to execute transactions that meet the set conditions in parallel, use the pre-deducted fee value as the quota consumption upper limit for transaction execution, and add the actual quota consumption value after the transaction execution to the actual total deduction of the initiator's account, so as to perform a unified deduction process from the initiator's account status balance after the transaction execution.
[0114] It should be noted that the above modules correspond to the steps described in Example 1, and the examples and application scenarios implemented by the above modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above Example 1. It should be noted that the above modules, as part of the system, can be executed in a computer system such as a set of computer-executable instructions.
[0115] In further embodiments, there is also provided:
[0116] An electronic device includes a memory and a processor, and computer instructions stored in the memory and executed by the processor, wherein when the computer instructions are executed by the processor, the method described in Example 1 is performed. For the sake of brevity, no further details are given here.
[0117] It should be understood that in this embodiment, the processor may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), off-the-shelf field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0118] The memory may include a read-only memory and a random access memory, and provides instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store information about the device type.
[0119] A computer-readable storage medium is used to store computer instructions, and when the computer instructions are executed by a processor, the method described in Example 1 is performed.
[0120] The method in Example 1 can be directly implemented as a hardware processor, or can be implemented using a combination of hardware and software modules in the processor. The software module can be located in a storage medium mature in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, it will not be described in detail here.
[0121] A computer program product includes a computer program, which implements the method described in embodiment 1 when executed by a processor.
[0122] The present invention also provides at least one computer program product tangibly stored on a non-transitory computer-readable storage medium. The computer program product includes computer-executable instructions, such as instructions contained in program modules, which are executed in a device on a real or virtual processor of a target to perform the process / method described above. Generally, program modules include routines, programs, libraries, objects, classes, components, data structures, etc. that perform specific tasks or implement specific abstract data types. In various embodiments, the functionality of program modules can be combined or divided between program modules as needed. The machine-executable instructions for the program modules can be executed in local or distributed devices. In distributed devices, program modules can be located in local and remote storage media.
[0123] The computer program code for implementing the method of the present invention can be written in one or more programming languages. These computer program codes can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the computer or other programmable data processing device, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on a computer, partially on a computer, as an independent software package, partially on a computer and partially on a remote computer, or entirely on a remote computer or server.
[0124] In the context of the present invention, computer program code or related data can be carried by any appropriate carrier to enable a device, apparatus, or processor to perform the various processes and operations described above. Examples of carriers include signals, computer-readable media, and the like. Examples of signals include electrical, optical, radio, acoustic, or other forms of propagated signals, such as carrier waves, infrared signals, and the like.
[0125] Those skilled in the art will appreciate that the units and algorithm steps of the various examples described in conjunction with this embodiment can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0126] Although the above describes the specific embodiments of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without any creative work are still within the scope of protection of the present invention.
Claims
1. A blockchain quota consumption control method supporting parallel transaction processing, characterized in that: include: Build a transaction dependency graph based on the account read and write sets of transactions in the block; According to the transaction dependency graph, the withholding fee processing is performed on the transactions subject to withholding fees in accordance with the transaction order, the withholding fee value is determined, and the post-withholding fee balance of the account of the initiator of the transaction subject to withholding fees is updated; wherein the transaction subject to withholding fees is a non-breakpoint transaction, a transaction that is different from the initiator of the breakpoint transaction and does not depend on the breakpoint transaction; the breakpoint transactions include quota breakpoint transactions and insufficient balance breakpoint transactions, and the insufficient balance breakpoint transaction is a transaction in which the post-withholding fee balance of the account is less than the withholding fee value; Transactions that meet the set conditions are executed in parallel, and the pre-deducted fee value is used as the quota consumption limit for transaction execution. The actual quota consumption value after the transaction execution is accumulated to the actual total deduction of the initiator's account, so that a unified deduction is made from the initiator's account status balance after the transaction execution.
2. A blockchain quota consumption control method supporting parallel transaction processing according to claim 1, characterized in that: During the withholding fee processing, if the current transaction is the first transaction of the initiator's account in this withholding fee processing, the account's balance after withholding fees will be set as the account status balance; If the account status balance of the current transaction initiator is 0, the on-chain status of the current transaction is marked as a failed transaction, and the current transaction is removed from the transaction dependency graph, ending the withholding fee processing for this transaction.
3. A blockchain quota consumption control method supporting parallel transaction processing according to claim 1, characterized in that: The process of determining the withholding fee value includes: if the current transaction is the first transaction of its initiator account in this withholding fee processing, the withholding fee value is the minimum value of the account status balance, the system quota consumption limit, and the user quota consumption limit; if not, the withholding fee value is the minimum value of the system quota consumption limit and the user quota consumption limit; The balance after updating the account withholding fee is the balance of the account withholding fee of the current transaction initiator's account minus the withholding fee value of the current transaction.
4. A blockchain quota consumption control method supporting parallel transaction processing according to claim 1, characterized in that: The setting conditions are: All transactions with an out-degree of 0 and withheld fees will be directly executed by the smart contract, and the withheld fee value will be used as the upper limit of the transaction execution quota during execution; All breakpoint transactions with an out-degree of 0 and a sequence number smaller than the current transaction and the same initiator account transactions that have all been executed will be processed as breakpoint transactions.
5. A blockchain quota consumption control method supporting parallel transaction processing according to claim 4, characterized in that: The process of processing quota breakpoint transactions includes: Update the account status balance of the write account involved in the breakpoint transaction and the account initiator of the breakpoint transaction; Fees are deducted from the account status balance. The updated account status balance is minus the withholding fee value. The withholding fee value is the minimum value of the account status balance, the system quota consumption limit, and the user quota consumption limit. Call the smart contract to execute the current transaction. After the execution is completed, the overcharged withholding fee value of the account status balance will be rolled back based on the actual quota consumption; the balance of the account after withholding the fee is updated to the account status balance, and the current transaction is removed from the transaction dependency graph; After the current transaction, the fees for subsequent transactions that have not been withheld will be withheld again. After the withholding is completed, the current transaction ends and the transactions that meet the set conditions are selected again for parallel processing.
6. A blockchain quota consumption control method supporting parallel transaction processing according to claim 4, characterized in that: The process of handling breakpoint transactions for insufficient balance breakpoint transactions includes: Update the account status balance of the initiator of the breakpoint transaction and deduct the actual quota consumption from the account status balance; then continue with the withholding fee processing from the current transaction. After the withholding fee is completed, start selecting transactions that meet the set conditions for parallel processing again.
7. A blockchain quota consumption control system supporting parallel transaction processing, characterized in that: include: A dependency graph building module is configured to build a transaction dependency graph based on the account read-write sets of transactions in the block; The withholding fee module is configured to perform withholding fee processing for transaction execution quota consumption on transactions subject to withholding fees in accordance with the transaction dependency graph and in a transaction order, determine the withholding fee value, and update the post-withholding fee balance of the account of the initiator of the transaction subject to withholding fees; wherein the transaction subject to withholding fees is a non-breakpoint transaction, a transaction that is different from the initiator of the breakpoint transaction and is not dependent on the breakpoint transaction; breakpoint transactions include quota breakpoint transactions and insufficient balance breakpoint transactions, and insufficient balance breakpoint transactions are transactions in which the post-withholding fee balance of the account is less than the withholding fee value; The transaction parallel execution module is configured to execute transactions that meet the set conditions in parallel, use the pre-deducted fee value as the quota consumption upper limit for transaction execution, and add the actual quota consumption value after the transaction execution to the actual total deduction of the initiator's account, so as to perform a unified deduction process from the initiator's account status balance after the transaction execution.
8. An electronic device, characterized in that: The method comprises a memory and a processor, and computer instructions stored in the memory and executed on the processor, wherein when the computer instructions are executed by the processor, the method according to any one of claims 1 to 6 is completed.
9. A computer-readable storage medium, characterized in that Used to store computer instructions, which, when executed by a processor, complete the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that The invention comprises a computer program, which is used to implement the method according to any one of claims 1 to 6 when the computer program is executed by a processor.