EquivSage: LLM-assisted Detection of EVM-Inequivalent Code Smells in Multi-chain Reuse Contracts
Abstract
With the increasing development of Solidity contracts on Ethereum , more developers are reusing them on other compatible blockchains. However, developers may overlook the differences between the designs of the blockchain system, such as the Gas Mechanism and Consensus Protocol , leading to the same contracts on different blockchains not being able to achieve consistent execution as on Ethereum . This inconsistency reveals design flaws in reused contracts, exposing code smells that hinder code reusability, and we define this inconsistency as EVM-Inequivalent Code Smells . In this paper, we conducted an empirical study to reveal the causes and characteristics of EVM-Inequivalent Code Smells . To ensure the identified smells reflect real developer concerns, we analyzed 1,379 security audit reports, 823 bug bounty reports, and 326 Stack Overflow posts related to reused contracts on EVM-compatible blockchains, such as Binance Smart Chain (BSC) and Polygon . Using the Open Card Sorting method, we defined nine types of EVM-Inequivalent Code Smells . To enable efficient detection, we developed EquivSage , a tool that leverages the contextual understanding capabilities of large language models (LLMs) to guide slicing and static taint analysis via task-specific prompts. Symbolic execution is integrated to improve detection reliability. An analysis of 1,263,683 contracts across six EVM-compatible blockchains using EquivSage reveals that, on average, 15.45% contain at least one EVM-Inequivalent Code Smell , underscoring its widespread prevalence. Since 2024, code smells in reused contracts on Ethereum , Polygon , and Optimism have increased significantly. While not all instances lead to financial loss, high frequency and asset exposure highlight the risks inherent in contract reuse. Developers are encouraged to avoid copy-and-paste practices and to detect such smells proactively before reuse.
Community
0 commentsNo discussion yet
Be the first to share a question or observation.