CN-115271715-B - Method for improving block chain intelligent contract transaction execution speed and transaction execution device
Abstract
A method for improving execution speed of intelligent block chain contract transaction includes identifying all global counters of global variable type which is easy to cause read-write conflict according to application type of read-write conflict in original application program, dividing each identified global counter into multiple sub-counters, distributing intelligent block chain contract transaction to one of corresponding sub-counters to process according to preset random algorithm when intelligent block chain contract transaction arrives, obtaining count value of corresponding sub-counter, and adding count value of multiple sub-counters when real-time value of global counter is needed to be obtained. Therefore, the invention effectively reduces the probability of the read-write conflict of the application program in the parallel execution process of the intelligent contract, thereby greatly improving the speed of the parallel execution transaction of the intelligent contract.
Inventors
- MING ZHE
- WU MING
- LONG FAN
- YANG GUANG
- Li chenxing
- LI PEILUN
Assignees
- 上海树图区块链研究院
Dates
- Publication Date
- 20260508
- Application Date
- 20220614
Claims (8)
- 1. A method for improving the execution speed of a blockchain intelligent contract transaction is used for parallelizing the intelligent contract transaction in a multi-core and multi-thread mode, and is characterized by being applied to a scene that the original read-write conflict problem in a blockchain application program is caused by distributing the same address in a short time when the intelligent contract is parallelly executed in a blockchain system, so that the transaction execution efficiency is improved, and the method comprises the following steps: step S1, according to the application type of the original read-write conflict in the application program, identifying all global counter of global variable types which are easy to cause the read-write conflict; Dividing each identified global counter which is easy to cause read-write conflict into N Sub-counters Sub-1 counter, sub-2 counter, sub-N counter, wherein the number of Sub-counters Sub-1 counter, sub-2 counter is determined according to the application type, traffic and/or the number of microprocessors of a sender system of the conflict, and N is more than or equal to 2; Step S3, when the blockchain intelligent contract transaction arrives, distributing the blockchain intelligent contract transaction to corresponding Sub-counters Sub-1 counter, sub-2 counter according to a preset random algorithm, processing the blockchain intelligent contract transaction on one of the Sub-counters, and obtaining the count value of the corresponding Sub-counter; and S4, when the real-time value of the global counter needs to be acquired, adding the count values of the N Sub-counters Sub-1 counter and Sub-2 counter.
- 2. The method according to claim 1, wherein in the step S2, if a single transmission address is involved in the processing, each global counter changes the single transmission address to a plurality of transmission addresses, and each transmission address corresponds to one of Sub-counters Sub-1 counter, sub-2 counter.
- 3. The method according to claim 2, wherein the step S3 of assigning the blockchain smart contract transaction to the corresponding sub-counter is based on a hash value of the blockchain smart contract transaction transmission address to assign the transaction to the corresponding sub-counter.
- 4. The method of claim 1, wherein the application types of read-write conflicts are included in the application types of ERC-20 token's dispatch/air drop, open finance DeFi project, and Mint of non-homogenous token NFT.
- 5. The method of claim 1, wherein the application type of the read-write conflict is accomplished by analysis of the smart contract code, detection of conflict fields by tools, and conflict identification of transactional memory.
- 6. A transaction execution device of a blockchain intelligent contract adopts a multi-core multithreading mode to parallelize and process the intelligent contract transaction, which is characterized in that the transaction execution device is applied to a scene that when the intelligent contract is executed in parallel in a blockchain system, the problem of read-write conflict in a blockchain application program is caused by distributing the same address in a short time, and thus the transaction execution efficiency is improved, and the transaction execution device comprises: The identification module is used for identifying all global counter global counters of global variable types which are easy to cause read-write conflict according to the application type of the read-write conflict in the application program; A dividing module for dividing each identified global counter which is easy to cause read-write conflict into N Sub-counters Sub-1 counter, sub-2 counter, sub-N counter, wherein the number of Sub-counters Sub-1 counter, sub-2 counter is determined according to the application type, traffic and/or the number of microprocessors of a sender system of the conflict, and N is more than or equal to 2; The transaction module is used for distributing the blockchain intelligent contract transaction to one of corresponding Sub-counters Sub-1 counter, sub-2 counter according to a preset random algorithm when the blockchain intelligent contract transaction arrives, processing the blockchain intelligent contract transaction, and obtaining the count value of the corresponding Sub-counter; and the result generation module is used for adding the count values of the Sub-counters Sub-1 counter and Sub-2 counter when the real-time value of the global counter needs to be acquired.
- 7. A readable storage medium storing executable instructions for performing a method of increasing the execution speed of a blockchain smart contract transaction as in any of claims 1-5.
- 8. A data processing terminal for receiving, co-identifying and storing blocks in a P2P network as co-identified nodes of the P2P network, the data processing terminal comprising: A readable storage medium; a processor that retrieves and executes executable instructions in the readable storage medium to perform a method of increasing the execution speed of a blockchain smart contract transaction as recited in any of claims 1-5.
Description
Method for improving block chain intelligent contract transaction execution speed and transaction execution device Technical Field The invention relates to the technical field of big data processing and information, in particular to a method for improving the execution speed of a blockchain intelligent contract transaction and a transaction execution device. Background The blockchain system has very limited transaction throughput due to the problem of the consensus mechanism, such as 7 transactions per second at maximum of bitcoin and 30-40 transactions per second can be supported at maximum of Ethernet ETH1.0, and with the development of the consensus mechanism in recent years, such as the fragmentation technology of Ethernet ETH2.0, the transaction execution of part of the chain can reach thousands of transactions per second. It is clear to those skilled in the art that the bottleneck in transaction throughput is focused on disk I/O, network bandwidth, and transaction execution efficiency, where the improvement in transaction execution efficiency is most challenging. Typically, the execution of transactions in ethernet is sequential, and the execution speed of the transactions is limited by the execution of a single core. In how to further improve the transaction execution efficiency, some documents have proposed improving the speed of transaction execution by parallelizing the execution of intelligent contracts. For example, the transaction execution efficiency is improved by parallelizing the transaction processing method in a multi-core and multi-thread mode. However, the above method for improving the transaction execution efficiency is far from ideal, because in the parallel processing process, the problem of read-write collision in some blockchain applications, such as the sender (sender) address of the smart contract for distributing tokens, is inevitably encountered, and is called by multiple threads at the same time, resulting in read-write collision. The above conflicts are mostly concentrated in a single counter or array in the application, such as in the code in a token distributed smart contract, with the following functions: When this function is called, the sender's balance (msg. Sender) is decremented and the recipient's balance (balance to) is incremented by a corresponding amount. The balance of the sender is a special field stored in the state tree, the operations of the field involve loading (SLOAD), adding (ADD) by a counter, updating (SSTORE) and the like, when two transactions trigger the function at the same time, the state conflict of the balance field of the sender can be caused, the execution speed of the transaction is influenced, the execution time of the transaction is prolonged, and when the conflict is more, the transaction throughput is seriously influenced. According to experimental statistics, the application types of conflict can be mainly divided into three main categories: ① . The first is on the distribution/air drop of ERC20 tokens, and the conflict ratio is up to 60%; ② . The second is the open finance DIFI project (Decentralized Finance), especially the DIFI project just online, such application accounting for 29%; ③ . The third is MINT, which is a non-homogenous token NFT, such is 10%. In the application scenario, the number of read-write conflicts is greatly increased because the read-write conflicts are distributed through the same address in a short time, and the transaction throughput of the whole network is affected. That is, the above problem of transaction throughput makes the manner of executing the transaction in parallel not very effectively increase the transaction speed, and there is a great gap from the theoretical speed, so that the execution efficiency is not ideal, and the user experience is seriously affected. Therefore, how to further increase the execution speed of the blockchain smart contract transaction is an urgent problem to be solved in the industry. Disclosure of Invention The invention aims to provide a method and a device for improving the transaction execution speed of a blockchain intelligent contract based on a partition counter, which can improve the transaction execution efficiency by solving some problems in the intelligent contract, which can cause system call conflict. In order to achieve the above purpose, the technical scheme of the invention is as follows: A method for increasing execution speed of a blockchain smart contract transaction based on a partition counter for parallelizing processing of the smart contract transaction by multi-core multithreading, comprising the steps of: Step S1, according to the application type of the read-write conflict in the application program, identifying all global counters (global counters) of the global variable type which is easy to cause the read-write conflict; Dividing each identified global counter into N Sub-counters Sub-1 counter, sub-2 counter, sub-2 counter, wherein the number o