Smart Contract AoT Compilation Storage Overhead

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In the context of blockchain technologies, especially in the 2.0 era, executing smart contracts efficiently across diverse hardware and software environments is challenging due to differences in processor architectures and instruction sets, leading to increased storage overheads and reduced execution efficiency.

Innovation Solution

The method involves compiling smart contract bytecode into machine code using Ahead-Of-Time (AoT) compilation before deployment, allowing each blockchain node to perform local AoT compilation and interpretation execution, reducing the need for multiple machine code versions and minimizing storage requirements.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If smart contract bytecode is compiled into machine code using traditional just-in-time (JIT) compilation for each blockchain node, then execution efficiency is improved, but storage overhead increases due to needing multiple versions for different processor architectures

Engineering Contradiction:
Improveexecution efficiencyVSAvoidstorage overhead
Core Design Contradiction:
ProductivityVSQuantity of substance

Solution Approach 1:

The patent applies ahead-of-time (AoT) compilation to pre-compile smart contract bytecode into machine code before deployment on the blockchain. This preliminary compilation action allows the compiled machine code to be stored once in the blockchain, eliminating the need for each node to perform JIT compilation and store multiple architecture-specific versions, thus reducing storage overhead while maintaining execution efficiency

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent creates a universal compilation solution where the same compiled machine code can be executed across different processor architectures. By using AoT compilation with architecture-specific target selection during compilation, the system achieves multi-functionality where one compiled version serves multiple deployment scenarios, reducing the need for nodes to maintain multiple machine code versions

Inventive Principle:
Principle #6Universality (Multi-functionality)

2Adaptability or versatility

If each blockchain node performs local AoT compilation for smart contract bytecode, then cross-platform portability is improved, but processing time during deployment increases

Engineering Contradiction:
Improvecross-platform portabilityVSAvoidprocessing time
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

The patent performs AoT compilation as a preliminary action during smart contract deployment rather than requiring each node to compile locally. The compiler generates machine code for the target architecture in advance, and this pre-compiled code is then deployed to the blockchain, achieving cross-platform portability without imposing compilation time penalties on individual nodes

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent enables the compilation process to be performed by the deployer or a centralized compilation service rather than requiring each blockchain node to perform self-service compilation. This approach maintains cross-platform portability through targeted compilation while avoiding the time loss that would occur if every node independently performed compilation

Inventive Principle:
Principle #25Self-service

3Quantity of substance

If smart contract bytecode is interpreted and executed without pre-compilation, then storage requirements are reduced, but execution speed decreases

Engineering Contradiction:
Improvestorage requirementsVSAvoidexecution speed
Core Design Contradiction:
Quantity of substanceVSSpeed

Solution Approach 1:

The patent applies ahead-of-time compilation to pre-compile smart contract bytecode into optimized machine code before deployment. This preliminary compilation action produces executable machine code that is stored in the blockchain, enabling fast execution without requiring interpretation at runtime, thus resolving the trade-off between storage requirements and execution speed

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent implements a dynamic execution model where the blockchain node can select between interpreting bytecode and executing pre-compiled machine code based on availability. When machine code is available from AoT compilation, it is executed for high speed; when not available, bytecode interpretation serves as a fallback, optimizing the balance between storage and execution speed

Inventive Principle:
Principle #15Dynamics

Data Source

PatentEP3961437B1Method for executing smart contract, blockchain node, and storage medium
Publication Date: 2023.06.07 ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
  • EP3961437B1 patent drawingFigure 1
  • EP3961437B1 patent drawingFigure 2
  • EP3961437B1 patent drawingFigure 3~4

AI summary

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 machine code by using ahead of time (AoT) and storing the machine code; and during execution of a smart contract that has been deployed, interpreting and executing, by the blockchain node, a bytecode of the smart contract in response to that a machine code of the smart contract is not locally stored. According to the above implementations of the present application, when AoT compilation is not completed, the bytecode of the smart contract is interpreted and executed, so normal processing of a blockchain service request can be ensured while AoT compilation is performed.