[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN111768200A - Method for deploying intelligent contract, block chain node and storage medium - Google Patents

Method for deploying intelligent contract, block chain node and storage medium Download PDF

Info

Publication number
CN111768200A
CN111768200A CN202010899212.3A CN202010899212A CN111768200A CN 111768200 A CN111768200 A CN 111768200A CN 202010899212 A CN202010899212 A CN 202010899212A CN 111768200 A CN111768200 A CN 111768200A
Authority
CN
China
Prior art keywords
transaction
intelligent contract
contract
signatures
machine code
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.)
Pending
Application number
CN202010899212.3A
Other languages
Chinese (zh)
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.)
Alipay Hangzhou Information Technology Co Ltd
Original Assignee
Alipay Hangzhou Information 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 Alipay Hangzhou Information Technology Co Ltd filed Critical Alipay Hangzhou Information Technology Co Ltd
Priority to CN202010899212.3A priority Critical patent/CN111768200A/en
Publication of CN111768200A publication Critical patent/CN111768200A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3825Use of electronic signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • G06F21/6245Protecting personal data, e.g. for financial or medical purposes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Finance (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Computer Security & Cryptography (AREA)
  • Bioethics (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Development Economics (AREA)
  • Medical Informatics (AREA)
  • Databases & Information Systems (AREA)
  • Computer Hardware Design (AREA)
  • Technology Law (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

One or more embodiments of the present specification provide a method, blockchain node, and storage medium for deploying an intelligent contract. An embodiment of a method for deploying an intelligent contract comprises: receiving a transaction for creating an intelligent contract by a blockchain node, wherein the transaction comprises a machine code of the intelligent contract, and the machine code is obtained by compiling a byte code of the intelligent contract through AoT; and the blockchain node completes the deployment of the intelligent contract under the condition that the initiator account of the transaction belongs to a plurality of management parties and the transaction contains the signatures of the plurality of management parties.

Description

Method for deploying intelligent contract, block chain node and storage medium
Technical Field
The embodiment of the specification belongs to the technical field of block chains, and particularly relates to a method for deploying an intelligent contract, a block chain node and a storage medium.
Background
The Blockchain (Blockchain) is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. An intelligent contract appears in the 2.0 era of the block chain, and the application range of the block chain is improved to a new height. With intelligent contracts, the blockchain can do no longer a single transfer transaction, but can also invoke a piece of code, which can be customized by the user.
Disclosure of Invention
The present specification is directed to a method, blockchain node, and storage medium for deploying an intelligent contract.
The method, the block chain node and the storage medium for deploying the intelligent contract provided by the embodiments of the present specification are implemented by:
a method of deploying an intelligent contract, comprising:
receiving a transaction for creating an intelligent contract by a blockchain node, wherein the transaction comprises a machine code of the intelligent contract, and the machine code is obtained by compiling a byte code of the intelligent contract through AoT;
and the blockchain node completes the deployment of the intelligent contract under the condition that the initiator account of the transaction belongs to a plurality of management parties and the transaction contains the signatures of the plurality of management parties.
A method of deploying an intelligent contract, comprising:
receiving a transaction for creating an intelligent contract by a blockchain node, wherein the transaction comprises a machine code of the intelligent contract, and the machine code is obtained by compiling a byte code of the intelligent contract through AoT;
and the block chain node completes the deployment of the intelligent contract under the condition that the initiator account of the transaction belongs to a plurality of management parties and the transaction contains the signatures of the management parties in a preset number.
A blockchain node for deploying an intelligent contract performs the above method.
A block link point for deploying an intelligent contract, comprising:
a processor for processing the received data, wherein the processor is used for processing the received data,
a memory storing a program, wherein the method described above is performed when the processor executes the program.
A storage medium storing a program, wherein the program when executed performs the operations of the above method.
Through the embodiment of the present specification, before the intelligent contract is deployed to the blockchain, the bytecode of the intelligent contract is compiled into the corresponding machine code through AoT in advance, so that the machine code of the intelligent contract is directly deployed on the blockchain, and thus efficient operation can be realized based on the deployed machine code when the intelligent contract is invoked. Due to the characteristics of the machine code, the machine code can perform much more operations than the bytecode, and accordingly, more risks are brought, such as leakage of private data stored at the link nodes of the block, influence on stable operation of the link nodes of the block, and the like. Thus, for a transaction that creates a smart contract, the same thing may be that the managing party manages the action of deploying the smart contract in machine code by limiting the account of the initiator of the transaction to a multi-party managing account (i.e., there are multiple managing parties), and ensuring that at least some of the managing parties agree to deploy the smart contract based on signature verification, which may avoid deploying the smart contract in machine code at will, thereby reducing or eliminating the aforementioned risk.
Drawings
FIG. 1 is a schematic diagram of compilation execution and interpretive execution in one embodiment;
FIG. 2 is a schematic diagram illustrating implementation and JIT in one embodiment;
FIG. 3 is a diagram process of creating an intelligent contract, of an embodiment;
FIG. 4 is a diagram process of invoking an intelligent contract, of an embodiment;
FIG. 5 is a schematic diagram of creating an intelligent contract and invoking an intelligent contract, in one embodiment;
FIG. 6 is a flow diagram that illustrates deploying an intelligent contract, in one embodiment;
FIG. 7 is a block diagram of a blockchain node in one embodiment;
FIG. 8 is a schematic diagram of creating an intelligent contract and invoking an intelligent contract, in one embodiment;
FIG. 9 is a diagram that illustrates virtual machine execution involved in creating an intelligent contract and invoking the intelligent contract, in one embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of the present specification. Rather, they are merely examples of apparatus and methods consistent with certain aspects of one or more embodiments of the specification, as detailed in the claims which follow.
It should be noted that: in other embodiments, the steps of the corresponding methods are not necessarily performed in the order shown and described herein. In some other embodiments, the method may include more or fewer steps than those described herein. Moreover, a single step described in this specification may be broken down into multiple steps for description in other embodiments; multiple steps described in this specification may be combined into a single step in other embodiments.
The 1.0 era of blockchain generally refers to the development stage of blockchain applications represented by bitcoin between 2009 and 2014, which mainly aim to solve the decentralization problem of currency and payment means. Since 2014, developers have been focusing more and more on solving the deficiencies of bitcoin in technology and extensibility. In the end of 2013, vitarik burein issued the etherhouse white paper, "etherhouse: the next generation of intelligent contracts and decentralized application platforms introduce the intelligent contracts into the blockchain, open the application of the blockchain outside the currency field, and further open the 2.0 era of the blockchain.
An intelligent contract is a computer contract that executes automatically based on specified trigger rules and may also be considered a digital version of a traditional contract. The concept of smart contracts was first proposed by cross-domain law workers, cryptology researchers, Nick Szabo (Nick Szabo) in 1994. This technology has not been used in the real industry for the first time due to the lack of programmable digital systems and related technologies, until the advent of blockchain technology and etherhouses provided reliable execution environments for it. Due to the adoption of the block chain type account book in the block chain technology, the generated data cannot be falsified or deleted, and account book data are continuously added to the whole account book, so that the traceability of historical data is ensured; meanwhile, the decentralized operation mechanism avoids the influence of centralized factors. The intelligent contract based on the block chain technology not only can exert the advantages of the intelligent contract in the aspects of cost and efficiency, but also can avoid the interference of malicious behaviors on the normal execution of the contract. The intelligent contracts are written into the block chain in a digital form, and the characteristics of the block chain technology ensure that the whole process of storage, reading and execution is transparent, traceable and not falsifiable.
A smart contract is essentially a piece of program that can be executed by a computer. The smart contracts, like computer programs that are widely used today, may be written in a high-level language (e.g., C language, C + + language, etc.). Program code of an intelligent contract written in a high-level language is generally converted by a "compiler" into "machine code" that can be recognized and executed by a CPU of a computer, and such machine code (alternatively referred to as "microprocessor instructions") can be executed by the CPU. This approach is commonly referred to as "compilation execution.
Compilation execution generally does not have cross-platform extensibility. Since there are CPUs of different manufacturers, brands and generations, and the instruction sets supported by these different CPUs are different in many cases, such as the x86 instruction set, the ARM instruction set, etc., and the instruction sets supported by CPUs of the same manufacturer and different generations (such as Intel CPUs of different generations) are not identical, the machine codes converted by compilers on different CPUs may be different for the same program code written in the same high-level language. Specifically, in the process of converting program codes written in a high-level language into machine codes, a compiler performs optimization in combination with characteristics of a specific CPU instruction set (such as a vector instruction set) to improve the speed of program execution, and such optimization is often related to specific CPU hardware. Thus, for the same machine code, one may run on x86, but another may not run on ARM; even the same x86 platform, instruction sets are continually enriched and expanded over time, which results in different machine code runs on different generations of x86 platforms. Furthermore, since executing machine code requires the CPU to be scheduled by the os kernel, machine code supporting execution under different os may be different even if it is the same hardware.
Unlike compilation execution, there is also a way of running programs that "interpret execution. Such as the Java language, compiles Java source code into standard byte codes (bytecodes) by a Java compiler, where the compiler does not target any actual instruction set of the hardware processor, but rather defines an abstract set of standard instruction sets. The compiled standard bytecode generally cannot be directly run on a hardware CPU, so a virtual machine, i.e. JVM, is introduced, and the JVM runs on a specific hardware processor to interpret and execute the compiled standard bytecode.
JVM is an abbreviation of Java Virtual Machine, and is an imaginary computer, which is often implemented by simulating various computer functions on an actual computer. The JVM shields information related to a specific hardware platform, an operating system, and the like, so that the Java program can be run on various platforms without modification only by generating standard bytecodes which can be run on the Java virtual machine.
A very important feature of the Java language is independence from the platform. The use of a Java virtual machine is the key to achieving this feature. A typical high-level language, if it is to be run on a different platform, needs to be compiled into at least different object codes. After the Java language virtual machine is introduced, the Java language does not need to be recompiled when running on different platforms. The Java language masks information related to a specific platform using a Java virtual machine, so that a Java language compiler can be executed on a variety of platforms without modification by only generating object codes (bytecodes) to be executed on the Java virtual machine. When executing the byte code, the Java virtual machine interprets the byte code into machine instruction execution on a specific platform. This is why Java is able to "compile once, run everywhere".
The JVM runs on a specific hardware processor, is responsible for the interpretation and execution of bytecodes for the specific processor running, and masks up these underlying differences, presenting the developer with a standard development specification. The JVM, when executing bytecodes, actually eventually interprets the bytecodes into machine instruction execution on a particular platform. Specifically, after receiving the input bytecode, the JVM interprets each instruction sentence by sentence and translates the interpreted instruction into a machine code suitable for the current machine to run, and these processes are interpreted and executed by, for example, an Interpreter called Interpreter. In this way, the developer writing the Java program does not need to consider on which hardware platform the written program code will run. The development of the JVM itself is done by a professional developer of the Java organization to adapt the JVM to different processor architectures. To date, the mainstream processor architectures have limited number, such as X86, ARM, RISC-V, MIPS. After a professional developer transplants the JVMs onto platforms supporting these specific hardware, the Java program can theoretically run on all machines. The JVM migration work is usually provided by a professional in the Java development organization, which greatly relieves the Java application developer of the burden.
Interpretive execution brings cross-platform portability, but because execution of bytecodes goes through the process of JVM intermediate translation, execution efficiency is not as high as the above compilation execution efficiency, and the difference in efficiency can sometimes even reach several tens of times.
Fig. 1 shows the common points and different points of compilation execution and interpretation execution. Whether interpreted or compiled, or physical or virtual, it is not possible for an application program to be read, understood, and then executed as if it were human. Most of the program code needs to go through the steps of fig. 1 before the object code of the physical machine or the instruction set that the virtual machine can execute. The branch from the top to the left in fig. 1 is the generation process of the program code to the target machine code in the conventional compilation principle, and the branch from the top to the right is the process of the interpreted execution. Nowadays, languages based on a physical machine, a Java virtual machine, or other High-Level Language virtual machines (HLLVM) other than Java mostly follow the idea based on the modern classical compilation principle, and before execution, lexical analysis and syntax analysis processing are performed on program source codes to convert the source codes into Abstract Syntax Trees (AST). For implementation of a specific language, the lexical analysis, the syntactic analysis and the subsequent optimizer and object code generator can be selected to be independent of the execution engine to form a complete compiler for implementation, and the representation is C/C + + language. Alternatively, some of the steps (e.g., the steps prior to generating the abstract syntax tree) may be implemented as a semi-independent compiler, such as the Java language. Or all the steps and the execution engines are packaged in a closed black box in a centralized mode, such as most JavaScript executors.
To achieve as good a compromise between cross-platform portability and high performance as possible, the concept of Just-In-time compiler (JIT) was proposed. The core idea of JIT is "how to efficiently avoid repetitive work in interpreting instructions". There is a large amount of repeatedly executed code in a computer program, for example, some computing "functions" may be called many times in a loop during the execution of a program. If it is an interpretive execution, each execution of the loop process translates this function from bytecode to machine code. However, in practice, the machine code generated by this function in tens of translations is the same. Naturally, after the first translation, the machine code of the translated function is cached, and in the subsequent re-execution process, the cached code is directly used without the need of re-translation, so that the execution efficiency can be improved.
On the contrary, some functions are executed only once during the program running period (for example, the initialization is started), so that the functions do not need to be cached and can be directly interpreted and executed once. Thus, a core module in the JIT technology is "hot spot analysis", which analyzes which codes are executed multiple times during program execution, and thus caches the translated machine codes. For operations that are performed a small number of times, no caching is required. This may result in an optimal balance between execution efficiency and memory overhead.
In addition, another core module in JIT technology is compilation optimization (or optimized compilation). The directly translated machine code is not optimized by combining the context, only the high-frequency machine code is cached, and the performance improvement is limited. Further optimization of the compiler may be performed if better performance is to be achieved. The way of compiling the optimization generally requires relatively more time to implement.
The working principle of JIT is shown, for example, in fig. 2. The Java source code is compiled by a Java Compiler to generate a Java bytecode, and is distributed to two execution paths (JIT Compiler and interproerter) after hot spot analysis. The code determined as the hot spot (high-frequency execution) is compiled in the JIT compiler to obtain a machine code, cached and executed, and generally executed by the CPU under the control of an Operating System (OS). A low frequency input Interpreter (Interpreter), which translates the code into machine code and is executed by the CPU under the control of the OS.
Due to the context of the program code itself, a large optimization space often exists in the compiling process. The execution efficiency of the optimized machine code is far higher than that of the directly translated machine code. Compiler optimization is necessary if better performance is to be achieved. The process of JIT compiler compilation may be time consuming. In particular, the process of JIT Compiler compiling bytecode for the first time can be time consuming and even not as efficient as interpretation. Then, for some java programs, if the hot spot is not very prominent, i.e. the overall execution frequency is not very high, and the overall execution flow is very long, it is difficult for JIT to exert the advantage of compiling execution.
In addition, an idea has been proposed of AoT (ahead of time). AoT corresponds to a method of precompiled execution. Before the program runs, the bytecode is compiled once aiming at a target execution environment to obtain a machine code, and then the machine code is deployed to a target machine for execution. AoT the efficiency of operation can be such that compilation is performed. At AoT, the hardware, instruction set architecture, system, etc. of the target system need to be known explicitly to ensure that the compiled code can run. Furthermore, generally speaking, for instructions with the same function, the amount of statements required for machine code expression is larger than that of bytecodes, and more than that of codes written in a high-level language, so that for programs with the same content, it is likely that the size of machine code > the size of bytecodes > the size of codes in a high-level language. The bytecode may be compiled AoT into machine code with explicit knowledge of the target system's hardware, instruction set architecture, system, etc. Meanwhile, the machine codes of different types of target systems are different, and therefore, different versions of machine codes may need to be provided for various target systems to have corresponding correctly executed machine codes. Thus, the total size of the machine code is typically larger than the byte code or the high-level language code.
For example, Android employed the Dalvik virtual machine before version 5.0, and ART virtual machine after version 5.0. Dalvik uses a JIT compiler to interpret bytecodes, while ART is the AoT mechanism. The ART approach precompiles bytecode (the installation process of the Android App is actually the bytecode of the installer) to machine code at application installation time. After the process of removing the interpretation code, the application program on the Android is executed more efficiently and started more quickly.
The block chain is used as a decentralized distributed system and needs to maintain distributed consistency. Specifically, each node in a group of nodes in the distributed system is internally provided with a state machine. Each state machine needs to execute the same instructions in the same order from the same initial state, and keep the change of each state the same, thereby ensuring that the consistent state is finally achieved. And each node device participating in the same blockchain network is difficult to be in the same hardware configuration and software environment. Therefore, in the representative etherhouse in the blockchain 2.0, in order to ensure that the process and the result of executing the smart contracts on the respective nodes are the same, a Virtual Machine similar to a JVM, an Etherhouse Virtual Machine (EVM), is used. Differences of hardware configuration and software environment of each node can be shielded through the EVM. In this way, a developer can develop a set of codes of the intelligent contract, and the codes of the intelligent contract are compiled locally by the developer and then the compiled byte codes (bytecodes) are uploaded to the block chain. After each node executes the same byte code through the same EVM interpretation in the same initial state, the same final result and the same intermediate result can be obtained, and the underlying hardware and environment differences of different nodes can be shielded. Thus, the advent of decentralized blockchain technology enabled smart contracts to be implemented as early as 1994, and further handled in an interpretive manner to ensure that the same execution results were obtained on many different hardware and runtime machines going to the center, since decentralized implementations necessarily face hardware and runtime differences between different execution machines.
The EVM is a well-defined virtual machine, which means that various complex logic can be implemented through it, which is also taifang as one of the largest improvements over blockchain 1.0 represented by blockchain 2.0. The user issuing and invoking smart contracts in the ethernet house may be run on the EVM. As mentioned previously, EVM runs directly on bytecode, and the intelligent contracts deployed on the blockchain may be in the form of bytecode.
For example, as shown in fig. 3, after Bob sends a transaction containing information to create an intelligent contract to the ethernet network, the EVM of node 1 may execute the transaction and generate a corresponding contract instance. The data field of the transaction may store a bytecode, and the to field of the transaction may be an empty address. After the agreement is achieved between the nodes through the consensus mechanism, the contract is successfully created, and the subsequent user can call the contract.
After the contract is created, a contract account corresponding to the intelligent contract appears on the blockchain and has a specific address, and the contract code and account storage can be stored in the contract account. The behavior of the intelligent contract is controlled by the contract code, while the account storage of the intelligent contract preserves the state of the contract. In other words, the intelligent contract causes a virtual account to be generated on the blockchain that contains the contract code and account storage.
As mentioned above, the data field containing the transaction that created the smart contract holds what may be the byte code of the smart contract. A bytecode consists of a series of bytes, each of which may indicate an operation. Based on the multiple considerations of development efficiency, readability and the like, a developer can select a high-level language to write intelligent contract codes instead of directly writing byte codes. The intelligent contract code written by the high-level language is compiled by a compiler to generate byte codes, and the byte codes can be deployed on the block chain. The high-level languages supported by Etherns are many, such as Solidity, Serpent, LLL, etc.
Taking the Solidity language as an example, the contract written by the method is similar to a Class (Class) in an object-oriented programming language, and various members including state variables, functions, function modifiers, events and the like can be declared in one contract. A state variable is a value permanently stored in the account storage of a smart contract that is used to save the state of the contract.
The following code example 1 is a simple intelligent contract written in the Solidity language:
Contract Example{
int balance;
function C( ){
balance + = 1;
}
functiongetbalance( ) returns(int){
return balance ;
}
}
generally, after the contract is deployed in the blockchain, the "balance" state variable may be an asset type newly defined in the contract. function C () this function may define a change operation of balance, and functiotblance () returns (int) this function may define an operation that takes the current value of balance and returns.
Further, as shown in fig. 4, still taking the ethernet house as an example, after Bob sends a transaction containing the information of invoking the intelligent contract to the ethernet house network, the EVM of node 1 may execute the transaction and generate the corresponding contract instance. The from field of the transaction in FIG. 4 is the address of the account from which the intelligent contract was initiated, and "0 x692a70d2 …" in the to field represents the address of the intelligent contract being invoked, and the value field is the value in EtherFang that is the Tai currency value, and the data field of the transaction holds the method and parameters for invoking the intelligent contract. After invoking the smart contract, the value of balance may change. Subsequently, a certain client can check the current value of balance through a certain block link point.
The intelligent contract can be independently executed at each node in the blockchain network in a specified mode, and all execution records and data are stored on the blockchain, so that after the transaction is completed, transaction certificates which cannot be tampered and lost are stored on the blockchain.
A schematic diagram of creating an intelligent contract and invoking the intelligent contract is shown in fig. 5. An intelligent contract is created in an Ethernet workshop and needs to be subjected to the processes of compiling the intelligent contract, changing the intelligent contract into byte codes, deploying the intelligent contract to a block chain and the like. The intelligent contract is called in the Ethernet, a transaction pointing to the address of the intelligent contract (the address of the intelligent contract can be pointed through the to field in the transaction) is initiated, and the intelligent contract code is distributed and operated in the virtual machine of each node in the Ethernet.
The transaction for creating the smart contract is sent to the blockchain network, and after consensus, each blockchain link point can execute the transaction. In particular, this transaction may be performed by the EVM/WASM of the blockchain node. As previously described, a contract account corresponding to the intelligent contract appears on the time zone block chain (including, for example, the Identity of the account, the hash value Codehash of the contract, and the root StorageRoot of the contract store), and has a specific address, and the contract code and account store may be stored in the store of the contract account, as shown in fig. 9. The behavior of the intelligent contract is controlled by the contract code, while the account storage of the intelligent contract preserves the state of the contract. In other words, the intelligent contract causes a virtual account to be generated on the blockchain that contains the contract code and account storage. For contract deployment transactions or contract update transactions, the value of the Codehash will be generated or altered. Subsequently, the block link point may receive a transaction request that invokes the deployed smart contract, which may include the address of the invoked contract, the function in the invoked contract, and the parameters of the input. Generally, after the transaction request is identified, each node of the blockchain can independently execute the intelligent contract for the designated call. Specifically, as shown in fig. 9, the node may load the byte code (Bytecode) of the contract from the store into the virtual machine (EVM/WASM) according to the address of the contract; furthermore, the Interpreter (Interpreter) interprets the execution, for example, including parsing the byte code of the called contract to obtain operation codes (opcodes), and stores these opcodes in the Memory of the virtual machine, and also obtains the address of the called function; after the Gas consumed by executing the contract is calculated and is enough, jumping to the corresponding address of the Memory to obtain the OPcode of the called function and starting to execute, and performing operations such as data calculation (DataComputation) and push/push Stack (Stack) on the data operated by the OPcode of the called function, thereby completing the data calculation. In this process, some contract Context (Context) information may also be needed, such as block number, information of the initiator calling the contract, and the like, which can be obtained from the Context (Get operation). Finally, the generated state is stored in a store (Storage) by calling a store interface. It should be noted that, during the process of creating the contract, interpretation and execution of some functions in the contract may also be generated, for example, a function of initialization operation, and at this time, the code is also parsed, a jump instruction is generated, the jump instruction is stored in the Memory, data is operated in the Stack, and the like. In the above-described interpretation execution process, generally, the repeatedly executed functions are not cached, and even if there are more than a plurality of times of execution of the functions, the virtual machine needs to repeat the analysis and execution processes.
Similarly, as mentioned above for the cross-platform portability advantage of JVMs and the need to improve performance, EVMs in blockchains may also employ techniques such as JIT and AoT to improve performance when executing smart contracts. For example, before the intelligent contract is deployed on the blockchain, AoT compilation is performed, and the machine code obtained after compilation is linked up, so as to complete the deployment of the contract, such as the process shown in fig. 8. The contract that completes the deployment may have a particular address on the blockchain. In this way, the machine code of the contract may be included in a client-initiated transaction to create a contract. For example, the machine code may be obtained by compiling AoT locally at the client after compiling the smart contract written in the high-level language into bytecode by the client. The process of executing the contract on the chain (or called the process of calling the intelligent contract) may be, for example, a client (which may be different from the client creating the intelligent contract) directly calls AoT the machine code on the chain and executes the machine code. Here, in a transaction that invokes a contract, the address that is generally pointed to (i.e., the address pointed to by the to field) may be the address of the invoked contract. Since the AoT compilation in this example is done before the chain is completed on the smart contract, it may be referred to as "chain-down AoT" for short. The offline AoT compilation process may allow for a large amount of code optimization so that the efficiency of executing contracts on the chain may be greatly increased. The drawback is also apparent that the processor architecture, operating environment, etc. of the deployed target node need to be obtained in advance when the node is down AoT, otherwise the machine code of the uplink will likely not be able to be executed on the target node subsequently. Also, to accommodate a variety of different target nodes, AoT may need to be compiled into a variety of different machine codes. Thus, the machine code size compiled by AoT is much larger than the size of the original intelligent contract byte code, thereby increasing the uplink data volume and increasing the storage overhead.
The present specification provides an embodiment of a method for deploying an intelligent contract, as shown in fig. 6, comprising:
s601: the blockchain node receives a transaction for creating the intelligent contract, wherein the transaction comprises machine code of the intelligent contract, and the machine code is compiled from byte code of the intelligent contract through AoT.
The user may write the smart contract in a high-level language locally to the user. The written intelligent contract can be compiled by a compiler which is adapted to the high-level language to obtain byte codes. Furthermore, the byte codes of the intelligent contract obtained by compiling can be compiled into machine codes through the client, and then the machine codes of the intelligent contract are packaged into transactions by the client and are sent to the block chain network. The format of the transaction is shown, for example, in fig. 3-5, where the machine code of the smart contract that needs to be created may be stored in the data field of the transaction.
The user may also write the intelligent contract in the high-level language directly on the first block chain node, and then the first block chain node may also use a compiler to compile the intelligent contract written in the high-level language to generate the bytecode, and the first block chain node may also compile the bytecode into the machine code. In addition, the user can directly write the intelligent contract in the high-level language on the first block chain node, and the first block chain node also adopts a compiler to compile the intelligent contract written in the high-level language to generate byte codes; and further compiling the bytecode generated by the first blockchain node into machine code by the second blockchain node. Then, the client may first obtain the machine code of the intelligent contract from the first blockchain node or the second blockchain node, and then package the machine code of the intelligent contract into a transaction, and send the transaction to the blockchain network.
When compiling the bytecode of the intelligent contract into machine code, the bytecode of the intelligent contract may be compiled into machine code through AoT. AoT compiling technology can improve the performance of intelligent contract when executing, specifically, compiling can be performed by combining the front-back association of program codes, and machine codes after optimized compiling can be obtained. By compiling optimized machine code, the execution efficiency is generally higher than that of machine code obtained by direct translation. In one aspect, the compiled machine code has optimization of hardware + environment by providing the hardware and environment information of the blockchain node to the AoT engine, which may specifically include optimization in machine code generation, including instruction-level optimization, register allocation and optimization, and the like. On the other hand, the AoT engine may analyze context information such as branch jump statements executed in the current function, identify which of them is the most likely line to jump, and thus adjust this jump likelihood to the top so that a higher probability of hitting the branch first statement may be executed; the compiler optimization process may also perform dead code elimination through data flow analysis/active variable analysis, such as eliminating branches that cannot be taken, and may also include optimization of loop statements, common word expression replacement, and the like.
S603: and the blockchain node completes the deployment of the intelligent contract under the condition that the initiator account of the transaction belongs to a plurality of management parties and the transaction contains the signatures of the plurality of management parties.
As described above, a user may submit a transaction for creating an intelligent contract into the blockchain network through a client, and the user is an initiator of the transaction. In the blockchain scenario, the user information may be maintained in an account manner, and the initiator also has a corresponding account, i.e., an initiator account. Information of the initiator account is recorded in the transaction. For example, in the embodiment shown in FIG. 3, Bob is the initiator of the transaction, and information about the initiator account is recorded in the From field of the transaction. Generally, an account in a blockchain scenario (i.e., a blockchain account) corresponds to an entity, for example, the entity may be the user, the enterprise, or the like. This entity has administrative rights to the corresponding blockchain account upon which a transaction for creating a smart contract, a transaction invoking a smart contract, etc. may be initiated. Some blockchain accounts correspond to multiple entities at the same time, and the entities can manage the behavior of the blockchain account at the same time, namely the entities correspond to multiple managers of the blockchain account. Mutual supervision and balance control can be realized among the management parties, and block chain accounts are prevented from being abused.
Machine code can perform many more operations than bytecode, and thus is a relatively greater threat to the chain. For example, by tampering with the machine code of the smart contract, after the smart contract is invoked, the machine code may be executed to read private data stored on the blockchain node, such as private data in a Trusted Execution Environment (TEE) deployed on the blockchain node, and the like, and may even affect the normal operation of the blockchain node, and destroy the security and stability of the blockchain network. Thus, when the bytecode of the smart contract is included in the transaction for creating the smart contract, the blockchain link point may not restrict the originator account, so that the blockchain account corresponding to one entity may deploy the bytecode of the smart contract onto the blockchain; when the machine code of the intelligent contract is included in the transaction for creating the intelligent contract, the blockchain link points need to restrict the account of the initiator, and ensure that only blockchain accounts corresponding to a plurality of managers can deploy the machine code of the intelligent contract to the blockchain.
The block chain node can verify a plurality of signatures contained in the transaction through the public keys of the management parties corresponding to the management parties respectively, and determine that the transaction contains the signatures of the management parties when the signatures pass the verification. In the verification process, if a one-to-one corresponding verification relationship can be realized between the management public key and the signature, for example, the management public key 1 corresponds to the signature 1 (i.e., the verification is successful), the management public key 2 corresponds to the signature 2, and the management public key 3 corresponds to the signature 3 (taking the number as 3 as an example), it is confirmed that the transaction includes signatures of a plurality of management parties, and the machine code included in the transaction is allowed to be deployed.
Optionally, the block link point may respectively obtain the number of the management party to which the account of the initiator belongs and the number of the signatures included in the transaction: if the number of the management parties to which the account of the initiator belongs is 1 or the number of the signatures contained in the transaction is 1, or although the account of the initiator belongs to a plurality of management parties and the transaction contains a plurality of signatures, the number of the management parties is inconsistent with the number of the signatures (for example, the number of the management parties is 3 and the number of the signatures is 2, or the number of the management parties is 3 and the number of the signatures is 4), the block link point can directly judge that the signatures are not verified without performing the operation of verifying the signatures, and the machine codes contained in the transaction are not allowed to be deployed, so that the waste of related processing resources can be avoided. And only when the account of the initiator belongs to a plurality of managers, the transaction comprises a plurality of signatures and the number of the managers and the number of the signatures are consistent, the block chain node verifies the plurality of signatures contained in the transaction through the public keys of the managers respectively corresponding to the managers so as to further determine whether the signatures pass the verification: still take the number of 3 for example, the manager public key 1 corresponds to the signature 1, the manager public key 2 corresponds to the signature 2, and the manager public key 3 does not correspond to the signature 1, the signature 2, or the signature 3, and for example, the manager public key 1 corresponds to the signature 1 and the signature 3, the manager public key 2 corresponds to the signature 2, and the manager public key 3 does not correspond to the signature 1, the signature 2, or the like, it is determined that the transaction does not include signatures of multiple managers, and the machine code included in the transaction is not allowed to be deployed.
The block chain node may execute the above processing logic based on chain code, including obtaining a public key of a manager to which the initiator account belongs, obtaining a signature included in the transaction, verifying the signature based on the public key of the manager, identifying the number of the public keys of the manager, identifying the number of the transaction, determining the relationship between the public keys of the manager and the number of the transaction, and the like. Alternatively, these processing logic may be implemented by a block chain node by invoking a pre-deployed system contract.
In a public, alliance, or private chain system of etherhouses and similar principles, block chain nodes may initiate consensus for a batch of transactions. The batch of transactions may include the transactions described above for creating smart contracts. After consensus, generally, each consensus node locally stores the machine code of the intelligent contract to be created. Each consensus node can locally execute the transaction for creating the intelligent contract and create a corresponding contract account; and creating an address for the contract account according to the same rule, wherein the addresses created by the consensus nodes for the same contract are the same. Thus, the contract deployment is completed.
Preferably, the storage is a cache, and the subsequent response can be made more quickly by caching the storage in a memory. Specifically, the memory may be a cache area opened in the virtual machine. Of course, even if the data is stored to a magnetic disk, the response speed can be improved to some extent in many cases.
After deployment of the intelligent contract is completed, a call to the contract may be provided. In this way, a client (possibly different from the client initiating the create contract transaction in S601) may initiate a call to the contract. For example, the client initiates a transaction, wherein the to field is the address of the smart contract deployed as described above, and the data field may include the method of the invoked contract and the entered parameters, thereby enabling invocation of the smart contract deployed. Generally, after a batch of transactions including the transaction of the invoking contract are identified, each identified node executes the transaction respectively. In the process of calling the contract by the block chain node, under the condition that the machine code of the intelligent contract is stored, the machine code can be directly executed by a CPU (under the control of an OS), so that the speed of executing the intelligent contract can be greatly increased by the block chain node. In addition, the execution speed of the intelligent contract can be further improved under the condition that the machine code of the intelligent contract is cached in the memory. Of course, even if stored in a magnetic disk, the execution speed can be raised to some extent. The block chain node executes the machine code, and specifically may execute a machine code corresponding to a called function in the stored contract.
The machine code in this specification may be applied to, in addition to EVM, a wasm (web assembly) Virtual machine, jsvm (javascript Virtual machine), and the like, and is not limited herein.
It should be noted that the block link point in S601 may be different from the block link point in S603. This is because the blockchain acts as a distributed system, and the node receiving the transaction, the node initiating the consensus, and the node performing the transaction may be different nodes or, of course, the same node.
Another method embodiment of deploying intelligent contracts of the present specification is introduced below, comprising:
step A1: the blockchain node receives a transaction for creating the intelligent contract, wherein the transaction comprises machine code of the intelligent contract, and the machine code is compiled from byte code of the intelligent contract through AoT.
The user may write the smart contract in a high-level language locally to the user. The written intelligent contract can be compiled by a compiler which is adapted to the high-level language to obtain byte codes. Furthermore, the byte codes of the intelligent contract obtained by compiling can be compiled into machine codes through the client, and then the machine codes of the intelligent contract are packaged into transactions by the client and are sent to the block chain network. The format of the transaction is shown, for example, in fig. 3-5, where the machine code of the smart contract that needs to be created may be stored in the data field of the transaction.
The user may also write the intelligent contract in the high-level language directly on the first block chain node, and then the first block chain node may also use a compiler to compile the intelligent contract written in the high-level language to generate the bytecode, and the first block chain node may also compile the bytecode into the machine code. In addition, the user can directly write the intelligent contract in the high-level language on the first block chain node, and the first block chain node also adopts a compiler to compile the intelligent contract written in the high-level language to generate byte codes; and further compiling the bytecode generated by the first blockchain node into machine code by the second blockchain node. Then, the client may first obtain the machine code of the intelligent contract from the first blockchain node or the second blockchain node, and then package the machine code of the intelligent contract into a transaction, and send the transaction to the blockchain network.
When compiling the bytecode of the intelligent contract into machine code, the bytecode of the intelligent contract may be compiled into machine code through AoT. AoT compiling technology can improve the performance of intelligent contract when executing, specifically, compiling can be performed by combining the front-back association of program codes, and machine codes after optimized compiling can be obtained. By compiling optimized machine code, the execution efficiency is generally higher than that of machine code obtained by direct translation. In one aspect, the compiled machine code has optimization of hardware + environment by providing the hardware and environment information of the blockchain node to the AoT engine, which may specifically include optimization in machine code generation, including instruction-level optimization, register allocation and optimization, and the like. On the other hand, the AoT engine may analyze context information such as branch jump statements executed in the current function, identify which of them is the most likely line to jump, and thus adjust this jump likelihood to the top so that a higher probability of hitting the branch first statement may be executed; the compiler optimization process may also perform dead code elimination through data flow analysis/active variable analysis, such as eliminating branches that cannot be taken, and may also include optimization of loop statements, common word expression replacement, and the like.
Step A2: and the block chain node completes the deployment of the intelligent contract under the condition that the initiator account of the transaction belongs to a plurality of management parties and the transaction contains the signatures of the management parties in a preset number.
As described above, a user may submit a transaction for creating an intelligent contract into the blockchain network through a client, and the user is an initiator of the transaction. In the blockchain scenario, the user information may be maintained in an account manner, and the initiator also has a corresponding account, i.e., an initiator account. Information of the initiator account is recorded in the transaction. For example, in the embodiment shown in FIG. 3, Bob is the initiator of the transaction, and information about the initiator account is recorded in the From field of the transaction. Generally, an account in a blockchain scenario (i.e., a blockchain account) corresponds to an entity, for example, the entity may be the user, the enterprise, or the like. This entity has administrative rights to the corresponding blockchain account upon which a transaction for creating a smart contract, a transaction invoking a smart contract, etc. may be initiated. Some blockchain accounts correspond to multiple entities at the same time, and the entities can manage the behavior of the blockchain account at the same time, namely the entities correspond to multiple managers of the blockchain account. Mutual supervision and balance control can be realized among the management parties, and block chain accounts are prevented from being abused.
Machine code can perform many more operations than bytecode, and thus is a relatively greater threat to the chain. For example, by tampering with the machine code of the smart contract, after the smart contract is invoked, the machine code may be executed to read private data stored on the blockchain node, such as private data in a Trusted Execution Environment (TEE) deployed on the blockchain node, and the like, and may even affect the normal operation of the blockchain node, and destroy the security and stability of the blockchain network. Thus, when the bytecode of the smart contract is included in the transaction for creating the smart contract, the blockchain link point may not restrict the originator account, so that the blockchain account corresponding to one entity may deploy the bytecode of the smart contract onto the blockchain; when the machine code of the intelligent contract is included in the transaction for creating the intelligent contract, the blockchain link points need to restrict the account of the initiator, and ensure that only blockchain accounts corresponding to a plurality of managers can deploy the machine code of the intelligent contract to the blockchain.
The block chain node can verify a plurality of signatures contained in the transaction through the public keys of the management parties corresponding to the management parties respectively, and determine that the transaction contains the signatures of the management parties when the signatures pass the verification. In the verification process, if the signature matched with the public key of the management party reaches a preset number, the transaction for creating the intelligent contract is considered to be approved by the management party corresponding to the account of the initiator, so that the machine code contained in the transaction is allowed to be deployed. The preset number may be a predefined fixed number, or the preset number may be dynamically changed according to the number of management parties. When the value of the preset number changes dynamically, for example, it can be ensured that the ratio of the preset number to the total number of the management side is not less than a preset ratio, and the preset ratio can be a certain predefined fixed value (e.g., 50%, 75%, or any other preset value). When the preset proportion is 100%, it indicates that the transaction needs to include signatures formed by all managers corresponding to the initiator account, that is, there needs to be one-to-one correspondence between the manager public key and the signature, and reference may be made to the embodiment shown in fig. 6. Assuming that the number of management parties is 4 and the preset ratio is 75%, the transaction should include at least 3 signatures of the management parties, and the block nodes are allowed to deploy the machine code included in the transaction. Optionally, the block node may further verify whether the signatures included in the transaction are all from the administrator, for example, when at least one signature cannot be verified by the public key of the administrator, even if the number of verified signatures reaches the preset number, it should be determined that there is a security risk, and the machine code included in the transaction is not deployed.
Optionally, the block link point may respectively obtain the number of the management party to which the account of the initiator belongs and the number of the signatures included in the transaction: if the number of the management parties of the account of the initiator is 1 or the number of the signatures contained in the transaction does not reach the preset number, the block chain node can directly judge that the signatures are not verified without performing the operation of verifying the signatures, the machine codes contained in the transaction are not allowed to be deployed, and the waste of related processing resources can be avoided. And only when the account of the initiator is determined to belong to a plurality of managers and the transaction contains a preset number of signatures, the blockchain node verifies the plurality of signatures contained in the transaction through the public keys of the managers respectively corresponding to the managers so as to further determine whether the signatures pass the verification.
The block chain node may execute the above processing logic based on chain code, including obtaining a public key of a manager to which the initiator account belongs, obtaining a signature included in the transaction, verifying the signature based on the public key of the manager, identifying the number of the public keys of the manager, identifying the number of the transaction, determining the relationship between the public keys of the manager and the number of the transaction, and the like. Alternatively, these processing logic may be implemented by a block chain node by invoking a pre-deployed system contract.
In a public, alliance, or private chain system of etherhouses and similar principles, block chain nodes may initiate consensus for a batch of transactions. The batch of transactions may include the transactions described above for creating smart contracts. After consensus, generally, each consensus node locally stores the machine code of the intelligent contract to be created. Each consensus node can locally execute the transaction for creating the intelligent contract and create a corresponding contract account; and creating an address for the contract account according to the same rule, wherein the addresses created by the consensus nodes for the same contract are the same. Thus, the contract deployment is completed.
Preferably, the storage is a cache, and the subsequent response can be made more quickly by caching the storage in a memory. Specifically, the memory may be a cache area opened in the virtual machine. Of course, even if the data is stored to a magnetic disk, the response speed can be improved to some extent in many cases.
After deployment of the intelligent contract is completed, a call to the contract may be provided. In this way, a client (possibly different from the client that initiated the create contract transaction in step A1) may initiate a call to the contract. For example, the client initiates a transaction, wherein the to field is the address of the smart contract deployed as described above, and the data field may include the method of the invoked contract and the entered parameters, thereby enabling invocation of the smart contract deployed. Generally, after a batch of transactions including the transaction of the invoking contract are identified, each identified node executes the transaction respectively. In the process of calling the contract by the block chain node, under the condition that the machine code of the intelligent contract is stored, the machine code can be directly executed by a CPU (under the control of an OS), so that the speed of executing the intelligent contract can be greatly increased by the block chain node. In addition, the execution speed of the intelligent contract can be further improved under the condition that the machine code of the intelligent contract is cached in the memory. Of course, even if stored in a magnetic disk, the execution speed can be raised to some extent. The block chain node executes the machine code, and specifically may execute a machine code corresponding to a called function in the stored contract.
The machine code in this specification may be applied to, in addition to EVM, a wasm (web assembly) Virtual machine, jsvm (javascript Virtual machine), and the like, and is not limited herein.
It should be noted that the block link points in step a1 may be different from the block link nodes in step a 2. This is because the blockchain acts as a distributed system, and the node receiving the transaction, the node initiating the consensus, and the node performing the transaction may be different nodes or, of course, the same node.
An embodiment of a block link point for deploying an intelligent contract, as shown in fig. 7, is described below, including:
a receiving unit 71, configured to receive a transaction for creating an intelligent contract, where the transaction includes a machine code of the intelligent contract, and the machine code is compiled from a bytecode of the intelligent contract through AoT;
a verification unit 72 for verifying whether an initiator account satisfying the transaction belongs to a plurality of managing parties, and the transaction includes signatures of the plurality of managing parties;
and the deployment unit 73 is used for completing the deployment of the intelligent contract under the condition that the account of the initiator of the transaction belongs to a plurality of managers and the transaction contains the signatures of the managers.
Optionally, compiling the bytecode of the intelligent contract into the machine code through AoT includes:
and performing AoT translation on the byte codes of the intelligent contracts to perform optimized compilation.
Optionally, compiling the bytecode of the intelligent contract into the machine code includes:
compiling byte codes of the intelligent contracts into the machine codes by the client submitting the transaction;
the block chain nodes compile byte codes of the intelligent contracts into the machine codes; or,
compiling byte code of the intelligent contract into the machine code at another block link node distinct from the block link node.
Alternatively to this, the first and second parts may,
the information of the management party to which the initiator belongs is recorded in the initiator account; or,
the mapping relationship between the information of the initiator account and the administrator is recorded in a system contract.
Optionally, the information of the multiple managers includes: and the plurality of managers respectively correspond to the manager public keys.
Optionally, the verification unit 72 is specifically configured to:
and verifying a plurality of signatures contained in the transaction through the public keys of the management parties respectively corresponding to the management parties, and determining that the transaction contains the signatures of the management parties when the signatures pass the verification.
Optionally, the method further includes:
a determining unit 74, configured to determine a management party to which the initiator account belongs and a signature included in the transaction, respectively;
when it is determined that the initiator account belongs to a plurality of managers, the transaction includes a plurality of signatures, and the number of the managers and the number of the signatures are consistent, the verifying unit 82 verifies the plurality of signatures included in the transaction through the manager public keys respectively corresponding to the managers.
Another block link point embodiment of deploying an intelligent contract described herein is presented as follows, including:
a receiving unit, configured to receive a transaction for creating an intelligent contract, where the transaction includes a machine code of the intelligent contract, and the machine code is obtained by compiling a bytecode of the intelligent contract through AoT;
the verification unit is used for verifying whether an initiator account meeting the transaction belongs to a plurality of management parties, and the transaction comprises the signatures of a preset number of the management parties;
and the deployment unit is used for finishing the deployment of the intelligent contract under the condition that the account of the initiator of the transaction belongs to a plurality of management parties and the transaction contains the signatures of the management parties in a preset quantity.
Optionally, a ratio of the preset number to the total number of the plurality of management parties is not less than a preset ratio.
Optionally, compiling the bytecode of the intelligent contract into the machine code through AoT includes:
and performing AoT translation on the byte codes of the intelligent contracts to perform optimized compilation.
Optionally, compiling the bytecode of the intelligent contract into the machine code includes:
compiling byte codes of the intelligent contracts into the machine codes by the client submitting the transaction;
the block chain nodes compile byte codes of the intelligent contracts into the machine codes; or,
compiling byte code of the intelligent contract into the machine code at another block link node distinct from the block link node.
Alternatively to this, the first and second parts may,
the information of the management party to which the initiator belongs is recorded in the initiator account; or,
the mapping relationship between the information of the initiator account and the administrator is recorded in a system contract.
Optionally, the information of the multiple managers includes: and the plurality of managers respectively correspond to the manager public keys.
Optionally, the verification unit is specifically configured to:
and verifying a plurality of signatures contained in the transaction through the public keys of the management parties respectively corresponding to the management parties, and determining that the transaction contains the signatures of the management parties when the signatures pass the verification.
Optionally, the method further includes:
a determining unit, configured to determine a management party to which the initiator account belongs and a signature included in the transaction, respectively;
the verification unit verifies a plurality of signatures contained in the transaction through public keys of management parties corresponding to the management parties respectively under the condition that the initiator account belongs to the management parties and the transaction contains the preset number of signatures.
The present description also provides a block link point embodiment, comprising:
a processor for processing the received data, wherein the processor is used for processing the received data,
a memory storing a program, wherein the smart contracts are deployed in the manner previously described when the program is executed by the processor.
The present specification also provides a storage medium embodiment for storing a program, wherein the program, when executed, performs the aforementioned method.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
In a typical configuration, a computer includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The terminology used in the description of the one or more embodiments is for the purpose of describing the particular embodiments only and is not intended to be limiting of the description of the one or more embodiments. As used in one or more embodiments of the present specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in one or more embodiments of the present description to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of one or more embodiments herein. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
The above description is only for the purpose of illustrating the preferred embodiments of the one or more embodiments of the present disclosure, and is not intended to limit the scope of the one or more embodiments of the present disclosure, and any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the one or more embodiments of the present disclosure should be included in the scope of the one or more embodiments of the present disclosure.

Claims (18)

1. A method of deploying an intelligent contract, comprising:
receiving a transaction for creating an intelligent contract by a blockchain node, wherein the transaction comprises a machine code of the intelligent contract, and the machine code is obtained by compiling a byte code of the intelligent contract through AoT;
and the blockchain node completes the deployment of the intelligent contract under the condition that the initiator account of the transaction belongs to a plurality of management parties and the transaction contains the signatures of the plurality of management parties.
2. The method of claim 1, compiling byte code of the intelligent contract into the machine code via AoT, comprising:
and performing AoT optimized compiling during the compiling process of the byte codes of the intelligent contracts.
3. The method of claim 1, compiling byte code of the smart contract into the machine code, comprising:
compiling byte codes of the intelligent contracts into the machine codes by the client submitting the transaction;
the block chain nodes compile byte codes of the intelligent contracts into the machine codes; or,
compiling byte code of the intelligent contract into the machine code at another block link node distinct from the block link node.
4. The method of claim 1, wherein the first and second light sources are selected from the group consisting of a red light source, a green light source, and a blue light source,
the information of the management party to which the initiator belongs is recorded in the initiator account; or,
the mapping relationship between the information of the initiator account and the administrator is recorded in a system contract.
5. The method of claim 4, the information of the plurality of managers comprising: and the plurality of managers respectively correspond to the manager public keys.
6. The method of claim 1, the block nexus determining that an initiator account for the transaction belongs to multiple management parties, and the transaction includes signatures for the multiple management parties, comprising:
and the block chain node verifies a plurality of signatures contained in the transaction through the public keys of the management parties respectively corresponding to the plurality of management parties, and determines that the transaction contains the signatures of the plurality of management parties under the condition that the signatures are verified.
7. The method of claim 6, further comprising:
the block chain node respectively determines a management party to which the initiator account belongs and a signature contained in the transaction;
and under the condition that the account of the initiator belongs to a plurality of managers, the transaction contains a plurality of signatures and the number of the managers and the number of the signatures are consistent, the blockchain node verifies the plurality of signatures contained in the transaction through the public keys of the managers respectively corresponding to the managers.
8. A method of deploying an intelligent contract, comprising:
receiving a transaction for creating an intelligent contract by a blockchain node, wherein the transaction comprises a machine code of the intelligent contract, and the machine code is obtained by compiling a byte code of the intelligent contract through AoT;
and the block chain node completes the deployment of the intelligent contract under the condition that the initiator account of the transaction belongs to a plurality of management parties and the transaction contains the signatures of the management parties in a preset number.
9. The method of claim 8, wherein a ratio of the preset number to a total number of the plurality of management parties is not less than a preset ratio.
10. The method of claim 8, compiling the bytecode of the intelligent contract into the machine code via AoT, comprising:
and performing AoT optimized compiling during the compiling process of the byte codes of the intelligent contracts.
11. The method of claim 8, compiling byte code of the smart contract into the machine code, comprising:
compiling byte codes of the intelligent contracts into the machine codes by the client submitting the transaction;
the block chain nodes compile byte codes of the intelligent contracts into the machine codes; or,
compiling byte code of the intelligent contract into the machine code at another block link node distinct from the block link node.
12. The method of claim 8, wherein the first and second light sources are selected from the group consisting of,
the information of the management party to which the initiator belongs is recorded in the initiator account; or,
the mapping relationship between the information of the initiator account and the administrator is recorded in a system contract.
13. The method of claim 12, the information of the plurality of managers comprising: and the plurality of managers respectively correspond to the manager public keys.
14. The method of claim 8, the block nexus determining that an originator account of the transaction belongs to multiple management parties, and the transaction contains a preset number of signatures of the management parties, comprising:
and the block chain node verifies a plurality of signatures contained in the transaction through the public keys of the management parties respectively corresponding to the plurality of management parties, and determines that the transaction contains the signatures of the plurality of management parties under the condition that the signatures are verified.
15. The method of claim 14, further comprising:
the block chain node respectively determines a management party to which the initiator account belongs and a signature contained in the transaction;
and under the condition that the account of the initiator belongs to a plurality of managers and the transaction contains the preset number of signatures, the blockchain node verifies the signatures contained in the transaction through the public keys of the managers respectively corresponding to the managers.
16. A blockchain node for deploying an intelligent contract, performing the method of any of the preceding claims 1-7 or 8-15.
17. A block link point for deploying an intelligent contract, comprising:
a processor for processing the received data, wherein the processor is used for processing the received data,
a memory storing a program, wherein the method of any of the above claims 1-7 or 8-15 is performed when the program is executed by the processor.
18. A storage medium storing a program, wherein the program when executed performs the operations of any of the above claims 1-7 or 8-15.
CN202010899212.3A 2020-08-31 2020-08-31 Method for deploying intelligent contract, block chain node and storage medium Pending CN111768200A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010899212.3A CN111768200A (en) 2020-08-31 2020-08-31 Method for deploying intelligent contract, block chain node and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010899212.3A CN111768200A (en) 2020-08-31 2020-08-31 Method for deploying intelligent contract, block chain node and storage medium

Publications (1)

Publication Number Publication Date
CN111768200A true CN111768200A (en) 2020-10-13

Family

ID=72729146

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010899212.3A Pending CN111768200A (en) 2020-08-31 2020-08-31 Method for deploying intelligent contract, block chain node and storage medium

Country Status (1)

Country Link
CN (1) CN111768200A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112583585A (en) * 2020-12-09 2021-03-30 杭州复杂美科技有限公司 Transaction execution method, apparatus and storage medium
CN112965729A (en) * 2021-03-23 2021-06-15 工银科技有限公司 Method, device, electronic equipment and medium for deploying intelligent contract of block chain by one key
CN113254054A (en) * 2021-06-09 2021-08-13 上海万向区块链股份公司 Intelligent contract one-stop development system and method
CN117349867A (en) * 2023-12-04 2024-01-05 成都峰潮信息技术有限公司 Intelligent contract deployment method, system, equipment and medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110096338A (en) * 2019-05-10 2019-08-06 百度在线网络技术(北京)有限公司 Intelligent contract executes method, apparatus, equipment and medium
CN111179086A (en) * 2019-12-31 2020-05-19 杭州趣链科技有限公司 Intelligent contract virtual machine based on WebAssembly
US20200219045A1 (en) * 2017-08-03 2020-07-09 Liquineq AG System and method for automotive inventory management and recordkeeping using multi-tiered distributed network transactional database

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200219045A1 (en) * 2017-08-03 2020-07-09 Liquineq AG System and method for automotive inventory management and recordkeeping using multi-tiered distributed network transactional database
CN110096338A (en) * 2019-05-10 2019-08-06 百度在线网络技术(北京)有限公司 Intelligent contract executes method, apparatus, equipment and medium
CN111179086A (en) * 2019-12-31 2020-05-19 杭州趣链科技有限公司 Intelligent contract virtual machine based on WebAssembly

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
ODAILY星球⽇报: "BM即将推出WASM解释器,目前已通过测试,解释执行和编译执行了解一下", 《36KRHTTPS://36KR.COM/P/1722795409409》 *
STARTEOS.IO: "什么是多重签名", 《知乎ZHUANLAN.ZHIHU.COM/P/ 67089563》 *
互联网: "在NEO区块链中部署NEP-5智能合约 (第1部分)", 《币界网HTTPS://WWW.528BTC.COM/COLLEGE/51159.HTML》 *
李辉忠等: "FISCO BCOS 技术应用实践", 《信息通信技术与政策》 *
白兴强: "FISCO BCOS 2.0原理解析:预编译合约架构设计", 《MY.OSCHINA.NET/FISCOBCOS/BLOG/4384678》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112583585A (en) * 2020-12-09 2021-03-30 杭州复杂美科技有限公司 Transaction execution method, apparatus and storage medium
CN112583585B (en) * 2020-12-09 2022-06-28 杭州复杂美科技有限公司 Transaction execution method, apparatus and storage medium
CN112965729A (en) * 2021-03-23 2021-06-15 工银科技有限公司 Method, device, electronic equipment and medium for deploying intelligent contract of block chain by one key
CN113254054A (en) * 2021-06-09 2021-08-13 上海万向区块链股份公司 Intelligent contract one-stop development system and method
CN113254054B (en) * 2021-06-09 2024-05-10 上海万向区块链股份公司 Intelligent contract one-stop development system and method
CN117349867A (en) * 2023-12-04 2024-01-05 成都峰潮信息技术有限公司 Intelligent contract deployment method, system, equipment and medium
CN117349867B (en) * 2023-12-04 2024-02-09 成都峰潮信息技术有限公司 Intelligent contract deployment method, system, equipment and medium

Similar Documents

Publication Publication Date Title
CN111770206B (en) Method for deploying intelligent contract, block chain node and storage medium
CN111770113B (en) Method for executing intelligent contract, block chain node and node equipment
CN111814202B (en) Method for executing intelligent contract, block chain node and storage medium
CN111768187A (en) Method for deploying intelligent contract, block chain node and storage medium
CN111770205B (en) Method, block chain node, system and storage medium for executing intelligent contract
CN111815330A (en) Method for deploying intelligent contract, block chain node and storage medium
CN111770204B (en) Method for executing intelligent contract, block chain node and storage medium
CN111768200A (en) Method for deploying intelligent contract, block chain node and storage medium
CN111815310B (en) Method for executing intelligent contract, block chain node and storage medium
CN111770116B (en) Method for executing intelligent contract, block chain node and storage medium
CN111768183B (en) Method for executing intelligent contract, block chain node and storage medium
CN111768184A (en) Method for executing intelligent contract and block link point
CN111770202B (en) Method for executing intelligent contract, block chain node and storage medium
CN113220326B (en) Intelligent contract upgrading method and block chain system
CN113220327B (en) Intelligent contract upgrading method and block chain 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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40039053

Country of ref document: HK

RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20201013