Researchers from UCL, UC Berkeley, and other institutions have introduced a novel hybrid decompilation pipeline designed to address the lack of transparency in "closed-source" smart contracts on the Ethereum blockchain. By combining traditional static analysis with a fine-tuned Llama-3.2-3B model, the system converts raw Ethereum Virtual Machine (EVM) bytecode into human-readable Solidity with high semantic and structural fidelity.
The Challenge of Opaque Smart Contracts
On Ethereum, less than 1% of deployed contracts have publicly verified source code. For security auditors, this opacity is a significant barrier. Investigators often encounter inscrutable EVM bytecode—a low-level, stack-based representation that is nearly impossible for humans to audit effectively. Existing decompilers like Gigahorse or Panoramix frequently produce "spaghetti code" with generic variable names and complex control flows, making it difficult to discern developer intent or identify subtle vulnerabilities.
A Hybrid Decompilation Pipeline
The proposed system moves away from "black box" neural approaches in favor of a hybrid pipeline that leverages the strengths of both symbolic and neural methods.
As shown in the pipeline above, the process consists of three primary stages:
- Static Analysis & TAC Recovery: Traditional program analysis converts raw EVM bytecode into Three-Address Code (TAC). This intermediate representation makes data and control flow explicit, removing the complexity of the EVM's stack-based operations.
- Neural Code Generation: The structured TAC is fed into a Llama-3.2-3B model, fine-tuned using Low-Rank Adaptation (LoRA) specifically for translating TAC to Solidity.
- Post-Processing: The generated code undergoes syntax and validation checks to ensure it is compilable and semantically faithful to the original logic.
Datasets and Training
The model was trained on a high-quality dataset of 238,446 TAC-to-Solidity function pairs extracted from verified Ethereum contracts. Evaluation was performed on a held-out set of 9,731 functions. The dataset includes critical context such as function signatures and visibility modifiers, which are typically lost during compilation but are essential for readability.
Key Results and Insights
The hybrid approach demonstrates a significant improvement over traditional tools. The system achieved an average semantic similarity score of 0.82 (where 1.0 is a perfect match). Furthermore, 82.5% of decompiled functions exhibited a normalized edit distance of less than 0.4 from the original source code, indicating high structural fidelity.
Analysis of the results yielded several key insights:
- Efficiency of Small Models: A 3B-parameter model, when fine-tuned on domain-specific data, can outperform larger general-purpose models.
- The Entropy Gap: Researchers found that Solidity has lower entropy (~4.22 bits/token) than EVM bytecode (~6.30 bits/opcode). Decompilation is thus an expansion task where the model re-introduces the redundancy (names, structure) necessary for human comprehension.
- Real-World Impact: In case studies, the tool successfully identified a critical vulnerability in the "Dx Protocol" that allowed unauthorized repeated withdrawals—a flaw nearly invisible in raw bytecode.
Limitations and Future Directions
While the system represents a leap forward, challenges remain. The model occasionally struggles with complex DeFi mathematics, such as fixed-point arithmetic scaling. Performance also tends to degrade for very long functions (over 1,000 characters) or contracts with deep inheritance patterns. The researchers have released the tool at evmdecompiler.com, contributing to a more transparent and auditable blockchain ecosystem.
Summary updated