Skip to content

[TM-337] Use safe migrations

Konstantin Ivanov requested to merge martoon/tm337-use-safe-migrations into master

Description

Problem: they are not used yet.

Solution: use them in upgradeable contract template and in samples.

We still allow manual migrations because migrations consisting of multiple stages (for the sake of fitting into gas limit) are not supported yet.

Also in this commit I had to make MigrationScript, as well as ContractCode, a newtype wrapper for the sake of HasTypeDoc instance.

What remains for future work (these changes are problematic to do at the current stage):

  • Make Parameter type of upgradeable contract know storage type.
  • Make ContractCode know storage type.
  • Make MigrationScript know old/new storage types.
  • Consider using more safe coercions for UContractRouter and MigrationScript (e.g. only coercion between UContractRouter and SomeUContractRouter should be allowed, not between two UContractRouters).

After these changes it won't be possible to accidentially apply migration to wrong version of a contract.

Related issue(s)

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

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 Konstantin Ivanov

Merge request reports