[DSP-55] Add analyzer
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
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.