Interactive WebAssembly Debugging via Shared Library Conversion

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current debugging tools for smart contract code on blockchain platforms, particularly those using WebAssembly (WASM), face challenges in identifying erroneous execution logic and optimizing performance due to limitations in stack unwinding and lack of support for stack traces, leading to inefficient debugging processes.

Innovation Solution

The method involves converting smart contract source code into a native binary format as a shared library, allowing for interactive debugging within a host executable, with execution tracing inserted during compilation to generate detailed execution traces without altering the contract's behavior, enabling developers to debug and optimize WASM code for improved performance.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If smart contract code is executed in WebAssembly (WASM) format on blockchain platforms, then portability and cross-platform compatibility are improved, but debugging capability and execution trace visibility deteriorate due to limitations in stack unwinding and lack of stack trace support

Engineering Contradiction:
ImproveportabilityVSAvoiddebugging capability
Core Design Contradiction:
Adaptability or versatilityVSDifficulty of detecting and measuring

Solution Approach 1:

The patent introduces an intermediary debugging system that bridges WASM execution and native debugging tools. The system includes a debugger that attaches to the host executable, intercepts WASM execution, and translates WASM operations into debuggable events. This intermediary layer enables stack trace generation and execution tracing for WASM code without altering the original WASM execution semantics, thus maintaining portability while improving debugging capability.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Measurement precision

If debugging tools are enhanced to provide detailed execution traces for WASM code, then identification of execution logic errors is improved, but system complexity and overhead increase

Engineering Contradiction:
Improveexecution trace visibilityVSAvoidsystem complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The debugging system is segmented into distinct modular components: (1) a compiler plugin that instruments WASM code during compilation, (2) a host executable debugger that attaches to the running process, (3) a debugging interface that presents trace information to developers. Each component handles specific aspects of debugging, reducing overall system complexity while providing comprehensive execution traces.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system performs preliminary instrumentation of WASM code during the compilation phase, embedding debugging information and trace hooks into the WASM binary before execution. This preliminary action ensures that detailed execution traces are available during runtime without adding significant overhead to the debugging system architecture.

Inventive Principle:
Principle #10Preliminary action

3Measurement precision

If execution tracing is inserted during smart contract compilation, then identification of performance issues is improved, but compilation time and processing overhead increase

Engineering Contradiction:
Improveperformance measurement accuracyVSAvoidcompilation time
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The compilation process offers partial instrumentation by default, inserting only essential performance tracing code rather than comprehensive logging. Developers can opt-in to more detailed tracing if needed. This partial action approach provides sufficient performance measurement accuracy for most cases while minimizing compilation overhead.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The system allows dynamic adjustment of tracing parameters such as trace granularity, buffer size, and output frequency. By optimizing these parameters, the system achieves accurate performance measurement with minimal impact on compilation time and runtime overhead.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS20240256428A1System and method for interactively debugging webassembly code
Publication Date: 2024.08.01 BULLISH GLOBAL
  • US20240256428A1 patent drawing
  • US20240256428A1 patent drawing
  • US20240256428A1 patent drawing

AI summary

Embodiments relate to interactively debugging non-native code inside native executables to identify erroneous execution logic and/or performance issues. The non-native code can be WebAssembly (WASM) code. Source smart contract code can be converted into a native binary in a format of a shared library. The shared library can be loaded by a blockchain executable when ready to load the smart contract for execution, and execution control can be passed to the shared library. A debugger can be attached to the host executable and single step through the smart contract code invoked. Embodiments relate to enabling interactive debugging of code as shared libraries (.so files) inside blockchains and native executables and/or generating execution trace information for smart contracts from non-native code without modifying its execution logic and/or generating relative performance information comparing smart contract execution in blockchains as non-native code with native execution as shared libraries to establish performance benchmarks.