Intelligent contract deployment method and device

文档序号:7200 发布日期:2021-09-17 浏览:41次 中文

1. An intelligent contract deployment method is characterized in that,

the client acquires the source code of the intelligent contract written by the high-level programming language from the local;

compiling the source code of the intelligent contract into a target code which can be executed in an Ethernet virtual machine;

coding the target code by using a custom coding character set to obtain a coded target code;

and deploying the coded target code to an intelligent contract server.

2. The intelligent contract deployment method of claim 1 wherein compiling source code of the intelligent contract into target code executable in an etherhouse virtual machine comprises:

performing lexical analysis on the source code of the intelligent contract to obtain a word stream;

carrying out syntax analysis on the word stream to obtain an abstract syntax tree;

and performing semantic analysis on the abstract syntax tree to obtain a target code.

3. The intelligent contract deployment method of claim 1 wherein the custom code character set is a BASE100 code character set.

4. The intelligent contract deployment method of claim 1 wherein deploying the encoded target code to an intelligent contract server comprises:

the client links the coded target code to a main chain server to obtain an intelligent contract block;

and the main chain server sends the intelligent contract block to an intelligent contract server, and the intelligent contract server enables the intelligent contract block to take effect after confirming that the intelligent contract block passes the validity and consistency check so as to complete the deployment of the intelligent contract.

5. The intelligent contract deployment method of claim 1 wherein a client multiple electronic signatures the encoded target code before deploying the encoded target code to an intelligent contract server.

6. An intelligent contract deployment apparatus, the apparatus comprising:

the source code acquisition module is used for the client to locally acquire the source code of the intelligent contract written by the high-level programming language;

the compiling module is used for compiling the source code of the intelligent contract into a target code which can be executed in the EtherFang virtual machine;

the coding module is used for coding the target code by using a custom coding character set to obtain a coded target code;

and the deployment module is used for deploying the coded target code to the intelligent contract server.

7. The intelligent contract deployment apparatus of claim 6, wherein the compilation module comprises:

the lexical analysis submodule is used for carrying out lexical analysis on the source code of the intelligent contract to obtain a word stream;

the syntax analysis submodule is used for carrying out syntax analysis on the word stream to obtain an abstract syntax tree;

and the semantic analysis submodule is used for carrying out semantic analysis on the abstract syntax tree to obtain the target code.

8. The intelligent contract deployment apparatus of claim 6, wherein the custom code character set is a BASE100 code character set.

9. An intelligent contract deployment apparatus according to claim 6, wherein the deployment module comprises:

the chaining sub-module is used for chaining the coded target code to a main chain server to obtain an intelligent contract block;

and the deployment submodule is used for sending the intelligent contract block to an intelligent contract server so as to indicate the intelligent contract server to enable the intelligent contract block to take effect after the intelligent contract block is confirmed to pass the validity and consistency check, so that the intelligent contract is deployed.

10. The intelligent contract deployment apparatus of claim 6, wherein the intelligent contract deployment apparatus further comprises a signature module; the signature module is used for carrying out multiple electronic signatures on the coded target code before the coded target code is deployed to an intelligent contract server.

Background

Because the source code of the intelligent contract of the block chain has illegal characters, the intelligent contract of the block chain has to be compiled into the target code, and the code is written into the block chain in a digital form to control information, perform validation and save on the network. When the block link receives a transaction needing to be processed and needs to call the intelligent contract, the intelligent contract code runs in an Ethernet Virtual Machine (EVM) and returns an execution result. The EVM is a stack-based virtual machine special for the block chain, and has the problems of relatively simple design, relatively low efficiency of block chain information interaction, more files generated in the middle, relatively narrow application range and relatively poor safety.

Disclosure of Invention

