Characterizing and Detecting Gas-Inefficient Patterns in Smart Contracts
Ethereum blockchain is a new internetware with tens of millions of smart contracts running on it. Different from general programs, smart contracts are decentralized, tamper-resistant and permanently running. Moreover, to avoid resource abuse, Ethereum charges users for deploying and invoking smart c...
Saved in:
Published in | Journal of computer science and technology Vol. 37; no. 1; pp. 67 - 82 |
---|---|
Main Authors | , , , , , , |
Format | Journal Article |
Language | English |
Published |
Singapore
Springer Singapore
01.02.2022
Springer Springer Nature B.V School of Computer Science and Engineering,Sun Yat-sen University,Guangzhou 510006,China%School of Software Engineering,Sun Yat-sen University,Zhuhai 519082,China%Guangdong Key Laboratory for Big Data Analysis and Simulation of Public Opinion,School of Communication and Design,Sun Yat-sen University,Guangzhou 510006,China%Peking University Shenzhen Graduate School,Shenzhen 518000,China |
Subjects | |
Online Access | Get full text |
Cover
Loading…
Summary: | Ethereum blockchain is a new internetware with tens of millions of smart contracts running on it. Different from general programs, smart contracts are decentralized, tamper-resistant and permanently running. Moreover, to avoid resource abuse, Ethereum charges users for deploying and invoking smart contracts according to the size of contract and the operations executed by contracts. It is necessary to optimize smart contracts to save money. However, since developers are not familiar with the operating environment of smart contracts (i.e., Ethereum virtual machine) or do not pay attention to resource consumption during development, there are many optimization opportunities for smart contracts. To fill this gap, this paper defines six gas-inefficient patterns from more than 25 000 posts and proposes an optimization approach at the source code level to let users know clearly where the contract is optimized. To evaluate the prevalence and economic benefits of gas-inefficient patterns, this paper conducts an empirical study on more than 160 000 real smart contracts. The promising experimental results demonstrate that 52.75% of contracts contain at least one gas-inefficient pattern proposed in this paper. If these patterns are removed from the contract, at least $0.30 can be saved per contract. |
---|---|
ISSN: | 1000-9000 1860-4749 |
DOI: | 10.1007/s11390-021-1674-4 |