The Treewidth of Smart Contracts - Archive ouverte HAL Accéder directement au contenu
Communication Dans Un Congrès Année : 2019

The Treewidth of Smart Contracts

Résumé

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 in-traprocedural 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 intraprocedu-ral treewidth of structured Solidity and Vyper smart contracts is at most 9. Second, for global analysis, we prove that the interpro-cedural 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
Fichier principal
Vignette du fichier
CGG-SAC2019.pdf (10.13 Mo) Télécharger le fichier
Origine : Fichiers produits par l'(les) auteur(s)
Loading...

Dates et versions

hal-01942005 , version 1 (02-12-2018)
hal-01942005 , version 2 (05-03-2019)

Identifiants

  • HAL Id : hal-01942005 , version 2

Citer

Krishnendu Chatterjee, Amir Kafshdar Goharshady, Ehsan Kafshdar Goharshady. The Treewidth of Smart Contracts. ACM Symposium on Applied Computing (SAC), Apr 2019, Limassol, Cyprus. ⟨hal-01942005v2⟩

Collections

TDS-MACS
94 Consultations
354 Téléchargements

Partager

Gmail Facebook X LinkedIn More