The invention provides an intelligent contract deployment method and device aiming at the defects, the source code of the intelligent contract can be compiled into the object code which can be stored in a database and executed in a virtual machine, the source code of the intelligent contract is compiled, the object code of the intelligent contract is validated and a one-key deployment is carried out in place, no intermediate temporary file is generated in the process, and the deployment can be completed in any node in a block chain network.

The invention provides an intelligent contract deployment method according to a first aspect, which in one embodiment comprises the following steps:

the client acquires the source code of the intelligent contract written by the high-level programming language from the local;

compiling a source code of the intelligent contract into a target code which can be executed in an Ethernet virtual machine;

coding the target code by using a custom code character set to obtain a coded target code;

and deploying the coded target code to an intelligent contract server.

In one embodiment, compiling source code of a smart contract into target code executable in an etherhouse virtual machine includes:

performing lexical analysis on a source code of the intelligent contract to obtain a word stream;

carrying out grammatical analysis on the word stream to obtain an abstract syntax tree;

and performing semantic analysis on the abstract syntax tree to obtain the target code.

In one embodiment, the custom code character set is the BASE100 code character set.

In one embodiment, deploying the encoded target code to an intelligent contract server comprises:

the client links the coded target code to a main chain server to obtain an intelligent contract block;

the main chain server sends the intelligent contract block to the intelligent contract server, and the intelligent contract server enables the intelligent contract block to take effect after confirming that the intelligent contract block passes the validity and consistency check so as to complete the deployment of the intelligent contract.

In one embodiment, the client performs multiple electronic signatures on the encoded target code before deploying the encoded target code to the intelligent contract server.

The present invention also provides, according to a second aspect, an intelligent contract deployment apparatus, which, in one embodiment, comprises:

the source code acquisition module is used for the client to locally acquire the source code of the intelligent contract written by the high-level programming language;

the compiling module is used for compiling the source code of the intelligent contract into a target code which can be executed in the Ethengfang virtual machine;

the coding module is used for coding the target code by using a custom coding character set to obtain a coded target code;

and the deployment module is used for deploying the coded target code to the intelligent contract server.

In one embodiment, a compiling module includes:

the lexical analysis submodule is used for carrying out lexical analysis on the source code of the intelligent contract to obtain a word stream;

the syntax analysis submodule is used for carrying out syntax analysis on the word stream to obtain an abstract syntax tree;

and the semantic analysis submodule is used for carrying out semantic analysis on the abstract syntax tree to obtain the target code.

In one embodiment, the custom code character set is the BASE100 code character set.

In one embodiment, a deployment module includes:

the chaining sub-module is used for chaining the coded target code to the main chain server to obtain an intelligent contract block;

and the deployment submodule is used for sending the intelligent contract block to the intelligent contract server so as to indicate the intelligent contract server to enable the intelligent contract block to take effect after the intelligent contract block is confirmed to pass the validity and consistency check, so that the intelligent contract is deployed.

In one embodiment, the intelligent contract deploying apparatus further comprises a signature module; and the signature module is used for carrying out multiple electronic signatures on the coded target code before the coded target code is deployed to the intelligent contract server.

In the embodiment of the invention, the client acquires the source code of the intelligent contract written by the high-level programming language from the local; compiling a source code of the intelligent contract into a target code which can be executed in an Ethernet virtual machine; coding the target code by using a custom code character set to obtain a coded target code; the coded object code is deployed to an intelligent contract server, the embodiment can compile the source code of the intelligent contract into the object code which can be saved in a database and executed in a virtual machine, compile from the source code of the intelligent contract to the validation of the object code of the intelligent contract and deploy one key in place, no intermediate temporary file is generated in the process, and the deployment can be completed in any node in the blockchain network.

Drawings

FIG. 1 is a schematic flow chart diagram illustrating a method for intelligent contract deployment in one embodiment;

FIG. 2 is a diagram of an embodiment of a BASE64 encoding character set;

3-1 and 3-2 are diagrams of BASE100 encoding character sets in one embodiment;

