IP Library › Granted Patent US 11,379,830
Granted Patent B2
US 11,379,830 · App. 17/351,998 · Granted Jul 5, 2022

Method for executing smart contract, blockchain node, and storage medium

Inventors: Ying Yan (Zhejiang, CN); Changzheng Wei (Zhejiang, CN); Xuepeng Guo (Zhejiang, CN)
Assignee: Alipay (Hangzhou) Information Technology Co., Ltd.
G06Q20/3825G06F8/425G06F8/4441G06F9/4552G06Q20/38215H04L9/3242H04L9/3247H04L2209/38H04L2209/56
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,379,830
App. No.
17/351,998
Granted
Jul 5, 2022
Kind
B2
Abstract

The present specification provides a method for executing a smart contract, a blockchain node, and a storage medium. An implementation of 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 first machine code by using ahead-of-time compilation and storing the machine code; and performing, by the blockchain node in execution of the deployed smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on the bytecode of the smart contract to obtain a second machine code and storing the second machine code, and executing the second machine code.

Claims (63)

1. A method for executing a smart contract, comprising:

starting, by a blockchain node of a blockchain network after a smart contract of bytecodes has been deployed in the blockchain network, to compile a bytecode of the bytecodes of the smart contract into a first machine code by using ahead-of-time (AoT) compilation and storing the first machine code; and

performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, just-in-time (JIT) compilation on a bytecode of the bytecodes of the smart contract to obtain a second machine code and storing the second machine code, and executing the second machine code,

wherein the performing, by the blockchain node of the blockchain network in the execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on the bytecode of the bytecodes of the smart contract includes:

querying, by the blockchain node of the blockchain network in the execution of the smart contract, a current AoT compilation status of the bytecode of the bytecodes of the smart contract in response to the first machine code of the smart contract not being locally stored;

in response to the bytecode of the bytecodes of the smart contract being in AoT compilation, performing JIT compilation on the bytecode of the bytecodes of the smart contract; and

in response to the bytecode of the bytecodes of the smart contract not being in AoT compilation, starting AoT compilation and performing JIT compilation on the bytecode of the bytecodes of the smart contract.

2. The method according to claim 1 , wherein the starting to compile the bytecode of the bytecodes of the smart contract into the first machine code by using AoT compilation includes:

starting, by the blockchain node after the smart contract has been deployed in the blockchain network, AoT compilation on the bytecode of the bytecodes of the smart contract; or

performing, by the blockchain node after the smart contract has been deployed in the blockchain network, AoT compilation on the bytecode of the bytecodes of the smart contract within a determined idle time period.

3. The method according to claim 1 , wherein the performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on the bytecode of the bytecodes of the smart contract to obtain the second machine code and storing the second machine code includes:

performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on a bytecode corresponding to an invoked function in the smart contract.

4. The method according to claim 1 , wherein the performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on the bytecode of the bytecodes of the smart contract to obtain the second machine code and storing the second machine code includes at least one of:

in a process of at least one of interpreting or executing the bytecode of the bytecodes of the smart contract, identifying a hotspot second machine code, and storing the hotspot second machine code for subsequent invoking; or

performing optimizing compilation to obtain the second machine code and storing the second machine code in the process of at least one of interpreting or executing the bytecode of the bytecodes of the smart contract.

5. The method according to claim 1 , further comprising:

in execution of the smart contract, executing, by the blockchain node of the blockchain network, the first machine code of the smart contract in response to the first machine code of the smart contract being locally stored.

6. The method according to claim 5 , wherein the executing, by the blockchain node of the blockchain network, the first machine code of the smart contract includes:

executing, by the blockchain node of the blockchain network, the stored first machine code of the smart contract corresponding to an invoked function in the smart contract.

7. The method according to claim 1 , wherein the storing is caching.

8. The method according to claim 1 , further comprising:

receiving, by the blockchain node of the blockchain network, a request for deploying the smart contract in the blockchain network, wherein the request includes the bytecodes of the smart contract; and

causing, by the blockchain node of the blockchain network, deployment of the smart contract in the blockchain network.

9. A blockchain node for executing a smart contract, comprising:

a processor; and

a memory coupled to the processor and having executable instructions stored thereon that are executable by the processor to perform acts including:

starting, by a blockchain node of a blockchain network after a smart contract of bytecodes has been deployed in the blockchain network, to compile a bytecode of the bytecodes of the smart contract into a first machine code by using ahead-of-time (AoT) compilation and storing the first machine code; and

performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, just-in-time (JIT) compilation on a bytecode of the bytecodes of the smart contract to obtain a second machine code and storing the second machine code, and executing the second machine code,

wherein the performing, by the blockchain node of the blockchain network in the execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on the bytecode of the bytecodes of the smart contract includes:

querying, by the blockchain node of the blockchain network in the execution of the smart contract, a current AoT compilation status of the bytecode of the bytecodes of the smart contract in response to the first machine code of the smart contract not being locally stored;

in response to the bytecode of the bytecodes of the smart contract being in AoT compilation, performing JIT compilation on the bytecode of the bytecodes of the smart contract; and

in response to the bytecode of the bytecodes of the smart contract not being in AoT compilation, starting AoT compilation and performing JIT compilation on the bytecode of the bytecodes of the smart contract.

