amusingaxl
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # [DRAFT] Proposal for a New Spell Architecture at MakerDAO ``` Author(s): @amusingaxl Contributors: ``` ## Motivation Spell crafting is one of the most challenging aspects in MakerDAO. Currently spells take the form of monolithic smart contracts. Depending on the contents of the Executive Spell of a given week, they can become huge pieces of **unaudited code** with **root access** to the Maker Protocol. In other words, every week MakerDAO contributors produce a new smart contract that can brick the entire system in case there is a bug. To prevent catastrophic failures, spell crafting is a **very** resource intensive task. There is always an engineer responsible for the crafting the spell (most of the time a Protocol Engineering member), but other members or teams might required to collaborate on the same spell. Different people collaborating on the same handful of source code files usually leads to **merge conflicts**, which can be bad productivity sinkholes. After the spell is considered ready, it needs to be reviewed by at least 2 different engineers, which are required to go through [several checklists]([https://](https://github.com/makerdao/pe-checklists/tree/master/spell)) manually to see if nothing was missed. During review there can still be some back and forth regarding the exact content. Finally once everyone involved agrees on the spell code, it need to be deployed, verified and then scheduled for execution. While the herculean efforts of the teams involved, especially GovAlpha and Protocol Engineering, have brought us this far without major problems, the [Law of Large Numbers](https://https://en.wikipedia.org/wiki/Law_of_large_numbers) is not on our favor here. With the upcoming changes related to the End Game™ and the need of having more teams from the broader Maker ecosystem being able to make changes to the Maker Protocol and also to SubDAOs, the current process can be seen as not scalable, as it is expensive and error prone. ## The Status Quo Currently the MCD Governance Module has 3 major on-chain components: - **Chief**: (a.k.a. `MCD_ADM`) a `DSChief` contract that handles the "election" of a _spell_. - **Pause**: (a.k.a `MCD_PAUSE`) a `DSPause` contract that handles the execution of a _spell_ through a `delegatecall` after an enforced delay. - **Spell**: a bespoke un-owned contract that encapsulates actions to be performed within the Maker Protocol. Source: [MakerDAO Docs](https://docs.makerdao.com/smart-contract-modules/governance-module). Before any spell is written, the process starts with [Governance Polls](https://vote.makerdao.com/polling), that serves as a signaling mechanism for proposals. Polls have a limited duration and if they receive enough support, they can be selected A spell that has the most MKR support in the **Chief** at a given time can be permissionlessly `lift`ed to receive the `hat`. Once it gets the hat, the spell can be `schedule`d and, after the **governance delay**, it can be `cast` (executed). After being cast, the spell is marked as `done` to prevent replay attacks. MKR holders express their support for spells on-chain through the `vote` methods from the **Chief** contract. The support is weighted by the amount of MKR the holder has locked into the **Chief**. The [current **Chief** contract](https://etherscan.io/address/0x0a3f6849f78076aefadf113f5bed87720274ddc0#readContract#F3) allows each holder to support up to 5 different spells at once with all their MKR, meaning they do not have to split their MKR among the different spells. One interesting property of such system is that in case a MKR holder does not want to support a new spell, they can simply leave their MKR bound to another old, but already executed spell that they previously voted for. Inertia in this case is in favor of not making changes to the protocol. In case a bad spell ends up with the hat, be it because of a governance attack or due to a bug in the spell being discovered only after it has been `schedule`d, Maker Governance can act to `drop` it during the governance delay. To make this task easier, one can leverage tools like [`protego`](https://github.com/makerdao/protego), which can be `lift`ed to receive the `hat` and used to permissionlessly `drop` such spell. ... TODO ... ## Wishlist Below are some ideas for a new mechanism for making changes to the Maker Protocol that is less reliant on central parties, such as core unit members. The idea is inline with the goals of the End Game™. ### Spell Crafting - Common operations within the protocol can captured into **"primitives"**. - Currently the jargon used is _spell actions_, but to keep within the spirit of the weird names, we could call them something like **_potions_**. - Each _potion_ is a well defined action (or set thereof) to be performed within the protocol. - Examples of _potion_: "Onboarding a new type of collateral", "Paying a delegate", "Modifying the debt ceiling of a collateral", etc. - Each _potion_ has a clear effect in the overall state of the protocol that can be asserted, preferably in an automated fashion. - Common types of _potions_ should have well-known **factory** contracts that can receive all required parameters and produce a valid smart contract that can later be incorporated into a spell. - There should be a UI connected to the common potion factory contracts to allow non-technical people to create them. - Primitives ("potions") are bundled together as a spell. - A set of potions executed atomically would compose a spell. - Ideally a spell should be a [commutative Monoid](https://encyclopediaofmath.org/wiki/Monoid) over potions, meaning that: 1. Potions can be arbitrarily grouped 2-by-2 for execution (associativity). 2. There exists an _identity_ potion (identity). 3. The order of execution of different potions does not matter (commutativity). - Informally this means that potions should ideally be independent among themselves. - Potions can be executed in any order. If a potion depends on the result of a different potion, it means that the set of operations composing them should be grouped into a single one. - A spell can be a simple contract that simply iterates over and executes its potions. - There should be a UI that allows non-technical people to bundle potions into a spell. - Spells should be atomic. - If any of the potions fail to execute, the entire spell must revert. - Potions should be self-contained and predictable. - The pre and post-conditions for each individual potion must be clearly defined. - There should be enough safe-guards around potions (maybe a "base" potion from which the other ones are derived) to avoid common pitfalls. - Potions do not "leak" to other potions, meaning they can be independently tested at any time. - One instance where this might be harder than it sounds: two independent potions are to increase the debt ceiling of two unrelated collateral types. Debt ceiling increase can or cannot also increase the global debt ceiling. - Potion test should not be coded with absolute debt ceilings in mind, but ensuring that the global debt ceiling changes by the expected amount after the potion execution. ### Spell Voting - Anyone should be allowed to submit a spell for voting. - Currently there is a spell whitelist controlled centrally by GovAlpha. - To prevent spamming and other malicious activities, the spell **_bundler_** must commit assets to it (i.e.: stake some MKR to back the bundle). - If the spell is correct and reflects the expected output, the _bundler_ receive their stake back plus some reward from the protocol. - There must be a time window through which anyone can "challenge" a spell by providing an competing spell after commiting assets to it. - If there is a challenge, the dispute must be solved: - By some sort of committee composed of reputable and knowledgeable members of the Maker Community that can decide which competing spell is the correct one. - By outsourcing decision to some specialized on-chain dispute resolution mechanism such as [Kleros](https://kleros.io/) or [Aragon](https://court.aragon.org/). - The decision should **not** be based on a staking war (i.e.: the most voted spell wins), but from a technical perspective relative to the outcome of the polls that have already been voted. - This is important to prevent reverting decisions that has already been made (i.e.: someone dislikes the result of a poll and decides to bring more MKR to the table to revert it before execution). - In case of competing spells, the winner bundler receives their stake back plus all other competing bundlers' stake plus some reward from the protocol. - This provides the right cryptoeconomic incentives to bundlers. If they misbehave, most likely they will lose money. - Submit a bad spell? Someone will challenge it and get your stake. - Challenge a good spell? The original bundler get your stake. - The amount to required be staked when creating a spell is something that should be defined through some cryptoeconomic model. - If it is too low, it will not succeed preventing spams and malicious activity. - If it is too high, people will not be incentivized to create spells. - Opposed to the current fluid spell supporting mechanism, the spell staking needs to be time-bound and immutable during that time frame to work properly. - Effectively this would turn Governance Polls into the primary governance driver, while the spell staking mechanism would enforce that the decisions that have been made previously are honored. - Executive Votes as they exist today would probably be superfluous. ### Spell Execution ... TODO ...

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully