TY - CONF AB - Smart contracts are programs that are stored and executed on the Blockchain and can receive, manage and transfer money (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 cause significant financial losses. Compiler optimization is also crucial, because every action of a smart contract has to be executed by every node in the Blockchain network. Therefore, optimizations in compiling smart contracts can lead to significant savings in computation, time and energy. Two classical approaches in 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, the analyses are usually reduced to graph problems over the control flow graph (CFG) of the program. These graph problems are often computationally expensive. Hence, there has been ample research on exploiting structural properties of CFGs for efficient algorithms. One such well-studied property is the treewidth, which is a measure of tree-likeness of graphs. It is known that intraprocedural CFGs of structured programs have treewidth at most 6, whereas the interprocedural treewidth cannot be bounded. This result 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. AU - Chatterjee, Krishnendu AU - Goharshady, Amir Kafshdar AU - Goharshady, Ehsan Kafshdar ID - 6490 SN - 9781450359337 T2 - Proceedings of the 34th ACM Symposium on Applied Computing TI - The treewidth of smart contracts VL - Part F147772 ER - TY - JOUR AB - Interprocedural analysis is at the heart of numerous applications in programming languages, such as alias analysis, constant propagation, and so on. Recursive state machines (RSMs) are standard models for interprocedural analysis. We consider a general framework with RSMs where the transitions are labeled from a semiring and path properties are algebraic with semiring operations. RSMs with algebraic path properties can model interprocedural dataflow analysis problems, the shortest path problem, the most probable path problem, and so on. The traditional algorithms for interprocedural analysis focus on path properties where the starting point is fixed as the entry point of a specific method. In this work, we consider possible multiple queries as required in many applications such as in alias analysis. The study of multiple queries allows us to bring in an important algorithmic distinction between the resource usage of the one-time preprocessing vs for each individual query. The second aspect we consider is that the control flow graphs for most programs have constant treewidth. Our main contributions are simple and implementable algorithms that support multiple queries for algebraic path properties for RSMs that have constant treewidth. Our theoretical results show that our algorithms have small additional one-time preprocessing but can answer subsequent queries significantly faster as compared to the current algorithmic solutions for interprocedural dataflow analysis. We have also implemented our algorithms and evaluated their performance for performing on-demand interprocedural dataflow analysis on various domains, such as for live variable analysis and reaching definitions, on a standard benchmark set. Our experimental results align with our theoretical statements and show that after a lightweight preprocessing, on-demand queries are answered much faster than the standard existing algorithmic approaches. AU - Chatterjee, Krishnendu AU - Goharshady, Amir Kafshdar AU - Goyal, Prateesh AU - Ibsen-Jensen, Rasmus AU - Pavlogiannis, Andreas ID - 7158 IS - 4 JF - ACM Transactions on Programming Languages and Systems SN - 0164-0925 TI - Faster algorithms for dynamic algebraic queries in basic RSMs with constant treewidth VL - 41 ER - TY - JOUR AB - We study the problem of developing efficient approaches for proving worst-case bounds of non-deterministic recursive programs. Ranking functions are sound and complete for proving termination and worst-case bounds of nonrecursive programs. First, we apply ranking functions to recursion, resulting in measure functions. We show that measure functions provide a sound and complete approach to prove worst-case bounds of non-deterministic recursive programs. Our second contribution is the synthesis of measure functions in nonpolynomial forms. We show that non-polynomial measure functions with logarithm and exponentiation can be synthesized through abstraction of logarithmic or exponentiation terms, Farkas' Lemma, and Handelman's Theorem using linear programming. While previous methods obtain worst-case polynomial bounds, our approach can synthesize bounds of the form $\mathcal{O}(n\log n)$ as well as $\mathcal{O}(n^r)$ where $r$ is not an integer. We present experimental results to demonstrate that our approach can obtain efficiently worst-case bounds of classical recursive algorithms such as (i) Merge-Sort, the divide-and-conquer algorithm for the Closest-Pair problem, where we obtain $\mathcal{O}(n \log n)$ worst-case bound, and (ii) Karatsuba's algorithm for polynomial multiplication and Strassen's algorithm for matrix multiplication, where we obtain $\mathcal{O}(n^r)$ bound such that $r$ is not an integer and close to the best-known bounds for the respective algorithms. AU - Chatterjee, Krishnendu AU - Fu, Hongfei AU - Goharshady, Amir Kafshdar ID - 7014 IS - 4 JF - ACM Transactions on Programming Languages and Systems TI - Non-polynomial worst-case analysis of recursive programs VL - 41 ER - TY - JOUR AB - Based on a novel control scheme, where a steady modification of the streamwise velocity profile leads to complete relaminarization of initially fully turbulent pipe flow, we investigate the applicability and usefulness of custom-shaped honeycombs for such control. The custom-shaped honeycombs are used as stationary flow management devices which generate specific modifications of the streamwise velocity profile. Stereoscopic particle image velocimetry and pressure drop measurements are used to investigate and capture the development of the relaminarizing flow downstream these devices. We compare the performance of straight (constant length across the radius of the pipe) honeycombs with custom-shaped ones (variable length across the radius) and try to determine the optimal shape for maximal relaminarization at minimal pressure loss. The optimally modified streamwise velocity profile is found to be M-shaped, and the maximum attainable Reynolds number for total relaminarization is found to be of the order of 10,000. Consequently, the respective reduction in skin friction downstream of the device is almost by a factor of 5. The break-even point, where the additional pressure drop caused by the device is balanced by the savings due to relaminarization and a net gain is obtained, corresponds to a downstream stretch of distances as low as approximately 100 pipe diameters of laminar flow. AU - Kühnen, Jakob AU - Scarselli, Davide AU - Hof, Björn ID - 6486 IS - 11 JF - Journal of Fluids Engineering SN - 00982202 TI - Relaminarization of pipe flow by means of 3D-printed shaped honeycombs VL - 141 ER - TY - JOUR AB - Following the recent observation that turbulent pipe flow can be relaminarised bya relatively simple modification of the mean velocity profile, we here carry out aquantitative experimental investigation of this phenomenon. Our study confirms thata flat velocity profile leads to a collapse of turbulence and in order to achieve theblunted profile shape, we employ a moving pipe segment that is briefly and rapidlyshifted in the streamwise direction. The relaminarisation threshold and the minimumshift length and speeds are determined as a function of Reynolds number. Althoughturbulence is still active after the acceleration phase, the modulated profile possessesa severely decreased lift-up potential as measured by transient growth. As shown,this results in an exponential decay of fluctuations and the flow relaminarises. Whilethis method can be easily applied at low to moderate flow speeds, the minimumstreamwise length over which the acceleration needs to act increases linearly with theReynolds number. AU - Scarselli, Davide AU - Kühnen, Jakob AU - Hof, Björn ID - 6228 JF - Journal of Fluid Mechanics SN - 00221120 TI - Relaminarising pipe flow by wall movement VL - 867 ER -