Unearthing Gas-Wasting Code Smells in Smart Contracts With Large Language Models

Smart contracts are automated programs stored on a blockchain, featuring unique attributes such as permissionlessness, trustlessness, immutability, and transparency. These properties underpin an array of unprecedented decentralized services. Compiled into bytecodes, Ethereum smart contracts are executed within the Ethereum Virtual Machine (EVM). Ethereum's distinct gas mechanism assigns a price to each bytecode execution, incentivizing resource-efficient computing. However, a disconnect exists between conventional coding practices and the less intuitive gas consumption computation mechanism, resulting in inadvertent gas wastage. Gas-wasting code smells at the source code level have been studied in various related works; however, the task of manually identifying such code smells by reading through codes and reasoning about them is both time-consuming and economically inefficient. In this work, we propose to leverage Large Language Models (LLMs), which have seen a surge in popularity recently, to facilitate undertaking the labor-intensive part of the code-smell-finding pipeline. In particular, we focus on Solidity, the predominant programming language for Ethereum smart contracts. Overall, we identified 26 gas-wasting code smells, out of which 13 were not presented in previous papers. On average, applying these code smells led to a reduction of approximately 10.534% in deployment costs and 21.528% in message call costs across our test codes. We further make a report on each of the identified code smells with associated example contracts sourced from either previous literature or recently deployed contracts.

Authors

Institutions

Publication Details

Journal
IEEE Transactions on Software Engineering
Published
2024-11-19
DOI
https://doi.org/10.1109/tse.2024.3491578
Citations
7
Primary Topic
Blockchain Technology Applications and Security
Type
article
Field-Weighted Citation Impact
5.45
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Unearthing Gas-Wasting Code Smells in Smart Contracts With Large Language Models

Yutian Tang, Jinan Jiang, Xiao-Ming Wu, Haoran Qin et al.
7 citations
IEEE Transactions on Software Engineering
Blockchain Technology Applications and Security
5.45
article

Unearthing Gas-Wasting Code Smells in Smart Contracts With Large Language Models

Yutian Tang, Jinan Jiang, Xiao-Ming Wu, Haoran Qin, Muhui Jiang, Chenxiong Qian, Zihao Li, Xiapu Luo, Ting Chen, Haoyu Wang
article en
7 citations

Abstract

Smart contracts are automated programs stored on a blockchain, featuring unique attributes such as permissionlessness, trustlessness, immutability, and transparency. These properties underpin an array of unprecedented decentralized services. Compiled into bytecodes, Ethereum smart contracts are executed within the Ethereum Virtual Machine (EVM). Ethereum's distinct gas mechanism assigns a price to each bytecode execution, incentivizing resource-efficient computing. However, a disconnect exists between conventional coding practices and the less intuitive gas consumption computation mechanism, resulting in inadvertent gas wastage. Gas-wasting code smells at the source code level have been studied in various related works; however, the task of manually identifying such code smells by reading through codes and reasoning about them is both time-consuming and economically inefficient. In this work, we propose to leverage Large Language Models (LLMs), which have seen a surge in popularity recently, to facilitate undertaking the labor-intensive part of the code-smell-finding pipeline. In particular, we focus on Solidity, the predominant programming language for Ethereum smart contracts. Overall, we identified 26 gas-wasting code smells, out of which 13 were not presented in previous papers. On average, applying these code smells led to a reduction of approximately 10.534% in deployment costs and 21.528% in message call costs across our test codes. We further make a report on each of the identified code smells with associated example contracts sourced from either previous literature or recently deployed contracts.

IEEE Transactions on Software EngineeringVol. 51(4)
Hong Kong Polytechnic University (HK), University of Electronic Science and Technology of China (CN), Huazhong University of Science and Technology (CN), University of Glasgow (GB), University of Hong Kong (HK)
Openalex Percentile: Top 4%
Blockchain Technology Applications and Security
5.45
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.