Mark Nichols
    • 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
    # Block Proposals - Writeup We have been working on an exploratory project focused on adding a major new feature to Tezos -- something that we internally call "block proposals". The original idea for block proposals began as a way of realzing one of the goals of the Tezos architecture, that of allowing plugable consensus algorithms to be added to Tezos. We were also hoping that as a side effect, this project would provide our developer(s) a hands-on way to gain a deeper understanding of the Tezos codebase. In this document, we will first provide an explanation of the concept of block proposals, and then describe the steps we went throught and how ulitmately this work can be completed. *** ## Block proposals overview The purpose of 'block proposals' is to change the way Tezos decides which blocks will be added to the chain, with the goal of making Tezos a better fit for the way most modern consensus algorithms are defined. Consensus algorithms can then be adopted directly, without having to first rework them to fit Tezos' architecture (and without having to adapt any correctness proofs associated with the algorithms). The way Tezos currently works, a new block is chosen based on its fitness, and then all endorsements of the chosen block are bundled with the submission of the subsequent block. Block proposals, on the other hand, allows multiple blocks to be simultaneously proposed and endorsed, with the choice of the fittest block made only after sufficient votes/endorsements for the block have been received. With block proposals in place, a good number of modern consensus algorithms can be implemented within Tezos in a more direct, straight-forward way. *** ## Motivation Most modern consensus algorithms are formulated within a common overall structure. One node, usually called the leader, submits a potential block to be added to the chain. Other nodes vote their acceptance or rejection of the proposed block. Once sufficient 'yes' votes have been received, the block is added to the chain. Many details within the above pattern vary among the different algorithms: how leaders are chosen, what rules a voter follows for validation, the number of positive votes required, etc. What is, however, generally the same among these algorithms is the overall flow: > *A block is proposed --> > Nodes vote for or against the block --> > The block is accepted or rejected as the next block* The correctness proofs provided for each algorithm also generally depend (either explicitly or implicitly) on the above flow being followed. Without an extra feature such as block proposals added to Tezos, it is generally not possible to directly implement these algorithms in Tezos such that the validity of the correctness proofs can be assumed. There is no way to directly allow multiple candidate blocks to be proposed, with the choice of the 'winning' block postponed until after the votes (aka endorsements) have been received. Attempting to modify consensus algorithms to work directly with Tezos (i.e., in such a way that a single fittest block can be determined before voting is completed) can be difficult. Even if the algorithm can be adapted, proving that the modified algorithm has all the properties and guarantees of the original can also be demanding. ### Examples Some examples of consensus algorithms that follow the high-level pattern described above: [Tendermint](https://tendermint.com/) [PaLa](https://eprint.iacr.org/2018/981.pdf) [Streamlet](https://eprint.iacr.org/2020/088.pdf) [HotStuff](https://arxiv.org/abs/1803.05069) [Tangaroa](https://www.scs.stanford.edu/14au-cs244b/labs/projects/copeland_zhong.pdfk) At some point the state-of-the-art of these algorithms may improve significantly enough that upgrading from our current Tenderbake algorithm is indicated. Having block proposals in place will make this simpler and faster to accomplish. See [Appendix A](#Appendix-A:-Technical-Details) for further technical details about block proposals *** ### Where we left off We eventually decided to put this project on hold, leaving its completion to a future time or to another team. The biggest reason to not continue was coming to grips with the the amount of work required to maintain a working merge with the Tezos master branch. For our one-man team, the percentage of overhead was too great to make foward progress at a reasonable pace, and other priorities prevented us from adding more resources to this effort. With the sucess of Tezos' Tenderbake consensus, we also realized that block proposals was not going to be seen as the highest prioirty, and there was a relatively low chance of getting this merged into the main branch any time soon. See [Appendix B](#Appendix-B) for links to the codebase and details about what still needs to be implemented *** ## Appendix A: Technical Details *** ### Specification #### Implementation Overview: The following paragraphs provide a high level description of key aspects of the current POC implementation of the block proposal mechanism. A link to the current code can be found below in [Appendix B](#Appendix-B). * Block proposals are implemented similarly to blocks, with a key difference being that some amount of validation can be postponed until after the winning block has been selected. Determining what validation can be skipped at which point in the process is still a work in progress. Avoiding unnecessary validation processing is likely to be important to maintaining good performance. * Block proposals produce streams that can be watched, and events can be fired. This is implemented in the same way that streams of blocks are currently handled. * There is a block proposal voter process that is implemented similarly to the (now defunct) endorser process. This process listens for block proposals and triggers voting. * Block proposal votes are implemented as operations, very similar to endorsements. #### Additional details Much of the ways in which Tezos with block proposals will differ from current Tezos depends on the specific consensus algorithm that is chosen. Block proposals on its own will not change anything -- only when it is utilized by a consensus algorithm will the behavior change. Specifying the precise nature of leader selection, voting procedures, etc. cannot be done until such a choice is made. #### New Client commands: The following client commands will be added: * `propose` - Submit a new block proposal * `bake proposed` - Bake a proposed block. This specialized version of *bake* is only needed to keep the existing *bake* functionality unchanged. #### Misc Notes * The fitness function in Tezos can be implemented to choose the block with the most votes. A block with insufficient votes is invalid as per the specific consensus algorithm in use and should not be seen by the fitness function. * We can leave the full validation to the bakers when the block is finally produced. This would allow propagating this operation faster * We have needed to add new peer-to-peer messages, new types of requests, events, etc. * When used on mainnet, any consensus algorithm implemented using block proposals will still need to use the existing PoS mechanism for quorum selection and voting power. * For P2P, we will attempt to send the entire proposal 'header', rather than send just a hash that requires the receiver to then fetch the data #### Optional / related changes ##### Consensus API / library Block proposals are meant to work with one or more of the many published consensus algorithms. It should be possible to centralize the common code that is required by all such algorithms, and so design a consensus API such that multiple consensus algorithms can be implemented with minimal code duplication between them. This will allow rapid evaluation of new algorithms, and enable simpler experimentation for private chain use cases, etc. ##### Storing endorsements with the block they are endorsing One possible change that can be implemented along with block proposals is to store endorsements as part of the current block, rather than including them in the subsequent block. Putting the endorsements into the same block they are endorsing would make the block format a bit more intuitive. *** ### Rationale Design decisions made while building the POC reflect this set of requirements: #### Block Proposals: * require specific shell support * must have a priority higher than operations * must have guaranteed progress -- cannot be sent as 'best-effort' (e.g. the lossy manner in which operations are sent) * must have an accompanying `vote` operation, similar to endorsements * cannot be allowed to overwhelm validators. At a given time, only a few potential proposals should be valid. * must be able to be authenticated * must work with blacklisting (in the same way that blocks do) #### Block proposal validations must ensure that: * the proposal is signed * the operation can legitimately be emitted * dependencies are available #### The role of the baker is to: * receive block proposals * vote on block proposals * collect votes on block proposals * inject actual blocks when sufficient votes have been seen ### Development cost Though the cost of completing the block proposals code plus implementing an initial consensus algorithm will not be insignificant, the benefit of this approach should be fully realized when integrating a new consensus algorithm is desired. Adding a second algorithm should be markedly less effort then integrating another algorithm in the manner or Tenderbake. ### Alternatives to Block Proposals One alternative to implementing block proposals would be to research / prove some notion of equivalence between Tezos' fitness / endorsement process and the block selection process employed by one or more consensus algorithms. It might be possible to find a general equivalence between a class of consensus algorithms (as opposed to e.g., a Tenderbake-specific proof) *** ### Backwards Compatibility Most of the work for block proposals involves adding new features to the Tezos codebase that will not by executed by existing branches. For common features that need some modification (e.g. baking), the existing code will be left unchanged, as to avoid any unplanned impact. This will involve some small amount of code duplication - if desired it can be removed at a later date. ### Security Considerations As block proposals are meant to work with one of the published consensus algorithms, it is of course necessary to ensure that whatever algorithm is chosen meets the required security and reliability requirements for Tezos. We must also verify that blocks produced through an altered flow via block proposals still execute all the required validations. *** ## Appendix B Here is a [link to the repo](https://gitlab.com/oxheadalpha/tezos/-/tree/block-proposals-staging) for this project The most recent branch is `block-proposals-staging`, and the commit hash as of this writing is `9f71cbcb18473bcdb335ebfd611a45f7854a1b3f`. The commit hash for the state of the Tezos repo which was most recently merged into our code is `7146825c1524c7b227d41101b2fb8599999aec81` #### What still needs to be done * Complete the work on the voting operations, including verifying they can be properly received. * Change the existing fitness function to check that sufficient votes have been received. * The current baking rights behavior needs to be replaced - all bakers should be potential 'leaders', the choice of which is determined by the consensus algorithm. * Implemement an initital test consensus algorthim, and verify the full cycle of block proposal, voting, and baking the winning block works correctly and performs reasonalbly. * While attempting to emulate Tenderbake's 'pre-application' of blocks as a model for block proposal validation, a failure was introduced that still needs to be tracked down. #### Some categories of changes, files, etc. Overall, the diff shows x number of files changed, but here are some categories of files/changes to help make some sense of the picture: ##### New client commands * Create a block proposal *Command: "block-proposal-create for <baker-name>"* *[Link to the code:](https://gitlab.com/oxheadalpha/tezos/-/blob/block-proposals-staging/src/proto_alpha/lib_delegate/baking_commands.ml#L236)* * Bake a block proposal block *Command: "block-proposal-bake for <baker-name>"* *[Link to the code:](https://gitlab.com/oxheadalpha/tezos/-/blob/block-proposals-staging/src/proto_alpha/lib_delegate/baking_commands.ml#L259)* * Vote on a block proposal *Command: "block-proposal-vote for <baker-name>"* *[Link to the code:](https://gitlab.com/oxheadalpha/tezos/-/blob/block-proposals-staging/src/proto_alpha/lib_delegate/baking_commands.ml#L284)* ##### Block proposals voting * Primary source file: [link to the code:](https://gitlab.com/oxheadalpha/tezos/-/blob/block-proposals-staging/src/proto_alpha/lib_delegate/client_baking_votes.ml) * New block proposal vote operation type: [link to the code:](https://gitlab.com/oxheadalpha/tezos/-/blob/block-proposals-staging/src/proto_alpha/lib_protocol/operation_repr.ml#L56) * Running the voter daemon: [link to the code](https://gitlab.com/oxheadalpha/tezos/-/blob/block-proposals-staging/src/proto_alpha/lib_delegate/baking_commands.ml#L461) ##### RPC Handlers * Propse Block RPC definition: [link to the code](https://gitlab.com/oxheadalpha/tezos/-/blob/block-proposals-staging/src/lib_shell_services/block_services.ml#L842) * Block proposal monitoring RPC definition: [link to the code]() ##### Block proposal notifications * Requesting block proposal monitoring [link to code:](https://gitlab.com/oxheadalpha/tezos/-/blob/block-proposals-staging/src/proto_alpha/lib_delegate/client_baking_blocks.ml#L205) * Creating the stream of block proposals: [link to the code](https://gitlab.com/oxheadalpha/tezos/-/blob/block-proposals-staging/src/proto_alpha/lib_delegate/client_daemon.ml#L164) * Received a block proposal notification, begin voting: [link to the code:](https://gitlab.com/oxheadalpha/tezos/-/blob/block-proposals-staging/src/proto_alpha/lib_delegate/client_baking_votes.ml#L110)

    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