FIG. 4 is a block diagram of an intelligent contract deployment apparatus, under an embodiment;

FIG. 5 is a diagram illustrating an internal structure of a computer device according to an embodiment.

Detailed Description

In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.

The invention provides an intelligent contract deployment method. In one embodiment, as shown in fig. 1, the intelligent contract deployment method includes:

s110: the client acquires the source code of the intelligent contract written by the high-level programming language from the local;

s120: compiling a source code of the intelligent contract into a target code which can be executed in an Ethernet virtual machine;

s130: coding the target code by using a custom code character set to obtain a coded target code;

s140: and deploying the coded target code to an intelligent contract server.

The embodiment can compile the source code of the intelligent contract into the object code which can be saved in the database and executed in the virtual machine, compile the source code of the intelligent contract, validate the object code of the intelligent contract and deploy one key in place, and do not generate an intermediate temporary file in the process, and can complete deployment in any node in the blockchain network.

The above steps are explained in detail below.

Before further detailed description of the embodiments of the present invention, terms and expressions referred to in the embodiments of the present invention are described, and the terms and expressions referred to in the embodiments of the present invention are applicable to the following explanations.

Transaction (Transaction): equivalent to the computer term "transaction," a transaction includes an operation that needs to be committed to a blockchain network for execution and does not refer solely to a transaction in the business context, which is followed by embodiments of the present invention in view of the convention in blockchain technology that colloquially uses the term "transaction. For example, a deployment (deployment) transaction is used to install a specified smart contract to a node in a blockchain network and is ready to be invoked; the Invoke (Invoke) transaction is used to append records of the transaction in the blockchain by invoking the smart contract and to perform operations on the state database of the blockchain, including update operations (including adding, deleting, and modifying key-value pairs in the state database) and query operations (i.e., querying key-value pairs in the state database).

Blockchain (Blockchain): is the storage structure of an encrypted, chained transaction formed by blocks (blocks).

