arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.04483cs.SEcs.CEcs.DCcs.ETcs.NI
收藏

以太坊智能合约最低Gas限额与Gas消耗量的揭秘与近乎完美估计

Demystification and Near-perfect Estimation of Minimum Gas Limit and Gas Used for Ethereum Smart Contracts

Danilo Rafael de Lima Cabral, Pedro Antonino, Augusto Sampaio

AI总结:

本文明确了以太坊最低gas限额与gas消耗量的区别,提出二者的精确估计方法,证明基于近期区块状态可近乎完美估计后续交易的相关gas指标,为用户和开发者提供参考。

摘要:

以太坊区块链拥有一套gas系统,该系统将各类操作与以gas单位计量的成本相关联。这套系统的两个核心概念是由交易发起者设置的gas限额,以及交易实际消耗的gas量。前者是一项预算,必须在交易执行完成前不得耗尽,否则执行会失败。因此,确定能够确保交易执行不会因gas不足而中止的最低gas限额,似乎相当重要。尽管这一概念具有实际意义,但尚未得到妥善研究。现有文献中,gas消耗量与最低gas限额被混为一谈。本文提出了最低gas限额的精确定义,以及它与交易gas消耗量之间可能存在的差异;本文还通过对以太坊区块链真实交易的定量研究对此进行了论证。另一项重要贡献是,针对这两个指标分别提出了一种相当精确的估计器。同样,对这些概念的混淆导致以往仅针对交易gas消耗量构建估计器。我们证明,以太坊区块链(区块生成后)状态t下的最低gas限额,可以作为区块t+Δ(其中Δ≤11)上交易执行情况的近乎完美估计;gas消耗量的估计也同样适用。这些精确的估计器在帮助用户预测交易gas预算、协助开发者优化智能合约方面极具价值;对gas消耗量和最低gas限额的高估或低估都会引发诸多实际问题。总体而言,本文为区块链开发者和用户了解gas系统的实际运作方式提供了重要参考。

英文摘要:

The Ethereum blockchain has a \emph{gas system} that associates operations with a cost in gas units. Two central concepts of this system are the \emph{gas limit} assigned by the issuer of a transaction and the \emph{gas used} by a transaction. The former is a budget that must not be exhausted before the completion of the transaction execution; otherwise, the execution fails. Therefore, it seems rather essential to determine the \emph{minimum gas limit} that ensures the execution of a transaction will not abort due to the lack of gas. Despite its practical relevance, this concept has not been properly addressed. In the literature, gas used and minimum gas limit are conflated. This paper proposes a precise notion of minimum gas limit and how it can differ from gas used by a transaction; this is also demonstrated with a quantitative study on real transactions of the Ethereum blockchain. Another significant contribution is the proposition of a fairly precise estimator for each of the two metrics. Again, the confusion between these concepts has led to the creation of estimators only for the gas used by a transaction. We demonstrate that the minimum gas limit for the state of the Ethereum blockchain (after the block) $t$ can serve as a near-perfect estimation for the execution of the transaction at block $t + Δ$, where $Δ\leq 11$; the same holds for estimating gas used. These precise estimators can be very valuable in helping the users predict the gas budget of transactions and developers in optimising their smart contracts; over and underestimating gas used and minimum gas limit can lead to a number of practical issues. Overall, this paper serves as an important reference for blockchain developers and users as to how the gas system really works.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