CN111176625B - Method for efficiently compiling intelligent contract of solubility at browser end - Google Patents

Method for efficiently compiling intelligent contract of solubility at browser end Download PDF

Info

Publication number
CN111176625B
CN111176625B CN201911424066.2A CN201911424066A CN111176625B CN 111176625 B CN111176625 B CN 111176625B CN 201911424066 A CN201911424066 A CN 201911424066A CN 111176625 B CN111176625 B CN 111176625B
Authority
CN
China
Prior art keywords
compiler
solubility
file
browser
compiling
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
Application number
CN201911424066.2A
Other languages
Chinese (zh)
Other versions
CN111176625A (en
Inventor
邱炜伟
李伟
尹可挺
匡立中
万世医
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN201911424066.2A priority Critical patent/CN111176625B/en
Publication of CN111176625A publication Critical patent/CN111176625A/en
Application granted granted Critical
Publication of CN111176625B publication Critical patent/CN111176625B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a method for efficiently compiling a solubility intelligent contract at a browser end, which comprises the following steps: firstly, disposing all current solubility compilers on domestic servers or CDN nodes, and updating the latest compilers in time; then, a solubility source file is transmitted or input into a browser end, and a WASM format file of a solubility compiler is built in a browser script; directly compiling an intelligent contract file by a solubility compiler, and returning a compiling result in a Javascript main thread; or a script file is dynamically added to pull a required solubility compiler from a domestic server or CDN node, meanwhile, compiling operation is executed in a Javascript sub-thread, and a compiling result is returned to a main thread; when the intelligent contract file is compiled, the compiler to be pulled is not downloaded, or the pulling is failed, the server compiles the solubility source code through the back-end service, and then the compiling result is returned to the front-end browser. The method can avoid the blockage of the main thread and ensure the high-efficiency stable stability compiling environment.

Description

Method for efficiently compiling intelligent contract of solubility at browser end
Technical Field
The invention relates to a solubility intelligent contract compiling technology, in particular to a method for efficiently compiling a solubility intelligent contract at a browser end.
Background
In the existing blockchain application development mode, a developer often compiles a solubility intelligent contract 1) by installing a solubility intelligent contract compiler binary file in a local computer and compiles an intelligent contract in a command line mode to obtain a compiling result. 2) And (3) installing a solubility intelligent contract compiler binary file in a certain server, and acquiring a compiling result by calling a service. 3) And compiling the intelligent contract of the solubility by a browser-side online tool Remix and acquiring a result. However, there are more or less problems with these several approaches: 1) The development personnel are required to be familiar with related knowledge to learn the command line when the binary file is locally installed, so that the learning cost is increased, and the local computer resource is consumed; 2) Under the condition that the number of developers is increased, a compiling tool is installed on a remote server, when the compiling request quantity is increased, the load of a server side is easy to be overlarge, so that the compiling process is abnormal or exits, and a special operation and maintenance person is required to maintain the compiling service; 3) In compiling the solubility file in the remix, because the remix is deployed on a foreign server by dynamic loading, the network service is unstable, and the loading speed is slow, a long time is required to wait for downloading the compiler, and sometimes the compiler cannot be loaded well even for a long time.
Disclosure of Invention
Aiming at the defects in the technical scheme of the traditional intelligent contract for compiling the solubility, the invention provides a method for efficiently compiling the intelligent contract for the solubility at a browser end, which can provide convenient, stable and efficient online compiling service for the solubility.
The aim of the invention is realized by the following technical scheme: a method for efficiently compiling a solubility intelligent contract at a browser end, the method comprising the steps of:
(1) Deploying all current solubility compilers on domestic servers or CDN nodes, and simultaneously periodically comparing version lists with foreign Ethernet official compiler warehouses to update the latest compilers in time;
(2) A, inputting or inputting a solubility source file at a browser end, and embedding a WASM format file of a latest and stable solubility compiler into a browser script;
(3) If the compiler version declared by the solubility source code is consistent with the built-in compiler version or the compiler version is not declared, directly compiling the intelligent contract file by using the solubility compiler of the built-in WASM version, and returning a compiling result in the Javascript main thread; if the solubility source file declares the compiler version and the version is inconsistent with the solubility compiler of the built-in WASM file, specifying the src attribute as a path of a domestic server or CDN node in a mode of dynamically and newly adding a script tag to the Javascript code, thereby pulling the required solubility compiler, executing the compiling operation of the intelligent contract file in the Javascript sub-thread, and returning the compiling result to the main thread;
(4) If the compiler to be pulled is not downloaded or fails to pull when the intelligent contract file is compiled in the step (3), the source code is sent to node. Js back-end service in a client server request mode, the solubility source code is compiled through the back-end service, and then the compiling result is returned to the front-end browser;
(5) When the same intelligent contract file requests compiling again, returning to the step (3).
Further, in the step (1), before all the solubility compilers are deployed on the domestic server or CDN node, or the latest version of the compiler is pulled to the ethernet official solubility compiler warehouse, the c++ version of the compiler needs to be compiled into an asm.js version file supporting the front-end browser environment and the node.js environment through an emscript or other LLVM tool.
Further, in the step (2), before the latest and stable compiler is built in the browser, the c++ version compiler needs to be compiled into a WASM file in binary byte code format supported by the browser through an emscript or other LLVM tool, and then the WASM file is packaged into front-end script codes through a front-end packaging tool such as weback. Whether the built-in WASM file compiler is used or not is judged by the version number of the validity file declaration in the browser. The compiler is used in case the version matches correctly or the resolution file does not declare a version number.
Further, in the step (2), the WASM format file is a binary byte code file, and can be directly run in the browser without interpretation and compiling by a browser script engine.
Further, in the step (3), when the solution file in the browser end fails to match with the WASM compiler file, the browser dynamically creates a script, loads the compiler version corresponding to the current solution file in the domestic server or CDN node, creates a Web workbench sub-thread to compile the solution file, and returns the compiling result to the JavaScript main thread, thereby effectively preventing the JavaScript main thread from being blocked.
Further, in the step (4), all the solubility compilers in the domestic server or the CDN node are synchronized in the back-end node.js, and the latest solubility compilers in the server are regularly pulled by comparing the compiler version lists. Under the condition that the dynamic creation script in the browser is not downloaded or fails to be downloaded, a client server request is temporarily sent to node.js service, compiling operation is executed in the node.js service, a compiled result is returned to the browser end, and after the compiler of the browser end is loaded, the loaded compiler is used for executing the compiling operation.
The beneficial effects of the invention are as follows:
firstly, compiling by using an Emscripten or other specific LLVM tools, a compiler which is compiled into an asm.js format by using a native C++ version of the solubility compiler can support a Javascript language environment, so that the solubility compiler can operate in a browser end and a node.js, the compiler operates in the browser end, the computer resources and the learning cost of most developers are saved, and the solubility intelligent contract can be compiled through simple visual operation. Meanwhile, the file in the WASM format is compiled through the Emscripten or other specific LLVM tools, and the file is a binary byte code file running at the browser end, compared with the traditional Javascript script file, the browser omits the process of interpretation and compiling during execution, so that the efficiency of the whole compiler executing process can be greatly improved. Secondly, different compiler scripts are dynamically loaded in the browser, so that the server pressure can be shared, the number of built-in Web assembly version compilers can be reduced, the volume of initialized Javascript script files is kept small, the compiling process is carried out by creating a sub-thread through a Web Worker in a modern browser, and the blocking of a main thread can be avoided. Finally, the browser side is prevented from loading some abnormal situations in the compiler process through the support of the node. Js compiler service. All the steps ensure that the browser provides an efficient and stable solubility compiling environment.
Drawings
FIG. 1 is a block diagram of a method for efficiently compiling a resolution smart contract at the browser side in accordance with the present invention;
FIG. 2 is a flow chart of a method of efficiently compiling a resolution smart contract at the browser side of the present invention.
Detailed Description
The method for efficiently compiling the intelligent solubility contract at the browser side is further described below with reference to the accompanying drawings.
As shown in fig. 1, a method for efficiently compiling a solubility intelligent contract at a browser end is characterized in that the method comprises the following steps:
(1) Compiling a compiler of a C++ version into asm.js version files supporting a front-end browser environment and a node.js environment through an Emscripten or other LLVM tool, deploying all current solubility compilers on a domestic server or CDN node, and simultaneously regularly comparing a version list with a foreign Ethernet official compiler warehouse to update the latest compiler in time;
(2) A, inputting or inputting a solubility source file at a browser end, and embedding a WASM format file of a latest and stable solubility compiler into a browser script; the method comprises the following steps: a C++ version compiler is compiled into a WASM file in a binary byte code format supported by a browser through Emscrinten or other LLVM tools, and then the WASM file is packaged into a front-end script code through a Webpack front-end packaging tool and the like, so that the WASM file can be directly operated in the browser without interpretation and compiling through a browser script engine. Whether the built-in WASM file compiler is used or not is judged by the version number of the validity file declaration in the browser. The compiler is used in case the version matches correctly or the resolution file does not declare a version number.
(3) Directly compiling an intelligent contract file by using a solubility compiler with a built-in WASM version, and returning a compiling result in a Javascript main thread; or a script tag is dynamically and newly added to a Javascript code to designate the src attribute as a path of a domestic server or CDN node, so that a required solubility compiler is pulled, meanwhile, compiling operation of an intelligent contract file is executed in a Javascript sub-thread, and a compiling result is returned to a main thread; when the solubility file in the browser end fails to be matched with the WASM compiler file, the browser dynamically creates a script, loads a compiler version corresponding to the current solubility file in a domestic server or CDN node, creates a Web workbench sub-thread to compile the solubility file, returns a compiling result to the JavaScript main thread, and effectively prevents the JavaScript main thread from being blocked.
(4) If the compiler to be pulled is not downloaded or fails to pull when the intelligent contract file is compiled in the step (3), the source code is sent to node. Js back-end service in a client server request mode, the solubility source code is compiled through the back-end service, and then the compiling result is returned to the front-end browser; the method comprises the following steps: and synchronizing all the solubility compilers in the domestic server or CDN node in the back-end node. Js, and simultaneously regularly pulling the latest solubility compilers in the server by comparing the version lists of the compilers. Under the condition that the dynamic creation script in the browser is not downloaded or fails to be downloaded, a client server request is temporarily sent to node.js service, compiling operation is executed in the node.js service, a compiled result is returned to the browser end, and after the compiler of the browser end is loaded, the loaded compiler is used for executing the compiling operation.
(5) When the same intelligent contract file requests compiling again, returning to the step (3).
As shown in fig. 2, the solution intelligent contract compiling process is divided into the following steps:
(1) A solubility source file is transmitted or input to a browser end, a needed compiler version is marked, and if the version is not the version, a default built-in compiler is used;
(2) When the compiler version of the solubility source code declaration is consistent with the built-in compiler version or the compiler version is not declared, directly compiling by using the solubility compiler of the built-in WASM version, and returning a compiling result;
(3) If the solubility source file declares the compiler version and the version is not consistent with the solubility compiler of the built-in WASM version, dynamically creating a script file to pull the compiler of the corresponding version from the domestic server or CDN node, executing compiling operation on the Javascript sub-thread, and returning the compiling result to the main thread;
(4) And (3) when the dynamic pulling in the step (3) finds that the designated version compiler is not available, inquiring whether the version compiler exists in the official compiler warehouse, if so, updating the compiler in the server, and simultaneously giving an error prompt to the browser.
(5) If the pulling compiler in the step (3) is too slow or the pulling fails, the source code is sent to the node. Js back-end service in a client server request mode, the server compiles the solubility source code through the back-end service, and then the compiling result is returned to the front-end browser;
(6) If the step (5) finds that the node.js has no corresponding compiler version, inquiring whether the compiler version exists in the domestic server, if so, updating the compiler in the node.js service, and simultaneously returning an error message to the browser;
(7) When the same file is required to be compiled again after passing through the step (3), judging whether the local compiler script is completely loaded or not through the step (3), and otherwise, continuing the operations in the steps (4), (5) and (6).
The above-described embodiments are intended to illustrate the present invention, not to limit it, and any modifications and variations made thereto are within the spirit of the invention and the scope of the appended claims.

