Skip to content

[#829] Prohibit some operations in views

Nikolay Yakimov requested to merge lierdakil/#829-views-prohibited-ops into master

Description

Problem: As per jakarta's changelog for Michelson:

Some operations are now forbidden in views: CREATE_CONTRACT, SET_DELEGATE and TRANSFER_TOKENS cannot be used at the top-level of a view because they are stateful, and SELF because the entry-point does not make sense in a view. However, CREATE_CONTRACT, SET_DELEGATE and TRANSFER_TOKENS remain available in lambdas defined inside a view.

We want to do the same and prohibit these instructions from appearing in views in morley as well.

Solution: Introduce an empty typeclass 'IsNotInView', with a default instance producing a type error and a helper 'giveNotInView' that fakes this instance. Constrain forbidden instructions by this typeclass. Provide the faked instance inside lambdas and in contract code (in the typed interface). In typechecker, explicitly pass a 'Maybe (Dict IsNotInView)' as part of instruction typechecking env. Also fix a weird place where instruction typechecking env is thrown away inside DIP.

In Lorentz, the need to constrain lambdas forces us to introduce an explicit lambda datatype.

Related issue(s)

Resolves #829 (closed)

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:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Edited by Nikolay Yakimov

Merge request reports