Synthesis of Sound and Precise Storage Cost Bounds via Unsound Resource Analysis and Max-SMT
Proceedings of the 33rd ACM SIGSOFT International Symposium on Software …, 2024•dl.acm.org
A storage is a persistent memory whose contents are kept across different program
executions. In the blockchain technology, storage contents are replicated and incur the
largest costs of a program's execution (aka gas fees). Storage costs are dynamically
calculated using a rather complex model which assigns a much larger cost to the first access
made in an execution to a storage key, and besides assigns different costs to write accesses
depending on whether they change the values wrt the initial and previous contents. Safely …
executions. In the blockchain technology, storage contents are replicated and incur the
largest costs of a program's execution (aka gas fees). Storage costs are dynamically
calculated using a rather complex model which assigns a much larger cost to the first access
made in an execution to a storage key, and besides assigns different costs to write accesses
depending on whether they change the values wrt the initial and previous contents. Safely …
A storage is a persistent memory whose contents are kept across different program executions. In the blockchain technology, storage contents are replicated and incur the largest costs of a program’s execution (a.k.a. gas fees). Storage costs are dynamically calculated using a rather complex model which assigns a much larger cost to the first access made in an execution to a storage key, and besides assigns different costs to write accesses depending on whether they change the values w.r.t. the initial and previous contents. Safely assuming the largest cost for all situations, as done in existing gas analyzers, is an overly-pessimistic approach that might render useless bounds because of being too loose. The challenge is to soundly, and yet accurately, synthesize storage bounds which take into account the dynamicity implicit to the cost model. Our solution consists in using an off-the-shelf static resource analysis —but do not always assuming a worst-case cost— and hence yielding unsound bounds; and then, in a posterior stage, computing corrections to recover soundness in the bounds by using a new Max-SMT based approach. We have implemented our approach and used it to improve the precision of two gas analyzers for Ethereum, gastap and asparagus. Experimental results on more than 400,000 functions show that we achieve great accuracy gains, up to 75%, on the storage bounds, being the most frequent gains between 10-20%.

Showing the best result for this search. See all results