Gareth Davies
    • 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
    6
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: Snark Worker description: Details the role of the snark worker in the Mina protocol tags: mina, candidate --- # Snark Worker While [block producers](https://hackmd.io/@garethtdavies/BkFFd6pdD) create [blockchain proofs](#) that prove the validity of the current state of the blockchain, they do not certify the included individual transactions. Snark workers handle the task of creating these [transaction proofs](#). Offloading these transaction proofs from the block producer to snark workers means that the transaction proof generation may be parallelized, significantly improving the network's throughput. When a block producer generates a block, they may include transactions recently seen on the network and included in the [transaction pool](#). The block producer includes these transactions in the [staged ledger](#) via a data structure known as the [scan state](https://hackmd.io/@garethtdavies/rkHUda6uP). For each transaction they add to the scan state, the block producer must add an equivalent amount of completed snark work from the [snark pool](https://hackmd.io/gHjzytCLT0qRUIGojZfxNQ#Snark-Pool). The snark pool contains completed transaction proofs submitted by snark workers for transactions added by prior block producers. Snark workers charge a fee for generating these transaction proofs and are compensated by the block producers purchasing their completed snark work. A snark worker may charge any fee for the work they produce, but a block producer will (all things being equal) purchase the work required for the lowest fee. A snark worker does not need the full state to operate and can run as a standalone process when paired with a [snark coordinator](https://hackmd.io/gHjzytCLT0qRUIGojZfxNQ#Snark-Coordinator). :::success A snark worker is run by adding the `-set-snark-worker <PUBLIC_KEY>` option to the `coda daemon` command or via the CLI via `coda client set-snark-worker -address <PUBLIC_KEY>`. ::: ## Work Selection The snark work required is defined by the structure of the scan state. Newly added transactions from the block producer create pending work in the form of base transaction and merge transaction proofs. Snark work is delivered in a work package, usually containing two work ids (the exception is the final merge proof of a tree in the scan state where there is only a single work id). Work ids are combined as each transaction included in a block will require the equivalent of two proofs due to the base proof and multiple merge proofs required, and as such, snark work is purchased in equal quantity to transactions included in a block. In addition to any pending work that does not have an existing completed proof in the snark pool, a snark worker may choose work that they can complete for a lower fee. If they complete and broadcast the work before a block producer purchases it, this work will replace the higher fee work in the snark pool. The Mina [daemon](#) includes two work selection algorithms, _sequential_ and _random_. The sequential algorithm processes new pending work in the order required by the scan state, whereas the random work selection algorithm chooses work in random order. :::info Modify the work selection algorithm using the `--work-selection` option of the `coda daemon` command ::: ## Snark Pool The snark pool contains all the completed work submitted by snark workers. The pool only maintains the lowest fee for each work bundle as well as the public key of the prover. For example: ```json { "work_ids":[ 839740827, 702578095 ], "fee":"0.011", "prover":"B62qpEX1JXC7qNrC3bTwEEDU3UQGSE5DUVSenpmmLpLnNmwPDsLj8Jh" } ``` The work required to be purchased by the block producer is derived by the [scan state](#) structure, and work must be purchased in a defined order. If there is no available snark work to purchase for a required work id, then no transactions will be included in a block (including the coinbase transaction). Additionally, a block producer will not purchase unprofitable snark work, i.e., the block producer may forgo a coinbase reward rather than spend more on snark work than they would receive. Typically, transaction fees cover the fees paid for purchased snark work. All work received from other nodes is validated before it is added to the pool and is only added if the proof is valid, and it is the cheapest fee available. If invalid work is received from a peer, the sender is punished according to the [trust system](#). If work of an equal fee is submitted, the first seen work will remain in the pool and not be replaced. For nodes joining the network, the snark pool is rebroadcast via locally created diffs every five minutes on a fixed schedule. Each diff is re-broadcastable for fifty minutes from the time it was added. Once work has been included in a block, it remains in the snark pool for as long as it is referenced in the last `k` blocks of the scan state. After that time, the snark work is removed from the snark pool. :::info See the contents of the snark pool with the `coda advanced snark-pool-list` command. ::: ## Snark Coordinator A snark coordinator coordinates snark jobs among many snark workers. The coordinator is responsible for sending new work to the snark workers, ensuring they do not duplicate the same work. The snark workers communicate with the snark coordinator via RPC calls. New work is requested by a snark worker using the `get_work` RPC call. Completed work is submitted via the `submit_work` daemon RPC call. Once received, the coordinator broadcasts the completed work to the network. A snark coordinator is run by providing the `-run-snark-coordinator <PUBLICKEY>` option to the `coda daemon` command. All workers using the same coordinator will use the same public key. A standalone snark worker may be started using the `coda internal snark-worker` command by providing the `-daemon-address`, which is the client port of the daemon running the coordinator (default 8301).

    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