Smart Contract JIT Compilation for Blockchain Execution Speed

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Blockchain nodes in decentralized systems face challenges in executing smart contracts across different hardware configurations and software environments, leading to inconsistencies and inefficiencies due to the need for multiple machine code versions and reduced execution efficiency.

Innovation Solution

Implementing a method that uses Just-In-Time (JIT) compilation to identify and cache hotspot code within smart contracts, allowing for efficient execution on various nodes by marking critical code sections with a hotspot identifier and optimizing compilation to balance execution speed and memory usage.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If multiple machine code versions are maintained for different hardware configurations, then compatibility across diverse environments is improved, but device complexity and storage requirements increase

Engineering Contradiction:
ImprovecompatibilityVSAvoidcomplexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent uses virtual machine bytecode as a universal copy that can be executed across different hardware architectures. Instead of maintaining multiple native machine code versions, a single bytecode format is created that serves as a platform-independent copy, allowing the same code to run on diverse hardware through the virtual machine abstraction layer.

Inventive Principle:
Principle #26Copying

Solution Approach 2:

The virtual machine acts as an intermediary between the high-level bytecode and various hardware platforms. The virtual machine translates and executes the platform-independent bytecode into hardware-specific instructions at runtime, eliminating the need for pre-compiling multiple machine code versions for different hardware configurations.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Speed

If full smart contract code is compiled and cached, then execution speed is improved, but storage overhead increases

Engineering Contradiction:
Improveexecution speedVSAvoidstorage overhead
Core Design Contradiction:
SpeedVSQuantity of substance

Solution Approach 1:

The patent segments the smart contract code into two parts: the immutable bytecode stored on-chain and the executable machine code generated locally. Only the necessary bytecode is stored in the blockchain, while the machine code is generated on-demand during execution, reducing storage overhead while maintaining execution speed through local compilation caching.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system performs preliminary compilation of the bytecode into machine code before execution, caching the compiled result for subsequent use. This preliminary action of compiling and caching the machine code enables fast execution speeds while avoiding the need to store the complete original code, thus reducing storage requirements.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentEP3961376B1Improving smart contracts execution with just-in-time compilation
Publication Date: 2023.12.27 ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
  • EP3961376B1 patent drawingFigure 1
  • EP3961376B1 patent drawingFigure 2~3
  • EP3961376B1 patent drawingFigure 4~5

AI summary

The present specification provides a method, a blockchain node, and a node device for executing a smart contract. An embodiment of the method for executing a smart contract includes: receiving, by a blockchain node, a request for creating a smart contract, where the request includes code of the smart contract, and the code of the smart contract includes hotspot code marked by using a hotspot identifier; compiling, by the blockchain node, the code of the smart contract into machine code through Just-In-Time (JIT) compilation after deploying the smart contract, and storing the hotspot code marked by using the hotspot identifier; and executing, by the blockchain node when executing the deployed smart contract, the machine code if the machine code corresponding to the code of the smart contract is locally stored. In the embodiments of the present specification, the blockchain node can greatly increase the speed of executing the smart contract.