Facundo Olano
    • 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
    • Engagement control
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control 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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # aleo-consensus fees, validator rewards and staking proposal 2022-12-27 NOTE: this was a design proposal which has already been implemented. Refer to the aleo-consensus README for up to date documentation. ## Current status / assumptions * We currently use the SnarkVM built-in credits program to create and transfer credits * The initial credits distribution is done at genesis. We already implemented support to set a list of initial records in the tendermint genesis file, which is loaded into the record store when a testnet is first started. * Further credits can be minted by nodes when blocks are proposed (see below) * An execution consists of a list of transitions. A transition is essentially a function calls with inputs, outputs and a proof. * In our current implementation, executions are a single function call and thus generate a single transition. There could be more if the function had nested functions or called imported programs, which we don't support right at the moment. * Part of execution generation in SnarkVM is to [calculate the transition fee](https://github.com/Entropy1729/snarkVM/blob/6f601cb1458b65e035f6d9043475cc543c8acfb1/vm/compiler/src/process/stack/execute.rs#L373) (inputs - outputs). * Part of execution validation in SnarkVM includes [verifying that executions don't mint new tokens](https://github.com/Entropy1729/snarkVM/blob/6f601cb1458b65e035f6d9043475cc543c8acfb1/vm/compiler/src/process/stack/execute.rs#L346) (inputs - outputs is non-negative) * We assume that when we switch from SnarkVM to EntropyVM, the credits and execution validations will continue to work with similar behavior ## Fees and validator rewards * Transaction fees are the sum of the fees of its transitions. * For executions, there will be an implicit fee in the difference of input and output credits. This difference will typically be zero, so a secondary transition can be included to force a difference to be payed as the fee. * For deployments there are no function calls, so fees need to be payed as well by including a separate credit-consuming transition. * The `credits` program in SnarkVM [already includes a 'fee' function](https://github.com/Entropy1729/aleo-consensus/blob/62c89cfa0b434018079d07b23711312910441dbb/aleo/credits.aleo#L45-L50) for this purpose. The function takes a record and subtracts credits from it. * In addition credits from transaction fees, a baseline amount of credits could be minted with each block. * The sum of the fees payed by all transactions and the baseline credits will be distributed among the validators according to some rule, for example: 50% for the block proposer and 50% for the subset of validators that voted for it, weighted by their voting power. * NOTE: the fees associated with each transition and with each block are public. This seems to be the same model as the current SnarkVM/SnarkOS implementation. In the future we could look into how zcash handles this in case we can make it privacy preserving. ### Implementation details * On our blockchain application, we will track a mapping between tendermint validator addresses and their aleo account addresses. * The `BeginBlock` tendermint hook includes the current block proposer address and the list of votes from the previous block (validator addresses and their voting power). We can use this to decide how to distribute the next round of rewards. * NOTE: with this approach we'd be rewarding voters from block H and proposer of block H+1 with the fees from H+1. We could workaround this if it becomes a problem. * Each time the `DeliverTx` hook is run for a transaction we calculate the fee as described above and add it to the current block rewards. * In the `Commit` hook we add the baseline credits to the collected fees and distribute the credits as described above, by generating new records owned by the validator aleo addresses. The records are then added as unspent in the record store. * **NOTE: this requires some way of producing the exact same record in all blockchain nodes (because all need to reach consensus about the reward records without explicit synchronization). To do this we need to figure out how to deterministically generate the same record nonce in all nodes using pseudo-randomness (sharing a seed at genesis, tracking a counter, deriving it from the block height, etc.). This pseudo-randomness would be exclusive to the records generated on-chain for rewards, the rest of the execution output records can still use proper randomness.** * NOTE: by default, fees won't affect transaction prioritization (they will run in the order they arrive regarldess of the fee). Different versions of tendermint have different features that can enable this feature. We started a discussion about this [in the tendermint repo](https://github.com/tendermint/tendermint/discussions/9772). Depending on what we find out we may just use an available feature or need to upgrade to a different tendermint version or implement the feature on our own. * We can update the `deploy` and `execute` functions in the CLI to accept a `--fee <gates>` argument. This could lookup available records owned by the current account, and call `credits/fee` as necessary to ensure the transaction pays the desired amount of credits to the blockchain. ## Staking * Tendermint has a voting power attribute that affects the weight of a validator's vote in the conensus algorithm. * Above we used this to weight the rewards assigned to each validator. * To implement staking we need some way of translating staked credits to tendermint voting power. Tendermint tracks the total voting power so we can just increase it proportionally to the staked credits. * By default, just as we distribute a default amount of credits at genesis, we can set a default validator power. * We can add `stake` an `unstake` functions to the credits program * The `stake` function consume credits from an input record and outputs staked voting power. * The `unstake` function consumes voting power and outputs records with credits. * Changes resulting from executions of these functions will be passed to tendermint to adjust the voting power of validators used in consensus. * These functions would executed directly by the validator account. A future improvement would be to allow other accounts to delegate stake to the validator. * For a second iteration we could consider setting up the validators to automatically stake their rewards. * NOTE: the voting power (and thus, the amount of credits staked/unstaked by an account) will be public. We could improve this in future versions for example by delegating/pooling staked credits (such that the total amount of staked credits is public but not the individual account contributions). ### Implementation details * These functions will need special treatment (like other functions of the credits program): unstake is allowed to execute even though it creates credits, but nodes will need to validate that the account has the amount of voting power used as input. * The blockchain application tracks voting power changes by stake/unstake executions in the `DeliverTx` hook, and applies them as `validator_updates` in the `EndBlock` hook. * By default, voting power updates in tendermint at hieght H will become effective in H+2. If we wanted, we could add some extra delay (e.g. need to stake for N blocks before voting power changes take effect).

    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