PLDI 2024
Mon 24 - Fri 28 June 2024 Copenhagen, Denmark

Ethereum is the first and largest blockchain that supports smart contracts. To enhance scalability and security, one planed major change of Ethereum 2.0 (Eth2) is to upgrade the smart contract execution layer from Ethereum Virtual Machine (EVM) to WebAssembly (WASM). In the meanwhile, many other popular blockchains have adopted WASM. Since EVM hosts millions of smart contracts on Ethereum, it is highly desirable to automatically migrate EVM smart contracts to WASM code to foster the prosperity of blockchain ecosystem, while inheriting the historical transactions and blockchain states from Ethereum. Unfortunately, it is non-trivial to achieve this purpose due to the challenges in converting the EVM bytecode of smart contracts to WASM bytecode and adapting the generated WASM bytecode to the underlying blockchain environment. In particular, none of the existing tools are adequate to this task because they fail to achieve accurate translation and compatibility with the blockchain environment. In this paper, we propose a novel approach to accomplish this task and use Eth2 as the target blockchain to demonstrate its feasibility and performance, because Eth2 is highly attractive to the industry and academia. Specifically, we develop EVMBT, a novel static EVM2WASM bytecode translation framework that not only ensures the fidelity of translation but also supports LLVM plugins to improve smart contracts, and conduct extensive experiments to evaluate it. The results demonstrate that EVMBT can successfully translate real-world EVM contracts with high fidelity and low gas overhead.