arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2008.05449cs.SEcs.CLcs.CR
收藏

在Solidity智能合约中分析天然气消耗

Profiling Gas Consumption in Solidity Smart Contracts

University of Sannio(桑尼奥大学)

Andrea Di Sorbo, Sonia Laudanna, Anna Vacca, Corrado A. Visaggio, Gerardo Canfora

摘要:

如今,越来越多的应用程序被开发用于在分布式账本技术上运行,即dApps。dApps的业务逻辑通常在通过Solidity开发的智能合约中实现,Solidity是一种用于在不同区块链平台上编写智能合约的程序设计语言,包括流行的以太坊。在以太坊中,智能合约在矿工的机器上运行,gas对应于补偿这些计算资源的执行费用。然而,智能合约的部署和执行成本取决于开发人员的实现选择。不适当的设计选择可能导致比必要的更高的气体消耗。在本文中,我们(i)确定了一组影响智能合约部署和交易成本的19种Solidity代码气味,以及(ii)通过涉及34名参与者的调查评估这些气味的相关性。在这些气味之上,我们提出了GasMet,这是一套从气体消耗角度静态评估智能合约代码质量的指标。一项涉及2,186个智能合约的实验表明,所提出的指标与部署成本有直接关联。我们套件中的指标可用于更轻松地识别需要优化的源代码段。

英文摘要:

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.

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

↑