Asparagus: Automated Synthesis of Parametric Gas Upper-Bounds for Smart Contracts

Author:

Cai Zhuo1ORCID,Farokhnia Soroush1ORCID,Goharshady Amir Kafshdar1ORCID,Hitarth S.1ORCID

Affiliation:

1. Hong Kong University of Science and Technology, Hong Kong, Hong Kong

Abstract

Modern programmable blockchains have built-in support for smart contracts, i.e. ‍programs that are stored on the blockchain and whose state is subject to consensus. After a smart contract is deployed on the blockchain, anyone on the network can interact with it and call its functions by creating transactions. The blockchain protocol is then used to reach a consensus about the order of the transactions and, as a direct corollary, the state of every smart contract. Reaching such consensus necessarily requires every node on the network to execute all function calls. Thus, an attacker can perform DoS by creating expensive transactions and function calls that use considerable or even possibly infinite time and space. To avoid this, following Ethereum, virtually all programmable blockchains have introduced the concept of “gas”. A fixed hard-coded gas cost is assigned to every atomic operation and the user who calls a function has to pay for its total gas usage. This technique ensures that the protocol is not vulnerable to DoS attacks, but it has also had significant unintended consequences. Out-of-gas errors, i.e. ‍when a user misunderestimates the gas usage of their function call and does not allocate enough gas, are a major source of security vulnerabilities in Ethereum. We focus on the well-studied problem of automatically finding upper-bounds on the gas usage of a smart contract. This is a classical problem in the blockchain community and has also been extensively studied by researchers in programming languages and verification. In this work, we provide a novel approach using theorems from polyhedral geometry and real algebraic geometry, namely Farkas’ Lemma, Handelman’s Theorem, and Putinar’s Positivstellensatz, to automatically synthesize linear and polynomial parametric bounds for the gas usage of smart contracts. Our approach is the first to provide completeness guarantees for the synthesis of such parametric upper-bounds. Moreover, our theoretical results are independent of the underlying consensus protocol and can be applied to smart contracts written in any language and run on any blockchain. As a proof of concept, we also provide a tool, called “Asparagus” that implements our algorithms for Ethereum contracts written in Solidity. Finally, we provide extensive experimental results over 24,188 real-world smart contracts that are currently deployed on the Ethereum blockchain. We compare Asparagus against GASTAP, which is the only previous tool that could provide parametric bounds, and show that our method significantly outperforms it, both in terms of applicability and the tightness of the resulting bounds. More specifically, our approach can handle 80.56% of the functions (126,269 out of 156,735) in comparison with GASTAP’s 58.62%. Additionally, even on the benchmarks where both approaches successfully synthesize a bound, our bound is tighter in 97.85% of the cases.

Publisher

Association for Computing Machinery (ACM)

Subject

Safety, Risk, Reliability and Quality,Software

Reference62 articles.

1. Elvira Albert Puri Arenas Samir Genaim Miguel Gómez-Zamalloa German Puebla Diana V. Ramírez-Deantes Guillermo Román-Díez and Damiano Zanardini. 2009. Termination and Cost Analysis with COSTA and its User Interfaces. In PROLE. 109–121. Elvira Albert Puri Arenas Samir Genaim Miguel Gómez-Zamalloa German Puebla Diana V. Ramírez-Deantes Guillermo Román-Díez and Damiano Zanardini. 2009. Termination and Cost Analysis with COSTA and its User Interfaces. In PROLE. 109–121.

2. Elvira Albert , Jesús Correas , Pablo Gordillo , Guillermo Román-Díez , and Albert Rubio . 2020 . GASOL: Gas analysis and optimization for Ethereum smart contracts. In TACAS (2). 118–125. Elvira Albert, Jesús Correas, Pablo Gordillo, Guillermo Román-Díez, and Albert Rubio. 2020. GASOL: Gas analysis and optimization for Ethereum smart contracts. In TACAS (2). 118–125.

3. Don’t run on fumes—Parametric gas bounds for smart contracts

4. Elvira Albert Pablo Gordillo Benjamin Livshits Albert Rubio and Ilya Sergey. 2018. EthIR: A framework for high-level analysis of Ethereum bytecode. In ATVA. 513–520. Elvira Albert Pablo Gordillo Benjamin Livshits Albert Rubio and Ilya Sergey. 2018. EthIR: A framework for high-level analysis of Ethereum bytecode. In ATVA. 513–520.

5. Ali Asadi , Krishnendu Chatterjee , Hongfei Fu , Amir Kafshdar Goharshady, and Mohammad Mahdavi . 2021 . Polynomial reachability witnesses via Stellensätze. In PLDI. ACM , 772–787. Ali Asadi, Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, and Mohammad Mahdavi. 2021. Polynomial reachability witnesses via Stellensätze. In PLDI. ACM, 772–787.

Cited by 6 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

1. Practical Approximate Quantifier Elimination for Non-linear Real Arithmetic;Lecture Notes in Computer Science;2024-09-11

2. Sound and Complete Witnesses for Template-Based Verification of LTL Properties on Polynomial Programs;Lecture Notes in Computer Science;2024-09-11

3. Synthesis of Sound and Precise Storage Cost Bounds via Unsound Resource Analysis and Max-SMT;Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis;2024-09-11

4. SRNG: An Efficient Decentralized Approach for Secret Random Number Generation;2024 IEEE International Conference on Blockchain and Cryptocurrency (ICBC);2024-05-27

5. Gas-Efficient Decentralized Random Beacons;2024 IEEE International Conference on Blockchain and Cryptocurrency (ICBC);2024-05-27

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3