Wasm Smart Contract Execution With Codehash Caching

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing smart contract execution engines face performance issues due to the inefficiencies of WebAssembly (Wasm) bytecode execution, particularly in blockchain environments, where complex functions like the start function incur significant overheads and time consumption.

Innovation Solution

Optimize Wasm bytecode by determining a codehash of the Wasm contract, creating a linear memory, and executing the bytecode with a Wasm virtual machine instance, optimizing and caching a Wasm module object to improve execution efficiency.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Speed

If Wasm bytecode is executed directly without optimization, then the execution process is simple, but the execution speed is slow and overhead is high

Engineering Contradiction:
Improveexecution speedVSAvoidexecution process complexity
Core Design Contradiction:
SpeedVSDevice complexity

Solution Approach 1:

The patent applies preliminary action by optimizing Wasm bytecode before execution. The system performs bytecode optimization in advance, converting unoptimized Wasm bytecode into optimized form and caching the results. This preliminary optimization reduces execution overhead and improves speed during actual contract execution, resolving the contradiction between execution speed and process complexity.

Inventive Principle:
Principle #10Preliminary action

2Productivity

If Wasm bytecode is optimized and cached, then execution efficiency is improved, but memory usage increases

Engineering Contradiction:
Improveexecution efficiencyVSAvoidmemory usage
Core Design Contradiction:
ProductivityVSQuantity of substance

Solution Approach 1:

The patent extracts only the necessary optimized components for caching. Instead of caching entire Wasm modules, the system extracts and caches specifically the optimized bytecode portions that will be reused during execution. This selective extraction reduces memory consumption while maintaining execution efficiency benefits.

Inventive Principle:
Principle #2Taking out (Extraction)

3Reliability

If complex functions like start function are executed, then complete functionality is achieved, but overhead and time consumption increase

Engineering Contradiction:
Improvefunctionality completenessVSAvoidtime consumption
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent extracts and removes unnecessary complex functions from the Wasm bytecode during optimization. Specifically, the start function and other non-essential complex functions are identified and extracted, reducing execution overhead while maintaining the core functionality needed for smart contract execution. This resolves the contradiction between functionality completeness and time consumption.

Inventive Principle:
Principle #2Taking out (Extraction)

Data Source

PatentUS20260104870A1Smart contract calling methods, execution methods, computer devices, and storage media
Publication Date: 2026.04.16 ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
  • US20260104870A1 patent drawing
  • US20260104870A1 patent drawing
  • US20260104870A1 patent drawing

AI summary

Smart contract calling is described. A blockchain node receives a transaction that calls a contract. The transaction indicates a called contract account address, a called function, and an input parameter, and the contract is a WebAssembly (Wasm) contract existing before optimization. The blockchain node determines a codehash of the Wasm contract based on the contract account address, and optimizes Wasm bytecode corresponding to the codehash, to obtain and cache a Wasm module object. Each process of executing the Wasm bytecode includes: starting a Wasm virtual machine instance, creating a linear memory corresponding to the instance based on the cached Wasm module object, and filling the linear memory. Code is executed in a code segment in the Wasm module object based on the filled linear memory and the input parameter.