Skip to content

TM-292 Make it possible to apply a function to all strings

Ivan Gromakovskii requested to merge gromak/tm292-transform-strings into master

Description

Problem: having large strings in Michelson is painful.
1. They increase gas consumption.
2. They increase operation size. And increasing size may indirectly
increase gas consumption if you `UNPACK` something with a long string.

And we sometimes produce code with long strings, e. g. if they are
generated from field names. Sometimes these long strings are ok, but
sometimes we want to optimize gas consumption or code's size.

Solution: add `Preprocess` module exposing `transformStrings` to
apply an arbitrary function to all strings in a contract.
Existing `dfsInstr` function was generalized and now is used in
analyzer and preprocessor.

It's based on !36 (merged) because I need it in another project.

Related issue(s)

https://issues.serokell.io/issue/TM-292

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)

Merge request reports