Skip to main content
QUICK REVIEW

[论文解读] Profiling Gas Leaks in Solidity Smart Contracts

Gerardo Canfora, Andrea Di Sorbo|arXiv (Cornell University)|Aug 12, 2020
Blockchain Technology Applications and Security参考文献 30被引用 5
一句话总结

本文识别出19种导致以太坊智能合约气体成本增加的Solidity代码异味,并提出GasMet——一套用于评估气体效率的静态分析指标套件。在2,186个合约上的实验验证了这些指标与部署成本之间存在强烈相关性,使开发者能够精确定位并优化高成本代码段。

ABSTRACT

Nowadays, more and more applications are developed for running on a distributed ledger technology, namely dApps. The business logic of dApps is usually implemented within smart contracts developed through Solidity, a programming language for writing smart contracts on different blockchain platforms, including the popular Ethereum. In Ethereum, the smart contracts run on the machines of miners and the gas corresponds to the execution fee compensating such computing resources. However, the deployment and execution costs of a smart contract depend on the implementation choices done by developers. Unappropriated design choices could lead to higher gas consumption than necessary. In this paper, we (i) identify a set of 19 Solidity code smells affecting the deployment and transaction costs of a smart contract, and (ii) assess the relevance of such smells through a survey involving 34 participants. On top of these smells, we propose GasMet, a suite of metrics for statically evaluating the code quality of a smart contract from the gas consumption perspective. An experiment involving 2,186 smart contracts demonstrates that the proposed metrics have direct associations with deployment costs. The metrics in our suite can be used for more easily identifying source code segments that need optimizations.

研究动机与目标

  • 识别在智能合约部署和执行过程中导致不必要的气体消耗的Solidity代码异味。
  • 通过34名软件工程从业者参与的调查,评估这些代码异味的相关性。
  • 开发GasMet,一套用于评估智能合约源代码气体效率的静态指标。
  • 通过实证研究验证GasMet指标与真实世界智能合约实际部署成本之间的相关性。

提出的方法

  • 通过分析智能合约开发中的常见反模式,识别出19种影响气体成本的Solidity代码异味。
  • 对34名参与者进行调查,评估所识别代码异味的感知相关性和影响程度。
  • 设计GasMet作为一套静态代码指标,用于量化Solidity合约中的气体低效性。
  • 将GasMet应用于2,186个真实世界的智能合约,以衡量其与部署成本的关联性。
  • 使用统计分析评估GasMet指标与实际气体消耗之间关系的强度。

实验结果

研究问题

  • RQ1哪些Solidity代码异味会显著导致智能合约中气体消耗的增加?
  • RQ2这些代码异味在实际智能合约开发人员中的相关性如何,从业实践者如何看待其重要性?
  • RQ3所提出的GasMet指标与真实世界合约中实际部署成本的相关程度如何?
  • RQ4GasMet能否有效识别出可能产生高额气体成本的代码段?

主要发现

  • 所识别的19种代码异味与合约部署和执行期间气体使用的增加存在强烈关联。
  • 调查参与者确认,大多数所识别的代码异味在实践中具有相关性且常见。
  • GasMet指标在所分析的2,186个智能合约中,与部署成本表现出直接且可量化的关联。
  • 研究证实,GasMet能够有效标记出需要优化的高气体消耗代码段。
  • 结果表明,专注于气体效率的代码质量实践可显著降低部署和执行成本。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。