Block chain Network (Blockchain Network): the new block is incorporated into the set of a series of nodes of the block chain in a consensus manner. Wherein Consensus (Consensus) is a process in a blockchain network, and is used to agree on transactions in a block among a plurality of nodes involved, the agreed block is to be appended to the end of the blockchain, and the mechanisms for implementing Consensus include Proof of workload (PoW, Proof of title), Proof of rights and interests (PoS, Proof of authorization of equity (DPoS), Proof of Elapsed Time (PoET, Proof of Elapsed Time), and so on.

Smart Contracts (Smart Contracts): also called chain code or application code, is a program deployed in a node of a blockchain network (or called blockchain node), and the node executes an intelligent contract called in a received transaction to update or query key-value data of a state database.

In this embodiment, based on considerations in multiple aspects such as development efficiency and readability, a user may locally write an intelligent contract to be deployed by using a high-level programming language, where the high-level programming language used for writing the intelligent contract may be a high-level programming language supported by etherhouses such as a Solidity, Serpent, and LLL languages; after the source code of the intelligent contract is compiled, the source code of the intelligent contract is compiled into a target code (byte code), wherein the traditional compiling mode comprises 5 steps of lexical analysis, syntactic analysis, semantic check, intermediate code generation, code optimization and target code generation, and the compiling mode can generate an intermediate file (such as java. cast). The method for compiling the source code of the intelligent contract into the target code capable of being executed in the Ethernet virtual machine comprises the following steps: performing lexical analysis on a source code of the intelligent contract to obtain a word stream; carrying out grammatical analysis on the word stream to obtain an abstract syntax tree; and performing semantic analysis on the abstract syntax tree to obtain the target code.

After the target code of the intelligent contract is obtained through compiling, the target code is coded by using the custom code character set, the target code is deployed into the block chain network after being coded, and the target code can be conveniently transmitted on the network by using the custom code character set for coding. Wherein, the custom code character set is a BASE100 code character set. Specifically, the BASE100 code character set is obtained by adding 36 ask ii code characters to the BASE64 code character set (see fig. 2 for the included characters), and the selection rule of the characters in the BASE100 code character set is primarily not ambiguous, see fig. 3-1 and fig. 3-2. The BASE100 coding character set is adopted to compile the source code of the intelligent contract, so that the expression range of the target code is wider, the unit block capacity is increased by nearly 1 time compared with the result obtained by coding the BASE58 coding character set commonly used by a block chain, namely the block capacity which can be expressed by the same data length is increased by nearly 1 time, and the efficiency is effectively improved.

Before the coded target code is deployed to the intelligent contract server, multiple electronic signatures can be carried out on the coded target code so as to improve the data security of the intelligent contract. When the coded target code is deployed to the intelligent contract server, the coded target code is linked to the main chain server by the client to obtain an intelligent contract block; and then the main chain server sends the intelligent contract block to the intelligent contract server, and the intelligent contract server enables the intelligent contract block to take effect after confirming that the intelligent contract block passes the validity and consistency check so as to complete the deployment of the intelligent contract.

Fig. 1 is a flowchart illustrating an intelligent contract deployment method in one embodiment. It should be understood that, although the steps in the flowchart of fig. 1 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps in fig. 1 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

In one embodiment, the invention also provides an intelligent contract deployment device. As shown in fig. 4, the intelligent contract deployment apparatus includes the following modules:

a source code obtaining module 110, configured to obtain, by a client, a source code of an intelligent contract written in a high-level programming language from a local;

a compiling module 120, configured to compile a source code of the intelligent contract into an object code that can be executed in the ethernet virtual machine;

the encoding module 130 is configured to encode the target code by using a custom code character set to obtain an encoded target code;

and the deployment module 140 is configured to deploy the encoded target code to the intelligent contract server.

The embodiment of the invention can compile the source code of the intelligent contract into the target code which can be stored in a database and executed in the virtual machine, and does not generate an intermediate temporary file in the period from the compiling of the source code of the intelligent contract to the validation and the one-key deployment of the target code of the intelligent contract, and can complete the deployment in any node in the block chain network.

In one embodiment, the compiling module includes:

the lexical analysis submodule is used for carrying out lexical analysis on the source code of the intelligent contract to obtain a word stream;

the syntax analysis submodule is used for carrying out syntax analysis on the word stream to obtain an abstract syntax tree;

and the semantic analysis submodule is used for carrying out semantic analysis on the abstract syntax tree to obtain the target code.

In one embodiment, the custom code character set is the BASE100 code character set.

In one embodiment, the deployment module specifically includes:

the chaining sub-module is used for chaining the coded target code to the main chain server to obtain an intelligent contract block;

and the deployment submodule is used for sending the intelligent contract block to the intelligent contract server so as to indicate the intelligent contract server to enable the intelligent contract block to take effect after the intelligent contract block is confirmed to pass the validity and consistency check, so that the intelligent contract is deployed.

In one embodiment, the intelligent contract deploying apparatus further comprises a signature module; and the signature module is used for carrying out multiple electronic signatures on the coded target code before the coded target code is deployed to the intelligent contract server.

For specific definition of the intelligent contract deployment apparatus, reference may be made to the definition of the intelligent contract deployment method in the foregoing, and details are not described here. The modules in the intelligent contract deployment apparatus may be implemented in whole or in part by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.

In one embodiment, a computer device is provided, the internal structure of which may be as shown in FIG. 5. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data such as source code, target code and the like of the intelligent contract, and the specific stored data can also be referred to as the definition in the above method embodiment. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an intelligent contract deployment method.

Those skilled in the art will appreciate that the architecture shown in fig. 5 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.

It will be understood by those skilled in the art that all or part of the processes of the embodiments of the methods described above can be implemented by a computer program, which can be stored in a non-volatile computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the computer program is executed. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.

The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种wifi在线烧写装置及方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!