IP Library Granted Patent US 11,010,303
Granted Patent B2
US 11,010,303 · App. 16/944,122 · Granted May 18, 2021

Deploying a smart contract

Inventor: Zhongxiao Yao (Hangzhou, CN)
Assignee: Advanced New Technologies Co., Ltd.
G06F12/0875G06F12/04G06F16/2282G06F16/2443G06F16/28G06F2212/452
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,010,303
App. No.
16/944,122
Granted
May 18, 2021
Kind
B2
Abstract

Implementations of the present specification provide a method for deploying a smart contract. According to one implementation the method includes: receiving a transaction request for invoking a first contract; obtaining a first instruction code and a function index table, wherein the function index table is used to indicate a memory address of an instruction code corresponding to each of import and export functions in the first contract; determining a first memory address corresponding to the invocation function based on the function index table; and executing the first instruction code in the first memory address based on the determined first memory address.

Claims (40)

1. A computer-implemented method for executing a smart contract comprising:

receiving, by a node in a blockchain network, a transaction request for invoking a first contract, wherein the transaction request comprises a contract address and an invocation function of the first contract;

obtaining, from a cache memory, a first instruction code and a function index table that correspond to the first contract and are stored in the cache memory during a phase of deploying the first contract, wherein the function index table is used to indicate a memory address of an instruction code corresponding to each of import and export functions in the first contract;

determining a first memory address corresponding to the invocation function based on the function index table, wherein the function index table comprises a first index table and a second index table, the first index table comprises a mapping relationship between a function name of each of the import and export functions and one or more function index numbers, and the second index table comprises a mapping relationship between the one or more function index numbers and one or more memory addresses; and

executing the first instruction code in the first memory address based on the determined first memory address.

2. The computer-implemented method of claim 1 , wherein determining the first memory address corresponding to the invocation function based on the function index table comprises:

searching the first index table based on a function name of the invocation function to determine an index number corresponding to the invocation function; and

searching the second index table by using the determined index number to determine a corresponding memory address as the first memory address.

3. The computer-implemented method of claim 1 , wherein the function index table comprises a mapping relationship between the function name and a memory address of the one or more memory addresses.

4. The computer-implemented method of claim 1 , wherein the phase of deploying the first contract is completed prior to obtaining the first instruction code and the function index table from the cache memory.

5. The computer-implemented method of claim 1 , wherein bytecode comprised in a contract module corresponding to the first contract is parsed into executable instruction code and used to determine the function index table stored in the cache memory prior to the node in the blockchain network receiving the transaction request for invoking the first contract.

6. The computer-implemented method of claim 5 , wherein the bytecode is encoded using a first coding protocol.

7. The computer-implemented method of claim 6 , wherein the first coding protocol is a variable-length coding protocol.

8. The computer-implemented method of claim 6 , wherein the first contract is parsed into the executable instruction code using a decoding protocol corresponding to the first coding protocol.

9. The computer-implemented method of claim 6 , wherein a variable-length instruction is converted into a memory-aligned fixed-length instruction.

10. The computer-implemented method of claim 6 , wherein the contract module is a WebAssembly (WASM) module, and the first coding protocol is a leb 128 coding protocol.

11. The computer-implemented method of claim 5 , wherein the bytecode is parsed into the executable instruction code using a memory-aligned instruction storage location to modify a target address in a control transfer instruction.

12. A non-transitory, computer-readable medium storing one or more instructions executable by a computer system to perform operations for executing a smart contract comprising:

receiving, by a node in a blockchain network, a transaction request for invoking a first contract, wherein the transaction request comprises a contract address and an invocation function of the first contract;

obtaining, from a cache memory, a first instruction code and a function index table that correspond to the first contract and are stored in the cache memory during a phase of deploying the first contract, wherein the function index table is used to indicate a memory address of an instruction code corresponding to each of import and export functions in the first contract;

determining a first memory address corresponding to the invocation function based on the function index table, wherein the function index table comprises a first index table and a second index table, the first index table comprises a mapping relationship between a function name of each of the import and export functions and one or more function index numbers, and the second index table comprises a mapping relationship between the one or more function index numbers and one or more memory addresses; and

executing the first instruction code in the first memory address based on the determined first memory address.

13. The non-transitory, computer-readable medium of claim 12 , wherein determining the first memory address corresponding to the invocation function based on the function index table comprises:

searching the first index table based on a function name of the invocation function to determine an index number corresponding to the invocation function; and

searching the second index table by using the determined index number to determine a corresponding memory address as the first memory address.

14. The non-transitory, computer-readable medium of claim 12 , wherein the function index table comprises a mapping relationship between the function name and a memory address of the one or more memory addresses.

15. The non-transitory, computer-readable medium of claim 12 , wherein the phase of deploying the first contract is completed prior to obtaining the first instruction code and the function index table from the cache memory.

16. 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 one or more operations for executing a smart contract, wherein the operations comprise:

receiving, by a node in a blockchain network, a transaction request for invoking a first contract, wherein the transaction request comprises a contract address and an invocation function of the first contract;

obtaining, from a cache memory, a first instruction code and a function index table that correspond to the first contract and are stored in the cache memory during a phase of deploying the first contract, wherein the function index table is used to indicate a memory address of an instruction code corresponding to each of import and export functions in the first contract;

determining a first memory address corresponding to the invocation function based on the function index table, wherein the function index table comprises a first index table and a second index table, the first index table comprises a mapping relationship between a function name of each of the import and export functions and one or more function index numbers, and the second index table comprises a mapping relationship between the one or more function index numbers and one or more memory addresses; and

executing the first instruction code in the first memory address based on the determined first memory address.

17. The computer-implemented system of claim 16 , wherein the phase of deploying the first contract is completed prior to obtaining the first instruction code and the function index table from the cache memory.

18. The computer-implemented system of claim 16 , wherein determining the first memory address corresponding to the invocation function based on the function index table comprises:

searching the first index table based on a function name of the invocation function to determine an index number corresponding to the invocation function; and

searching the second index table by using the determined index number to determine a corresponding memory address as the first memory address.

19. The computer-implemented system of claim 16 , wherein the function index table comprises a mapping relationship between the function name and a memory address of the one or more memory addresses.

20. The computer-implemented system of claim 16 , wherein bytecode comprised in a contract module corresponding to the first contract is parsed into executable instruction code and used to determine the function index table stored in the cache memory prior to the node in the blockchain network receiving the transaction request for invoking the first contract.

Assignments (3)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 10, 2020
From: ADVANTAGEOUS NEW TECHNOLOGIES CO., LTD.
To: ADVANCED NEW TECHNOLOGIES CO., LTD.
Reel/Frame 053754/0625 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 31, 2020
From: YAO, ZHONGXIAO
To: ALIBABA GROUP HOLDING LIMITED
Reel/Frame 053649/0689 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 31, 2020
From: ALIBABA GROUP HOLDING LIMITED
To: ADVANTAGEOUS NEW TECHNOLOGIES CO., LTD.
Reel/Frame 053743/0464 →
Cited By (2)
US 12,524,575 US 12,658,297