Off-Chain Smart Contract Testing via Virtual Execution Environment
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
The decentralized and distributed nature of blockchain systems makes on-chain testing of smart contracts time-consuming and inefficient, potentially causing undesired changes to the blockchain, especially as smart contracts become more complex and require testing with multiple transactions.
Innovation Solution
An off-chain testing method and device that generate execution environment information, including transaction context, blockchain, and state information, with an API interface to simulate the smart contract's execution environment, allowing for reduced testing time and resource usage while preventing unwanted blockchain changes.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If on-chain testing is performed on the blockchain, then the smart contract can be tested in its actual execution environment, but the testing becomes time-consuming and causes undesired changes to the blockchain
Solution Approach 1:
The patent creates a copy of the blockchain execution environment that replicates the smart contract's behavior and state transitions. This virtual environment allows multiple transactions to be tested simultaneously without affecting the actual blockchain, thereby reducing testing time while maintaining testing accuracy through environmental fidelity.
Solution Approach 2:
The system performs preliminary analysis of the smart contract to identify all possible state transitions and required test cases before actual testing begins. By pre-computing the test scenario and preparing the execution environment in advance, the system eliminates the need for time-consuming sequential testing on the live blockchain.
2Reliability
If testing is performed with multiple transactions to handle complex smart contracts, then the testing coverage improves, but the testing efficiency decreases
Solution Approach 1:
The patent segments the complex smart contract testing into multiple independent virtual execution environments, each handling specific state transitions. This allows parallel processing of multiple transactions across different segments, improving testing efficiency while maintaining comprehensive coverage through the aggregation of results from all segments.
Solution Approach 2:
The system adds a temporal dimension to testing by executing multiple transactions concurrently in the virtual environment rather than sequentially on the blockchain. This dimensional shift from sequential to parallel execution dramatically improves productivity while achieving complete state transition coverage through coordinated multi-threaded testing.
3Reliability
If on-chain testing is performed, then the smart contract behavior can be verified in the actual blockchain environment, but the blockchain state may be altered undesirably
Solution Approach 1:
The patent introduces a virtual execution environment as an intermediary layer between the tester and the actual blockchain. This mediator replicates the blockchain's execution semantics and state management, allowing behavior verification to occur without direct interaction with the live blockchain, thus preventing any harmful alterations while maintaining verification reliability.
4Ease of manufacture
If conventional testing methods are used on the blockchain, then the testing can be performed with existing tools, but the resource consumption increases and testing becomes inefficient
Solution Approach 1:
The patent creates a universal virtual execution environment that can handle multiple types of smart contracts and transaction types simultaneously. This multi-functional platform allows diverse testing scenarios to be executed in parallel using the same infrastructure, dramatically increasing testing throughput while maintaining ease of access through standardized interfaces for different contract types.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
Disclosed herein are methods, devices, and apparatuses, including computer programs stored on computer-readable media, for performing an off-chain testing on a smart contract. One of the methods includes: generating execution environment information for the smart contract, the execution environment information including at least one of transaction context information, blockchain information, or state information; providing an interface between the generated execution environment information and the smart contract; executing the smart contract based on the generated execution environment information and the provided interface; and storing an execution result of the smart contract.