The Treewidth of Smart Contracts

Chatterjee, Krishnendu and Goharshady, Amir and Goharshady, Ehsan The Treewidth of Smart Contracts. In: ACM Symposium on Applied Computing (SAC), April 8-12, 2019, Limassol, Cyprus. (Submitted)

[img] Text
paper.pdf - Submitted Version
Download (10Mb)


Smart contracts are programs that are stored and executed on the Blockchain and can receive, manage and transfer money in the form of cryptocurrency units. Two important problems regarding smart contracts are formal analysis and compiler optimization. Formal analysis is extremely important, because smart contracts hold funds worth billions of dollars and their code is immutable after deployment. Hence, an undetected bug can potentially cause significant financial losses. Compiler optimization is also crucial, because every action of a smart contract has to be executed and verified by every node in the Blockchain network. Hence, optimizations in compiling smart contracts can lead to significant savings of computation, time and energy. Two classical approaches in both program analysis and compiler optimization are intraprocedural and interprocedural analysis. In intraprocedural analysis, each function is analyzed separately, while interprocedural analysis considers the entire program. In both cases, optimization and analysis problems are often reduced to graph problems over the control flow graph (CFG) of the program. However, the resulting graph problems are often computationally expensive. Hence, there has been ample research on exploiting structural properties of CFGs to obtain efficient algorithms for these problems. One well-studied structural property is the treewidth. Treewidth is a measure of tree-likeness of graphs and small treewidth can be exploited for efficient algorithms. It is known that intraprocedural CFGs of structured programs have treewidth at most 6, whereas the interprocedural treewidth cannot be bounded. Bounded treewidth has been used as a basis for many efficient intraprocedural analyses. In this paper, we explore the idea of exploiting the treewidth of smart contracts for formal analysis and compiler optimization. First, similar to classical programs, we show that the intraprocedural treewidth of structured Solidity and Vyper smart contracts is at most~9. Second, for global analysis, we prove that the interprocedural treewidth of structured smart contracts is bounded by 10 and, in sharp contrast with classical programs, treewidth-based algorithms can be easily applied for interprocedural analysis. Finally, we supplement our theoretical results with experiments using a tool we implemented for computing treewidth of smart contracts and show that the treewidth is much lower in practice. We use 36,764 real-world Ethereum smart contracts as benchmarks and find that they have an average treewidth of at most 3.35 for the intraprocedural case and 3.65 for the interprocedural case.

Item Type: Conference or Workshop Item (Paper)
Subjects: 000 Computer science, knowledge & general works > 000 Computer science, knowledge & systems > 004 Data processing & computer science
Research Group: Chatterjee Group
Depositing User: Amir Goharshady
Date Deposited: 03 Dec 2018 12:18
Last Modified: 03 Dec 2018 12:18

Actions (login required)

View Item View Item