Skip to main content
Top
Published in:
Cover of the book

Open Access 2022 | OriginalPaper | Chapter

A Max-SMT Superoptimizer for EVM handling Memory and Storage

Authors : Elvira Albert, Pablo Gordillo, Alejandro Hernández-Cerezo, Albert Rubio

Published in: Tools and Algorithms for the Construction and Analysis of Systems

Publisher: Springer International Publishing

loading …

Superoptimization is a compilation technique that searches for the optimal sequence of instructions semantically equivalent to a given (loop-free) initial sequence. With the advent of SMT solvers, it has been successfully applied to LLVM code (to reduce the number of instructions) and to Ethereum EVM bytecode (to reduce its gas consumption). Both applications, when proven practical, have left out memory operations and thus missed important optimization opportunities. A main challenge to superoptimization today is handling memory operations while remaining scalable. We present $$\textsf {GASOL}^{v2}$$ GASOL v 2 , a gas and bytes-size superoptimization tool for Ethereum smart contracts, that leverages a previous Max-SMT approach for only stack optimization to optimize also wrt. memory and storage. $$\textsf {GASOL}^{v2}$$ GASOL v 2 can be used to optimize the size in bytes, aligned with the optimization criterion used by the Solidity compiler solc, and it can also be used to optimize gas consumption. Our experiments on 12,378 blocks from 30 randomly selected real contracts achieve gains of 16.42% in gas wrt. the previous version of the optimizer without memory handling, and gains of 3.28% in bytes-size over code already optimized by solc.

Metadata
Title
A Max-SMT Superoptimizer for EVM handling Memory and Storage
Authors
Elvira Albert
Pablo Gordillo
Alejandro Hernández-Cerezo
Albert Rubio
Copyright Year
2022
DOI
https://doi.org/10.1007/978-3-030-99524-9_11

Premium Partner