ISSTA 2024
Mon 16 - Fri 20 September 2024 Vienna, Austria
co-located with ISSTA/ECOOP 2024

Smart contracts mostly written in Solidity are Turing-complete programs executed on the blockchain platforms such as Ethereum. To prevent resource abuse, a gas fee is required when users deploy or invoke smart contracts. Although saving gas consumption has received much attention, no work investigates the effect of function dispatch on the invocation gas consumption. In this paper, after demystifying how the function dispatch affects the invocation gas consumption, we present \textsf{\textsc{FunRedisp}}, a bytecode refactoring method and an open-source tool, to reduce the overall invocation gas consumption of smart contracts. At the source code level, \textsf{\textsc{FunRedisp}} initially identifies hot functions in a smart contract that have a big chance to be invoked, and then move them to the front of the function dispatch at the bytecode level. We implement \textsf{\textsc{FunRedisp}} and evaluate it on 50 real-world smart contracts randomly selected from Ethereum. The experimental results demonstrate that \textsf{\textsc{FunRedisp}} can save approximately 125.17 units of gas per transaction with the compilation overhead increased by only 0.37 seconds.