CN110532038B - Parallel execution method based on Java intelligent contract - Google Patents
Parallel execution method based on Java intelligent contract Download PDFInfo
- Publication number
- CN110532038B CN110532038B CN201910764308.6A CN201910764308A CN110532038B CN 110532038 B CN110532038 B CN 110532038B CN 201910764308 A CN201910764308 A CN 201910764308A CN 110532038 B CN110532038 B CN 110532038B
- Authority
- CN
- China
- Prior art keywords
- contract
- transaction
- contracts
- execution
- transactions
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4482—Procedural
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
Abstract
The invention discloses a parallel execution method based on Java intelligent contracts, transactions received by a block chain platform are executed after being packaged, finally the transactions generate a block after the execution is finished, all the contracts related to the transactions are taken out before the execution, a contract calling link of each transaction is obtained by acquiring a value of a cross-contract calling field in the contract and analyzing, then the calling dependency analysis between the transactions is carried out through the contract calling link, finally a calling link list of the transactions is obtained, and each transaction calling link is executed in a multi-thread mode by starting a plurality of virtual machine instances, so that each transaction link is executed in parallel. The invention can realize the parallel execution of the Java intelligent contract, ensures that the problem of data concurrency cannot be generated in the process of executing the Java contract in parallel, and improves the execution efficiency of the block chain.
Description
Technical Field
The invention relates to the field of design of a decentralized block chain intelligent contract execution process, in particular to a parallel execution method based on Java intelligent contracts.
Background
The block chain technology is a novel decentralized protocol, digital currency transactions or other data can be safely stored, and information cannot be forged or falsified; the intelligent contract is a piece of code which can be deployed and executed in a blockchain network environment, the deployment and execution of the code can be presented in a transaction form in the blockchain network, and the deployment and execution results can be commonly known by the whole network along with the transaction; the results thus performed must guarantee consistency at each node, since the results need to be handed to consensus layer consensus.
The traditional alliance block chain intelligent contract execution engine comprises evm and jvm, but no matter the evm or jvm execution, all executions of each block of each packed transaction are executed in full series, when more transactions exist in one block, the next transaction must completely wait for the execution of the previous transaction to be completed before the execution of the previous transaction can be started, and thus the multi-core characteristic of the current general computer is not fully utilized, and the execution performance of the block chain intelligent contract is limited to a certain extent. Also, if all transactions packed into a block are simply parallel, concurrent operation problems for the same contract state may be involved because of the presence of cross contract calls.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides a parallel execution method based on a Java intelligent contract, which can execute transactions packed into a block in parallel and solve the problem that the modification of all state quantities in the process of executing the transactions in parallel does not cause concurrency.
The purpose of the invention is realized by the following technical scheme:
a parallel execution method based on Java intelligent contracts is characterized in that the intelligent contracts contain annotations called across contracts, and the method specifically comprises the following steps:
the method comprises the following steps: when receiving and executing the packaged transaction, the block chain node firstly takes out a corresponding contract source code from the account book database according to a contract address specified in the transaction and loads the contract source code;
step two: for all loaded contracts, acquiring whether the annotations called by the cross contracts exist in the contracts through reflection, if so, taking out the addresses called by the cross contracts, taking out the corresponding contract source codes from the account book database, loading, and recursively analyzing the addresses called by the cross contracts in the contracts;
finally, for each transaction, obtaining a cross contract calling link table starting from the contract address called by the current transaction;
step three: and analyzing the calling dependency relationship of all the transactions according to the obtained calling chains of the contracts corresponding to all the transactions, traversing the contract calling chain corresponding to the contract obtained in the step two if the contract of the transaction is a calling contract, placing the two transactions in one transaction calling chain if the contract calling chain comprises the contracts related to other transactions, and otherwise, independently using the transaction as one transaction calling chain. If the contract for a transaction is a deployment contract, the pen transaction is directly treated as a transaction call chain alone. After the analysis of the dependency relationship of all the transactions is completed, a plurality of transaction call chains which can not be influenced by each other in execution are finally obtained.
Step four: and C, putting the transaction call chains which are obtained in the step three and can not influence each other in execution into a plurality of virtual machine instances which are started in advance for parallel execution, executing one transaction link by each virtual machine, executing the internal serial execution in a single virtual machine, collecting results after all the virtual machine execution links are finished, and then returning the results to an upper layer for other operations.
Further, in the second step, the cross-contract call link table includes all contract addresses involved in the current transaction execution, and the length of the contract addresses is at least 1.
Further, in the second step, the manner of loading the extracted contract source code needs to be consistent.
Furthermore, in the third step, when performing the analysis comparison, the comparison must be performed with all contract addresses involved in all other transactions, that is, after finding the first identical address in the traversal process, the traversal is not terminated directly, but all the contract addresses are found continuously.
Furthermore, in the fourth step, when collecting the result, it is necessary to wait for all the virtual machines to finish executing before returning the execution result, and if any virtual machine does not return within the specified time, it is directly determined that all the transactions executed by the virtual machine are illegal.
Compared with the prior art, the invention has the following beneficial effects:
the parallel execution method is applied to the block chain intelligent contract execution engine under the alliance chain background, can execute the transactions packed into one block in parallel, ensures that the modification of all state quantities cannot generate concurrency problems in the transaction parallel execution process, and is a breakthrough of a Java virtual machine execution engine under the block chain virtual machine execution engine.
Drawings
FIG. 1 is an overall flow diagram of the parallel execution method of the present invention;
FIG. 2 is a flow chart of transaction dependency analysis in the method of the present invention.
Detailed Description
The present invention will be described in detail below with reference to the accompanying drawings and preferred embodiments, and the objects and effects of the invention will become more apparent. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
A method for parallel execution based on Java intelligent contracts, as shown in fig. 1-2, where the intelligent contracts contain annotations called across contracts, the method specifically includes the following steps:
the method comprises the following steps: when receiving and executing the packaged transaction, the block chain node firstly takes out a corresponding contract source code from the account book database according to a contract address specified in the transaction and loads the contract source code;
step two: for all loaded contracts, acquiring whether the annotations called by the cross contracts exist in the contracts through reflection, if so, taking out the addresses called by the cross contracts, taking out the corresponding contract source codes from the account book database, loading, and recursively analyzing the addresses called by the cross contracts in the contracts; finally, for each transaction, obtaining a cross contract calling link table starting from the contract address called by the current transaction;
the related cross-contract call link table is generated by analyzing the contract recursive analysis of the cross-contract call, contains all contract addresses related to the current transaction execution, has the length of at least 1, and needs to acquire all the annotations of the cross-contract call in the contract when acquiring the annotations of the cross-contract call. For each acquired annotation, recursive analysis is required to finally obtain a call link table; as one of the embodiments, the manner of loading the extracted contract source code needs to be consistent;
step three: and analyzing the calling dependency relationship of all the transactions according to the obtained calling chains of the contracts corresponding to all the transactions, traversing the contract calling chain corresponding to the contract obtained in the step two if the contract of the transaction is one calling contract, placing the two transactions in one transaction calling chain if the contract calling chain comprises the contracts related to other transactions, and otherwise, independently using the transaction as one transaction calling chain. If the contract of the transaction is a deployment contract, directly taking the pen transaction as a transaction call chain; after the analysis of the dependency relationship of all the transactions is completed, a plurality of transaction call chains which can not be influenced by each other in execution are finally obtained.
When the contract calling chain corresponding to the called contract is traversed, the contract calling chain is compared with all contract addresses related to all other transactions, and as long as the same address exists, two transactions need to be placed in one transaction calling chain. That is, after finding the first identical address in the traversal process, the traversal is continued to find all addresses, instead of directly terminating.
Step four: and C, putting the transaction call chains which are obtained in the step three and can not influence each other in execution into a plurality of virtual machine instances which are started in advance for parallel execution, executing one transaction link by each virtual machine, executing the internal serial execution in a single virtual machine, collecting results after all the virtual machine execution links are finished, and then returning the results to an upper layer for other operations.
By starting a plurality of virtual machines, each virtual machine is executed in a multithread mode, and when the results are collected, the results can be returned only after all the virtual machines are executed. By executing the block transaction in parallel, the multi-core characteristics and the computing resources of a common computer are fully utilized, and further, by analyzing the dependency relation called among transactions, the problem of data concurrency cannot be generated in the process of executing the transactions concurrently. If any virtual machine does not return within the specified time, all transactions executed by the virtual machine are directly judged to be illegal.
It will be understood by those skilled in the art that the foregoing is only a preferred embodiment of the present invention, and is not intended to limit the invention, and although the invention has been described in detail with reference to the foregoing examples, it will be apparent to those skilled in the art that various changes in the form and details of the embodiments may be made and equivalents may be substituted for elements thereof. All modifications, equivalents and the like which come within the spirit and principle of the invention are intended to be included within the scope of the invention.
Claims (5)
1. A parallel execution method based on Java intelligent contracts is characterized in that the intelligent contracts contain annotations called across contracts, and the method specifically comprises the following steps:
the method comprises the following steps: when receiving and executing the packaged transaction, the block chain node firstly takes out a corresponding contract source code from the account book database according to a contract address specified in the transaction and loads the contract source code;
step two: for all loaded contracts, acquiring whether the annotations called by the cross contracts exist in the contracts through reflection, if so, taking out the addresses called by the cross contracts, taking out the corresponding contract source codes from the account book database, loading, and recursively analyzing the addresses called by the cross contracts in the contracts;
finally, for each transaction, obtaining a cross contract calling link table starting from the contract address called by the current transaction;
step three: analyzing the calling dependency relationship of all the transactions according to the obtained calling chains of the contracts corresponding to all the transactions, traversing the contract calling chain corresponding to the contract obtained in the second step if the contract of the transaction is a calling contract, placing the two transactions in one transaction calling chain if the contract calling chain comprises the contracts related to other transactions, and otherwise, independently using the transaction as one transaction calling chain; if the contract of the transaction is a deployment contract, directly and independently using the transaction as a transaction call chain; after the analysis of the dependency relationship of all the transactions is finished, a plurality of transaction call chains which can not be mutually influenced in execution are finally obtained;
step four: and C, putting the transaction call chains which are obtained in the step three and can not influence each other in execution into a plurality of virtual machine instances which are started in advance for parallel execution, executing one transaction link by each virtual machine, executing the internal serial execution in a single virtual machine, collecting results after all the virtual machine execution links are finished, and then returning the results to an upper layer for other operations.
2. A method for parallel execution of Java-based smart contracts according to claim 1, wherein in step two, the cross-contract call link table contains all contract addresses involved in the execution of the current transaction, and the length of the contract addresses is at least 1.
3. A method for parallel execution of Java-based smart contracts according to claim 1, wherein in step two, the manner of loading the fetched contract source code needs to be consistent.
4. The method for parallel execution based on Java intelligent contracts according to claim 1, wherein in the third step, when performing the analysis comparison, the contract address related to the current transaction must be compared with all the contract addresses related to all other transactions, that is, after finding the first same address in the traversal process, the process is not terminated directly, but the remaining contract addresses are traversed continuously to find the transactions corresponding to all the same contract addresses.
5. The method according to claim 1, wherein in the fourth step, the collection of the results must wait for all the virtual machines to finish execution before returning the execution results, and if any virtual machine does not return within a predetermined time, it is directly determined that all the transactions executed by the virtual machine are illegal.
Priority Applications (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910764308.6A CN110532038B (en) | 2019-08-19 | 2019-08-19 | Parallel execution method based on Java intelligent contract |
PCT/CN2020/109984 WO2021032115A1 (en) | 2019-08-19 | 2020-08-19 | Method, apparatus and device for parallel execution of smart contract, and medium |
JP2022510861A JP7394211B2 (en) | 2019-08-19 | 2020-08-19 | Methods, devices, equipment, and media for parallel execution of smart contracts |
US17/636,366 US20220292082A1 (en) | 2019-08-19 | 2020-08-19 | Method, apparatus and device for parallel execution of smart contract, and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910764308.6A CN110532038B (en) | 2019-08-19 | 2019-08-19 | Parallel execution method based on Java intelligent contract |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110532038A CN110532038A (en) | 2019-12-03 |
CN110532038B true CN110532038B (en) | 2021-07-30 |
Family
ID=68663906
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910764308.6A Active CN110532038B (en) | 2019-08-19 | 2019-08-19 | Parallel execution method based on Java intelligent contract |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110532038B (en) |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP7394211B2 (en) * | 2019-08-19 | 2023-12-07 | 杭州趣鏈科技有限公司 | Methods, devices, equipment, and media for parallel execution of smart contracts |
CN111221639A (en) * | 2020-01-09 | 2020-06-02 | 杭州趣链科技有限公司 | Block pipeline execution method of block chain platform |
CN112037061A (en) * | 2020-08-31 | 2020-12-04 | 深圳前海微众银行股份有限公司 | Processing method and device for transactions in block chain, electronic equipment and storage medium |
CN112394939B (en) * | 2020-10-30 | 2023-06-13 | 迅鳐成都科技有限公司 | User contract automatic deployment method, device and storage medium based on alliance chain |
CN112363804B (en) * | 2020-11-16 | 2024-01-26 | 北京差旅天下网络科技有限责任公司 | Blockchain JVM application method, device and storage medium |
CN112508574A (en) * | 2021-02-03 | 2021-03-16 | 北京全息智信科技有限公司 | Block chain parallel transaction execution method and device and electronic equipment |
CN112819634B (en) * | 2021-02-25 | 2023-06-02 | 成都质数斯达克科技有限公司 | Transaction processing method, device, electronic equipment and readable storage medium |
CN117422468B (en) * | 2023-12-18 | 2024-03-29 | 安徽中科晶格技术有限公司 | Method, equipment and storage medium for parallelizing contract link contracts based on DAG model |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10255108B2 (en) * | 2016-01-26 | 2019-04-09 | International Business Machines Corporation | Parallel execution of blockchain transactions |
US10282558B2 (en) * | 2016-09-02 | 2019-05-07 | The Toronto-Dominion Bank | System and method for maintaining a segregated database in a multiple distributed ledger system |
CN107562513B (en) * | 2017-07-18 | 2020-08-07 | 杭州趣链科技有限公司 | Intelligent contract life cycle management method based on JAVA |
CN109636592B (en) * | 2017-10-20 | 2023-02-28 | 北京航空航天大学 | High performance intelligent contract design |
CN108848119B (en) * | 2018-04-03 | 2020-04-28 | 阿里巴巴集团控股有限公司 | Cross-block-chain interaction method, device, system and electronic equipment |
CN109242636A (en) * | 2018-09-26 | 2019-01-18 | 盈盈(杭州)网络技术有限公司 | A kind of data transacting system and its implementation based on block chain |
CN109710680A (en) * | 2018-12-29 | 2019-05-03 | 杭州趣链科技有限公司 | A kind of block chain data processing engine and operating method |
CN110135985B (en) * | 2019-04-04 | 2021-07-27 | 杭州抖音科技有限公司 | Parallel execution method and system for transactions on block chain |
-
2019
- 2019-08-19 CN CN201910764308.6A patent/CN110532038B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN110532038A (en) | 2019-12-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110532038B (en) | Parallel execution method based on Java intelligent contract | |
US10394694B2 (en) | Unexplored branch search in hybrid fuzz testing of software binaries | |
CN109032631B (en) | Application program patch package obtaining method and device, computer equipment and storage medium | |
CN106648755B (en) | Method and device for dynamically loading dex in android art environment | |
JP7394211B2 (en) | Methods, devices, equipment, and media for parallel execution of smart contracts | |
EP3198452B1 (en) | On-demand loading of dynamic scripting language code for reduced memory usage | |
CN108197306A (en) | SQL statement processing method, device, computer equipment and storage medium | |
CN111813412B (en) | Method and system for constructing test data set for evaluating binary code comparison tool | |
US8615729B2 (en) | Extending existing model-to-model transformations | |
CN110990001A (en) | IVR (Interactive Voice response) process execution method and device | |
CN112451972A (en) | Game engine-based resource compression package construction method, device, system and medium | |
CN113568604B (en) | Method and device for updating wind control strategy and computer readable storage medium | |
CN108897678B (en) | Static code detection method, static code detection system and storage device | |
CN108897569A (en) | The method for cleaning and computer readable storage medium of iOS engineering discarded record | |
CN108897858A (en) | The appraisal procedure and device, electronic equipment of distributed type assemblies index fragment | |
CN108920179A (en) | Java reflects implementation method, device and system | |
CN111259619A (en) | Control method and device for configuration object, storage medium and verification platform | |
US9396239B2 (en) | Compiling method, storage medium and compiling apparatus | |
CN111026947A (en) | Crawler method and embedded crawler implementation method based on browser | |
CN116107578A (en) | Method, device, electronic equipment and storage medium for executing intelligent contract | |
CN112035432B (en) | Data replacement migration method and device and computer equipment | |
CN107066391A (en) | The processing method and system of test case | |
CN110737465B (en) | Method and related device for acquiring function call path | |
CN113792026A (en) | Deployment method and device of database script and computer readable storage medium | |
CN112052035A (en) | Version packaging method and device based on bank back-line system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |