TY - GEN
T1 - Towards saving money in using smart contracts
AU - Chen, Ting
AU - Li, Zihao
AU - Zhou, Hao
AU - Chen, Jiachi
AU - Luo, Xiapu
AU - Li, Xiaoqi
AU - Zhang, Xiaosong
PY - 2018/5/27
Y1 - 2018/5/27
N2 - Being a new kind of software leveraging blockchain to execute real contracts, smart contracts are in great demand due to many advantages. Ethereum is the largest blockchain platform that supports smart contracts by running them in its virtual machine. To ensure that a smart contract will terminate eventually and prevent abuse of resources, Ethereum charges the developers for deploying smart contracts and the users for executing smart contracts. Although our previous work shows that under-optimized smart contracts may cost more money than necessary, it just lists 7 anti-patterns and the detection method for 3 of them. In this paper, we conduct the first in-depth investigation on such under-optimized smart contracts. We first identify 24 anti-patterns from the execution traces of real smart contracts. Then, we design and develop GasReducer, the first tool to automatically detect all these anti-patterns from the bytecode of smart contracts and replace them with efficient code through bytecode-to-bytecode optimization. Using GasReducer to analyze all smart contracts and their execution traces, we detect 9,490,768 and 557,565,754 anti-pattern instances in deploying and invoking smart contracts, respectively.
AB - Being a new kind of software leveraging blockchain to execute real contracts, smart contracts are in great demand due to many advantages. Ethereum is the largest blockchain platform that supports smart contracts by running them in its virtual machine. To ensure that a smart contract will terminate eventually and prevent abuse of resources, Ethereum charges the developers for deploying smart contracts and the users for executing smart contracts. Although our previous work shows that under-optimized smart contracts may cost more money than necessary, it just lists 7 anti-patterns and the detection method for 3 of them. In this paper, we conduct the first in-depth investigation on such under-optimized smart contracts. We first identify 24 anti-patterns from the execution traces of real smart contracts. Then, we design and develop GasReducer, the first tool to automatically detect all these anti-patterns from the bytecode of smart contracts and replace them with efficient code through bytecode-to-bytecode optimization. Using GasReducer to analyze all smart contracts and their execution traces, we detect 9,490,768 and 557,565,754 anti-pattern instances in deploying and invoking smart contracts, respectively.
KW - Anti-patterns
KW - Detection
KW - Optimization
KW - Smart contract
UR - http://www.scopus.com/inward/record.url?scp=85049791243&partnerID=8YFLogxK
U2 - 10.1145/3183399.3183420
DO - 10.1145/3183399.3183420
M3 - Conference article published in proceeding or book
AN - SCOPUS:85049791243
T3 - Proceedings - International Conference on Software Engineering
SP - 81
EP - 84
BT - Proceedings 2018 ACM/IEEE 40th International Conference on Software Engineering
PB - IEEE Computer Society
T2 - 40th ACM/IEEE International Conference on Software Engineering: New Ideas and Emerging Results, ICSE-NIER 2018
Y2 - 30 May 2018 through 1 June 2018
ER -