Claims (6)

1. A method for efficiently compiling a solubility intelligent contract at a browser end is characterized by comprising the following steps:
(1) Deploying all current solubility compilers on domestic servers or CDN nodes, and simultaneously periodically comparing version lists with foreign Ethernet official compiler warehouses to update the latest compilers in time;
(2) A, inputting or inputting a solubility source file at a browser end, and embedding a WASM format file of a latest and stable solubility compiler into a browser script;
(3) If the compiler version declared by the solubility source code is consistent with the built-in compiler version or the compiler version is not declared, directly compiling the intelligent contract file by using the solubility compiler of the built-in WASM version, and returning a compiling result in the Javascript main thread; if the solubility source file declares the compiler version and the version is inconsistent with the solubility compiler of the built-in WASM file, specifying the src attribute as a path of a domestic server or CDN node in a mode of dynamically and newly adding a script tag to the Javascript code, thereby pulling the required solubility compiler, executing the compiling operation of the intelligent contract file in the Javascript sub-thread, and returning the compiling result to the main thread;
(4) If the compiler to be pulled is not downloaded or fails to pull when the intelligent contract file is compiled in the step (3), the source code is sent to node. Js back-end service in a client server request mode, the solubility source code is compiled through the back-end service, and then the compiling result is returned to the front-end browser;
(5) When the same intelligent contract file requests compiling again, returning to the step (3).
2. The method according to claim 1, wherein in the step (1), before all the solubility compilers are deployed on the domestic server or CDN node, or the latest version of the compiler is pulled to the ethernet official solubility compiler warehouse, the c++ version of the compiler needs to be compiled into an asm.js version file supporting the front-end browser environment and the node.js environment by an emscript or other LLVM tool.
3. The method for efficiently compiling a solution intelligent contract at a browser end according to claim 1, wherein in the step (2), before a latest and stable compiler is built in the browser, the c++ version compiler needs to be compiled into a WASM file in a binary byte code format supported by the browser through an emscript or other LLVM tool, and then the WASM file is packaged into a front-end script code through a weback front-end packaging tool; judging whether to use the built-in WASM file compiler or not through the version number of the solubility file declaration in the browser; the compiler is used in case the version matches correctly or the resolution file does not declare a version number.
4. The method for efficiently compiling a solubility intelligent contract at a browser end according to claim 3, wherein in the step (2), the WASM format file is a binary byte code file, and the method can be directly operated in the browser without interpretation and compiling by a browser script engine.
5. The method for efficiently compiling a solution intelligent contract at a browser end according to claim 1, wherein in the step (3), when the solution file in the browser end fails to match with a WASM compiler file, the browser dynamically creates a script, loads a compiler version corresponding to the current solution file in a domestic server or CDN node, creates a Web Worker sub-thread to compile the solution file, and returns the compiling result to a JavaScript main thread, thereby effectively preventing the JavaScript main thread from being blocked.
6. The method according to claim 1, wherein in the step (4), all the solubility compilers in the domestic server or the CDN node are synchronized in the back-end node. Js, and the latest solubility compilers in the server are regularly pulled by comparing the compiler version lists; under the condition that the dynamic creation script in the browser is not downloaded or fails to be downloaded, a client server request is temporarily sent to node.js service, compiling operation is executed in the node.js service, a compiled result is returned to the browser end, and after the compiler of the browser end is loaded, the loaded compiler is used for executing the compiling operation.
CN201911424066.2A 2019-12-31 2019-12-31 Method for efficiently compiling intelligent contract of solubility at browser end Active CN111176625B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911424066.2A CN111176625B (en) 2019-12-31 2019-12-31 Method for efficiently compiling intelligent contract of solubility at browser end

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911424066.2A CN111176625B (en) 2019-12-31 2019-12-31 Method for efficiently compiling intelligent contract of solubility at browser end

