Skip to content

Superfluid Host Overview

Miao ZhiCheng edited this page Apr 28, 2022 · 13 revisions

Superfluid host contract (Superfluid.sol) is the central contract that provides the following functionalities in the Superfluid Framework:

Super Agreement

Key features:

  • Allow new agreement class to be whitelisted.
  • callAgreement (contextless + contextual).
  • IAgreementFramework:
    • for callbacks: callAppBeforeCallback, callAppAfterCallback, appCallbackPush, appCallbackPop
    • ctxUseAllowance: for app credit.
    • jailApp: for jail rules.

Design Points:

  • Agreement Whitelisting:

    • No choice.
  • Polymorphic agreement support:

    • No polymorphic approach: always add new entry functions for new agreement in host contract.
      • Pros: avoid duck tapes (hence type-safe)
      • Cons: more boiler plate.
    • callAgreement: duck tape "polymorphic" solution.
      • Pros: extremely flexible.
      • Cons: type-unsafe, may have security implications when handling calldata.
    • Better approach, e.g. "spec-haskell" type class, define AgreementOperation instances.
      • Pros: CORRECT WAY OF DOING THINGS.
      • Cons: not supported by dumb languages.
  • App Jail:

    • Main objective: make sure that agreement is always destructible.
    • Zero tolerance jail:fdd
      • assuming hostile app,
      • being over protective to users so that they don't continue to interact with the callbacks.

Super App

Key Features:

  • App Registry

    • Whitelisting modes:
      • registerAppWithKey
      • registerAppByFactory
      • [TODO] whitelistedDeployerWithExpirationDate
  • Composability:

    • App Level
    • Callbacks
    • App Credit
  • Ctx: transactional secure heap-memory in EVM

Design Points:

  • App Registry:

    • whitelisting: to be removed as soon as we feel fit.
  • Composability:

    • State Sync: Callbacks vs Async
    • App Credit:
      • objective: zero balance super app requirement for reasonable cases.
      • benchmark case: 1to1 flow forwarding.
    • App Level:
      • 1-level ~= global re-entrance protection

Extra Notes

  • function overload: use or not use?
  • function pointer: worth exploring a bit.
  • more usage of user types: worth exploring in the future.
  • generics: let's wait and see.
Clone this wiki locally