Synthesis of Super-Optimized Smart Contracts Using Max-SMT

被引:23
作者
Albert, Elvira [1 ,2 ]
Gordillo, Pablo [2 ]
Rubio, Albert [1 ,2 ]
Schett, Maria A. [3 ]
机构
[1] Inst Tecnol Conocimiento, Madrid, Spain
[2] Univ Complutense Madrid, Madrid, Spain
[3] UCL, London, England
来源
COMPUTER AIDED VERIFICATION (CAV 2020), PT I | 2020年 / 12224卷
关键词
D O I
10.1007/978-3-030-53288-8_10
中图分类号
TP3 [计算技术、计算机技术];
学科分类号
0812 ;
摘要
With the advent of smart contracts that execute on the blockchain ecosystem, a new mode of reasoning is required for developers that must pay meticulous attention to the gas spent by their smart contracts, as well as for optimization tools that must be capable of effectively reducing the gas required by the smart contracts. Super-optimization is a technique which attempts to find the best translation of a block of code by trying all possible sequences of instructions that produce the same result. This paper presents a novel approach for super-optimization of smart contracts based on Max-SMT which is split into two main phases: (i) the extraction of a stack functional specification from the basic blocks of the smart contract, which is simplified using rules that capture the semantics of the arithmetic, bit-wise, relational operations, etc. (ii) the synthesis of optimized blocks which, by means of an efficient Max-SMT encoding, finds the bytecode blocks with minimal gas cost whose stack functional specification is equal (modulo commutativity) to the extracted one. Our experimental results are very promising: we are able to optimize 55.41 % of the blocks, and prove that 34.28 % were already optimal, for more than 61 000 blocks from the most called 2500 Ethereum contracts.
引用
收藏
页码:177 / 200
页数:24
相关论文
共 23 条
  • [1] Albert E., 2018, LECT NOTES COMPUT SC, V11138, P513, DOI DOI 10.1007/978-3-030-01090-4_30
  • [2] GASOL: Gas Analysis and Optimization for Ethereum Smart Contracts
    Albert, Elvira
    Correas, Jesus
    Gordillo, Pablo
    Roman-Diez, Guillermo
    Rubio, Albert
    [J]. TOOLS AND ALGORITHMS FOR THE CONSTRUCTION AND ANALYSIS OF SYSTEMS, PT II, TACAS 2020, 2020, 12079 : 118 - 125
  • [3] [Anonymous], 2018, RATTLE AN EVM BINARY
  • [4] Bofill M, 2008, LECT NOTES COMPUT SC, V5123, P294
  • [5] TOAST: Applying answer set programming to superoptimisation
    Brain, Martin
    Crick, Tom
    De Vos, Marina
    Fitch, John
    [J]. LOGIC PROGRAMMING, PROCEEDINGS, 2006, 4079 : 270 - 284
  • [6] Towards Saving Money in Using Smart Contracts
    Chen, Ting
    Li, Zihao
    Zhou, Hao
    Chen, Jiachi
    Luo, Xiapu
    Li, Xiaoqi
    Zhang, Xiaosong
    [J]. 2018 IEEE/ACM 40TH INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING: NEW IDEAS AND EMERGING TECHNOLOGIES RESULTS (ICSE-NIER), 2018, : 81 - 84
  • [7] Chen T, 2017, 2017 IEEE 24TH INTERNATIONAL CONFERENCE ON SOFTWARE ANALYSIS, EVOLUTION, AND REENGINEERING (SANER), P442, DOI 10.1109/SANER.2017.7884650
  • [8] Cimatti A, 2013, LECT NOTES COMPUT SC, V7795, P93
  • [9] Z3: An efficient SMT solver
    de Moura, Leonardo
    Bjorner, Nikolaj
    [J]. TOOLS AND ALGORITHMS FOR THE CONSTRUCTION AND ANALYSIS OF SYSTEMS, 2008, 4963 : 337 - 340
  • [10] Dill D.L, 2019, MOVE LANGUAGE PROGRA