10. The blockchain node according to claim 9 , wherein the starting to compile the bytecode of the bytecodes of the smart contract into the first machine code by using AoT compilation includes:

starting, by the blockchain node after the smart contract has been deployed in the blockchain network, AoT compilation on the bytecode of the bytecodes of the smart contract; or

performing, by the blockchain node after the smart contract has been deployed in the blockchain network, AoT compilation on the bytecode of the bytecodes of the smart contract within a determined idle time period.

11. The blockchain node according to claim 9 , wherein the performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on the bytecode of the bytecodes of the smart contract to obtain the second machine code and storing the second machine code includes:

performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on a bytecode corresponding to an invoked function in the smart contract.

12. The blockchain node according to claim 9 , wherein the performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on the bytecode of the bytecodes of the smart contract to obtain the second machine code and storing the second machine code includes at least one of:

in a process of at least one of interpreting or executing the bytecode of the bytecodes of the smart contract, identifying a hotspot second machine code, and storing the hotspot second machine code for subsequent invoking; or

performing optimizing compilation to obtain the second machine code and storing the second machine code in the process of at least one of interpreting or executing the bytecode of the bytecodes of the smart contract.

13. The blockchain node according to claim 9 , wherein the acts further include:

in execution of the smart contract, executing, by the blockchain node of the blockchain network, the first machine code of the smart contract in response to the first machine code of the smart contract being locally stored.

14. The blockchain node according to claim 13 , wherein the executing, by the blockchain node of the blockchain network, the first machine code of the smart contract includes:

executing, by the blockchain node of the blockchain network, the stored first machine code of the smart contract corresponding to an invoked function in the smart contract.

15. The blockchain node according to claim 9 , wherein the storing is caching.

16. The blockchain node according to claim 9 , wherein the acts further include:

receiving, by the blockchain node of the blockchain network, a request for deploying the smart contract in the blockchain network, wherein the request includes the bytecodes of the smart contract; and

causing, by the blockchain node of the blockchain network, deployment of the smart contract in the blockchain network.

17. A non-transitory computer storage medium, the storage medium having executable instructions stored thereon that are executable by one or more processors to perform acts including:

starting, by a blockchain node of a blockchain network after a smart contract of bytecodes has been deployed in the blockchain network, to compile a bytecode of the bytecodes of the smart contract into a first machine code by using ahead-of-time (AoT) compilation and storing the first machine code; and

performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, just-in-time (JIT) compilation on a bytecode of the bytecodes of the smart contract to obtain a second machine code and storing the second machine code, and executing the second machine code,

wherein the performing, by the blockchain node of the blockchain network in the execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on the bytecode of the bytecodes of the smart contract includes:

querying, by the blockchain node of the blockchain network in the execution of the smart contract, a current AoT compilation status of the bytecode of the bytecodes of the smart contract in response to the first machine code of the smart contract not being locally stored;

in response to the bytecode of the bytecodes of the smart contract being in AoT compilation, performing JIT compilation on the bytecode of the bytecodes of the smart contract; and

in response to the bytecode of the bytecodes of the smart contract not being in AoT compilation, starting AoT compilation and performing JIT compilation on the bytecode of the bytecodes of the smart contract.

18. The non-transitory computer storage medium according to claim 17 , wherein the starting to compile the bytecode of the bytecodes of the smart contract into the first machine code by using AoT compilation includes:

starting, by the blockchain node after the smart contract has been deployed in the blockchain network, AoT compilation on the bytecode of the bytecodes of the smart contract; or

performing, by the blockchain node after the smart contract has been deployed in the blockchain network, AoT compilation on the bytecode of the bytecodes of the smart contract within a determined idle time period.

19. The non-transitory computer storage medium according to claim 17 , wherein the performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on the bytecode of the bytecodes of the smart contract to obtain the second machine code and storing the second machine code includes:

performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on a bytecode corresponding to an invoked function in the smart contract.

20. The non-transitory computer storage medium according to claim 17 , wherein the performing, by the blockchain node of the blockchain network in execution of the smart contract and in response to the first machine code of the smart contract not being locally stored, JIT compilation on the bytecode of the bytecodes of the smart contract to obtain the second machine code and storing the second machine code includes at least one of:

in a process of at least one of interpreting or executing the bytecode of the bytecodes of the smart contract, identifying a hotspot second machine code, and storing the hotspot second machine code for subsequent invoking; or

performing optimizing compilation to obtain the second machine code and storing the second machine code in the process of at least one of interpreting or executing the bytecode of the bytecodes of the smart contract.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Mar 18, 2025
From: ALIPAY (HANGZHOU) INFORMATION TECHNOLOGY CO., LTD.
To: ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO., LTD.
Reel/Frame 070552/0207 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jun 23, 2021
From: YAN, YING; WEI, CHANGZHENG; GUO, XUEPENG
To: ALIPAY (HANGZHOU) INFORMATION TECHNOLOGY CO., LTD.
Reel/Frame 056639/0577 →
Priority Claims (1)
CN 202010899207.2 · Aug 31, 2020 · national
Continuity (1)
Related Publication 20220067721A1 · Mar 3, 2022