# US 2021/0342131 A1 · Methods, blockchain nodes, and storage media for executing smart contract

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0342131 A1
- Document ID: US20210342131A1
- Status: Published application
- Kind: A1
- Application number: 17/363,520
- Filed: 2021-06-30
- Published: 2021-11-04
- Earliest claimed: 2020-08-31
- Assignees: Alipay (Hangzhou) Information Technology Co., Ltd.
- Applicants: Alipay (Hangzhou) Information Technology Co., Ltd.
- Inventors: Qi Liu
- Web page: https://patentgrep.com/patent/US20210342131A1

## CPC

- G06F 8/41: Compilation
- H04L 9/3239: {involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD}
- G06F 9/45508: {Runtime interpretation or emulation, e g. emulator loops, bytecode interpretation}
- G06F 9/45516: {Runtime code conversion or optimisation}
- G06F 16/2315: {Optimistic concurrency control}
- G06F 21/64: Protecting data integrity, e.g. using checksums, certificates or signatures
- G06Q 20/02: involving a neutral party, e.g. certification authority, notary or trusted third party [TTP]
- H04L 9/50: {using hash chains, e.g. blockchains or hash trees}
- G06Q 10/10: Office automation; Time management
- G06Q 20/389: {Keeping log of transactions for guaranteeing non-repudiation of a transaction}
- G06Q 2220/00: Business processing using cryptography
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)
- G06Q: INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR

## Abstract

Methods, systems, and apparatus for executing a smart contract by a blockchain node of a blockchain. An example method includes receiving bytecode of a smart contract; deploying the smart contract, comprising storing the bytecode of the smart contract on the blockchain; compiling, through Just-In-Time (JIT) compilation, the bytecode of the smart contract into machine code; locally storing the machine code in a memory of the blockchain node; and executing the smart contract deployed on the blockchain, comprising determining whether the machine code corresponding to the bytecode of the smart contract is locally stored in the memory of the blockchain node, and interpreting and executing the bytecode of the smart contract if the machine code corresponding to the bytecode of the smart contract is not locally stored.

## Claims

### Claim 1

A computer-implemented method performed by a blockchain node of a blockchain, comprising:
receiving bytecode of a smart contract;
deploying the smart contract, comprising storing the bytecode of the smart contract on the blockchain;
compiling, through Just-In-Time (JIT) compilation, the bytecode of the smart contract into machine code;
locally storing the machine code in a memory of the blockchain node; and
executing the smart contract deployed on the blockchain, comprising
determining whether the machine code corresponding to the bytecode of the smart contract is locally stored in the memory of the blockchain node, and
interpreting and executing the bytecode of the smart contract if the machine code corresponding to the bytecode of the smart contract is not locally stored.

### Claim 2 (depends on 1)

The computer-implemented method according to claim 1, wherein compiling, through Just-In-Time (JIT) compilation, the bytecode of the smart contract into the machine code comprises:
compiling the bytecode of the smart contract through JIT compilation immediately after deploying the smart contract; or
compiling the bytecode of the smart contract through JIT compilation during an idle time period after deploying the smart contract; or
compiling the bytecode of the smart contract through JIT compilation in response to receiving a transaction request for invoking the smart contract that has been deployed.

### Claim 3 (depends on 1)

The computer-implemented method according to claim 1, wherein compiling, through Just-In-Time (JIT) compilation, the bytecode of the smart contract into the machine code comprises:
compiling hotspot bytecode that has been identified from the bytecode of the smart contract during a process of translating or executing the bytecode of the smart contract; or
performing optimizing compilation during the process of translating or executing the bytecode of the smart contract.

### Claim 4 (depends on 3)

The computer-implemented method according to claim 3, wherein a granularity of identifying the hotspot bytecode comprises a function level or a code block level.

### Claim 5 (depends on 1)

The computer-implemented method according to claim 1, wherein interpreting and executing the bytecode of the smart contract if the machine code corresponding to the bytecode of the smart contract is not locally stored comprises:
querying a current JIT compilation status of the bytecode of the smart contract; and
interpreting and executing the bytecode of the smart contract if the current JIT compilation status specifies that the bytecode of the smart contract is currently being compiled through JIT compilation.

### Claim 6 (depends on 5)

The computer-implemented method according to claim 5, further comprising:
if the current JIT compilation status specifies that a JIT compilation has not been started, starting the JIT compilation, and interpreting and executing the bytecode of the smart contract.

### Claim 7 (depends on 1)

The computer-implemented method according to claim 1, wherein interpreting and executing the bytecode of the smart contract comprises:
interpreting and executing bytecode that corresponds to a function invoked in the smart contract.

### Claim 8 (depends on 1)

The computer-implemented method according to claim 1, wherein executing the smart contract deployed on the blockchain further comprises:
executing the machine code if the machine code corresponding to the bytecode of the smart contract is locally stored.

### Claim 9 (depends on 8)

The computer-implemented method according to claim 8, wherein executing the machine code comprises:
executing machine code that corresponds to a function invoked in the smart contract or a code block of the smart contract.

### Claim 10 (depends on 1)

The computer-implemented method according to claim 1, wherein the memory is a cache.

### Claim 11 (depends on 1)

The computer-implemented method according to claim 1, wherein receiving the bytecode of the smart contract comprises:
receiving a request for creating the smart contract, wherein the request comprises the bytecode of the smart contract.

### Claim 12

A non-transitory, computer-readable medium storing one or more instructions executable by a computer system to perform operations comprising:
receiving, by a blockchain node of a blockchain, bytecode of a smart contract;
deploying, by the blockchain node, the smart contract, comprising storing the bytecode of the smart contract on the blockchain;
compiling, by the blockchain node and through Just-In-Time (JIT) compilation, the bytecode of the smart contract into machine code;
locally storing, by the blockchain node, the machine code in a memory of the blockchain node; and
executing, by the blockchain node, the smart contract deployed on the blockchain, comprising
determining whether the machine code corresponding to the bytecode of the smart contract is locally stored in the memory of the blockchain node, and
interpreting and executing the bytecode of the smart contract if the machine code corresponding to the bytecode of the smart contract is not locally stored.

### Claim 13

A computer-implemented system, comprising:
one or more computers; and
one or more computer memory devices interoperably coupled with the one or more computers and having tangible, non-transitory, machine-readable media storing one or more instructions that, when executed by the one or more computers, perform operations comprising:
receiving, by a blockchain node of a blockchain, bytecode of a smart contract;
deploying, by the blockchain node, the smart contract, comprising storing the bytecode of the smart contract on the blockchain;
compiling, by the blockchain node and through Just-In-Time (JIT) compilation, the bytecode of the smart contract into machine code;
locally storing, by the blockchain node, the machine code in a memory of the blockchain node; and
executing, by the blockchain node, the smart contract deployed on the blockchain, comprising
determining whether the machine code corresponding to the bytecode of the smart contract is locally stored in the memory of the blockchain node, and
interpreting and executing the bytecode of the smart contract if the machine code corresponding to the bytecode of the smart contract is not locally stored.

### Claim 14 (depends on 13)

The computer-implemented system according to claim 13, wherein compiling, through Just-In-Time (JIT) compilation, the bytecode of the smart contract into the machine code comprises:
compiling the bytecode of the smart contract through JIT compilation immediately after deploying the smart contract; or
compiling the bytecode of the smart contract through JIT compilation during an idle time period after deploying the smart contract; or
compiling the bytecode of the smart contract through JIT compilation in response to receiving a transaction request for invoking the smart contract that has been deployed.

### Claim 15 (depends on 13)

The computer-implemented system according to claim 13, wherein compiling, through Just-In-Time (JIT) compilation, the bytecode of the smart contract into the machine code comprises:
compiling hotspot bytecode that has been identified from the bytecode of the smart contract during a process of translating or executing the bytecode of the smart contract; or
performing optimizing compilation during the process of translating or executing the bytecode of the smart contract.

### Claim 16 (depends on 15)

The computer-implemented system according to claim 15, wherein a granularity of identifying the hotspot bytecode comprises a function level or a code block level.

### Claim 17 (depends on 13)

The computer-implemented system according to claim 13, wherein interpreting and executing the bytecode of the smart contract if the machine code corresponding to the bytecode of the smart contract is not locally stored comprises:
querying a current JIT compilation status of the bytecode of the smart contract; and
interpreting and executing the bytecode of the smart contract if the current JIT compilation status specifies that the bytecode of the smart contract is currently being compiled through JIT compilation.

### Claim 18 (depends on 17)

The computer-implemented system according to claim 17, wherein the operations further comprise:
if the current JIT compilation status specifies that a JIT compilation has not been started, starting the JIT compilation, and interpreting and executing the bytecode of the smart contract.

### Claim 19 (depends on 13)

The computer-implemented system according to claim 13, wherein interpreting and executing the bytecode of the smart contract comprises:
interpreting and executing bytecode that corresponds to a function invoked in the smart contract.

### Claim 20 (depends on 13)

The computer-implemented system according to claim 13, wherein executing the smart contract deployed on the blockchain further comprises:
executing the machine code if the machine code corresponding to the bytecode of the smart contract is locally stored.
