WO2022237590A1 - Smart contract upgrading method and blockchain system - Google Patents

Smart contract upgrading method and blockchain system Download PDF

Info

Publication number
WO2022237590A1
WO2022237590A1 PCT/CN2022/090384 CN2022090384W WO2022237590A1 WO 2022237590 A1 WO2022237590 A1 WO 2022237590A1 CN 2022090384 W CN2022090384 W CN 2022090384W WO 2022237590 A1 WO2022237590 A1 WO 2022237590A1
Authority
WO
WIPO (PCT)
Prior art keywords
contract
blockchain
bytecode
transaction
upgrade
Prior art date
Application number
PCT/CN2022/090384
Other languages
French (fr)
Chinese (zh)
Inventor
林志平
Original Assignee
支付宝(杭州)信息技术有限公司
蚂蚁区块链科技(上海)有限公司
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 支付宝(杭州)信息技术有限公司, 蚂蚁区块链科技(上海)有限公司 filed Critical 支付宝(杭州)信息技术有限公司
Publication of WO2022237590A1 publication Critical patent/WO2022237590A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45516Runtime code conversion or optimisation
    • G06F9/4552Involving translation to a different instruction set architecture, e.g. just-in-time translation in a JVM

Definitions

  • This manual relates to the blockchain field, in particular to a smart contract upgrade method and a blockchain system.
  • blockchain nodes in related technologies need to receive instruction information sent by users before they can perform corresponding operations.
  • the user needs to participate in at least two interactions, and the efficiency of contract upgrade is low.
  • one or more embodiments of this specification provide a smart contract upgrade method and a blockchain system.
  • a blockchain system including: a plurality of blockchain nodes; wherein, each blockchain node in the blockchain system obtains a The contract deployment transaction of the bytecode, and deploy the corresponding smart contract based on the contract deployment transaction; any blockchain node in the blockchain network JIT compiles the bytecode to obtain the smart contract machine code, and generate a contract upgrade transaction for the smart contract based on the machine code; all blockchain nodes in the blockchain network respectively obtain the contract upgrade transaction, and based on the contract upgrade transaction, The contract code corresponding to the smart contract is upgraded from the bytecode to the machine code.
  • Fig. 1 is a schematic diagram of the principle of compiling execution and interpreting execution in an embodiment.
  • Figure 2 is a schematic diagram illustrating execution and JIT in one embodiment.
  • Fig. 3 is a flow chart of a smart contract upgrade method shown in an exemplary embodiment of this specification.
  • Fig. 5 is an interaction diagram of a smart contract upgrade method shown in an exemplary embodiment of this specification.
  • first, second, third, etc. may be used in this specification to describe various information, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this specification, first information may also be called second information, and similarly, second information may also be called first information. Depending on the context, the word “if” as used herein may be interpreted as “at” or “when” or “in response to a determination.”
  • the blockchain 1.0 era usually refers to the development stage of blockchain applications represented by Bitcoin between 2009 and 2014. They are mainly dedicated to solving the decentralization of currency and means of payment. Beginning in 2014, developers have increasingly focused on addressing Bitcoin's technical and scalability deficiencies. At the end of 2013, Vitalik Buterin released the Ethereum white paper "Ethereum: Next-Generation Smart Contract and Decentralized Application Platform", which introduced smart contracts into the blockchain, opened up the application of the blockchain outside the currency field, and thus opened the blockchain Chain 2.0 era.
  • a smart contract is an automatically executable computer contract based on prescribed trigger rules, and can also be regarded as a digital version of a traditional contract.
  • the concept of smart contracts was first proposed by Nick Szabo, an interdisciplinary legal scholar and cryptography researcher, in 1994. This technology was once not used in the actual industry due to the lack of programmable digital systems and related technologies, until the emergence of blockchain technology and Ethereum provided a reliable execution environment for it. Due to the blockchain ledger adopted by the blockchain technology, the generated data cannot be tampered with or deleted, and the entire ledger will continue to add ledger data, thus ensuring the traceability of historical data; at the same time, the decentralized operating mechanism avoids central influence of cultural factors.
  • Smart contracts based on blockchain technology can not only give full play to the advantages of smart contracts in terms of cost and efficiency, but also prevent malicious behavior from interfering with the normal execution of contracts.
  • the smart contract is written into the blockchain in a digital form, and the characteristics of the blockchain technology ensure that the entire process of storage, reading, and execution is transparent, traceable, and tamper-proof.
  • a smart contract is essentially a program that can be executed by a computer.
  • Smart contracts like computer programs widely used today, can be written in high-level languages (such as C language, C++ language, etc.).
  • the program code of a smart contract written in a high-level language can generally be converted into a "machine code” that the computer's CPU can recognize and run through a “compiler”, and then the CPU can execute such machine code (or called “microprocessing"). device command”). This method is generally called “compilation and execution”.
  • Compilation and execution generally do not have cross-platform scalability. Because there are different manufacturers, different brands and different generations of CPUs, and the instruction sets supported by these different CPUs are different in many cases, such as the x86 instruction set, ARM instruction set, etc., and the same manufacturer of the same brand but different generations of CPUs ( For example, the instruction sets supported by different generations of Intel CPUs are not exactly the same. Therefore, the same program code written in the same high-level language may have different machine codes converted by compilers on different CPUs. Specifically, in the process of converting the program code written in the high-level language to the machine code, the compiler will combine the characteristics of the specific CPU instruction set (such as the vector instruction set, etc.) It is related to the specific CPU hardware.
  • the specific CPU instruction set such as the vector instruction set, etc.
  • the same machine code one can run on x86, but the other may not run on ARM; even the same x86 platform, with the passage of time, the instruction set is constantly enriched and expanded, which leads to different generation codes.
  • the machine code that the x86 platform runs is also different.
  • the execution of machine codes requires the CPU to be scheduled by the operating system kernel, even the same hardware may support different machine codes running under different operating systems.
  • the Java source code is compiled into a standard bytecode (bytecode) through a Java compiler.
  • the compiler does not target any actual hardware processor instruction set, but defines a set of abstract standard instruction sets.
  • the compiled standard bytecode generally cannot run directly on the hardware CPU, so a virtual machine, namely JVM, is introduced.
  • the JVM runs on a specific hardware processor to interpret and execute the compiled standard bytecode.
  • JVM is the abbreviation of Java Virtual Machine (Java Virtual Machine). It is a fictional computer, which is often realized by simulating various computer functions on an actual computer. JVM shields information related to specific hardware platforms, operating systems, etc., so that Java programs only need to be generated standard bytecodes that can run on Java virtual machines, and can run on multiple platforms without modification.
  • Java virtual machine A very important feature of the Java language is its independence from the platform.
  • the use of Java virtual machine is the key to realize this feature. If a general high-level language is to be run on different platforms, at least it needs to be compiled into different object codes. After the introduction of the Java language virtual machine, the Java language does not need to be recompiled when running on different platforms.
  • the Java language uses the Java virtual machine to shield the information related to the specific platform, so that the Java language compiler only needs to generate the object code (byte code) that runs on the Java virtual machine, and it can run on various platforms without modification. .
  • the Java virtual machine executes the bytecode, it interprets the bytecode into machine instructions on a specific platform for execution. This is why Java can "compile once, run everywhere".
  • the JVM runs on a specific hardware processor, is responsible for interpreting and executing the bytecode for the specific processor it is running on, and shields these underlying differences upwards, presenting standard development specifications to developers.
  • the JVM executes the bytecode, it actually interprets the bytecode into machine instructions on a specific platform for execution. Specifically, after the JVM receives the input bytecode, it interprets each instruction sentence by sentence, and translates it into a machine code suitable for the current machine to run. These processes are interpreted and executed by an interpreter called Interpreter, for example. In this way, developers who write Java programs do not need to consider which hardware platform the written program code will run on.
  • the development of the JVM itself is done by professional developers of the Java organization to adapt the JVM to different processor architectures.
  • Figure 1 shows the similarities and differences between compiled execution and interpreted execution. Regardless of whether it is interpreted or compiled, or whether it is a physical machine or a virtual machine, it is impossible for a machine to read and understand an application program like a human, and then obtain the ability to execute it. Most of the program code needs to go through the steps in Figure 1 before reaching the target code of the physical machine or the instruction set that the virtual machine can execute.
  • the branch from the top to the left in Figure 1 is the generation process from the program code to the target machine code in the traditional compilation principle, and the branch from the top to the right is the process of interpretation and execution.
  • HLLVM High-Level Language Virtual Machine
  • the source code is processed by lexical analysis and syntax analysis, and the source code is converted into an abstract syntax tree (Abstract SyntaxTree, AST).
  • lexical analysis, syntax analysis, and subsequent optimizers and object code generators can be selected independently of the execution engine to form a complete compiler for implementation.
  • This type of representative is C/C++ language. It is also possible to choose to implement some of the steps (such as the steps before generating the abstract syntax tree) as a semi-independent compiler, which is represented by the Java language. Or these steps and the execution engine are all encapsulated in a closed black box, such as most JavaScript executors.
  • JIT Just-In-TimeCompiler
  • a core module in JIT technology is "hot spot analysis", that is, to analyze which codes have been executed multiple times during program execution, so as to cache the translated machine code. For operations that are executed infrequently, no caching is required. This achieves the best balance between execution efficiency and memory overhead.
  • JIT technology another core module in JIT technology is compilation optimization (or called optimized compilation).
  • compilation optimization or called optimized compilation.
  • the directly translated machine code is not optimized in combination with the context, but only caches the high-frequency machine code, and the performance improvement is limited. If you want to get better performance, you can make further optimizations to the compiler. The way of compiling optimization generally takes relatively more time to implement.
  • JIT Java bytecode
  • the Java source code is compiled by the Java compiler to generate a piece of Java bytecode, which is distributed to two execution paths (JIT Compiler and Interpreter) after hotspot analysis.
  • the code judged as a hotspot is compiled by the JIT compiler to obtain machine code, cached and executed, and is generally executed by the CPU under the control of the operating system (OS).
  • OS operating system
  • the low frequency enters the interpreter (Interpreter), and after being translated into machine code, it is executed by the CPU under the control of the OS.
  • JIT compiler compilation may be time-consuming.
  • JIT Compiler may take a long time in the process of compiling bytecode for the first time, which is not even as good as interpreting and executing. Then, for some java programs, if the hot spots are not very prominent, that is, the overall execution frequency is not very high, and the overall execution process is very long, it will be difficult for JIT to take advantage of compilation and execution.
  • JIT compilation has become an important means to improve the efficiency of program execution.
  • due to the consistency requirements of blockchain technology for each node "how to integrate JIT compilation into the blockchain, To improve the execution efficiency of smart contracts" has become an urgent problem in the blockchain field.
  • smart contracts in the blockchain are usually compiled by users themselves, and deployed by sending contract deployment transactions. Furthermore, when it is necessary to upgrade the deployed smart contract, it is necessary to further send a contract upgrade transaction to each blockchain node, so that each blockchain node can upgrade the deployed bytecode to the machine code compiled by JIT . It can be seen that in the process of contract deployment and contract upgrade, related technologies require users to interact with blockchain nodes multiple times, and the efficiency of contract upgrade is low.
  • this manual proposes a smart contract upgrade method, so that when JIT compilation is applied to blockchain technology, it does not need to occupy a large amount of blockchain processing resources, nor does it require users to interact with blockchain nodes multiple times .
  • Fig. 3 is a flow chart of a smart contract upgrade method shown in an exemplary embodiment of this specification.
  • the method may include the following steps: Step 302, all blockchain nodes in the blockchain network respectively obtain contract deployment transactions containing bytecodes, and deploy corresponding smart contracts based on the contract deployment transactions.
  • this specification needs to prioritize the deployment of bytecodes of smart contracts.
  • users can compile the bytecode of the smart contract by themselves, and send a contract deployment request to the client they use, so that the client generates a contract deployment transaction based on the bytecode.
  • the client can send the generated contract deployment transaction to any blockchain node, so that any blockchain node can implement a transaction consensus on the contract deployment transaction, so that after the consensus is passed, each blockchain node will separately The bytecode contained therein is deployed.
  • each blockchain node needs to JIT compile the bytecode by itself, which takes up more blockchain processing. resource.
  • the deployed bytecode needs to be upgraded, the user also needs to send an upgrade instruction for the smart contract to the blockchain node, which reduces the efficiency of the contract upgrade.
  • the JIT compilation is performed by each blockchain node in the related technology, when the user sends an upgrade instruction, he needs to send an upgrade instruction to each blockchain node to ensure that each blockchain node
  • the contract upgrade operation can be completed. It can be seen that this method not only increases the number of interactions, but also occupies a large amount of transmission resources.
  • each blockchain node no longer executes JIT compilation separately, but a node in the blockchain network performs JIT compilation, and then sends the compiled machine code to the blockchain
  • Each blockchain node in the network so that each blockchain node does not need to perform JIT compilation operations separately, reducing the occupation of blockchain processing resources during the JIT compilation process.
  • this manual no longer controls the contract upgrade operation by the user, but by After the blockchain node completes the JIT compilation, it will upgrade the deployed bytecode to machine code by itself.
  • Step 304 the first blockchain node in the blockchain network performs JIT compilation on the bytecode to obtain the machine code of the smart contract, and generates a contract for the smart contract based on the machine code Upgrade deals.
  • the aforementioned blockchain node responsible for JIT compiling the smart contract is referred to as the first blockchain node.
  • the first blockchain node can determine whether to perform JIT compilation on the smart contract in the contract deployment transaction according to actual needs.
  • the first block chain node may, after receiving the instruction information sent by the user for instructing to compile the bytecode of the smart contract into machine
  • the section code is JIT compiled to obtain the machine code of the smart contract.
  • the process of JIT compilation is controlled by the user, which improves the controllability of the contract upgrade.
  • the first blockchain node may, upon receiving a smart contract deployment transaction, determine whether the smart contract transaction contains an indication flag for instructing to compile the bytecode of the smart contract into machine code , and JIT-compile the bytecode contained in the contract deployment transaction when the indication is included.
  • the user only needs to add a corresponding indicator in the contract deployment transaction to inform the first blockchain node that "the bytecode in the contract deployment transaction needs to be JIT compiled", without the need to Send additional instructions.
  • the first blockchain node may determine whether to JIT compile the bytecode in the contract deployment transaction according to the initiator of the contract deployment transaction or the type of business data contained in the contract deployment transaction. Specifically, the first blockchain node can JIT compile the bytecode in the contract deployment transaction when it is determined that the received contract deployment transaction is initiated by a predefined specific user; or, the first blockchain node When the node determines that the business data contained in the received contract deployment transaction belongs to a predefined business type, it can perform JIT compilation on the bytecode in the contract deployment transaction.
  • timing for performing JIT compilation can also be determined according to actual conditions.
  • the first blockchain node may start to JIT compile the bytecode of the smart contract after determining that the bytecode of the smart contract is deployed. This method is equivalent to sequentially executing bytecode deployment and bytecode JIT compilation.
  • the first blockchain node may use relatively idle time to perform JIT compilation on the bytecode of the smart contract when it is determined that the bytecode of the smart contract has been deployed.
  • the bytecode of the smart contract can be JIT compiled when the first blockchain node does not need to process transactions.
  • the JIT compilation for bytecode and contract deployment operations can be performed in parallel.
  • the first blockchain node can simultaneously perform JIT compilation on the bytecode in the contract deployment transaction.
  • the machine code of the smart contract can be quickly obtained, and then the deployed bytecode can be upgraded in a timely manner.
  • the first blockchain node when the first blockchain node JIT compiles the bytecode of the smart contract, it can compile all bytecodes in the contract deployment transaction; or, the first blockchain node can use JIT compilation
  • the characteristics of the hotspot analysis of the bytecode in the contract deployment transaction are given priority, and then the hotspot bytecode determined by the hotspot analysis (bytecode executed frequently) is compiled; or, due to the contract code itself Relevance, there is usually a large room for optimization. Therefore, when the first blockchain node performs JIT compilation on the bytecode of the smart contract, it can optimize the compilation of the bytecode contained in the contract deployment transaction to improve the compilation. The resulting machine code execution efficiency.
  • Step 306 all blockchain nodes in the blockchain network respectively obtain the contract upgrade transaction, and based on the contract upgrade transaction, upgrade the contract code corresponding to the smart contract from the bytecode to the machine code.
  • the smart contracts deployed in the blockchain are usually compiled by users themselves, and the deployment is completed by submitting contract deployment transactions. In other words, the ownership of the smart contract belongs to the individual user. Therefore, in related technologies, after the blockchain node compiles the smart contract into machine code, the user usually needs to send an upgrade instruction to the corresponding blockchain node to indicate that the bytecode is allowed to be upgraded to machine code.
  • the block chain node can perform the operation of upgrading the deployed bytecode to machine code.
  • each blockchain node needs to perform JIT compilation operations separately, when sending an upgrade instruction, the user also needs to send an upgrade instruction to each blockchain node, which takes up a lot of transmission resources.
  • the first blockchain node in this manual can obtain the contract upgrade authorization of the sender of the contract deployment transaction in advance, so that the first blockchain node can generate the The contract upgrade transaction of the machine code, and then upgrade the deployed bytecode.
  • the user after compiling the bytecode, the user usually sends the contract deployment transaction containing the bytecode to any node in the blockchain network to deploy the smart contract.
  • the blockchain nodes responsible for JIT compilation are usually not fixed. Therefore, users usually grant contract upgrade authorization to all nodes in the blockchain network, so that when any node is responsible for JIT compilation, contract upgrade transactions can be generated based on the compiled machine code.
  • the blockchain network is usually maintained by the provider of the blockchain technology (also known as the platform that provides the blockchain technology). Therefore, in the actual authorization process, the user only needs to grant the provider the contract upgrade authorization, which is equivalent to granting the contract upgrade authorization to each node in the blockchain network.
  • smart contracts deployed in the blockchain network may be invoked by users at any time.
  • the smart contract may not have been upgraded and is still deployed in the corresponding contract address in the form of bytecode; it may also have been upgraded and deployed in the form of machine code in the corresponding contract address. It should be understood that for smart contracts deployed in different forms, calls need to be made in different ways.
  • the second blockchain node in the blockchain network receives an invocation transaction for a smart contract
  • all nodes in the blockchain network can conduct a transaction consensus on the invocation transaction, and if the consensus is passed , all blockchain nodes can determine the contract address of the smart contract to be called according to the call transaction, so as to obtain the contract code of the called smart contract through the contract address.
  • the obtained contract code is a bytecode
  • each blockchain node can interpret and execute the bytecode to realize the call of the smart contract; and when the obtained contract code is a machine code Under this condition, each blockchain node can directly execute the obtained machine code.
  • the third block chain node may be the same node as the first block chain node, or may be a different node.
  • What needs to be declared is that when the obtained contract code is machine code, it is not necessary to execute all the obtained machine codes, but the machine code to be executed can be determined according to the called function/code block contained in the calling transaction . In other words, only the machine code corresponding to the called function/code block in the acquired contract code of the smart contract can be executed.
  • the chain code run by each blockchain node usually contains Contract upgrade logic code
  • the contract upgrade logic code is used to generate a contract upgrade transaction for the smart contract when it is determined that the JIT compilation has been completed, so as to upgrade the deployed contract code from bytecode to machine through the contract upgrade transaction code.
  • the technical solution of this specification is applied to the BaaS architecture, it is equivalent to the first blockchain node being installed in a virtual machine.
  • the JIT compilation service can be pre-deployed in the virtual machine corresponding to the first blockchain node. Used to JIT compile the bytecode of the smart contract.
  • the blockchain network in this specification obtains the contract deployment transaction, on the one hand, it deploys the bytecode in the contract deployment transaction to each blockchain node;
  • the first blockchain node of JIT compiles the bytecode in the contract deployment transaction to obtain the machine code of the corresponding smart contract.
  • the first blockchain node can send the contract upgrade transaction containing the compiled machine code to each blockchain node after the JIT compilation has been completed, so that each blockchain node can Upgrade deployed bytecode to machine code.
  • the blockchain nodes in this manual can obtain the contract upgrade authorization granted by the user in advance, so that the blockchain nodes in this manual can generate contract upgrade transactions based on the compiled machine code after JIT compilation is completed. , and then complete the contract upgrade operation for smart contracts, avoiding the need for users to send upgrade instructions to each blockchain node in related technologies, and then solving the problem of low upgrade efficiency due to the large number of interactions in related technologies , and the problem of occupying a large amount of transmission resources.
  • this specification also proposes a blockchain system.
  • the blockchain system is used to implement the above solution, and most of the operation methods are similar to the previous embodiment. How to perform JIT compilation, how to generate contract upgrade transactions, etc., can refer to the introduction of the previous embodiment, and will not be discussed in the next embodiment. repeat.
  • Figure 4 is a block chain system shown in an exemplary embodiment of this specification, as shown in Figure 4, the block chain system 4 includes: a plurality of block chain nodes; wherein, in the block chain system Each block chain node respectively obtains the contract deployment transaction containing the bytecode, and deploys the corresponding smart contract based on the contract deployment transaction; any block chain node in the block chain network executes the bytecode JIT compilation to obtain the machine code of the smart contract, and generate a contract upgrade transaction for the smart contract based on the machine code; all blockchain nodes in the blockchain network respectively obtain the contract upgrade transaction, And based on the contract upgrade transaction, the contract code corresponding to the smart contract is upgraded from the bytecode to the machine code.
  • this specification needs to prioritize the deployment of the bytecode of the smart contract.
  • users can compile the bytecode of the smart contract by themselves, and send a contract deployment request to the client they use, so that the client generates a contract deployment transaction based on the bytecode.
  • the client can send the generated contract deployment transaction to any blockchain node in the blockchain system 4, so that any blockchain node can achieve a transaction consensus on the contract deployment transaction, and after the consensus is passed, the Each blockchain node deploys the bytecode contained therein respectively.
  • the blockchain node responsible for JIT compiling the smart contract in this specification can be any node in the blockchain system.
  • any blockchain node may be node 41 in FIG. 4 , that is, node 41 is the first blockchain node in the previous embodiment.
  • the first blockchain node may, after receiving the instruction information sent by the above-mentioned user for instructing to compile the bytecode of the smart contract into machine code, then deploy the bytecode contained in the above-mentioned contract The code is JIT compiled to obtain the machine code of the smart contract.
  • the first blockchain node may, upon receiving the smart contract deployment transaction, determine whether the smart contract transaction contains an instruction flag for instructing the bytecode of the smart contract to be compiled into machine code, and If the flag is indicated, JIT compiles the bytecode contained in the contract deployment transaction.
  • the first blockchain node may determine whether to JIT-compile the bytecode in the contract deployment transaction according to the initiator of the contract deployment transaction or the type of business data contained in the contract deployment transaction.
  • the first blockchain node can start to JIT compile the bytecode of the smart contract after determining that the bytecode of the smart contract is deployed.
  • the first blockchain node can also use relatively free time to JIT compile the bytecode of the smart contract when it is determined that the bytecode of the smart contract has been deployed.
  • the blockchain nodes in this manual can obtain the contract upgrade authorization of the sender of the contract deployment transaction in advance, so that after the blockchain node completes the JIT compilation for the smart contract, it can generate the compiled machine code by itself.
  • the contract upgrade transaction of and then upgrade the deployed bytecode.
  • smart contracts deployed in the blockchain system may be invoked by users at any time.
  • the smart contract may not have been upgraded and is still deployed in the corresponding contract address in the form of bytecode; it may also have been upgraded and deployed in the form of machine code in the corresponding contract address.
  • the second blockchain node in the blockchain network receives an invocation transaction for a smart contract, all nodes in the blockchain network can conduct a transaction consensus on the invocation transaction, and if the consensus is passed , all blockchain nodes can determine the contract address of the smart contract to be called according to the call transaction, so as to obtain the contract code of the called smart contract through the contract address.
  • each blockchain node when the obtained contract code is a bytecode, each blockchain node can interpret and execute the bytecode to realize the call of the smart contract; and when the obtained contract code is a machine code Under this condition, each blockchain node can directly execute the obtained machine code.
  • the second block chain node can be the same node as the first block chain node, such as node 41; the second block chain node can also be a different node from the first block chain node, such as Node 42.
  • the above-mentioned blockchain system can be based on the traditional architecture of blockchain technology, that is, all blockchain nodes in the blockchain system are formed by deploying blockchain codes on corresponding physical devices, and in most cases Next, each node corresponds to a physical device; the above blockchain system can also be based on the BaaS (Blockchain as a Service) architecture in blockchain technology, that is, all nodes in the blockchain system are distributed in the cloud through cloud services. It is formed by deploying the blockchain code on the realized virtual machine, and the blockchain nodes do not need to correspond to the corresponding physical devices one by one.
  • the blockchain system in this specification deploys the bytecode in the contract deployment transaction to each blockchain node on the one hand;
  • the included first blockchain node performs JIT compilation on the bytecode in the contract deployment transaction to obtain the machine code of the corresponding smart contract.
  • the first blockchain node can send the contract upgrade transaction containing the compiled machine code to each blockchain node after JIT compilation is completed, so that each blockchain node can respectively Deployed bytecode is upgraded to machine code. In this manner, the problem of wasting blockchain processing resources caused by the need to perform JIT compilation in each blockchain node in the related art is avoided.
  • the first blockchain node can obtain the contract upgrade authorization granted by the user in advance, so that the blockchain node in this manual can generate the contract upgrade transaction based on the machine code obtained by JIT compilation after the JIT compilation is completed, and then Upgrading the deployed bytecode to machine code avoids the problem of occupying a large amount of transmission resources in related technologies that require users to send upgrade instructions to each blockchain node.
  • Fig. 5 is an interaction diagram of a smart contract upgrade method shown in an exemplary embodiment of this specification.
  • the method may include the following steps: Step 501, the client sends a contract deployment transaction to the first blockchain node in the blockchain network.
  • the user can compile the bytecode of the smart contract to be deployed on the client used by the user. After compiling the bytecode of the smart contract, the user can initiate a deployment instruction for the smart contract to the client, so that the client can generate a contract deployment transaction based on the bytecode of the smart contract under the instruction of the deployment instruction.
  • the client may contain a contract deployment control, so that the user can initiate a contract deployment request to the client through the control.
  • the contract deployment transaction can be generated based on the bytecode compiled by the user , and send it to the first blockchain node in the blockchain network, so as to deploy the bytecode of the smart contract to each blockchain node through the first blockchain node.
  • the first blockchain node is any node in the blockchain network.
  • Step 502 the first blockchain node and other nodes in the blockchain network conduct a transaction consensus on the contract deployment transaction, so that each blockchain node deploys the bytecode contained in the contract deployment transaction.
  • the first blockchain node After the first blockchain node receives the contract deployment transaction, it needs to give priority to the transaction consensus on the contract deployment transaction, and if the consensus is passed, then send the contract deployment transaction to each blockchain Nodes, so that the bytecode contained in the transaction is deployed by each blockchain node.
  • Step 503 the first blockchain node performs JIT compilation on the bytecode in the contract deployment transaction to obtain the corresponding machine code.
  • the JIT compilation can be performed while the bytecode of the smart contract is being deployed; or the JIT compilation can be performed after the bytecode of the smart contract is compiled.
  • how to JIT compile the bytecode of the smart contract can be determined by those skilled in the art according to actual needs.
  • Step 504 the first blockchain node generates a contract upgrade transaction based on the compiled machine code.
  • the blockchain network is maintained by the provider of the blockchain technology, and the user can pre-grant the provider "contract upgrade authorization for smart contracts", so that any block in the blockchain network After the chain node completes the JIT compilation of the bytecode of the smart contract, it can generate a contract upgrade transaction based on the machine code obtained by JIT compilation.
  • this embodiment is only introduced by taking the first blockchain node in charge of JIT compilation to be responsible for generating contract upgrade transactions as an example.
  • the blockchain node responsible for generating contract upgrade transactions and the blockchain node responsible for JIT compilation can also be different nodes. Specifically, after the first blockchain node completes JIT compilation, it can convert the compiled The machine code is sent to the blockchain node responsible for generating the contract upgrade transaction, so that the blockchain node generates the contract upgrade transaction.
  • the provider of the blockchain technology can set up a server for the blockchain network to maintain the blockchain network through the server. On this basis, the user can only grant the server contract upgrade authorization.
  • the first blockchain node After the first blockchain node completes JIT compilation, it can also send the compiled machine code to the server, so that the server is responsible for generating contract upgrade transactions. Specifically how to generate a contract upgrade transaction can be determined by those skilled in the art according to the actual situation.
  • Step 505 the first blockchain node and other nodes in the blockchain network conduct a transaction consensus on the contract upgrade transaction, so that each blockchain node upgrades the deployed bytecode to the machine code contained in the contract upgrade transaction .
  • the first blockchain node after the first blockchain node generates a contract upgrade transaction, it can conduct transaction consensus with other nodes in the blockchain network, and when the consensus is passed, the contract upgrade transaction is sent to other nodes , so that each blockchain node replaces the deployed bytecode in the contract address with the machine code in the contract upgrade transaction, and then completes the upgrade for the smart contract.
  • the blockchain node After the user sends the compiled smart contract to the blockchain node, on the one hand, the blockchain node will conduct a transaction consensus with other nodes on the contract deployment transaction containing the smart contract, so that when the consensus is passed Next, each blockchain node deploys the bytecode of the smart contract; on the other hand, the blockchain node JIT compiles the bytecode to obtain the machine code of the smart contract.
  • the blockchain node has obtained the user's contract upgrade authorization in advance, so that the blockchain node can directly generate a contract upgrade transaction based on the compiled machine code after completing the JIT compilation, so that the deployed The bytecode is upgraded to the compiled machine code.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions
  • the device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
  • Memory may include non-permanent storage in computer-readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer readable media.
  • RAM random access memory
  • ROM read-only memory
  • flash RAM flash random access memory
  • Computer-readable media including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information.
  • 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 Disc (DVD) or other optical storage, Magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by computing devices.
  • computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
  • one or more embodiments of this specification may be provided as a method, system or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of the present description may employ a computer program embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein. The form of the product.
  • program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types.
  • program modules may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network.
  • program modules may be located in both local and remote computer storage media including storage devices.

Abstract

A smart contract upgrading method and a blockchain node. The method comprises: all blockchain nodes in a blockchain network respectively obtain a contract deployment transaction comprising a bytecode, and deploy a corresponding smart contract on the basis of the contract deployment transaction (302); a first blockchain node in the blockchain network performs JIT compilation on the bytecode to obtain a machine code of the smart contract, and generates a contract upgrade transaction for the smart contract on the basis of the machine code (304); all the blockchain nodes in the blockchain network respectively obtain the contract upgrade transaction, and upgrade, on the basis of the contract upgrade transaction, a contract code corresponding to the smart contract from the bytecode to the machine code (306).

Description

智能合约升级方法及区块链系统Smart contract upgrade method and blockchain system 技术领域technical field
本说明书涉及区块链领域,特别涉及一种智能合约升级方法及区块链系统。This manual relates to the blockchain field, in particular to a smart contract upgrade method and a blockchain system.
背景技术Background technique
区块链技术(也被称为,分布式账本技术)是一种去中心化的分布式数据库技术,具有去中心化、公开透明、不可篡改、可信任等多种特点,适用于诸多对数据可靠性具有高需求的应用场景中。而JIT(Just-In-TimeCompiler,即时编译)则是一种能够提高程序代码执行效率的编译方式。如何将JIT编译应用于区块链,以提高智能合约的执行效率,已成为亟待解决的技术问题。Blockchain technology (also known as distributed ledger technology) is a decentralized distributed database technology, which has many characteristics such as decentralization, openness and transparency, non-tamperable, and trustworthy, and is suitable for many In application scenarios with high reliability requirements. And JIT (Just-In-Time Compiler, just-in-time compilation) is a compilation method that can improve the efficiency of program code execution. How to apply JIT compilation to the blockchain to improve the execution efficiency of smart contracts has become an urgent technical problem to be solved.
相关技术在将JIT编译应用至区块链时,通常需要在将智能合约的字节码部署至各个区块链节点后,由各个区块链节点自行对字节码进行JIT编译,并将已部署的字节码升级为编译得到的机器码。由于这种方式需要各个区块链节点分别对字节码进行JIT编译,占用了大量区块链处理资源。Related technologies When applying JIT compilation to the blockchain, it is usually necessary to JIT-compile the bytecode by each blockchain node after deploying the bytecode of the smart contract to each blockchain node, and then The deployed bytecode is upgraded to compiled machine code. Since this method requires each blockchain node to JIT-compile the bytecode separately, it takes up a lot of blockchain processing resources.
除此之外,相关技术中的区块链节点在部署智能合约和升级智能合约时,均需在接收到用户发送的指示信息的情况下,才能执行相应的操作。换言之,由合约的部署操作到合约的升级操作,用户至少需要参与两次交互,合约升级的效率较低。In addition, when deploying smart contracts and upgrading smart contracts, blockchain nodes in related technologies need to receive instruction information sent by users before they can perform corresponding operations. In other words, from the deployment operation of the contract to the upgrade operation of the contract, the user needs to participate in at least two interactions, and the efficiency of contract upgrade is low.
发明内容Contents of the invention
有鉴于此,本说明书一个或多个实施例提供一种智能合约升级方法及区块链系统。In view of this, one or more embodiments of this specification provide a smart contract upgrade method and a blockchain system.
本说明书一个或多个实施例提供技术方案如下:根据本说明书一个或多个实施例的第一方面,提出了一种智能合约升级方法,包括:区块链网络中的所有区块链节点分别获取包含字节码的合约部署交易,并基于所述合约部署交易部署相应的智能合约;所述区块链网络中的第一区块链节点对所述字节码进行JIT编译,得到所述智能合约的机器码,并基于所述机器码生成针对所述智能合约的合约升级交易;所述区块链网络中的所有区块链节点分别获取所述合约升级交易,并基于所述合约升级交易将所述智能合约对应的合约代码由所述字节码升级为所述机器码。One or more embodiments of this specification provide technical solutions as follows: According to the first aspect of one or more embodiments of this specification, a smart contract upgrade method is proposed, including: all blockchain nodes in the blockchain network are respectively Obtain a contract deployment transaction containing bytecode, and deploy a corresponding smart contract based on the contract deployment transaction; the first blockchain node in the blockchain network JIT compiles the bytecode to obtain the The machine code of the smart contract, and generate a contract upgrade transaction for the smart contract based on the machine code; all blockchain nodes in the blockchain network respectively obtain the contract upgrade transaction, and based on the contract upgrade The transaction upgrades the contract code corresponding to the smart contract from the bytecode to the machine code.
根据本说明书一个或多个实施例的第二方面,提出了一种区块链系统,包括:多个区块链节点;其中,所述区块链系统中的各个区块链节点分别获取包含字节码的合约部 署交易,并基于所述合约部署交易部署相应的智能合约;所述区块链网络中的任一区块链节点对所述字节码进行JIT编译,得到所述智能合约的机器码,并基于所述机器码生成针对所述智能合约的合约升级交易;所述区块链网络中的所有区块链节点分别获取所述合约升级交易,并基于所述合约升级交易将所述智能合约对应的合约代码由所述字节码升级为所述机器码。According to the second aspect of one or more embodiments of this specification, a blockchain system is proposed, including: a plurality of blockchain nodes; wherein, each blockchain node in the blockchain system obtains a The contract deployment transaction of the bytecode, and deploy the corresponding smart contract based on the contract deployment transaction; any blockchain node in the blockchain network JIT compiles the bytecode to obtain the smart contract machine code, and generate a contract upgrade transaction for the smart contract based on the machine code; all blockchain nodes in the blockchain network respectively obtain the contract upgrade transaction, and based on the contract upgrade transaction, The contract code corresponding to the smart contract is upgraded from the bytecode to the machine code.
附图说明Description of drawings
图1是一实施例中编译执行和解释执行的原理示意图。Fig. 1 is a schematic diagram of the principle of compiling execution and interpreting execution in an embodiment.
图2是一实施例中解释执行和JIT的原理示意图。Figure 2 is a schematic diagram illustrating execution and JIT in one embodiment.
图3是本说明书一示例性实施例示出的一种智能合约升级方法的流程图。Fig. 3 is a flow chart of a smart contract upgrade method shown in an exemplary embodiment of this specification.
图4是本说明书一示例性实施例示出的一种区块链系统。Fig. 4 is a blockchain system shown in an exemplary embodiment of this specification.
图5是本说明书一示例性实施例示出的一种智能合约升级方法的交互图。Fig. 5 is an interaction diagram of a smart contract upgrade method shown in an exemplary embodiment of this specification.
具体实施方式Detailed ways
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本说明书相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本说明书的一些方面相一致的装置和方法的例子。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, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with this specification. Rather, they are merely examples of apparatuses and methods consistent with aspects of the present specification as recited in the appended claims.
在本说明书使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本说明书。在本说明书和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。The terms used in this specification are for the purpose of describing particular embodiments only, and are not intended to limit the specification. As used in this specification and the appended claims, the singular forms "a", "the", and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It should also be understood that the term "and/or" as used herein refers to and includes 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 this specification to describe various information, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this specification, first information may also be called second information, and similarly, second information may also be called first information. Depending on the context, the word "if" as used herein may be interpreted as "at" or "when" or "in response to a determination."
区块链1.0时代通常是指在2009年到2014年之间,以比特币为代表的区块链应用发展阶段,它们主要致力于解决货币和支付手段的去中心化问题。从2014年开始,开 发者们越来越注重于解决比特币在技术和扩展性方面的不足。2013年底,VitalikButerin发布了以太坊白皮书《以太坊:下一代智能合约和去中心化应用平台》,将智能合约引入区块链,打开了区块链在货币领域以外的应用,从而开启了区块链2.0时代。The blockchain 1.0 era usually refers to the development stage of blockchain applications represented by Bitcoin between 2009 and 2014. They are mainly dedicated to solving the decentralization of currency and means of payment. Beginning in 2014, developers have increasingly focused on addressing Bitcoin's technical and scalability deficiencies. At the end of 2013, Vitalik Buterin released the Ethereum white paper "Ethereum: Next-Generation Smart Contract and Decentralized Application Platform", which introduced smart contracts into the blockchain, opened up the application of the blockchain outside the currency field, and thus opened the blockchain Chain 2.0 era.
智能合约是一种基于规定触发规则的,可自动执行的计算机合约,也可以看作是传统合约的数字版本。智能合约这一概念最早由跨领域法律学者、密码学研究工作者尼克·萨博(NickSzabo)在1994年提出。这项技术曾一度因为缺乏可编程数字系统和相关技术而没有被用于实际产业中,直到区块链技术和以太坊的出现为其提供了可靠的执行环境。由于区块链技术采用的块链式账本,产生的数据不可篡改或者删除,且整个账本将不断新增账本数据,从而保证了历史数据的可追溯;同时,去中心化的运行机制避免了中心化因素的影响。基于区块链技术的智能合约不仅可以发挥智能合约在成本、效率方面的优势,而且可以避免恶意行为对合约正常执行的干扰。将智能合约以数字化的形式写入区块链中,由区块链技术的特性保障存储、读取、执行整个过程透明可跟踪、不可篡改。A smart contract is an automatically executable computer contract based on prescribed trigger rules, and can also be regarded as a digital version of a traditional contract. The concept of smart contracts was first proposed by Nick Szabo, an interdisciplinary legal scholar and cryptography researcher, in 1994. This technology was once not used in the actual industry due to the lack of programmable digital systems and related technologies, until the emergence of blockchain technology and Ethereum provided a reliable execution environment for it. Due to the blockchain ledger adopted by the blockchain technology, the generated data cannot be tampered with or deleted, and the entire ledger will continue to add ledger data, thus ensuring the traceability of historical data; at the same time, the decentralized operating mechanism avoids central influence of cultural factors. Smart contracts based on blockchain technology can not only give full play to the advantages of smart contracts in terms of cost and efficiency, but also prevent malicious behavior from interfering with the normal execution of contracts. The smart contract is written into the blockchain in a digital form, and the characteristics of the blockchain technology ensure that the entire process of storage, reading, and execution is transparent, traceable, and tamper-proof.
智能合约本质上是一段可由计算机执行的程序。智能合约与现在广泛使用的计算机程序一样,可以通过高级语言(例如C语言、C++语言等)编写而成。由高级语言编写好的智能合约的程序代码,一般可以通过“编译器”转换为计算机的CPU可以识别和运行的“机器码”,进而可以由CPU执行这样的机器码(或者称为“微处理器指令”)。这种方式一般称为“编译执行”。A smart contract is essentially a program that can be executed by a computer. Smart contracts, like computer programs widely used today, can be written in high-level languages (such as C language, C++ language, etc.). The program code of a smart contract written in a high-level language can generally be converted into a "machine code" that the computer's CPU can recognize and run through a "compiler", and then the CPU can execute such machine code (or called "microprocessing"). device command"). This method is generally called "compilation and execution".
编译执行一般不具有跨平台的可扩展性。由于存在不同厂商、不同品牌和不同代的CPU,而这些不同的CPU支持的指令集很多情况下是不同的,如x86指令集,ARM指令集等,且同一厂商同一品牌但不同代的CPU(如不同代的IntelCPU)支持的指令集也不完全相同,因此,用同样的高级语言编写的同样的程序代码,在不同CPU上被编译器转换出来的机器码可能不同。具体的,编译器在转换高级语言编写的程序代码到机器码的过程中,会结合具体的CPU指令集的特点(如向量指令集等)进行优化以提升程序执行的速度,而此类优化往往与具体的CPU硬件相关。这样,同样的机器码,一个在x86上可以运行,但另一个在ARM上就可能无法运行;甚至同样是x86平台,随着时间的推移,指令集也不断丰富和扩展,这就导致不同代的x86平台运行的机器码也有不同。而且,由于执行机器码需要由操作系统内核对CPU进行调度,因此即使是同样的硬件,在不同操作系统下支持运行的机器码也可能不同。Compilation and execution generally do not have cross-platform scalability. Because there are different manufacturers, different brands and different generations of CPUs, and the instruction sets supported by these different CPUs are different in many cases, such as the x86 instruction set, ARM instruction set, etc., and the same manufacturer of the same brand but different generations of CPUs ( For example, the instruction sets supported by different generations of Intel CPUs are not exactly the same. Therefore, the same program code written in the same high-level language may have different machine codes converted by compilers on different CPUs. Specifically, in the process of converting the program code written in the high-level language to the machine code, the compiler will combine the characteristics of the specific CPU instruction set (such as the vector instruction set, etc.) It is related to the specific CPU hardware. In this way, the same machine code, one can run on x86, but the other may not run on ARM; even the same x86 platform, with the passage of time, the instruction set is constantly enriched and expanded, which leads to different generation codes. The machine code that the x86 platform runs is also different. Moreover, since the execution of machine codes requires the CPU to be scheduled by the operating system kernel, even the same hardware may support different machine codes running under different operating systems.
不同于编译执行,还存在一种“解释执行”的程序运行方式。比如Java语言,将Java 源代码通过Java的编译器编译成标准的字节码(bytecode),这里编译器不针对任何实际的硬件处理器的指令集,而是定义了一套抽象的标准指令集。编译成的标准字节码一般无法在硬件CPU上直接运行,因此引入了一个虚拟机,即JVM,JVM运行在特定的硬件处理器上,用以解释和执行编译后的标准字节码。Different from compilation and execution, there is also a program running mode of "interpretation and execution". For example, in the Java language, the Java source code is compiled into a standard bytecode (bytecode) through a Java compiler. Here, the compiler does not target any actual hardware processor instruction set, but defines a set of abstract standard instruction sets. . The compiled standard bytecode generally cannot run directly on the hardware CPU, so a virtual machine, namely JVM, is introduced. The JVM runs on a specific hardware processor to interpret and execute the compiled standard bytecode.
JVM是Java Virtual Machine(Java虚拟机)的缩写,是一种虚构出来的计算机,往往通过在实际的计算机上仿真模拟各种计算机功能来实现。JVM屏蔽了与具体的硬件平台、操作系统等相关的信息,使Java程序只需要是生成的可在Java虚拟机上运行的标准字节码,就可以在多种平台上不加修改地运行。JVM is the abbreviation of Java Virtual Machine (Java Virtual Machine). It is a fictional computer, which is often realized by simulating various computer functions on an actual computer. JVM shields information related to specific hardware platforms, operating systems, etc., so that Java programs only need to be generated standard bytecodes that can run on Java virtual machines, and can run on multiple platforms without modification.
Java语言的一个非常重要的特点就是与平台的无关性。而使用Java虚拟机是实现这一特点的关键。一般的高级语言如果要在不同的平台上运行,至少需要编译成不同的目标代码。而引入Java语言虚拟机后,Java语言在不同平台上运行时不需要重新编译。Java语言使用Java虚拟机屏蔽了与具体平台相关的信息,使得Java语言编译程序只需生成在Java虚拟机上运行的目标代码(字节码),就可以在多种平台上不加修改地运行。Java虚拟机在执行字节码时,把字节码解释成具体平台上的机器指令执行。这就是Java的能够“一次编译,到处运行”的原因。A very important feature of the Java language is its independence from the platform. The use of Java virtual machine is the key to realize this feature. If a general high-level language is to be run on different platforms, at least it needs to be compiled into different object codes. After the introduction of the Java language virtual machine, the Java language does not need to be recompiled when running on different platforms. The Java language uses the Java virtual machine to shield the information related to the specific platform, so that the Java language compiler only needs to generate the object code (byte code) that runs on the Java virtual machine, and it can run on various platforms without modification. . When the Java virtual machine executes the bytecode, it interprets the bytecode into machine instructions on a specific platform for execution. This is why Java can "compile once, run everywhere".
JVM运行在特定的硬件处理器上,负责针对所运行的特定处理器而进行字节码的解释和执行,并向上屏蔽这些底层的差异,呈现给开发者以标准的开发规范。JVM在执行字节码时,实际上最终还是把字节码解释成具体平台上的机器指令执行。具体的,JVM接收到输入的字节码后,逐句解释其中的每一条指令,并翻译成适合当前机器的机器码来运行,这些过程例如由称为Interpreter的解释器进行解释和执行。这样一来,编写Java程序的开发者不需要考虑编写后的程序代码将运行在哪种硬件平台上。JVM本身的开发是由Java组织的专业开发人员完成,以将JVM适配到不同的处理器架构上。迄今为止,主流的处理器架构只有有限的几种,如X86,ARM,RISC-V,MIPS。专业的开发人员将JVM分别移植到支持这几种特定硬件的平台后,Java程序理论上就可以在所有的机器上运行了。JVM的移植工作通常由Java开发组织专业的人员提供的,这就极大减轻了Java应用开发者的负担。The JVM runs on a specific hardware processor, is responsible for interpreting and executing the bytecode for the specific processor it is running on, and shields these underlying differences upwards, presenting standard development specifications to developers. When the JVM executes the bytecode, it actually interprets the bytecode into machine instructions on a specific platform for execution. Specifically, after the JVM receives the input bytecode, it interprets each instruction sentence by sentence, and translates it into a machine code suitable for the current machine to run. These processes are interpreted and executed by an interpreter called Interpreter, for example. In this way, developers who write Java programs do not need to consider which hardware platform the written program code will run on. The development of the JVM itself is done by professional developers of the Java organization to adapt the JVM to different processor architectures. So far, there are only a limited number of mainstream processor architectures, such as X86, ARM, RISC-V, and MIPS. After professional developers port the JVM to platforms that support these specific hardware, Java programs can theoretically run on all machines. The transplantation of JVM is usually provided by professional personnel of Java development organization, which greatly reduces the burden of Java application developers.
解释执行带来了跨平台可移植性,但由于bytecode的执行经历了JVM中间翻译的过程,因此执行效率不如上述编译执行效率高,这种效率的差异有时甚至可达几十倍。Interpretation execution brings cross-platform portability, but because the execution of bytecode has gone through the process of JVM intermediate translation, the execution efficiency is not as high as the above-mentioned compilation execution efficiency, and the difference in efficiency can sometimes even reach dozens of times.
图1示出了编译执行和解释执行的共同点和不同点。不论是解释执行还是编译执行,也不论是物理机还是虚拟机,对于应用程序,机器都不可能如人那样阅读、理解,然后 就获得了执行能力。大部分的程序代码到物理机的目标代码或虚拟机能执行的指令集之前,都需要经过图1中的各个步骤。图1中从顶部到左边的那条分支就是传统编译原理中程序代码到目标机器代码的生成过程,从顶部到右边的那条分支是解释执行的过程。如今,基于物理机、Java虚拟机,或者非Java的其他高级语言虚拟机(High-Level Language VirtualMachine,HLLVM)的语言,大多都会遵循这种基于现代经典编译原理的思路,在执行前先对程序源码进行词法分析和语法分析处理,把源码转化为抽象语法树(Abstract SyntaxTree,AST)。对于一门具体语言的实现来说,词法分析、语法分析以至后面的优化器和目标代码生成器都可以选择独立于执行引擎,形成一个完整意义的编译器去实现,这类代表是C/C++语言。也可以选择把其中一部分步骤(如生成抽象语法树之前的步骤)实现为一个半独立的编译器,这类代表是Java语言。又或者把这些步骤和执行引擎全部集中封装在一个封闭的黑匣子之中,如大多数的JavaScript执行器。Figure 1 shows the similarities and differences between compiled execution and interpreted execution. Regardless of whether it is interpreted or compiled, or whether it is a physical machine or a virtual machine, it is impossible for a machine to read and understand an application program like a human, and then obtain the ability to execute it. Most of the program code needs to go through the steps in Figure 1 before reaching the target code of the physical machine or the instruction set that the virtual machine can execute. The branch from the top to the left in Figure 1 is the generation process from the program code to the target machine code in the traditional compilation principle, and the branch from the top to the right is the process of interpretation and execution. Nowadays, languages based on physical machines, Java virtual machines, or other non-Java high-level language virtual machines (High-Level Language Virtual Machine, HLLVM) mostly follow this idea based on modern classic compilation principles, and compile the program before execution. The source code is processed by lexical analysis and syntax analysis, and the source code is converted into an abstract syntax tree (Abstract SyntaxTree, AST). For the implementation of a specific language, lexical analysis, syntax analysis, and subsequent optimizers and object code generators can be selected independently of the execution engine to form a complete compiler for implementation. This type of representative is C/C++ language. It is also possible to choose to implement some of the steps (such as the steps before generating the abstract syntax tree) as a semi-independent compiler, which is represented by the Java language. Or these steps and the execution engine are all encapsulated in a closed black box, such as most JavaScript executors.
为了尽可能地兼顾跨平台可移植性和高性能,即时编译器(Just-In-TimeCompiler,JIT)的概念被提出。JIT的核心思想是“如何高效避免解释指令的重复工作”。计算机程序中存在大量重复执行的代码,比如某些计算“函数”在一个程序执行过程中可能被循环调用了很多次。如果是解释执行,则循环过程的每次执行都要对这个函数进行字节码到机器码的翻译。然而实际情况是,这个函数在几十次的翻译中产生的机器码都是完全一样的。很自然的,在第一次翻译后,将翻译好的函数的机器码缓存下来,后续再次执行的过程中,不需要再次翻译,而是直接使用缓存好的代码,这样可以提高执行效率。In order to take into account cross-platform portability and high performance as much as possible, the concept of just-in-time compiler (Just-In-TimeCompiler, JIT) was proposed. The core idea of JIT is "how to efficiently avoid the repeated work of interpreting instructions". There are a lot of codes that are repeatedly executed in computer programs. For example, some calculation "functions" may be called repeatedly many times during the execution of a program. If it is interpreted execution, each execution of the loop process needs to translate the function from bytecode to machine code. However, the actual situation is that the machine code generated by this function in dozens of translations is exactly the same. Naturally, after the first translation, the machine code of the translated function is cached. In the process of subsequent re-execution, there is no need to translate again, but the cached code is directly used, which can improve execution efficiency.
相反的,有些函数在程序运行周期过程中只执行了一次(比如启动初始化),那么这类函数就不需要缓存,直接解释执行一次即可。因此JIT技术中一个核心的模块就是“热点分析”,即通过程序执行过程中分析出哪些代码执行了多次,从而对其翻译后的机器码进行缓存。对于执行次数较少的操作,不需要进行缓存。这样可以在执行效率和内存开销上达到最佳平衡。On the contrary, some functions are executed only once during the program running cycle (such as startup initialization), then such functions do not need to be cached, and can be directly interpreted and executed once. Therefore, a core module in JIT technology is "hot spot analysis", that is, to analyze which codes have been executed multiple times during program execution, so as to cache the translated machine code. For operations that are executed infrequently, no caching is required. This achieves the best balance between execution efficiency and memory overhead.
此外,JIT技术中的另一个核心的模块是编译优化(或称为优化编译)。直接翻译的机器码,没有结合上下文进行优化,仅仅是将高频的机器码缓存下来,性能提升有限。如果要获得更好的性能,可以对编译器进行进一步的优化。编译优化的方式,一般需要相对更多的时间来实现。In addition, another core module in JIT technology is compilation optimization (or called optimized compilation). The directly translated machine code is not optimized in combination with the context, but only caches the high-frequency machine code, and the performance improvement is limited. If you want to get better performance, you can make further optimizations to the compiler. The way of compiling optimization generally takes relatively more time to implement.
JIT的工作原理例如图2中所示。Java源代码经过Java编译器编译后生成一段Java字节码,经过热点分析后被分发到两个执行路径上(JIT Compiler和Interpreter)。被判断为热点(高频执行)的代码经JIT compiler中进行编译得到机器码,缓存并执行,一 般是由CPU在操作系统(OperatingSystem,OS)的控制下执行。低频的进入解释器(Interpreter),翻译成机器码后由CPU在OS的控制下执行。The working principle of JIT is shown in Figure 2 for example. The Java source code is compiled by the Java compiler to generate a piece of Java bytecode, which is distributed to two execution paths (JIT Compiler and Interpreter) after hotspot analysis. The code judged as a hotspot (high-frequency execution) is compiled by the JIT compiler to obtain machine code, cached and executed, and is generally executed by the CPU under the control of the operating system (OS). The low frequency enters the interpreter (Interpreter), and after being translated into machine code, it is executed by the CPU under the control of the OS.
由于程序代码本身的前后关联性,编译过程往往存在较大的优化空间。优化后的机器码,执行效率会远高于直接翻译的机器码。如果要获得更好的性能,编译器的优化是必须的。JIT compiler编译的过程可能比较耗时。特别是JIT Compiler在第一次编译字节码的过程可能耗时很长,甚至不如解释执行。那么,对于某些java程序,如果热点不是很突出,即整体的执行频度都不是很高,而整体执行流程又很长的,JIT就很难发挥出编译执行的优势。Due to the contextuality of the program code itself, there is often a large room for optimization in the compilation process. The optimized machine code has much higher execution efficiency than the directly translated machine code. If you want to get better performance, compiler optimization is a must. The process of JIT compiler compilation may be time-consuming. In particular, JIT Compiler may take a long time in the process of compiling bytecode for the first time, which is not even as good as interpreting and executing. Then, for some java programs, if the hot spots are not very prominent, that is, the overall execution frequency is not very high, and the overall execution process is very long, it will be difficult for JIT to take advantage of compilation and execution.
鉴于上述优势,在区块链之外,JIT编译已经成为提升程序执行效率的一种重要手段,但由于区块链技术对各个节点的一致性要求,“如何将JIT编译集成至区块链,以提升智能合约的执行效率”已经成为区块链领域亟待解决的问题。In view of the above advantages, outside the blockchain, JIT compilation has become an important means to improve the efficiency of program execution. However, due to the consistency requirements of blockchain technology for each node, "how to integrate JIT compilation into the blockchain, To improve the execution efficiency of smart contracts" has become an urgent problem in the blockchain field.
在相关技术中,若需要对区块链网络中的智能合约进行JIT编译,通常需要在将智能合约的字节码部署至各个区块链节点后,由各个区块链节点自行进行JIT编译,并在JIT编译完成后,将已部署的字节码升级为JIT编译得到的机器码。由于这种方式需要各个区块链节点分别对字节码进行JIT编译,占用了大量区块链处理资源。In related technologies, if it is necessary to JIT compile the smart contract in the blockchain network, it is usually necessary for each blockchain node to perform JIT compilation after deploying the bytecode of the smart contract to each blockchain node. And after the JIT compilation is completed, the deployed bytecode is upgraded to the machine code obtained by JIT compilation. Since this method requires each blockchain node to JIT-compile the bytecode separately, it takes up a lot of blockchain processing resources.
除此之外,区块链中智能合约,通常由用户自行编译后,通过发送合约部署交易的方式完成部署。进一步的,在需要对已部署的智能合约进行升级时,还需进一步向各个区块链节点发送合约升级交易,以便各个区块链节点将已部署的字节码升级为JIT编译得到的机器码。可见,相关技术在合约部署和合约升级的过程中,需要用户与区块链节点进行多次交互,合约升级的效率较低。In addition, smart contracts in the blockchain are usually compiled by users themselves, and deployed by sending contract deployment transactions. Furthermore, when it is necessary to upgrade the deployed smart contract, it is necessary to further send a contract upgrade transaction to each blockchain node, so that each blockchain node can upgrade the deployed bytecode to the machine code compiled by JIT . It can be seen that in the process of contract deployment and contract upgrade, related technologies require users to interact with blockchain nodes multiple times, and the efficiency of contract upgrade is low.
为此,本说明书提出了一种智能合约升级方法,使得在将JIT编译应用于区块链技术时,既无需占用大量的区块链处理资源,也无需用户与区块链节点进行多次交互。For this reason, this manual proposes a smart contract upgrade method, so that when JIT compilation is applied to blockchain technology, it does not need to occupy a large amount of blockchain processing resources, nor does it require users to interact with blockchain nodes multiple times .
图3是本说明书一示例性实施例示出的一种智能合约升级方法的流程图。该方法可以包括以下步骤:步骤302,区块链网络中的所有区块链节点分别获取包含字节码的合约部署交易,并基于所述合约部署交易部署相应的智能合约。Fig. 3 is a flow chart of a smart contract upgrade method shown in an exemplary embodiment of this specification. The method may include the following steps: Step 302, all blockchain nodes in the blockchain network respectively obtain contract deployment transactions containing bytecodes, and deploy corresponding smart contracts based on the contract deployment transactions.
与相关技术相类似的是,本说明书需要优先对智能合约的字节码进行部署。在实际操作中,用户可以自行编译智能合约的字节码,并通过向自身使用的客户端发送合约部署请求的方式,使客户端基于该字节码生成合约部署交易。客户端可以将生成的合约部署交易发送至任一区块链节点,以使该任一区块链节点对该合约部署交易进行交易共识, 以在共识通过后,由各个区块链节点分别对其中包含的字节码进行部署。Similar to related technologies, this specification needs to prioritize the deployment of bytecodes of smart contracts. In actual operation, users can compile the bytecode of the smart contract by themselves, and send a contract deployment request to the client they use, so that the client generates a contract deployment transaction based on the bytecode. The client can send the generated contract deployment transaction to any blockchain node, so that any blockchain node can implement a transaction consensus on the contract deployment transaction, so that after the consensus is passed, each blockchain node will separately The bytecode contained therein is deployed.
由上述内容可知,在相关技术中,在各个区块链节点对字节码完成部署后,各个区块链节点需要自行对该字节码进行JIT编译,致使占用了较多的区块链处理资源。除此之外,在需要对已部署的字节码进行升级时,用户还需额外向区块链节点发送针对智能合约的升级指示,降低了合约升级的效率。其中,需要指出的是,由于相关技术中由各个区块链节点分别执行JIT编译,因此,用户在发送升级指示时,需要向各个区块链节点分别发送升级指示,以保证各个区块链节点均能完成合约升级操作。可见,该方式不仅增加了交互次数,还占用了大量传输资源。From the above content, we can see that in related technologies, after each blockchain node deploys the bytecode, each blockchain node needs to JIT compile the bytecode by itself, which takes up more blockchain processing. resource. In addition, when the deployed bytecode needs to be upgraded, the user also needs to send an upgrade instruction for the smart contract to the blockchain node, which reduces the efficiency of the contract upgrade. Among them, it should be pointed out that since the JIT compilation is performed by each blockchain node in the related technology, when the user sends an upgrade instruction, he needs to send an upgrade instruction to each blockchain node to ensure that each blockchain node The contract upgrade operation can be completed. It can be seen that this method not only increases the number of interactions, but also occupies a large amount of transmission resources.
有鉴于此,本说明书中不再由各个区块链节点分别执行JIT编译,而是由区块链网络中的某一节点在执行JIT编译后,再将编译得到的机器码发送至区块链网络中的各个区块链节点,以使各个区块链节点无需分别执行JIT编译操作,减少了JIT编译过程对区块链处理资源的占用。同时,为了避免用户与区块链节点之间的交互次数较多,而导致升级效率较低的问题,以及占用传输资源较多的问题,本说明书不再由用户控制合约升级操作,而是由区块链节点在完成JIT编译后,自行将已部署的字节码升级为机器码。In view of this, in this manual, each blockchain node no longer executes JIT compilation separately, but a node in the blockchain network performs JIT compilation, and then sends the compiled machine code to the blockchain Each blockchain node in the network, so that each blockchain node does not need to perform JIT compilation operations separately, reducing the occupation of blockchain processing resources during the JIT compilation process. At the same time, in order to avoid the problem of low upgrade efficiency due to the high number of interactions between the user and the blockchain node, and the problem of occupying more transmission resources, this manual no longer controls the contract upgrade operation by the user, but by After the blockchain node completes the JIT compilation, it will upgrade the deployed bytecode to machine code by itself.
步骤304,所述区块链网络中的第一区块链节点对所述字节码进行JIT编译,得到所述智能合约的机器码,并基于所述机器码生成针对所述智能合约的合约升级交易。 Step 304, the first blockchain node in the blockchain network performs JIT compilation on the bytecode to obtain the machine code of the smart contract, and generates a contract for the smart contract based on the machine code Upgrade deals.
在本说明书中,将上述负责对智能合约进行JIT编译的区块链节点称为第一区块链节点。In this specification, the aforementioned blockchain node responsible for JIT compiling the smart contract is referred to as the first blockchain node.
在实际应用中,并非所有的智能合约均需要被编译为机器码。因此,第一区块链节点可以根据实际需求确定是否对合约部署交易中的智能合约进行JIT编译。In practice, not all smart contracts need to be compiled into machine code. Therefore, the first blockchain node can determine whether to perform JIT compilation on the smart contract in the contract deployment transaction according to actual needs.
在一实施例中,第一区块链节点可以在接收到用户发送的用于指示将智能合约的字节码编译为机器码的指示信息的情况下,再对上述合约部署交易中包含的字节码进行JIT编译,以得到智能合约的机器码。在该实施例中,相当于由用户控制JIT编译的过程,提高了合约升级的可控性。In an embodiment, the first block chain node may, after receiving the instruction information sent by the user for instructing to compile the bytecode of the smart contract into machine The section code is JIT compiled to obtain the machine code of the smart contract. In this embodiment, the process of JIT compilation is controlled by the user, which improves the controllability of the contract upgrade.
在另一实施例中,第一区块链节点可以在接收到智能合约部署交易的情况下,判断该智能合约交易中是否包含用于指示将智能合约的字节码编译为机器码的指示标识,并在包含该指示标识的情况下,对合约部署交易中包含的字节码进行JIT编译。在该实施例中,用户只需在合约部署交易中添加相应的指示标识即可告知第一区块链节点“该合约部署交易中的字节码需要进行JIT编译”,而无需如上一实施例额外发送指示信息。In another embodiment, the first blockchain node may, upon receiving a smart contract deployment transaction, determine whether the smart contract transaction contains an indication flag for instructing to compile the bytecode of the smart contract into machine code , and JIT-compile the bytecode contained in the contract deployment transaction when the indication is included. In this embodiment, the user only needs to add a corresponding indicator in the contract deployment transaction to inform the first blockchain node that "the bytecode in the contract deployment transaction needs to be JIT compiled", without the need to Send additional instructions.
在又一实施例中,第一区块链节点可以根据合约部署交易的发起方或者合约部署交易中包含的业务数据的类型,判断是否需要对合约部署交易中的字节码进行JIT编译。具体的,第一区块链节点可以在确定接收到的合约部署交易由预定义的特定用户发起的情况下,对该合约部署交易中的字节码进行JIT编译;或者,第一区块链节点可以在确定接收到的合约部署交易中包含的业务数据属于预定义的业务类型的情况下,对该合约部署交易中的字节码进行JIT编译。In yet another embodiment, the first blockchain node may determine whether to JIT compile the bytecode in the contract deployment transaction according to the initiator of the contract deployment transaction or the type of business data contained in the contract deployment transaction. Specifically, the first blockchain node can JIT compile the bytecode in the contract deployment transaction when it is determined that the received contract deployment transaction is initiated by a predefined specific user; or, the first blockchain node When the node determines that the business data contained in the received contract deployment transaction belongs to a predefined business type, it can perform JIT compilation on the bytecode in the contract deployment transaction.
在本说明书中,还可以根据实际情况确定执行JIT编译的时机。In this specification, the timing for performing JIT compilation can also be determined according to actual conditions.
在一实施例中,第一区块链节点可以在确定智能合约的字节码被部署完成后,开始对智能合约的字节码进行JIT编译。该方式相当于依次执行字节码的部署和字节码的JIT编译。In an embodiment, the first blockchain node may start to JIT compile the bytecode of the smart contract after determining that the bytecode of the smart contract is deployed. This method is equivalent to sequentially executing bytecode deployment and bytecode JIT compilation.
在另一实施例中,第一区块链节点可以在确定智能合约的字节码被部署完成的情况下,利用相对空闲的时间对智能合约的字节码进行JIT编译。例如,可以在第一区块链节点无需处理交易时,对该智能合约的字节码进行JIT编译。In another embodiment, the first blockchain node may use relatively idle time to perform JIT compilation on the bytecode of the smart contract when it is determined that the bytecode of the smart contract has been deployed. For example, the bytecode of the smart contract can be JIT compiled when the first blockchain node does not need to process transactions.
在又一实施例中,针对字节码的JIT编译和合约部署操作可以并行执行。换言之,合约部署交易中的字节码在被部署至各个区块链节点的过程中,第一区块链节点可以同时对合约部署交易中的字节码进行JIT编译。在该实施例中,由于两个操作并行执行,可以快速获得智能合约的机器码,进而更及时地对已部署的字节码进行合约升级。In yet another embodiment, the JIT compilation for bytecode and contract deployment operations can be performed in parallel. In other words, when the bytecode in the contract deployment transaction is deployed to each blockchain node, the first blockchain node can simultaneously perform JIT compilation on the bytecode in the contract deployment transaction. In this embodiment, since the two operations are executed in parallel, the machine code of the smart contract can be quickly obtained, and then the deployed bytecode can be upgraded in a timely manner.
在本说明书中,第一区块链节点在对智能合约的字节码进行JIT编译时,可以对合约部署交易中的所有字节码进行编译;或者,第一区块链节点可以利用JIT编译的特性,优先对合约部署交易中的字节码进行热点分析,再对通过热点分析确定出的热点字节码(高频执行的字节码)进行编译;再或者,由于合约代码本身的前后关联性,通常有较大的优化空间,因此,第一区块链节点可以在对智能合约的字节码进行JIT编译时,对合约部署交易中包含的字节码进行优化编译,以提高编译得到的机器码的执行效率。In this specification, when the first blockchain node JIT compiles the bytecode of the smart contract, it can compile all bytecodes in the contract deployment transaction; or, the first blockchain node can use JIT compilation The characteristics of the hotspot analysis of the bytecode in the contract deployment transaction are given priority, and then the hotspot bytecode determined by the hotspot analysis (bytecode executed frequently) is compiled; or, due to the contract code itself Relevance, there is usually a large room for optimization. Therefore, when the first blockchain node performs JIT compilation on the bytecode of the smart contract, it can optimize the compilation of the bytecode contained in the contract deployment transaction to improve the compilation. The resulting machine code execution efficiency.
步骤306,所述区块链网络中的所有区块链节点分别获取所述合约升级交易,并基于所述合约升级交易将所述智能合约对应的合约代码由所述字节码升级为所述机器码。 Step 306, all blockchain nodes in the blockchain network respectively obtain the contract upgrade transaction, and based on the contract upgrade transaction, upgrade the contract code corresponding to the smart contract from the bytecode to the machine code.
需要声明的是,正如上文所述:区块链中部署的智能合约,通常由用户自行编译后,通过递交合约部署交易的方式完成部署。换言之,智能合约的归属权属于用户个人。因此,在相关技术中,在区块链节点将智能合约编译为机器码后,通常需要用户向相应的区块链节点发送用于表征允许将字节码升级为机器码的升级指示后,区块链节点才能执 行将已部署的字节码升级为机器码的操作。然而,在相关技术中,由于需要各个区块链节点分别执行JIT编译的操作,因此,在发送升级指示时,也需要用户向各个区块链节点分别发送升级指示,占用了大量的传输资源。What needs to be declared is that, as mentioned above: the smart contracts deployed in the blockchain are usually compiled by users themselves, and the deployment is completed by submitting contract deployment transactions. In other words, the ownership of the smart contract belongs to the individual user. Therefore, in related technologies, after the blockchain node compiles the smart contract into machine code, the user usually needs to send an upgrade instruction to the corresponding blockchain node to indicate that the bytecode is allowed to be upgraded to machine code. The block chain node can perform the operation of upgrading the deployed bytecode to machine code. However, in related technologies, since each blockchain node needs to perform JIT compilation operations separately, when sending an upgrade instruction, the user also needs to send an upgrade instruction to each blockchain node, which takes up a lot of transmission resources.
为此,本说明书中的第一区块链节点可以预先获取合约部署交易发送方的合约升级授权,以便第一区块链节点在完成针对智能合约的JIT编译后,即可自行生成包含编译得到的机器码的合约升级交易,进而对已部署的字节码进行升级。For this reason, the first blockchain node in this manual can obtain the contract upgrade authorization of the sender of the contract deployment transaction in advance, so that the first blockchain node can generate the The contract upgrade transaction of the machine code, and then upgrade the deployed bytecode.
应当理解的是,在实际操作中,用户在完成字节码的编译后,通常是将包含字节码的合约部署交易发送至区块链网络中的任一节点,以进行智能合约的部署。换言之,负责JIT编译的区块链节点通常不是固定的。因此,用户通常会将合约升级授权授予区块链网络中的所有节点,以使在由任一节点负责JIT编译时,均可基于编译得到的机器码生成合约升级交易。It should be understood that in actual operation, after compiling the bytecode, the user usually sends the contract deployment transaction containing the bytecode to any node in the blockchain network to deploy the smart contract. In other words, the blockchain nodes responsible for JIT compilation are usually not fixed. Therefore, users usually grant contract upgrade authorization to all nodes in the blockchain network, so that when any node is responsible for JIT compilation, contract upgrade transactions can be generated based on the compiled machine code.
在实际操作中,区块链网络通常由区块链技术的提供方(也被称为提供区块链技术的平台方)进行维护。因此,在实际的授权过程中,用户只需授予该提供方合约升级授权即可,相当于给区块链网络中的各个节点均授予了合约升级授权。In practice, the blockchain network is usually maintained by the provider of the blockchain technology (also known as the platform that provides the blockchain technology). Therefore, in the actual authorization process, the user only needs to grant the provider the contract upgrade authorization, which is equivalent to granting the contract upgrade authorization to each node in the blockchain network.
在本说明书中,区块链网络中的任一区块链节点在将字节码升级为机器码时,需要优先确定智能合约的合约地址,再将合约地址对应的已部署的字节码替换为机器码,以实现智能合约的升级。In this manual, when any blockchain node in the blockchain network upgrades the bytecode to machine code, it needs to first determine the contract address of the smart contract, and then replace the deployed bytecode corresponding to the contract address It is the machine code to realize the upgrade of the smart contract.
在实际应用中,区块链网络中部署的智能合约随时都有可能被用户调用。而在已部署的智能合约被调用时,该智能合约既有可能尚未进行升级,仍以字节码的形式被部署于相应的合约地址中;也有可能已经被升级,以机器码的形式被部署于相应的合约地址中。应当理解的是,对于以不同形式部署的智能合约,需要通过不同的方式进行调用。In practical applications, smart contracts deployed in the blockchain network may be invoked by users at any time. When the deployed smart contract is invoked, the smart contract may not have been upgraded and is still deployed in the corresponding contract address in the form of bytecode; it may also have been upgraded and deployed in the form of machine code in the corresponding contract address. It should be understood that for smart contracts deployed in different forms, calls need to be made in different ways.
具体的,当区块链网络中的第二区块链节点接收到针对智能合约的调用交易时,区块链网络中的所有节点可以对该调用交易进行交易共识,并在共识通过的情况下,所有区块链节点可以根据该调用交易确定所要调用的智能合约的合约地址,以通过该合约地址获取所调用智能合约的合约代码。其中,在获取到的合约代码为字节码的情况下,各个区块链节点可以对该字节码进行解释执行,以实现智能合约的调用;而在获取到的合约代码为机器码的情况下,各个区块链节点可以直接执行获取到的机器码。其中,第三区块链节点既可以与第一区块链节点为同一节点,也可以为不同节点。Specifically, when the second blockchain node in the blockchain network receives an invocation transaction for a smart contract, all nodes in the blockchain network can conduct a transaction consensus on the invocation transaction, and if the consensus is passed , all blockchain nodes can determine the contract address of the smart contract to be called according to the call transaction, so as to obtain the contract code of the called smart contract through the contract address. Among them, when the obtained contract code is a bytecode, each blockchain node can interpret and execute the bytecode to realize the call of the smart contract; and when the obtained contract code is a machine code Under this condition, each blockchain node can directly execute the obtained machine code. Wherein, the third block chain node may be the same node as the first block chain node, or may be a different node.
需要声明的是,当获取到的合约代码为机器码时,并非必须执行获取到的所有机器 码,而是可以根据调用交易中包含的所调用函数/代码块,确定出所需执行的机器码。换言之,可以仅执行获取的智能合约的合约代码中与所调用函数/代码块对应的机器码。What needs to be declared is that when the obtained contract code is machine code, it is not necessary to execute all the obtained machine codes, but the machine code to be executed can be determined according to the called function/code block contained in the calling transaction . In other words, only the machine code corresponding to the called function/code block in the acquired contract code of the smart contract can be executed.
除此之外,为了使区块链网络中的各个区块链节点能够在接收到的合约升级交易对相应的智能合约执行合约升级操作,各个区块链节点所运行的链代码中通常包含有合约升级逻辑代码,该合约升级逻辑代码用于在确定JIT编译已完成的情况下,生成针对智能合约的合约升级交易,以通过该合约升级交易将已部署的合约代码由字节码升级为机器码。In addition, in order to enable each blockchain node in the blockchain network to perform a contract upgrade operation on the corresponding smart contract in the received contract upgrade transaction, the chain code run by each blockchain node usually contains Contract upgrade logic code, the contract upgrade logic code is used to generate a contract upgrade transaction for the smart contract when it is determined that the JIT compilation has been completed, so as to upgrade the deployed contract code from bytecode to machine through the contract upgrade transaction code.
需要强调的是,本说明书中的技术方案既可以应用于区块链技术的传统架构,即区块链网络中的所有区块链节点均通过在相应实体设备上部署区块链代码而形成,大多数情况下,每个节点均对应于一个实体设备;本说明书的技术方案也可以应用于区块链技术中的BaaS(Blockchain as a Service)架构,即区块链网络中的所有节点均通过云服务在云端实现的虚拟机上部署区块链代码而形成,区块链节点无需一一对应于相应的实体设备。It should be emphasized that the technical solutions in this specification can be applied to the traditional architecture of blockchain technology, that is, all blockchain nodes in the blockchain network are formed by deploying blockchain codes on corresponding physical devices, In most cases, each node corresponds to a physical device; the technical solution in this manual can also be applied to the BaaS (Blockchain as a Service) architecture in the blockchain technology, that is, all nodes in the blockchain network pass Cloud services are formed by deploying blockchain codes on virtual machines implemented in the cloud, and blockchain nodes do not need to correspond to corresponding physical devices one by one.
其中,在本说明书的技术方案应用于BaaS架构时,相当于第一区块链节点搭载于虚拟机中,此时,第一区块链节点对应的虚拟机中可以预先部署有JIT编译服务,以用于对智能合约的字节码进行JIT编译。Among them, when the technical solution of this specification is applied to the BaaS architecture, it is equivalent to the first blockchain node being installed in a virtual machine. At this time, the JIT compilation service can be pre-deployed in the virtual machine corresponding to the first blockchain node. Used to JIT compile the bytecode of the smart contract.
由上述技术方案可知,本说明书中的区块链网络在获取到合约部署交易后,一方面将该合约部署交易中的字节码部署至各个区块链节点中;另一方面又通过所包含的第一区块链节点对合约部署交易中的字节码进行JIT编译,以得到相应智能合约的机器码。在此基础上,该第一区块链节点即可在JIT编译已完成的情况下,将包含编译得到的机器码的合约升级交易发送至各个区块链节点,以由各个区块链节点分别将已部署的字节码升级为机器码。It can be seen from the above technical solutions that after the blockchain network in this specification obtains the contract deployment transaction, on the one hand, it deploys the bytecode in the contract deployment transaction to each blockchain node; The first blockchain node of JIT compiles the bytecode in the contract deployment transaction to obtain the machine code of the corresponding smart contract. On this basis, the first blockchain node can send the contract upgrade transaction containing the compiled machine code to each blockchain node after the JIT compilation has been completed, so that each blockchain node can Upgrade deployed bytecode to machine code.
应当理解的是,本说明书的技术方案相当于仅通过区块链网络中的一个节点对智能合约的字节码进行JIT编译,并在编译完成后,通过生成合约升级交易的方式,将编译得到的机器码同步至各个区块链节点,以由各个区块链节点将字节码升级为机器码。显然,通过本说明书的技术方案,避免了相关技术中需要各个区块链节点分别执行JIT编译操作的情况,减少了JIT编译对区块链处理资源的占用。It should be understood that the technical solution in this manual is equivalent to JIT compiling the bytecode of the smart contract through only one node in the blockchain network, and after the compilation is completed, the compiled The machine code of the blockchain is synchronized to each blockchain node, so that each blockchain node can upgrade the bytecode to machine code. Apparently, through the technical solution in this manual, the situation in related technologies that requires each blockchain node to perform JIT compilation operation separately is avoided, and the occupation of blockchain processing resources by JIT compilation is reduced.
进一步的,本说明书中的区块链节点可以预先获取用户授予的合约升级授权,使得本说明书中的区块链节点在完成JIT编译的情况下,能够基于编译得到的机器码自行生 成合约升级交易,进而完成针对智能合约的合约升级操作,避免了相关技术中需要用户向各个区块链节点发送升级指示的情况,进而解决了相关技术中由于交互次数较多而导致的升级效率较低的问题,以及占用大量传输资源的问题。Furthermore, the blockchain nodes in this manual can obtain the contract upgrade authorization granted by the user in advance, so that the blockchain nodes in this manual can generate contract upgrade transactions based on the compiled machine code after JIT compilation is completed. , and then complete the contract upgrade operation for smart contracts, avoiding the need for users to send upgrade instructions to each blockchain node in related technologies, and then solving the problem of low upgrade efficiency due to the large number of interactions in related technologies , and the problem of occupying a large amount of transmission resources.
为实现上述智能合约升级方法,本说明书还提出了一种区块链系统。该区块链系统用于实现上述方案,大多操作方式与上一实施例类似,如何进行JIT编译、如何生成合约升级交易等,均可参照上一实施例的介绍,在下一实施例中不再赘述。In order to realize the above smart contract upgrade method, this specification also proposes a blockchain system. The blockchain system is used to implement the above solution, and most of the operation methods are similar to the previous embodiment. How to perform JIT compilation, how to generate contract upgrade transactions, etc., can refer to the introduction of the previous embodiment, and will not be discussed in the next embodiment. repeat.
图4为本说明书一示例性实施例示出的一种区块链系统,如图4所示,该区块链系统4包括:多个区块链节点;其中,所述区块链系统中的各个区块链节点分别获取包含字节码的合约部署交易,并基于所述合约部署交易部署相应的智能合约;所述区块链网络中的任一区块链节点对所述字节码进行JIT编译,得到所述智能合约的机器码,并基于所述机器码生成针对所述智能合约的合约升级交易;所述区块链网络中的所有区块链节点分别获取所述合约升级交易,并基于所述合约升级交易将所述智能合约对应的合约代码由所述字节码升级为所述机器码。Figure 4 is a block chain system shown in an exemplary embodiment of this specification, as shown in Figure 4, the block chain system 4 includes: a plurality of block chain nodes; wherein, in the block chain system Each block chain node respectively obtains the contract deployment transaction containing the bytecode, and deploys the corresponding smart contract based on the contract deployment transaction; any block chain node in the block chain network executes the bytecode JIT compilation to obtain the machine code of the smart contract, and generate a contract upgrade transaction for the smart contract based on the machine code; all blockchain nodes in the blockchain network respectively obtain the contract upgrade transaction, And based on the contract upgrade transaction, the contract code corresponding to the smart contract is upgraded from the bytecode to the machine code.
如上所述,本说明书需要优先对智能合约的字节码进行部署。在实际操作中,用户可以自行编译智能合约的字节码,并通过向自身使用的客户端发送合约部署请求的方式,使客户端基于该字节码生成合约部署交易。客户端可以将生成的合约部署交易发送至区块链系统4中的任一区块链节点,以使该任一区块链节点对该合约部署交易进行交易共识,并在共识通过后,由各个区块链节点分别对其中包含的字节码进行部署。As mentioned above, this specification needs to prioritize the deployment of the bytecode of the smart contract. In actual operation, users can compile the bytecode of the smart contract by themselves, and send a contract deployment request to the client they use, so that the client generates a contract deployment transaction based on the bytecode. The client can send the generated contract deployment transaction to any blockchain node in the blockchain system 4, so that any blockchain node can achieve a transaction consensus on the contract deployment transaction, and after the consensus is passed, the Each blockchain node deploys the bytecode contained therein respectively.
如上所述,本说明书中负责对智能合约进行JIT编译的区块链节点可以为区块链系统中的任一节点。例如,该任一区块链节点可以为图4中的节点41,即将节点41作为上一实施例中的第一区块链节点。As mentioned above, the blockchain node responsible for JIT compiling the smart contract in this specification can be any node in the blockchain system. For example, any blockchain node may be node 41 in FIG. 4 , that is, node 41 is the first blockchain node in the previous embodiment.
如上所述,第一区块链节点可以在接收到上述用户发送的用于指示将智能合约的字节码编译为机器码的指示信息的情况下,再对上述合约部署交易中包含的字节码进行JIT编译,以得到智能合约的机器码。或者,第一区块链节点可以在接收到智能合约部署交易的情况下,判断该智能合约交易中是否包含用于指示将智能合约的字节码编译为机器码的指示标识,并在包含该指示标识的情况下,对合约部署交易中包含的字节码进行JIT编译。再或者,第一区块链节点可以根据合约部署交易的发起方或者合约部署交易中包含的业务数据的类型,判断是否需要对合约部署交易中的字节码进行JIT编译。As mentioned above, the first blockchain node may, after receiving the instruction information sent by the above-mentioned user for instructing to compile the bytecode of the smart contract into machine code, then deploy the bytecode contained in the above-mentioned contract The code is JIT compiled to obtain the machine code of the smart contract. Alternatively, the first blockchain node may, upon receiving the smart contract deployment transaction, determine whether the smart contract transaction contains an instruction flag for instructing the bytecode of the smart contract to be compiled into machine code, and If the flag is indicated, JIT compiles the bytecode contained in the contract deployment transaction. Alternatively, the first blockchain node may determine whether to JIT-compile the bytecode in the contract deployment transaction according to the initiator of the contract deployment transaction or the type of business data contained in the contract deployment transaction.
如上所述,第一区块链节点可以在确定智能合约的字节码被部署完成后,开始对智 能合约的字节码进行JIT编译。第一区块链节点也可以在确定智能合约的字节码被部署完成的情况下,利用相对空闲的时间对智能合约的字节码进行JIT编译。As mentioned above, the first blockchain node can start to JIT compile the bytecode of the smart contract after determining that the bytecode of the smart contract is deployed. The first blockchain node can also use relatively free time to JIT compile the bytecode of the smart contract when it is determined that the bytecode of the smart contract has been deployed.
如上所述,本说明书中的区块链节点可以预先获取合约部署交易发送方的合约升级授权,以便区块链节点在完成针对智能合约的JIT编译后,即可自行生成包含编译得到的机器码的合约升级交易,进而对已部署的字节码进行升级。As mentioned above, the blockchain nodes in this manual can obtain the contract upgrade authorization of the sender of the contract deployment transaction in advance, so that after the blockchain node completes the JIT compilation for the smart contract, it can generate the compiled machine code by itself. The contract upgrade transaction of , and then upgrade the deployed bytecode.
如上所述,区块链系统中部署的智能合约随时都有可能被用户调用。而在已部署的智能合约被调用时,该智能合约既有可能尚未进行升级,仍以字节码的形式被部署于相应的合约地址中;也有可能已经被升级,以机器码的形式被部署于相应的合约地址中。具体的,当区块链网络中的第二区块链节点接收到针对智能合约的调用交易时,区块链网络中的所有节点可以对该调用交易进行交易共识,并在共识通过的情况下,所有区块链节点可以根据该调用交易确定所要调用的智能合约的合约地址,以通过该合约地址获取所调用智能合约的合约代码。其中,在获取到的合约代码为字节码的情况下,各个区块链节点可以对该字节码进行解释执行,以实现智能合约的调用;而在获取到的合约代码为机器码的情况下,各个区块链节点可以直接执行获取到的机器码。其中,该第二区块链节点既可以与第一区块链节点为同一节点,如均为节点41;该第二区块链节点也可以与第一区块链节点为不同节点,如为节点42。As mentioned above, smart contracts deployed in the blockchain system may be invoked by users at any time. When the deployed smart contract is invoked, the smart contract may not have been upgraded and is still deployed in the corresponding contract address in the form of bytecode; it may also have been upgraded and deployed in the form of machine code in the corresponding contract address. Specifically, when the second blockchain node in the blockchain network receives an invocation transaction for a smart contract, all nodes in the blockchain network can conduct a transaction consensus on the invocation transaction, and if the consensus is passed , all blockchain nodes can determine the contract address of the smart contract to be called according to the call transaction, so as to obtain the contract code of the called smart contract through the contract address. Among them, when the obtained contract code is a bytecode, each blockchain node can interpret and execute the bytecode to realize the call of the smart contract; and when the obtained contract code is a machine code Under this condition, each blockchain node can directly execute the obtained machine code. Wherein, the second block chain node can be the same node as the first block chain node, such as node 41; the second block chain node can also be a different node from the first block chain node, such as Node 42.
如上所述,上述区块链系统既可以基于区块链技术的传统架构,即区块链系统中的所有区块链节点均通过在相应实体设备上部署区块链代码而形成,大多数情况下,每个节点均对应于一个实体设备;上述区块链系统也可以基于区块链技术中的BaaS(Blockchain as a Service)架构,即区块链系统中的所有节点均通过云服务在云端实现的虚拟机上部署区块链代码而形成,区块链节点无需一一对应于相应的实体设备。As mentioned above, the above-mentioned blockchain system can be based on the traditional architecture of blockchain technology, that is, all blockchain nodes in the blockchain system are formed by deploying blockchain codes on corresponding physical devices, and in most cases Next, each node corresponds to a physical device; the above blockchain system can also be based on the BaaS (Blockchain as a Service) architecture in blockchain technology, that is, all nodes in the blockchain system are distributed in the cloud through cloud services. It is formed by deploying the blockchain code on the realized virtual machine, and the blockchain nodes do not need to correspond to the corresponding physical devices one by one.
由上述区块链系统可知,本说明书中的区块链系统在获取到合约部署交易后,一方面将该合约部署交易中的字节码部署至各个区块链节点中;另一方面又通过所包含的第一区块链节点对合约部署交易中的字节码进行JIT编译,以得到相应智能合约的机器码。在此基础上,该第一区块链节点即可在完成JIT编译的情况下,将包含编译得到的机器码的合约升级交易发送至各个区块链节点,以由各个区块链节点分别将已部署的字节码升级为机器码。通过该方式,避免了相关技术中由于需要在各个区块链节点中分别执行JIT编译而导致的浪费区块链处理资源的问题。It can be seen from the above blockchain system that after obtaining the contract deployment transaction, the blockchain system in this specification deploys the bytecode in the contract deployment transaction to each blockchain node on the one hand; The included first blockchain node performs JIT compilation on the bytecode in the contract deployment transaction to obtain the machine code of the corresponding smart contract. On this basis, the first blockchain node can send the contract upgrade transaction containing the compiled machine code to each blockchain node after JIT compilation is completed, so that each blockchain node can respectively Deployed bytecode is upgraded to machine code. In this manner, the problem of wasting blockchain processing resources caused by the need to perform JIT compilation in each blockchain node in the related art is avoided.
其中,第一区块链节点可以预先获取用户授予的合约升级授权,使得本说明书中的区块链节点可以在JIT编译完成的情况下,基于JIT编译得到的机器码自行生成合约升 级交易,进而将已部署的字节码升级为机器码,避免了相关技术中由于需要用户向各个区块链节点发送升级指示,而造成的占用大量传输资源的问题。Among them, the first blockchain node can obtain the contract upgrade authorization granted by the user in advance, so that the blockchain node in this manual can generate the contract upgrade transaction based on the machine code obtained by JIT compilation after the JIT compilation is completed, and then Upgrading the deployed bytecode to machine code avoids the problem of occupying a large amount of transmission resources in related technologies that require users to send upgrade instructions to each blockchain node.
接下来,通过具体实施例对本说明书的技术方案进行介绍。Next, the technical solution of this specification is introduced through specific embodiments.
图5是本说明书一示例性实施例示出的一种智能合约升级方法的交互图。该方法可以包括以下步骤:步骤501,客户端向区块链网络中的第一区块链节点发送合约部署交易。Fig. 5 is an interaction diagram of a smart contract upgrade method shown in an exemplary embodiment of this specification. The method may include the following steps: Step 501, the client sends a contract deployment transaction to the first blockchain node in the blockchain network.
在本实施例中,用户可以在自身所使用的客户端上编译需要部署的智能合约的字节码。用户在编译好智能合约的字节码后,即可向客户端发起针对该智能合约的部署指示,以使客户端在该部署指示的指示下,基于智能合约的字节码生成合约部署交易。In this embodiment, the user can compile the bytecode of the smart contract to be deployed on the client used by the user. After compiling the bytecode of the smart contract, the user can initiate a deployment instruction for the smart contract to the client, so that the client can generate a contract deployment transaction based on the bytecode of the smart contract under the instruction of the deployment instruction.
在实际应用中,客户端上可以包含一合约部署控件,以便用户可以通过该控件向客户端发起合约部署请求。具体的,当客户端在检测到该合约部署控件被触发后,即可确定用户需要将相应的智能合约部署至区块链网络中,因此,可以基于用户编译得到的字节码生成合约部署交易,并将其发送至区块链网络中的第一区块链节点,以通过第一区块链节点将智能合约的字节码部署至各个区块链节点中。其中,该第一区块链节点为区块链网络中的任一节点。In practical applications, the client may contain a contract deployment control, so that the user can initiate a contract deployment request to the client through the control. Specifically, when the client detects that the contract deployment control is triggered, it can determine that the user needs to deploy the corresponding smart contract to the blockchain network. Therefore, the contract deployment transaction can be generated based on the bytecode compiled by the user , and send it to the first blockchain node in the blockchain network, so as to deploy the bytecode of the smart contract to each blockchain node through the first blockchain node. Wherein, the first blockchain node is any node in the blockchain network.
步骤502,第一区块链节点与区块链网络中的其他节点对合约部署交易进行交易共识,以使各个区块链节点对该合约部署交易中包含的字节码进行部署。Step 502, the first blockchain node and other nodes in the blockchain network conduct a transaction consensus on the contract deployment transaction, so that each blockchain node deploys the bytecode contained in the contract deployment transaction.
应当理解的是,第一区块链节点在接收到合约部署交易后,需要优先对该合约部署交易进行交易共识,并在共识通过的情况下,再将该合约部署交易发送至各个区块链节点,以由各个区块链节点分别对该交易中包含的字节码进行部署。It should be understood that after the first blockchain node receives the contract deployment transaction, it needs to give priority to the transaction consensus on the contract deployment transaction, and if the consensus is passed, then send the contract deployment transaction to each blockchain Nodes, so that the bytecode contained in the transaction is deployed by each blockchain node.
需要声明的是,各个区块链节点在接收到上述合约部署交易后,会通过将该交易中包含的字节码保存至相应合约地址的方式,以完成对智能合约的部署。What needs to be declared is that after each blockchain node receives the above-mentioned contract deployment transaction, it will save the bytecode contained in the transaction to the corresponding contract address to complete the deployment of the smart contract.
步骤503,第一区块链节点对合约部署交易中的字节码进行JIT编译,以得到相应的机器码。Step 503, the first blockchain node performs JIT compilation on the bytecode in the contract deployment transaction to obtain the corresponding machine code.
在本实施例中,可以在对智能合约的字节码进行部署的同时,进行JIT编译;也可以在对智能合约的字节码编译完成后,再进行JIT编译。具体如何对智能合约的字节码进行JIT编译,可由本领域技术人员根据实际需求确定。In this embodiment, the JIT compilation can be performed while the bytecode of the smart contract is being deployed; or the JIT compilation can be performed after the bytecode of the smart contract is compiled. Specifically, how to JIT compile the bytecode of the smart contract can be determined by those skilled in the art according to actual needs.
步骤504,第一区块链节点基于编译得到的机器码生成合约升级交易。Step 504, the first blockchain node generates a contract upgrade transaction based on the compiled machine code.
在本实施例中,区块链网络由区块链技术的提供方进行维护,用户可以预先授予该提供方“针对智能合约的合约升级授权”,以使得区块链网络中的任一区块链节点在完成针对智能合约的字节码的JIT编译后,能够自行基于JIT编译得到的机器码生成合约升级交易。In this embodiment, the blockchain network is maintained by the provider of the blockchain technology, and the user can pre-grant the provider "contract upgrade authorization for smart contracts", so that any block in the blockchain network After the chain node completes the JIT compilation of the bytecode of the smart contract, it can generate a contract upgrade transaction based on the machine code obtained by JIT compilation.
当然,本实施例仅仅是以由负责JIT编译的第一区块链节点负责生成合约升级交易为例进行介绍。在实际应用中,负责生成合约升级交易的区块链节点和负责JIT编译的区块链节点也可以为不同节点,具体的,第一区块链节点在完成JIT编译后,可以将编译得到的机器码发送至负责生成合约升级交易的区块链节点,以由该区块链节点生成合约升级交易。再进一步的,区块链技术的提供方可以为区块链网络设置一服务器,以通过该服务器对区块链网络进行维护,在此基础上,用户可以仅授予该服务器合约升级授权,因此,第一区块链节点在完成JIT编译后,也可以将编译得到的机器码发送至该服务器,以由该服务器负责生成合约升级交易。具体如何生成合约升级交易可由本领域技术人员根据实际情况确定。Of course, this embodiment is only introduced by taking the first blockchain node in charge of JIT compilation to be responsible for generating contract upgrade transactions as an example. In practical applications, the blockchain node responsible for generating contract upgrade transactions and the blockchain node responsible for JIT compilation can also be different nodes. Specifically, after the first blockchain node completes JIT compilation, it can convert the compiled The machine code is sent to the blockchain node responsible for generating the contract upgrade transaction, so that the blockchain node generates the contract upgrade transaction. Furthermore, the provider of the blockchain technology can set up a server for the blockchain network to maintain the blockchain network through the server. On this basis, the user can only grant the server contract upgrade authorization. Therefore, After the first blockchain node completes JIT compilation, it can also send the compiled machine code to the server, so that the server is responsible for generating contract upgrade transactions. Specifically how to generate a contract upgrade transaction can be determined by those skilled in the art according to the actual situation.
步骤505,第一区块链节点与区块链网络中的其他节点对合约升级交易进行交易共识,以使各个区块链节点将已部署的字节码升级为合约升级交易中包含的机器码。Step 505, the first blockchain node and other nodes in the blockchain network conduct a transaction consensus on the contract upgrade transaction, so that each blockchain node upgrades the deployed bytecode to the machine code contained in the contract upgrade transaction .
在本实施例中,第一区块链节点在生成合约升级交易后,即可与区块链网络中的其他节点进行交易共识,并在共识通过的情况下,将合约升级交易发送至其他节点,以由各个区块链节点分别将合约地址中已部署的字节码替换为合约升级交易中的机器码,进而完成针对智能合约的升级。In this embodiment, after the first blockchain node generates a contract upgrade transaction, it can conduct transaction consensus with other nodes in the blockchain network, and when the consensus is passed, the contract upgrade transaction is sent to other nodes , so that each blockchain node replaces the deployed bytecode in the contract address with the machine code in the contract upgrade transaction, and then completes the upgrade for the smart contract.
由上述技术方案可知,用户将编译完成的智能合约发送至区块链节点后,区块链节点一方面会与其他节点对包含该智能合约的合约部署交易进行交易共识,以在共识通过的情况下,由各个区块链节点分别对智能合约的字节码进行部署;另一方面,区块链节点会对字节码进行JIT编译,以得到智能合约的机器码。其中,区块链节点预先获取了用户的合约升级授权,使得区块链节点在完成JIT编译的情况下,可以直接基于编译得到的机器码生成合约升级交易,以通过该合约升级交易将已部署的字节码升级成编译得到的机器码。显然,通过该方法,无需如相关技术需要由各个区块链节点分别执行JIT编译,减少了对区块链处理资源的占用。进一步的,由于区块链节点预先获取了用户授予的合约升级授权,避免了相关技术中需要用户向各个区块链节点发送升级指示的情况,减少了对传输资源的占用。It can be seen from the above technical solution that after the user sends the compiled smart contract to the blockchain node, on the one hand, the blockchain node will conduct a transaction consensus with other nodes on the contract deployment transaction containing the smart contract, so that when the consensus is passed Next, each blockchain node deploys the bytecode of the smart contract; on the other hand, the blockchain node JIT compiles the bytecode to obtain the machine code of the smart contract. Among them, the blockchain node has obtained the user's contract upgrade authorization in advance, so that the blockchain node can directly generate a contract upgrade transaction based on the compiled machine code after completing the JIT compilation, so that the deployed The bytecode is upgraded to the compiled machine code. Obviously, through this method, it is not necessary to perform JIT compilation by each blockchain node separately as in related technologies, which reduces the occupation of blockchain processing resources. Furthermore, since the blockchain nodes have pre-obtained the contract upgrade authorization granted by the user, it avoids the need for the user to send an upgrade instruction to each blockchain node in related technologies, and reduces the occupation of transmission resources.
本发明是参照根据本发明实施例的方法、系统、和计算机程序产品的流程图和/或 方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, systems, and computer program products according to embodiments of the invention. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in computer-readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer readable media.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储、石墨烯存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information. 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 Disc (DVD) or other optical storage, Magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by computing devices. As defined herein, computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
本领域技术人员应明白,本说明书一个或多个实施例可提供为方法、系统或计算机 程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书一个或多个实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that one or more embodiments of this specification may be provided as a method, system or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of the present description may employ a computer program embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein. The form of the product.
本说明书一个或多个实施例可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本本说明书一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。One or more embodiments of this specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本说明书的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。Each embodiment in this specification is described in a progressive manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for relevant parts, refer to part of the description of the method embodiment. In the description of this specification, descriptions referring to the terms "one embodiment", "some embodiments", "example", "specific examples", or "some examples" mean that specific features described in connection with the embodiment or example , structures, materials or features are included in at least one embodiment or example of this specification. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the described specific features, structures, materials or characteristics may be combined in any suitable manner in any one or more embodiments or examples. In addition, those skilled in the art can combine and combine different embodiments or examples and features of different embodiments or examples described in this specification without conflicting with each other.
以上所述仅为本说明书一个或多个实施例的实施例而已,并不用于限制本本说明书一个或多个实施例。对于本领域技术人员来说,本说明书一个或多个实施例可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在权利要求范围之内。The above description is only an example of one or more embodiments of this specification, and is not intended to limit one or more embodiments of this specification. For those skilled in the art, various modifications and changes may occur in one or more embodiments of this description. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this specification shall be included in the scope of the claims.

Claims (11)

  1. 一种智能合约升级方法,包括:A smart contract upgrade method, including:
    区块链网络中的所有区块链节点分别获取包含字节码的合约部署交易,并基于所述合约部署交易部署相应的智能合约;All blockchain nodes in the blockchain network respectively obtain contract deployment transactions containing bytecodes, and deploy corresponding smart contracts based on the contract deployment transactions;
    所述区块链网络中的第一区块链节点对所述字节码进行JIT编译,得到所述智能合约的机器码,并基于所述机器码生成针对所述智能合约的合约升级交易;The first blockchain node in the blockchain network performs JIT compilation on the bytecode to obtain the machine code of the smart contract, and generates a contract upgrade transaction for the smart contract based on the machine code;
    所述区块链网络中的所有区块链节点分别获取所述合约升级交易,并基于所述合约升级交易将所述智能合约对应的合约代码由所述字节码升级为所述机器码。All blockchain nodes in the blockchain network respectively obtain the contract upgrade transaction, and upgrade the contract code corresponding to the smart contract from the bytecode to the machine code based on the contract upgrade transaction.
  2. 根据权利要求1所述的方法,所述区块链网络中的第一区块链节点对所述字节码进行JIT编译,包括:According to the method according to claim 1, the first blockchain node in the blockchain network performs JIT compilation on the bytecode, comprising:
    所述第一区块链节点响应于用户发送的用于指示将所述智能合约的字节码编译为机器码的指示消息,对所述合约部署交易中的字节码进行JIT编译;或者,The first blockchain node performs JIT compilation on the bytecode in the contract deployment transaction in response to the instruction message sent by the user for instructing to compile the bytecode of the smart contract into machine code; or,
    所述第一区块链节点在确定所述合约部署交易中包含用于指示将所述智能合约的字节码编译为机器码的指示标识的情况下,对所述合约部署交易中的字节码进行JIT编译;或者,When the first block chain node determines that the contract deployment transaction contains an instruction flag for instructing to compile the bytecode of the smart contract into machine code, the byte code in the contract deployment transaction code for JIT compilation; or,
    所述第一区块链节点在确定所述合约部署交易由预定义的特定用户发起的情况下,对所述合约部署交易中的字节码进行JIT编译;或者,When the first blockchain node determines that the contract deployment transaction is initiated by a predefined specific user, JIT compiles the bytecode in the contract deployment transaction; or,
    所述第一区块链节点在确定所述合约部署交易中包含的业务数据属于预定义的业务类型的情况下,对所述合约部署交易中的字节码进行JIT编译。When the first blockchain node determines that the business data included in the contract deployment transaction belongs to a predefined business type, JIT compiles the bytecode in the contract deployment transaction.
  3. 根据权利要求1所述的方法,所述区块链网络中的第一区块链节点对所述字节码进行JIT编译,包括:According to the method according to claim 1, the first blockchain node in the blockchain network performs JIT compilation on the bytecode, comprising:
    所述第一区块链节点在确定所述智能合约的字节码被部署完成后,开始对所述智能合约的字节码进行JIT编译;或者,After the first blockchain node determines that the bytecode of the smart contract is deployed, it starts to JIT compile the bytecode of the smart contract; or,
    所述第一区块链节点在确定所述智能合约的字节码被部署完成的情况下,利用相对空闲的时间段对所述字节码进行JIT编译。When the first blockchain node determines that the bytecode of the smart contract has been deployed, it uses a relatively idle time period to perform JIT compilation on the bytecode.
  4. 根据权利要求1所述的方法,所述区块链网络中的第一区块链节点对所述字节码进行JIT编译,包括:According to the method according to claim 1, the first blockchain node in the blockchain network performs JIT compilation on the bytecode, comprising:
    所述第一区块链节点对所述合约部署交易中包含的所有字节码进行编译;和/或,The first blockchain node compiles all bytecodes contained in the contract deployment transaction; and/or,
    所述第一区块链节点对所述合约部署交易中包含的字节码进行热点分析,并对得到的热点字节码进行编译;和/或,The first blockchain node performs hotspot analysis on the bytecode contained in the contract deployment transaction, and compiles the obtained hotspot bytecode; and/or,
    所述第一区块链节点对所述合约部署交易中包含的字节码进行优化编译。The first blockchain node optimizes and compiles the bytecode contained in the contract deployment transaction.
  5. 根据权利要求1所述的方法,所述区块链网络中的任一区块链节点基于所述合约升级交易将所述智能合约对应的合约代码由所述字节码升级为所述机器码,包括:According to the method according to claim 1, any blockchain node in the blockchain network upgrades the contract code corresponding to the smart contract from the bytecode to the machine code based on the contract upgrade transaction ,include:
    所述区块链网络中的任一区块链节点确定所述智能合约的合约地址,并将所述合约地址中已部署的字节码替换为所述机器码。Any blockchain node in the blockchain network determines the contract address of the smart contract, and replaces the deployed bytecode in the contract address with the machine code.
  6. 根据权利要求1所述的方法,还包括:The method according to claim 1, further comprising:
    所述区块链网络中的第二区块链节点接收针对所述智能合约的调用交易;所述第二区块链节点与所述第一区块链节点为同一节点或不同节点;The second block chain node in the block chain network receives the calling transaction for the smart contract; the second block chain node and the first block chain node are the same node or different nodes;
    所述所有区块链节点根据所述调用交易确定所述智能合约的合约地址,以获取所述智能合约的合约代码;All the blockchain nodes determine the contract address of the smart contract according to the calling transaction, so as to obtain the contract code of the smart contract;
    所述所有区块链节点在确定所述合约代码为所述字节码的情况下,对所述字节码进行解释执行;When all the blockchain nodes determine that the contract code is the bytecode, they interpret and execute the bytecode;
    所述所有区块链节点在确定所述合约代码为所述机器码的情况下,直接执行所述机器码。When all the blockchain nodes determine that the contract code is the machine code, they directly execute the machine code.
  7. 根据权利要求6所述的方法,所述所有区块链节点直接执行所述机器码,包括:According to the method according to claim 6, said all blockchain nodes directly execute said machine code, comprising:
    所述所有区块链节点执行所述智能合约中对应所调用函数/代码块的机器码。All the blockchain nodes execute the machine code corresponding to the called function/code block in the smart contract.
  8. 根据权利要求1所述的方法,所述第一区块链节点预先获取了所述合约部署交易发送方的合约升级授权。According to the method according to claim 1, the first block chain node has obtained the contract upgrade authorization of the sender of the contract deployment transaction in advance.
  9. 根据权利要求1所述的方法,所述第一区块链节点的链代码中包含合约升级逻辑代码,用于指示在确定所述JIT编译已完成的情况下,生成针对所述智能合约的合约升级交易。According to the method according to claim 1, the chain code of the first blockchain node includes a contract upgrade logic code, which is used to instruct to generate a contract for the smart contract when it is determined that the JIT compilation has been completed Upgrade transactions.
  10. 根据权利要求1所述的方法,所述第一区块链节点搭载于虚拟机,所述虚拟机中预先部署有JIT编译服务,针对所述智能合约的JIT编译通过调用所述JIT编译服务完成。According to the method according to claim 1, the first blockchain node is mounted on a virtual machine, a JIT compilation service is pre-deployed in the virtual machine, and the JIT compilation for the smart contract is completed by calling the JIT compilation service .
  11. 一种区块链系统,包括:多个区块链节点;其中,A blockchain system, comprising: a plurality of blockchain nodes; wherein,
    所述区块链系统中的各个区块链节点分别获取包含字节码的合约部署交易,并基于所述合约部署交易部署相应的智能合约;Each blockchain node in the blockchain system respectively obtains a contract deployment transaction including bytecode, and deploys a corresponding smart contract based on the contract deployment transaction;
    所述区块链网络中的任一区块链节点对所述字节码进行JIT编译,得到所述智能合约的机器码,并基于所述机器码生成针对所述智能合约的合约升级交易;Any blockchain node in the blockchain network performs JIT compilation on the bytecode to obtain the machine code of the smart contract, and generates a contract upgrade transaction for the smart contract based on the machine code;
    所述区块链网络中的所有区块链节点分别获取所述合约升级交易,并基于所述合约升级交易将所述智能合约对应的合约代码由所述字节码升级为所述机器码。All blockchain nodes in the blockchain network respectively obtain the contract upgrade transaction, and upgrade the contract code corresponding to the smart contract from the bytecode to the machine code based on the contract upgrade transaction.
PCT/CN2022/090384 2021-05-11 2022-04-29 Smart contract upgrading method and blockchain system WO2022237590A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110510125.9 2021-05-11
CN202110510125.9A CN113220326B (en) 2021-05-11 2021-05-11 Intelligent contract upgrading method and block chain system

Publications (1)

Publication Number Publication Date
WO2022237590A1 true WO2022237590A1 (en) 2022-11-17

Family

ID=77094607

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/090384 WO2022237590A1 (en) 2021-05-11 2022-04-29 Smart contract upgrading method and blockchain system

Country Status (2)

Country Link
CN (1) CN113220326B (en)
WO (1) WO2022237590A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113220326B (en) * 2021-05-11 2022-09-16 支付宝(杭州)信息技术有限公司 Intelligent contract upgrading method and block chain system
CN114553912A (en) * 2022-02-24 2022-05-27 平安国际智慧城市科技股份有限公司 Health file sharing method, system, equipment and storage medium based on block chain

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190278767A1 (en) * 2017-08-23 2019-09-12 Zhongan Information Technology Service Co., Ltd. Smart contract upgrade method and system based on alliance chain
US20200119905A1 (en) * 2018-10-15 2020-04-16 Adobe Inc. Smart contract platform for generating and customizing smart contracts
CN111770206A (en) * 2020-08-31 2020-10-13 支付宝(杭州)信息技术有限公司 Method for deploying intelligent contract, block chain node and storage medium
CN111768184A (en) * 2020-08-31 2020-10-13 支付宝(杭州)信息技术有限公司 Method for executing intelligent contract and block link point
CN111814202A (en) * 2020-08-31 2020-10-23 支付宝(杭州)信息技术有限公司 Method for executing intelligent contract, block chain node and storage medium
CN112596754A (en) * 2021-03-01 2021-04-02 腾讯科技(深圳)有限公司 Block chain intelligent contract deployment method and device
CN113220327A (en) * 2021-05-11 2021-08-06 支付宝(杭州)信息技术有限公司 Intelligent contract upgrading method and block chain system
CN113220326A (en) * 2021-05-11 2021-08-06 支付宝(杭州)信息技术有限公司 Intelligent contract upgrading method and block chain system

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3612930A4 (en) * 2019-03-26 2020-06-24 Alibaba Group Holding Limited System and method for implementing different types of blockchain contracts
WO2019170175A2 (en) * 2019-06-28 2019-09-12 Alibaba Group Holding Limited System and method for executing different types of blockchain contracts
CN110413304B (en) * 2019-07-31 2023-07-14 中国工商银行股份有限公司 Intelligent contract hot upgrading method and device based on block chain network
CN111538521B (en) * 2020-04-24 2024-02-09 中国工商银行股份有限公司 Intelligent contract deployment and transaction method and device
CN111736954B (en) * 2020-06-24 2024-01-05 陈鹏 Multi-intelligent contract virtual machine implementation method, multi-intelligent contract virtual machine and system
CN112866392B (en) * 2020-08-31 2023-06-30 支付宝(杭州)信息技术有限公司 Method, blockchain node, system and storage medium for executing intelligent contract
CN111770116B (en) * 2020-08-31 2020-12-15 支付宝(杭州)信息技术有限公司 Method for executing intelligent contract, block chain node and storage medium
CN111770204B (en) * 2020-08-31 2021-10-22 支付宝(杭州)信息技术有限公司 Method for executing intelligent contract, block chain node and storage medium
CN111770113B (en) * 2020-08-31 2021-07-30 支付宝(杭州)信息技术有限公司 Method for executing intelligent contract, block chain node and node equipment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190278767A1 (en) * 2017-08-23 2019-09-12 Zhongan Information Technology Service Co., Ltd. Smart contract upgrade method and system based on alliance chain
US20200119905A1 (en) * 2018-10-15 2020-04-16 Adobe Inc. Smart contract platform for generating and customizing smart contracts
CN111770206A (en) * 2020-08-31 2020-10-13 支付宝(杭州)信息技术有限公司 Method for deploying intelligent contract, block chain node and storage medium
CN111768184A (en) * 2020-08-31 2020-10-13 支付宝(杭州)信息技术有限公司 Method for executing intelligent contract and block link point
CN111814202A (en) * 2020-08-31 2020-10-23 支付宝(杭州)信息技术有限公司 Method for executing intelligent contract, block chain node and storage medium
CN112596754A (en) * 2021-03-01 2021-04-02 腾讯科技(深圳)有限公司 Block chain intelligent contract deployment method and device
CN113220327A (en) * 2021-05-11 2021-08-06 支付宝(杭州)信息技术有限公司 Intelligent contract upgrading method and block chain system
CN113220326A (en) * 2021-05-11 2021-08-06 支付宝(杭州)信息技术有限公司 Intelligent contract upgrading method and block chain system

Also Published As

Publication number Publication date
CN113220326A (en) 2021-08-06
CN113220326B (en) 2022-09-16

Similar Documents

Publication Publication Date Title
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
CN111770205B (en) Method, block chain node, system and storage medium for executing intelligent contract
WO2022237590A1 (en) Smart contract upgrading method and blockchain system
CN111770116B (en) Method for executing intelligent contract, block chain node and storage medium
EP3961973B1 (en) Methods, blockchain nodes, and storage media for deploying smart contract
CN111815310B (en) Method for executing intelligent contract, block chain node and storage medium
EP3961460B1 (en) Methods, blockchain nodes and storage media for deploying smart contract
EP3961390A1 (en) Method for executing smart contract and blockchain node
CN111770204B (en) Method for executing intelligent contract, block chain node and storage medium
EP3961438B1 (en) Method for executing smart contract, blockchain node, and storage medium
CN111768200A (en) Method for deploying intelligent contract, block chain node and storage medium
CN111770202B (en) Method for executing intelligent contract, block chain node and storage medium
CN113220327B (en) Intelligent contract upgrading method and block chain system
You et al. A static region‐based compiler for the Dalvik virtual machine

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22806558

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE