BACKGROUND

Technical Field

Implementations of the present specification pertain to the field of blockchain technologies, and in particular, to a method for executing a smart contract and a blockchain node.

Description of the Related Art

A blockchain is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, and an encryption algorithm. In the 2.0 era of the blockchain, a smart contract appears, which greatly expands the application range of the blockchain. With a smart contract, a blockchain can invoke a segment of code that can be customized by a user, instead of performing only transfer transactions.

BRIEF SUMMARY

The present specification provides a method for executing a smart contract, a blockchain system, and a node device.

Implementations of the present specification provide a method for executing a smart contract and a blockchain node, which are implemented in the following methods:

A method for executing a smart contract includes: receiving, by a blockchain node, a request for creating a smart contract, the request including a bytecode of the smart contract; starting, by the blockchain node after completing deployment of the smart contract, to compile the bytecode of the smart contract into a machine code by using just-in-time (JIT) and storing the machine code; and in execution of the deployed smart contract, executing, by the blockchain node, the machine code corresponding to a bytecode of the smart contract in response to the machine code being locally stored.

A method for executing a smart contract includes: starting, by a blockchain node after deploying a bytecode of a smart contract, to compile the bytecode of the smart contract into a machine code by using JIT and storing the machine code; and in execution of the deployed smart contract, executing, by the blockchain node, the machine code of the smart contract in response to the machine code being locally stored.

A blockchain node for executing a smart contract performs the above method.

A blockchain node for executing a smart contract includes: a processor; and a memory storing a program, where the above method is performed when the processor executes the program.

A storage medium is used for storing a program, where the program performs an operation of the above method when executed.

According to the above implementations of the present application, when a machine code of a smart contract is stored, because the machine code itself is directly executable by a CPU, the blockchain node can greatly increase a speed of executing the smart contract.

