Skip to content

[#856] Implement EMIT and other Kathmandu changes

Nikolay Yakimov requested to merge lierdakil/#856-implement-emit into master

Note: this removes jakartanet tests because obviously can't test new features on an old network.

Discussion point: I've introduced transferWithEmit to Cleveland as a version of transfer returning a list of emitted events. There is another possible design point: have transfer be polymorphic in emit and force a "default" using an incoherent instance, e.g.

transfer :: forall emit addr r.
            ( HasCallStack
            , TransferFunc ('Incomplete (InitialTransferMode addr)) emit 'HasNoAmount r
            , ToL1Address addr
            , DefaultEmit emit )
         => addr -> r
transfer = transfer'r @_ @emit @'HasNoAmount . initialData @addr

class DefaultEmit (emit :: ReturnEmit)
instance {-# INCOHERENT #-} emit ~ 'DontReturnEmit => DefaultEmit emit
instance DefaultEmit 'ReturnEmit

In this case, if one wants to get the list of events, one would call transfer @'ReturnEmit (probably better rename it ReturnEvents, but you get the point). If this type variable is unspecified, it resolves to DontReturnEmit by incoherent instance resolution rules.

Not sure which is more ergonomic at the end of the day, but the version with the incoherent instance feels more hack-ish (and also requires -Wno-redundant-constraints)

Description

Problem: Kathmandu introduced EMIT instruction.

Solution: Add support for it.

See individual commits for more in-depth explanations.

TL;DR: grab a list of emitted events from transfer operations' internal_operation_results, clean those up and return from transferWithEmit. Not simply from transfer, because backwards compatibility, and I don't expect EMIT to be used particularly often.

Related issue(s)

Resolves #856 (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