Publications (2)

Publication Number Publication Date
CN111176625A CN111176625A (en) 2020-05-19
CN111176625B true CN111176625B (en) 2023-07-28

Family

ID=70649150

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911424066.2A Active CN111176625B (en) 2019-12-31 2019-12-31 Method for efficiently compiling intelligent contract of solubility at browser end

Country Status (1)

Country Link
CN (1) CN111176625B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111737621B (en) * 2020-06-17 2023-07-25 友虹(北京)科技有限公司 WASM-based OFD rendering method, system and device
CN111984245A (en) * 2020-08-31 2020-11-24 上海玳鸽信息技术有限公司 Block chain intelligent contract online integrated development environment system and implementation method
CN111815310B (en) 2020-08-31 2021-08-17 支付宝(杭州)信息技术有限公司 Method for executing intelligent contract, block chain node and storage medium
CN112269602B (en) * 2020-11-10 2023-12-29 深圳晶泰科技有限公司 WebAssemble loading method, device and storage medium
CN116048532B (en) * 2023-04-03 2023-06-09 深圳市启明智显科技有限公司 Web-based embedded UI effect simulation preview method, device and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833449A (en) * 2010-04-16 2010-09-15 中山大学 Compile processing method and system based on cloud computing
CN102736943A (en) * 2012-06-12 2012-10-17 电子科技大学 Dynamic compiling and executing method of embedded browser engine
WO2012142892A1 (en) * 2011-04-19 2012-10-26 腾讯科技(深圳)有限公司 Script processing method and system for browsers
CN109375899A (en) * 2018-09-25 2019-02-22 杭州趣链科技有限公司 A kind of method of formal verification Solidity intelligence contract
CN109766099A (en) * 2018-12-11 2019-05-17 浙江口碑网络技术有限公司 Front end source code Compilation Method, device, storage medium and computer equipment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070055964A1 (en) * 2005-09-06 2007-03-08 Morfik Technology Pty. Ltd. System and method for synthesizing object-oriented high-level code into browser-side javascript
US7966608B2 (en) * 2005-10-26 2011-06-21 Hewlett-Packard Development Company, L.P. Method and apparatus for providing a compiler interface
CN105893103A (en) * 2014-11-26 2016-08-24 深圳他拍档电子商务有限公司 Compilation method and compiler adopting same
CN105468427A (en) * 2015-11-19 2016-04-06 深圳创维数字技术有限公司 Implementation method and system of automatic compilation and release
CN109683898A (en) * 2017-09-01 2019-04-26 北京猿圈科技有限责任公司 A kind of Compilation Method and cloud compiling system based on cloud compiling

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833449A (en) * 2010-04-16 2010-09-15 中山大学 Compile processing method and system based on cloud computing
WO2012142892A1 (en) * 2011-04-19 2012-10-26 腾讯科技(深圳)有限公司 Script processing method and system for browsers
CN102736943A (en) * 2012-06-12 2012-10-17 电子科技大学 Dynamic compiling and executing method of embedded browser engine
CN109375899A (en) * 2018-09-25 2019-02-22 杭州趣链科技有限公司 A kind of method of formal verification Solidity intelligence contract
CN109766099A (en) * 2018-12-11 2019-05-17 浙江口碑网络技术有限公司 Front end source code Compilation Method, device, storage medium and computer equipment

