Off-Chain Smart Contract Testing via Virtual Execution Environment

Resolve Bottlenecks,
Find Innovative Solutions
Generate 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

VSEngineering 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

Engineering Contradiction:
Improvetesting accuracyVSAvoidtesting time
Core Design Contradiction:
ReliabilityVSLoss of time

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.

Inventive Principle:
Principle #26Copying

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.

Inventive Principle:
Principle #10Preliminary action

2Reliability

If testing is performed with multiple transactions to handle complex smart contracts, then the testing coverage improves, but the testing efficiency decreases

Engineering Contradiction:
Improvetesting coverageVSAvoidtesting efficiency
Core Design Contradiction:
ReliabilityVSProductivity

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.

Inventive Principle:
Principle #1Segmentation

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.

Inventive Principle:
Principle #17Another dimension (Dimensionality change)

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

Engineering Contradiction:
Improvebehavior verificationVSAvoidblockchain contamination
Core Design Contradiction:
ReliabilityVSObject-affected harmful factors

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.

Inventive Principle:
Principle #24Intermediary (Mediator)

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

Engineering Contradiction:
Improvetesting accessibilityVSAvoidtesting throughput
Core Design Contradiction:
Ease of manufactureVSProductivity

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.

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

Data Source

PatentEP3613203B1Methods and devices for performing off-chain testing on smart contract
Publication Date: 2023.06.07 ADVANCED NEW TECHNOLOGIES CO LTD
  • EP3613203B1 patent drawingFigure 1
  • EP3613203B1 patent drawingFigure 2
  • EP3613203B1 patent drawingFigure 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.