• 中国精品科技期刊
  • CCF推荐A类中文期刊
  • 计算领域高质量科技期刊T1类
Advanced Search
Song Shuwei, Ni Xiaoze, Chen Ting. Gas Optimization for Smart Contracts: A Survey[J]. Journal of Computer Research and Development, 2023, 60(2): 311-325. DOI: 10.7544/issn1000-1239.202220887
Citation: Song Shuwei, Ni Xiaoze, Chen Ting. Gas Optimization for Smart Contracts: A Survey[J]. Journal of Computer Research and Development, 2023, 60(2): 311-325. DOI: 10.7544/issn1000-1239.202220887

Gas Optimization for Smart Contracts: A Survey

Funds: This work was supported by the National Natural Science Foundation of China (61872057, U19A2066) and the Natural Science Foundation of Sichuan Province (2022NSFSC0871).
More Information
  • Received Date: October 20, 2022
  • Revised Date: December 20, 2022
  • Available Online: February 10, 2023
  • Published Date: October 20, 2022
  • The most significant feature of Blockchain 2.0 is the introduction of support for smart contracts, which enables the blockchain to run various applications. The smart contract is a type of computer software that runs automatically according to pre-defined code logic. Distinguished from traditional software, smart contracts are empowered by blockchain technology with the ability to execute correctly on mutually untrusted nodes without relying on a trusted central authority, making them widely used in areas such as digital payments and the sharing economy. To prevent the waste of computing resources caused by the abuse of smart contracts, blockchains such as Ethereum charges Gas fees for two activities, deployment and execution of smart contracts. The computing resource consumed by smart contracts is the factor that determines the cost. Smart contracts with inefficient code are wasteful of resources and vulnerable to attacks, and the developers and users of them suffer unnecessary costs. Therefore, optimizing smart contracts to save resources has become a critical issue for developers and researchers. This survey first analyzes the main challenges of Gas optimization for smart contracts in detail, and then reviews and summarizes the various optimization techniques proposed in recent years. Finally, we discuss future work, which provides references for developers and researchers who explore smart contracts.

  • [1]
    Nakamoto S. Bitcoin: A peer-to-peer electronic cash system [EB/OL]. (2008−10−31) [2022−09−14].https://bitcoin.org/bitcoin.pdf
    [2]
    von Haller Gronbaek M. Blockchain 2.0, smart contracts and challenges [EB/OL]. [2022−09−14].https://www.twobirds.com/-/media/pdfs/in-focus/fintech/blockchain2_0_martinvonhallergroenbaek_08_06_16.pdf
    [3]
    Zou Weiqin, Lo D, Kochhar P, et al. Smart contract development: Challenges and opportunities[J]. IEEE Transactions on Software Engineering, 2019, 47(10): 2084−2106
    [4]
    Ruth A. Why build decentralized applications: Understanding Dapp [EB/OL]. (2022−01−17) [2022−09−14].https://due.com/blog/why-build-decentralized-applications-understanding-dapp/
    [5]
    Ethereum. org. Ethereum [EB/OL]. [2022−09−14].https://ethereum.org/en/
    [6]
    Young M. Over 44 million contracts deployed to Ethereum since genesis: Research [EB/OL]. (2022−08−04) [2022−09−14].https://cryptopotato.com/over-44-million-contracts-deployed-to-ethereum-since-genesis-research/
    [7]
    Wood G. Ethereum: A secure decentralised generalised transaction ledger[J]. Ethereum Project Yellow Paper, 2014, 151(2014): 1−32
    [8]
    Chen Ting, Li Xiaoqi, Wang Ying, et al. An adaptive gas cost mechanism for Ethereum to defend against under-priced DoS attacks [J]. arXiv preprint, arXiv: 1712.06438, 2017
    [9]
    Binance. An Introduction to BNB Smart Chain (BSC) [EB/OL]. [2022−10−09].https://academy.binance.com/en/articles/an-introduction-to-binance-smart-chain-bsc
    [10]
    Polygon technology. Polygon [EB/OL]. [2022−10−09].https://polygon.technology/
    [11]
    Chen Ting, Feng Youzheng, Li Zihao, et al. Gaschecker: Scalable analysis for discovering gas-inefficient smart contracts[J]. IEEE Transactions on Emerging Topics in Computing, 2020, 9(3): 1433−1448
    [12]
    Monrat A A, Schelén O, Andersson K. A survey of blockchain from the perspectives of applications, challenges, and opportunities[J]. IEEE Access, 2019, 7(1): 117134−117151
    [13]
    Szabo N. Formalizing and securing relationships on public networks[J]. First Monday, 1997, 2(9): 1−22
    [14]
    Clack C D, McGonagle C. Smart derivatives contracts: The ISDA master agreement and the automation of payments and deliveries [J]. arXiv preprint, arXiv: 1904.01461, 2019
    [15]
    Wang Zeli, Jin Hai, Dai Weiqi, et al. Ethereum smart contract security research: Survey and future research opportunities[J]. Frontiers of Computer Science, 2021, 15(2): 1−18
    [16]
    Albert E, Gordillo P, Hernández-Cerezo A, et al. Super-optimization of smart contracts [J]. ACM Transactions on Software Engineering and Methodology, 2022, 31(4): Article 70
    [17]
    Liu Chao, Gao Jianbo, Li Yue, et al. Understanding out of gas exceptions on Ethereum [C] //Proc of Int Conf on Blockchain and Trustworthy Systems. Berlin: Springer, 2019: 505 − 519
    [18]
    Albert E, Correas J, Gordillo P, et al. GASOL: Gas Analysis and optimization for Ethereum smart contracts [J]. arXiv preprint, arXiv: 1912.11929, 2019
    [19]
    Etherscan. Ethereum average gas price chart [EB/OL]. (2022−09−23) [2022−09−26].https://etherscan.io/chart/gasprice
    [20]
    Etherscan. Ether daily price (USD) chart [EB/OL]. (2022−09−23) [2022−09−26].https://etherscan.io/chart/etherprice
    [21]
    Liao Zhou, Song Shuwei, Zhu Hang, et al. Large-Scale Empirical Study of Inline Assembly on 7.6 Million Ethereum Smart Contracts [J]. IEEE Transactions on Software Engineering, 2022, Early Access: 1 − 25
    [22]
    Chen Ting, Li Xiaoqi, Luo Xiapu. Under-optimized smart contracts devour your money [C] //Proc of the IEEE 24th Int Conf on Software Analysis, Evolution and Reengineering (SANER). Piscataway, NJ: IEEE, 2017: 442 − 446
    [23]
    Chen Ting, Li Zihao, Zhou Hao, et al. Towards saving money in using smart contracts [C] //Proc of the IEEE/ACM 40th Int Conf on Software Engineering: New Ideas and Emerging Technologies Results (ICSE-NIER). Piscataway, NJ: IEEE, 2018: 81 − 84
    [24]
    Brandstätter T. Optimization of solidity smart contracts [D]. Vienna: Vienna University of Technology, 2020
    [25]
    Grech N, Kong M, Jurisevic A, et al. Madmax: Surviving out-of-gas conditions in Ethereum smart contracts[J]. Proceedings of the ACM on Programming Languages, 2018, 2(OOPSLA): 1−27
    [26]
    Albert E, Gordillo P, Rubio A, et al. Synthesis of super-optimized smart contracts using max-smt [C] //proc of Int Conf on Computer Aided Verification. Berlin: Springer, 2020: 177 − 200
    [27]
    Massalin H. Superoptimizer: A look at the smallest program[J]. ACM SIGARCH Computer Architecture News, 1987, 15(5): 122−126 doi: 10.1145/36177.36194
    [28]
    Nagele J, Schett M A. Blockchain superoptimizer [J]. arXiv preprint, arXiv: 2005.05912, 2020
    [29]
    Schett M A, Nagele J. Populating the Peephole Optimizer of a Smart Contract Compiler [C] //Proc of the 2nd Workshop on Formal Methods for Blockchains (FMBC). Wadern: Schloss Dagstuhl-Leibniz-Zentrum für Informatik, 2020: 1 − 15
    [30]
    Zhang Pengcheng, Xiao Feng, Luo Xiapu. SolidityCheck: Quickly detecting smart contract problems through regular expressions [J]. arXiv preprint, arXiv: 1911.09425, 2019
    [31]
    Luu L, Chu D, Olickel H, et al. Making smart contracts smarter [C] //Proc of 2016 ACM SIGSAC Conf on Computer and Communications security. New York: ACM, 2016: 254 − 269
    [32]
    Nikolić I, Kolluri A, Sergey I, et al. Finding the greedy, prodigal, and suicidal contracts at scale [C] //Proc of the 34th Annual Computer Security Applications Conf. New York: ACM, 2018: 653 − 663
    [33]
    Torres C F, Schütte J, State R. Osiris: Hunting for integer bugs in ethereum smart contracts [C] //Proc of the 34th Annual Computer Security Applications Conf. New York: ACM, 2018: 664 − 676
    [34]
    Tsankov P, Dan A, Drachsler-Cohen D, et al. Securify: Practical security analysis of smart contracts [C] //Proc of the 2018 ACM SIGSAC Conf on Computer and Communications Security. New York: ACM, 2018: 67 − 82
    [35]
    Tikhomirov S, Voskresenskaya E, Ivanitskiy I, et al. SmartCheck: Static analysis of Ethereum smart contracts [C] //Proc of IEEE/ACM 1st Int Workshop on Emerging Trends in Software Engineering for Blockchain (WETSEB). New York: ACM, 2018: 9 − 16
    [36]
    Feist J, Grieco G, Groce A. Slither: A static analysis framework for smart contracts [C] //Proc of IEEE/ACM 2nd Int Workshop on Emerging Trends in Software Engineering for Blockchain (WETSEB). Piscataway, NJ: IEEE, 2019: 8 − 15
    [37]
    Albert E, Correas J, Gordillo P, et al. GASOL: Gas analysis and optimization for Ethereum smart contracts [C] //Proc of Int Conf on Tools and Algorithms for the Construction and Analysis of Systems. Berlin: Springer, 2020: 118 − 125
    [38]
    Correas J, Gordillo P, Román-Díez G. Static profiling and optimization of Ethereum smart contracts using resource Analysis[J]. IEEE Access, 2021, 9(1): 25495−25507
    [39]
    Li Chunmiao. Gas estimation and optimization for smart contracts on Ethereum [C] //Proc of the 36th IEEE/ACM Int Conf on Automated Software Engineering (ASE). Piscataway, NJ: IEEE, 2021: 1082 − 1086
    [40]
    Kong Queping, Wang Ziyan, Huang Yuan, et al. Characterizing and detecting gas-inefficient patterns in smart contracts[J]. Journal of Computer Science and Technology, 2022, 37(1): 67−82 doi: 10.1007/s11390-021-1674-4
    [41]
    Inc Stack Exchange. Ethereum stack exchange [EB/OL]. [2022−10−08].https://ethereum.stackexchange.com/
    [42]
    Chen Yanju, Wang Yuepeng, Goyal M, et al. Synthesis-powered optimization of smart contracts via data type refactoring[J]. Proceedings of the ACM on Programming Languages, 2022, 6(OOPSLA2): 560−588 doi: 10.1145/3563308
    [43]
    Marchesi L, Marchesi M, Destefanis G, et al. Design patterns for gas optimization in ethereum [C] //Proc of IEEE Int Workshop on Blockchain Oriented Software Engineering (IWBOSE). Piscataway, NJ: IEEE, 2020: 9 − 15
    [44]
    Čeke D, Kunosić S, Buzađija N. Smart contract execution costs optimisation on blockchain network [C] //Proc of the 45th Jubilee Int Convention on Information, Communication and Electronic Technology (MIPRO). Piscataway, NJ: IEEE, 2022: 1442 − 1447
    [45]
    Bentley J L. Writing Efficient Programs [M]. Upper Saddle River: Prentice-Hall, Inc. , 1982
    [46]
    Brandstätter T, Schulte S, Cito J, et al. Characterizing efficiency optimizations in solidity smart contracts [C] //Proc of IEEE Int Conf on Blockchain (Blockchain). Piscataway, NJ: IEEE, 2020: 281 − 290
    [47]
    Ma Fuchen, Ren Meng, Ying Fu, et al. V-Gas: Generating high gas consumption inputs to avoid out-of-Gas vulnerability [J/OL]. ACM Transactions on Internet Technology (TOIT), 2018. https://dl.acm.org/doi/abs/10.1145/3511900?casa_token=vx-wRTMrwlkAAAAA:_Z1FzwVEFB9C7EnHGiVQTeMmhuxqqt6g2Cxjp6OXXMZwvDJXe36pyOcVPJavIlxh8gVeXXGXqQHgz8o
    [48]
    Albert E, Gordillo P, Rubio A, et al. GASTAP: A gas analyzer for smart contracts [J]. arXiv preprint, arXiv: 1811.10403, 2018
    [49]
    Marescotti M, Blicha M, Hyvärinen A E J, et al. Computing exact worst-case gas consumption for smart contracts [C] //Proc of Int Symp on Leveraging Applications of Formal Methods. Berlin: Springer, 2018: 450 − 465
    [50]
    Soto D, Bergel A, Hevia A. Fuzzing to estimate gas costs of Ethereum contracts [C] //Proc of IEEE Int Conf on Software Maintenance and Evolution (ICSME). Piscataway, NJ: IEEE, 2020: 687 − 691
    [51]
    Li Chunmiao, Nie Shijie, Cao Yang, et al. Trace-based dynamic gas estimation of loops in smart contracts[J]. IEEE Open Journal of the Computer Society, 2020, 1(1): 295−306
    [52]
    Chen Jiaqi, Li Kai, Yu Zhe, et al. GRuB: Gas-efficient blockchain storage via workload-adaptive data replication [J]. arXiv preprint, arXiv: 1911.04078, 2019
    [53]
    Chen Ting, Li Xiaoqi, Wang Ying, et al. An adaptive gas cost mechanism for ethereum to defend against under-priced dos attacks [C] //Proc of Int conf on Information Security Practice and Experience. Berlin: Springer, 2017: 3 − 24
    [54]
    Korpela K, Hallikas J, Dahlberg T. Digital supply chain transformation toward blockchain integration [C] //Proc of the 50th Hawaii Int Conf on System Sciences. Mānoa: ScholarSpace, 2017: 1 − 10
    [55]
    Reyna A, Martín C, Chen J, et al. On blockchain and its integration with IoT. Challenges and opportunities[J]. Future Generation Computer Systems, 2018, 88(1): 173−190
    [56]
    Chakraborty S, Aich S, Kim H. A secure healthcare system design framework using blockchain technology [C] //Proc of 21st Int Conf on Advanced Communication Technology (ICACT). Piscataway, NJ: IEEE, 2019: 260 − 264
    [57]
    Ma Zhaofeng, Jiang Ming, Gao Hongmin, et al. Blockchain for digital rights management[J]. Future Generation Computer Systems, 2018, 89(1): 746−764
    [58]
    Gatteschi V, Lamberti F, Demartini C, et al. Blockchain and smart contracts for insurance: Is the technology mature enough? [J]. Future Internet, 2018, 10(2): 20
    [59]
    Fanning K, Centers D P. Blockchain and its coming impact on financial services[J]. Journal of Corporate Accounting & Finance, 2016, 27(5): 53−57
    [60]
    Karamitsos I, Papadaki M, Al Barghuthi N B. Design of the blockchain smart contract: A use case for real estate[J]. Journal of Information Security, 2018, 9(3): 177−177 doi: 10.4236/jis.2018.93013
    [61]
    Etherscan. Ethereum daily transactions chart [EB/OL]. [2022−09−26].https://etherscan.io/chart/tx
    [62]
    Vyperlang. Vyper [EB/OL]. [2022−10−08].https://github.com/vyperlang/vyper
  • Related Articles

  • Cited by

    Periodical cited type(12)

    1. 刘向举,李金贺,方贤进,王宇. 移动边缘计算中计算卸载与资源分配联合优化策略. 计算机工程与科学. 2024(03): 416-426 .
    2. 闾国年,袁林旺,陈旻,张雪英,周良辰,俞肇元,罗文,乐松山,吴明光. 地理信息学科发展的思考. 地球信息科学学报. 2024(04): 767-778 .
    3. 谢满德,黄竹芳,孙浩. 云边端协同下多用户细粒度任务卸载调度策略. 电信科学. 2024(04): 107-121 .
    4. 纪允,孙建明,夏涛,吴子良,叶旭琪. 基于多层次数据协同应用的海关数据安全机制研究. 中国口岸科学技术. 2024(05): 27-34 .
    5. 方浩添,田乐,郭茂祖. 基于多群体混合智能优化算法的卸载决策寻优方法. 智能系统学报. 2024(06): 1573-1583 .
    6. 牟琦,韩嘉嘉,张寒,李占利. 基于云边协同的煤矿井下尺度自适应目标跟踪方法. 工矿自动化. 2023(04): 50-61 .
    7. 陆嘉旻,蒋丞,柴俊,贺亚龙,漆昭铃. 基于云边端协同的UUV数字模型设计与实现. 电声技术. 2023(03): 31-35 .
    8. 何牧,孙越,庞琦方. 基于边缘计算的智能视频分析算法研究. 电力大数据. 2023(04): 65-73 .
    9. 王宏杰,徐胜超,陈刚,杨波,毛明扬. 基于萤火虫算法的移动边缘计算网络带宽优化策略. 计算机测量与控制. 2023(11): 280-285 .
    10. 张俊娜,鲍想,陈家伟,赵晓焱,袁培燕,王尚广. 一种联合时延和能耗的依赖性任务卸载方法. 计算机研究与发展. 2023(12): 2770-2782 . 本站查看
    11. 邱丹青,许宇辉. 5G移动边缘计算环境下的任务卸载方法研究. 企业科技与发展. 2023(12): 75-78 .
    12. 林铭敏. 基于目标追踪的视频边缘计算云边协同任务调度及信息安全管理. 信息与电脑(理论版). 2023(20): 63-65 .

    Other cited types(21)

Catalog

    Article views (389) PDF downloads (161) Cited by(33)

    /

    DownLoad:  Full-Size Img  PowerPoint
    Return
    Return