GasMet: Profiling Gas Leaks in the Deployment of Solidity Smart Contracts

08/12/2020
by   Gerardo Canfora, et al.
0

Nowadays, blockchain technologies are increasingly adopted for different purposes and in different application domains. Accordingly, more and more applications are developed for running on a distributed ledger technology (i.e., dApps). The business logic of a dApp (or part of it) is usually implemented within one (or more) smart contract(s) developed through Solidity, an object-oriented programming language for writing smart contracts on different blockchain platforms, including the popular Ethereum. In Ethereum, once compiled, the smart contracts run on the machines of miners who can earn Ethers (a cryptographic currency like Bitcoin) by contributing their computing resources and the gas (in Ether) corresponds to the execution fee compensating such computing resources. However, the deployment and execution costs of a smart contract strictly depend on the choices done by developers while implementing it. Unappropriated design choices – e.g., in the data structures and the specific instructions used – could lead to higher gas consumption than necessary. In this paper, we systematically identify a set of 20 Solidity code smells that could affect the deployment and transaction costs of a smart contract, i.e., cost smells. 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. In an experiment involving 2,186 real-world smart contracts, we demonstrate that the proposed metrics (i) have direct associations with deployment costs, and (ii) they could be used to properly identify the level of gas consumption of a smart contract without the need for deploying it.

READ FULL TEXT
research
10/23/2019

The Economics of Smart Contracts

Ethereum is a distributed blockchain that can execute smart contracts, w...
research
11/11/2019

GRuB: Gas-Efficient Blockchain Storage via Workload-Adaptive Data Replication

Modern Blockchains support the execution of user programs, called smart ...
research
09/20/2023

Lazy Contracts: Alleviating High Gas Costs by Secure and Trustless Off-chain Execution of Smart Contracts

Smart contracts are programs that are executed on the blockchain and can...
research
06/16/2021

iBatch: Saving Ethereum Fees via Secure and Cost-Effective Batching of Smart-Contract Invocations

This paper presents iBatch, a middleware system running on top of an ope...
research
01/11/2023

Inferring Needless Write Memory Accesses on Ethereum Bytecode (Extended Version)

Efficiency is a fundamental property of any type of program, but it is e...
research
09/16/2019

Broken Metre: Attacking Resource Metering in EVM

Metering is an approach developed to assign cost to smart contract execu...
research
12/18/2017

An Adaptive Gas Cost Mechanism for Ethereum to Defend Against Under-Priced DoS Attacks

The gas mechanism in Ethereum charges the execution of every operation t...

Please sign up or login with your details

Forgot password? Click here to reset