Abstract
Since executing a smart contract on the Ethereum blockchain costs money (measured in gas), smart contract developers spend significant effort in reducing gas usage. In this paper, we propose a new technique for reducing the gas usage of smart contracts by changing the underlying data layout. Given a smart contract P and a type-level transformation, our method automatically synthesizes a new contract P′ that is functionally equivalent to P. Our approach provides a convenient DSL for expressing data type refactorings and employs program synthesis to generate the new version of the contract. We have implemented our approach in a tool called Solidare and demonstrate its capabilities on real-world smart contracts from Etherscan and GasStation. In particular, we show that our approach is effective at automating the desired data layout transformation and that it is useful for reducing gas usage of smart contracts that use rich data structures.
- Elvira Albert, Jesús Correas, Pablo Gordillo, Guillermo Román-Díez, and Albert Rubio. 2020. GASOL: Gas Analysis and Optimization for Ethereum Smart Contracts. In International Conference on Tools and Algorithms for the Construction and Analysis of Systems (TACAS). 12079, Springer, 118–125. https://doi.org/10.1007/978-3-030-45237-7_7
Google Scholar
Digital Library
- Elvira Albert, Pablo Gordillo, Albert Rubio, and Maria Anna Schett. 2020. Synthesis of Super-Optimized Smart Contracts Using Max-SMT. 177–200. https://doi.org/10.1007/978-3-030-53288-8_10
Google Scholar
Digital Library
- Elvira Albert, Pablo Gordillo, Albert Rubio, and Ilya Sergey. 2019. Running on Fumes - Preventing Out-of-Gas Vulnerabilities in Ethereum Smart Contracts Using Static Resource Analysis. In Proceedings of International Conference on Verification and Evaluation of Computer and Communication Systems (VECoS). Springer, 63–78. https://doi.org/10.1007/978-3-030-35092-5_5
Google Scholar
Cross Ref
- Ittai Balaban, Frank Tip, and Robert M. Fuhrer. 2005. Refactoring support for class library migration. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming (OOPSLA). ACM, 265–279. https://doi.org/10.1145/1094811.1094832
Google Scholar
Digital Library
- Vitalik Buterin. 2014. Ethereum: A Next-Generation Smart Contract and Decentralized Application Platform. https://ethereum.org/en/whitepaper
Google Scholar
- Ting Chen, Xiaoqi Li, Xiapu Luo, and Xiaosong Zhang. 2017. Under-optimized smart contracts devour your money. In IEEE 24th International Conference on Software Analysis, Evolution and Reengineering (SANER). IEEE Computer Society, 442–446. https://doi.org/10.1109/SANER.2017.7884650
Google Scholar
Cross Ref
- Ting Chen, Zihao Li, Hao Zhou, Jiachi Chen, Xiapu Luo, Xiaoqi Li, and Xiaosong Zhang. 2018. Towards saving money in using smart contracts. In 2018 IEEE/ACM 40th International Conference on Software Engineering: New Ideas and Emerging Technologies Results (ICSE-NIER). 81–84. https://doi.org/10.1145/3183399.3183420
Google Scholar
Digital Library
- Carlo Curino, Hyun Jin Moon, Alin Deutsch, and Carlo Zaniolo. 2013. Automating the database schema evolution process. VLDB J., 22, 1 (2013), 73–98. https://doi.org/10.1007/s00778-012-0302-x
Google Scholar
Digital Library
- Ankush Das, Stephanie Balzer, Jan Hoffmann, Frank Pfenning, and Ishani Santurkar. 2020. Language-Based Web Session Integrity. In Proceedings of the Computer Security Foundations Symposium (CSF). IEEE, 107–122. https://doi.org/10.1109/CSF49147.2020.00016
Google Scholar
Cross Ref
- Ankush Das and Shaz Qadeer. 2020. Exact and Linear-Time Gas-Cost Analysis. 12389 (2020), 333–356. https://doi.org/10.1007/978-3-030-65474-0_15
Google Scholar
Digital Library
- Benjamin Delaware, Clément Pit-Claudel, Jason Gross, and Adam Chlipala. 2015. Fiat: Deductive Synthesis of Abstract Data Types in a Proof Assistant. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. ACM, 689–700. https://doi.org/10.1145/2676726.2677006
Google Scholar
Digital Library
- Danny Dig, Stas Negara, Vibhu Mohindra, and Ralph E. Johnson. 2008. ReBA: refactoring-aware binary adaptation of evolving libraries. In Proceedings of the International Conference on Software Engineering (ICSE). ACM, 441–450. https://doi.org/10.1145/1368088.1368148
Google Scholar
Digital Library
- Ethereum. 2022. Ethereum Virtual Machine. https://ethereum.org/en/developers/docs/evm
Google Scholar
- Etherscan. 2022. https://etherscan.io
Google Scholar
- ETHGasStation. 2022. https://ethgasstation.info
Google Scholar
- Yu Feng, Ruben Martins, Osbert Bastani, and Isil Dillig. 2018. Program synthesis using conflict-driven learning. 420–435. https://doi.org/10.1145/3192366.3192382
Google Scholar
Digital Library
- John Feser, Sam Madden, Nan Tang, and Armando Solar-Lezama. 2020. Deductive optimization of relational data storage. Proceedings of the ACM on Programming Languages, 4, OOPSLA (2020), 1–30. https://doi.org/10.1145/3428238
Google Scholar
Digital Library
- Peter Hawkins, Alex Aiken, Kathleen Fisher, Martin C. Rinard, and Mooly Sagiv. 2011. Data representation synthesis. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). ACM, 38–49. https://doi.org/10.1145/1993498.1993504
Google Scholar
Digital Library
- Peter Hawkins, Alex Aiken, Kathleen Fisher, Martin C. Rinard, and Mooly Sagiv. 2012. Concurrent data representation synthesis. In ACM SIGPLAN Conference on Programming Language Design and Implementation, (PLDI). ACM, 417–428. https://doi.org/10.1145/2254064.2254114
Google Scholar
Digital Library
- Johannes Henkel and Amer Diwan. 2005. CatchUp!: capturing and replaying refactorings to support API evolution. In Proceedings of the International Conference on Software Engineering (ICSE). ACM, 274–283. https://doi.org/10.1145/1062455.1062512
Google Scholar
Digital Library
- Bo Jiang, Ye Liu, and W. K. Chan. 2018. ContractFuzzer: fuzzing smart contracts for vulnerability detection. In Proceedings of the ACM/IEEE International Conference on Automated Software Engineering, (ASE). ACM, 259–269. https://doi.org/10.1145/3238147.3238177
Google Scholar
Digital Library
- Sukrit Kalra, Seep Goel, Mohan Dhawan, and Subodh Sharma. 2018. ZEUS: Analyzing Safety of Smart Contracts. In Proceedings of the Annual Network and Distributed System Security Symposium (NDSS). The Internet Society. https://doi.org/10.14722/ndss.2018.23082
Google Scholar
Cross Ref
- Ameya Ketkar, Ali Mesbah, Davood Mazinanian, Danny Dig, and Edward Aftandilian. 2019. Type migration in ultra-large-scale codebases. In Proceedings of the International Conference on Software Engineering (ICSE). IEEE / ACM, 1142–1153. https://doi.org/10.1109/ICSE.2019.00117
Google Scholar
Digital Library
- Daniel Le Berre and Anne Parrain. 2010. The sat4j library, release 2.2, system description. Journal on Satisfiability, Boolean Modeling and Computation, 7 (2010), 59–64. https://doi.org/10.3233/SAT190075
Google Scholar
Cross Ref
- Ao Li, Jemin Andrew Choi, and Fan Long. 2020. Securing smart contract with runtime validation. In Proceedings of the ACM SIGPLAN International Conference on Programming Language Design and Implementation (PLDI). ACM, 438–453. https://doi.org/10.1145/3385412.3385982
Google Scholar
Digital Library
- Chu Min Li and Felip Manya. 2009. MaxSAT, Hard and Soft Constraints.. Handbook of satisfiability, 185 (2009), 613–631. https://doi.org/10.3233/FAIA201007
Google Scholar
Cross Ref
- Shaokai Lin, Xinyuan Sun, Jianan Yao, and Ronghui Gu. 2021. SciviK: A Versatile Framework for Specifying and Verifying Smart Contracts. CoRR, abs/2103.02209 (2021), arxiv:2103.02209. arxiv:2103.02209
Google Scholar
- Calvin Loncaric, Michael D. Ernst, and Emina Torlak. 2018. Generalized data structure synthesis. In Proceedings of the 40th International Conference on Software Engineering (ICSE). ACM, 958–968. https://doi.org/10.1145/3180155.3180211
Google Scholar
Digital Library
- Calvin Loncaric, Emina Torlak, and Michael D. Ernst. 2016. Fast synthesis of fast collections. In Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). ACM, 355–368. https://doi.org/10.1145/2908080.2908122
Google Scholar
Digital Library
- Loi Luu, Duc-Hiep Chu, Hrishi Olickel, Prateek Saxena, and Aquinas Hobor. 2016. Making Smart Contracts Smarter. In Proceedings of the ACM SIGSAC Conference on Computer and Communications Security (CCS). ACM, 254–269. https://doi.org/10.1109/ICBC51069.2021.9461148
Google Scholar
Cross Ref
- Inês Lynce and Joao P Marques-Silva. 2004. On computing minimum unsatisfiable cores. http://www.satisfiability.org/SAT04/programme/110.pdf
Google Scholar
- Benjamin Mariano, Yanju Chen, Yu Feng, Shuvendu K. Lahiri, and Isil Dillig. 2020. Demystifying Loops in Smart Contracts. In Proceedings of the International Conference on Automated Software Engineering (ASE). IEEE, 262–274. https://doi.org/10.1145/3324884.3416626
Google Scholar
Digital Library
- Joao Marques-Silva, Inês Lynce, and Sharad Malik. 2009. Conflict-driven clause learning SAT solvers. In Handbook of satisfiability. ios Press, 131–153. https://doi.org/10.3233/978-1-58603-929-5-131
Google Scholar
Cross Ref
- John C Mitchell. 1991. On the equivalence of data representations. Artificial intelligence and mathematical theory of computation: papers in honor of John McCarthy, 305–330. https://doi.org/10.1016/b978-0-12-450010-5.50023-2
Google Scholar
Cross Ref
- Julian Nagele and Maria A Schett. 2020. Blockchain Superoptimizer. arXiv preprint arXiv:2005.05912, arxiv:2005.05912
Google Scholar
- Shankara Pailoor, Yuepeng Wang, Xinyu Wang, and Isil Dillig. 2021. Synthesizing data structure refinements from integrity constraints. In Proceedings of the ACM SIGPLAN International Conference on Programming Language Design and Implementation (PLDI). ACM, 574–587. https://doi.org/10.1145/3453483.3454063
Google Scholar
Digital Library
- Anton Permenev, Dimitar Dimitrov, Petar Tsankov, Dana Drachsler-Cohen, and Martin T. Vechev. 2020. VerX: Safety Verification of Smart Contracts. In IEEE Symposium on Security and Privacy (SP). IEEE, 1661–1677. https://doi.org/10.1109/SP40000.2020.00024
Google Scholar
Cross Ref
- Xiaokang Qiu and Armando Solar-Lezama. 2017. Natural synthesis of provably-correct data-structure manipulations. Proceedings of the ACM on Programming Languages, 1, OOPSLA (2017), 65:1–65:28. https://doi.org/10.1145/3133889
Google Scholar
Digital Library
- Ilya Sergey, Vaivaswatha Nagaraj, Jacob Johannsen, Amrit Kumar, Anton Trunov, and Ken Chan Guan Hao. 2019. Safer smart contract programming with Scilla. Proceedings of the ACM on Programming Languages, 3, OOPSLA (2019), 185:1–185:30. https://doi.org/10.1145/3360611
Google Scholar
Digital Library
- Armando Solar-Lezama, Christopher Grant Jones, and Rastislav Bodík. 2008. Sketching concurrent data structures. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). ACM, 136–148. https://doi.org/10.1145/1375581.1375599
Google Scholar
Digital Library
- Friedrich Steimann and Andreas Thies. 2009. From Public to Private to Absent: Refactoring Java Programs under Constrained Accessibility. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP) (Lecture Notes in Computer Science, Vol. 5653). Springer, 419–443. https://doi.org/10.1007/978-3-642-03013-0_19
Google Scholar
Digital Library
- Frank Tip, Robert M. Fuhrer, Adam Kiezun, Michael D. Ernst, Ittai Balaban, and Bjorn De Sutter. 2011. Refactoring using type constraints. ACM Trans. Program. Lang. Syst., 33, 3 (2011), 9:1–9:47. https://doi.org/10.1145/1961204.1961205
Google Scholar
Digital Library
- Frank Tip, Adam Kiezun, and Dirk Bäumer. 2003. Refactoring for generalization using type constraints. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems (OOPSLA). ACM, 13–26. https://doi.org/10.1145/949305.949308
Google Scholar
Digital Library
- Yuepeng Wang, James Dong, Rushi Shah, and Isil Dillig. 2019. Synthesizing database programs for schema refactoring. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). ACM, 286–300. https://doi.org/10.1145/3314221.3314588
Google Scholar
Digital Library
- Yuepeng Wang, Shuvendu K. Lahiri, Shuo Chen, Rong Pan, Isil Dillig, Cody Born, Immad Naseer, and Kostas Ferles. 2019. Formal Verification of Workflow Policies for Smart Contracts in Azure Blockchain. In Proceedings of the International Conference on Verified Software. Theories, Tools, and Experiments (VSTTE) (Lecture Notes in Computer Science, Vol. 12031). Springer, 87–106. https://doi.org/10.1007/978-3-030-41600-3_7
Google Scholar
Cross Ref
- Yuepeng Wang, Rushi Shah, Abby Criswell, Rong Pan, and Isil Dillig. 2020. Data Migration using Datalog Program Synthesis. Proceedings of the VLDB Endowment, 13, 7 (2020), 1006–1019. https://doi.org/10.14778/3384345.3384350
Google Scholar
Digital Library
- Gavin Wood. 2022. Ethereum: A Secure Decentralised Generalised Transaction Ledger. https://ethereum.github.io/yellowpaper/paper.pdf
Google Scholar
Index Terms
Synthesis-powered optimization of smart contracts via data type refactoring
Recommendations
An overview on smart contracts: Challenges, advances and platforms
AbstractSmart contract technology is reshaping conventional industry and business processes. Being embedded in blockchains, smart contracts enable the contractual terms of an agreement to be enforced automatically without the intervention of a ...
Highlights- Opportunities of smart contracts for industrial internet of things.
- Lifecycle ...
Blockchain and Smart Contracts
ICSIE '19: Proceedings of the 8th International Conference on Software and Information EngineeringThis paper presents an introduction to the current state of art of the Blockchain and Smart Contract technologies. Blockchain is a fast-disruptive technology becoming a key instrument in share economy. The Blockchain-based Smart Contract aim to ...
Towards saving money in using smart contracts
ICSE-NIER '18: Proceedings of the 40th International Conference on Software Engineering: New Ideas and Emerging ResultsBeing a new kind of software leveraging blockchain to execute real contracts, smart contracts are in great demand due to many advantages. Ethereum is the largest blockchain platform that supports smart contracts by running them in its virtual machine. ...






Comments