Blockchain Node AoT Compilation for Smart Contract Execution
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing blockchain technologies face challenges in efficiently executing smart contracts across different hardware and software environments due to differences in processor architectures and instruction sets, leading to inefficiencies and increased storage overheads from compiling multiple machine codes.
Innovation Solution
Implementing an ahead-of-time (AoT) compilation method where a blockchain node compiles smart contract bytecode into machine code before deployment, allowing each node to execute the machine code directly, reducing the need for multiple machine code versions and minimizing storage requirements.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Speed
If blockchain nodes compile smart contract bytecode into machine code for execution, then execution speed is improved, but storage overheads increase due to needing multiple machine code versions for different processor architectures
Solution Approach 1:
The patent applies ahead-of-time (AoT) compilation where the bytecode is compiled into machine code before deployment and execution. This preliminary compilation action allows the machine code to be directly executable by the CPU during contract execution, significantly improving execution speed compared to interpretation-based approaches.
Solution Approach 2:
The patent employs a virtual machine architecture that enables a single bytecode version to be executed across multiple different processor architectures and operating systems. This universal approach allows one bytecode to serve multiple platforms without requiring separate machine code versions for each architecture, thereby reducing storage overheads while maintaining fast execution.
2Adaptability or versatility
If blockchain nodes compile multiple versions of machine code for different processor architectures, then compatibility across environments is improved, but device complexity and storage requirements increase
Solution Approach 1:
The patent introduces a virtual machine as an intermediary layer between the bytecode and the underlying hardware. This virtual machine acts as a mediator that translates and executes bytecode across different processor architectures and operating systems, enabling compatibility without requiring nodes to maintain multiple machine code versions. The virtual machine abstracts away the hardware differences, simplifying the node design while preserving adaptability.
3Ease of manufacture
If blockchain nodes use interpretation-based execution for smart contracts, then ease of deployment is improved, but execution speed decreases
Solution Approach 1:
The patent applies ahead-of-time (AoT) compilation where the bytecode is compiled into machine code before deployment and execution. This preliminary compilation action allows the machine code to be directly executable by the CPU during contract execution, significantly improving execution speed compared to interpretation-based approaches.
Data Source
Figure 1
Figure 2~3
Figure 4~5
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 the deployed smart contract, executing, by the blockchain node, the machine code of the smart contract in response to the machine code being locally stored. According to the above implementations of the present application, the blockchain node can greatly increase a speed of executing a smart contract, and reduce storage overheads on the blockchain node.