Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
166 tokens/sec
GPT-4o
7 tokens/sec
Gemini 2.5 Pro Pro
42 tokens/sec
o3 Pro
4 tokens/sec
GPT-4.1 Pro
38 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

Under-Optimized Smart Contracts Devour Your Money (1703.03994v2)

Published 11 Mar 2017 in cs.SE

Abstract: Smart contracts are full-fledged programs that run on blockchains (e.g., Ethereum, one of the most popular blockchains). In Ethereum, gas (in Ether, a cryptographic currency like Bitcoin) is the execution fee compensating the computing resources of miners for running smart contracts. However, we find that under-optimized smart contracts cost more gas than necessary, and therefore the creators or users will be overcharged. In this work, we conduct the first investigation on Solidity, the recommended compiler, and reveal that it fails to optimize gas-costly programming patterns. In particular, we identify 7 gas-costly patterns and group them to 2 categories. Then, we propose and develop GASPER, a new tool for automatically locating gas-costly patterns by analyzing smart contracts' bytecodes. The preliminary results on discovering 3 representative patterns from 4,240 real smart contracts show that 93.5%, 90.1% and 80% contracts suffer from these 3 patterns, respectively.

Citations (323)

Summary

  • The paper presents a detailed analysis of Solidity compiler inefficiencies that inflate gas costs in Ethereum smart contracts.
  • It introduces Gasper, a symbolic execution tool that detects three key gas-costly patterns in contract bytecode.
  • The study finds up to 93.5% of contracts display these inefficiencies, urging improvements in compiler design for cost-effective deployments.

Analyzing Gas Consumption in Ethereum Smart Contracts: A Study on Program Optimization

The paper "Under-Optimized Smart Contracts Devour Your Money" presents a comprehensive inquiry into the resource cost associated with executing smart contracts on the Ethereum blockchain. The primary focus of this research lies in evaluating the efficiency of the Solidity compiler regarding its inability to optimize gas consumption patterns, which in turn leads to monetary inefficiencies for contract creators and users.

Key Contributions and Findings

The authors identify seven distinctive gas-costly programming patterns that Solidity fails to optimize. These patterns fall under two major categories: useless code related patterns and loop-related patterns. The paper introduces a utility, termed Gasper, which successfully detects three representative patterns in the deployed contracts' bytecode: dead code, opaque predicates, and expensive operations within loops.

Numerical assessments highlight that a staggering proportion of contracts—93.5%, 90.1%, and 80%—manifest the presence of dead code, opaque predicates, and costly operations respectively. Therefore, the prevalent usage of such patterns underscores a pervasive inefficiency in smart contract deployments on Ethereum, indicating that the current compiler optimizations in Solidity are insufficient for significant portions of smart contract code.

Implications and Utility of Gasper

The practical tool, Gasper employs symbolic execution to perform a meticulous analysis of smart contract bytecode. By doing this, it identifies gas inefficiencies without requiring source code access. This capability is crucial, given the limited availability of open-source smart contracts. The adoption of Gasper may bear significant implications for both practitioners and researchers as it highlights the extent and specifics of inefficiencies present in current smart contracts.

The current iteration of Gasper identifies a limited subset of the gas-costly patterns, with potential for future expansion to a broader set of recognized inefficiencies. The introduction of Gasper could stimulate improvements in compiler design by highlighting specific areas where automatic optimizations could be implemented, thus reducing unnecessary expenditures for contract deployments and executions.

Future Directions

Future advancements should involve an expanded scope for Gasper, allowing it to detect a wider array of inefficient patterns not yet covered. Additionally, enhancing compiler technologies to incorporate optimization strategies for the patterns identified can ensure that smart contracts are inherently more cost-effective on deployment. Moreover, optimizations addressing these inefficiencies at a virtual machine level could provide benefits to existing contracts that are deployed without the need for redeployment or recompilation.

Conclusion

This paper contributes meaningfully to the domain of blockchain and smart contracts by illuminating the widespread occurrence of non-optimized gas consumption patterns in Ethereum's smart contracts and proposing a method for systematically identifying these inefficiencies. The paper presents not just an academic exploration but a call to action for improving both software development practices in blockchain environments and the tools needed to ensure financially efficient operations.