Skip to content

[DSP-55] Add analyzer

Ivan Gromakovskii requested to merge gromak/dsp55-analyze-contracts into master

Description

Problem: sometimes we want to statically analyze Michelson contracts. Our current use case is to figure out whether we have some long strings that are used in many places. Such strings may substantially increase operations' sizes, so we may have to optimize them.

Solution: add Michelson.Analyzer with analysis logic. analyze function returns AnalyzerRes data type which we can extend later. For now it only stores information about string and bytes constants. morley executable now has a new command to analyze a contract.

This is the first step towards analyzing our big contract. This static analysis can help us decrease contract's size, but it's not really useful for gas consumption optimization. I plan to also add some analysis to interpreter to know how often constant strings are used, because if some constant appears in code 10000 times, but is almost never used, making it smaller won't affect gas consumption significantly.

Related issue(s)

https://issues.serokell.io/issue/DSP-55

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:

Stylistic guide (mandatory)

Edited by Ivan Gromakovskii

Merge request reports