[#856] Add Lorentz emit instructions
Description
Problem: we support contract events, but lorentz lacks corresponding instructions.
Solution: add emit
and emit'
instructions, the latter omitting the
type annotation.
Related issue(s)
Resolves None

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.
Merge request reports
Activity
assigned to @lierdakil
mentioned in merge request !1213 (merged)
847 851 openChest :: ChestKey : Chest : Natural : s :-> OpenChest : s 848 852 openChest = I OPEN_CHEST 849 853 854 emit :: forall t s. (NicePackedValue t, HasAnnotation t) => FieldAnn -> t : s :-> Operation : s 855 emit tag = I $ EMIT tag ann' \\ nicePackedValueEvi @t 856 where 857 ann = getAnnotation @t NotFollowEntrypoint 858 ann' | ann == starNotes = Nothing 859 | otherwise = Just ann - Comment on lines +857 to +859
this is done for efficiency, right?as we discussed
Just startNotes
andNothing
result in different Michelson instructions, but in practice they behave the same (except that one is heavier because of the type annotation).If this is the case, could you please add a comment to clarify that this is the reason?
847 851 openChest :: ChestKey : Chest : Natural : s :-> OpenChest : s 848 852 openChest = I OPEN_CHEST 849 853 854 emit :: forall t s. (NicePackedValue t, HasAnnotation t) => FieldAnn -> t : s :-> Operation : s 855 emit tag = I $ EMIT tag ann' \\ nicePackedValueEvi @t 856 where 857 ann = getAnnotation @t NotFollowEntrypoint 858 ann' | ann == starNotes = Nothing 859 | otherwise = Just ann 860 861 -- | Version of 'emit' that omits the type annotation, letting the runtime infer 862 -- it instead. 863 emit' :: forall t s. (NicePackedValue t) => FieldAnn -> t : s :-> Operation : s 864 emit' tag = I $ EMIT tag Nothing \\ nicePackedValueEvi @t - Comment on lines +854 to +864
Only one suggestion from me because:
- these two are mostly the same
- I could see a rare case in which one would want to specify the
Notes
directly (e.g. this would be the only way to useJust starNotes
if one wants it for whatever reason)
So I think it would be nice to add a third variant with the additional argument, e.g.
854 emit :: forall t s. (NicePackedValue t, HasAnnotation t) => FieldAnn -> t : s :-> Operation : s 855 emit tag = I $ EMIT tag ann' \\ nicePackedValueEvi @t 856 where 857 ann = getAnnotation @t NotFollowEntrypoint 858 ann' | ann == starNotes = Nothing 859 | otherwise = Just ann 860 861 -- | Version of 'emit' that omits the type annotation, letting the runtime infer 862 -- it instead. 863 emit' :: forall t s. (NicePackedValue t) => FieldAnn -> t : s :-> Operation : s 864 emit' tag = I $ EMIT tag Nothing \\ nicePackedValueEvi @t 854 -- | Version of 'emit' that adds the type annotation, only when @t@ has annotations. 855 emit :: forall t s. (NicePackedValue t, HasAnnotation t) => FieldAnn -> t : s :-> Operation : s 856 emit tag = emit' tag ann' 857 where 858 ann = getAnnotation @t NotFollowEntrypoint 859 ann' | ann == starNotes = Nothing 860 | otherwise = Just ann 861 862 -- | Version of 'emit' that omits the type annotation, letting the runtime infer 863 -- it instead. 864 emitAuto :: forall t s. (NicePackedValue t) => FieldAnn -> t : s :-> Operation : s 865 emitAuto tag = emit' tag Nothing 866 867 emit' 868 :: forall t s. (NicePackedValue t) 869 => FieldAnn 870 -> Maybe (Notes (ToT t)) 871 -> t : s :-> Operation : s 872 emit' tag mNotes = I $ EMIT tag mNotes \\ nicePackedValueEvi @t changed this line in version 2 of the diff
added 1 commit
- 3718da4f - fixup! [#856 (closed)] Add Lorentz emit instructions
marked this merge request as draft from 3718da4f
added 7 commits
-
3718da4f...235c6a6e - 5 commits from branch
master
- a8e31575 - [#856 (closed)] Add Lorentz emit instructions
- 542a0d89 - [Chore] Update changelog
-
3718da4f...235c6a6e - 5 commits from branch
enabled an automatic merge when the pipeline for 542a0d89 succeeds
mentioned in commit d22607fb