Skip to main content
QUICK REVIEW

[Paper Review] Profiling Gas Leaks in Solidity Smart Contracts

Gerardo Canfora, Andrea Di Sorbo|arXiv (Cornell University)|Aug 12, 2020
Blockchain Technology Applications and SecurityComputer Science30 references5 citations
TL;DR

This paper identifies 19 Solidity code smells that increase gas costs in Ethereum smart contracts and proposes GasMet, a static analysis suite of metrics to evaluate gas efficiency. Experimentation on 2,186 contracts confirms the metrics strongly correlate with deployment costs, enabling developers to pinpoint and optimize high-cost code segments.

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.

Motivation & Objective

  • To identify code smells in Solidity that lead to unnecessary gas consumption during smart contract deployment and execution.
  • To evaluate the relevance of these code smells through a survey with 34 software engineering practitioners.
  • To develop GasMet, a set of static metrics for assessing gas efficiency in smart contract source code.
  • To empirically validate the correlation between GasMet metrics and actual deployment costs in real-world smart contracts.

Proposed method

  • Identified 19 Solidity code smells affecting gas costs through analysis of common anti-patterns in smart contract development.
  • Conducted a survey with 34 participants to assess the perceived relevance and impact of the identified code smells.
  • Designed GasMet as a suite of static code metrics to quantify gas inefficiency in Solidity contracts.
  • Applied GasMet to analyze 2,186 real-world smart contracts to measure associations with deployment costs.
  • Used statistical analysis to evaluate the strength of the relationship between GasMet metrics and actual gas consumption.

Experimental results

Research questions

  • RQ1Which Solidity code smells significantly contribute to increased gas consumption in smart contracts?
  • RQ2How relevant are these code smells to practicing smart contract developers, as perceived by industry practitioners?
  • RQ3To what extent do the proposed GasMet metrics correlate with actual deployment costs in real-world contracts?
  • RQ4Can GasMet effectively identify code segments that are likely to incur high gas costs?

Key findings

  • The 19 identified code smells are strongly associated with increased gas usage during contract deployment and execution.
  • Survey participants confirmed that the majority of the identified code smells are relevant and commonly encountered in practice.
  • GasMet metrics demonstrated a direct and measurable association with deployment costs across 2,186 analyzed smart contracts.
  • The study confirms that GasMet can effectively flag high-gas-consumption code segments for optimization.
  • The results indicate that code quality practices focused on gas efficiency can significantly reduce deployment and execution costs.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.