paperbot · PL 论文追踪

全部论文 待读 收藏

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

Asparagus:智能合约参数化 Gas 上界的自动合成
OOPSLA 7(OOPSLA2)2023匹配度 3/10 · 该论文属于程序分析与形式化验证,研究智能合约 gas 消耗的参数化上界自动合成,兼具理论保证与工程工具;但研究对象是区块链智能合约,不涉及 LLM/Agent、浮点程序分析或贝叶斯程序分析,与用户当前核心交叉方向不匹配。引用 16 inbox
Zhuo Cai, Soroush Farokhnia, Amir Kafshdar Goharshady, S. Hitarth
crossref: 2026-09-10

AI 速览

一句话:用多面体几何与实代数几何定理自动合成智能合约 gas 消耗的参数化上界,并首次给出完备性保证。

智能合约的调用者若低估 gas 用量会触发 out-of-gas 错误,是主要安全漏洞来源,因此自动推断 gas 使用上界十分重要。本文借助多面体几何与实代数几何中的 Farkas 引理、Handelman 定理和 Putinar Positivstellensatz,自动合成 gas 消耗的线性与多项式参数化上界,是首个为该类参数化上界合成提供完备性保证的工作;其理论结果不依赖具体共识协议,适用于任何语言与区块链。作者实现工具 Asparagus,面向 Solidity/Ethereum 合约。在 24,188 个真实部署合约上,Asparagus 可处理 80.56% 的函数(126,269/156,735),而此前唯一支持参数化界的工具 GASTAP 仅 58.62%;在两者都成功的基准上,Asparagus 的界在 97.85% 的情形下更紧。

问题
智能合约的 gas 消耗上界难以自动推断:用户低估 gas 会导致 out-of-gas 错误,且上界通常依赖输入参数,需要参数化分析。
方法
利用 Farkas 引理、Handelman 定理与 Putinar Positivstellensatz 等多面体几何和实代数几何工具,自动合成 gas 用量的线性与多项式参数化上界,并给出完备性保证;实现面向 Solidity 的工具 Asparagus。
评估
在 24,188 个已部署的以太坊真实合约上与唯一能给出参数化界的工具 GASTAP 对比:Asparagus 的函数覆盖率为 80.56%(126,269/156,735),GASTAP 为 58.62%;且在两者都成功合成的基准上,Asparagus 的界在 97.85% 的情形下更紧。
原文摘要(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.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1840,
  title = {Asparagus: Automated Synthesis of Parametric Gas Upper-Bounds for Smart Contracts},
  author = {Zhuo Cai and Soroush Farokhnia and Amir Kafshdar Goharshady and S. Hitarth},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {OOPSLA2},
  year = {2023},
  doi = {10.1145/3622829}
}