Also Published As

Publication number Publication date
CN111176625A (en) 2020-05-19

Similar Documents

Publication Publication Date Title
CN111176625B (en) Method for efficiently compiling intelligent contract of solubility at browser end
CN108399083B (en) System deployment method, device, electronic equipment and storage medium
CN111209005B (en) Method and apparatus for compiling program file, and computer-readable storage medium
US10341194B2 (en) System and method for building, optimizing, and enforcing infrastructure on a cloud based computing environment
CN111736954B (en) Multi-intelligent contract virtual machine implementation method, multi-intelligent contract virtual machine and system
CN105446712B (en) Application program defect repairing method and device
CN112799677B (en) Method, device, equipment and storage medium for hook of compiling period
US20070169010A1 (en) Multiplatform programming environment
CN111966366A (en) Cluster deployment method and device of multi-CPU architecture
US20140331201A1 (en) Optimizing intermediate representation of script code for fast path execution
US9317265B2 (en) Optimizing intermediate representation of script code for atomic execution
CN110888652A (en) Multi-version construction method based on jenkins plug-in and terminal
CN111610974A (en) Cross-system platform compiling method facing edge calculation
CN116820493A (en) Mirror image file deployment method, system, equipment and storage medium
CN113204351B (en) Embedded system package management method and using method thereof
CN113360156B (en) IOS compiling method and related equipment
CN114911481A (en) Code compiling method and device and electronic equipment
CN116954699A (en) Dependency detection processing method and device for front-end engineering
CN116360887A (en) Program parameter loading method, device, equipment and storage medium
CN114253552B (en) Programmable edge device self-adapting method and device
CN115390846A (en) Compiling construction method and device, electronic equipment and storage medium
CN114253595A (en) Code warehouse management method and device, computer equipment and storage medium
Chen et al. Dynamic service update based on osgi
CN114942784A (en) Open source software transplanting method, device, equipment and storage medium
CN116414402A (en) Service deployment method and system based on JGit class library

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