论文标题
在固体智能合约中分析气体消耗
Profiling Gas Consumption in Solidity Smart Contracts
论文作者
论文摘要
如今,开发了越来越多的应用程序,用于运行分布式分类帐技术,即Dapps。 DAPP的业务逻辑通常是在通过Solidity开发的智能合约中实现的,Solidity是一种编程语言,用于在包括流行的以太坊在内的不同区块链平台上编写智能合约。在以太坊中,智能合约在矿工的机器上运行,气体对应于补偿此类计算资源的执行费。但是,智能合约的部署和执行成本取决于开发人员所做的实施选择。未列出的设计选择可能会导致更高的气体消耗量。在本文中,我们(i)确定了一组智能合约的部署和交易成本的19种固体代码气味,以及(ii)通过涉及34名参与者的调查来评估此类气味的相关性。除了这些气味,我们还建议使用Gasmet,这是一套用于从气体消耗的角度静态评估智能合约的代码质量的指标。涉及2186份智能合约的实验表明,拟议的指标与部署成本有直接关联。我们套件中的指标可用于更轻松地识别需要优化的源代码段。
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.