Prysmatic Labs
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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
    • 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 Help
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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
    # Weak Subjectivity: implementation roadmap ###### tags: `weak subjectivity` **Author(s):** Victor Farazdagi (Prysmatic Labs) *Last Updated: Apr 17, 2021* [TOC] ## Overview This roadmap outlines the tasks we need to complete to support WS as outlined in [specs](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/weak-subjectivity.md). This is a follow-up document to [Weak subjectivity todos before mainnet](/scB0xoCjRjaHM13Cf7wp5w?view) by Terence and parts of the whole of this document will become a GH tracking issue for the topic of Weak Subjectivity. ## Current state of affairs - We've introduced an RPC endpoint to obtain block and state roots + epoch in [PR #7216](https://github.com/prysmaticlabs/prysm/pull/7216). It exposes `GetWeakSubjectivityCheckpoint()` function. - In the `PR #7216` WS period calculations have been implemented in [slot_epoch.go:WeakSubjectivityCheckptEpoch()](https://github.com/prysmaticlabs/prysm/blob/0b06c48ed0196f2bea2df7a59013c5a95e55b7fc/beacon-chain/core/helpers/slot_epoch.go#L203), however, calculations there are outdated, and the helper needs to be updated. - State embedding, when it comes to genesis state, has been implemented in [PR #8614](https://github.com/prysmaticlabs/prysm/pull/8614). We need to make sure that similar methods work for an arbitrary checkpoint state. :::info **Progress so far:** Item | Owner | URL | Status ------|------|------------|------- 1. Calculating weak subjectivity period | Victor | [PR#8695](https://github.com/prysmaticlabs/prysm/pull/8695) | done 2. Weak subjectivity sync using a checkpoint | Victor | TBA | in-progress 3. Weak subjectivity sync using a given state | Victor | TBA | in-progress 4. Checking if weak subjectivity checkpoint is stale | Victor | [PR#8706](https://github.com/prysmaticlabs/prysm/pull/8706) | done 5. Fetching historical blocks | To be assigned | TBA | N/A 6. Exposing weak subjectivity checkpoint via RPC endpoint | Victor | [PR#8707](https://github.com/prysmaticlabs/prysm/pull/8707) | done 7. Validate peers agains WS checkpoint | Victor | TBA | N/A ::: ## Tasks ### 1. Calculating weak subjectivity period For short-range attacks the canonical chain is protected by slashing mechanism. However, if a node stays offline for long enough, there may occur a situation when 1/3 of validators it knows about from the last sync have already exited (and have "nothing at stake"), but continue attesting, thus giving a probability of forming a chain with conflicting finalized states (exploiting retired validators and/or relying on diverging validator sets). The weak subjectivity period refers to number of recent epochs within which there must be a weak subjectivity checkpoint, to ensure that "nothing at stake" long-range attack is avoided. We need to update [slot_epoch.go:WeakSubjectivityCheckptEpoch()](https://github.com/prysmaticlabs/prysm/blob/0b06c48ed0196f2bea2df7a59013c5a95e55b7fc/beacon-chain/core/helpers/slot_epoch.go#L203) to comply with the current [specs](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/weak-subjectivity.md#calculating-the-weak-subjectivity-period). Owner | Link to PR | Status ------|------------|------- Victor | [PR #8695](https://github.com/prysmaticlabs/prysm/pull/8695) | done ### 2. Weak subjectivity sync using a checkpoint When CLI node is started with a weak subjectivity checkpoint in a `block_root:epoch_number` form, synchronization must take into account weak subjectivity requirements. There are two cases possible: - Checkpoint epoch is in the future (node's stored finalized epoch is lower than checkpoint epoch): during sync when node arrives at checkpoint epoch, and checkpoint root is not part of the chain, node must halt with a descriptive error. - Checkpoint epoch is in the past (node's stored finalized epoch is higher than checkpoint epoch): before proceeding with sync, node must assert that block root at checkpoint epoch of the canonical chain is equal to the provided root. Halt the node with descriptive error, otherwise. Owner | Link to PR | Status ------|------------|------- Victor | TBA | in-progress See [weak_subjectivity_checks.go:VerifyWeakSubjectivityRoot()](https://github.com/prysmaticlabs/prysm/blob/f822f0436e28d278a9cae7da00ea57d72a6be2bf/beacon-chain/blockchain/weak_subjectivity_checks.go#L15) and the corresponding [PR#7344](https://github.com/prysmaticlabs/prysm/pull/7344) ### 3. Weak subjectivity sync using a given state Variation of weak subjectivity sync, when SSZ state is provided at startup. Node should be able to start syncing from a given state. This will augment state embedding (should we opt for embedding when distributing weak subjectivity checkpoints) and allow feeding different states w/o binary recompilation. Owner | Link to PR | Status ------|------------|------- Victor | TBA | N/A ### 4. Checking if weak subjectivity checkpoint is stale To check that weak subjectivity checkpoint is not stale at the time of node startup (client either accepts state as input param, or fetches state for a specified checkpoint), the specs define [is_within_weak_subjectivity_period()](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/weak-subjectivity.md#checking-for-stale-weak-subjectivity-checkpoint). We need to support the corresponding helper method. Owner | Link to PR | Status ------|------------|------- Victor | [PR #8706](https://github.com/prysmaticlabs/prysm/pull/8706) | done ### 5. Fetching historical blocks When node is started from a given state -- there should be a mechanism that will allow it to fill the gap. Node may already contain part of canonical chain (up to some epoch) or be a new node (from genesis), and backfilling blocks in between should be possible (mandatory?). When backfilling blocks, we should allow end-users to select (with a CLI flag), whether they require to redo state transitions or just verifying block roots is enough. Owner | Link to PR | Status ------|------------|------- To be assigned | TBA | N/A ### 6. Exposing weak subjectivity checkpoint via RPC endpoint One way to distribute weak subjectivity checkpoints, is by exposing some RPC endpoint which can be used to obtain one. Currently, we do provide [GetWeakSubjectivityCheckpoint()](https://github.com/prysmaticlabs/prysm/blob/1c6c058bba13920598c69bf5346aa4e957bd0147/beacon-chain/rpc/beacon/blocks.go#L366) method, but it works incorrectly: it just provides a block root and epoch of the weak subjectivity period (where period is just a span within which there must exist weak subjctivity point). That's if weak subjectivity period is computed to be 752, our current endpoint will return the root of the starting slot of 752th epoch. The correct way to implement it, is to subtract weak subjectivity period from the currently known epoch, and assuming this will result in a positive number, use that epoch (or some epoch after that) as a weak subjectivity checkpoint. This is safe as weak subjectivity period, gives us range within which finalizing conflicting blocks will result in 1/3 of validators being slashed. Owner | Link to PR | Status ------|------------|------- Victor | [PR #8707](https://github.com/prysmaticlabs/prysm/pull/8707) | done ### 7. Validate peers agains WS checkpoint Consider decreasing scores of peers (or marking them as bad), when they return block with the root that doesn't match that of provided weak subjectivity checkpoint. Owner | Link to PR | Status ------|------------|------- Victor | TBA | N/A ## Implementation plan We'll start with support of checkpoints in form of `block_root:epoch_number` (items 1, 2 and 4). With syncing from state (item 3) following up shortly, then, allowing to back sync historical blocks (item 5). We will support distribution of weak subjectivity checkpoints using RPC endpoint (item 6). ## References - [Weak subjectivity todos before mainnet](/scB0xoCjRjaHM13Cf7wp5w?view) - [Specs](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/weak-subjectivity.md) and for a more in-depth of coverage of WS period calculations, see [Weak Subjectivity Analysis](https://github.com/runtimeverification/beacon-chain-verification/blob/master/weak-subjectivity/weak-subjectivity-analysis.pdf). - [Proof of Stake: How I Learned to Love Weak Subjectivity](https://blog.ethereum.org/2014/11/25/proof-stake-learned-love-weak-subjectivity/) - [Weak Subjectivity in Eth2.0](https://notes.ethereum.org/@adiasg/weak-subjectvity-eth2)

    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